当前位置: 首页>>代码示例>>C++>>正文


C++ ExitCritical函数代码示例

本文整理汇总了C++中ExitCritical函数的典型用法代码示例。如果您正苦于以下问题:C++ ExitCritical函数的具体用法?C++ ExitCritical怎么用?C++ ExitCritical使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了ExitCritical函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CI2C1_SendBlock

/*
** ===================================================================
**     Method      :  CI2C1_SendBlock (component InternalI2C)
**     Description :
**         When working as a MASTER, this method writes one (7-bit
**         addressing) or two (10-bit addressing) slave address bytes
**         inclusive of R/W bit = 0 to the I2C bus and then writes the
**         block of characters to the bus. The slave address must be
**         specified before, by the "SelectSlave" or "SlaveSelect10"
**         method or in component initialization section, "Target slave
**         address init" property. If interrupt service is enabled and
**         the method returns ERR_OK, it doesn't mean that transmission
**         was successful. The state of transmission is detectable by
**         means of events (OnTransmitData, OnError or OnArbitLost).
**         Data to be send is not copied to an internal buffer and
**         remains in the original location. Therefore the content of
**         the buffer should not be changed until the transmission is
**         complete. Event OnTransmitData can be used to detect the end
**         of the transmission.
**         When working as a SLAVE, this method writes a block of
**         characters to the internal output slave buffer and then,
**         after the master starts the communication, to the I2C bus.
**         If no character is ready for a transmission (internal output
**         slave buffer is empty), the "Empty character" will be sent
**         (see "Empty character" property). In SLAVE mode the data are
**         copied to an internal buffer, if specified by "Output buffer
**         size" property.
**     Parameters  :
**         NAME            - DESCRIPTION
**       * Ptr             - Pointer to the block of data to send.
**         Siz             - Size of the block.
**       * Snt             - Amount of data sent (moved to a buffer).
**                           In master mode, if interrupt support is
**                           enabled, the parameter always returns the
**                           same value as the parameter 'Siz' of this
**                           method.
**     Returns     :
**         ---             - Error code, possible codes:
**                           ERR_OK - OK
**                           ERR_SPEED - This device does not work in
**                           the active speed mode
**                           ERR_DISABLED -  Device is disabled
**                           ERR_BUSY - The slave device is busy, it
**                           does not respond by the acknowledge (only
**                           in master mode and when interrupt service
**                           is disabled)
**                           ERR_BUSOFF - Clock timeout elapsed or
**                           device cannot transmit data
**                           ERR_TXFULL - Transmitter is full. Some data
**                           has not been sent. (slave mode only)
**                           ERR_ARBITR - Arbitration lost (only when
**                           interrupt service is disabled and in master
**                           mode)
** ===================================================================
*/
byte CI2C1_SendBlock(void *Ptr,word Siz,word *Snt)
{
  LDD_TError Error;

  if (Siz == 0U) {                     /* Test variable Size on zero */
    *Snt = 0U;
    return ERR_OK;                     /* If zero then OK */
  }
  EnterCritical();                     /* Enter the critical section */
  Error = IntI2cLdd1_MasterSendBlock(IntI2cLdd1_DeviceDataPtr, (LDD_TData *)Ptr, (LDD_I2C_TSize)Siz, LDD_I2C_SEND_STOP); /* Send one data byte */
  if (Error == ERR_BUSY) {
    ExitCritical();                    /* Exit the critical section */
    return ERR_BUSOFF;
  }
  OutLenM = Siz;                       /* Set length of output bufer's content */
  ExitCritical();                      /* Exit the critical section */
  *Snt = Siz;                          /* Dummy number of really sent chars */
  return ERR_OK;                       /* OK */
}
开发者ID:yuhua-cheng,项目名称:usi0106,代码行数:74,代码来源:CI2C1.c

示例2: Serial_2_ClearRxBuf

/*
** ===================================================================
**     Method      :  Serial_2_ClearRxBuf (component AsynchroSerial)
**     Description :
**         Clears the receive buffer.
**         This method is available only if non-zero length of the
**         input buffer is defined and the receiver property is enabled.
**     Parameters  : None
**     Returns     :
**         ---             - Error code, possible codes:
**                           ERR_OK - OK
**                           ERR_SPEED - This device does not work in
**                           the active speed mode
** ===================================================================
*/
byte Serial_2_ClearRxBuf(void)
{
  EnterCritical();                     /* Save the PS register */
  Serial_2_InpLen = 0x00U;             /* Set number of chars in the receive buffer to 0 */
  InpIndxR = 0x00U;                    /* Reset read index to the receive buffer */
  InpIndxW = 0x00U;                    /* Reset write index to the receive buffer */
  SerFlag &= (byte)(~(byte)(CHAR_IN_RX | FULL_RX)); /* Clear the flags indicating a char in buffer */
  ExitCritical();                      /* Restore the PS register */
  return ERR_OK;                       /* OK */
}
开发者ID:ddtdanilo,项目名称:Proyectos-III-War-of-Tanks,代码行数:25,代码来源:Serial_2.c

