示例#1
0
/*FUNCTION*-------------------------------------------------------------------
*
* Function Name    : _bsp_btnled_init
* Returned Value   : HMI_CLIENT_STRUCT_PTR for success, NULL for failure
* Comments         :
*    This function performs BSP-specific initialization related to HMI.
*    It installs interrupts for TSS and initializes btnled client with
*    default providers.
*END*----------------------------------------------------------------------*/
HMI_CLIENT_STRUCT_PTR _bsp_btnled_init(void)
{
    
    _int_install_isr(INT_TSI0, TSS_TSI0Isr, NULL);    /* Install and then enable TSI0 Isr */
    _bsp_int_init(INT_TSI0, BSP_TSI_INT_LEVEL, 0, TRUE);
    _bsp_int_enable(INT_TSI0);

    _bsp_tss_io_init();                                 /* TSI init */
    hmi_tss_init(hmi_system_control_kinetis);           /* TSS init */

    /* BTNLED initialization */
    hmi_btnled_handle_ptr = btnled_init();
    if(hmi_btnled_handle_ptr == NULL)
    {
        return NULL;    /* BTNLED not initialized */
    }

    /* providers init - only providers available on board */
    hmi_twrpi_provider_lwgpio_ptr = hmi_lwgpio_provider_init(hmi_init_table_lwgpio);    /* LWGPIO */
    hmi_twrpi_provider_keypad_ptr = hmi_tss_keypad_provider_init(hmi_init_table_tss_twrpi_void, 0);  /* TSS Keypad - C0_TYPE */   

    /* add providers to the btnled table */
    if (!hmi_add_provider(hmi_btnled_handle_ptr, hmi_twrpi_provider_keypad_ptr) || !hmi_add_provider(hmi_btnled_handle_ptr,hmi_twrpi_provider_lwgpio_ptr))
    {
        return NULL;    /* provider's addition to the client's table failed */
    }
    return hmi_btnled_handle_ptr;
}
示例#2
0
_mqx_int _mtim16_timer_install_kernel
(
		/* [IN] the timer to initialize */
		uint8_t    timer,

		/* [IN] ticks per second */
		uint32_t   tickfreq,

		/* [IN] input clock speed in Hz */
		uint32_t   clk,

	    /* [IN] interrupt priority */
	    uint32_t priority,

		/* [IN] unmask the timer after installation */
		bool   unmask_timer
)
{
    uint32_t result;
    uint32_t period;
    _mqx_uint vector = _bsp_get_mtim16_vector(timer);

    if (vector == 0)
    {
        return MQX_INVALID_DEVICE;
    }

    _bsp_int_disable(vector);

    /* Set up tick timer */
    period = _mtim16_timer_init(timer, tickfreq, clk, FALSE);

    /* Install the timer interrupt handler */
    if (_int_install_isr(vector, _mtim16_kernel_isr, NULL) == NULL)
	{
		return MQX_TIMER_ISR_INSTALL_FAIL;
	}

    /* Initialize the timer interrupt */
    _time_set_timer_vector(_bsp_get_mtim16_vector(timer));
    _time_set_hwtick_function(_mtim16_get_hwticks, (void *) timer);
    _time_set_hwticks_per_tick(period);
    _time_set_ticks_per_sec(tickfreq);

    _bsp_int_init(vector, priority, 0, TRUE);
    
    _bsp_int_enable(vector);

    if (unmask_timer) {
    	_mtim16_unmask_int(timer);
    }

    return MQX_OK;

}
示例#3
0
_mqx_int _mtim16_timer_install
(
  /* [IN] the timer to initialize */
  uint8_t    timer,

  /* [IN] ticks per second */
  uint32_t   tickfreq,

  /* [IN] input clock speed in Hz */
  uint32_t   clk,

  /* [IN] interrupt priority */
  uint32_t priority,

  INT_ISR_FPTR isr_ptr,
    
  /* [IN] unmask the timer after installation */
  bool   unmask_timer
)
{
    uint32_t result;
    _mqx_uint vector = _bsp_get_mtim16_vector(timer);

    if (vector == 0)
    {
        return MQX_INVALID_DEVICE;
    }

    _bsp_int_disable(vector);

    /* Set up tick timer */
    _mtim16_timer_init(timer, tickfreq, clk, FALSE);

    /* Install the timer interrupt handler */
    if (_int_install_isr(vector, isr_ptr, NULL) == NULL)
	{
		return MQX_TIMER_ISR_INSTALL_FAIL;
	}

    _bsp_int_init(vector, priority, 0, TRUE);
    
    _bsp_int_enable(vector);

    if (unmask_timer) {
    	_mtim16_unmask_int(timer);
    }
    
    return MQX_OK;
}
uint32_t _ki2c_int_tx
   (
      /* [IN] the address of the device specific information */
      IO_I2C_INT_DEVICE_STRUCT_PTR int_io_dev_ptr,

      /* [IN] The array characters are to be read from */
      unsigned char                    *buffer,
      
      /* [IN] number of bytes to output */
      uint32_t                      length
   )
{ /* Body */
   VKI2C_INFO_STRUCT_PTR           io_info_ptr;
   I2C_MemMapPtr                   i2c_ptr;   
   uint32_t                        tmp;
   
   io_info_ptr  = int_io_dev_ptr->DEV_INFO_PTR;
   i2c_ptr = io_info_ptr->I2C_PTR;

   /* Critical section + avoiding spurious interrupt */
   _int_disable ();
   _bsp_int_disable (io_info_ptr->VECTOR);
   _int_enable ();
   
   /* If beginning of transmission, set state and send address (master only) */
   io_info_ptr->OPERATION &= (~ I2C_OPERATION_READ);
   io_info_ptr->TX_BUFFER      = buffer;
   io_info_ptr->TX_BUFFER_SIZE = length;
   io_info_ptr->TX_INDEX       = 0;
   
   tmp = io_info_ptr->STATE;
   if (I2C_MODE_MASTER == io_info_ptr->MODE)
   {
      if ((I2C_STATE_READY == tmp) || (I2C_STATE_REPEATED_START == tmp))
      {
         i2c_ptr->C1 |= I2C_C1_TX_MASK;
         i2c_ptr->S |= I2C_S_IICIF_MASK;
         if (I2C_STATE_REPEATED_START == tmp)
         {
            i2c_ptr->C1 |= I2C_C1_RSTA_MASK;
         }
         else
         {
            i2c_ptr->C1 |= I2C_C1_MST_MASK;
         }
         io_info_ptr->OPERATION |= I2C_OPERATION_STARTED;
         i2c_ptr->D = (io_info_ptr->ADDRESSEE << 1) | I2C_OPERATION_WRITE;
         io_info_ptr->STATISTICS.TX_PACKETS++;
      }
      else if(I2C_STATE_TRANSMIT == tmp)
      {
         if(length != 0)
         {
            /* send first byte */
            i2c_ptr->D = io_info_ptr->TX_BUFFER[io_info_ptr->TX_INDEX++];   /*  transmit data */
            io_info_ptr->STATISTICS.TX_PACKETS++;
         }
         else
            return 0;
      }
   }

   /* Interrupt enable - end of critical section */
   _bsp_int_enable (io_info_ptr->VECTOR);
   
   /* Wait for tx complite */
   _lwsem_wait((LWSEM_STRUCT_PTR)(&(io_info_ptr->LWSEM)));

   return io_info_ptr->TX_INDEX;

} /* Endbody */