Ejemplo n.º 1
0
/***********************************************************************************
* @fn      halRfRxInterruptConfig
*
* @brief   Configure RX interrupt.
*
* @param   none
*
* @return  none
*/
void halRfRxInterruptConfig(ISR_FUNC_PTR pf)
{
    uint8 x;
    HAL_INT_LOCK(x);
    pfISR= pf;
    HAL_INT_UNLOCK(x);
}
Ejemplo n.º 2
0
/***********************************************************************************
* @fn      halJoystickIntConnect
*
* @brief   Connect isr for joystick move interrupt. The parameter event tells for
*          which joystick direction this isr should be called.
*
* @param   event - Joystick direction
*          func - Pointer to function to connect
*
* @return  none
*/
uint8 halJoystickIntConnect(uint8 event, ISR_FUNC_PTR func)
{
    istate_t key;
    HAL_INT_LOCK(key);
    switch(event) {
    case HAL_JOYSTICK_EVT_UP:
        joystick_isr_tbl[HAL_JOYSTICK_EVT_UP] = func;
        break;
    case HAL_JOYSTICK_EVT_DOWN:
        joystick_isr_tbl[HAL_JOYSTICK_EVT_DOWN] = func;
        break;
    case HAL_JOYSTICK_EVT_LEFT:
        joystick_isr_tbl[HAL_JOYSTICK_EVT_LEFT] = func;
        break;
    case HAL_JOYSTICK_EVT_RIGHT:
        joystick_isr_tbl[HAL_JOYSTICK_EVT_RIGHT] = func;
        break;
    case HAL_JOYSTICK_EVT_PUSHED:
        joystick_isr_tbl[HAL_JOYSTICK_EVT_PUSHED] = func;
        break;
    default:
        HAL_INT_UNLOCK(key); return FAILED;
    }
    HAL_INT_UNLOCK(key);
    return SUCCESS;
}
Ejemplo n.º 3
0
/***********************************************************************************
* @fn      halTimer32kIntConnect
*
* @brief   Connect function to timer interrupt
*
* @param   ISR_FUNC_PTR isr - pointer to function
*
* @return  none
*/
void halTimer32kIntConnect(ISR_FUNC_PTR isr)
{
    istate_t key;
    HAL_INT_LOCK(key);
    fptr = isr;
    HAL_INT_UNLOCK(key);
}
Ejemplo n.º 4
0
/**************************************************************************************************
 * @fn      HalKeyIntConnect
 *
 * @brief   
 *
 * @param   none
 *
 * @return  None
 **************************************************************************************************/
uint8 HalKeyIntConnect(uint8 event, EVT_FUNC_PTR func)
{
	istate_t key;
	HAL_INT_LOCK(key);

	switch(event) 
	{
	    case HAL_KEY_EVENT_DOWN:
		key_event_tbl[HAL_KEY_EVENT_DOWN] = func;
		break;
	    case HAL_KEY_EVENT_UP:
		key_event_tbl[HAL_KEY_EVENT_UP] = func;
		break;
            case HAL_KEY_EVENT_SHORT:
		key_event_tbl[HAL_KEY_EVENT_SHORT] = func;
                break;
	    case HAL_KEY_EVENT_LONG:
		key_event_tbl[HAL_KEY_EVENT_LONG] = func;
                break;
	    default:
		HAL_INT_UNLOCK(key); return FAILURE;
	}
	HAL_INT_UNLOCK(key);
	return SUCCESS;
}
Ejemplo n.º 5
0
/***********************************************************************************
 * @fn          halTimer32kIntEnable
 *
 * @brief       Enable 32KHz timer interrupt on compare latch 0
 *
 * input parameters
 *
 * output parameters
 *
 * @return      none
 */
void halTimer32kIntEnable(void)
{
  istate_t key;
  HAL_INT_LOCK(key);
  TB0CCTL0 |= CCIE;
  HAL_INT_UNLOCK(key);
}
Ejemplo n.º 6
0
//----------------------------------------------------------------------------------
//----------------------------------------------------------------------------------
uint8 halDigio2IntConnect(digio io, ISR_FUNC_PTR func)
{
    istate_t key;
    HAL_INT_LOCK(key);
    switch (io.port)
    {
        case 1: port1_isr_tbl[io.pin] = func; break;
        case 2: port2_isr_tbl[io.pin] = func; break;
        default: HAL_INT_UNLOCK(key); return(HAL_DIGIO_ERROR);
    }
    halDigio2IntClear(io);
    HAL_INT_UNLOCK(key);
    return(HAL_DIGIO_OK);
}
Ejemplo n.º 7
0
Archivo: hal_digio.c Proyecto: gxp/node
/***********************************************************************************
* @fn      halDigioIntConnect
*
* @brief   Connect function to IO interrupt
*
* @param   digioConfig* p - pointer to configuration structure for IO pin
*          ISR_FUNC_PTR func - pointer to function
*
* @return  uint8 - HAL_DIGIO_ERROR or HAL_DIGIO_OK
*/
uint8 halDigioIntConnect(const digioConfig *p, ISR_FUNC_PTR func)
{
    istate_t key;
    HAL_INT_LOCK(key);
    switch (p->port)
    {
    case 1: port1_isr_tbl[p->pin] = func; break;
    case 2: port2_isr_tbl[p->pin] = func; break;
    default: HAL_INT_UNLOCK(key); return(HAL_DIGIO_ERROR);
    }
    halDigioIntClear(p);
    HAL_INT_UNLOCK(key);
    return(HAL_DIGIO_OK);
}
Ejemplo n.º 8
0
/************************************************************************************
* @fn          rfIsr
*
* @brief       Interrupt service routine that handles RFPKTDONE interrupt.
*
* @param       none
*
* @return      none
*/
HAL_ISR_FUNCTION( rfIsr, RF_VECTOR )
{
    uint8 x;

    HAL_INT_LOCK(x);

    if( RFIRQF0 & IRQ_RXPKTDONE )
    {
        if(pfISR){
            (*pfISR)();                 // Execute the custom ISR
        }
        S1CON= 0;                   // Clear general RF interrupt flag
        RFIRQF0&= ~IRQ_RXPKTDONE;   // Clear RXPKTDONE interrupt
    }
    HAL_INT_UNLOCK(x);
}
Ejemplo n.º 9
0
/*******************************************************************************
 * @fn          halTimer32kRestart
 *
 * @brief       Restart timer B. The timer is first stopped, then restarted,
 *              counting up from 0
 *
 * input parameters
 *
 * output parameters
 *
 * @return      none
 */
