完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
电子发烧友论坛|
static TaskHandle_t xTaskToNotify = NULL;
/* The peripheral driver's transmit function. */ void StartTransmission( uint8_t *pcData, size_t xDataLength ) { /* At this point xTaskToNotify should be NULL as no transmission is in progress. A mutex can be used to guard access to the peripheral if necessary. */ configASSERT( xTaskToNotify == NULL ); /* Store the handle of the calling task. */ xTaskToNotify = xTaskGetCurrentTaskHandle(); /* Start the transmission - an interrupt is generated when the transmission is complete. */ vStartTransmit( pcData, xDatalength ); } /*-----------------------------------------------------------*/ /* The transmit end interrupt. */ void vTransmitEndISR( void ) { BaseType_t xHigherPriorityTaskWoken = pdFALSE; /* At this point xTaskToNotify should not be NULL as a transmission was in progress. */ configASSERT( xTaskToNotify != NULL ); /* Notify the task that the transmission is complete. */ vTaskNotifyGiveFromISR( xTaskToNotify, &xHigherPriorityTaskWoken ); /* There are no transmissions in progress, so no tasks to notify. */ xTaskToNotify = NULL; /* If xHigherPriorityTaskWoken is now set to pdTRUE then a context switch should be performed to ensure the interrupt returns directly to the highest priority task. The macro used for this purpose is dependent on the port in use and may be called portEND_SWITCHING_ISR(). */ portYIELD_FROM_ISR( xHigherPriorityTaskWoken ); } /*-----------------------------------------------------------*/ /* The task that initiates the transmission, then enters the Blocked state (so not consuming any CPU time) to wait for it to complete. */ void vAFunctionCalledFromATask( uint8_t ucDataToTransmit, size_t xDataLength ) { uint32_t ulNotificationValue; const TickType_t xMaxBlockTime = pdMS_TO_TICKS( 200 ); /* Start the transmission by calling the function shown above. */ StartTransmission( ucDataToTransmit, xDataLength ); /* Wait for the transmission to complete. */ ulNotificationValue = ulTaskNotifyTake( pdFALSE, xMaxBlockTime ); if( ulNotificationValue == 1 ) { /* The transmission ended as expected. */ } else { /* The call to ulTaskNotifyTake() timed out. */ } } 这是官网范例,按照范例来写 |
|
|
|
|
只有小组成员才能发言,加入小组>>
1026 浏览 1 评论
1856 浏览 0 评论
1837 浏览 1 评论
3261 浏览 5 评论
3587 浏览 9 评论
1026浏览 1评论
1853浏览 1评论
如何知道嵌入式电子控制单元 (ECU) 中的RAM使用情况?
1365浏览 1评论
1856浏览 0评论
1181浏览 0评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-3 07:53 , Processed in 0.491260 second(s), Total 74, Slave 54 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
1056