示例3: route_show

void
route_show(void) {
  int i;
  print_route(NULL);
  EnterCritical();
  for (i = 0 ; i < GETNUMROUTEENTRIES ; i++) {
    print_route(GETROUTEP(i));
  }
  ExitCritical();
}
开发者ID:aunali1,项目名称:exopc,代码行数:10,代码来源:routenif.c

示例4: SM1_GetError

/*
** ===================================================================
**     Method      :  SM1_GetError (component SynchroMaster)
**     Description :
**         Returns a set of errors on the channel (errors that cannot
**         be returned in given methods). The component accumulates
**         errors in a set; after calling [GetError] this set is
**         returned and cleared. This method is available only if the
**         "Interrupt service/event" property is enabled.
**     Parameters  :
**         NAME            - DESCRIPTION
**       * Err             - A pointer to the returned set of errors
**     Returns     :
**         ---             - Error code (if GetError did not succeed),
**                           possible codes:
**                           ERR_OK - OK
**                           ERR_SPEED - This device does not work in
**                           the active speed mode
** ===================================================================
*/
byte SM1_GetError(SM1_TError *Err)
{
  EnterCritical();                     /* Disable global interrupts */
  Err->err = 0U;
  Err->errName.OverRun = (((ErrFlag & OVERRUN_ERR) != 0U)? 1U : 0U); /* Overrun error */
  Err->errName.RxBufOvf = (((ErrFlag & FULL_RX) != 0U)? 1U : 0U); /* Buffer overflow */
  ErrFlag = 0x00U;                     /* Reset error flags */
  ExitCritical();                      /* Enable global interrupts */
  return ERR_OK;                       /* OK */
}
开发者ID:nikolarobottesla,项目名称:BatteryTestSystem,代码行数:30,代码来源:SM1.c

示例5: SM1_ClearRxBuf

/*
** ===================================================================
**     Method      :  SM1_ClearRxBuf (component SynchroMaster)
**     Description :
**         Clears the receive buffer. This method is available only if
**         a non-zero length of input buffer is defined.
**     Parameters  : None
**     Returns     :
**         ---             - Error code, possible codes:
**                           ERR_OK - OK
**                           ERR_SPEED - This device does not work in
**                           the active speed mode
** ===================================================================
*/
byte SM1_ClearRxBuf(void)
{
  EnterCritical();                     /* Disable global interrupts */
  SM1_InpLen = 0U;                     /* Set number of chars in the transmit buffer to 0 */
  InpIndexW = 0x00U;                   /* Set index on the first item in the transmit buffer */
  InpIndexR = 0x00U;
  SerFlag &= (byte)~(OVERRUN_ERR | FULL_RX); /* Clear flags */
  ExitCritical();                      /* Enable global interrupts */
  return ERR_OK;                       /* OK */
}
开发者ID:nikolarobottesla,项目名称:BatteryTestSystem,代码行数:24,代码来源:SM1.c

示例6: TMOUT1_LeaveCounter

/*
** ===================================================================
**     Method      :  TMOUT1_LeaveCounter (component Timeout)
**
**     Description :
**         To be called to return the counter. Note that a counter
**         always should be returned so it can be reused.
**     Parameters  :
**         NAME            - DESCRIPTION
**         handle          - Counter handle
**     Returns     : Nothing
** ===================================================================
*/
void TMOUT1_LeaveCounter(TMOUT1_CounterHandle handle)
{
  if (handle==TMOUT1_OUT_OF_HANDLE) {
    return;
  }
  EnterCritical();
  TMOUT1_Counters[handle] = 0;
  TMOUT1_FreeCounters[handle]=TRUE;
  ExitCritical();
}
开发者ID:michaeljohneduave,项目名称:superninjamodethesis,代码行数:23,代码来源:TMOUT1.c

示例7: hwExpIn_GetRxIdle