void halTimer32kRestart(void)
{
  istate_t key;
  HAL_INT_LOCK(key);
  /* - Stopping the timer in case it's running
   * - Clears & disables Timer B TBIFG interrupts and all compare latch interrups
   * - Resets TB0R(the counter)
   */
  TB0CTL = 0;
  /* Avoid compiler optimization (skipping the line above) */
  asm(" nop");
  TB0CTL = TBCLR;
  TB0CCTL0 = 0;
  asm(" nop");
  TB0CTL = mode;
  HAL_INT_UNLOCK(key);
}
Ejemplo n.º 10
0
Archivo: hal_rf.c Proyecto: gxp/node
/************************************************************************************
 * @fn          macMcuRfIsr
 *
 * @brief       Interrupt service routine that handles FIFOP interrupts.
 *
 * @param       none
 *
 * @return      none
 */
HAL_ISR_FUNCTION( macMcuRfIsr, RF_VECTOR )
{
    uint8 rfim;
    uint8 x;

    HAL_INT_LOCK(x);

    rfim = RFIM;

    if ((RFIF & IRQ_FIFOP) & rfim)
    {
        (pfISR)();                  // Execute the custom ISR
        S1CON= 0;
        RFIF&= ~IRQ_FIFOP;
    }
    HAL_INT_UNLOCK(x);
}
Ejemplo n.º 11
0
/*******************************************************************************
 * @fn          halTimer32kInit
 *
 * @brief       Set up timer B to periodically count upwards specified cycles
 *              of 32768 Hz clock without generating an interrupt using compare
 *              latch 0.  To enable an interrupt:
 *               - Before calling this function, connect an ISR to the interrupt
 *                 vector using halTimer32kIntConnect(ISR_FUNC_PTR isr) if not
 *                 allready done.
 *               - Call this function to set the periodical number of 32768 Hz
 *                 cycles to count.
 *               - Call halTimer32kIntEnable()
 *
 * input parameters
 *
 * @param       cycles  - Number of cycles between interrupt
 *
 * output parameters
 *
 * @return      none
 */
void halTimer32kInit(uint16 cycles)
{
  /* Blocking interrupts when configuring timer */
  istate_t key;
  HAL_INT_LOCK(key);
  /* - Stopping the timer in case it's running
   * - Clears & disables Timer B TBIFG interrupts and all compare latch interrups
   * - Resets TB0R(the counter)
   */
  TB0CTL = 0;
  /* Avoid compiler optimization (skipping the line above) */
  asm(" nop");
  TB0CTL = TBCLR;


  /* Setting up TB0CCTL0( capture/compare control register
   * - Compare mode
   * - Clear interrupt pending flag and disable interrupt on comapre latch 0
   * - TB0CL0 loads immediately when writing TB0CCR0
   * -
   */
  TB0CCTL0 = 0;

  /* Set compare value in the TB0CCR0 register */
  TB0CCR0 = cycles;

  /* Setting up the Timer B mode:
   * Timer source ACLK
   * 16 bit counter mode
   * Each TB0CLn latch loads independantly
   * Dont't divide input ACKL
   * Count up to TB0CCR0
   * Clear timer
   */
  mode = TBSSEL_1 | CNTL_0 | TBCLGRP_0 | ID_0 | MC_1 ;
  TB0CTL = mode;
  TB0EX0 = TBIDEX_0;
  HAL_INT_UNLOCK(key);
}
Ejemplo n.º 12
0
/**************************************************************************//**
* @brief    Turns global interrupts off and returns current interrupt state.
*           Should always be used together with halIntUnlock().
*
* @return   Returns the current interrupt state
******************************************************************************/
uint16 halIntLock(void)
{
    uint16 key;
    HAL_INT_LOCK(key);
    return(key);
}
Ejemplo n.º 13
0
/***********************************************************************************
* @fn      halIntLock
*
* @brief   Turns global interrupts off and returns current interrupt state.
*          Should always be used together with halIntUnlock().
*
* @param   none
*
* @return  uint16_t - current interrupt state
*/
uint16_t halIntLock(void)
{
    istate_t key;
    HAL_INT_LOCK( key );
    return key ;
}