本文整理汇总了C++中INT_Enable函数的典型用法代码示例。如果您正苦于以下问题:C++ INT_Enable函数的具体用法?C++ INT_Enable怎么用?C++ INT_Enable使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了INT_Enable函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//--------------------------------------------------------------------------------
int main(void) {
/* Init System Timer to fire interrupts at 1ms - timer tick */
OCR0 = 125; // set output compare match register, timer tick 1ms
TCCR0 = (1 << WGM01) + (1 << CS02) + (1 << CS00); //clear on compare match mode, Fclk/128
TIMSK |= (1 << OCIE0); // enable output compare 2 interrupt
TCNT0 = 0x00; // clear timer2 register
uSMARTX_Init(uSmartXTaskTable);
/* Append timeout trigger function. The trigger function will be executed after
* there is no write/read access if the buffer contains some unread data.
*/
BUF_AppendToutFxn(&BUF, 10 /*10 ms*/, &TimeoutFxn);
/* Append level trigger function. The trigger function will be executed after
* the buffer fills to a level of 4. The function will be re-triggered after the
* buffer is completely emptied out.
*/
BUF_AppendTrgFxn(&BUF, 4, &TriggerFxn);
/* Enable interrupts. */
INT_Enable();
while(1) {
if(uSMARTX_Scheduler() == SYS_ERROR)
break;
}
/* Handle error here. */
return 0;
}
示例2: service_net
void
service_net ()
{
while (interrupts > 0)
{
NRF_CE_lo;
uint8_t status = NRF_ReadRegister(NRF_STATUS);
RXEN_lo;
// received a packet
if (status & 0x40)
{
printf("Radio received a packet\n");
readPacket();
} else if (status & 0x20)
{ // packet was sent
printf("Radio successfully sent the packet\n");
NRF_WriteRegister(NRF_STATUS, 0x10);
} else if (status & 0x10)
{ // packet failed to send
printf("Radio failed to send the packet\n");
NRF_WriteRegister(NRF_STATUS, 0x20);
}
RXEN_hi;
NRF_CE_hi;
INT_Disable();
interrupts--;
INT_Enable();
}
}
示例3: sleepUntilDmaDone
/**************************************************************************//**
* @brief Sleep in EM1 until DMA transfer is done
*****************************************************************************/
void sleepUntilDmaDone(void)
{
/* Enter EM1 while DMA transfer is active to save power. Note that
* interrupts are disabled to prevent the ISR from being triggered
* after checking the transferActive flag, but before entering
* sleep. If this were to happen, there would be no interrupt to wake
* the core again and the MCU would be stuck in EM1. While the
* core is in sleep, pending interrupts will still wake up the
* core and the ISR will be triggered after interrupts are enabled
* again.
*/
bool isActive = false;
while(1)
{
INT_Disable();
isActive = spiDmaIsActive();
if ( isActive )
{
EMU_EnterEM1();
}
INT_Enable();
// Exit the loop if transfer has completed
if ( !isActive )
{
DPRINT("SPI DONE");
break;
}
}
}
示例4: RTCDRV_TimeRemaining
/***************************************************************************//**
* @brief
* Get time left before a given timer expires.
*
* @param[in] id The id of the timer to query.
*
* @param[out] timeRemaining Time left expressed in milliseconds.
* Only valid if return status is ECODE_EMDRV_RTCDRV_OK.
* @return
* @ref ECODE_EMDRV_RTCDRV_OK on [email protected]
* @ref ECODE_EMDRV_RTCDRV_ILLEGAL_TIMER_ID if id has an illegal value. @n
* @ref ECODE_EMDRV_RTCDRV_TIMER_NOT_ALLOCATED if the timer is not [email protected]
* @ref ECODE_EMDRV_RTCDRV_TIMER_NOT_RUNNING if the timer is not [email protected]
* @ref ECODE_EMDRV_RTCDRV_PARAM_ERROR if an invalid timeRemaining pointer
* was supplied.
******************************************************************************/
Ecode_t RTCDRV_TimeRemaining( RTCDRV_TimerID_t id, uint32_t *timeRemaining )
{
uint64_t tmp;
uint32_t timeLeft, currentCnt, lastRtcStart;
// Check if valid timer ID.
if ( id >= EMDRV_RTCDRV_NUM_TIMERS ) {
return ECODE_EMDRV_RTCDRV_ILLEGAL_TIMER_ID;
}
// Check pointer validity.
if ( timeRemaining == NULL ) {
return ECODE_EMDRV_RTCDRV_PARAM_ERROR;
}
INT_Disable();
// Check if timer is reserved.
if ( ! timer[ id ].allocated ) {
INT_Enable();
return ECODE_EMDRV_RTCDRV_TIMER_NOT_ALLOCATED;
}
// Check if timer is running.
if ( ! timer[ id ].running ) {
INT_Enable();
return ECODE_EMDRV_RTCDRV_TIMER_NOT_RUNNING;
}
timeLeft = timer[ id ].remaining;
currentCnt = RTC_COUNTERGET();
lastRtcStart = lastStart;
INT_Enable();
// Get number of RTC clock ticks elapsed since last RTC reschedule.
currentCnt = TIMEDIFF( currentCnt, lastRtcStart );
if ( currentCnt > timeLeft ) {
timeLeft = 0;
} else {
timeLeft -= currentCnt;
}
tmp = TICKS_TO_MSEC( timeLeft );
*timeRemaining = tmp;
return ECODE_EMDRV_RTCDRV_OK;
}
示例5: unblockSleepMode
/** Unblock the microcontroller from sleeping below a certain mode
*
* This will unblock sleep() from entering an energy mode below the one given.
* -- To be called by peripheral HAL's --
*
* This should be called after all transactions on a peripheral are done.
*/
void unblockSleepMode(sleepstate_enum minimumMode)
{
INT_Disable();
if(sleep_block_counter[minimumMode] > 0) {
sleep_block_counter[minimumMode]--;
}
INT_Enable();
}
示例6: RTCDRV_SetWallClock
/***************************************************************************//**
* @brief
* Set wallclock time.
*
* @param[in] secs Value to set (seconds).
*
* @return
* @ref ECODE_EMDRV_RTCDRV_OK
******************************************************************************/
Ecode_t RTCDRV_SetWallClock( uint32_t secs )
{
INT_Disable();
wallClockTime = secs;
wallClockInitTime = RTC_COUNTERGET();
INT_Enable();
return ECODE_EMDRV_RTCDRV_OK;
}
示例7: memoryTakeReference
void memoryTakeReference(void *handle)
{
INT_Disable();
if(memoryPtrFromHandle(handle) != NULL)
{
memoryObjs[(uint32_t)handle].refCount++;
}
INT_Enable();
}
示例8: memoryFree
void memoryFree(void *handle)
{
INT_Disable();
if(memoryPtrFromHandle(handle) != NULL)
{
memoryObjs[(uint32_t)handle].refCount--;
}
INT_Enable();
}
示例9: GPIOINT_CallbackRegister
/***************************************************************************//**
* @brief
* Registers user callback for given pin number.
*
* @details
* Use this function to register a callback which shall be called upon
* interrupt generated from given pin number (port is irrelevant). Interrupt
* itself must be configured externally. Function overwrites previously
* registered callback.
*
* @param[in] pin
* Pin number for the callback.
* @param[in] callbackPtr
* A pointer to callback function.
******************************************************************************/
void GPIOINT_CallbackRegister(uint8_t pin, GPIOINT_IrqCallbackPtr_t callbackPtr)
{
INT_Disable();
/* Dispatcher is used */
gpioCallbacks[pin] = callbackPtr;
INT_Enable();
}
示例10: RTCDRV_StopTimer
/***************************************************************************//**
* @brief
* Stop a given timer.
*
* @param[in] id The id of the timer to stop.
*
* @return
* @ref ECODE_EMDRV_RTCDRV_OK on [email protected]
* @ref ECODE_EMDRV_RTCDRV_ILLEGAL_TIMER_ID if id has an illegal value. @n
* @ref ECODE_EMDRV_RTCDRV_TIMER_NOT_ALLOCATED if the timer is not reserved.
******************************************************************************/
Ecode_t RTCDRV_StopTimer( RTCDRV_TimerID_t id )
{
// Check if valid timer ID.
if ( id >= EMDRV_RTCDRV_NUM_TIMERS ) {
return ECODE_EMDRV_RTCDRV_ILLEGAL_TIMER_ID;
}
INT_Disable();
if ( ! timer[ id ].allocated ) {
INT_Enable();
return ECODE_EMDRV_RTCDRV_TIMER_NOT_ALLOCATED;
}
timer[ id ].running = false;
INT_Enable();
return ECODE_EMDRV_RTCDRV_OK;
}
示例11: DMADRV_Init
/***************************************************************************//**
* @brief
* Initialize DMADRV.
*
* @details
* The DMA hw is initialized.
*
* @return
* @ref ECODE_EMDRV_DMADRV_OK on success. On failure an appropriate
* DMADRV @ref Ecode_t is returned.
******************************************************************************/
Ecode_t DMADRV_Init( void )
{
int i;
#if defined( EMDRV_DMADRV_UDMA )
DMA_Init_TypeDef dmaInit;
#elif defined( EMDRV_DMADRV_LDMA )
LDMA_Init_t dmaInit = LDMA_INIT_DEFAULT;
dmaInit.ldmaInitCtrlNumFixed = EMDRV_DMADRV_DMA_CH_PRIORITY;
#endif
INT_Disable();
if ( initialized )
{
INT_Enable();
return ECODE_EMDRV_DMADRV_ALREADY_INITIALIZED;
}
initialized = true;
INT_Enable();
if ( EMDRV_DMADRV_DMA_IRQ_PRIORITY > 7 )
{
return ECODE_EMDRV_DMADRV_PARAM_ERROR;
}
for ( i=0; i < EMDRV_DMADRV_DMA_CH_COUNT; i++ )
{
chTable[ i ].allocated = false;
}
#if defined( EMDRV_DMADRV_UDMA )
NVIC_SetPriority( DMA_IRQn, EMDRV_DMADRV_DMA_IRQ_PRIORITY );
dmaInit.hprot = 0;
dmaInit.controlBlock = dmaControlBlock;
DMA_Init( &dmaInit );
#elif defined( EMDRV_DMADRV_LDMA )
dmaInit.ldmaInitIrqPriority = EMDRV_DMADRV_DMA_IRQ_PRIORITY;
LDMA_Init( &dmaInit );
#endif
return ECODE_EMDRV_DMADRV_OK;
}
示例12: COM_WriteString
Ecode_t COM_WriteString(COM_Port_t port, PGM_P string)
{
if (checkValidPort(port)==false)
{
return EMBER_ERR_FATAL;
}
uint8_t *fifohead= &comhandle[port]->txQueue->fifo[comhandle[port]->txQueue->head];
uint8_t length = 0;
uint8_t wraplength = 0;
while(*string != '\0') {
while (! getOutputFifoSpace(port, 0)) {};
INT_Disable();
FIFO_ENQUEUE(comhandle[port]->txQueue,*string,comhandle[port]->txsize);
INT_Enable();
string++;
length++;
// queue just wrapped
if (comhandle[port]->txQueue->head == 0)
{
// store first transmit length
wraplength = length;
// transmit chunk
if ( (port == COM_USART0) || (port == COM_USART1) || (port == COM_USART2) )
{
while(UARTDRV_Transmit(comhandle[port]->uarthandle, fifohead, wraplength, unloadTxBuffer) != EMBER_SUCCESS);
}
#ifdef COM_VCP_ENABLE
if (port == COM_VCP)
{
emDebugSendVuartMessage(comhandle[port]->txQueue->fifo, comhandle[port]->txsize);
dequeueFifoBuffer(port, comhandle[port]->txsize);
}
#endif //COM_VCP_ENABLE
// move fifohead back to start
fifohead = comhandle[port]->txQueue->fifo;
}
}
if ( length > wraplength)
{
if ( (port == COM_USART0) || (port == COM_USART1) || (port == COM_USART2) )
{
while(UARTDRV_Transmit(comhandle[port]->uarthandle, fifohead, length - wraplength, unloadTxBuffer) != EMBER_SUCCESS);
}
#ifdef COM_VCP_ENABLE
if (port == COM_VCP)
{
emDebugSendVuartMessage(comhandle[port]->txQueue->fifo, comhandle[port]->txsize);
dequeueFifoBuffer(port, comhandle[port]->txsize);
}
#endif //COM_VCP_ENABLE
}
return EMBER_SUCCESS;
}
示例13: TIMER1_IRQHandler
/**
* \brief Timer1 interrupt handler.
*/
void TIMER1_IRQHandler()
{
uint32_t flags;
INT_Disable();
flags = TIMER_IntGet( TIMER1 );
_hal_tcCb();
TIMER_IntClear( TIMER1, flags );
INT_Enable();
}
示例14: buf_read_byte
bool buf_read_byte(buf_t *buf, uint8_t *data)
{
if (buf->count == 0)
return false; // no data
*data = buf->data[buf->read_idx++];
if (buf->read_idx >= buf->size)
buf->read_idx = 0;
INT_Disable();
buf->count--;
INT_Enable();
return true;
}
示例15: buf_write_byte
bool buf_write_byte(buf_t *buf, const uint8_t data)
{
if (buf->count >= buf->size)
return false; // no room
buf->data[buf->write_idx++] = data;
if (buf->write_idx >= buf->size)
buf->write_idx = 0;
INT_Disable();
buf->count++;
INT_Enable();
return true;
}