本文整理匯總了C++中ENABLE_INTERRUPTS函數的典型用法代碼示例。如果您正苦於以下問題:C++ ENABLE_INTERRUPTS函數的具體用法?C++ ENABLE_INTERRUPTS怎麽用?C++ ENABLE_INTERRUPTS使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了ENABLE_INTERRUPTS函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: new
/**
\brief Request a new (free) packet buffer.
Component throughout the protocol stack can call this function is they want to
get a new packet buffer to start creating a new packet.
\note Once a packet has been allocated, it is up to the creator of the packet
to free it using the openqueue_freePacketBuffer() function.
\returns A pointer to the queue entry when it could be allocated, or NULL when
it could not be allocated (buffer full or not synchronized).
*/
OpenQueueEntry_t* openqueue_getFreePacketBuffer(uint8_t creator) {
uint8_t i;
INTERRUPT_DECLARATION();
DISABLE_INTERRUPTS();
// refuse to allocate if we're not in sync
if (ieee154e_isSynch()==FALSE && creator > COMPONENT_IEEE802154E){
ENABLE_INTERRUPTS();
return NULL;
}
// if you get here, I will try to allocate a buffer for you
// walk through queue and find free entry
for (i=0;i<QUEUELENGTH;i++) {
if (openqueue_vars.queue[i].owner==COMPONENT_NULL) {
openqueue_vars.queue[i].creator=creator;
openqueue_vars.queue[i].owner=COMPONENT_OPENQUEUE;
ENABLE_INTERRUPTS();
return &openqueue_vars.queue[i];
}
}
ENABLE_INTERRUPTS();
return NULL;
}
示例2: DISABLE_INTERRUPTS
//Puts the thread with the ID tid to sleep
void CALLING_CONVENTION CX86Scheduler::sleepThread(pid_t tid, size_t count)
{
if (count == 0)
return;
bool islocked = false;
bool isrunning = true;
DISABLE_INTERRUPTS(); //Turn off preemption
m_lock.acquireSpinlock();
iterator_t itr = m_runningList.findValue((PTHREAD)tid);
if (!m_runningList.isEntry(itr))
{
isrunning = false;
//Not on the running list, scan the blocked list
itr = m_blockedList.findValue((PTHREAD)tid);
if (!m_blockedList.isEntry(itr))
{
//Thread does not exist, release lock and return
m_lock.releaseSpinlock();
ENABLE_INTERRUPTS();
return;
}
}
//OK, we found the thread
PTHREAD thread = (PTHREAD)tid;
thread->waitcount += count;
if (isrunning)
{
m_runningList.removeAt(itr);
m_blockedList.insertToTail(thread);
}
m_lock.releaseSpinlock();
ENABLE_INTERRUPTS();
}
示例3: mythread_cleanup
// Threads return here and space is freed
void mythread_cleanup()
{
// Unblock thread blocked by join
DISABLE_INTERRUPTS();
int id = running_thread[1]->thread.blocking_id;
if (id > 0) {
Node * temp = 0xffffffff;
temp = lookup_node(running_thread[1]->thread.blocking_id, WAITING); //Blocking ID was not the expected value Camtendo 11/4
if (temp != 0xffffffff) // not found
{
Node * blocked_node = (Node *) malloc(sizeof(Node));
blocked_node->thread = temp->thread;
blocked_node->thread.scheduling_status = READY;
remove_node(temp, WAITING);
add_node(blocked_node, READY);
}
}
ENABLE_INTERRUPTS();
alt_printf("COMPLETED.\n");
DISABLE_INTERRUPTS();
free(running_thread[1]->thread.context);
running_thread[1]->thread.scheduling_status = DONE;
ENABLE_INTERRUPTS();
while(TRUE);
}
示例4: usl_stack_push
/*
* Record a usimple_lock just acquired on
* the current processor.
*
* MACH_RT: Preemption has been disabled by lock
* acquisition, so it's safe to use the cpu number
* specified by the caller.
*/
void
usl_stack_push(
usimple_lock_t l,
int mycpu)
{
spl_t s;
if (uslock_stack_enabled == FALSE)
return;
DISABLE_INTERRUPTS(s);
assert(uslock_stack_index[mycpu] >= 0);
assert(uslock_stack_index[mycpu] < USLOCK_STACK_DEPTH);
if (uslock_stack_index[mycpu] >= USLOCK_STACK_DEPTH) {
printf("usl_stack_push (cpu 0x%x): too many locks (%d)",
mycpu, uslock_stack_index[mycpu]);
printf(" disabling stacks\n");
uslock_stack_enabled = FALSE;
ENABLE_INTERRUPTS(s);
return;
}
uslock_stack[mycpu][uslock_stack_index[mycpu]] = l;
uslock_stack_index[mycpu]++;
ENABLE_INTERRUPTS(s);
}
示例5: main
void main(){
OUTPUT_LOW(LCD_RW); //Che do ghi
LCD_Init(); //Khoi tao LCD
LCD_PutCmd(0x01); //Xoa man hinh
ENABLE_INTERRUPTS(INT_TIMER0); //Kich hoat ngat ngoai
SETUP_TIMER_0(RTCC_INTERNAL|RTCC_DIV_32); //Xung kich noi va chia truoc 32
ENABLE_INTERRUPTS(GLOBAL); //Cho phep ngat toan cuc
SET_TIMER0(100); //Bat dau dem tu 100, khi tran Timer0 duoc 1ms
while (True){ //Duy tri hoat dong cua vi dieu khien
if (dem > N_max){
dem = 0;
LCD_PutCmd(0x01);
}
LCD_SetPosition(0x00); //Cot 1 dong 1
LCD_PutChar("Dem so:");
LCD_SetPosition(0x07); //Cot 8 dong 1
printf(LCD_PutChar,"%lu",dem);
}
}
示例6: openqueue_macGetDataPacket
OpenQueueEntry_t* openqueue_macGetDataPacket(open_addr_t* toNeighbor) {
uint8_t i;
INTERRUPT_DECLARATION();
DISABLE_INTERRUPTS();
if (toNeighbor->type==ADDR_64B) {
// a neighbor is specified, look for a packet unicast to that neigbhbor
for (i=0;i<QUEUELENGTH;i++) {
if (openqueue_vars.queue[i].owner==COMPONENT_RES_TO_IEEE802154E &&
packetfunctions_sameAddress(toNeighbor,&openqueue_vars.queue[i].l2_nextORpreviousHop)) {
ENABLE_INTERRUPTS();
return &openqueue_vars.queue[i];
}
}
} else if (toNeighbor->type==ADDR_ANYCAST) {
// anycast case: look for a packet which is either not created by RES
// or an KA (created by RES, but not broadcast)
for (i=0;i<QUEUELENGTH;i++) {
if (openqueue_vars.queue[i].owner==COMPONENT_RES_TO_IEEE802154E &&
( openqueue_vars.queue[i].creator!=COMPONENT_RES ||
(
openqueue_vars.queue[i].creator==COMPONENT_RES &&
packetfunctions_isBroadcastMulticast(&(openqueue_vars.queue[i].l2_nextORpreviousHop))==FALSE
)
)
) {
ENABLE_INTERRUPTS();
return &openqueue_vars.queue[i];
}
}
}
ENABLE_INTERRUPTS();
return NULL;
}
示例7: process_reorg_encrypt_restart
void process_reorg_encrypt_restart(void)
{
intrpt_state_t prev_intrpt_state;
enc_info_t *encr_ptr;
int gtmcrypt_errno;
gd_segment *seg;
sgmnt_addrs *csa;
csa = reorg_encrypt_restart_csa;
assert(NULL != csa); /* caller should have ensured this */
/* Opening handles for encryption is a heavyweight operation. Caller should have ensured we are not in crit for
* any region when the new key handles are opened for any one region. Assert that.
*/
assert(0 == have_crit(CRIT_HAVE_ANY_REG));
DEFER_INTERRUPTS(INTRPT_IN_CRYPT_RECONFIG, prev_intrpt_state);
encr_ptr = csa->encr_ptr;
assert(NULL != encr_ptr);
DBG_RECORD_CRYPT_RECEIVE(csa->hdr, csa, csa->nl, process_id, encr_ptr);
seg = csa->region->dyn.addr;
INIT_DB_OR_JNL_ENCRYPTION(csa, encr_ptr, seg->fname_len, seg->fname, gtmcrypt_errno);
if (0 != gtmcrypt_errno)
{
ENABLE_INTERRUPTS(INTRPT_IN_CRYPT_RECONFIG, prev_intrpt_state);
GTMCRYPT_REPORT_ERROR(gtmcrypt_errno, rts_error, seg->fname_len, seg->fname);
}
reorg_encrypt_restart_csa = NULL;
ENABLE_INTERRUPTS(INTRPT_IN_CRYPT_RECONFIG, prev_intrpt_state);
}
示例8: usl_stack_pop
/*
* Eliminate the entry for a usimple_lock
* that had been active on the current processor.
*
* MACH_RT: Preemption has been disabled by lock
* acquisition, and we haven't yet actually
* released the hardware lock associated with
* this usimple_lock, so it's safe to use the
* cpu number supplied by the caller.
*/
void
usl_stack_pop(
usimple_lock_t l,
int mycpu)
{
unsigned int i, index;
spl_t s;
if (uslock_stack_enabled == FALSE)
return;
DISABLE_INTERRUPTS(s);
assert(uslock_stack_index[mycpu] > 0);
assert(uslock_stack_index[mycpu] <= USLOCK_STACK_DEPTH);
if (uslock_stack_index[mycpu] == 0) {
printf("usl_stack_pop (cpu 0x%x): not enough locks (%d)",
mycpu, uslock_stack_index[mycpu]);
printf(" disabling stacks\n");
uslock_stack_enabled = FALSE;
ENABLE_INTERRUPTS(s);
return;
}
index = --uslock_stack_index[mycpu];
for (i = 0; i <= index; ++i) {
if (uslock_stack[mycpu][i] == l) {
if (i != index)
uslock_stack[mycpu][i] =
uslock_stack[mycpu][index];
ENABLE_INTERRUPTS(s);
return;
}
}
ENABLE_INTERRUPTS(s);
panic("usl_stack_pop: can't find usimple_lock 0x%x", l);
}
示例9: openserial_startInput
void openserial_startInput() {
INTERRUPT_DECLARATION();
if (openserial_vars.inputBufFill>0) {
openserial_printError(COMPONENT_OPENSERIAL,ERR_INPUTBUFFER_LENGTH,
(errorparameter_t)openserial_vars.inputBufFill,
(errorparameter_t)0);
DISABLE_INTERRUPTS();
openserial_vars.inputBufFill=0;
ENABLE_INTERRUPTS();
}
uart_clearTxInterrupts();
uart_clearRxInterrupts(); // clear possible pending interrupts
uart_enableInterrupts(); // Enable USCI_A1 TX & RX interrupt
DISABLE_INTERRUPTS();
openserial_vars.busyReceiving = FALSE;
openserial_vars.mode = MODE_INPUT;
openserial_vars.reqFrameIdx = 0;
#ifdef FASTSIM
uart_writeBufferByLen_FASTSIM(
openserial_vars.reqFrame,
sizeof(openserial_vars.reqFrame)
);
openserial_vars.reqFrameIdx = sizeof(openserial_vars.reqFrame);
#else
uart_writeByte(openserial_vars.reqFrame[openserial_vars.reqFrameIdx]);
#endif
ENABLE_INTERRUPTS();
}
示例10: idmanager_setMyID
owerror_t idmanager_setMyID(open_addr_t* newID) {
INTERRUPT_DECLARATION();
DISABLE_INTERRUPTS();
switch (newID->type) {
case ADDR_16B:
memcpy(&idmanager_vars.my16bID,newID,sizeof(open_addr_t));
break;
case ADDR_64B:
memcpy(&idmanager_vars.my64bID,newID,sizeof(open_addr_t));
break;
case ADDR_PANID:
memcpy(&idmanager_vars.myPANID,newID,sizeof(open_addr_t));
break;
case ADDR_PREFIX:
memcpy(&idmanager_vars.myPrefix,newID,sizeof(open_addr_t));
break;
case ADDR_128B:
//don't set 128b, but rather prefix and 64b
default:
openserial_printCritical(COMPONENT_IDMANAGER,ERR_WRONG_ADDR_TYPE,
(errorparameter_t)newID->type,
(errorparameter_t)1);
ENABLE_INTERRUPTS();
return E_FAIL;
}
ENABLE_INTERRUPTS();
return E_SUCCESS;
}
示例11: main
void main(){
float distance = 0;
OUTPUT_LOW(LCD_RW);
LCD_Init();
LCD_PutCmd(0x01);
SETUP_TIMER_1(T1_INTERNAL|T1_DIV_BY_4);
SETUP_CCP1(CCP_CAPTURE_RE);
ENABLE_INTERRUPTS(INT_CCP1);
ENABLE_INTERRUPTS(GLOBAL);
while (True){
Trigger();
while (echo == 0){
;
}
distance = value*0.8/58;
LCD_PutCmd(0x01);
LCD_SetPosition(0x00);
LCD_PutChar("Distance:");
LCD_SetPosition(0x40);
printf(LCD_PutChar,"%.2fcm",distance);
delay_ms(1000);
}
}
示例12: openserial_getInputBuffer
uint8_t openserial_getInputBuffer(uint8_t* bufferToWrite, uint8_t maxNumBytes) {
uint8_t numBytesWritten;
uint8_t inputBufFillLevel;
INTERRUPT_DECLARATION();
//<<<<<<<<<<<<<<<<<<<<<<<
DISABLE_INTERRUPTS();
inputBufFillLevel = openserial_vars.inputBufFillLevel;
ENABLE_INTERRUPTS();
//>>>>>>>>>>>>>>>>>>>>>>>
if (maxNumBytes<inputBufFillLevel-1) {
openserial_printError(
COMPONENT_OPENSERIAL,
ERR_GETDATA_ASKS_TOO_FEW_BYTES,
(errorparameter_t)maxNumBytes,
(errorparameter_t)inputBufFillLevel-1
);
numBytesWritten = 0;
} else {
numBytesWritten = inputBufFillLevel-1;
//<<<<<<<<<<<<<<<<<<<<<<<
DISABLE_INTERRUPTS();
memcpy(bufferToWrite,&(openserial_vars.inputBuf[1]),numBytesWritten);
ENABLE_INTERRUPTS();
//>>>>>>>>>>>>>>>>>>>>>>>
}
return numBytesWritten;
}
示例13: serPutByte
/**
* Send the given byte to the USART. It is added to the transmit buffer, and asynchronously
* transmitted.
*
* @param c Byte to write out on the serial port
*/
void serPutByte(BYTE c) {
//Check if buffer is full.
#ifdef SER_WAIT_FOR_TXBUF
//Wait until a byte is transmitted by the interrupt routine and buffer has place again.
while (busIsTxBufFull(BUSID)) {
FAST_USER_PROCESS();
}
#else
if (busIsTxBufFull(BUSID)) {
serStat |= SER1_TXBUF_OVERRUN;
return;
}
#endif
//Enter critical section
DISBALE_INTERRUPTS();
//If we are not currently TXing, the TX buffer will be empty. No need to transmit via buffer,
//just write direct to TXREG
if ( !PIE1_TXIE)
{
TXREG = c; //Send byte
PIE1_TXIE = 1; //Indicate that we are currently TXing
ENABLE_INTERRUPTS();
}
//We are currently TXing. This means that the TXIF will soon be set after the current byte
//has been transmitted, and the TX buffer will be checked for any unsent data. Add current
//byte to TX buffer.
else {
//Add byte to TX buffer, and update buffer pointers
busPutByteTxBuf(BUFID, c);
ENABLE_INTERRUPTS();
}
}
示例14: main
void main(){
TRISE = 0x00; //Chan OUTPUT
ENABLE_INTERRUPTS(INT_TIMER0); //Kich hoat ngat tran Timer0
SETUP_TIMER_0(RTCC_INTERNAL|RTCC_DIV_32); //Xung kich noi va chia truoc 32
ENABLE_INTERRUPTS(GLOBAL); //Cho phep ngat toan cuc
SET_TIMER0(100); //Bat dau dem tu 100, khi tran Timer0 duoc 1ms
while (True){ //Duy tri hoat dong cua vi dieu khien
;
}
}
示例15: neighbors_isPreferredParent
bool neighbors_isPreferredParent(open_addr_t* address) {
uint8_t i;
INTERRUPT_DECLARATION();
DISABLE_INTERRUPTS();
for (i=0;i<MAXNUMNEIGHBORS;i++) {
if (isThisRowMatching(address,i) && neighbors_vars.neighbors[i].parentPreference==MAXPREFERENCE) {
ENABLE_INTERRUPTS();
return TRUE;
}
}
ENABLE_INTERRUPTS();
return FALSE;
}