本文整理汇总了C++中DISABLE_INTERRUPTS函数的典型用法代码示例。如果您正苦于以下问题:C++ DISABLE_INTERRUPTS函数的具体用法?C++ DISABLE_INTERRUPTS怎么用?C++ DISABLE_INTERRUPTS使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了DISABLE_INTERRUPTS函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PRIMITIVE_CLOSE
int
PRIMITIVE_CLOSE(int fileID)
{
interrupt_state istate;
_LOCK_PRIMIO();
PrimIOCB.op = PRIM_CLOSE;
PrimIOCB.fileID = fileID;
PrimIOCB.flags = 0; /* (not used) */
PrimIOCB.more = NULL;
DISABLE_INTERRUPTS(istate);
#if defined(__ADSPBLACKFIN__)
FLUSH_CACHE_PRIMIOCB();
DISABLE_CACHE();
SYNCH_MEMORY();
#endif
_primIO();
#if defined(__ADSPBLACKFIN__)
ENABLE_CACHE();
#endif
ENABLE_INTERRUPTS(istate);
_UNLOCK_PRIMIO();
return 0;
}
示例2: output_buffer_index_write_increment
uint16_t output_buffer_index_write_increment() {
INTERRUPT_DECLARATION();
DISABLE_INTERRUPTS();
openserial_vars.output_buffer_index_write=(openserial_vars.output_buffer_index_write+1)%SERIAL_OUTPUT_BUFFER_SIZE;
ENABLE_INTERRUPTS();
return openserial_vars.output_buffer_index_write;
}
示例3: schedule_advanceSlot
void schedule_advanceSlot() {
INTERRUPT_DECLARATION();
DISABLE_INTERRUPTS();
// advance to next active slot
schedule_vars.currentScheduleEntry = schedule_vars.currentScheduleEntry->next;
ENABLE_INTERRUPTS();
}
示例4: StartApplication
void StartApplication( void (*StartAddress)() )
{
PortBooterLoadProgram((void**)&StartAddress);
hal_printf( "Starting main application at 0x%08x\r\n", (size_t)StartAddress );
LCD_Clear();
USART_Flush( ConvertCOM_ComPort(g_State.UsartPort) );
if(g_State.UsingUsb)
{
USB_Flush( ConvertCOM_UsbStream( g_State.UsbPort ) );
USB_CloseStream( ConvertCOM_UsbStream(g_State.UsbPort) );
USB_Uninitialize( ConvertCOM_UsbController(g_State.UsbPort) ); //disable the USB for the next application
}
DISABLE_INTERRUPTS();
LCD_Uninitialize();
CPU_DisableCaches();
(*StartAddress)();
}
示例5: openserial_printError
error_t openserial_printError(uint8_t calling_component, uint8_t error_code,
errorparameter_t arg1,
errorparameter_t arg2) {
leds_error_toggle();
INTERRUPT_DECLARATION();
DISABLE_INTERRUPTS();
openserial_vars.somethingInOutputBuffer=TRUE;
openserial_vars.output_buffer[output_buffer_index_write_increment()]=(uint8_t)'^'; //preamble
openserial_vars.output_buffer[output_buffer_index_write_increment()]=(uint8_t)'^';
openserial_vars.output_buffer[output_buffer_index_write_increment()]=(uint8_t)'^';
openserial_vars.output_buffer[output_buffer_index_write_increment()]=(uint8_t)'E'; //this is an error
openserial_vars.output_buffer[output_buffer_index_write_increment()]=(uint8_t)((idmanager_getMyID(ADDR_16B))->addr_16b[1]);
openserial_vars.output_buffer[output_buffer_index_write_increment()]=(uint8_t)((idmanager_getMyID(ADDR_16B))->addr_16b[0]);
openserial_vars.output_buffer[output_buffer_index_write_increment()]=(uint8_t)calling_component; //component generating error
openserial_vars.output_buffer[output_buffer_index_write_increment()]=(uint8_t)error_code; //error_code
openserial_vars.output_buffer[output_buffer_index_write_increment()]=(uint8_t)((arg1 & 0xff00)>>8); //arg1
openserial_vars.output_buffer[output_buffer_index_write_increment()]=(uint8_t) (arg1 & 0x00ff);
openserial_vars.output_buffer[output_buffer_index_write_increment()]=(uint8_t)((arg2 & 0xff00)>>8); //arg2
openserial_vars.output_buffer[output_buffer_index_write_increment()]=(uint8_t) (arg2 & 0x00ff);
openserial_vars.output_buffer[output_buffer_index_write_increment()]=(uint8_t)'$'; //postamble
openserial_vars.output_buffer[output_buffer_index_write_increment()]=(uint8_t)'$';
openserial_vars.output_buffer[output_buffer_index_write_increment()]=(uint8_t)'$';
ENABLE_INTERRUPTS();
return E_SUCCESS;
}
示例6: RITQueue_Get_Element
sRITqueue RITQueue_Get_Element(uint8_t pos)
{
sRITqueue elem;
//EnterCriticalSection
INTERRUPT_DECLARATION();
DISABLE_INTERRUPTS();
if (RITQueue_IsEmpty() == false)
{
if ( pos < maxElements)
{
elem = pvObjList[pos];
}
else
{
elem.frameType = 0;
RITQueue_ClearAddress(&elem.destaddr);
}
}
else
{
elem.frameType = 0;
RITQueue_ClearAddress(&elem.destaddr);
}
//LeaveCriticalSection
ENABLE_INTERRUPTS();
return elem;
}
示例7: RITQueue_ExistFramePending
/*
* Verifica se existe algum frame pendente
*/
bool RITQueue_ExistFramePending(void)
{
bool ret = false;
uint8_t i;
//EnterCriticalSection
INTERRUPT_DECLARATION();
DISABLE_INTERRUPTS();
for (i = 0; i < maxElements; i++)
{
if (pvObjList[i].pending)
{
if (pvObjList[i].countretry < 3)
{
ret = true;
break;
}
else //REMOVO O ELEMENTO QUE JA ESTA A TEMPOS AQUI
{
RITQueue_Free(i);
}
}
}
if (coappending)
ret = true;
//LeaveCriticalSection
ENABLE_INTERRUPTS();
return ret;
}
示例8: drvSysTick_getUptime
int drvSysTick_getUptime(struct timeval* uptime)
{
unsigned int sysTickValue; // System Tick counter counts down!
CHECK_STARTED_INT(&sInstDscr, 0);
CHECK_POINTER_INT(uptime);
/* Note that SysTick->VAL counts down and rolls over to SysTick->LOAD
* when reaching 0 even if interrupts are disabled.
* Therefore, if SysTick->VAL rolls over while reading out uptime,
* try again. Could use outdated uptime otherwise.
*/
do
{
SysTick->CTRL &= ~SysTick_CTRL_COUNTFLAG_Msk;
DISABLE_INTERRUPTS();
sysTickValue = SysTick->VAL;
*uptime = sInstDscr.uptime;
ENABLE_INTERRUPTS();
} while (SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk);
sysTickValue = SysTick->LOAD - sysTickValue;
/* Initial code, when uptime was of type unsigned long long:
* *uptime += (unsigned long long)sysTickValue * 1000000 / SystemCoreClock;
* However, this invokes the function __aeabi_uldivmod() for the 64bit
* integer division. Takes quite long. With a simple trick (divide
* numerator and divisor by 1000) the division can be kept in the integer
* range. That causes the compiler to use the UDIV instruction, which is
* much faster executed than the __aeabi_uldivmod() function.
*/
uptime->tv_usec += sysTickValue * 1000UL / (SystemCoreClock / 1000UL);
uptime->tv_sec += uptime->tv_usec / 1000000UL;
uptime->tv_usec %= 1000000UL;
return R_SUCCESS;
}
示例9: uart0_in
int uart0_in (ECTX ectx, WORD count, BYTEPTR pointer)
{
unsigned short imask;
int reschedule;
DISABLE_INTERRUPTS (imask);
if (rx_pending) {
write_byte (pointer, (BYTE) rx_buffer);
rx_pending = 0;
BARRIER;
reschedule = 0;
} else {
rx_channel = ectx->wptr;
rx_ptr = pointer;
BARRIER;
reschedule = 1;
}
ENABLE_INTERRUPTS (imask);
if (reschedule) {
/* Lower (set) CTS */
*pPORTHIO_CLEAR = CTS_MASK;
/* Save instruction pointer */
WORKSPACE_SET (ectx->wptr, WS_IPTR, (WORD) ectx->iptr);
/* Reschedule */
return ectx->run_next_on_queue (ectx);
} else {
return ECTX_CONTINUE;
}
}
示例10: Gyro_Calculation
void Gyro_Calculation(Gyro * gyro)
{
short velocity;
short angular_velocity;
CPU_MSR msr;
//gyro.velocityBack = pid.currentVelocityBack;
msr = DISABLE_INTERRUPTS();
velocity = raw_gyro_data.velocity;
angular_velocity = raw_gyro_data.angular_velocity;
RESTORE_INTERRUPTS(msr);
// V_b
gyro->backVelocity = raw_gyro_data.velocity;
// W
gyro->omega = (CONVERT_TO_RAD_SEC * raw_gyro_data.angular_velocity);
//R_b
gyro->backRadius = gyro->backVelocity/gyro->omega;
// K_b
gyro->backCurvature = gyro->omega/gyro->backVelocity;
// V_f
gyro->frontVelocity = gyro->backVelocity * sqrt(1+((gyro->backCurvature)*gyro->backCurvature*(gyro->wheelBase)*gyro->wheelBase));
// K_f
gyro->frontCurvature = gyro->omega/gyro->frontVelocity;
//R_b
gyro->frontRadius = gyro->frontVelocity/gyro->omega;
// Delta
gyro->steeringAngle = asin(gyro->wheelBase * (1/gyro->frontRadius));
}
示例11: Gyro_GetTotalAngle
inline int Gyro_GetTotalAngle(){
CPU_MSR msr = DISABLE_INTERRUPTS();
int millidegrees = raw_gyro_data.total_angle;
//raw_gyro_data.total_angle = 0;
RESTORE_INTERRUPTS(msr);
return millidegrees * 8.75;
}
示例12: schedule_indicateTx
/**
\brief Indicate the transmission of a packet.
*/
void schedule_indicateTx(asn_t* asnTimestamp,
bool succesfullTx) {
INTERRUPT_DECLARATION();
DISABLE_INTERRUPTS();
// increment usage statistics
if (schedule_vars.currentScheduleEntry->numTx==0xFF) {
schedule_vars.currentScheduleEntry->numTx/=2;
schedule_vars.currentScheduleEntry->numTxACK/=2;
}
schedule_vars.currentScheduleEntry->numTx++;
if (succesfullTx==TRUE) {
schedule_vars.currentScheduleEntry->numTxACK++;
}
// update last used timestamp
memcpy(&schedule_vars.currentScheduleEntry->lastUsedAsn, asnTimestamp, sizeof(asn_t));
// update this slot's backoff parameters
if (succesfullTx==TRUE) {
// reset backoffExponent
schedule_vars.currentScheduleEntry->backoffExponent = MINBE-1;
// reset backoff
schedule_vars.currentScheduleEntry->backoff = 0;
} else {
// increase the backoffExponent
if (schedule_vars.currentScheduleEntry->backoffExponent<MAXBE) {
schedule_vars.currentScheduleEntry->backoffExponent++;
}
// set the backoff to a random value in [0..2^BE]
schedule_vars.currentScheduleEntry->backoff =
openrandom_get16b()%(1<<schedule_vars.currentScheduleEntry->backoffExponent);
}
ENABLE_INTERRUPTS();
}
示例13: GM_Level
void GM_Level()
{
_restart:
v_gamemode |= GameMode_PreLevel; // flag that we're in pre-level sequence
if(f_demo != DemoMode_Credits)
PlaySound_Special(BGM_Fade);
ClearPLC();
PaletteFadeOut();
// If we're not doing an ending sequence demo...
if(f_demo != DemoMode_Credits)
{
DISABLE_INTERRUPTS();
NemDec(Nem_TitleCard, 0xB000);
ENABLE_INTERRUPTS();
auto plc1 = LevelHeaders[v_zone].gfx >> 24;
if(plc1 != 0)
AddPLC(plc1); // load level patterns
AddPLC(PLC_Main2); // load standard patterns
}
示例14: hal_aci_tl_send
bool hal_aci_tl_send(hal_aci_data_t *p_aci_cmd)
{
uint8_t length = p_aci_cmd->buffer[0];
if (!spi_transmit_requested)
{
// ASSERT(ERROR_CODE_HAL_ACI_TL_OVERFLOW,(p_aci_cmd->buffer[0] <= HAL_ACI_MAX_LENGTH));
if (length > HAL_ACI_MAX_LENGTH)
{
return(false);
}
{
bool is_interrupt_enabled_before_send = ARE_INTERRUPTS_ENABLED();
DISABLE_INTERRUPTS(); /*disable interrupts to protects the modification of the buffer pointer*/
lib_mem_copy((uint8_t *) data_to_send.buffer, p_aci_cmd->buffer, length+1);
spi_transmit_requested = true; // Request transmission
if (is_interrupt_enabled_before_send)
{
ENABLE_INTERRUPTS(); /*eventually re-enable the interrupts if they were enabled*/
}
}
digitalWrite(reqn, LOW);
return(true);
}
else
{
return(false);
}
}
示例15: openserial_printData
owerror_t openserial_printData(uint8_t* buffer, uint8_t length) {
uint8_t i;
uint8_t asn[5];
INTERRUPT_DECLARATION();
// retrieve ASN
ieee154e_getAsn(asn);// byte01,byte23,byte4
DISABLE_INTERRUPTS();
openserial_vars.outputBufFilled = TRUE;
outputHdlcOpen();
outputHdlcWrite(SERFRAME_MOTE2PC_DATA);
outputHdlcWrite(idmanager_getMyID(ADDR_16B)->addr_16b[1]);
outputHdlcWrite(idmanager_getMyID(ADDR_16B)->addr_16b[0]);
outputHdlcWrite(asn[0]);
outputHdlcWrite(asn[1]);
outputHdlcWrite(asn[2]);
outputHdlcWrite(asn[3]);
outputHdlcWrite(asn[4]);
for (i=0;i<length;i++){
outputHdlcWrite(buffer[i]);
}
outputHdlcClose();
ENABLE_INTERRUPTS();
return E_SUCCESS;
}