[Shanghai Hangxin ACM32F070 development board review] 6. Transplant the RTX operating system
[Copy link]
This post was last edited by ddllxxrr on 2022-11-3 12:58
Recently, a high-level company held a lecture on the UCOS operating system. I was furious when I heard it, because the porting of UCOS is too troublesome. I have said it before, do you dare to use it in your product after porting it? ? ?
I was reminded of KEIL’s RTX operating system, which does not require any porting, just a check mark.
This time I will move it to the Shanghai Hangxin ACM32F070 development board. Why not take a shortcut? Besides, RTX also has a file system and a GUI.
The first step is to check the box: find the green diamond in the MDK menu
Step 2: Write your own program
1. Use the last watchdog program to delete the dog first, and include the header file at the beginning of the MAIN function: #include "cmsis_os.h"
After including the header file, the definition is as follows:
void led_Thread1 (void const *argument);
osThreadDef(led_Thread1, osPriorityNormal, 1, 0);
osThreadId T_led_ID1;
And write the led_Thread1 function:
void led_Thread1 (void const *argument)
{
while(1)
{
printfS("HELLO EEWORLD !!!");
osDelay(500);
}
}
Step 3:
Then compile, and it will prompt that the SYSTICK program definition is repeated.
Disable the SYSTICK function in System_ACM32F0x0.c and compile it again.
Operation results:
Full Program:
*
******************************************************************************
* @File main.c
* @brief main source File.
******************************************************************************
*/
#include "APP.h"
#include "cmsis_os.h"
#define UART_BAUD_RATE 115200
UART_HandleTypeDef UART2_Handle;
void led_Thread1 (void const *argument);
osThreadDef(led_Thread1, osPriorityNormal, 1, 0);
osThreadId T_led_ID1;
/************************************************************************
* function : Uart_Init
* Description: Uart Initiation.
************************************************************************/
void Uart_Init(void)
{
UART2_Handle.Instance = UART2;
UART2_Handle.Init.BaudRate = UART_BAUD_RATE;
UART2_Handle.Init.WordLength = UART_WORDLENGTH_8B;
UART2_Handle.Init.StopBits = UART_STOPBITS_1;
UART2_Handle.Init.Parity = UART_PARITY_NONE;
UART2_Handle.Init.Mode = UART_MODE_TX_RX_DEBUG;
UART2_Handle.Init.HwFlowCtl = UART_HWCONTROL_NONE;
HAL_UART_Init(&UART2_Handle);
/* UART_DEBUG_ENABLE control printfS */
printfS("MCU is running, HCLK=%dHz, PCLK=%dHz\n", System_Get_SystemClock(), System_Get_APBClock());
}
/*********************************************************************************
* Function : main
* Description :
* Input :
* Outpu :
* Author : CWT Data : 2020年
**********************************************************************************/
int main(void)
{
osKernelInitialize (); // initialize CMSIS-RTOS
System_Init();
Uart_Init();
//WDT_Reset_Test();
T_led_ID1 = osThreadCreate(osThread(led_Thread1), NULL);
osKernelStart (); // start thread execution
}
void led_Thread1 (void const *argument)
{
while(1)
{
printfS("HELLO EEWORLD !!!");
osDelay(500);
}
}
|