diff --git a/Power_Pico/User/Tasks/Inc/user_KeyTask.h b/Power_Pico/User/Tasks/Inc/user_KeyTask.h new file mode 100644 index 0000000..9d0eaa0 --- /dev/null +++ b/Power_Pico/User/Tasks/Inc/user_KeyTask.h @@ -0,0 +1,16 @@ +#ifndef __USER_KEYTASK_H__ +#define __USER_KEYTASK_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +void KeyTask(void *argument); + + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/Power_Pico/User/Tasks/Inc/user_SendTask.h b/Power_Pico/User/Tasks/Inc/user_SendTask.h new file mode 100644 index 0000000..f8d18bd --- /dev/null +++ b/Power_Pico/User/Tasks/Inc/user_SendTask.h @@ -0,0 +1,16 @@ +#ifndef __USER_SENDTASK_H__ +#define __USER_SENDTASK_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +void UartSendTask(void *argument); + + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/Power_Pico/User/Tasks/Src/user_KeyTask.c b/Power_Pico/User/Tasks/Src/user_KeyTask.c new file mode 100644 index 0000000..3f67aef --- /dev/null +++ b/Power_Pico/User/Tasks/Src/user_KeyTask.c @@ -0,0 +1,51 @@ +/* Private includes -----------------------------------------------------------*/ +//includes +#include "user_TasksInit.h" +#include "main.h" +#include "key.h" + +/* Private typedef -----------------------------------------------------------*/ + +/* Private define ------------------------------------------------------------*/ + +/* Private variables ---------------------------------------------------------*/ + +/* Private function prototypes -----------------------------------------------*/ + + +/** + * @brief Key press check task + * @param argument: Not used + * @retval None + */ +void KeyTask(void *argument) +{ + uint8_t keystr = 0; + while(1) + { + keystr = KeyScan(0); + switch(keystr) + { + case KEYB_NUM: + osMessageQueuePut(Key_MessageQueue, &keystr, 0, 1); + break; + + case KEYY_NUM: + osMessageQueuePut(Key_MessageQueue, &keystr, 0, 1); + break; + + case KEYL_NUM: + osMessageQueuePut(Key_MessageQueue, &keystr, 0, 1); + break; + + case KEYR_NUM: + osMessageQueuePut(Key_MessageQueue, &keystr, 0, 1); + break; + + case KEYN_NUM: + osMessageQueuePut(Key_MessageQueue, &keystr, 0, 1); + break; + } + osDelay(1); + } +} diff --git a/Power_Pico/User/Tasks/Src/user_SendTask.c b/Power_Pico/User/Tasks/Src/user_SendTask.c new file mode 100644 index 0000000..a436b01 --- /dev/null +++ b/Power_Pico/User/Tasks/Src/user_SendTask.c @@ -0,0 +1,31 @@ +/* Private includes -----------------------------------------------------------*/ +//includes +#include "user_TasksInit.h" +#include "main.h" + +/* Private typedef -----------------------------------------------------------*/ + +/* Private define ------------------------------------------------------------*/ + +/* Private variables ---------------------------------------------------------*/ + +/* Private function prototypes -----------------------------------------------*/ + + +/** + * @brief task for send messages or data + * @param argument: Not used + * @retval None + */ +void UartSendTask(void *argument) +{ + uint8_t keystr = 0; + while(1) + { + if(osMessageQueueGet(Key_MessageQueue, &keystr, NULL, 0)==osOK) + { + UART6_TX_Send((uint8_t *)"key pressed\r\n", 13); + } + osDelay(1); + } +} diff --git a/Power_Pico/User/Tasks/Src/user_TasksInit.c b/Power_Pico/User/Tasks/Src/user_TasksInit.c index 26f1f79..f05e970 100644 --- a/Power_Pico/User/Tasks/Src/user_TasksInit.c +++ b/Power_Pico/User/Tasks/Src/user_TasksInit.c @@ -10,7 +10,8 @@ //tasks #include "user_HardwareInitTask.h" - +#include "user_SendTask.h" +#include "user_KeyTask.h" /* Private typedef -----------------------------------------------------------*/ @@ -34,12 +35,12 @@ const osThreadAttr_t HardwareInitTask_attributes = { .priority = (osPriority_t) osPriorityHigh3, }; -//LVGL Handler task -osThreadId_t LvHandlerTaskHandle; -const osThreadAttr_t LvHandlerTask_attributes = { - .name = "LvHandlerTask", - .stack_size = 128 * 24, - .priority = (osPriority_t) osPriorityLow, +//UART send task +osThreadId_t UartSendTaskHandle; +const osThreadAttr_t UartSendTask_attributes = { + .name = "UartSendTask", + .stack_size = 128 * 1, + .priority = (osPriority_t) osPriorityHigh1, }; //Key task @@ -50,6 +51,14 @@ const osThreadAttr_t KeyTask_attributes = { .priority = (osPriority_t) osPriorityNormal, }; +//LVGL Handler task +osThreadId_t LvHandlerTaskHandle; +const osThreadAttr_t LvHandlerTask_attributes = { + .name = "LvHandlerTask", + .stack_size = 128 * 24, + .priority = (osPriority_t) osPriorityLow, +}; + /* Message queues ------------------------------------------------------------*/ //Key message @@ -72,13 +81,13 @@ void User_Tasks_Init(void) /* start timers, add new ones, ... */ /* add queues, ... */ - Key_MessageQueue = osMessageQueueNew(1, 1, NULL); + Key_MessageQueue = osMessageQueueNew(4, 1, NULL); /* add threads, ... */ HardwareInitTaskHandle = osThreadNew(HardwareInitTask, NULL, &HardwareInitTask_attributes); + UartSendTaskHandle = osThreadNew(UartSendTask, NULL, &UartSendTask_attributes); + KeyTaskHandle = osThreadNew(KeyTask, NULL, &KeyTask_attributes); LvHandlerTaskHandle = osThreadNew(LvHandlerTask, NULL, &LvHandlerTask_attributes); - // KeyTaskHandle = osThreadNew(KeyTask, NULL, &KeyTask_attributes); - /* add events, ... */