Codex++ 安装与 Codex 环境配置指南
2026/6/30 18:02:08
| 资源 | 描述 | |
|---|---|---|
| mspm0_sdk_2_09_00_01 | MSPM0 Software Development Kit. The MSPM0 SDK provides the ultimate collection of software, tools and documentation to accelerate the development of applications for the MSPM0 MCU platform under a single software package. | Download |
| CCSTUDIO | Code Composer Studio™ integrated development environment (IDE) | Download |
| SEGGER J-Links | SEGGER J-Links are the most widely used line of debug probes available today | Download |
intmain(void){/* Prepare the hardware to run this demo. */prvSetupHardware();main_blinky();return0;}/* Kernel includes. */#include"FreeRTOS.h"#include"semphr.h"#include"task.h"/* TI includes. */#include"ti_msp_dl_config.h"/* Priorities at which the tasks are created. */#definemainQUEUE_RECEIVE_TASK_PRIORITY(tskIDLE_PRIORITY+2)#definemainQUEUE_SEND_TASK_PRIORITY(tskIDLE_PRIORITY+1)/* * The rate at which data is sent to the queue. The 1s (1000ms) value is * converted to ticks using the pdMS_TO_TICKS constant. */#definemainQUEUE_SEND_FREQUENCY_MS(pdMS_TO_TICKS(1000UL))/* * The number of items the queue can hold. This is 1 as the receive task * will remove items as they are added, meaning the send task should always * find the queue empty. */#definemainQUEUE_LENGTH(1)/* * Values passed to the two tasks just to check the task parameter * functionality. */#definemainQUEUE_SEND_PARAMETER(0x1111UL)#definemainQUEUE_RECEIVE_PARAMETER(0x22UL)/*-----------------------------------------------------------*//* The tasks as described in the comments at the top of this file. */staticvoidprvQueueReceiveTask(void*pvParameters);staticvoidprvQueueSendTask(void*pvParameters);/* Called by main() to create the simply blinky style application */voidmain_blinky(void);/*-----------------------------------------------------------*//* The queue used by both tasks. */staticQueueHandle_t xQueue=NULL;/*-----------------------------------------------------------*/voidmain_blinky(void){/* Create the queue. */xQueue=xQueueCreate(mainQUEUE_LENGTH,sizeof(uint32_t));if(xQueue!=NULL){/* * Start the two tasks as described in the comments at the top of this * file. */xTaskCreate(prvQueueReceiveTask,/* The function that implements the task. */"Rx",/* The text name assigned to the task - for debug only as it is not used by the kernel. */configMINIMAL_STACK_SIZE,/* The size of the stack to allocate to the task. */(void*)mainQUEUE_RECEIVE_PARAMETER,/* The parameter passed to the task - just to check the functionality. */mainQUEUE_RECEIVE_TASK_PRIORITY,/* The priority assigned to the task. */NULL);/* The task handle is not required, so NULL is passed. */xTaskCreate(prvQueueSendTask,"TX",configMINIMAL_STACK_SIZE,(void*)mainQUEUE_SEND_PARAMETER,mainQUEUE_SEND_TASK_PRIORITY,NULL);/* Start the tasks. */vTaskStartScheduler();}/* * If all is well, the scheduler will now be running, and the following * line will never be reached. If the following line does execute, then * there was insufficient FreeRTOS heap memory available for the idle * and/or timer tasks to be created. See the memory management section on * the FreeRTOS web site for more details. */for(;;);}/*-----------------------------------------------------------*/staticvoidprvQueueSendTask(void*pvParameters){TickType_t xNextWakeTime;constunsignedlongulValueToSend=100UL;/* Check the task parameter is as expected. */configASSERT(((unsignedlong)pvParameters)==mainQUEUE_SEND_PARAMETER);/* Initialize xNextWakeTime - this only needs to be done once. */xNextWakeTime=xTaskGetTickCount();for(;;){/* * Place this task in the blocked state until it is time to run again. * The block time is specified in ticks, the constant used converts * ticks to ms. While in the Blocked state this task will not consume * any CPU time. */vTaskDelayUntil(&xNextWakeTime,mainQUEUE_SEND_FREQUENCY_MS);/* * Send to the queue - causing the queue receive task to unblock and * toggle the LED. 0 is used as the block time so the sending operation * will not block - it shouldn't need to block as the queue should always * be empty at this point in the code. */xQueueSend(xQueue,&ulValueToSend,0U);}}/*-----------------------------------------------------------*/staticvoidprvQueueReceiveTask(void*pvParameters){unsignedlongulReceivedValue;staticconstTickType_t xShortBlock=pdMS_TO_TICKS(50);/* Check the task parameter is as expected. */configASSERT(((unsignedlong)pvParameters)==mainQUEUE_RECEIVE_PARAMETER);for(;;){/* * Wait until something arrives in the queue - this task will block * indefinitely provided INCLUDE_vTaskSuspend is set to 1 in * FreeRTOSConfig.h. */xQueueReceive(xQueue,&ulReceivedValue,portMAX_DELAY);/* * To get here something must have been received from the queue, but * is it the expected value? If it is, toggle the LED. */if(ulReceivedValue==100UL){/* * Blip the LED for a short while so as not to use too much * power. */DL_GPIO_togglePins(GPIO_LEDS_PORT,GPIO_LEDS_USER_LED_1_PIN);vTaskDelay(xShortBlock);DL_GPIO_togglePins(GPIO_LEDS_PORT,GPIO_LEDS_USER_LED_1_PIN);ulReceivedValue=0U;}}}用任务与队列实现一个“1 秒闪烁一次 LED”的简单应用。程序创建一个长度为 1 的队列和两个任务:发送任务每秒向队列发送一个固定值,接收任务从队列读取值并在值匹配时短暂点亮(翻转)LED。