本文整理汇总了C++中pdMS_TO_TICKS函数的典型用法代码示例。如果您正苦于以下问题:C++ pdMS_TO_TICKS函数的具体用法?C++ pdMS_TO_TICKS怎么用?C++ pdMS_TO_TICKS使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pdMS_TO_TICKS函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: ButtonTask
/* SW2: PTC1 (near USB)
* SW3: PTB17
*/
static void ButtonTask(void *pvParameters) {
(void)pvParameters;
g = 3.5;
floatFunc(5.5);
for(;;) {
if (SW2IsPressed()) { /* SW2 pressed */
PrintButtonPressed(2, TRUE);
vTaskDelay(pdMS_TO_TICKS(50)); /* debounce */
while(SW2IsPressed()) { /* wait until released */
//vTaskDelay(pdMS_TO_TICKS(50)); /*! \todo 4 Add delay of 50 ms */
}
PrintButtonPressed(2, FALSE);
(void)xSemaphoreGive(semSW2); /* send message to toggle USB */
(void)xSemaphoreGive(semMouse); /* send message to toggle USB */
(void)xSemaphoreGive(semKbd); /* send message to toggle USB */
}
if (SW3IsPressed()) { /* SW3 pressed */
PrintButtonPressed(3, TRUE);
vTaskDelay(pdMS_TO_TICKS(50)); /* debounce */
while(SW3IsPressed()) { /* wait until released */
//vTaskDelay(pdMS_TO_TICKS(50)); /*! \todo 5 Add delay of 50 ms */
}
PrintButtonPressed(3, FALSE);
(void)xSemaphoreGive(semSW3); /* send message */
(void)xSemaphoreGive(semLED); /* send message to change LED */
}
//vTaskDelay(pdMS_TO_TICKS(10)); /*! \todo 2 Add delay of 10 ms */
}
}
开发者ID:SISommer,项目名称:mcuoneclipse,代码行数:32,代码来源:Application.c
示例2: SWT_Init
void SWT_Init(void) {
BaseType_t res;
led = 0; /* red */
#if configSUPPORT_STATIC_ALLOCATION
handle = xTimerCreateStatic(
"swtimer", /* debug name of task */
pdMS_TO_TICKS(500), /* period */
pdTRUE, /* auto-reload */
NULL, /* no timer ID */
vTimerCallback, /* callback */
&xTimerBuffer
);
#else /* configSUPPORT_DYNAMIC_ALLOCATION */
handle = xTimerCreate(
"swtimer", /* debug name of task */
pdMS_TO_TICKS(500), /* period */
pdTRUE, /* auto-reload */
NULL, /* no timer ID */
vTimerCallback /* callback */
);
#endif
if (handle==NULL) {
for(;;); /* error creating timer */
}
res = xTimerStart(handle, 0);
if (res==pdFAIL) {
for(;;); /* error starting timer */
}
}
开发者ID:Johnnygx,项目名称:mcuoneclipse,代码行数:30,代码来源:SwTimer.c
示例3: main
/**************************************************************************//**
* @brief Main function
*****************************************************************************/
int main(void)
{
/* Chip errata */
CHIP_Init();
/* If first word of user data page is non-zero, enable eA Profiler trace */
BSP_TraceProfilerSetup();
/* Initialize LED driver */
BSP_LedsInit();
/* Setting state of leds*/
BSP_LedSet(0);
BSP_LedSet(1);
/* Initialize SLEEP driver, no calbacks are used */
SLEEP_Init(NULL, NULL);
#if (configSLEEP_MODE < 3)
/* do not let to sleep deeper than define */
SLEEP_SleepBlockBegin((SLEEP_EnergyMode_t)(configSLEEP_MODE+1));
#endif
/* Parameters value for taks*/
static TaskParams_t parametersToTask1 = { pdMS_TO_TICKS(1000), 0 };
static TaskParams_t parametersToTask2 = { pdMS_TO_TICKS(500), 1 };
/*Create two task for blinking leds*/
xTaskCreate( LedBlink, (const char *) "LedBlink1", STACK_SIZE_FOR_TASK, ¶metersToTask1, TASK_PRIORITY, NULL);
xTaskCreate( LedBlink, (const char *) "LedBlink2", STACK_SIZE_FOR_TASK, ¶metersToTask2, TASK_PRIORITY, NULL);
/*Start FreeRTOS Scheduler*/
vTaskStartScheduler();
return 0;
}
开发者ID:SiliconLabs,项目名称:Gecko_SDK,代码行数:36,代码来源:main.c
示例4: test_runner
void test_runner(void *arg)
{
PUBNUB_UNUSED(arg);
for (;;) {
unsigned next_test = 0;
unsigned failed_count = 0;
unsigned passed_count = 0;
unsigned indete_count = 0;
unsigned tests_in_progress = 0;
FreeRTOS_printf(("Starting Run of %d tests\n", TEST_COUNT));
while (failed_count + passed_count + indete_count < TEST_COUNT) {
struct TestResultMessage msg;
if ((tests_in_progress < g_max_conc_tests) && (next_test < TEST_COUNT)) {
start_test(next_test++);
++tests_in_progress;
}
if (pdTRUE == xQueueReceive(m_TestResultQueue, &msg, pdMS_TO_TICKS(20))) {
switch (msg.result) {
case trFail:
FreeRTOS_printf(("\n !!!!!!! The %d. test ('%s') failed!\n\n", msg.test + 1, m_aTest[msg.test].name));
++failed_count;
break;
case trPass:
++passed_count;
break;
case trIndeterminate:
++indete_count;
FreeRTOS_printf((" Indeterminate %d. test ('%s') of %d\t", msg.test+1, m_aTest[msg.test].name, TEST_COUNT));
/* Should restart the test... */
//FreeRTOS_printf((" ReStarting %d. test of %ld\t", msg.test + 1, TEST_COUNT));
break;
}
#ifdef INCLUDE_vTaskDelete
vTaskDelete(m_aTest[msg.test].task);
#endif
--tests_in_progress;
}
}
FreeRTOS_printf(("Test run over.\n"));
if (passed_count == TEST_COUNT) {
FreeRTOS_printf(("\n All %d tests passed\n", TEST_COUNT));
}
else {
FreeRTOS_printf(("\n\n %d tests passed, %d tests failed, %d tests indeterminate\n",
passed_count,
failed_count,
indete_count
));
}
vTaskDelay(pdMS_TO_TICKS(10 * 1000));
}
}
开发者ID:evanbeard,项目名称:c-core,代码行数:57,代码来源:pubnub_fntest_runner.c
示例5: vStartNTPTask
void vStartNTPTask( uint16_t usTaskStackSize, UBaseType_t uxTaskPriority )
{
/* The only public function in this module: start a task to contact
some NTP server. */
if( xNTPTaskhandle != NULL )
{
switch( xStatus )
{
case EStatusPause:
xStatus = EStatusAsking;
vSignalTask();
break;
case EStatusLookup:
FreeRTOS_printf( ( "NTP looking up server\n" ) );
break;
case EStatusAsking:
FreeRTOS_printf( ( "NTP still asking\n" ) );
break;
case EStatusFailed:
FreeRTOS_printf( ( "NTP failed somehow\n" ) );
ulIPAddressFound = 0ul;
xStatus = EStatusLookup;
vSignalTask();
break;
}
}
else
{
xUDPSocket = FreeRTOS_socket( FREERTOS_AF_INET, FREERTOS_SOCK_DGRAM, FREERTOS_IPPROTO_UDP );
if( xUDPSocket != NULL )
{
struct freertos_sockaddr xAddress;
#if( ipconfigUSE_CALLBACKS != 0 )
BaseType_t xReceiveTimeOut = pdMS_TO_TICKS( 0 );
#else
BaseType_t xReceiveTimeOut = pdMS_TO_TICKS( 5000 );
#endif
xAddress.sin_addr = 0ul;
xAddress.sin_port = FreeRTOS_htons( NTP_PORT );
FreeRTOS_bind( xUDPSocket, &xAddress, sizeof( xAddress ) );
FreeRTOS_setsockopt( xUDPSocket, 0, FREERTOS_SO_RCVTIMEO, &xReceiveTimeOut, sizeof( xReceiveTimeOut ) );
xTaskCreate( prvNTPTask, /* The function that implements the task. */
( const char * ) "NTP client", /* Just a text name for the task to aid debugging. */
usTaskStackSize, /* The stack size is defined in FreeRTOSIPConfig.h. */
NULL, /* The task parameter, not used in this case. */
uxTaskPriority, /* The priority assigned to the task is defined in FreeRTOSConfig.h. */
&xNTPTaskhandle ); /* The task handle. */
}
else
{
FreeRTOS_printf( ( "Creating socket failed\n" ) );
}
}
}
开发者ID:notwendig,项目名称:FreeRTOS-eZ80F91,代码行数:57,代码来源:NTPDemo.c
示例6: main_thread
void
main_thread(void *pdata) {
try_flash();
if (user_vtor[1] == 0xFFFFFFFF) {
serial_puts(&Serial1, "No application loaded, trying to load again in 10 seconds\r\n");
vTaskDelay(pdMS_TO_TICKS(10000));
NVIC_SystemReset();
} else {
serial_puts(&Serial1, "Booting application\r\n");
vTaskDelay(pdMS_TO_TICKS(250));
reset_and_jump();
}
}
开发者ID:lispmeister,项目名称:laureline-firmware,代码行数:13,代码来源:main.c
示例7: xPhyCheckLinkStatus
BaseType_t xPhyCheckLinkStatus( EthernetPhy_t *pxPhyObject, BaseType_t xHadReception )
{
uint32_t ulStatus, ulBitMask = 1u;
BaseType_t xPhyIndex;
BaseType_t xNeedCheck = pdFALSE;
if( xHadReception > 0 )
{
/* A packet was received. No need to check for the PHY status now,
but set a timer to check it later on. */
vTaskSetTimeOutState( &( pxPhyObject->xLinkStatusTimer ) );
pxPhyObject->xLinkStatusRemaining = pdMS_TO_TICKS( ipconfigPHY_LS_HIGH_CHECK_TIME_MS );
}
else if( xTaskCheckForTimeOut( &( pxPhyObject->xLinkStatusTimer ), &( pxPhyObject->xLinkStatusRemaining ) ) != pdFALSE )
{
for( xPhyIndex = 0; xPhyIndex < pxPhyObject->xPortCount; xPhyIndex++, ulBitMask <<= 1 )
{
BaseType_t xPhyAddress = pxPhyObject->ucPhyIndexes[ xPhyIndex ];
if( pxPhyObject->fnPhyRead( xPhyAddress, phyREG_01_BMSR, &ulStatus ) == 0 )
{
if( !!( pxPhyObject->ulLinkStatusMask & ulBitMask ) != !!( ulStatus & phyBMSR_LINK_STATUS ) )
{
if( ( ulStatus & phyBMSR_LINK_STATUS ) != 0 )
{
pxPhyObject->ulLinkStatusMask |= ulBitMask;
}
else
{
pxPhyObject->ulLinkStatusMask &= ~( ulBitMask );
}
FreeRTOS_printf( ( "xPhyCheckLinkStatus: PHY LS now %02lX\n", pxPhyObject->ulLinkStatusMask ) );
eventLogAdd( "PHY LS now %02lX", pxPhyObject->ulLinkStatusMask );
xNeedCheck = pdTRUE;
}
}
}
vTaskSetTimeOutState( &( pxPhyObject->xLinkStatusTimer ) );
if( ( pxPhyObject->ulLinkStatusMask & phyBMSR_LINK_STATUS ) != 0 )
{
pxPhyObject->xLinkStatusRemaining = pdMS_TO_TICKS( ipconfigPHY_LS_HIGH_CHECK_TIME_MS );
}
else
{
pxPhyObject->xLinkStatusRemaining = pdMS_TO_TICKS( ipconfigPHY_LS_LOW_CHECK_TIME_MS );
}
}
return xNeedCheck;
}
开发者ID:cjlano,项目名称:freertos,代码行数:49,代码来源:phyHandling.c
示例8: cliWriteConfig
static void
cliWriteConfig(void) {
int16_t result;
if (!HAS_FEATURE(PPSEN) && (cfg.flags & FLAG_PPSEN)) {
cli_puts("WARNING: PPS output not available on this hardware\r\n");
cfg.flags &= ~FLAG_PPSEN;
}
if ((cfg.flags & (FLAG_GPSEXT | FLAG_GPSOUT)) == (FLAG_GPSEXT | FLAG_GPSOUT)) {
cli_puts("WARNING: gps_ext_in and gps_ext_out are mutually exclusive.\r\n");
cfg.flags &= ~FLAG_GPSOUT;
}
/* Check for more than one ntpkey type */
result = 0;
if (cfg.flags & FLAG_NTPKEY_MD5) {
result++;
}
if (cfg.flags & FLAG_NTPKEY_SHA1) {
result++;
}
if (result > 1) {
cli_puts("WARNING: More than one ntpkey type specified\r\n");
cfg.flags &= ~(FLAG_NTPKEY_MD5 | FLAG_NTPKEY_SHA1);
}
cli_puts("Writing EEPROM...\r\n");
result = eeprom_write_cfg();
if (result == EERR_OK) {
cli_puts("OK\r\n");
serial_drain(cl_out);
vTaskDelay(pdMS_TO_TICKS(1000));
NVIC_SystemReset();
} else {
show_eeprom_error(result);
}
}
开发者ID:lispmeister,项目名称:laureline-firmware,代码行数:34,代码来源:cmdline.c
示例9: prvCheckTask
static void prvCheckTask( void *pvParameters )
{
const TickType_t xCycleFrequency = pdMS_TO_TICKS( 2500UL );
static char *pcStatusMessage = "No errors";
/* Just to remove compiler warning. */
( void ) pvParameters;
for( ;; )
{
/* Place this task in the blocked state until it is time to run again. */
vTaskDelay( xCycleFrequency );
/* Check the tasks that use static allocation are still executing. */
if( xAreStaticAllocationTasksStillRunning() != pdPASS )
{
pcStatusMessage = "Error: Static allocation";
}
/* This is the only task that uses stdout so its ok to call printf()
directly. */
printf( "%s - tick count %d - number of tasks executing %d\r\n",
pcStatusMessage,
xTaskGetTickCount(),
uxTaskGetNumberOfTasks() );
}
}
开发者ID:Eclo,项目名称:FreeRTOS,代码行数:27,代码来源:main.c
示例10: prvQueueReceiveTask
static void prvQueueReceiveTask( void *pvParameters )
{
uint32_t ulReceivedValue;
const uint32_t ulExpectedValue = 100UL;
const TickType_t xShortDelay = pdMS_TO_TICKS( 10 );
/* Remove compiler warning about unused parameter. */
( void ) pvParameters;
for( ;; )
{
/* Wait until something arrives in the queue - this task will block
indefinitely provided INCLUDE_vTaskSuspend is set to 1 in
FreeRTOSConfig.h. */
xQueueReceive( xQueue, &ulReceivedValue, portMAX_DELAY );
/* To get here something must have been received from the queue, but
is it the expected value? If it is, toggle the LED. */
if( ulReceivedValue == ulExpectedValue )
{
/* Blip the LED briefly to show the demo is running, but without
leaving the LED on too long as energy is being conserved. */
mainTOGGLE_LED();
vTaskDelay( xShortDelay );
mainTOGGLE_LED();
ulReceivedValue = 0U;
}
}
}
开发者ID:mattmanj17,项目名称:freertos,代码行数:30,代码来源:main_low_power.c
示例11: prvCreateDNSSocket
static Socket_t prvCreateDNSSocket( void )
{
static Socket_t xSocket = NULL;
struct freertos_sockaddr xAddress;
BaseType_t xReturn;
TickType_t xTimeoutTime = pdMS_TO_TICKS( 200 );
/* This must be the first time this function has been called. Create
the socket. */
xSocket = FreeRTOS_socket( FREERTOS_AF_INET, FREERTOS_SOCK_DGRAM, FREERTOS_IPPROTO_UDP );
/* Auto bind the port. */
xAddress.sin_port = 0u;
xReturn = FreeRTOS_bind( xSocket, &xAddress, sizeof( xAddress ) );
/* Check the bind was successful, and clean up if not. */
if( xReturn != 0 )
{
FreeRTOS_closesocket( xSocket );
xSocket = NULL;
}
else
{
/* Set the send and receive timeouts. */
FreeRTOS_setsockopt( xSocket, 0, FREERTOS_SO_RCVTIMEO, ( void * ) &xTimeoutTime, sizeof( TickType_t ) );
FreeRTOS_setsockopt( xSocket, 0, FREERTOS_SO_SNDTIMEO, ( void * ) &xTimeoutTime, sizeof( TickType_t ) );
}
return xSocket;
}
开发者ID:unnamet,项目名称:Repo,代码行数:30,代码来源:FreeRTOS_DNS.c
示例12: xNetworkInterfaceInitialise
BaseType_t xNetworkInterfaceInitialise( void )
{
const TickType_t x5_Seconds = 5000UL;
if( xEMACTaskHandle == NULL )
{
prvGMACInit();
/* Wait at most 5 seconds for a Link Status in the PHY. */
xGMACWaitLS( pdMS_TO_TICKS( x5_Seconds ) );
/* The handler task is created at the highest possible priority to
ensure the interrupt handler can return directly to it. */
xTaskCreate( prvEMACHandlerTask, "EMAC", configEMAC_TASK_STACK_SIZE, NULL, configMAX_PRIORITIES - 1, &xEMACTaskHandle );
configASSERT( xEMACTaskHandle );
}
if( xTxBufferQueue == NULL )
{
xTxBufferQueue = xQueueCreate( GMAC_TX_BUFFERS, sizeof( void * ) );
configASSERT( xTxBufferQueue );
}
if( xTXDescriptorSemaphore == NULL )
{
xTXDescriptorSemaphore = xSemaphoreCreateCounting( ( UBaseType_t ) GMAC_TX_BUFFERS, ( UBaseType_t ) GMAC_TX_BUFFERS );
configASSERT( xTXDescriptorSemaphore );
}
/* When returning non-zero, the stack will become active and
start DHCP (in configured) */
return ( ulPHYLinkStatus & BMSR_LINK_STATUS ) != 0;
}
开发者ID:unnamet,项目名称:Repo,代码行数:32,代码来源:NetworkInterface.c
示例13: vApplicationTickHook
void vApplicationTickHook( void )
{
static uint32_t ulCallCount = 0;
const uint32_t ulCallsBetweenSends = pdMS_TO_TICKS( 1000 );
const uint32_t ulMessage = configPRINT_SYSTEM_STATUS;
portBASE_TYPE xDummy;
/* If configUSE_TICK_HOOK is set to 1 then this function will get called
from each RTOS tick. It is called from the tick interrupt and therefore
will be executing in the privileged state. */
ulCallCount++;
/* Is it time to print out the pass/fail message again? */
if( ulCallCount >= ulCallsBetweenSends )
{
ulCallCount = 0;
/* Send a message to the check task to command it to check that all
the tasks are still running then print out the status.
This is running in an ISR so has to use the "FromISR" version of
xQueueSend(). Because it is in an ISR it is running with privileges
so can access xGlobalScopeCheckQueue directly. */
xQueueSendFromISR( xGlobalScopeCheckQueue, &ulMessage, &xDummy );
}
}
开发者ID:Eclo,项目名称:FreeRTOS,代码行数:27,代码来源:main.c
示例14: sim800_config
/**
* SIM800 IP configuration commands fail if the IP application is running,
* even though the configuration settings are already right. The following
* monkey dance is therefore needed.
*/
static int sim800_config(struct cellular *modem, const char *option, const char *value, int attempts)
{
at_set_timeout(modem->at, 10);
for (int i=0; i<attempts; i++) {
/* Blindly try to set the configuration option. */
at_command(modem->at, "AT+%s=%s", option, value);
/* Query the setting status. */
const char *response = at_command(modem->at, "AT+%s?", option);
/* Bail out on timeouts. */
if (response == NULL)
return -1;
/* Check if the setting has the correct value. */
char expected[16];
if (snprintf(expected, sizeof(expected), "+%s: %s", option, value) >= (int) sizeof(expected)) {
return -1;
}
if (!strcmp(response, expected))
return 0;
vTaskDelay(pdMS_TO_TICKS(1000));
}
return -1;
}
开发者ID:jiandeng,项目名称:attentive,代码行数:32,代码来源:at-sim800.c
示例15: prvQueueReceiveTask
static void prvQueueReceiveTask( void *pvParameters )
{
uint32_t ulReceivedValue;
const uint32_t ulExpectedValue = 100UL;
const TickType_t xShortDelay = pdMS_TO_TICKS( 10 );
/* Remove compiler warning about unused parameter. */
( void ) pvParameters;
for( ;; ) {
/* Wait until something arrives in the queue - this task will block
indefinitely provided INCLUDE_vTaskSuspend is set to 1 in
FreeRTOSConfig.h. */
xQueueReceive( xQueue, &ulReceivedValue, portMAX_DELAY );
/* To get here something must have been received from the queue, but
is it the expected value? If it is, toggle the LED. */
if( ulReceivedValue == ulExpectedValue ) {
/* Turn the LED on for a brief time only so it doens't distort the
energy reading. */
BSP_LedSet( mainTASK_LED );
vTaskDelay( xShortDelay );
BSP_LedClear( mainTASK_LED );
ulReceivedValue = 0U;
}
}
}
开发者ID:peterliu2,项目名称:FreeRTOS,代码行数:27,代码来源:main_low_power.c
示例16: sim800_socket_connect
static int sim800_socket_connect(struct cellular *modem, int connid, const char *host, uint16_t port)
{
struct cellular_sim800 *priv = (struct cellular_sim800 *) modem;
if(connid == SIM800_NSOCKETS) {
return !(SIM800_SOCKET_STATUS_CONNECTED == priv->spp_status);
} else if(connid < SIM800_NSOCKETS) {
/* Send connection request. */
at_set_timeout(modem->at, SET_TIMEOUT);
priv->socket_status[connid] = SIM800_SOCKET_STATUS_UNKNOWN;
cellular_command_simple_pdp(modem, "AT+CIPSTART=%d,TCP,\"%s\",%d", connid, host, port);
/* Wait for socket status URC. */
for (int i=0; i<SIM800_CONNECT_TIMEOUT; i++) {
if (priv->socket_status[connid] == SIM800_SOCKET_STATUS_CONNECTED) {
return 0;
} else if (priv->socket_status[connid] == SIM800_SOCKET_STATUS_ERROR) {
return -1;
}
vTaskDelay(pdMS_TO_TICKS(1000));
}
}
return -1;
}
开发者ID:jiandeng,项目名称:attentive,代码行数:25,代码来源:at-sim800.c
示例17: prvQueueReceiveTask
static void prvQueueReceiveTask( void *pvParameters )
{
unsigned long ulReceivedValue;
static const TickType_t xShortBlock = pdMS_TO_TICKS( 50 );
/* Check the task parameter is as expected. */
configASSERT( ( ( unsigned long ) pvParameters ) == mainQUEUE_RECEIVE_PARAMETER );
for( ;; )
{
/* Wait until something arrives in the queue - this task will block
indefinitely provided INCLUDE_vTaskSuspend is set to 1 in
FreeRTOSConfig.h. */
xQueueReceive( xQueue, &ulReceivedValue, portMAX_DELAY );
/* To get here something must have been received from the queue, but
is it the expected value? If it is, toggle the LED. */
if( ulReceivedValue == 100UL )
{
/* Blip the LED for a short while so as not to use too much
power. */
configTOGGLE_LED();
vTaskDelay( xShortBlock );
configTOGGLE_LED();
ulReceivedValue = 0U;
}
}
}
开发者ID:wugsh,项目名称:wgs,代码行数:28,代码来源:main_blinky.c
示例18: sim800_ftp_get
static int sim800_ftp_get(struct cellular *modem, const char *filename)
{
struct cellular_sim800 *priv = (struct cellular_sim800 *) modem;
/* Configure filename. */
at_command_simple(modem->at, "AT+FTPGETPATH=\"/\"");
at_command_simple(modem->at, "AT+FTPGETNAME=\"%s\"", filename);
/* Try to open the connection. */
priv->ftpget1_status = -1;
cellular_command_simple_pdp(modem, "AT+FTPGET=1");
/* Wait for the operation result. */
for (int i=0; i<SIM800_FTP_TIMEOUT; i++) {
if (priv->ftpget1_status == 1)
return 0;
if (priv->ftpget1_status != -1) {
return -1;
}
vTaskDelay(pdMS_TO_TICKS(1000));
}
return -1;
}
开发者ID:jiandeng,项目名称:attentive,代码行数:26,代码来源:at-sim800.c
示例19: vSerialPutString
/* Function required in order to link UARTCommandConsole.c - which is used by
multiple different demo application. */
void vSerialPutString( xComPortHandle pxPort, const signed char * const pcString, unsigned short usStringLength )
{
const TickType_t xMaxBlockTime = pdMS_TO_TICKS( 5000 );
/* Only one port is supported. */
( void ) pxPort;
/* Clear the flag before initiating a new transmission */
sci1_txdone = FALSE;
/* Don't send the string unless the previous string has been sent. */
if( ( xSendingTask == NULL ) && ( usStringLength > 0 ) )
{
/* Ensure the calling task's notification state is not already
pending. */
xTaskNotifyStateClear( NULL );
/* Store the handle of the transmitting task. This is used to unblock
the task when the transmission has completed. */
xSendingTask = xTaskGetCurrentTaskHandle();
/* Send the string using the auto-generated API. */
R_SCI1_Serial_Send( ( uint8_t * ) pcString, usStringLength );
/* Wait in the Blocked state (so not using any CPU time) until the
transmission has completed. */
ulTaskNotifyTake( pdTRUE, xMaxBlockTime );
}
}
开发者ID:bleuelotus,项目名称:SweepRobot_Testing_Host,代码行数:31,代码来源:r_cg_sci_user_GCC.c
示例20: prvQueueSendTask
static void prvQueueSendTask( void *pvParameters )
{
TickType_t xNextWakeTime;
const unsigned long ulValueToSend = 100UL;
const TickType_t xBlockTime = pdMS_TO_TICKS( mainQUEUE_SEND_FREQUENCY_MS );
/* Remove compiler warning in the case that configASSERT() is not
defined. */
( void ) pvParameters;
/* Check the task parameter is as expected. */
configASSERT( ( ( unsigned long ) pvParameters ) == mainQUEUE_SEND_PARAMETER );
/* Initialise xNextWakeTime - this only needs to be done once. */
xNextWakeTime = xTaskGetTickCount();
for( ;; )
{
/* Place this task in the blocked state until it is time to run again.
The block time is specified in ticks, the constant used converts ticks
to ms. While in the Blocked state this task will not consume any CPU
time. */
vTaskDelayUntil( &xNextWakeTime, xBlockTime );
/* Send to the queue - causing the queue receive task to unblock and
toggle the LED. 0 is used as the block time so the sending operation
will not block - it shouldn't need to block as the queue should always
be empty at this point in the code. */
xQueueSend( xQueue, &ulValueToSend, 0U );
}
}
开发者ID:BuiChien,项目名称:FreeRTOS-TM4C123GXL,代码行数:31,代码来源:main_blinky.c
注:本文中的pdMS_TO_TICKS函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论