/*
** ===================================================================
**     Method      :  hwExpIn_GetRxIdle (bean AsynchroSerial)
**
**     Description :
**         Returns the state of the receiver idle flag. This method
**         is available only if event <OnIdle> is disabled.
**     Parameters  : None
**     Returns     :
**         ---             - The state of the receiver idle flag.
** ===================================================================
*/
bool hwExpIn_GetRxIdle(void)
{
  bool Result;

  EnterCritical();                     /* Save the PS register */
  Result = (bool)((SerFlag & IDLE_ERR)?1:0); /* If idle signal has been received? */
  SerFlag &= ~IDLE_ERR;                /* Reset idle signal flag */
  ExitCritical();                      /* Restore the PS register */
  return Result;                       /* OK */
}
开发者ID:WaterOptimizer,项目名称:WOIS-PE,代码行数:22,代码来源:hwExpIn.c

示例8: watchdog_periodic

/*---------------------------------------------------------------------------*/
void
watchdog_periodic(void)
{
#if PLATFORM_CONF_ENABLE_WATCHDOG
  EnterCritical();
  SIM_SRVCOP = SIM_SRVCOP_SRVCOP(COP_KEY_1);
  SIM_SRVCOP = SIM_SRVCOP_SRVCOP(COP_KEY_2);
  /* {Default RTOS Adapter} Critical section end, general PE function is used */
  ExitCritical();
#endif /* PLATFORM_CONF_ENABLE_WATCHDOG */
}
开发者ID:AlexanderWiniger,项目名称:kinetis-mote,代码行数:12,代码来源:watchdog.c

示例9: TACHO_CalcSpeed

void TACHO_CalcSpeed(void) {
#if 1
  /* we calculate the speed as follow:
                              1000         
  steps/sec =  delta * ----------------- 
                       samplePeriod (ms) 
  As this function may be called very frequently, it is important to make it as efficient as possible!
   */
  int16_t deltaLeft, deltaRight, newLeft, newRight, oldLeft, oldRight;
  int32_t speedLeft, speedRight;
  bool negLeft, negRight;

  EnterCritical();
  oldLeft = (int16_t)TACHO_LeftPosHistory[TACHO_PosHistory_Index]; /* oldest left entry */
  oldRight = (int16_t)TACHO_RightPosHistory[TACHO_PosHistory_Index]; /* oldest right entry */
  if (TACHO_PosHistory_Index==0) { /* get newest entry */
    newLeft = (int16_t)TACHO_LeftPosHistory[NOF_HISTORY-1];
    newRight = (int16_t)TACHO_RightPosHistory[NOF_HISTORY-1];
  } else {
    newLeft = (int16_t)TACHO_LeftPosHistory[TACHO_PosHistory_Index-1];
    newRight = (int16_t)TACHO_RightPosHistory[TACHO_PosHistory_Index-1];
  }
  ExitCritical();
  deltaLeft = oldLeft-newLeft; /* delta of oldest position and most recent one */
  /* use unsigned arithmetic */
  if (deltaLeft < 0) {
    deltaLeft = -deltaLeft;
    negLeft = TRUE;
  } else {
    negLeft = FALSE;
  }
  deltaRight = oldRight-newRight; /* delta of oldest position and most recent one */
  /* use unsigned arithmetic */
  if (deltaRight < 0) {
    deltaRight = -deltaRight;
    negRight = TRUE;
  } else {
    negRight = FALSE;
  }
  /* calculate speed. this is based on the delta and the time (number of samples or entries in the history table) */
  speedLeft = (int32_t)(deltaLeft * 1000/(TACHO_SAMPLE_PERIOD_MS*(NOF_HISTORY-1)));
  if (negLeft) {
    speedLeft = -speedLeft;
  }
  speedRight = (int32_t)(deltaRight * 1000/(TACHO_SAMPLE_PERIOD_MS*(NOF_HISTORY-1)));
  if (negRight) {
    speedRight = -speedRight;
  }
  TACHO_currLeftSpeed = -speedLeft; /* store current speed in global variable */
  TACHO_currRightSpeed = -speedRight; /* store current speed in global variable */
#else
  /*! \todo Implement function */ 
#endif
}
开发者ID:infotronik,项目名称:sumo,代码行数:54,代码来源:Tacho.c

示例10: get_ifnum_cardno

int
get_ifnum_cardno(int ifnum) {
  if_entry_p ife;
  int cardno;
  ASSERTIFNUM(ifnum);
  EnterCritical();
  ife = GETIFP(ifnum);
  cardno = ife->cardno;
  ExitCritical();
  return cardno;
}
开发者ID:aunali1,项目名称:exopc,代码行数:11,代码来源:routenif.c

示例11: RC_SendChar

