コード例 #1
0
ファイル: ZottaOS_Atomic.c プロジェクト: beber007/zottaos
/* OSUINT16_SC: Same as OSUINT8_SC but applied to unsigned 16-bit integers. */
BOOL OSUINT16_SC(UINT16 *memory, UINT16 newValue)
{
  UINT16 state;
  state = _get_interrupt_state(); // Save interrupt enable bit value
  _disable_interrupts();
  if (_OSLLReserveBit) {          // Is the reservation still on?
     _OSLLReserveBit = FALSE;
     *memory = newValue;
     _set_interrupt_state(state); // Restore previous interrupt enable bit value
     return TRUE;
  }
  else {
     _set_interrupt_state(state); // Restore previous interrupt enable bit value
     return FALSE;
  }
} /* end of OSUINT16_SC */
コード例 #2
0
ファイル: Button.c プロジェクト: zaporozhets/ti_ezsdk_tools
/*
 *  ======== Button_disable ========
 *  Disable the specified buttons 
 */
Void Button_disable(Bits8 mask)
{
    unsigned short sr = _get_interrupt_state();
    _disable_interrupts();

    *(Bits8 *)Button_PORT_IE &= ~mask;

    _set_interrupt_state(sr);
}
コード例 #3
0
ファイル: Clock.c プロジェクト: zaporozhets/ti_ezsdk_tools
/*
 *  ======== Clock_wakeup ========
 */
Void Clock_wakeup()
{
    unsigned short sr = _get_interrupt_state();
    _disable_interrupts();

    Clock_TIMER->CCTL[0] |= CCIFG;

    _set_interrupt_state(sr);
}
コード例 #4
0
ファイル: ZottaOS_Atomic.c プロジェクト: beber007/zottaos
/* OSINT32_LL: Same as OSUINT32_LL but for signed integers. */
INT32 OSINT32_LL(INT32 *memory)
{
  INT32 tmp;
  UINT16 state;
  state = _get_interrupt_state(); // Save interrupt enable bit value
  _OSLLReserveBit = TRUE;         // Mark reserved
  _disable_interrupts();
  tmp = *memory;                  // Return the contents of the memory location
  _set_interrupt_state(state);    // Restore previous interrupt enable bit value
  return tmp;
} /* end of OSINT32_LL */
コード例 #5
0
ファイル: Button.c プロジェクト: zaporozhets/ti_ezsdk_tools
/*
 *  ======== Button_read ========
 *  Atomically read and clear the specified buttons
 */
Bits8 Button_read(Bits8 mask)
{
    Bits8 old;
    
    unsigned short sr = _get_interrupt_state();
    _disable_interrupts();

    old = *(Bits8 *)Button_PORT_IFG;
    *(Bits8 *)Button_PORT_IFG = old & ~mask;

    _set_interrupt_state(sr);

    return (old & mask);
}
コード例 #6
0
ファイル: Clock.c プロジェクト: zaporozhets/ti_ezsdk_tools
/*
 *  ======== Clock_sleep ========
 */
Void Clock_sleep(UInt16 usec, UInt lpm)
{
    unsigned short sr;
    
    /* compute the delay increment in clock ticks */
    unsigned int inc = (Clock_slowClockHz * usec + 500000L) / 1000000;
    if (inc == 0) {
        return;
    }
    
    /* atomically clear interrupt flag and set new compare value */
    sr = _get_interrupt_state();
    _disable_interrupts();
    Clock_TIMER->CCTL[0] &= ~CCIFG;             /* clear the interrupt flag */
    Clock_TIMER->CCR[0] = Clock_TIMER->R + inc; /* set new compare value */
    _set_interrupt_state(sr);

    /* loop until interrupt flag is set */
    while(!(Clock_TIMER->CCTL[0] & CCIFG)) {
        _bis_SR_register(lpm);
    }
}