[National Technology N32G430] 6. Porting FreeRtos
[Copy link]
[Purpose] Port freertos to the N32G430 development board and implement a basic routine for LED flashing:
1. Create a blank folder to store the project. Create three folders under the folder: FreeRTOS, MDK, and User, which are used to store freertos system files, MDK project files, and user files respectively.
2. Copy the firmware folder provided by the manufacturer to the Template directory:
3. Create a new project under the MDK directory, and set the location of the header file after establishing relevant references as shown in the figure:
4. Create main.c
#include "main.h"
#include "bsp_led.h"
#include "cmsis_os.h"
void MX_FREERTOS_Init(void);
int main(void)
{
LED_Initialize(LED1_GPIO_PORT, LED1_GPIO_PIN );
osKernelInitialize(); /* Call init function for freertos objects (in freertos.c) */
MX_FREERTOS_Init();
osKernelStart();
while(1)
{
}
}
osThreadId_t defaultTaskHandle;
const osThreadAttr_t defaultTask_attributes = {
.name = "defaultTask",
.stack_size = 128 * 4,
.priority = (osPriority_t) osPriorityNormal,
};
void StartDefaultTask(void *argument);
void MX_FREERTOS_Init(void);
void MX_FREERTOS_Init(void) {
defaultTaskHandle = osThreadNew(StartDefaultTask, NULL, &defaultTask_attributes);
}
void StartDefaultTask(void *argument)
{
for(;;)
{
osDelay(500);
LED_Toggle(LED1_GPIO_PORT, LED1_GPIO_PIN);
}
}
There are no errors in the compilation. After downloading to the development board, you can see that the PA1 light flashes regularly.
|