久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费
標題:
FreeRtos STM32工程 代碼帶部分中文注釋
[打印本頁]
作者:
13523698526
時間:
2020-10-16 17:15
標題:
FreeRtos STM32工程 代碼帶部分中文注釋
STM32F103C8T6的FreeRtos工程。
帶部分中文注釋。希望可以幫組初學者。
單片機源程序如下:
/* Standard includes. */
#include <stdio.h>
/* Scheduler includes. */
#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"
/* Library includes. */
#include "stm32f10x_it.h"
/* Demo app includes. */
#include "lcd.h"
#include "LCD_Message.h"
#include "BlockQ.h"
#include "death.h"
#include "integer.h"
#include "blocktim.h"
#include "partest.h"
#include "semtest.h"
#include "PollQ.h"
#include "flash.h"
#include "comtest2.h"
/* Task priorities. */
#define mainQUEUE_POLL_PRIORITY ( tskIDLE_PRIORITY + 2 )
#define mainCHECK_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 )
#define mainSEM_TEST_PRIORITY ( tskIDLE_PRIORITY + 1 )
#define mainBLOCK_Q_PRIORITY ( tskIDLE_PRIORITY + 2 )
#define mainCREATOR_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 )
#define mainFLASH_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 )
#define mainCOM_TEST_PRIORITY ( tskIDLE_PRIORITY + 1 )
#define mainINTEGER_TASK_PRIORITY ( tskIDLE_PRIORITY )
/* Constants related to the LCD. */
#define mainMAX_LINE ( 240 )
#define mainROW_INCREMENT ( 24 )
#define mainMAX_COLUMN ( 20 )
#define mainCOLUMN_START ( 319 )
#define mainCOLUMN_INCREMENT ( 16 )
/* The maximum number of message that can be waiting for display at any one
time. */
#define mainLCD_QUEUE_SIZE ( 3 )
/* The check task uses the sprintf function so requires a little more stack. */
#define mainCHECK_TASK_STACK_SIZE ( configMINIMAL_STACK_SIZE + 50 )
/* Dimensions the buffer into which the jitter time is written. */
#define mainMAX_MSG_LEN 25
/* The time between cycles of the 'check' task. */
#define mainCHECK_DELAY ( ( TickType_t ) 5000 / portTICK_PERIOD_MS )
/* The number of nano seconds between each processor clock. */
#define mainNS_PER_CLOCK ( ( unsigned long ) ( ( 1.0 / ( double ) configCPU_CLOCK_HZ ) * 1000000000.0 ) )
/* Baud rate used by the comtest tasks. */
#define mainCOM_TEST_BAUD_RATE ( 115200 )
/* The LED used by the comtest tasks. See the comtest.c file for more
information. */
#define mainCOM_TEST_LED ( 3 )
/*-----------------------------------------------------------*/
/*
* Configure the clocks, GPIO and other peripherals as required by the demo.
*/
static void prvSetupHardware( void );
/*
* Configure the LCD as required by the demo.
*/
static void prvConfigureLCD( void );
/*
* The LCD is written two by more than one task so is controlled by a
* 'gatekeeper' task. This is the only task that is actually permitted to
* access the LCD directly. Other tasks wanting to display a message send
* the message to the gatekeeper.
*/
static void vLCDTask( void *pvParameters );
/*
* Retargets the C library printf function to the USART.
*/
int fputc( int ch, FILE *f );
/*
* Checks the status of all the demo tasks then prints a message to the
* display. The message will be either PASS - and include in brackets the
* maximum measured jitter time (as described at the to of the file), or a
* message that describes which of the standard demo tasks an error has been
* discovered in.
*
* Messages are not written directly to the terminal, but passed to vLCDTask
* via a queue.
*/
static void vCheckTask( void *pvParameters );
/*
* Configures the timers and interrupts for the fast interrupt test as
* described at the top of this file.
*/
extern void vSetupTimerTest( void );
/*-----------------------------------------------------------*/
/* The queue used to send messages to the LCD task. */
QueueHandle_t xLCDQueue;
/*-----------------------------------------------------------*/
int main( void )
{
#ifdef DEBUG
debug();
#endif
prvSetupHardware();
/* Create the queue used by the LCD task. Messages for display on the LCD
are received via this queue. */
xLCDQueue = xQueueCreate( mainLCD_QUEUE_SIZE, sizeof( xLCDMessage ) ); //創建LCD列隊,并返回列隊編號
/* Start the standard demo tasks. */
vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY ); //創建了6個任務,處理三組參數
vCreateBlockTimeTasks(); //創建兩個block任務 阻塞任務
vStartSemaphoreTasks( mainSEM_TEST_PRIORITY ); //
vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY ); //創建列隊測試任務 待挖掘
vStartIntegerMathTasks( mainINTEGER_TASK_PRIORITY ); //
vStartLEDFlashTasks( mainFLASH_TASK_PRIORITY ); //創建LED翻轉任務,創建了3個相同的任務,每個對應不同的燈
vAltStartComTestTasks( mainCOM_TEST_PRIORITY, mainCOM_TEST_BAUD_RATE, mainCOM_TEST_LED ); //創建串口收發任務,收和發是兩個任務
/* Start the tasks defined within this file/specific to this demo. */
xTaskCreate( vCheckTask, "Check", mainCHECK_TASK_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL ); //創建LCD內容顯示設置任務
xTaskCreate( vLCDTask, "LCD", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL ); //創建LCD顯示任務
/* The suicide tasks must be created last as they need to know how many
tasks were running prior to their creation in order to ascertain whether
or not the correct/expected number of tasks are running at any given time. */
vCreateSuicidalTasks( mainCREATOR_TASK_PRIORITY ); //創建一批可以自動刪除的任務
/* Configure the timers used by the fast interrupt timer test. */
vSetupTimerTest(); //初始化定時器
/* Start the scheduler. */
vTaskStartScheduler(); //啟動調度器,開始操作系統
/* Will only get here if there was not enough heap space to create the
idle task. */
return 0;
}
/*-----------------------------------------------------------*/
void vLCDTask( void *pvParameters )
{
xLCDMessage xMessage;
/* Initialise the LCD and display a startup message. */
prvConfigureLCD();
LCD_DrawMonoPict( ( unsigned long * ) pcBitmap );
for( ;; )
{
/* Wait for a message to arrive that requires displaying. */
while( xQueueReceive( xLCDQueue, &xMessage, portMAX_DELAY ) != pdPASS ); //從序列中讀取數據,返回有沒有
/* Display the message. Print each message to a different position. */
printf( ( char const * ) xMessage.pcMessage );
}
}
/*-----------------------------------------------------------*/
static void vCheckTask( void *pvParameters )
{
TickType_t xLastExecutionTime;
xLCDMessage xMessage;
static signed char cPassMessage[ mainMAX_MSG_LEN ];
extern unsigned short usMaxJitter;
xLastExecutionTime = xTaskGetTickCount();
xMessage.pcMessage = cPassMessage;
for( ;; )
{
/* Perform this check every mainCHECK_DELAY milliseconds. */
vTaskDelayUntil( &xLastExecutionTime, mainCHECK_DELAY ); //絕對延時,如果某個延時被任務耽擱了,會在下一次調用時補償回來
/* Has an error been found in any task? */
if( xAreBlockingQueuesStillRunning() != pdTRUE )
{
xMessage.pcMessage = "ERROR IN BLOCK Q\n";
}
else if( xAreBlockTimeTestTasksStillRunning() != pdTRUE )
{
xMessage.pcMessage = "ERROR IN BLOCK TIME\n";
}
else if( xAreSemaphoreTasksStillRunning() != pdTRUE )
{
xMessage.pcMessage = "ERROR IN SEMAPHORE\n";
}
else if( xArePollingQueuesStillRunning() != pdTRUE )
{
xMessage.pcMessage = "ERROR IN POLL Q\n";
}
else if( xIsCreateTaskStillRunning() != pdTRUE )
{
xMessage.pcMessage = "ERROR IN CREATE\n";
}
else if( xAreIntegerMathsTaskStillRunning() != pdTRUE )
{
xMessage.pcMessage = "ERROR IN MATH\n";
}
else if( xAreComTestTasksStillRunning() != pdTRUE )
{
xMessage.pcMessage = "ERROR IN COM TEST\n";
}
else
{
sprintf( ( char * ) cPassMessage, "PASS [%uns]\n", ( ( unsigned long ) usMaxJitter ) * mainNS_PER_CLOCK );
}
/* Send the message to the LCD gatekeeper for display. */
xQueueSend( xLCDQueue, &xMessage, portMAX_DELAY );
}
}
/*-----------------------------------------------------------*/
static void prvSetupHardware( void )
{
/* Start with the clocks in their expected state. */
RCC_DeInit();
……………………
…………限于本文篇幅 余下代碼請從51黑下載附件…………
復制代碼
所有資料51hei提供下載:
FreeRTOS-project STM32.7z
(3.09 MB, 下載次數: 57)
2020-10-16 18:43 上傳
點擊文件名下載附件
STM32FreeRtos例程
下載積分: 黑幣 -5
歡迎光臨 (http://www.zg4o1577.cn/bbs/)
Powered by Discuz! X3.1
主站蜘蛛池模板:
日日摸夜夜爽人人添av
|
亚洲人人舔人人
|
本地毛片
|
日韩欧美在线视频观看
|
精品欧美一区二区中文字幕视频
|
久久精品在线免费视频
|
久久久久成人精品亚洲国产
|
日韩精品一区二区三区中文在线
|
国产精品久久久久久久久久久新郎
|
精品国产青草久久久久96
|
亚洲精品一区二区三区在线
|
成人午夜免费福利视频
|
日韩国产精品一区二区三区
|
亚洲精选久久
|
成人网av
|
亚洲一区二区三区
|
久草在线青青草
|
国产午夜久久久
|
国产亚洲一区二区三区在线观看
|
韩日av在线
|
欧美日韩电影在线
|
亚洲国产精品一区二区三区
|
国产一二三区免费视频
|
婷婷色国产偷v国产偷v小说
|
久久久91
|
亚洲欧美日韩在线不卡
|
h片在线免费观看
|
国产97在线看
|
欧美国产视频一区二区
|
亚洲毛片在线观看
|
国产精品美女久久久久aⅴ国产馆
|
日韩国产在线
|
日韩二三区
|
国产欧美精品区一区二区三区
|
aaa大片免费观看
|
欧美日高清视频
|
国产精品区二区三区日本
|
国产高清美女一级a毛片久久w
|
亚洲超碰在线观看
|
精品国产区
|
国产99久久久国产精品
|