/*
** ===================================================================
**     Method      :  RC_SendChar (component AsynchroSerial)
**     Description :
**         Sends one character to the channel. If the component is
**         temporarily disabled (Disable method) SendChar method only
**         stores data into an output buffer. In case of a zero output
**         buffer size, only one character can be stored. Enabling the
**         component (Enable method) starts the transmission of the
**         stored data. This method is available only if the
**         transmitter property is enabled.
**     Parameters  :
**         NAME            - DESCRIPTION
**         Chr             - Character to send
**     Returns     :
**         ---             - Error code, possible codes:
**                           ERR_OK - OK
**                           ERR_SPEED - This device does not work in
**                           the active speed mode
**                           ERR_TXFULL - Transmitter is full
** ===================================================================
*/
byte RC_SendChar(RC_TComData Chr)
{
  if ((SerFlag & FULL_TX) != 0U) {     /* Is any char is in TX buffer */
    return ERR_TXFULL;                 /* If yes then error */
  }
  EnterCritical();                     /* Disable global interrupts */
  OutBuffer = Chr;                     /* Store char to temporary variable */
  (void)ASerialLdd1_SendBlock(ASerialLdd1_DeviceDataPtr, (LDD_TData *)&OutBuffer, 1U); /* Send one data byte */
  SerFlag |= (FULL_TX);                /* Set the flag "full TX buffer" */
  ExitCritical();                      /* Enable global interrupts */
  return ERR_OK;                       /* OK */
}
开发者ID:kwrobit,项目名称:robit_k64f_drone,代码行数:34,代码来源:RC.c

示例12: TMOUT1_AddTick

/*
** ===================================================================
**     Method      :  TMOUT1_AddTick (component Timeout)
**
**     Description :
**         Method to be called from a priodic timer or interrupt. It
**         will decrement all current counters by one down to zero.
**     Parameters  : None
**     Returns     : Nothing
** ===================================================================
*/
void TMOUT1_AddTick(void)
{
  byte i;

  EnterCritical();
  for(i=0;i<TMOUT1_NOF_COUNTERS;i++) {
    if (TMOUT1_Counters[i]>0) {
      TMOUT1_Counters[i]--;
    }
  }
  ExitCritical();
}
开发者ID:michaeljohneduave,项目名称:superninjamodethesis,代码行数:23,代码来源:TMOUT1.c

示例13: TMOUT1_CounterExpired

/*
** ===================================================================
**     Method      :  TMOUT1_CounterExpired (component Timeout)
**
**     Description :
**         Returns true if the timeout counter has been expired
**     Parameters  :
**         NAME            - DESCRIPTION
**         handle          - The timeout handle retrieved using
**                           GetCounter()
**     Returns     :
**         ---             - Returns TRUE if the counter has been
**                           expired, FALSE otherwise
** ===================================================================
*/
bool TMOUT1_CounterExpired(TMOUT1_CounterHandle handle)
{
  bool res;

  if (handle==TMOUT1_OUT_OF_HANDLE) {
    return TRUE;
  }
  EnterCritical();
  res = (bool)(TMOUT1_Counters[handle]==0);
  ExitCritical();
  return res;
}
开发者ID:michaeljohneduave,项目名称:superninjamodethesis,代码行数:27,代码来源:TMOUT1.c

示例14: SPI_SD_GetBlockReceivedStatus

/* ===================================================================*/
bool SPI_SD_GetBlockReceivedStatus(LDD_TDeviceData *DeviceDataPtr)
{
  uint8_t Status;                      /* Temporary variable for flag saving */

  /* {Default RTOS Adapter} Critical section begin, general PE function is used */
  EnterCritical();
  Status = ((SPI_SD_TDeviceDataPtr)DeviceDataPtr)->SerFlag; /* Save flag for return */
  ((SPI_SD_TDeviceDataPtr)DeviceDataPtr)->SerFlag &= (uint8_t)(~(uint8_t)BLOCK_RECEIVED); /* Clear data block sent flag */
  /* {Default RTOS Adapter} Critical section end, general PE function is used */
  ExitCritical();
  return (bool)(((Status & BLOCK_RECEIVED) != 0U)? TRUE : FALSE); /* Return saved status */
}
开发者ID:SeismicPi,项目名称:SeismicPi,代码行数:13,代码来源:SPI_SD.c

示例15: wakeup

void wakeup (void *chan) {
  int i;

  d0printf("%d wakeup chan: %p\n", getpid(),chan);

  global_ftable->counter1++;
  EnterCritical();
  for (i = 0; i < NENV; i++) 
    if (synch_table->wchan[i] == chan) 
      synch_table->wchan[i] = (void *)0;
  ExitCritical();
}
开发者ID:aunali1,项目名称:exopc,代码行数:12,代码来源:synch.c


注:本文中的ExitCritical函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。