【GE32E231_DIY】FreeRTOS+DAP_RTT+Multi-function button+USART_DMA and add FREEMODBUS
[Copy link]
FreeRTOS+DAP_RTT+Multi-function button+USART_DMA and add FREEMODBUS
So far, the project has been realized step by step, and it is not easy to debug step by step. Thanks to my family for their support, Cheng has the time code.
FreeRTOSv10.2.1_MultiButton_FreeModbus_ok.rar
(11.51 MB, downloads: 257)
The main idea of freemodbus is to use a state machine to implement sending-interrupt, receiving-interrupt, hard time confirmation, plus a poll
int main(void)
{
systick_config();
// button_enable();
// CreateSoftwareTime();
LED_Init();
eMBInit(MB_RTU, 0x01, 1, 115200, MB_PAR_NONE);//Initialize Freemodbus data, timer, serial port (including interrupt), working state
eMBEnable(); //Start receiving interrupt and wait for serial port data to arrive
/* Create tasks. */
prvCreateTasks();
NVIC_SetPriority_Init();
NVIC_EnableIRQ_Init();
// TIMER2_Config();
/* Start scheduler. */
vTaskStartScheduler();
/* Will not get here if the scheduler starts successfully. If you do end up
here then there wasn't enough heap memory available to start either the idle
task or the timer/daemon task. https://www.freertos.org/a00111.html */
for( ; ; )
{
}
}
Create a polling task. ModbusSlavePoll
static void prvCreateTasks( void )
{
xTaskCreate(vLED1Task, //* Task function
"vLED1Task", //* Task name
configMINIMAL_STACK_SIZE, //* Task stack size, unit word, that is, 4 bytes
NULL, //* Task parameter
configMAX_PRIORITIES - 3, //* Task priority
&xHandleLED1Task); //* Task handle
xTaskCreate(vLED2Task, //* Task function
"vLED2Task", //* Task name
configMINIMAL_STACK_SIZE, // Task stack size, unit word, that is, 4 bytes
NULL, //* Task parameter
configMAX_PRIORITIES - 3, // Task priority
&xHandleLED2Task); //* Task handle
xTaskCreate(vLED3Task, //* Task function
"vLED3Task", //* Task name
configMINIMAL_STACK_SIZE, // Task stack size, unit word, that is, 4 bytes
NULL, //* Task parameter
configMAX_PRIORITIES - 3, // Task priority
&xHandleLED3Task); //* Task handle
xTaskCreate(vLED4Task, //* Task function
"vLED4Task", //* Task name
configMINIMAL_STACK_SIZE, // Task stack size, unit word, that is, 4 bytes
NULL, //* Task parameter
configMAX_PRIORITIES - 3, // Task priority
&xHandleLED4Task); //* Task handle
/* xTaskCreate(RTT_PrintfTask,//std_PrintfTask // Task function
"vprintfTask", // Task name
configMINIMAL_STACK_SIZE+50, // Task stack size, unit word, that is, 4 bytes
NULL, // Task parameter
configMAX_PRIORITIES - 3, // Task priority
&xHandleprintfTask); // Task handle
*/
xTaskCreate(ModbusSlavePoll, //* Task function
"ModbusSlavePoll", //* Task name
configMINIMAL_STACK_SIZE+300, //* Task stack size, unit word, that is, 4 bytes
NULL, //* Task parameter
configMAX_PRIORITIES - 3, //* Task priority
&xHandleModbusSlavePoll); //* Task handle
}
Welcome to post comments
|