这篇教程C++ EnterCritical函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中EnterCritical函数的典型用法代码示例。如果您正苦于以下问题:C++ EnterCritical函数的具体用法?C++ EnterCritical怎么用?C++ EnterCritical使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了EnterCritical函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: ES_DeQueue/**************************************************************************** Function ES_DeQueue Parameters unsigned char * pBlock : pointer to the block of memory in use as the Queue ES_Event * pReturnEvent : used to return the event pulled from the queue Returns The number of entries remaining in the Queue Description pulls next available entry from Queue, EF_NO_EVENT if Queue was empty and copies it to *pReturnEvent. Notes Author J. Edward Carryer, 08/09/11, 19:11****************************************************************************/uint8_t ES_DeQueue( ES_Event * pBlock, ES_Event * pReturnEvent ){ pQueue_t pThisQueue; uint8_t NumLeft; pThisQueue = (pQueue_t)pBlock; if ( pThisQueue->NumEntries > 0) { EnterCritical(); // save interrupt state, turn ints off *pReturnEvent = pBlock[ 1 + pThisQueue->CurrentIndex ]; // inc the index pThisQueue->CurrentIndex++; // this way we only do the modulo operation when we really need to if (pThisQueue->CurrentIndex >= pThisQueue->QueueSize) pThisQueue->CurrentIndex = (uint8_t)(pThisQueue->CurrentIndex % pThisQueue->QueueSize); //dec number of elements since we took 1 out NumLeft = --pThisQueue->NumEntries; ExitCritical(); // restore saved interrupt state }else { // no items left in the queue (*pReturnEvent).EventType = ES_NO_EVENT; (*pReturnEvent).EventParam = 0; NumLeft = 0; } return NumLeft;}
开发者ID:NitinBandaru,项目名称:Test,代码行数:41,
示例2: whilevoid NativeSoundMix::DoPlay(){ while ( true ) { // Wait for a buffer done event WaitForSingleObject(playEvent, 10*1000); EnterCritical(); if ( !hWaveOut || !playEvent ) { LeaveCritical(); return; } // If a buffer is done, fill it... int nSent = 0; for ( int i = 0; i < nBuffers; i++ ) { WAVEHDR* hdr = waveHDR+i; if ( (hdr->dwFlags & WHDR_DONE) || !(hdr->dwFlags & WHDR_PREPARED) ) { if ( buffer[i] ) { BuildAndWrite( &waveHdr[i], false ); }// SendBuffer(i); nSent++; } } if ( nSent > nBuffers-2 ) EnlargeBuffers(); if ( nSilent > nBuffers ) CloseDevice(); LeaveCritical(); }}
开发者ID:RaymondLiao,项目名称:elektronika,代码行数:33,
示例3: SetCV/*** ===================================================================** Method : SetCV (component FreeCntr8)**** Description :** Sets compare or preload register value. The method is called ** automatically as a part of several internal methods.** This method is internal. It is used by Processor Expert only.** ===================================================================*/static void SetCV(word Val){ EnterCritical(); /* Disable global interrupts */ setReg(TMR0_CMPLD1,Val); /* Store given value to the compare preload 1 register */ setReg(TMR0_CMPLD2,Val); /* Store given value to the compare preload 2 register */ ExitCritical(); /* Enable global interrupts */}
开发者ID:sk3tch,项目名称:Freescale-RFID-Emulator,代码行数:17,
示例4: FCALC_GFD_DutyCycle_DecodeU8 FCALC_GFD_DutyCycle_Decode(U8 frequency){ U16 local_DutyCycleCopy = 0; EnterCritical(); local_DutyCycleCopy = M_PE6_Frequency_calc_DutyCycle; ExitCritical(); switch (frequency) { case 50: return 100-local_DutyCycleCopy / 50; break; case 40: return 100-local_DutyCycleCopy / 62; break; case 30: return 100-local_DutyCycleCopy / 83; break; case 20: return 100-local_DutyCycleCopy / 125; break; case 10: return 100-local_DutyCycleCopy / 250; break; default: return 0; }}
开发者ID:Skyturtle,项目名称:dashboard,代码行数:27,
示例5: LoadTicks/*** ===================================================================** Method : LoadTicks (component FreeCntr8)**** Description :** Loads actual number of timer ticks from internal variable. The ** method is called automatically as a part of several internal ** methods.** This method is internal. It is used by Processor Expert only.** ===================================================================*/static void LoadTicks(void){ EnterCritical(); /* Disable global interrupts */ LTicks = TTicks; /* Loading actual number of timer ticks */ LOvf = TOvf; /* Loading actual state of "overflow flag" */ ExitCritical(); /* Enable global interrupts */}
开发者ID:sk3tch,项目名称:Freescale-RFID-Emulator,代码行数:18,
示例6: route_deleteintroute_delete(ipaddr_t net, ipaddr_t netmask) { int i,ret; route_entry_p routep; mk_ip_table_rw(); EnterCritical(); i = get_routen(net,netmask); if (i == -1) { /* not found */ fprintf(stderr,"Route not found/n"); ret = -1; } else if (i == GETNUMROUTEENTRIES - 1) { /* last route */ DECNUMROUTEENTRIES; ret = 0; } else { /* shift up all entries */ for ( ; i < GETNUMROUTEENTRIES ; i++) { routep = GETROUTEP(i); *routep = *(GETROUTEP(i + 1)); } DECNUMROUTEENTRIES; ret = 0; } ExitCritical(); mk_ip_table_ro(); return ret;}
开发者ID:aunali1,项目名称:exopc,代码行数:30,
示例7: MFSOpenFile//Returns 0 on succses.//Returns size of file if non-empty//If positive, populates mfi.//Returns -1 if can't find file or reached end of file list.int8_t MFSOpenFile( const char * fname, struct MFSFileInfo * mfi ){ if( mfs_at == 0 ) { FindMPFS(); } if( mfs_at == 0 ) { return -1; } EnterCritical(); flashchip->chip_size = 0x01000000; uint32 ptr = mfs_at; struct MFSFileEntry e; while(1) { spi_flash_read( ptr, (uint32*)&e, sizeof( e ) ); ptr += sizeof(e); if( e.name[0] == 0xff || ets_strlen( e.name ) == 0 ) break; if( ets_strcmp( e.name, fname ) == 0 ) { mfi->offset = e.start; mfi->filelen = e.len; flashchip->chip_size = 0x00080000; ExitCritical(); return 0; } } flashchip->chip_size = 0x00080000; ExitCritical(); return -1;}
开发者ID:SiwyDym,项目名称:esp8266ws2812i2s,代码行数:38,
示例8: TimerStartKernelTimerunsigned TimerStartKernelTimer (TTimer *pThis, unsigned nDelay, TKernelTimerHandler *pHandler, void *pParam, void *pContext){ assert (pThis != 0); EnterCritical (); unsigned hTimer; for (hTimer = 0; hTimer < KERNEL_TIMERS; hTimer++) { if (pThis->m_KernelTimer[hTimer].m_pHandler == 0) { break; } } if (hTimer >= KERNEL_TIMERS) { LeaveCritical (); LoggerWrite (LoggerGet (), "timer", LogPanic, "System limit of kernel timers exceeded"); return 0; } assert (pHandler != 0); pThis->m_KernelTimer[hTimer].m_pHandler = pHandler; pThis->m_KernelTimer[hTimer].m_nElapsesAt = pThis->m_nTicks+nDelay; pThis->m_KernelTimer[hTimer].m_pParam = pParam; pThis->m_KernelTimer[hTimer].m_pContext = pContext; LeaveCritical (); return hTimer+1;}
开发者ID:AdamRLukaitis,项目名称:uspi,代码行数:34,
示例9: ifconfig/* INTERFACE MANAGEMENT */intifconfig(char *name, int flags, ipaddr_t ipaddr, ipaddr_t netmask, ipaddr_t broadcast) { if_entry_p ife; int ret; mk_ip_table_rw(); EnterCritical(); if ((ife = get_if_by_name(name))) { bcopy(ipaddr, ife->ipaddr, 4); bcopy(netmask, ife->netmask, 4); bcopy(broadcast, ife->broadcast, 4); apply_netmask(ife->net, ipaddr, netmask); ife->flags = flags; ret = 0; } else { fprintf(stderr,"ifconfig: Device not found: %s/n",name); ret = -1; } ExitCritical(); mk_ip_table_ro(); return ret;}
开发者ID:aunali1,项目名称:exopc,代码行数:26,
示例10: assertTString *TimerGetTimeString (TTimer *pThis){ assert (pThis != 0); EnterCritical (); unsigned nTime = pThis->m_nTime; unsigned nTicks = pThis->m_nTicks; LeaveCritical (); if (nTicks == 0) { return 0; } unsigned nSecond = nTime % 60; nTime /= 60; unsigned nMinute = nTime % 60; nTime /= 60; unsigned nHours = nTime; nTicks %= HZ;#if (HZ != 100) nTicks = nTicks * 100 / HZ;#endif TString *pString = malloc (sizeof (TString)); assert (pString != 0); String (pString); StringFormat (pString, "%02u:%02u:%02u.%02lu", nHours, nMinute, nSecond, nTicks); return pString;}
开发者ID:AdamRLukaitis,项目名称:uspi,代码行数:35,
示例11: SMasterLdd3_SendBlock/* ===================================================================*/LDD_TError SMasterLdd3_SendBlock(LDD_TDeviceData *DeviceDataPtr, LDD_TData *BufferPtr, uint16_t Size){ /* Clock configuration test - this test can be disabled by setting the "Ignore clock configuration test" property to the "yes" value in the "Configuration inspector" */ if (!((SMasterLdd3_TDeviceDataPtr)DeviceDataPtr)->EnMode) { /* Is the device disabled in the actual speed CPU mode? */ return ERR_SPEED; /* If yes then error */ } /* Device state test - this test can be disabled by setting the "Ignore enable test" property to the "yes" value in the "Configuration inspector" */ if (!((SMasterLdd3_TDeviceDataPtr)DeviceDataPtr)->EnUser) { /* Is the device disabled by user? */ return ERR_DISABLED; /* If yes then error */ } if (((SMasterLdd3_TDeviceDataPtr)DeviceDataPtr)->OutDataNumReq != 0x00U) { /* Is the previous transmit operation pending? */ return ERR_BUSY; /* If yes then error */ } /* {Default RTOS Adapter} Critical section begin, general PE function is used */ EnterCritical(); ((SMasterLdd3_TDeviceDataPtr)DeviceDataPtr)->OutDataPtr = (uint8_t*)BufferPtr; /* Set a pointer to the output data. */ ((SMasterLdd3_TDeviceDataPtr)DeviceDataPtr)->OutDataNumReq = Size; /* Set the counter of characters to be sent. */ ((SMasterLdd3_TDeviceDataPtr)DeviceDataPtr)->OutSentDataNum = 0x00U; /* Clear the counter of sent characters. */ SPI_PDD_EnableDmasInterrupts(SPI2_BASE_PTR, SPI_PDD_TX_FIFO_FILL_INT_DMA); /* Enable TX interrupt */ /* {Default RTOS Adapter} Critical section end, general PE function is used */ ExitCritical(); return ERR_OK; /* OK */}
开发者ID:LoicGuillain,项目名称:Freescale,代码行数:26,
示例12: portTASK_FUNCTION/** * /brief Touch Task. Starts and stops walking Task by touchsensor. * @param TouchTask Taskname * @param pvParameters Not used * @return void */static portTASK_FUNCTION(TouchTask, pvParameters) { uint8_t errCode; uint16_t touchStatus; (void)pvParameters; TOUCH_init(); WAIT1_WaitOSms(10); for(;;) { errCode=TOUCH_getELE(&touchStatus); if(errCode != ERR_OK) { for(;;) {} /* error occurred!*/ } if(touchStatus!=0) { if (enabledWalking) { EnterCritical(); if(enabledWalking) { /* stop walking*/ enabledWalking = FALSE; } else { /* start walking*/ enabledWalking = TRUE; } ExitCritical(); } WAIT1_WaitOSms(1000); } WAIT1_WaitOSms(16); /* 16ms sampling time*/ }}
开发者ID:3ben1189,项目名称:mcuoneclipse,代码行数:33,
示例13: freevoid free (void *pBlock){ assert (pBlock != 0); TBlockHeader *pBlockHeader = (TBlockHeader *) ((unsigned long) pBlock - sizeof (TBlockHeader)); assert (pBlockHeader->nMagic == BLOCK_MAGIC); for (TBlockBucket *pBucket = s_BlockBucket; pBucket->nSize > 0; pBucket++) { if (pBlockHeader->nSize == pBucket->nSize) { EnterCritical (); pBlockHeader->pNext = pBucket->pFreeList; pBucket->pFreeList = pBlockHeader;#ifdef MEM_DEBUG pBucket->nCount--;#endif LeaveCritical (); break; } }}
开发者ID:Kokoro666,项目名称:Evangelion-Kernel,代码行数:25,
示例14: EnterCriticalvoid *PageAlloc(void){ EnterCritical ();#ifdef MEM_DEBUG if (++s_PageBucket.nCount > s_PageBucket.nMaxCount) { s_PageBucket.nMaxCount = s_PageBucket.nCount; }#endif TFreePage *pFreePage; if ((pFreePage = s_PageBucket.pFreeList) != 0) { s_PageBucket.pFreeList = pFreePage->pNext; pFreePage->nMagic = 0; } else { pFreePage = (TFreePage *) s_pNextPage; s_pNextPage += PAGE_SIZE; if (s_pNextPage > s_pPageLimit) { LeaveCritical (); return 0; // TODO: system should panic here } } LeaveCritical (); return pFreePage;}
开发者ID:Nvreformat,项目名称:Siwka-OS,代码行数:35,
示例15: EnterCriticalvoid CPollQProducer::Run() { unsigned short usValue = ( unsigned short ) 0; BaseType_t xError = pdFALSE, xLoop; for( ;; ) { for( xLoop = 0; xLoop < pollqVALUES_TO_PRODUCE; xLoop++ ) { /* Send an incrementing number on the queue without blocking. */ if( m_pQueue->Send((void*)&usValue, pollqNO_DELAY ) != pdPASS ) { /* We should never find the queue full so if we get here there has been an error. */ xError = pdTRUE; } else { if( xError == pdFALSE ) { /* If an error has ever been recorded we stop incrementing the check variable. */ EnterCritical(); m_nPollingCount++; ExitCritical(); } /* Update the value we are going to post next time around. */ usValue++; } } /* Wait before we start posting again to ensure the consumer runs and empties the queue. */ Delay(pollqPRODUCER_DELAY); }}
开发者ID:dessel,项目名称:stf12,代码行数:34,
示例16: RealTimeLdd1_GetTimeMS/* ===================================================================*/LDD_TError RealTimeLdd1_GetTimeMS(LDD_TDeviceData *DeviceDataPtr, uint16_t *TimePtr){ RealTimeLdd1_TDeviceData *DeviceDataPrv = (RealTimeLdd1_TDeviceData *)DeviceDataPtr; uint32_t CopyTicks; /* Working copy of variable TimerTicks */ bool CopyOverflow; /* Working copy of variable Overflow */ LDD_RealTime_Tfloat rtval; /* Result of multiplication */ /* {Default RTOS Adapter} Critical section begin, general PE function is used */ EnterCritical(); CopyTicks = DeviceDataPrv->TimerTicks; /* Loading actual number of timer ticks */ CopyOverflow = DeviceDataPrv->Overflow; /* Loading actual state of "overflow flag" */ /* {Default RTOS Adapter} Critical section end, general PE function is used */ ExitCritical(); if (CopyOverflow) { /* Testing counter overflow */ return ERR_OVERFLOW; /* If yes then error */ } rtval = CopyTicks * 6.25F; /* Multiply ticks and clock configuration 0 coefficient */ if (rtval > 0xFFFFUL) { /* Is the result greater than 65535 ? */ return ERR_MATH; /* If yes then error */ } else { *TimePtr = (uint16_t)rtval; } return ERR_OK;}
开发者ID:arulle,项目名称:CC3501,代码行数:26,
示例17: WriteWord/*** ===================================================================** Method : WriteWord (bean IntFLASH)**** Description :** This method is internal. ** ===================================================================*/byte WriteWord(word *Address,word Data16){ byte err; word Addr=(word)Address; EnterCritical(); /* Enter critical section */ FSTAT = 48; /* Clear all flags */ if (FSTAT_CBEIF == 0) { /* Is command buffer full ? */ ExitCritical(); /* Exit critical section */ return ERR_BUSY; /* If yes then error */ } *(volatile word *) Addr = Data16; /* Array address and program data */ FCMD = 32; /* Word program command */ FSTAT = 128; /* Clear flag command buffer empty */ asm { /* Jump to Wait in RAM code */ CLRB JSR WaitInRAMcode STAB err } ExitCritical(); /* Exit critical section */ if (err) return ERR_NOTAVAIL; /* Return error code if previous operation finished not correctly */ if (*(volatile word *) Addr != Data16) /* Was attempt to write data to the given address errorneous? */ return ERR_VALUE; /* If yes then error */ return ERR_OK; /* OK */}
开发者ID:jonyMarino,项目名称:microsdhacel,代码行数:34,
示例18: HWEnDi/*** ===================================================================** Method : HWEnDi (bean AsynchroSerial)**** Description :** Enables or disables the peripheral(s) associated with the bean.** The method is called automatically as a part of the Enable and ** Disable methods and several internal methods.** This method is internal. It is used by Processor Expert only.** ===================================================================*/static void HWEnDi(void){ EnterCritical(); /* Save the PS register */ if(EnMode && EnUser) { /* Enable device? */ SCI2BDH = 0x00; /* Set high divisor register (enable device) */ SCI2BDL = 0xA4; /* Set low divisor register (enable device) */ /* SCI2C3: ORIE=1,NEIE=1,FEIE=1,PEIE=1 */ SCI2C3 |= 0x0F; /* Enable error interrupts */ SCI2C2 |= ( SCI2C2_TE_MASK | SCI2C2_RE_MASK | SCI2C2_RIE_MASK | SCI2C2_ILIE_MASK); /* Enable transmitter, Enable receiver, Enable receiver interrupt, Enable idle interrupt */ if(SerFlag & FULL_TX) { /* Is any char in the transmit buffer? */ (void)SCI2S1; /* Reset interrupt request flag */ while(!SCI2S1_TDRE) {} /* Wait for transmitter empty */ SCI2D = (byte)BufferWrite; /* Store char to the transmitter register */ SCI2C2_TIE = 1; /* Enable transmit interrupt */ } } else { /* SCI2C3: ORIE=0,NEIE=0,FEIE=0,PEIE=0 */ SCI2C3 &= ~0x0F; /* Disable error interrupts */ SCI2C2 &= ( (~SCI2C2_RE_MASK) & (~SCI2C2_TE_MASK) & (~SCI2C2_TIE_MASK) & (~SCI2C2_RIE_MASK) & (~SCI2C2_ILIE_MASK)); /* Disable receiver, Disable transmitter, Disable transmit interrupt, Disable receiver interrupt, Disable idle interrupt */ SCI2BDH = 0x00; /* Set high divisor register to zero (disable device) */ SCI2BDL = 0x00; /* Set low divisor register to zero (disable device) */ } ExitCritical(); /* Restore the PS register */}
开发者ID:WaterOptimizer,项目名称:WOIS-PE,代码行数:36,
示例19: WriteArray/*** ===================================================================** Method : RestoreSector (bean IntFLASH)**** Description :** This method is internal. ** ===================================================================*/byte WriteArray(void * Address,word From, word To, word* Array){ word Addr=(word)Address; byte err; word i; EnterCritical(); /* Enter critical section */ FSTAT = 48; /* Clear all flags */ for (i = From; i < To; i+=2) { *(volatile word *) (Addr+i) = Array[i/2]; FCMD = 32; /* Word program command */ FSTAT = 128; /* Clear flag command buffer empty */ asm { /* Jump to Wait in RAM code */ CLRB JSR WaitInRAMcode STAB err } if (err) { ExitCritical(); /* Exit critical section */ return ERR_NOTAVAIL; /* Return error code if previous operation finished not correctly */ } if (*(volatile word *) (Addr+i) != Array[i/2]) { /* Was attempt to write data to the given address errorneous? */ ExitCritical(); /* Exit critical section */ return ERR_VALUE; /* If yes then error */ } } ExitCritical(); /* Exit critical section */ return ERR_OK; /* OK */}
开发者ID:jonyMarino,项目名称:microsdhacel,代码行数:38,
示例20: EraseSectorInternal/*** ===================================================================** Method : EraseSectorInternal (bean IntFLASH)**** Description :** This method is internal. ** ===================================================================*/byte EraseSectorInternal(void * Address){ word Addr =(word)Address; byte err; EnterCritical(); /* Enter critical section */ FSTAT = 48; /* Clear all flags */ if (FSTAT_CBEIF == 0) { /* Is command buffer full ? */ ExitCritical(); /* Exit critical section */ return ERR_BUSY; /* If yes then error */ } *(volatile word *) (Addr & 65024) = IFsh10_DummyData; /* Write eny word to FLASH buffer */ FCMD = 64; /* Initiate Sector Erase commamd */ FSTAT = 128; /* Clear flag command buffer empty */ asm { /* Jump to Wait in RAM code */ CLRB JSR WaitInRAMcode STAB err } ExitCritical(); /* Exit critical section */ if (err) return err; /* Return error code if previous operation finished not correctly */ return ERR_OK; /* OK */}
开发者ID:jonyMarino,项目名称:microsdhacel,代码行数:33,
示例21: SM1_SendBlock/*** ===================================================================** Method : SM1_SendBlock (component SynchroMaster)** Description :** Send a block of characters to the channel. This method is** only available if a non-zero length of output buffer is** defined.** Parameters :** NAME - DESCRIPTION** * Ptr - Pointer to the block of data to send** Size - Size of the block** * Snd - Pointer to number of data that are sent** (moved to buffer)** 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 (only if** output DMA is supported and enabled)** ERR_TXFULL - It was not possible to send** requested number of bytes** ===================================================================*/byte SM1_SendBlock(SM1_TComData *Ptr, word Size, word *Snd){ word count = 0x00U; /* Number of sent chars */ SM1_TComData *TmpPtr = Ptr; /* Temporary output buffer pointer */ bool tmpOnFreeTxBufSemaphore = OnFreeTxBufSemaphore; /* Local copy of OnFreeTxBufSemaphore state */ while((count < Size) && (SM1_OutLen < SM1_OUT_BUF_SIZE)) { /* While there is some char desired to send left and output buffer is not full do */ EnterCritical(); /* Enter the critical section */ OnFreeTxBufSemaphore = TRUE; /* Set the OnFreeTxBufSemaphore to block OnFreeTxBuf calling */ SM1_OutLen++; /* Increase number of bytes in the transmit buffer */ OutBuffer[OutIndexW++] = *TmpPtr++; /* Store char to buffer */ if (OutIndexW >= SM1_OUT_BUF_SIZE) { /* Is the index out of the transmit buffer? */ OutIndexW = 0x00U; /* Set index to the first item in the transmit buffer */ } count++; /* Increase the count of sent data */ if ((count == Size) || (SM1_OutLen == SM1_OUT_BUF_SIZE)) { /* Is the last desired char put into buffer or the buffer is full? */ if (!tmpOnFreeTxBufSemaphore) { /* Was the OnFreeTxBufSemaphore clear before enter the method? */ OnFreeTxBufSemaphore = FALSE; /* If yes then clear the OnFreeTxBufSemaphore */ } } if ((EnUser) && ((SerFlag & RUNINT_FROM_TX) == 0U)) { /* Is the device enabled by user? */ SerFlag |= RUNINT_FROM_TX; /* Set flag "running int from TX"? */ (void)SMasterLdd1_SendBlock(SMasterLdd1_DeviceDataPtr, (LDD_TData *)&OutBuffer[OutIndexR], 1U); /* Send one data byte */ } ExitCritical(); /* Exit the critical section */ } *Snd = count; /* Return number of sent chars */ if (count != Size) { /* Is the number of sent chars less then desired number of chars */ return ERR_TXFULL; /* If yes then error */ } return ERR_OK; /* OK */}
开发者ID:nikolarobottesla,项目名称:BatteryTestSystem,代码行数:56,
示例22: AS1_SendBlock/*** ===================================================================** Method : AS1_SendBlock (component AsynchroSerial)** Description :** Sends a block of characters to the channel.** This method is available only if non-zero length of the** output buffer is defined and the transmitter property is** enabled.** Parameters :** NAME - DESCRIPTION** * Ptr - Pointer to the block of data to send** Size - Size of the block** * Snd - Pointer to number of data that are sent** (moved to buffer)** Returns :** --- - Error code, possible codes:** ERR_OK - OK** ERR_SPEED - This device does not work in** the active speed mode** ERR_TXFULL - It was not possible to send** requested number of bytes** ===================================================================*/byte AS1_SendBlock(AS1_TComData *Ptr, word Size, word *Snd){ word count = 0x00U; /* Number of sent chars */ AS1_TComData *TmpPtr = Ptr; /* Temporary output buffer pointer */ while ((count < Size) && (AS1_OutLen < AS1_OUT_BUF_SIZE)) { /* While there is some char desired to send left and output buffer is not full do */ EnterCritical(); /* Enter the critical section */ AS1_OutLen++; /* Increase number of bytes in the transmit buffer */ OutBuffer[OutIndexW++] = *TmpPtr++; /* Store char to buffer */ if (OutIndexW >= AS1_OUT_BUF_SIZE) { /* Is the index out of the transmit buffer? */ OutIndexW = 0x00U; /* Set index to the first item in the transmit buffer */ } count++; /* Increase the count of sent data */ if ((SerFlag & RUNINT_FROM_TX) == 0U) { SerFlag |= RUNINT_FROM_TX; /* Set flag "running int from TX"? */ (void)ASerialLdd1_SendBlock(ASerialLdd1_DeviceDataPtr, (LDD_TData *)&OutBuffer[OutIndexR], 1U); /* Send one data byte */ } ExitCritical(); /* Exit the critical section */ } *Snd = count; /* Return number of sent chars */ if (count != Size) { /* Is the number of sent chars less then desired number of chars */ return ERR_TXFULL; /* If yes then error */ } return ERR_OK; /* OK */}
开发者ID:nikolarobottesla,项目名称:BatteryTestSystem,代码行数:48,
示例23: I2C_StoreCmdvoid I2C_StoreCmd(void) {#if PL_HAS_UI unsigned char buf[32]; uint8_t strSize;#if PL_HAS_RUNNER buf[0] = '@'; buf[1] = '/0'; RUNNER_GetCmdString(buf, sizeof(buf));#elif PL_HAS_SLIDER SLIDER_GetCmdString(buf, sizeof(buf));#else buf[0] = '/0';#endif if (buf[0]!='/0') { uint8_t cnt=3; while(cnt>0 && memDevice.u.data.cmdLength!=0) { /* poll cmdLength: this will be set to zero by the master if it is ok to place the string */ FRTOS1_vTaskDelay(50/portTICK_RATE_MS); /* give master some time to clear the flasg */ cnt--; } if (cnt==0) { /* timeout. Will loose that command. Not ideal, but simple :-) */ return; /* get out here */ } strSize = (uint8_t)(UTIL1_strlen(buf)+1); /* size of string including zero byte */ if (strSize>sizeof(memDevice.u.data.cmd)) { strSize = sizeof(memDevice.u.data.cmd); } EnterCritical(); memDevice.u.data.cmdLength = strSize; UTIL1_strcpy(memDevice.u.data.cmd, sizeof(memDevice.u.data.cmd), buf); ExitCritical(); }#endif /* PL_HAS_UI */}
开发者ID:krlosburgos,项目名称:mcuoneclipse,代码行数:35,
示例24: I2C_GetMotorPID_Dint32_t I2C_GetMotorPID_D(void) { int32_t val; EnterCritical(); val = memDevice.u.data.motorPID_D; ExitCritical(); return val;}
开发者ID:krlosburgos,项目名称:mcuoneclipse,代码行数:8,
示例25: I2C_GetMotorDesiredSpeedint32_t I2C_GetMotorDesiredSpeed(void) { int32_t val; EnterCritical(); val = memDevice.u.data.motorDesiredSpeed; ExitCritical(); return val;}
开发者ID:krlosburgos,项目名称:mcuoneclipse,代码行数:8,
示例26: I2C_GetMotorPWMPercentint8_t I2C_GetMotorPWMPercent(void) { int8_t val; EnterCritical(); val = memDevice.u.data.motorPWM; ExitCritical(); return val;}
开发者ID:krlosburgos,项目名称:mcuoneclipse,代码行数:8,
示例27: I2C_GetEKGIsDataReadybool I2C_GetEKGIsDataReady(void) { bool val; EnterCritical(); val = (bool)(memDevice.u.data.ekgNewReady!=0); ExitCritical(); return val;}
开发者ID:krlosburgos,项目名称:mcuoneclipse,代码行数:8,
示例28: I2C_GetEKGHeartRateuint8_t I2C_GetEKGHeartRate(void) { uint8_t val; EnterCritical(); val = memDevice.u.data.ekgHeartRate; ExitCritical(); return val;}
开发者ID:krlosburgos,项目名称:mcuoneclipse,代码行数:8,
示例29: I2C_GetAccelZint16_t I2C_GetAccelZ(void) { int16_t val; EnterCritical(); val = memDevice.u.data.accelZ; ExitCritical(); return val;}
开发者ID:krlosburgos,项目名称:mcuoneclipse,代码行数:8,
注:本文中的EnterCritical函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ EnterEvadeIfOutOfCombatArea函数代码示例 C++ EnsureVisible函数代码示例 |