├── .gitmodules ├── App ├── IEC870_PL │ ├── Task_PT_IEC870_PL.c │ └── Task_PT_IEC870_PL.h ├── README.md ├── SleepSort │ ├── SleepSort.c │ └── SleepSort.h ├── Task1 │ ├── Task1.c │ └── Task1.h ├── Task2 │ ├── Task2.c │ └── Task2.h ├── Task3 │ ├── Task3.c │ └── Task3.h ├── Task_Demo_Queue │ ├── Task_Demo_Queue.c │ └── Task_Demo_Queue.h ├── Task_LED_Demo │ ├── README.md │ ├── Task_LED_Demo.c │ └── Task_LED_Demo.h ├── Task_PT_11xx_Test │ ├── Task_PT_11xx_Test.c │ └── Task_PT_11xx_Test.h ├── Task_PT_Demo │ ├── Task_PT_Demo.c │ └── Task_PT_Demo.h └── Task_PT_Demo_2 │ ├── Task_PT_Demo2.c │ └── Task_PT_Demo2.h ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── Core ├── MOE_App.c ├── MOE_App.h ├── MOE_Core.c ├── MOE_Core.h ├── MOE_Event.c ├── MOE_Event.h ├── MOE_HAL.c ├── MOE_HAL.h ├── MOE_Msg.c ├── MOE_Msg.h ├── MOE_PT.h ├── MOE_Timer.c ├── MOE_Timer.h └── README.md ├── Cpu ├── NXP │ ├── KL25ZXX │ │ └── README.md │ └── iMXRT │ │ └── README.md ├── README.md └── ST │ └── STM32F10X │ ├── RCC.c │ ├── RCC.h │ └── README.md ├── Debug ├── ARM │ ├── CmBacktrace_Local │ │ └── README.md │ └── README.md └── General │ └── README.md ├── Documents ├── API_Description.md ├── API_Description_Chinese.md ├── Design_Record.md ├── Pic │ ├── Board │ │ ├── FRDM KL02Z_Mini-Shield.jpg │ │ ├── HappyGecko Starter-kit.png │ │ ├── MIMXRT1050-EVK-DEVICE.jpg │ │ ├── MIMXRT1050-EVK-DEVICE2.jpg │ │ ├── Navota-1.png │ │ ├── README.md │ │ └── STM32F407VE.png │ ├── FRDM-KL25Z.png │ ├── KL27-MINIBOARD.png │ ├── Logo │ │ └── README.MD │ ├── MOE logo V0.01.png │ ├── MOE logo V0.02.png │ ├── MOE logo V0.03 .png │ ├── MOE logo V0.1.png │ ├── MOE logo V0.1a.png │ ├── MOE logo V0.1b.png │ ├── MOE logo V0.1c.png │ ├── MOE logo.pdf │ ├── MOE_logo_V0_1d.jpg │ ├── MOE_logo_V0_1e.png │ ├── Nucleo-64.png │ ├── Nucleo-L011K4.jpg │ ├── Nucleo3_PinOut.png │ ├── README.md │ ├── mini-shield.png │ └── other │ │ ├── CPU_with_MOE.jpg │ │ ├── MOE with MI _1.jpg │ │ ├── MOE with MI_2.jpg │ │ ├── MOE_with_MI_3.jpg │ │ ├── MOE_with_MI_4.jpg │ │ └── README.md └── README.md ├── Driver ├── Dev │ ├── 11xx │ │ ├── MOE_DRV_11xx.c │ │ └── MOE_DRV_11xx.h │ ├── CC1101 │ │ ├── Drv_CC1101.c │ │ └── Drv_CC1101.h │ └── README.md ├── MCU │ ├── Common │ │ └── ARM_Cortex_M │ │ │ ├── MOE_SysTick.c │ │ │ └── MOE_SysTick.h │ ├── NXP-Freescale-_KLxx │ │ ├── MOE_HAL_SPI.c │ │ ├── MOE_HAL_SPI.h │ │ ├── MOE_HAL_UART.c │ │ ├── MOE_HAL_UART.h │ │ └── README.md │ ├── README.md │ ├── STM32F │ │ ├── MOE_HAL_UART.c │ │ ├── MOE_HAL_UART.h │ │ └── README.md │ └── i.MXRT │ │ └── README.md └── README.md ├── ISSUE_TEMPLATE.md ├── LICENCE.md ├── Log.md ├── Pub ├── README.md ├── common_head.h ├── debug.h └── type_def.h ├── README.md ├── README_CHINESE.md ├── Tools └── README.md ├── Utility ├── MOE_Link_list.c ├── MOE_Link_list.h ├── MOE_Queue.c ├── MOE_Queue.h └── README.md └── project ├── Basic_Demo_KL25 ├── Board_Config.c ├── Board_Config.h ├── MOE_main.c ├── MOE_main.h ├── README.md └── project_config.h ├── PT_Demo_EFM32HG322_3400A ├── README.md └── project_config.h ├── PT_Demo_KL25 ├── Board_Config.c ├── Board_Config.h ├── MOE_main.c ├── MOE_main.h ├── README.md └── project_config.h ├── PT_Demo_KL27_MiniBoard ├── Board_Config.c ├── Board_Config.h ├── MOE_main.c ├── MOE_main.h ├── README.md └── project_config.h ├── PT_Demo_MIMXRT1050-EVK ├── Board_Config.c ├── Board_Config.h ├── MOE_main.c ├── MOE_main.h ├── README.md └── project_config.h ├── PT_Demo_Navota_1 ├── Board_Config.c ├── Board_Config.h ├── MOE_Main.h ├── MOE_main.c ├── README.md └── project_config.h ├── PT_Demo_Nucleo_STM32L011K4 ├── Board_Config.c ├── Board_Config.h ├── MOE_main.c ├── MOE_main.h ├── README.md └── project_config.h ├── PT_Demo_STM32F407_SP1 ├── Board_Config.c ├── Board_Config.h ├── MOE_main.c ├── MOE_main.h ├── README.md └── project_config.h └── README.md /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "Debug/ARM/CmBacktrace"] 2 | path = Debug/ARM/CmBacktrace 3 | url = https://github.com/armink/CmBacktrace.git 4 | [submodule "Network/LEON"] 5 | path = Network/LEON 6 | url = https://github.com/ianhom/LEON.git 7 | -------------------------------------------------------------------------------- /App/IEC870_PL/Task_PT_IEC870_PL.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * File : Task_PT_IEC870_PL.h 3 | * Function : A demo task for PT application 4 | * Description: To be done. 5 | * Version : V1.00 6 | * Author : Ian 7 | * Date : 8th Jul 2016 8 | * History : No. When Who What 9 | * 1 08/Jul/2016 Ian Create 10 | ******************************************************************************/ 11 | 12 | 13 | #ifndef _TASK_PT_IEC870_PL_H_ 14 | #define _TASK_PT_IEC870_PL_H_ 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | /* Check if specified option is set for debugging */ 21 | #ifndef __DEBUG_MODE_PT_IEC870_PL 22 | #define __DEBUG_MODE __DEBUG_NONE /* Default: None debugging info */ 23 | #else 24 | #ifdef __DEBUG_MODE 25 | #undef __DEBUG_MODE 26 | #endif 27 | #define __DEBUG_MODE __DEBUG_MODE_PT_IEC870_PL /* According the set from project_config.h */ 28 | #endif 29 | 30 | //#define __PL_RCV_ENABLE 31 | #define __PL_SND_ENABLE 32 | 33 | 34 | #define PL_SEND(p) {\ 35 | CC1101_FIFO_Write(p);\ 36 | CC1101_Cmd(ADDR_CMD_SIDLE);\ 37 | CC1101_Cmd(ADDR_CMD_STX);\ 38 | DBG_PRINT("I am sending telegram!!\n");\ 39 | PT_DELAY(500);\ 40 | CC1101_Cmd(ADDR_CMD_SFTX);\ 41 | } 42 | 43 | #define PL_RECEIVE(p) {\ 44 | CC1101_Cmd(ADDR_CMD_SIDLE);\ 45 | CC1101_Cmd(ADDR_CMD_SRX);\ 46 | do\ 47 | {\ 48 | PT_DELAY(1);\ 49 | }\ 50 | while(0x6F != CC1101_Cmd(ADDR_CMD_SNOP));\ 51 | TASK_PT_DEMO_LED_On(LED_RED);\ 52 | CC1101_Cmd(ADDR_CMD_SIDLE);\ 53 | CC1101_FIFO_Read(p);\ 54 | CC1101_Cmd(ADDR_CMD_SFRX);\ 55 | } 56 | 57 | 58 | 59 | 60 | /****************************************************************************** 61 | * Name : uint8 Task_PT_IEC870_PL_Process(uint8 u8Evt) 62 | * Function : IEC870 physical layer test 63 | * Input : uint8 u8Evt 1~254 Event for the task 64 | * void *pPara Pointer of parameter 65 | * Output: : None 66 | * Return : SW_OK Successful operation 67 | * : SW_ERR Failed operation 68 | * 1~254 Event which is not processed. 69 | * Description: To be done 70 | * Version : V1.00 71 | * Author : Ian 72 | * Date : 13th Jul 2016 73 | ******************************************************************************/ 74 | uint8 Task_PT_IEC870_PL_Process(uint8 u8Evt, void *pPara); 75 | 76 | 77 | 78 | 79 | #ifdef __cplusplus 80 | } 81 | #endif 82 | 83 | #endif /* _TASK_PT_IEC870_PL_H */ 84 | 85 | /* End of file */ 86 | 87 | -------------------------------------------------------------------------------- /App/README.md: -------------------------------------------------------------------------------- 1 | ## Application Tasks 2 | This folder contains tasks for kinds of application, each task realise a specific function. Multiple tasks can be used to build an entire application. 3 | 4 | Task | Function 5 | ------------------ | --------- 6 | Task1/Task2/Task3 | Basic Multi-task demo 7 | Task_Demo_Queue | A demo task to show how to use Moe_Queue module 8 | Task_Led_Demo | A demo task to show how to control LEDs 9 | Task_PT_Demo/2 | Basic PT task demo. 10 | IEC870_PL | A test task to realise Phy. Layer of IEC870 11 | SleepSort | Sleep sorting 12 | 13 | -------------------------------------------------------------------------------- /App/SleepSort/SleepSort.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * File : SleepSort.c 3 | * Function : Sorting by sleep way 4 | * Description: To be done. 5 | * Version : V1.00 6 | * Author : Ian 7 | * Date : 23rd Jan 2018 8 | * History : No. When Who What 9 | * 1 23/Jan/2018 Ian Create 10 | ******************************************************************************/ 11 | 12 | #include "../../Pub/type_def.h" 13 | #include "../../Pub/common_head.h" 14 | #include "project_config.h" 15 | #include "../../Core/MOE_Core.h" 16 | #include "../../Core/MOE_Event.h" 17 | #include "../../Core/MOE_Timer.h" 18 | #include "../../Core/MOE_Msg.h" 19 | #include "./SleepSort.h 20 | #include "../../Pub/debug.h" 21 | 22 | static uint8 sg_u8TaskID = TASK_NO_TASK; 23 | 24 | static uint8 sg_au8Num[10] = [2,4,1,6,10,8,1,5,7,3,8,9]; 25 | static T_TIMER_NODE tNode; 26 | /****************************************************************************** 27 | * Name : uint8 SleepSort_Process(uint8 u8Evt, void *pPara) 28 | * Function : Sleep sorting 29 | * Input : uint8 u8Evt 1~254 Event for the task 30 | * void *pPara Pointer of parameter 31 | * Output: : None 32 | * Return : SW_OK Successful operation 33 | * : SW_ERR Failed operation 34 | * 1~254 Event which is not processed. 35 | * Description: To be done 36 | * Version : V1.00 37 | * Author : Ian 38 | * Date : 23rd Jan 2018 39 | ******************************************************************************/ 40 | uint8 SleepSort_Process(uint8 u8Evt, void *pPara) 41 | { 42 | /* Check which event should be processed */ 43 | switch (u8Evt) 44 | { 45 | /* If it is a delay event */ 46 | case EVENT_DELAY: 47 | { 48 | printf("%d",*((uint8*)pPara)); 49 | return SW_OK; /* Return SW_OK to indicate event is processed */ 50 | } 51 | 52 | 53 | /* If it is a message event */ 54 | case EVENT_INIT: 55 | { 56 | /******************************************************************/ 57 | MOE_MANDATORY_INIT(); /* Mandatory init, shout call it here only */ 58 | /******************************************************************/ 59 | 60 | /*-------------------- Add your init code here ----------------------*/ 61 | tNode.u16Cnt = 1; 62 | tNode.u8Evt = EVENT_DELAY; 63 | tNode.u8TaskID = TASK_CURRENT_TASK; 64 | for(uint8 u8Index = 0; u8Index < 10; u8Index++) 65 | { 66 | tNode.u32TmOut = sg_au8Num[u8Index]; 67 | tNode.u32TmLeft = sg_au8Num[u8Index]; 68 | tTmr.pTskPara = (void*)(&sg_au8Num[u8Index]); 69 | Moe_Timer_Start(tNode); 70 | } 71 | /*------------------- The end of your init code ---------------------*/ 72 | return SW_OK; /* Return SW_OK to indicate event is processed */ 73 | } 74 | 75 | /* If it is other event */ 76 | default: 77 | { 78 | return u8Evt; /* Return event to indicate event is NOT processed */ 79 | } 80 | } 81 | } 82 | 83 | /* End of file */ 84 | 85 | -------------------------------------------------------------------------------- /App/SleepSort/SleepSort.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * File : SleepSort.h 3 | * Function : To be done. 4 | * Description: To be done. 5 | * Version : V1.00 6 | * Author : Ian 7 | * Date : 24th Jan 2018 8 | * History : No. When Who What 9 | * 1 24/Jan/2018 Ian Create 10 | ******************************************************************************/ 11 | 12 | #ifndef _SLEEP_SORT_H_ 13 | #define _SLEEP_SORT_H_ 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | /* Check if specified option is set for debugging */ 20 | #ifndef __DEBUG_MODE_APP_SLEEP_SORT 21 | #define __DEBUG_MODE __DEBUG_NONE /* Default: None debugging info */ 22 | #else 23 | #ifdef __DEBUG_MODE 24 | #undef __DEBUG_MODE 25 | #endif 26 | #define __DEBUG_MODE __DEBUG_MODE_APP_SLEEP_SORT /* According the set from project_config.h */ 27 | #endif 28 | 29 | 30 | 31 | /****************************************************************************** 32 | * Name : uint8 SleepSort_Process(uint8 u8Evt, void *pPara) 33 | * Function : To be done. 34 | * Input : uint8 u8Evt 1~254 Event for the task 35 | * void *pPara Pointer of parameter 36 | * Output: : None 37 | * Return : SW_OK Successful operation 38 | * : SW_ERR Failed operation 39 | * 1~254 Event which is not processed. 40 | * Description: To be done 41 | * Version : V1.00 42 | * Author : Ian 43 | * Date : 24th Jan 2018 44 | ******************************************************************************/ 45 | uint8 Task1_Process(uint8 u8Evt, void *pPara); 46 | 47 | 48 | 49 | #ifdef __cplusplus 50 | } 51 | #endif 52 | 53 | #endif /* _SLEEP_SORT_H_ */ 54 | 55 | /* End of file */ 56 | 57 | -------------------------------------------------------------------------------- /App/Task1/Task1.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * File : Task1.c 3 | * Function : It is No. 1 task which is just a demo task 4 | * Description: To be done. 5 | * Version : V1.00 6 | * Author : Ian 7 | * Date : 3rd May 2016 8 | * History : No. When Who What 9 | * 1 3/May/2016 Ian Create 10 | ******************************************************************************/ 11 | 12 | #include "../../Pub/type_def.h" 13 | #include "../../Pub/common_head.h" 14 | #include "project_config.h" 15 | #include "../../Core/MOE_Core.h" 16 | #include "../../Core/MOE_Event.h" 17 | #include "../../Core/MOE_Timer.h" 18 | #include "../../Core/MOE_Msg.h" 19 | #include "./Task1.h" 20 | #include "../../Pub/debug.h" 21 | 22 | static uint8 sg_u8TaskID = TASK_NO_TASK; 23 | 24 | /****************************************************************************** 25 | * Name : uint8 Task1_Process(uint8 u8Evt, void *pPara) 26 | * Function : Task 1 process 27 | * Input : uint8 u8Evt 1~254 Event for the task 28 | * void *pPara Pointer of parameter 29 | * Output: : None 30 | * Return : SW_OK Successful operation 31 | * : SW_ERR Failed operation 32 | * 1~254 Event which is not processed. 33 | * Description: To be done 34 | * Version : V1.00 35 | * Author : Ian 36 | * Date : 3rd May 2016 37 | ******************************************************************************/ 38 | uint8 Task1_Process(uint8 u8Evt, void *pPara) 39 | { 40 | static uint32 u32Temp = 0x0; 41 | u32Temp++; 42 | /* Check which event should be processed */ 43 | switch (u8Evt) 44 | { 45 | /* If it is a timer event */ 46 | case EVENT_PERIODIC: 47 | { 48 | T_TEST_MSG tMsg; 49 | 50 | DBG_PRINT("I am task 1 and I am working!!\n"); 51 | 52 | tMsg.DATA.u32Data = u32Temp; 53 | if(SW_ERR == MOE_MSG_SEND(2, MSG_TYPE_TEST, tMsg)) 54 | { 55 | DBG_PRINT("Heap is running out!!"); 56 | } 57 | 58 | return SW_OK; /* Return SW_OK to indicate event is processed */ 59 | } 60 | 61 | /* If it is a message event */ 62 | case EVENT_MSG: 63 | { 64 | 65 | return SW_OK; /* Return SW_OK to indicate event is processed */ 66 | } 67 | 68 | /* If it is a test event */ 69 | case EVENT_TEST: 70 | { 71 | 72 | return SW_OK; /* Return SW_OK to indicate event is processed */ 73 | } 74 | 75 | /* If it is a timer event */ 76 | case EVENT_TIMER: 77 | { 78 | 79 | return SW_OK; /* Return SW_OK to indicate event is processed */ 80 | } 81 | 82 | /* If it is a message event */ 83 | case EVENT_INIT: 84 | { 85 | /******************************************************************/ 86 | MOE_MANDATORY_INIT(); /* Mandatory init, shout call it here only */ 87 | /******************************************************************/ 88 | 89 | /*-------------------- Add your init code here ----------------------*/ 90 | Moe_Timer_Periodic(100); 91 | /*------------------- The end of your init code ---------------------*/ 92 | return SW_OK; /* Return SW_OK to indicate event is processed */ 93 | } 94 | 95 | /* If it is other event */ 96 | default: 97 | { 98 | return u8Evt; /* Return event to indicate event is NOT processed */ 99 | } 100 | } 101 | } 102 | 103 | /* End of file */ 104 | 105 | 106 | -------------------------------------------------------------------------------- /App/Task1/Task1.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * File : Task1.h 3 | * Function : It is No. 1 task which is just a demo task 4 | * Description: To be done. 5 | * Version : V1.00 6 | * Author : Ian 7 | * Date : 3rd May 2016 8 | * History : No. When Who What 9 | * 1 3/May/2016 Ian Create 10 | ******************************************************************************/ 11 | 12 | #ifndef _TASK_1_H_ 13 | #define _TASK_1_H_ 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | /* Check if specified option is set for debugging */ 20 | #ifndef __DEBUG_MODE_APP_TASK_1 21 | #define __DEBUG_MODE __DEBUG_NONE /* Default: None debugging info */ 22 | #else 23 | #ifdef __DEBUG_MODE 24 | #undef __DEBUG_MODE 25 | #endif 26 | #define __DEBUG_MODE __DEBUG_MODE_APP_TASK_1 /* According the set from project_config.h */ 27 | #endif 28 | 29 | 30 | 31 | /****************************************************************************** 32 | * Name : uint8 Task1_Process(uint8 u8Evt, void *pPara) 33 | * Function : Task 1 process 34 | * Input : uint8 u8Evt 1~254 Event for the task 35 | * void *pPara Pointer of parameter 36 | * Output: : None 37 | * Return : SW_OK Successful operation 38 | * : SW_ERR Failed operation 39 | * 1~254 Event which is not processed. 40 | * Description: To be done 41 | * Version : V1.00 42 | * Author : Ian 43 | * Date : 3rd May 2016 44 | ******************************************************************************/ 45 | uint8 Task1_Process(uint8 u8Evt, void *pPara); 46 | 47 | 48 | 49 | #ifdef __cplusplus 50 | } 51 | #endif 52 | 53 | #endif /* _TASK_1_H */ 54 | 55 | /* End of file */ 56 | 57 | 58 | -------------------------------------------------------------------------------- /App/Task2/Task2.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * File : Task2.c 3 | * Function : It is No. 2 task which is just a demo task 4 | * Description: To be done. 5 | * Version : V1.00 6 | * Author : Ian 7 | * Date : 3rd May 2016 8 | * History : No. When Who What 9 | * 1 3/May/2016 Ian Create 10 | ******************************************************************************/ 11 | 12 | #include "../../Pub/type_def.h" 13 | #include "../../Pub/common_head.h" 14 | #include "project_config.h" 15 | #include "../../Core/MOE_Core.h" 16 | #include "../../Core/MOE_Event.h" 17 | #include "../../Core/MOE_Timer.h" 18 | #include "../../Core/MOE_Msg.h" 19 | #include "./Task2.h" 20 | #include "../../Pub/debug.h" 21 | 22 | 23 | static uint8 sg_u8TaskID = TASK_NO_TASK; 24 | /****************************************************************************** 25 | * Name : uint8 Task2_Process(uint8 u8Evt, void *pPara) 26 | * Function : Task 2 process 27 | * Input : uint8 u8Evt 1~254 Event for the task 28 | * void *pPara Pointer of parameter 29 | * Output: : None 30 | * Return : SW_OK Successful operation 31 | * : SW_ERR Failed operation 32 | * 1~254 Event which is not processed. 33 | * Description: To be done 34 | * Version : V1.00 35 | * Author : Ian 36 | * Date : 3rd May 2016 37 | ******************************************************************************/ 38 | uint8 Task2_Process(uint8 u8Evt, void *pPara) 39 | { 40 | /* Check which event should be processed */ 41 | switch (u8Evt) 42 | { 43 | /* If it is a timer event */ 44 | case EVENT_PERIODIC: 45 | { 46 | DBG_PRINT("I am task 2 and I am working!!\n"); 47 | return SW_OK; /* Return SW_OK to indicate event is processed */ 48 | } 49 | 50 | /* If it is a message event */ 51 | case EVENT_MSG: 52 | { 53 | uint8 u8MsgType = ((T_MSG_HEAD*)pPara)->u8MsgType; 54 | 55 | switch(u8MsgType) 56 | { 57 | case MSG_TYPE_TEST: 58 | { 59 | T_TEST_MSG *ptTestMsg = (T_TEST_MSG*)MOE_MSG_CONTENT(pPara); 60 | DBG_PRINT("I am task 2 , I got %d!\n",(ptTestMsg->DATA.u32Data)); 61 | Moe_Msg_Forward(pPara,3); 62 | } 63 | } 64 | 65 | return SW_OK; /* Return SW_OK to indicate event is processed */ 66 | } 67 | 68 | /* If it is a test event */ 69 | case EVENT_TEST: 70 | { 71 | 72 | return SW_OK; /* Return SW_OK to indicate event is processed */ 73 | } 74 | 75 | /* If it is a timer event */ 76 | case EVENT_TIMER: 77 | { 78 | 79 | return SW_OK; /* Return SW_OK to indicate event is processed */ 80 | } 81 | 82 | /* If it is a message event */ 83 | case EVENT_INIT: 84 | { 85 | /******************************************************************/ 86 | MOE_MANDATORY_INIT(); /* Mandatory init, shout call it here only */ 87 | /******************************************************************/ 88 | 89 | /*-------------------- Add your init code here ----------------------*/ 90 | //Moe_Timer_Periodic(1500); 91 | /*------------------- The end of your init code ---------------------*/ 92 | return SW_OK; /* Return SW_OK to indicate event is processed */ 93 | } 94 | 95 | /* If it is other event */ 96 | default: 97 | { 98 | return u8Evt; /* Return event to indicate event is NOT processed */ 99 | } 100 | } 101 | } 102 | /* End of file */ 103 | 104 | 105 | 106 | -------------------------------------------------------------------------------- /App/Task2/Task2.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * File : Task2.h 3 | * Function : To be doen. 4 | * Description: To be done. 5 | * Version : V1.00 6 | * Author : Ian 7 | * Date : 3rd May 2016 8 | * History : No. When Who What 9 | * 1 3/May/2016 Ian Create 10 | ******************************************************************************/ 11 | 12 | #ifndef _TASK_2_H_ 13 | #define _TASK_2_H_ 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | /* Check if specified option is set for debugging */ 20 | #ifndef __DEBUG_MODE_APP_TASK_2 21 | #define __DEBUG_MODE __DEBUG_NONE /* Default: None debugging info */ 22 | #else 23 | #ifdef __DEBUG_MODE 24 | #undef __DEBUG_MODE 25 | #endif 26 | #define __DEBUG_MODE __DEBUG_MODE_APP_TASK_2 /* According the set from project_config.h */ 27 | #endif 28 | 29 | 30 | 31 | /****************************************************************************** 32 | * Name : uint8 Task2_Process(uint8 u8Evt, void *pPara) 33 | * Function : Task 2 process 34 | * Input : uint8 u8Evt 1~254 Event for the task 35 | * void *pPara Pointer of parameter 36 | * Output: : None 37 | * Return : SW_OK Successful operation 38 | * : SW_ERR Failed operation 39 | * 1~254 Event which is not processed. 40 | * Description: To be done 41 | * Version : V1.00 42 | * Author : Ian 43 | * Date : 3rd May 2016 44 | ******************************************************************************/ 45 | uint8 Task2_Process(uint8 u8Evt, void *pPara); 46 | 47 | 48 | #ifdef __cplusplus 49 | } 50 | #endif 51 | 52 | #endif /* _TASK_2_H */ 53 | 54 | /* End of file */ 55 | 56 | 57 | -------------------------------------------------------------------------------- /App/Task3/Task3.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * File : Task3.c 3 | * Function : It is No. 3 task which is just a demo task 4 | * Description: To be done. 5 | * Version : V1.00 6 | * Author : Ian 7 | * Date : 3rd May 2016 8 | * History : No. When Who What 9 | * 1 3/May/2016 Ian Create 10 | ******************************************************************************/ 11 | 12 | #include "../../Pub/type_def.h" 13 | #include "../../Pub/common_head.h" 14 | #include "project_config.h" 15 | #include "../../Core/MOE_Core.h" 16 | #include "../../Core/MOE_Event.h" 17 | #include "../../Core/MOE_Timer.h" 18 | #include "../../Core/MOE_Msg.h" 19 | #include "./Task3.h" 20 | #include "../../Pub/debug.h" 21 | 22 | 23 | static uint8 sg_u8TaskID = TASK_NO_TASK; 24 | /****************************************************************************** 25 | * Name : uint8 Task3_Process(uint8 u8Evt, void *pPara) 26 | * Function : Task 3 process 27 | * Input : uint8 u8Evt 1~254 Event for the task 28 | * void *pPara Pointer of parameter 29 | * Output: : None 30 | * Return : SW_OK Successful operation 31 | * : SW_ERR Failed operation 32 | * 1~254 Event which is not processed. 33 | * Description: To be done 34 | * Version : V1.00 35 | * Author : Ian 36 | * Date : 3rd May 2016 37 | ******************************************************************************/ 38 | uint8 Task3_Process(uint8 u8Evt, void *pPara) 39 | { 40 | /* Check which event should be processed */ 41 | switch (u8Evt) 42 | { 43 | /* If it is a timer event */ 44 | case EVENT_PERIODIC: 45 | { 46 | DBG_PRINT("I am task 3 and I am working!!\n"); 47 | return SW_OK; /* Return SW_OK to indicate event is processed */ 48 | 49 | } 50 | 51 | /* If it is a message event */ 52 | case EVENT_MSG: 53 | { 54 | uint8 u8MsgType = ((T_MSG_HEAD*)pPara)->u8MsgType; 55 | static uint8 sg_u8Cnt = 0; 56 | 57 | u8MsgType = ((T_MSG_HEAD*)pPara)->u8MsgType; 58 | 59 | switch(u8MsgType) 60 | { 61 | case MSG_TYPE_TEST: 62 | { 63 | T_TEST_MSG *ptTestMsg = (T_TEST_MSG*)MOE_MSG_CONTENT(pPara); 64 | DBG_PRINT("\n\nThis is task %d\n",sg_u8TaskID); 65 | DBG_PRINT("Get %d messages\n",sg_u8Cnt++); 66 | DBG_PRINT("I get a uint32 data 0x%x!\n",(ptTestMsg->DATA.u32Data)); 67 | DBG_PRINT("I get a uint16 data 0x%x,0x%x!\n",(ptTestMsg->DATA.au16Data[0]),(ptTestMsg->DATA.au16Data[1])); 68 | DBG_PRINT("I get a uint8 data 0x%x,0x%x,0x%x,0x%x!\n\n",(ptTestMsg->DATA.au8Data[0]),(ptTestMsg->DATA.au8Data[1]),(ptTestMsg->DATA.au8Data[2]),(ptTestMsg->DATA.au8Data[3])); 69 | } 70 | default: 71 | { 72 | break; 73 | } 74 | 75 | } 76 | return SW_OK; /* Return SW_OK to indicate event is processed */ 77 | } 78 | 79 | /* If it is a test event */ 80 | case EVENT_TEST: 81 | { 82 | 83 | return SW_OK; /* Return SW_OK to indicate event is processed */ 84 | } 85 | 86 | /* If it is a timer event */ 87 | case EVENT_TIMER: 88 | { 89 | DBG_PRINT("I am a restart timer!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"); 90 | return SW_OK; /* Return SW_OK to indicate event is processed */ 91 | } 92 | 93 | /* If it is a timer event */ 94 | case EVENT_DELAY: 95 | { 96 | DBG_PRINT("I am a second delay!!!~~~~~~~~~~~~~~~~~~~~~\n"); 97 | return SW_OK; /* Return SW_OK to indicate event is processed */ 98 | } 99 | 100 | /* If it is a message event */ 101 | case EVENT_INIT: 102 | { 103 | /******************************************************************/ 104 | MOE_MANDATORY_INIT(); /* Mandatory init, shout call it here only */ 105 | /******************************************************************/ 106 | 107 | /*-------------------- Add your init code here ----------------------*/ 108 | Moe_Timer_Periodic(5000); 109 | /*------------------- The end of your init code ---------------------*/ 110 | return SW_OK; /* Return SW_OK to indicate event is processed */ 111 | } 112 | 113 | /* If it is other event */ 114 | default: 115 | { 116 | return u8Evt; /* Return event to indicate event is NOT processed */ 117 | } 118 | } 119 | } 120 | 121 | /* End of file */ 122 | 123 | 124 | 125 | -------------------------------------------------------------------------------- /App/Task3/Task3.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * File : Task3.h 3 | * Function : To be done. 4 | * Description: To be done. 5 | * Version : V1.00 6 | * Author : Ian 7 | * Date : 3rd May 2016 8 | * History : No. When Who What 9 | * 1 3/May/2016 Ian Create 10 | ******************************************************************************/ 11 | 12 | #ifndef _TASK_3_H_ 13 | #define _TASK_3_H_ 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | 20 | 21 | 22 | /* Check if specified option is set for debugging */ 23 | #ifndef __DEBUG_MODE_APP_TASK_3 24 | #define __DEBUG_MODE __DEBUG_NONE /* Default: None debugging info */ 25 | #else 26 | #ifdef __DEBUG_MODE 27 | #undef __DEBUG_MODE 28 | #endif 29 | #define __DEBUG_MODE __DEBUG_MODE_APP_TASK_3 /* According the set from project_config.h */ 30 | #endif 31 | 32 | /****************************************************************************** 33 | * Name : uint8 Task3_Process(uint8 u8Evt, void *pPara) 34 | * Function : Task 3 process 35 | * Input : uint8 u8Evt 1~254 Event for the task 36 | * void *pPara Pointer of parameter 37 | * Output: : None 38 | * Return : SW_OK Successful operation 39 | * : SW_ERR Failed operation 40 | * 1~254 Event which is not processed. 41 | * Description: To be done 42 | * Version : V1.00 43 | * Author : Ian 44 | * Date : 3rd May 2016 45 | ******************************************************************************/ 46 | uint8 Task3_Process(uint8 u8Evt, void *pPara); 47 | 48 | 49 | 50 | #ifdef __cplusplus 51 | } 52 | #endif 53 | 54 | #endif /* _TASK_3_H */ 55 | 56 | /* End of file */ 57 | 58 | 59 | -------------------------------------------------------------------------------- /App/Task_Demo_Queue/Task_Demo_Queue.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * File : Task_Demo_Queue.h 3 | * Function : It is demo task for queue 4 | * Description: This task creates two queues,one is located in task space, and 5 | * the other is created by Queue API. Task sends two messages with 6 | * the two queues and recieves the two messages from the queues. 7 | * Version : V1.00 8 | * Author : Ian 9 | * Date : 19th Jun 2016 10 | * History : No. When Who What 11 | * 1 19/Jun/2016 Ian V1.00: Create 12 | ******************************************************************************/ 13 | 14 | 15 | #ifndef _TASK_DEMO_QUEUE_H_ 16 | #define _TASK_DEMO_QUEUE_H_ 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | 23 | 24 | 25 | /* Check if specified option is set for debugging */ 26 | #ifndef __DEBUG_MODE_APP_TASK__DEMO_QUEUE 27 | #define __DEBUG_MODE __DEBUG_NONE /* Default: None debugging info */ 28 | #else 29 | #ifdef __DEBUG_MODE 30 | #undef __DEBUG_MODE 31 | #endif 32 | #define __DEBUG_MODE __DEBUG_MODE_APP_TASK__DEMO_QUEUE /* According the set from project_config.h */ 33 | #endif 34 | 35 | #define TASK_DEMO_QUEUE_BUF_NUM (5) /* Number of buffer blocks */ 36 | #define TASK_DEMO_QUEUE_BUF_SIZE (10) /* Size of each buffer blocks */ 37 | 38 | /****************************************************************************** 39 | * Name : uint8 Task_Demo_Queue_Process(uint8 u8Evt, void *pPara) 40 | * Function : Task Demo Queue process 41 | * Input : uint8 u8Evt 1~254 Event for the task 42 | * void *pPara Pointer of parameter 43 | * Output: : None 44 | * Return : To be done 45 | * Description: To be done 46 | * Version : V1.00 47 | * Author : Ian 48 | * Date : 19th Jun 2016 49 | ******************************************************************************/ 50 | uint8 Task_Demo_Queue_Process(uint8 u8Evt, void *pPara); 51 | 52 | 53 | 54 | 55 | 56 | #ifdef __cplusplus 57 | } 58 | #endif 59 | 60 | #endif /* _TASK_DEMO_QUEUE_H */ 61 | 62 | /* End of file */ 63 | 64 | 65 | -------------------------------------------------------------------------------- /App/Task_LED_Demo/README.md: -------------------------------------------------------------------------------- 1 | ## Task_LED_Demo 2 | This is a demo task which shows how to control LEDs 3 | -------------------------------------------------------------------------------- /App/Task_LED_Demo/Task_LED_Demo.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * File : Task_LED_Demo.c 3 | * Function : It is a LED demo task. 4 | * Description: To be done. 5 | * Version : V1.00 6 | * Author : Ian 7 | * Date : 3rd May 2016 8 | * History : No. When Who What 9 | * 1 3/May/2016 Ian Create 10 | ******************************************************************************/ 11 | 12 | #include "../../Pub/type_def.h" 13 | #include "../../Pub/common_head.h" 14 | #include "project_config.h" 15 | #include "../../Core/MOE_Core.h" 16 | #include "../../Core/MOE_Event.h" 17 | #include "../../Core/MOE_Timer.h" 18 | #include "../../Core/MOE_Msg.h" 19 | #include "Task_LED_Demo.h" 20 | #include "../../Pub/debug.h" 21 | #include "Board_Config.h" 22 | 23 | static uint8 sg_u8TaskID = TASK_NO_TASK; 24 | 25 | static void (*const TASK1_LED_Off)(uint8 u8Clr) = TASK1_LED_OFF; 26 | static void (*const TASK1_LED_On)(uint8 u8Clr) = TASK1_LED_ON; 27 | 28 | /****************************************************************************** 29 | * Name : uint8 lED_Demo_Process(uint8 u8Evt) 30 | * Function : LEd demo process 31 | * Input : uint8 u8Evt 1~254 Event for the task 32 | * void *pPara Pointer of parameter 33 | * Output: : None 34 | * Return : SW_OK Successful operation 35 | * : SW_ERR Failed operation 36 | * 1~254 Event which is not processed. 37 | * Description: To be done 38 | * Version : V1.00 39 | * Author : Ian 40 | * Date : 3rd May 2016 41 | ******************************************************************************/ 42 | uint8 LED_Demo_Process(uint8 u8Evt, void *pPara) 43 | { 44 | /* Check which event should be processed */ 45 | switch (u8Evt) 46 | { 47 | /* If it is a timer event */ 48 | case EVENT_PERIODIC: 49 | { 50 | DBG_PRINT("I am the task for LED demo and I am working!!\n"); 51 | 52 | static uint8 s_u8Clr = BOARD_CONFIG_LED_BLUE; 53 | TASK1_LED_Off(s_u8Clr); 54 | s_u8Clr = (s_u8Clr + 1) % (BOARD_CONFIG_LED_BLUE+1); 55 | TASK1_LED_On(s_u8Clr); 56 | switch(s_u8Clr) 57 | { 58 | case BOARD_CONFIG_LED_BLUE: 59 | { 60 | DBG_PRINT("Blue!!\n"); 61 | break; 62 | } 63 | case BOARD_CONFIG_LED_RED: 64 | { 65 | DBG_PRINT("Red!!\n"); 66 | break; 67 | } 68 | case BOARD_CONFIG_LED_YELLOW: 69 | { 70 | DBG_PRINT("Yellow!!\n"); 71 | break; 72 | } 73 | case BOARD_CONFIG_LED_GREEN: 74 | { 75 | DBG_PRINT("Green!!\n"); 76 | break; 77 | } 78 | default: 79 | { 80 | break; 81 | } 82 | } 83 | return SW_OK; /* Return SW_OK to indicate event is processed */ 84 | } 85 | 86 | /* If it is a message event */ 87 | case EVENT_MSG: 88 | { 89 | 90 | return SW_OK; /* Return SW_OK to indicate event is processed */ 91 | } 92 | 93 | /* If it is a test event */ 94 | case EVENT_TEST: 95 | { 96 | 97 | return SW_OK; /* Return SW_OK to indicate event is processed */ 98 | } 99 | 100 | /* If it is a timer event */ 101 | case EVENT_TIMER: 102 | { 103 | 104 | return SW_OK; /* Return SW_OK to indicate event is processed */ 105 | } 106 | 107 | /* If it is a message event */ 108 | case EVENT_INIT: 109 | { 110 | /******************************************************************/ 111 | MOE_MANDATORY_INIT(); /* Mandatory init, shout call it here only */ 112 | /******************************************************************/ 113 | 114 | /*-------------------- Add your init code here ----------------------*/ 115 | Moe_Timer_Periodic(300); 116 | /*------------------- The end of your init code ---------------------*/ 117 | return SW_OK; /* Return SW_OK to indicate event is processed */ 118 | } 119 | 120 | /* If it is other event */ 121 | default: 122 | { 123 | return u8Evt; /* Return event to indicate event is NOT processed */ 124 | } 125 | } 126 | } 127 | 128 | /* End of file */ 129 | 130 | 131 | 132 | -------------------------------------------------------------------------------- /App/Task_LED_Demo/Task_LED_Demo.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * File : Task_LED_Demo.h 3 | * Function : It is a LED demo task. 4 | * Description: To be done. 5 | * Version : V1.00 6 | * Author : Ian 7 | * Date : 3rd May 2016 8 | * History : No. When Who What 9 | * 1 3/May/2016 Ian Create 10 | ******************************************************************************/ 11 | 12 | 13 | #ifndef _TASK_LED_DEMO_H_ 14 | #define _TASK_LED_DEMO_H_ 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | /* Check if specified option is set for debugging */ 21 | #ifndef __DEBUG_MODE_TASK_LED_DEMO 22 | #define __DEBUG_MODE __DEBUG_NONE /* Default: None debugging info */ 23 | #else 24 | #ifdef __DEBUG_MODE 25 | #undef __DEBUG_MODE 26 | #endif 27 | #define __DEBUG_MODE __DEBUG_MODE_TASK_LED_DEMO /* According the set from project_config.h */ 28 | #endif 29 | 30 | 31 | 32 | /****************************************************************************** 33 | * Name : uint8 lED_Demo_Process(uint8 u8Evt) 34 | * Function : LEd demo process 35 | * Input : uint8 u8Evt 1~254 Event for the task 36 | * void *pPara Pointer of parameter 37 | * Output: : None 38 | * Return : SW_OK Successful operation 39 | * : SW_ERR Failed operation 40 | * 1~254 Event which is not processed. 41 | * Description: To be done 42 | * Version : V1.00 43 | * Author : Ian 44 | * Date : 3rd May 2016 45 | ******************************************************************************/ 46 | uint8 LED_Demo_Process(uint8 u8Evt, void *pPara); 47 | 48 | 49 | 50 | #ifdef __cplusplus 51 | } 52 | #endif 53 | 54 | #endif /* _TASK_LED_DEMO_H */ 55 | 56 | /* End of file */ 57 | 58 | 59 | -------------------------------------------------------------------------------- /App/Task_PT_11xx_Test/Task_PT_11xx_Test.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * File : Task_PT_11xx_Test.c 3 | * Function : PT task for 11xx test 4 | * Description: To be done. 5 | * Version : V1.00 6 | * Author : Ian 7 | * Date : 22nd May 2016 8 | * History : No. When Who What 9 | * 1 22/Jul/2016 Ian Create 10 | ******************************************************************************/ 11 | 12 | #include "../../Pub/type_def.h" 13 | #include "../../Pub/common_head.h" 14 | #include "project_config.h" 15 | #include "../../Core/MOE_Core.h" 16 | #include "../../Core/MOE_Event.h" 17 | #include "../../Core/MOE_Timer.h" 18 | #include "../../Core/MOE_Msg.h" 19 | #include "../../Core/MOE_PT.h" 20 | #include "Task_PT_11xx_Test.h" 21 | #include "../../Pub/debug.h" 22 | #include "MOE_HAL_UART.h" 23 | #include "../../Driver/Dev/11xx/MOE_DRV_11xx.h" 24 | #include "Board_Config.h" 25 | 26 | static uint8 sg_u8TaskID = TASK_NO_TASK; 27 | static uint8 sg_u8LFNIdx = 0; 28 | static uint8 sg_au8LFN[] = {0x80, 0x82, 0x84, 0x86, 0x88, 0x8A, 0x8C, 0x8E}; 29 | static uint8 sg_au8SndTele[] = {0x09, 0x00, 0x11, 0x22, 0x33, 0x44, 0x01, 0x00, 0x00, 0x00}; 30 | static uint8 sg_au8RcvTele[50] = {0x00}; 31 | 32 | static uint8 sg_au8SnAddr[6] = {0x66, 0x55, 0x44, 0x33, 0x22, 0x11}; 33 | static uint8 sg_au8ComAddr[8] = {0x00}; 34 | static uint8 sg_au8ShtAddr[2] = {0x00}; 35 | static uint8 sg_au8RegVal[256] = {0x01}; 36 | 37 | static void (*const TASK_PT_DEMO_LED_Off)(uint8 u8Clr) = TASK_PT_DEMO_LED_OFF; 38 | static void (*const TASK_PT_DEMO_LED_On)(uint8 u8Clr) = TASK_PT_DEMO_LED_ON; 39 | //static void (*const TASK_PT_DEMO_LED_Toggle)(uint8 u8Clr) = TASK_PT_DEMO_LED_TOGGLE; 40 | 41 | /****************************************************************************** 42 | * Name : uint8 Task_PT_11xx_Test(uint8 u8Evt, void *pPara) 43 | * Function : A test task for 11xx 44 | * Input : uint8 u8Evt 1~254 Event for the task 45 | * void *pPara Pointer of parameter 46 | * Output: : None 47 | * Return : SW_OK Successful operation 48 | * : SW_ERR Failed operation 49 | * 1~254 Event which is not processed. 50 | * Description: To be done 51 | * Version : V1.00 52 | * Author : Ian 53 | * Date : 22nd Jul 2016 54 | ******************************************************************************/ 55 | uint8 Task_PT_11xx_Test(uint8 u8Evt, void *pPara) 56 | { 57 | uint16 u16Idx; 58 | uint8 u8Temp = 0x07; 59 | 60 | PT_INIT(); 61 | 62 | PT_BEGIN(); 63 | 64 | /******************************************************************/ 65 | MOE_MANDATORY_INIT(); /* Mandatory init, shout call it here only */ 66 | /******************************************************************/ 67 | 68 | Drv_11xx_Init(); 69 | // Moe_HAL_Uart_Byte_Receive(); 70 | //Drv_11xx_Write_Reg(DRV_11XX_REG_TM_OUT, 1, &u8Temp); 71 | // Drv_11xx_Write_Reg(0x60, 1, &u8Temp); 72 | 73 | Drv_11xx_Cmd_Reg_Read(sg_au8RegVal); 74 | for (u16Idx = 0; u16Idx < DRV_11XX_MAX_REG_NUM; u16Idx++) 75 | { 76 | DBG_PRINT("0x%2x ", sg_au8RegVal[u16Idx]); 77 | } 78 | 79 | Moe_HAL_Uart_Rx_Int_Enable(); 80 | while(1) 81 | { 82 | #if (1) 83 | //TASK_PT_DEMO_LED_On(BOARD_CONFIG_LED_BLUE); 84 | //Drv_11xx_Receive_Telegram(sg_au8RcvTele); 85 | //TASK_PT_DEMO_LED_Off(BOARD_CONFIG_LED_BLUE); 86 | //PT_DELAY(500); 87 | TASK_PT_DEMO_LED_On(BOARD_CONFIG_LED_GREEN); 88 | Drv_11xx_Send_Telegram(sg_au8SndTele); 89 | //Drv_11xx_Send_Telegram(sg_au8RcvTele); 90 | PT_DELAY(50); 91 | sg_au8SndTele[9]++; 92 | sg_au8SndTele[6] = sg_au8LFN[sg_u8LFNIdx]; 93 | sg_u8LFNIdx = ((sg_u8LFNIdx + 1)%8); 94 | TASK_PT_DEMO_LED_Off(BOARD_CONFIG_LED_GREEN); 95 | #else 96 | TASK_PT_DEMO_LED_On(BOARD_CONFIG_LED_BLUE); 97 | if(MOE_HAL_UART_RCV_TEL == Moe_HAL_Uart_Got_Telegram()) 98 | { 99 | Moe_HAL_Uart_Tele_Receive(sg_au8RcvTele); 100 | TASK_PT_DEMO_LED_Off(BOARD_CONFIG_LED_BLUE); 101 | // PT_DELAY(500); 102 | // TASK_PT_DEMO_LED_On(BOARD_CONFIG_LED_GREEN); 103 | // Drv_11xx_Send_Telegram(sg_au8RcvTele); 104 | // PT_DELAY(100); 105 | // TASK_PT_DEMO_LED_Off(BOARD_CONFIG_LED_GREEN); 106 | } 107 | PT_BREAK(); 108 | #endif 109 | } 110 | 111 | PT_END(); 112 | 113 | return SW_OK; 114 | 115 | } 116 | 117 | /* End of file */ 118 | 119 | 120 | -------------------------------------------------------------------------------- /App/Task_PT_11xx_Test/Task_PT_11xx_Test.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * File : Task_PT_11xx_Test.h 3 | * Function : PT task for 11xx test 4 | * Description: To be done. 5 | * Version : V1.00 6 | * Author : Ian 7 | * Date : 22nd May 2016 8 | * History : No. When Who What 9 | * 1 22/Jul/2016 Ian Create 10 | ******************************************************************************/ 11 | 12 | 13 | #ifndef _TASK_PT_11XX_TEST_H_ 14 | #define _TASK_PT_11XX_TEST_H_ 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | /* Check if specified option is set for debugging */ 21 | #ifndef __DEBUG_MODE_PT_11XX_TEST 22 | #define __DEBUG_MODE __DEBUG_NONE /* Default: None debugging info */ 23 | #else 24 | #ifdef __DEBUG_MODE 25 | #undef __DEBUG_MODE 26 | #endif 27 | #define __DEBUG_MODE __DEBUG_MODE_PT_11XX_TEST /* According the set from project_config.h */ 28 | #endif 29 | 30 | 31 | 32 | /****************************************************************************** 33 | * Name : uint8 Task_PT_11xx_Test(uint8 u8Evt, void *pPara) 34 | * Function : A test task for 11xx 35 | * Input : uint8 u8Evt 1~254 Event for the task 36 | * void *pPara Pointer of parameter 37 | * Output: : None 38 | * Return : SW_OK Successful operation 39 | * : SW_ERR Failed operation 40 | * 1~254 Event which is not processed. 41 | * Description: To be done 42 | * Version : V1.00 43 | * Author : Ian 44 | * Date : 22nd Jul 2016 45 | ******************************************************************************/ 46 | uint8 Task_PT_11xx_Test(uint8 u8Evt, void *pPara); 47 | 48 | 49 | 50 | #ifdef __cplusplus 51 | } 52 | #endif 53 | 54 | #endif /* _TASK_PT_11XX_TEST_H */ 55 | 56 | /* End of file */ 57 | 58 | 59 | -------------------------------------------------------------------------------- /App/Task_PT_Demo/Task_PT_Demo.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * File : Task_PT_Demo.c 3 | * Function : A demo task for PT application 4 | * Description: To be done. 5 | * Version : V1.00 6 | * Author : Ian 7 | * Date : 8th Jul 2016 8 | * History : No. When Who What 9 | * 1 08/Jul/2016 Ian Create 10 | ******************************************************************************/ 11 | 12 | #include "../../Pub/type_def.h" 13 | #include "../../Pub/common_head.h" 14 | #include "project_config.h" 15 | #include "../../Core/MOE_Core.h" 16 | #include "../../Core/MOE_Event.h" 17 | #include "../../Core/MOE_Timer.h" 18 | #include "../../Core/MOE_Msg.h" 19 | #include "../../Core/MOE_PT.h" 20 | #include "./Task_PT_Demo.h" 21 | #include "../../Pub/debug.h" 22 | 23 | static uint8 sg_u8TaskID = TASK_NO_TASK; 24 | 25 | static void (*const TASK_PT_DEMO_LED_Off)(uint8 u8Clr) = TASK_PT_DEMO_LED_OFF; 26 | static void (*const TASK_PT_DEMO_LED_On)(uint8 u8Clr) = TASK_PT_DEMO_LED_ON; 27 | //static void (*const TASK_PT_DEMO_LED_Toggle)(uint8 u8Clr) = TASK_PT_DEMO_LED_TOGGLE; 28 | 29 | /****************************************************************************** 30 | * Name : uint8 Task_PT_Demo_Process(uint8 u8Evt, void *pPara) 31 | * Function : A demo task for PT application 32 | * Input : uint8 u8Evt 1~254 Event for the task 33 | * void *pPara Pointer of parameter 34 | 35 | * Output: : None 36 | * Return : SW_OK Successful operation 37 | * : SW_ERR Failed operation 38 | * 1~254 Event which is not processed. 39 | * Description: To be done 40 | * Version : V1.00 41 | * Author : Ian 42 | * Date : 8th Jul 2016 43 | ******************************************************************************/ 44 | uint8 Task_PT_Demo_Process(uint8 u8Evt, void *pPara) 45 | { 46 | PT_INIT(); 47 | 48 | PT_BEGIN(); 49 | 50 | /******************************************************************/ 51 | MOE_MANDATORY_INIT(); /* Mandatory init, shout call it here only */ 52 | /******************************************************************/ 53 | 54 | while(1) 55 | { 56 | TASK_PT_DEMO_LED_On(LED_RED); 57 | PT_DELAY(1000); 58 | TASK_PT_DEMO_LED_Off(LED_RED); 59 | 60 | TASK_PT_DEMO_LED_On(LED_GREEN); 61 | PT_DELAY(1000); 62 | TASK_PT_DEMO_LED_Off(LED_GREEN); 63 | 64 | TASK_PT_DEMO_LED_On(LED_BLUE); 65 | PT_DELAY(1000); 66 | TASK_PT_DEMO_LED_Off(LED_BLUE); 67 | } 68 | 69 | PT_END(); 70 | 71 | return SW_OK; 72 | 73 | } 74 | 75 | /* End of file */ 76 | 77 | -------------------------------------------------------------------------------- /App/Task_PT_Demo/Task_PT_Demo.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * File : Task_PT_Demo.h 3 | * Function : A demo task for PT application 4 | * Description: To be done. 5 | * Version : V1.00 6 | * Author : Ian 7 | * Date : 8th Jul 2016 8 | * History : No. When Who What 9 | * 1 08/Jul/2016 Ian Create 10 | ******************************************************************************/ 11 | 12 | 13 | #ifndef _TASK_PT_DEMO_H_ 14 | #define _TASK_PT_DEMO_H_ 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | /* Check if specified option is set for debugging */ 21 | #ifndef __DEBUG_MODE_PT_DEMO 22 | #define __DEBUG_MODE __DEBUG_NONE /* Default: None debugging info */ 23 | #else 24 | #ifdef __DEBUG_MODE 25 | #undef __DEBUG_MODE 26 | #endif 27 | #define __DEBUG_MODE __DEBUG_MODE_PT_DEMO /* According the set from project_config.h */ 28 | #endif 29 | 30 | 31 | 32 | /****************************************************************************** 33 | * Name : uint8 Task_PT_Demo_Process(uint8 u8Evt, void *pPara) 34 | * Function : A demo task for PT application 35 | * Input : uint8 u8Evt 1~254 Event for the task 36 | * void *pPara Pointer of parameter 37 | 38 | * Output: : None 39 | * Return : SW_OK Successful operation 40 | * : SW_ERR Failed operation 41 | * 1~254 Event which is not processed. 42 | * Description: To be done 43 | * Version : V1.00 44 | * Author : Ian 45 | * Date : 8th Jul 2016 46 | ******************************************************************************/ 47 | uint8 Task_PT_Demo_Process(uint8 u8Evt, void *pPara); 48 | 49 | 50 | 51 | 52 | #ifdef __cplusplus 53 | } 54 | #endif 55 | 56 | #endif /* _TASK_PT_DEMO_H */ 57 | 58 | /* End of file */ 59 | 60 | -------------------------------------------------------------------------------- /App/Task_PT_Demo_2/Task_PT_Demo2.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * File : Task_PT_Demo2.c 3 | * Function : Another demo task for PT application 4 | * Description: To be done. 5 | * Version : V1.00 6 | * Author : Ian 7 | * Date : 8th Jul 2016 8 | * History : No. When Who What 9 | * 1 08/Jul/2016 Ian Create 10 | ******************************************************************************/ 11 | 12 | #include "../../Pub/type_def.h" 13 | #include "../../Pub/common_head.h" 14 | #include "project_config.h" 15 | #include "../../Core/MOE_Core.h" 16 | #include "../../Core/MOE_Event.h" 17 | #include "../../Core/MOE_Timer.h" 18 | #include "../../Core/MOE_Msg.h" 19 | #include "../../Core/MOE_PT.h" 20 | #include "./Task_PT_Demo2.h" 21 | #include "../../Pub/debug.h" 22 | 23 | static uint8 sg_u8TaskID = TASK_NO_TASK; 24 | 25 | /****************************************************************************** 26 | * Name : uint8 Task_PT_Demo2_Process(uint8 u8Evt, void *pPara) 27 | * Function : A demo task for PT application 28 | * Input : uint8 u8Evt 1~254 Event for the task 29 | * void *pPara Pointer of parameter 30 | * Output: : None 31 | * Return : SW_OK Successful operation 32 | * : SW_ERR Failed operation 33 | * 1~254 Event which is not processed. 34 | * Description: To be done 35 | * Version : V1.00 36 | * Author : Ian 37 | * Date : 8th Jul 2016 38 | ******************************************************************************/ 39 | uint8 Task_PT_Demo2_Process(uint8 u8Evt, void *pPara) 40 | { 41 | PT_INIT(); 42 | 43 | PT_BEGIN(); 44 | 45 | /******************************************************************/ 46 | MOE_MANDATORY_INIT(); /* Mandatory init, shout call it here only */ 47 | /******************************************************************/ 48 | 49 | while(1) 50 | { 51 | printf("I am another Task!!\n"); 52 | PT_DELAY(1000); 53 | } 54 | 55 | PT_END(); 56 | 57 | return SW_OK; 58 | 59 | } 60 | 61 | /* End of file */ 62 | 63 | 64 | -------------------------------------------------------------------------------- /App/Task_PT_Demo_2/Task_PT_Demo2.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * File : Task_PT_Demo2.h 3 | * Function : Another demo task for PT application 4 | * Description: To be done. 5 | * Version : V1.00 6 | * Author : Ian 7 | * Date : 8th Jul 2016 8 | * History : No. When Who What 9 | * 1 08/Jul/2016 Ian Create 10 | ******************************************************************************/ 11 | 12 | 13 | #ifndef _TASK_PT_DEMO2_H_ 14 | #define _TASK_PT_DEMO2_H_ 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | /* Check if specified option is set for debugging */ 21 | #ifndef __DEBUG_MODE_PT_DEMO2 22 | #define __DEBUG_MODE __DEBUG_NONE /* Default: None debugging info */ 23 | #else 24 | #ifdef __DEBUG_MODE 25 | #undef __DEBUG_MODE 26 | #endif 27 | #define __DEBUG_MODE __DEBUG_MODE_PT_DEMO2 /* According the set from project_config.h */ 28 | #endif 29 | 30 | 31 | 32 | /****************************************************************************** 33 | * Name : uint8 Task_PT_Demo2_Process(uint8 u8Evt, void *pPara) 34 | * Function : A demo task for PT application 35 | * Input : uint8 u8Evt 1~254 Event for the task 36 | * void *pPara Pointer of parameter 37 | * Output: : None 38 | * Return : SW_OK Successful operation 39 | * : SW_ERR Failed operation 40 | * 1~254 Event which is not processed. 41 | * Description: To be done 42 | * Version : V1.00 43 | * Author : Ian 44 | * Date : 8th Jul 2016 45 | ******************************************************************************/ 46 | uint8 Task_PT_Demo2_Process(uint8 u8Evt, void *pPara); 47 | 48 | 49 | 50 | 51 | #ifdef __cplusplus 52 | } 53 | #endif 54 | 55 | #endif /* _TASK_PT_DEMO2_H */ 56 | 57 | /* End of file */ 58 | 59 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. 6 | 7 | ## Our Standards 8 | 9 | Examples of behavior that contributes to creating a positive environment include: 10 | 11 | * Using welcoming and inclusive language 12 | * Being respectful of differing viewpoints and experiences 13 | * Gracefully accepting constructive criticism 14 | * Focusing on what is best for the community 15 | * Showing empathy towards other community members 16 | 17 | Examples of unacceptable behavior by participants include: 18 | 19 | * The use of sexualized language or imagery and unwelcome sexual attention or advances 20 | * Trolling, insulting/derogatory comments, and personal or political attacks 21 | * Public or private harassment 22 | * Publishing others' private information, such as a physical or electronic address, without explicit permission 23 | * Other conduct which could reasonably be considered inappropriate in a professional setting 24 | 25 | ## Our Responsibilities 26 | 27 | Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. 28 | 29 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. 30 | 31 | ## Scope 32 | 33 | This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. 34 | 35 | ## Enforcement 36 | 37 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at ianhom@163.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. 38 | 39 | Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. 40 | 41 | ## Attribution 42 | 43 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] 44 | 45 | [homepage]: http://contributor-covenant.org 46 | [version]: http://contributor-covenant.org/version/1/4/ 47 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # CONTRIBUTING 2 | Hi everybody! welcome to join with MOE! 3 | -------------------------------------------------------------------------------- /Core/MOE_App.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * File : MOE_App.c 3 | * Function : This file is an interface for user to add tasks to MOE. 4 | * This file should be modified according to your tasks. 5 | * description: To be done. 6 | * Version : V1.00 7 | * Author : Ian 8 | * Date : 3rd May 2016 9 | * History : No. When Who What 10 | * 1 3/May/2016 Ian Create 11 | ******************************************************************************/ 12 | 13 | #include "type_def.h" 14 | #include "common_head.h" 15 | #include "project_config.h" 16 | #include "MOE_Core.h" 17 | #include "MOE_Event.h" 18 | #include "MOE_App.h" 19 | #include "debug.h" 20 | #include "Task1.h" 21 | #include "Task2.h" 22 | #include "Task3.h" 23 | #include "Task_Demo_Queue.h" 24 | 25 | /* Add your task process here */ 26 | const PF_TASK_PROCESS cg_apfTaskFn[] = 27 | { 28 | Task1_Process 29 | }; 30 | 31 | /* Calculate the total task number */ 32 | const uint8 cg_u8TaskNum = sizeof(cg_apfTaskFn)/sizeof(PF_TASK_PROCESS); 33 | 34 | #if (0) 35 | /* End of file */ 36 | 37 | 38 | -------------------------------------------------------------------------------- /Core/MOE_App.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * File : MOE_App.h 3 | * Function : User application definitions. 4 | * description: To be done. 5 | * Version : V1.00 6 | * Author : Ian 7 | * Date : 3rd May 2016 8 | * History : No. When Who What 9 | * 1 3/May/2016 Ian Create 10 | ******************************************************************************/ 11 | 12 | #ifndef _MOE_APP_H_ 13 | #define _MOE_APP_H_ 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | /* Check if specified option is set for debugging */ 20 | #ifndef __DEBUG_MODE_MOE_APP 21 | #define __DEBUG_MODE __DEBUG_NONE /* Default: None debugging info */ 22 | #else 23 | #ifdef __DEBUG_MODE 24 | #undef __DEBUG_MODE 25 | #endif 26 | #define __DEBUG_MODE __DEBUG_MODE_MOE_APP /* According the set from project_config.h */ 27 | #endif 28 | 29 | #ifndef MAX_TASK_NUM 30 | #define MAX_TASK_NUM (3) /* Max number of tasks */ 31 | #endif 32 | 33 | void Moe_Tasks_Init(); 34 | 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | 39 | #endif /* MOE_APP_H */ 40 | 41 | /* End of file */ 42 | 43 | -------------------------------------------------------------------------------- /Core/MOE_Event.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * File : MOE_Event.h 3 | * Function : Provide event services. 4 | * Description: To be done. 5 | * Version : V1.00 6 | * Author : Ian 7 | * Date : 21st Jun 2016 8 | * History : No. When Who What 9 | * 1 21/Jun/2016 Ian V1.00: Create 10 | ******************************************************************************/ 11 | 12 | 13 | #ifndef _MOE_EVENT_H_ 14 | #define _MOE_EVENT_H_ 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | /* Check if specified option is set for debugging */ 21 | #ifndef __DEBUG_MODE_MOE_EVENT 22 | #define __DEBUG_MODE __DEBUG_NONE /* Default: None debugging info */ 23 | #else 24 | #ifdef __DEBUG_MODE 25 | #undef __DEBUG_MODE 26 | #endif 27 | #define __DEBUG_MODE __DEBUG_MODE_MOE_EVENT /* According the set from project_config.h */ 28 | #endif 29 | 30 | 31 | /* MACRO */ 32 | #define MOE_EVENT_URGENT (1) /* It is an urgent event */ 33 | #define MOE_EVENT_NORMAL (0) /* It is a normal event */ 34 | 35 | #define EVENT_NONE (0x00) /* There is no events */ 36 | #define EVENT_INIT (0x01) /* There is a test event */ 37 | #define EVENT_TIMER (0x02) /* There is a timer event */ 38 | #define EVENT_MSG (0x03) /* There is a message event */ 39 | #define EVENT_INT (0x04) /* There is an interrupt event */ 40 | #define EVENT_DELAY (0x05) /* There is a deley event */ 41 | #define EVENT_PERIODIC (0x06) /* There is a periodic call event */ 42 | #define EVENT_TEST (0x07) /* There is a test event */ 43 | #define EVENT_BREAK (0x08) /* There is an event after a break */ 44 | 45 | /******************************************************************************* 46 | * Structure : T_EVENT 47 | * Description: Structure of event information including task ID and event. 48 | * Memebers : void *pPara Pointer of parameter 49 | * uint8 u8Src 1~255 The source task ID which set such event 50 | * uint8 u8Task 1~255 The destination task ID which receives such event 51 | * uint8 u8Evt 1~255 The event 52 | *******************************************************************************/ 53 | typedef struct _T_EVENT 54 | { 55 | void *pPara; 56 | uint8 u8Src; 57 | uint8 u8Task; 58 | uint8 u8Evt; 59 | }T_EVENT; 60 | 61 | /******************************************************************************* 62 | * Structure : T_EVENT_QUEUE 63 | * Description: Structure of event queue. 64 | * Memebers : struct _T_EVENT_QUEUE *ptNext Pointer for next event queue node 65 | * struct _T_EVENT_QUEUE *ptPre; Pointer for previous event queue node 66 | * T_EVENT atEvtQueue[MAX_QUEUE_EVT_NUM] Event queue block 67 | *******************************************************************************/ 68 | typedef struct _T_EVENT_QUEUE 69 | { 70 | struct _T_EVENT_QUEUE *ptNext; /* Pointer for next event queue node */ 71 | struct _T_EVENT_QUEUE *ptPre; /* Pointer for previous event queue node */ 72 | T_EVENT atEvtQueue[MAX_QUEUE_EVT_NUM]; 73 | }T_EVENT_QUEUE; 74 | 75 | 76 | /****************************************************************************** 77 | * Name : uint8 Moe_Event_Init(void) 78 | * Function : Init event queue 79 | * Input : None 80 | * Output: : None 81 | * Return : SW_OK Successful. 82 | * SW_ERR Failed. 83 | * Description: To be done. 84 | * Version : V1.00 85 | * Author : Ian 86 | * Date : 6th May 2016 87 | ******************************************************************************/ 88 | uint8 Moe_Event_Init(void); 89 | 90 | /****************************************************************************** 91 | * Name : uint8 Moe_Event_Set(uint8 u8TaskID, uint8 u8Evt, uint8 u8Urg, void *pPara) 92 | * Function : This function is used to set event for tasks. 93 | * Input : uint8 u8TaskID 1~255 The task ID to receive such event 94 | * uint8 u8Evt 1~255 The event type 95 | * uint8 u8Urg MOE_EVENT_URGENT It is an urgent event 96 | * MOE_EVENT_NORMAL It is a normal event 97 | * uint8 pPara Pointer of parameter 98 | * Output: : None 99 | * Return : SW_OK Successful. 100 | * SW_ERR Failed. 101 | * Description: To be done 102 | * Version : V1.00 103 | * Author : Ian 104 | * Date : 3rd May 2016 105 | ******************************************************************************/ 106 | uint8 Moe_Event_Set(uint8 u8TaskID, uint8 u8Evt, uint8 u8Urg, void *pPara); 107 | 108 | /****************************************************************************** 109 | * Name : T_EVENT* Moe_Event_Get(void) 110 | * Function : To get a event from quque 111 | * Input : None 112 | * Output: : None 113 | * Return : NULL : No event 114 | * Other: Event pointer 115 | * Description: To be done 116 | * Version : V1.00 117 | * Author : Ian 118 | * Date : 3rd May 2016 119 | ******************************************************************************/ 120 | T_EVENT* Moe_Event_Get(void); 121 | 122 | 123 | 124 | #ifdef __cplusplus 125 | } 126 | #endif 127 | 128 | #endif /* _MOE_EVENT_H_ */ 129 | 130 | /* End of file */ 131 | 132 | -------------------------------------------------------------------------------- /Core/MOE_HAL.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * File : MOE_HAL.c 3 | * Function : Hardware Abstract Layer. 4 | * Description: To be done. 5 | * Version : V1.00 6 | * Author : Ian 7 | * Date : 4th Jul 2016 8 | * History : No. When Who What 9 | * 1 04/Jul/2016 Ian Create 10 | ******************************************************************************/ 11 | 12 | #include "../Pub/type_def.h" 13 | #include "../Pub/common_head.h" 14 | #include "project_config.h" 15 | #include "./MOE_Core.h" 16 | #include "./MOE_Msg.h" 17 | #include "./MOE_HAL.h" 18 | #include "../Pub/debug.h" 19 | #ifdef __MOE_SPI_ENABLE 20 | #include "MOE_HAL_SPI.h" 21 | #endif 22 | #ifdef __MOE_I2C_ENABLE 23 | #include "MOE_HAL_I2C.h" 24 | #endif 25 | #ifdef __MOE_UART_ENABLE 26 | #include "MOE_HAL_UART.h" 27 | #endif 28 | 29 | 30 | 31 | /****************************************************************************** 32 | * Name : uint8 Moe_HAL_Init(void) 33 | * Function : Init hardware abstract layer 34 | * Input : None. 35 | * Output: : None. 36 | * Return : SW_OK Successful. 37 | * SW_ERR Failed. 38 | * Description: To be done. 39 | * Version : V1.00 40 | * Author : Ian 41 | * Date : 4th Jul 2016 42 | ******************************************************************************/ 43 | uint8 Moe_HAL_Init(void) 44 | { 45 | uint32 u32IntSt; 46 | 47 | ENTER_CRITICAL_ZONE(u32IntSt); /* Enter the critical zone to prevent event updating unexpectedly */ 48 | /**************************************************************************************************/ 49 | /**************************************************************************************************/ 50 | EXIT_CRITICAL_ZONE(u32IntSt); /* Exit the critical zone */ 51 | #ifdef __MOE_SPI_ENABLE 52 | Moe_HAL_SPI_Init(); 53 | #endif 54 | 55 | #ifdef __MOE_I2C_ENABLE 56 | Moe_HAL_I2C_Init(); 57 | #endif 58 | 59 | #ifdef __MOE_UART_ENABLE 60 | Moe_HAL_UART_Init(); 61 | #endif 62 | 63 | 64 | 65 | 66 | return SW_OK; 67 | 68 | } 69 | 70 | /* end of file */ 71 | 72 | -------------------------------------------------------------------------------- /Core/MOE_HAL.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * File : MOE_HAL.c 3 | * Function : Hardware Abstract Layer. 4 | * Description: To be done. 5 | * Version : V1.00 6 | * Author : Ian 7 | * Date : 4th Jul 2016 8 | * History : No. When Who What 9 | * 1 04/Jul/2016 Ian Create 10 | ******************************************************************************/ 11 | 12 | #ifndef _MOE_HAL_H_ 13 | #define _MOE_HAL_H_ 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | /* Check if specified option is set for debugging */ 20 | #ifndef __DEBUG_MODE_MOE_HAL 21 | #define __DEBUG_MODE __DEBUG_NONE /* Default: None debugging info */ 22 | #else 23 | #ifdef __DEBUG_MODE 24 | #undef __DEBUG_MODE 25 | #endif 26 | #define __DEBUG_MODE __DEBUG_MODE_MOE_HAL /* According the set from project_config.h */ 27 | #endif 28 | 29 | 30 | /* Driver configuration commmand type */ 31 | #define MOE_DRV_INIT (0) /* Init command */ 32 | #define MOE_DRV_CONFIG (1) /* Configure command */ 33 | #define MOE_DRV_CTRL (2) /* Control command */ 34 | #define MOE_DRV_FUNC_EN (3) /* Enable driver function */ 35 | #define MOE_DRV_FUNC_DIS (4) /* Disable driver function */ 36 | #define MOE_DRV_INT_EN (5) /* Enable interrupt */ 37 | #define MOE_DRV_INT_DIS (6) /* Disable interrupt */ 38 | #define MOE_DRV_RX_EN (7) /* Enable Rx */ 39 | #define MOE_DRV_RX_DIS (8) /* Disable RX */ 40 | #define MOE_DRV_TX_EN (9) /* Enable Tx */ 41 | #define MOE_DRV_TX_DIS (10) /* Disable TX */ 42 | #define MOE_DRV_DMA_EN (11) /* Enable DMA function */ 43 | #define MOE_DRV_DMA_DIS (12) /* Disable DMA function */ 44 | 45 | /* Structure of driver parameters */ 46 | typedef struct _T_MOE_DRV_PARA 47 | { 48 | void (*pfCallBack)(void *pPara); /* Callback pointer */ 49 | uint8 *pu8Buf; /* Pointer for parameter */ 50 | uint16 u16BufLen; /* Length of pararmeters in byte */ 51 | uint8 u8Type; /* Type of command or configuration */ 52 | }T_MOE_DRV_PARA; 53 | 54 | /* Structure of driver operation interface */ 55 | typedef struct _T_MOE_DRV_OP 56 | { 57 | uint8 (*pfInit)(T_MOE_DRV_PARA *ptPara); /* Init operation */ 58 | uint8 (*pfCtrl)(T_MOE_DRV_PARA *ptPara); /* Control operation */ 59 | uint8 (*pfRead)(T_MOE_DRV_PARA *ptPara); /* Read operation */ 60 | uint8 (*pfWrite)(T_MOE_DRV_PARA *ptPara); /* Write operation */ 61 | }T_MOE_DRV_OP; 62 | 63 | 64 | /****************************************************************************** 65 | * Name : uint8 Moe_HAL_Init(void) 66 | * Function : Init hardware abstract layer 67 | * Input : None. 68 | * Output: : None. 69 | * Return : SW_OK Successful. 70 | * SW_ERR Failed. 71 | * Description: To be done. 72 | * Version : V1.00 73 | * Author : Ian 74 | * Date : 4th Jul 2016 75 | ******************************************************************************/ 76 | uint8 Moe_HAL_Init(void); 77 | 78 | 79 | #ifdef __cplusplus 80 | } 81 | #endif 82 | 83 | #endif /* _MOE_HAL_H_ */ 84 | 85 | /* End of file */ 86 | 87 | -------------------------------------------------------------------------------- /Core/MOE_PT.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * File : MOE_PT.h 3 | * Function : PT definitions. 4 | * Description: To be done. 5 | * Version : V1.00 6 | * Author : Ian 7 | * Date : 8th Jul 2016 8 | * History : No. When Who What 9 | * 1 08/Jul/2016 Ian Create 10 | * 2 25/Nov/2016 Ian Extend the range of running point 11 | ******************************************************************************/ 12 | 13 | #ifndef _PT_H_ 14 | #define _PT_H_ 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | /* PT init, use this macro at the beginning of PT task */ 21 | #define PT_INIT() static unsigned short int sg_u16RunPoint = 0; 22 | 23 | /* PT begin, use it with PT_END to contain the pt process */ 24 | #define PT_BEGIN() unsigned char u8YieldFlag = 1;\ 25 | switch(sg_u16RunPoint)\ 26 | {\ 27 | case 0: 28 | 29 | /* PT end, use it with PT_BEGIN to contain the pt process */ 30 | #define PT_END() }\ 31 | u8YieldFlag = 0;\ 32 | sg_u16RunPoint = 0; 33 | 34 | /* PT yield, return from process */ 35 | #define PT_YIELD() do\ 36 | {\ 37 | u8YieldFlag = 0;\ 38 | sg_u16RunPoint = __LINE__;case __LINE__:\ 39 | if(0 == u8YieldFlag)\ 40 | {\ 41 | return SW_OK;\ 42 | }\ 43 | }\ 44 | while(0) 45 | 46 | /* PT yield until a condition */ 47 | #define PT_YIELD_UNTIL(c) do\ 48 | {\ 49 | u8YieldFlag = 0;\ 50 | sg_u16RunPoint = __LINE__;case __LINE__:\ 51 | if((0 == u8YieldFlag) || !(c))\ 52 | {\ 53 | return SW_OK;\ 54 | }\ 55 | }\ 56 | while(0) 57 | 58 | /* Wait a condition */ 59 | #define PT_WAIT_UNTIL(c) do\ 60 | {\ 61 | u8YieldFlag = 0;\ 62 | sg_u16RunPoint = __LINE__;case __LINE__:\ 63 | if(!(c))\ 64 | {\ 65 | return SW_OK;\ 66 | }\ 67 | }\ 68 | while(0) 69 | 70 | /* Wait for calling */ 71 | #define PT_WAIT_CALL() PT_YIELD() 72 | 73 | /* Wait an event */ 74 | #define PT_WAIT_EVENT(e) PT_YIELD_UNTIL(e == u8Evt) 75 | 76 | /* Wait a condition */ 77 | #define PT_WAIT_COND(c) PT_YIELD_UNTIL(c) 78 | 79 | /* Check a condition */ 80 | #define PT_CHECK_COND(c) PT_WAIT_UNTIL(c) 81 | 82 | /* Return and recall after t ms delay */ 83 | #define PT_DELAY(t) Moe_Timer_Delay(t);\ 84 | PT_WAIT_EVENT(EVENT_DELAY) 85 | 86 | /* Return and recall as soon as possible, leave a chance for other task */ 87 | #define PT_BREAK() Moe_Event_Set(sg_u8TaskID, EVENT_BREAK, MOE_EVENT_NORMAL, NULL);\ 88 | PT_YIELD() 89 | 90 | /* Wait for a message event */ 91 | #define PT_WAIT_MSG() PT_WAIT_EVENT(EVENT_MSG) 92 | 93 | /* Because PT process should NOT use stack, we need static local variable */ 94 | #define PTV static 95 | 96 | 97 | 98 | #ifdef __cplusplus 99 | } 100 | #endif 101 | 102 | #endif /* _PT_H_ */ 103 | 104 | /* End of file */ 105 | 106 | 107 | -------------------------------------------------------------------------------- /Core/README.md: -------------------------------------------------------------------------------- 1 | # MOE Core files 2 | 3 | ## Introduction 4 | The folder contains all core files of "MOE". It includes MOE scheduler, MOE timer, MOE message, MOE event, MOE queue and so on. 5 | 6 | 7 | Module | Function 8 | ------------- | --------- 9 | Moe_Core | Scheduler of MOE 10 | Moe_Timer | Timer module for core and application task. 11 | Moe_Msg | Message mechanism for the communication bewteen tasks or interrupt to tasks. 12 | Moe_Event | Event queue process. 13 | Moe_Queue | Provide easy-use queue services. 14 | Moe_HAL | Hardware Abstract Layer(**NOT FINISH YET**) 15 | Moe_PT | Protothread definition 16 | -------------------------------------------------------------------------------- /Cpu/NXP/KL25ZXX/README.md: -------------------------------------------------------------------------------- 1 | ## CPU related files of KL25ZXX 2 | -------------------------------------------------------------------------------- /Cpu/NXP/iMXRT/README.md: -------------------------------------------------------------------------------- 1 | # i.MX RT serial MCU 2 | - MIMXRT1052 3 | - MIMXRT1021 4 | -------------------------------------------------------------------------------- /Cpu/README.md: -------------------------------------------------------------------------------- 1 | ## CPU related code 2 | This folder contains CPU related code for following MCUs: 3 | Following MCUs are supported: 4 | 5 | Manufacturer | Series | Model 6 | ----------------- | --------- | ---------- 7 | NXP     |   KLxx   | KL16Zxx / KL25Zxx 8 | NXP | i.MX RT | i.MX RT1020/1050/1060 9 | ST | STM32Fxx |STM32F101xxx / STM32F103xxx 10 | 11 | 12 | -------------------------------------------------------------------------------- /Cpu/ST/STM32F10X/README.md: -------------------------------------------------------------------------------- 1 | ## Cpu related file of STM32F10X 2 | 3 | ### RCC- Reset and clock control module 4 | RCC files realise the basic function of clcok configuration and provides HCLK, SYSCLK, PCLK1, PCKL2 clock information. 5 | -------------------------------------------------------------------------------- /Debug/ARM/CmBacktrace_Local/README.md: -------------------------------------------------------------------------------- 1 | # Local code of CmBacktrace 2 | -------------------------------------------------------------------------------- /Debug/ARM/README.md: -------------------------------------------------------------------------------- 1 | # Debug tool & module for ARM 2 | -------------------------------------------------------------------------------- /Debug/General/README.md: -------------------------------------------------------------------------------- 1 | # General debug tools & modules 2 | -------------------------------------------------------------------------------- /Documents/API_Description.md: -------------------------------------------------------------------------------- 1 | # API Description of MOE 2 | 3 | ## Introduction 4 | **MOE** is an event-driven scheduler system for 8/16/32-bit MCUs. . Following features are realised: 5 | - Basic scheduler; 6 | - Multi-task; 7 | - Event driven. 8 | - Software Timer. 9 | - Messages. 10 | - Queue operation for general use. 11 | - And so on.... 12 | 13 | This document contains all description of MOE API, and help user for task coding. 14 | 15 | ## API Description 16 | APIs are classified by different modules: 17 | 18 | Module | Description 19 | -------------------- | ----------------------------- 20 | MOE Core | Scheduler & Event process 21 | MOE message | Messge mechanism 22 | MOE Timer | Software timer 23 | MOE Queue | General queue operation 24 | ... | ... 25 | 26 | ------------ 27 | 28 | ### MOE Core 29 | This is the core module of MOE, this module includes event-driven and scheduler。 30 | #### void Moe_Init(void) 31 | 32 | Name | void Moe_Init(void) 33 | --------------- | ------------------------------------------------ 34 | File | [MOE/Core/MOE_Core.c ](https://github.com/ianhom/MOE/blob/master/Core/MOE_Core.c) 35 | Function | Systeom init funciton which init hardware, system module and task init operation. 36 | Input | None 37 | Output | None 38 | Return | None 39 | Note | **Call this function once only before calling Moe_Run_System()** 40 | 41 | 42 | #### void Moe_Run_System(void) 43 | 44 | Name | void Moe_Run_System(void) 45 | --------------- | ------------------------------------------------ 46 | File | [MOE/Core/MOE_Core.c ](https://github.com/ianhom/MOE/blob/master/Core/MOE_Core.c) 47 | Function | System start function which will never return. 48 | Input | None 49 | Output | None 50 | Return | None 51 | Note | **Call Moe_Init() once before calling this function** 52 | 53 | 54 | #### uint8 Moe_Event_Set(uint8 u8TaskID, uint16 u16Evt) 55 | 56 | Name | uint8 Moe_Event_Set(uint8 u8TaskID, uint16 u16Evt) 57 | --------------- | ------------------------------------------------ 58 | File | [MOE/Core/MOE_Event.c ](https://github.com/ianhom/MOE/blob/master/Core/MOE_Event.c) 59 | Function | Event-Set function 60 | Input | uint8 u8TaskID: ID of the task which accept this event 61 | | uint16 u16Evt : Type of the event 62 | Output | None 63 | Return | SW_OK:Successful / SW_ERR:Failed 64 | Note | None 65 | 66 | 67 | #### uint8 Moe_Event_Set(uint8 u8TaskID, uint16 u16Evt) 68 | 69 | Name | uint8 Moe_Memset(uint8* pDes, uint8 u8Val, uint8 u8Len) 70 | --------------- | ------------------------------------------------ 71 | File | [MOE/Core/MOE_Core.c ](https://github.com/ianhom/MOE/blob/master/Core/MOE_Core.c) 72 | Function | Set desired value into desired position of memory with desired length 73 | Input | uint8* pDes : The start position of the memory to be writen 74 | | uint8 u8Val : The desired value 75 | | uint8 u8Len : The desired length 76 | Output | None 77 | Return | SW_OK:Successful / SW_ERR:Failed 78 | Note | This function is used to clear memory like event queue. 79 | 80 | 81 | #### uint8 Moe_Get_Active_Task(void) 82 | 83 | Name | uint8 Moe_Get_Active_Task(void) 84 | --------------- | ------------------------------------------------ 85 | File | [MOE/Core/MOE_Core.c ](https://github.com/ianhom/MOE/blob/master/Core/MOE_Core.c) 86 | Function | Get the current active task number。 87 | Input | None 88 | Output | None 89 | Return | TASK_NO_TASK(0): No task is active 90 | | 1~254: The active task number 91 | Note | None 92 | 93 | #### void* Moe_Malloc(uint32 u32Size) 94 | To be done... 95 | #### void Moe_Free(void *p) 96 | To be done... 97 | 98 | ------------ 99 | 100 | ### MOE Timer 101 | To be done... 102 | 103 | ------------ 104 | 105 | ### MOE Message 106 | To be done... 107 | 108 | ------------ 109 | 110 | ### MOE Queue 111 | To be done... 112 | 113 | ------------- 114 | 115 | ### MOE Link List 116 | To be done... 117 | -------------------------------------------------------------------------------- /Documents/Pic/Board/FRDM KL02Z_Mini-Shield.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ianhom/MOE/fee09423f8fc0a33a19ea9506f1d501a4e6fa421/Documents/Pic/Board/FRDM KL02Z_Mini-Shield.jpg -------------------------------------------------------------------------------- /Documents/Pic/Board/HappyGecko Starter-kit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ianhom/MOE/fee09423f8fc0a33a19ea9506f1d501a4e6fa421/Documents/Pic/Board/HappyGecko Starter-kit.png -------------------------------------------------------------------------------- /Documents/Pic/Board/MIMXRT1050-EVK-DEVICE.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ianhom/MOE/fee09423f8fc0a33a19ea9506f1d501a4e6fa421/Documents/Pic/Board/MIMXRT1050-EVK-DEVICE.jpg -------------------------------------------------------------------------------- /Documents/Pic/Board/MIMXRT1050-EVK-DEVICE2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ianhom/MOE/fee09423f8fc0a33a19ea9506f1d501a4e6fa421/Documents/Pic/Board/MIMXRT1050-EVK-DEVICE2.jpg -------------------------------------------------------------------------------- /Documents/Pic/Board/Navota-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ianhom/MOE/fee09423f8fc0a33a19ea9506f1d501a4e6fa421/Documents/Pic/Board/Navota-1.png -------------------------------------------------------------------------------- /Documents/Pic/Board/README.md: -------------------------------------------------------------------------------- 1 | ## Board pictures 2 | -------------------------------------------------------------------------------- /Documents/Pic/Board/STM32F407VE.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ianhom/MOE/fee09423f8fc0a33a19ea9506f1d501a4e6fa421/Documents/Pic/Board/STM32F407VE.png -------------------------------------------------------------------------------- /Documents/Pic/FRDM-KL25Z.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ianhom/MOE/fee09423f8fc0a33a19ea9506f1d501a4e6fa421/Documents/Pic/FRDM-KL25Z.png -------------------------------------------------------------------------------- /Documents/Pic/KL27-MINIBOARD.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ianhom/MOE/fee09423f8fc0a33a19ea9506f1d501a4e6fa421/Documents/Pic/KL27-MINIBOARD.png -------------------------------------------------------------------------------- /Documents/Pic/Logo/README.MD: -------------------------------------------------------------------------------- 1 | # Pictures of Logo 2 | -------------------------------------------------------------------------------- /Documents/Pic/MOE logo V0.01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ianhom/MOE/fee09423f8fc0a33a19ea9506f1d501a4e6fa421/Documents/Pic/MOE logo V0.01.png -------------------------------------------------------------------------------- /Documents/Pic/MOE logo V0.02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ianhom/MOE/fee09423f8fc0a33a19ea9506f1d501a4e6fa421/Documents/Pic/MOE logo V0.02.png -------------------------------------------------------------------------------- /Documents/Pic/MOE logo V0.03 .png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ianhom/MOE/fee09423f8fc0a33a19ea9506f1d501a4e6fa421/Documents/Pic/MOE logo V0.03 .png -------------------------------------------------------------------------------- /Documents/Pic/MOE logo V0.1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ianhom/MOE/fee09423f8fc0a33a19ea9506f1d501a4e6fa421/Documents/Pic/MOE logo V0.1.png -------------------------------------------------------------------------------- /Documents/Pic/MOE logo V0.1a.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ianhom/MOE/fee09423f8fc0a33a19ea9506f1d501a4e6fa421/Documents/Pic/MOE logo V0.1a.png -------------------------------------------------------------------------------- /Documents/Pic/MOE logo V0.1b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ianhom/MOE/fee09423f8fc0a33a19ea9506f1d501a4e6fa421/Documents/Pic/MOE logo V0.1b.png -------------------------------------------------------------------------------- /Documents/Pic/MOE logo V0.1c.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ianhom/MOE/fee09423f8fc0a33a19ea9506f1d501a4e6fa421/Documents/Pic/MOE logo V0.1c.png -------------------------------------------------------------------------------- /Documents/Pic/MOE logo.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ianhom/MOE/fee09423f8fc0a33a19ea9506f1d501a4e6fa421/Documents/Pic/MOE logo.pdf -------------------------------------------------------------------------------- /Documents/Pic/MOE_logo_V0_1d.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ianhom/MOE/fee09423f8fc0a33a19ea9506f1d501a4e6fa421/Documents/Pic/MOE_logo_V0_1d.jpg -------------------------------------------------------------------------------- /Documents/Pic/MOE_logo_V0_1e.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ianhom/MOE/fee09423f8fc0a33a19ea9506f1d501a4e6fa421/Documents/Pic/MOE_logo_V0_1e.png -------------------------------------------------------------------------------- /Documents/Pic/Nucleo-64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ianhom/MOE/fee09423f8fc0a33a19ea9506f1d501a4e6fa421/Documents/Pic/Nucleo-64.png -------------------------------------------------------------------------------- /Documents/Pic/Nucleo-L011K4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ianhom/MOE/fee09423f8fc0a33a19ea9506f1d501a4e6fa421/Documents/Pic/Nucleo-L011K4.jpg -------------------------------------------------------------------------------- /Documents/Pic/Nucleo3_PinOut.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ianhom/MOE/fee09423f8fc0a33a19ea9506f1d501a4e6fa421/Documents/Pic/Nucleo3_PinOut.png -------------------------------------------------------------------------------- /Documents/Pic/README.md: -------------------------------------------------------------------------------- 1 | ## Picture 2 | All pictures are located here 3 | -------------------------------------------------------------------------------- /Documents/Pic/mini-shield.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ianhom/MOE/fee09423f8fc0a33a19ea9506f1d501a4e6fa421/Documents/Pic/mini-shield.png -------------------------------------------------------------------------------- /Documents/Pic/other/CPU_with_MOE.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ianhom/MOE/fee09423f8fc0a33a19ea9506f1d501a4e6fa421/Documents/Pic/other/CPU_with_MOE.jpg -------------------------------------------------------------------------------- /Documents/Pic/other/MOE with MI _1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ianhom/MOE/fee09423f8fc0a33a19ea9506f1d501a4e6fa421/Documents/Pic/other/MOE with MI _1.jpg -------------------------------------------------------------------------------- /Documents/Pic/other/MOE with MI_2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ianhom/MOE/fee09423f8fc0a33a19ea9506f1d501a4e6fa421/Documents/Pic/other/MOE with MI_2.jpg -------------------------------------------------------------------------------- /Documents/Pic/other/MOE_with_MI_3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ianhom/MOE/fee09423f8fc0a33a19ea9506f1d501a4e6fa421/Documents/Pic/other/MOE_with_MI_3.jpg -------------------------------------------------------------------------------- /Documents/Pic/other/MOE_with_MI_4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ianhom/MOE/fee09423f8fc0a33a19ea9506f1d501a4e6fa421/Documents/Pic/other/MOE_with_MI_4.jpg -------------------------------------------------------------------------------- /Documents/Pic/other/README.md: -------------------------------------------------------------------------------- 1 | # others 2 | -------------------------------------------------------------------------------- /Documents/README.md: -------------------------------------------------------------------------------- 1 | # Documents 2 | This folder provide useful documents like : 3 | - API description; 4 | - User Guide; 5 | - Design records; 6 | - Pictures. 7 | -------------------------------------------------------------------------------- /Driver/Dev/README.md: -------------------------------------------------------------------------------- 1 | ## Drivers for different devices 2 | This folder contains kinds of drivers for different devices 3 | Following devices are supported: 4 | 5 | Modle | Introduction 6 | -------------- | ------------------- 7 | cc1100/cc1101| Sub-1GHz transceiver 8 | 11xx | Sub-1GHz transceiver 9 | 10 | 11 | -------------------------------------------------------------------------------- /Driver/MCU/Common/ARM_Cortex_M/MOE_SysTick.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * File : MOE_SysTick.c 3 | * Function : Set SysTick for 1 ms 4 | * Description: To be done. 5 | * Version : V1.00 6 | * Author : Ian 7 | * Date : 15th Feb 2017 8 | * History : No. When Who What 9 | * 1 15/Feb/2017 Ian Create 10 | ******************************************************************************/ 11 | #include "type_def.h" 12 | #include "../../Pub/common_head.h" 13 | #include "./project_config.h" 14 | #include "./MOE_sysTick.h" 15 | #include "../../Pub/debug.h" 16 | 17 | /* Init system ms counter */ 18 | volatile static uint32 sg_u32SysClk = 0; 19 | 20 | /****************************************************************************** 21 | * Name : void SysTick_Ms_Int_Init(uint32_t u32Tick) 22 | * Function : Init SysTick Register 23 | * Input : uint32_t u32Tick 1~0xFFFFFFFF The tick count for 1 ms 24 | * Output: : None. 25 | * Return : None. 26 | * Description: Configura clock source, Enable interrupt and Enable Systick function. 27 | * Version : V1.00 28 | * Author : Ian 29 | * Date : 16th Feb 2017 30 | ******************************************************************************/ 31 | void SysTick_Ms_Int_Init(uint32_t u32Tick) 32 | { 33 | MOE_SysTick->CTRL |= MOE_SysTick_CTRL_CLKSOURCE_MSK; /* Set clock source = core clock */ 34 | MOE_SysTick->CTRL |= MOE_SysTick_CTRL_TICKINT_MSK; /* Enable systick interrupt */ 35 | MOE_SysTick->LOAD = u32Tick; /* Set tick count for 1ms */ 36 | MOE_SysTick->VAL = 0; 37 | MOE_SysTick->CTRL |= MOE_SysTick_CTRL_ENABLE_MSK; /* Enable SysTick */ 38 | return; 39 | } 40 | 41 | /****************************************************************************** 42 | * Name : uint32 SysTick_GetSysClk(void) 43 | * Function : Return the current system ms counter(system clock) 44 | * Input : uint32_t u32Tick 1~0xFFFFFFFF The tick count for 1 ms 45 | * Output: : None. 46 | * Return : 1~0xFFFFFFFF The current system ms counter. 47 | * Description: None. 48 | * Version : V1.00 49 | * Author : Ian 50 | * Date : 16th Feb 2017 51 | ******************************************************************************/ 52 | uint32 SysTick_GetSysClk(void) 53 | { 54 | return sg_u32SysClk; /* System ms counter */ 55 | } 56 | 57 | /****************************************************************************** 58 | * Name : void SysTick_Handler(void) 59 | * Function : SysTick interrupt handler 60 | * Input : None. 61 | * Output: : None. 62 | * Return : None. 63 | * Description: To be done. 64 | * Version : V1.00 65 | * Author : Ian 66 | * Date : 16th Feb 2017 67 | ******************************************************************************/ 68 | void SysTick_Handler(void) 69 | { 70 | volatile uint32 u32Temp; 71 | u32Temp = MOE_SysTick->CTRL; 72 | sg_u32SysClk++; /* Update the system ms counter */ 73 | return; 74 | } 75 | 76 | /* End of file */ 77 | -------------------------------------------------------------------------------- /Driver/MCU/NXP-Freescale-_KLxx/MOE_HAL_SPI.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * File : MOE_HAL_SPI.c 3 | * Function : Hardware Abstract Layer for SPI of NXP KLXX MCU. 4 | * description: To be done. 5 | * Version : V1.00 6 | * Author : Ian 7 | * Date : 13th Jul 2016 8 | * History : No. When Who What 9 | * 1 13/Jul/2016 Ian Create 10 | ******************************************************************************/ 11 | 12 | #include "type_def.h" 13 | #include "../../../Pub/common_head.h" 14 | #include "project_config.h" 15 | #include "../../../Core/MOE_Core.h" 16 | #include "../../../Core/MOE_Msg.h" 17 | #include "../../../Core/MOE_HAL.h" 18 | #include "./MOE_HAL_SPI.h" 19 | #include "../../../Pub/debug.h" 20 | 21 | /****************************************************************************** 22 | * Name : uint8 uint8 Moe_HAL_SPI_Init(void) 23 | * Function : Init hardware abstract layer for SPI 24 | * Input : None. 25 | * Output: : None. 26 | * Return : SW_OK Successful. 27 | * SW_ERR Failed. 28 | * description: To be done. 29 | * Version : V1.00 30 | * Author : Ian 31 | * Date : 13th Jul 2016 32 | ******************************************************************************/ 33 | uint8 Moe_HAL_SPI_Init(void) 34 | { 35 | uint32 u32SpiC1 = 0; 36 | 37 | SIM_SCGC4 |= SIM_SCGC4_SPI1_MASK; /* Enoble SPI1 clock */ 38 | 39 | /* Configure C1 */ 40 | u32SpiC1 |= ( SPI_C1_SPE_MASK /* Enable SPI1 */ 41 | | SPI_C1_MSTR_MASK /* As Master */ 42 | | SPI_C1_SSOE_MASK); /* Slave select */ 43 | SPI1_C1 = u32SpiC1; 44 | 45 | SPI1_C2 |= SPI_C2_MODFEN_MASK; 46 | SPI1_BR |= SPI_BR_SPPR(0) | SPI_BR_SPR(6); 47 | 48 | return SW_OK; 49 | 50 | } 51 | 52 | /****************************************************************************** 53 | * Name : void Moe_HAL_SPI_Write(uint8 u8Data) 54 | * Function : SPI write operation 55 | * Input : uint8 u8Data 0~255 Data byte to be writen 56 | * Output: : None. 57 | * Return : None. 58 | * description: To be done. 59 | * Version : V1.00 60 | * Author : Ian 61 | * Date : 13th Jul 2016 62 | ******************************************************************************/ 63 | void Moe_HAL_SPI_Write(uint8 u8Data) 64 | { 65 | while((SPI1_S & SPI_S_SPTEF_MASK) != SPI_S_SPTEF_MASK); 66 | SPI1_D = u8Data; 67 | return; 68 | } 69 | 70 | 71 | /****************************************************************************** 72 | * Name : uint8 Moe_HAL_SPI_Read(void) 73 | * Function : SPI read operation 74 | * Input : None. 75 | * Output: : None. 76 | * Return : uint8 77 | * description: To be done. 78 | * Version : V1.00 79 | * Author : Ian 80 | * Date : 13th Jul 2016 81 | ******************************************************************************/ 82 | uint8 Moe_HAL_SPI_Read(void) 83 | { 84 | uint8 u8Temp; 85 | 86 | while((SPI1_S & SPI_S_SPRF_MASK) != SPI_S_SPRF_MASK); 87 | u8Temp = SPI1_D; 88 | return u8Temp; 89 | } 90 | 91 | /****************************************************************************** 92 | * Name : void Moe_HAL_SPI_Write(uint8 ucData) 93 | * Function : SPI write operation 94 | * Input : uint8 u8Val MOE_SPI_CS_LOW Set Cs as low level 95 | * MOE_SPI_CS_HIGH Set Cs as high level 96 | * Output: : None. 97 | * Return : None. 98 | * description: To be done. 99 | * Version : V1.00 100 | * Author : Ian 101 | * Date : 13th Jul 2016 102 | ******************************************************************************/ 103 | void Moe_HAL_SPI_Cs_Ctrl(uint8 u8Val) 104 | { 105 | if(MOE_SPI_CS_LOW == u8Val) 106 | { 107 | GPIOE_PCOR |= (1 << 4); /* Set Cs as low level */ 108 | } 109 | else 110 | { 111 | GPIOE_PSOR |= (1 << 4); /* Set Cs as high level */ 112 | } 113 | return; 114 | } 115 | 116 | 117 | /* end of file */ 118 | 119 | -------------------------------------------------------------------------------- /Driver/MCU/NXP-Freescale-_KLxx/MOE_HAL_SPI.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * File : MOE_HAL_SPI.h 3 | * Function : Hardware Abstract Layer for SPI of NXP KLXX MCU. 4 | * description: To be done. 5 | * Version : V1.00 6 | * Author : Ian 7 | * Date : 13th Jul 2016 8 | * History : No. When Who What 9 | * 1 13/Jul/2016 Ian Create 10 | ******************************************************************************/ 11 | 12 | #ifndef _MOE_HAL_SPI_H_ 13 | #define _MOE_HAL_SPI_H_ 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | /* Check if specified option is set for debugging */ 20 | #ifndef __DEBUG_MODE_MOE_HAL_SPI 21 | #define __DEBUG_MODE __DEBUG_NONE /* Default: None debugging info */ 22 | #else 23 | #ifdef __DEBUG_MODE 24 | #undef __DEBUG_MODE 25 | #endif 26 | #define __DEBUG_MODE __DEBUG_MODE_MOE_HAL_SPI /* According the set from project_config.h */ 27 | #endif 28 | 29 | #define MOE_SPI_CS_HIGH (1) /* High level for SPI Cs pin */ 30 | #define MOE_SPI_CS_LOW (0) /* Low level for SPI Cs pin */ 31 | 32 | /****************************************************************************** 33 | * Name : uint8 uint8 Moe_HAL_SPI_Init(void) 34 | * Function : Init hardware abstract layer for SPI 35 | * Input : None. 36 | * Output: : None. 37 | * Return : SW_OK Successful. 38 | * SW_ERR Failed. 39 | * description: To be done. 40 | * Version : V1.00 41 | * Author : Ian 42 | * Date : 13th Jul 2016 43 | ******************************************************************************/ 44 | uint8 Moe_HAL_SPI_Init(void); 45 | 46 | /****************************************************************************** 47 | * Name : void Moe_HAL_SPI_Write(uint8 u8Data) 48 | * Function : SPI write operation 49 | * Input : uint8 u8Data 0~255 Data byte to be writen 50 | * Output: : None. 51 | * Return : None. 52 | * description: To be done. 53 | * Version : V1.00 54 | * Author : Ian 55 | * Date : 13th Jul 2016 56 | ******************************************************************************/ 57 | void Moe_HAL_SPI_Write(uint8 u8Data); 58 | 59 | 60 | /****************************************************************************** 61 | * Name : uint8 Moe_HAL_SPI_Read(void) 62 | * Function : SPI read operation 63 | * Input : None. 64 | * Output: : None. 65 | * Return : uint8 66 | * description: To be done. 67 | * Version : V1.00 68 | * Author : Ian 69 | * Date : 13th Jul 2016 70 | ******************************************************************************/ 71 | uint8 Moe_HAL_SPI_Read(void); 72 | 73 | /****************************************************************************** 74 | * Name : void Moe_HAL_SPI_Write(uint8 ucData) 75 | * Function : SPI write operation 76 | * Input : uint8 u8Val MOE_SPI_CS_LOW Set Cs as low level 77 | * MOE_SPI_CS_HIGH Set Cs as high level 78 | * Output: : None. 79 | * Return : None. 80 | * description: To be done. 81 | * Version : V1.00 82 | * Author : Ian 83 | * Date : 13th Jul 2016 84 | ******************************************************************************/ 85 | void Moe_HAL_SPI_Cs_Ctrl(uint8 u8Val); 86 | 87 | 88 | 89 | #ifdef __cplusplus 90 | } 91 | #endif 92 | 93 | #endif /* _MOE_HAL_SPI_H_ */ 94 | 95 | /* End of file */ 96 | 97 | -------------------------------------------------------------------------------- /Driver/MCU/NXP-Freescale-_KLxx/README.md: -------------------------------------------------------------------------------- 1 | ## Driver for KLXX 2 | Following MCU is supported: 3 | - KL25ZXXX 4 | - KL16ZXXX 5 | - KL02ZXXX 6 | 7 | Following drivers is realized: 8 | - UART 9 | - SPI 10 | -------------------------------------------------------------------------------- /Driver/MCU/README.md: -------------------------------------------------------------------------------- 1 | ## Peripheral drivers for different MCUs 2 | This folder contains kinds of perihpheral drivers for different MCUs 3 | Following MCUs are supported: 4 | 5 | Manufacturer | Series | Model 6 | -------------- | --------- | ---------- 7 | NXP | KLxx | KL16Zxx / KL25Zxx 8 | ST | STM32Fxx | STM32F101xxx / STM32F103xxx 9 | 10 | 11 | -------------------------------------------------------------------------------- /Driver/MCU/STM32F/MOE_HAL_UART.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * File : MOE_HAL_UART.h 3 | * Function : Hardware Abstract Layer for UART of STM32F10X. 4 | * description: To be done. 5 | * Version : V1.00 6 | * Author : Ian 7 | * Date : 26th Jul 2016 8 | * History : No. When Who What 9 | * 1 26/Jul/2016 Ian Create 10 | ******************************************************************************/ 11 | 12 | #ifndef _MOE_HAL_UART_H_ 13 | #define _MOE_HAL_UART_H_ 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | /* Check if specified option is set for debugging */ 20 | #ifndef __DEBUG_MODE_MOE_HAL_UART 21 | #define __DEBUG_MODE __DEBUG_NONE /* Default: None debugging info */ 22 | #else 23 | #ifdef __DEBUG_MODE 24 | #undef __DEBUG_MODE 25 | #endif 26 | #define __DEBUG_MODE __DEBUG_MODE_MOE_HAL_UART /* According the set from project_config.h */ 27 | #endif 28 | 29 | #define MOE_HAL_UART_SND_BUF_FREE (1) /* Uart sending buffer is free */ 30 | #define MOE_HAL_UART_SND_BUF_NOT_FREE (0) /* Uart sending buffer is NOT free */ 31 | 32 | #define MOE_HAL_UART_NO_RCV_DATA (0) /* Uart get NONE received data */ 33 | #define MOE_HAL_UART_RCV_DATA (1) /* Uart get a received data */ 34 | 35 | /****************************************************************************** 36 | * Name : uint8 Moe_HAL_Init_UART(void) 37 | * Function : Init hardware abstract layer for UART 38 | * Input : None. 39 | * Output: : None. 40 | * Return : SW_OK Successful. 41 | * SW_ERR Failed. 42 | * description: To be done. 43 | * Version : V1.00 44 | * Author : Ian 45 | * Date : 26th Jul 2016 46 | ******************************************************************************/ 47 | uint8 Moe_HAL_UART_Init(void); 48 | 49 | /****************************************************************************** 50 | * Name : uint8 Moe_HAL_Uart_Ctrl(void) 51 | * Function : None. 52 | * Input : None. 53 | * Output: : None. 54 | * Return : uint8 Received data. 55 | * description: To be done. 56 | * Version : V1.00 57 | * Author : Ian 58 | * Date : 26th Jul 2016 59 | ******************************************************************************/ 60 | uint8 Moe_HAL_Uart_Ctrl(void); 61 | 62 | /****************************************************************************** 63 | * Name : uint8 Moe_HAL_Uart_Byte_Receive(void) 64 | * Function : Get a single byte data from uart receiving buffer 65 | * Input : None. 66 | * Output: : None. 67 | * Return : uint8 Received data. 68 | * description: To be done. 69 | * Version : V1.00 70 | * Author : Ian 71 | * Date : 26th Jul 2016 72 | ******************************************************************************/ 73 | uint8 Moe_HAL_Uart_Byte_Receive(void); 74 | 75 | /****************************************************************************** 76 | * Name : void Moe_HAL_Uart_Byte_Send(uint8 u8Data) 77 | * Function : Send a single byte data to uart sending buffer. 78 | * Input : None. 79 | * Output: : None. 80 | * Return : None. 81 | * description: To be done. 82 | * Version : V1.00 83 | * Author : Ian 84 | * Date : 26th Jul 2016 85 | ******************************************************************************/ 86 | void Moe_HAL_Uart_Byte_Send(uint8 u8Data); 87 | 88 | /****************************************************************************** 89 | * Name : uint8 Moe_HAL_Uart_Free_Send_Buf(void) 90 | * Function : Check sending buffer is free or NOT 91 | * Input : None. 92 | * Output: : None. 93 | * Return : MOE_HAL_UART_SND_BUF_NOT_FREE Sending buffer is NOT free 94 | * MOE_HAL_UART_SND_BUF_FREE Sending buffer is free 95 | * description: To be done. 96 | * Version : V1.00 97 | * Author : Ian 98 | * Date : 26th Jul 2016 99 | ******************************************************************************/ 100 | uint8 Moe_HAL_Uart_Free_Send_Buf(void); 101 | 102 | /****************************************************************************** 103 | * Name : uint8 Moe_HAL_Uart_Got_Data(void) 104 | * Function : Check sending buffer is free or NOT 105 | * Input : None. 106 | * Output: : None. 107 | * Return : MOE_HAL_UART_RCV_DATA Get a data in receiving buffer 108 | * MOE_HAL_UART_NO_RCV_DATA Get NONE data in receiving buffer 109 | * description: To be done. 110 | * Version : V1.00 111 | * Author : Ian 112 | * Date : 26th Jul 2016 113 | ******************************************************************************/ 114 | uint8 Moe_HAL_Uart_Got_Data(void); 115 | 116 | 117 | #ifdef __cplusplus 118 | } 119 | #endif 120 | 121 | #endif /* _MOE_HAL_UART_H_ */ 122 | 123 | /* End of file */ 124 | 125 | -------------------------------------------------------------------------------- /Driver/MCU/STM32F/README.md: -------------------------------------------------------------------------------- 1 | ## Driver for STM32F 2 | Following MCU is supported: 3 | - STM32F101XXX 4 | - STM32F103XXX 5 | 6 | Following drivers is realized: 7 | - UART1-5 8 | -------------------------------------------------------------------------------- /Driver/MCU/i.MXRT/README.md: -------------------------------------------------------------------------------- 1 | # i.MX RT 2 | - i.MX RT 1060 3 | - i.MX RT 1050 4 | - i.MX RT 1020 5 | - i.MX RT 1015 6 | -------------------------------------------------------------------------------- /Driver/README.md: -------------------------------------------------------------------------------- 1 | # Driver 2 | 3 | **NOT FINISH YET!!** 4 | -------------------------------------------------------------------------------- /ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | # Title 2 | [Link](https://github.com/ianhom/MOE) 3 | ![image](https://github.com/ianhom/MOE/blob/master/Documents/Pic/MOE_logo_V0_1e.png?raw=true) 4 | 5 | -------------------------------------------------------------------------------- /LICENCE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Ian Hom(Ye Hong) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Log.md: -------------------------------------------------------------------------------- 1 | # Log 2 | ## 30th Nov 2018 3 | - 记住不舍,向往未来,我会记住你们,我们一定会再相聚。再见了,我延期的20岁,请你做好准备,我的30岁。 4 | 5 | ## 17th Nov 2018 6 | - MOE is ready for a new satrt 7 | 8 | ## 10th Sep 2018 9 | - I am going to rebuild MOE with more fun function 10 | 11 | ## 1st April 2017 12 | ![MOE cpu](https://github.com/ianhom/MOE/blob/master/Documents/Pic/other/CPU_with_MOE.jpg?raw=true) 13 | - The first smart CPU with MOE in the world!.....Only today 14 | 15 | ## 19th Feb 2017 16 | Modify Macro of SysTick registers 17 | 18 | ## 16th Feb 2017 19 | Add SysTick driver 20 | 21 | ## 27th Jan 2017 22 | MOE: HAPPY CHINESE NEW YEAR 23 | 24 | ## 24th Jan 2017 25 | Improve driver structure 26 | 27 | ## 12th Dec 2016 28 | Start modifiy include path 29 | 30 | ## 4th Dec 2016 31 | Update design record. 32 | 33 | ## 3rd Dec 2016 34 | MOE's younger brother is born:smile: 35 | 36 | ## 2nd Dec 2016 37 | Add project code of NAVOTA 38 | 39 | ## 26th Nov 2016 40 | Update design record about portable. 41 | Create "Utility" folder 42 | 43 | ## 24th Nov 2016 44 | Fix the bug in PT.h, extend the range of running point which stores the line number of last running. 45 | 46 | ## 22nd Nov 2016 47 | Fix the bug of debug.h 48 | 49 | ## 21st Nov 2016 50 | Update project code of Nucleo-STM32L011K4 51 | 52 | ## 19th Nov 2016 53 | Update API-description 54 | 55 | ## 18th Nov 2016 56 | Port MOE on Nucleo-STM32L011K4 57 | 58 | ## 17th Nov 2016 59 | Port MOE on KL27-MiniBoard 60 | 61 | ## 12th Nov 2016 62 | Add more descriptions to introduction. 63 | 64 | ## 7th Nov 2016 65 | Add API description. 66 | 67 | ## 5th Nov 2016 68 | Fix some bug with new event structure 69 | 70 | ## 4th Sep 2016 71 | Modify timer with new event structure 72 | 73 | ## 31st Aug 2016 74 | First contribution from Joe, thank you!! 75 | 76 | ## 30th Aug 2016 77 | Complete the modification of message 78 | 79 | ## 28th Aug 2016 80 | Try a new way for a better message 81 | 82 | ## 24th Aug 2016 83 | Merge the new way for a better timer. 84 | 85 | ## 23rd Aug 2016 86 | Try a new way to improve timer. 87 | 88 | ## 22nd Aug 2016 89 | Add "Check if" into queue. 90 | 91 | ## 21st Aug 2016 92 | Add "assert" and "check if" into core, message, event, timer. 93 | 94 | ## 17th Aug 2016 95 | Add assert MACRO 96 | 97 | ## 16th Aug 2016 98 | Modify the event queue block deleting method, delete the added block. 99 | 100 | ## 10th Aug 2016 101 | 100-days!! 102 | 103 | ## 8th Aug 2016 104 | Fix the bug for flexible length event queue. 105 | 106 | ## 5th Aug 2016 107 | Add task name printing function. 108 | 109 | ## 1st Aug 2016 110 | Modify uart driver of KL25, use Rx interrupt to receive entire telegram. 111 | 112 | ## 25th Jul 2016 113 | Debug 11xx and finish sending. 114 | 115 | ## 21st Jul 2016 116 | Add driver of 11xx 117 | 118 | ## 20th Jul 2016 119 | Add uart driver of KL25 120 | 121 | ## 15th Jul 2016 122 | Add a demo app to use cc1101 driver for sending and receiving 123 | 124 | ## 14th Jul 2016 125 | Add CC1101 driver 126 | 127 | ## 8th Jul 2016 128 | Add PT application 129 | 130 | ## 3rd Jul 2016 131 | Use x macro to simplize the interface bewteen core and tasks. 132 | And create board configuration files for hardware configuration. 133 | 134 | ## 1st Jul 2016 135 | Modify all app modules 136 | 137 | ## 29th Jun 2016 138 | Make user interface more easier to configure. 139 | 140 | ## 27th Jun 2016 141 | Add message never receiving check. 142 | 143 | ## 22rd Jun 2016 144 | Re-design the events and scheduler, name it MOE :sunglasses: 145 | 146 | ## 12th Jun 2016 147 | Improve & complete queue process 148 | 149 | ## 6th Jun 2016 150 | Solve the #5 issue. 151 | 152 | ## 5th Jun 2016 153 | Finish message works, ready to debug. 154 | 155 | ## 26th May 2016 156 | Start message works. 157 | 158 | ## 25th May 2016 159 | Make some flexible malloc options. 160 | 161 | ## 24th May 2016 162 | Make some flexible debug options. 163 | 164 | ## 23rd May 2016 165 | Timer debugging complete. 166 | - [x] Debug timer code 167 | 168 | ## 20th May 2016 169 | Start debug the timer. 170 | 171 | ## 9th May 2016 172 | Still work with software timers, add some test functions, **un-debugged**. 173 | 174 | ## 7th May 2016 175 | Timer is added, however **the code is NOT debug yet**. Please wait for the updating. 176 | 177 | ## 4th May 2016 178 | I have finished the basical parts of schudeler function, I use 3 tasks and set event to each others, it works. Also I add debug print MACROs with maybe useful. I will add software timer in next step. 179 | 180 | -------- 181 | 182 | 写给萌萌的话: 183 | - 萌萌,这个是爸爸以你的名义写的代码,或许你直到长大也不能理解这段代码的用途,但是爸爸想用一个在这个时代我擅长的方式为你留下些什么。在编写的过程中,爸爸一直很用心,因为有你的名字,爸爸希望它能有更好的表现,让更多的人使用。或许有朝一日这个系统小有名气了,萌萌可以自豪地说“这是我爸爸为我写的!”。这是爸爸的初衷,如果真有那天,再来感谢老爸吧。 184 | - 不过此时此刻我要先感谢萌萌。萌萌的诞生给了爸爸很多正能量,其中最大的就是爆棚的责任感,这激励着爸爸在工作上奋力进取。随之MOE系统的成长,爸爸的编程能力也是不断提升,有种萌萌在帮助爸爸的感觉,所以要感谢萌萌所做的一切(成为我女儿)。 185 | - 爸爸会继续努力,不断为萌萌完善MOE,并照顾好萌萌和弟弟成成! 186 | 187 | 爸爸 188 | 2017.01.24 189 | 190 | P.S: 如果萌萌长大了,入错行当了程序媛,爸爸就把MOE交给你维护了! 191 | 192 | -------------------------------------------------------------------------------- /Pub/README.md: -------------------------------------------------------------------------------- 1 | ## Pub 2 | Public definition and typedef 3 | 4 | File | Function 5 | ----- | ----- 6 | common_head.h | common definition 7 | debug.h | Debug printf options 8 | typedef.h | Typedef used in MOE 9 | -------------------------------------------------------------------------------- /Pub/common_head.h: -------------------------------------------------------------------------------- 1 | 2 | /****************************************************************************** 3 | * File : common_head.h 4 | * Function : common definitions. 5 | * Description: To be done. 6 | * Version : V1.00 7 | * Author : Ian 8 | * Date : 3rd May 2016 9 | * History : No. When Who What 10 | * 1 3/May/2016 Ian Create 11 | ******************************************************************************/ 12 | 13 | #ifndef _COMMON_HEAD_H_ 14 | #define _COMMON_HEAD_H_ 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | 21 | /* Definition of init and process function for tasks */ 22 | typedef void (*PF_TASK_INIT)(uint8 u8Task, void *pPara); 23 | typedef uint8 (*PF_TASK_PROCESS)(uint8 u8Evt, void *pPara); 24 | 25 | #define __DEBUG_NONE (0) /* No need to printf */ 26 | #define __DEBUG_BASIC_INFO (1) /* Provide basic printf function */ 27 | #define __DEBUG_FILE_LINE_INFO (2) /* Provide file and line information with printf */ 28 | #define __DEBUG_FUNC_LINE_INFO (3) /* Provide function and line info with printf */ 29 | #define __DEBUG_FILE_LINE_FUNC_INFO (4) /* Provode file, line and function info with printf */ 30 | 31 | #define __MALLOC_STD (0) /* Use standard malloc and free */ 32 | #define __MALLOC_MOE (1) /* Use MOE malloc and free */ 33 | #define __MALLOC_MY (2) /* Use your malloc and free */ 34 | 35 | #define SW_OK (0) /* Return: Successful */ 36 | #define SW_ERR (0xFF) /* Return: Failed */ 37 | 38 | 39 | #ifdef __cplusplus 40 | } 41 | #endif 42 | 43 | #endif /* _COMMON_HEAD_H_ */ 44 | 45 | /* End of file */ 46 | 47 | 48 | -------------------------------------------------------------------------------- /Pub/debug.h: -------------------------------------------------------------------------------- 1 | 2 | /****************************************************************************** 3 | * File : debug.h 4 | * Function : debug control. 5 | * Description: To be done. 6 | * Version : V1.00 7 | * Author : Ian 8 | * Date : 24th May 2016 9 | * History : No. When Who What 10 | * 1 24/May/2016 Ian Create 11 | ******************************************************************************/ 12 | 13 | #ifndef _DEBUG_H_ 14 | #define _DEBUG_H_ 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | /* Color printing */ 21 | #define CP_NONE "\033[0m" 22 | #define CP_RED "\033[1;31;40m" 23 | #define CP_GREEN "\033[1;32;40m" 24 | #define CP_YELLOW "\033[1;33;40m" 25 | #define CP_BLUE "\033[1;34;40m" 26 | #define CP_MAGENTE "\033[1;35;40m" 27 | #define CP_CYAN "\033[1;36;40m" 28 | #define CP_WHITE "\033[1;37;40m" 29 | 30 | #ifndef __DEBUG_NONE 31 | #define __DEBUG_NONE (0) /* No need to printf */ 32 | #define __DEBUG_BASIC_INFO (1) /* Provide basic printf function */ 33 | #define __DEBUG_FILE_LINE_INFO (2) /* Provide file and line information with printf */ 34 | #define __DEBUG_FUNC_LINE_INFO (3) /* Provide function and line info with printf */ 35 | #define __DEBUG_FILE_LINE_FUNC_INFO (4) /* Provode file, line and function info with printf */ 36 | #endif 37 | 38 | #ifndef __DEBUG_MODE 39 | #define __DEBUG_MODE __DEBUG_BASIC_INFO//__DEBUG_FUNC_LINE_INFO 40 | #endif 41 | 42 | #ifdef IAR 43 | #if (__DEBUG_MODE == __DEBUG_FILE_LINE_FUNC_INFO) 44 | #pragma message("*** Debug printf outputs file name, function name, line number and desired info!! ***") 45 | #define DBG_PRINT(x,...) printf("FILE: "__FILE__", FUNC : %s, LINE: %d -- \n "x" \n", __func__ , __LINE__, ##__VA_ARGS__) 46 | 47 | #elif (__DEBUG_MODE == __DEBUG_FUNC_LINE_INFO) 48 | #pragma message("*** Debug printf outputs function name, line number and desired info!! ***") 49 | #define DBG_PRINT(x,...) printf("FUNC : %s, LINE: %d -- \n "x" \n", __func__ , __LINE__, ##__VA_ARGS__) 50 | #endif 51 | #endif 52 | 53 | #if (__DEBUG_MODE == __DEBUG_FILE_LINE_INFO) 54 | #ifdef IAR 55 | #pragma message("*** Debug printf outputs file name, line number and desired info!! ***") 56 | #endif 57 | #define DBG_PRINT(x,...) printf("FILE: "__FILE__", LINE: %d -- \n "x" \n", __LINE__, ##__VA_ARGS__) 58 | 59 | #elif (__DEBUG_MODE == __DEBUG_BASIC_INFO) 60 | #ifdef IAR 61 | #pragma message("*** Debug printf outputs desired basic info!! ***") 62 | #endif 63 | #define DBG_PRINT(x,...) printf(x, ##__VA_ARGS__) 64 | 65 | #else 66 | #ifdef IAR 67 | #pragma message("*** Debug printf is DISABLED!! ***") 68 | #endif 69 | #define DBG_PRINT(x,...) 70 | #endif 71 | 72 | /* Assert Macros */ 73 | #ifdef __DEBUG_MODE 74 | /* Stop running after assert error, report location of error */ 75 | #define MOE_ASSERT(Cond) if(!(Cond)) {printf("\n\n**ASSERT ERROR**: \nFILE: "__FILE__", LINE: %d\n**STOP RUNNING!!\n\n", __LINE__);while(1);} 76 | /* Stop running after assert error, report error information */ 77 | #define MOE_ASSERT_INFO(Cond,info) if(!(Cond)) {printf("\n\n**ASSERT ERROR**: \n**"info"\n**STOP RUNNING!!\n\n");while(1);} 78 | #else 79 | /* After debugging, assert code can be removed */ 80 | #define MOE_ASSERT(Cond) 81 | #define MOE_ASSERT_INFO(Cond,info) 82 | #endif 83 | 84 | /* Return void after assert error, with error information */ 85 | #define MOE_CHECK_IF_RET_VOID(Cond, reason,...) if((Cond)) {DBG_PRINT(reason, ##__VA_ARGS__);return;} 86 | /* Return value after assert error, with error information */ 87 | #define MOE_CHECK_IF_RET_VAL(Cond, ret,reason,...) if((Cond)) {DBG_PRINT(reason, ##__VA_ARGS__);return ret;} 88 | /* Return SW_ERR after assert error, with error information */ 89 | #define MOE_CHECK_IF_RET_ST(Cond, reason,...) if((Cond)) {DBG_PRINT(reason, ##__VA_ARGS__);return SW_ERR;}//MOE_CHECK_IF_RET_VAL(Cond, SW_ERR,reason,...) 90 | 91 | 92 | #ifdef __cplusplus 93 | } 94 | #endif 95 | 96 | #endif /* _DEBUG_H_ */ 97 | 98 | /* End of file */ 99 | 100 | 101 | -------------------------------------------------------------------------------- /Pub/type_def.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * File : type_def.h 3 | * Function : Type definitions. 4 | * Description: To be done. 5 | * Version : V1.00 6 | * Author : Ian 7 | * Date : 3rd May 2016 8 | * History : No. When Who What 9 | * 1 3/May/2016 Ian Create 10 | ******************************************************************************/ 11 | 12 | #ifndef _TYPE_DEF_H_ 13 | #define _TYPE_DEF_H_ 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | 20 | /* Definition for tpyes */ 21 | typedef unsigned char uint8; /* Type definition for 8-bit unsigned char */ 22 | typedef unsigned short int uint16; /* Type definition for 16-bit unsigned short int */ 23 | typedef unsigned int uint32; /* Type definition for 32-bit unsigned int */ 24 | 25 | typedef signed char int8; /* Type definition for 8-bit signed char */ 26 | typedef signed short int int16; /* Type definition for 16-bit signed short int */ 27 | typedef signed int int32; /* Type definition for 32-bit signed int */ 28 | 29 | #define NULL (0) /* Value for NULL pointer */ 30 | 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | 35 | #endif /* _TYPE_DEF_H_ */ 36 | 37 | /* End of file */ 38 | 39 | -------------------------------------------------------------------------------- /README_CHINESE.md: -------------------------------------------------------------------------------- 1 | # MOE 2 | [![license](https://img.shields.io/github/license/ianhom/MOE.svg?style=plastic)](https://github.com/ianhom/MOE/blob/master/LICENCE.md) [![GitHub release](https://img.shields.io/github/release/ianhom/MOE.svg?style=plastic)](https://github.com/ianhom/MOE/releases/tag/V0.1.6) [![status](https://img.shields.io/badge/作者状态-有点饿,想吃包子-blue.svg?style=plastic)](https://github.com/ianhom/Note-of-all/blob/master/Pic/Misc/zhifu.jpg?raw=true) 3 | [English](https://github.com/ianhom/MOE/blob/master/README.md) 4 | 5 | ![Smartphone with MOE](https://github.com/ianhom/MOE/blob/master/Documents/Pic/other/MOE_with_MI_3.jpg?raw=true) 6 | 7 | 全球首台搭载MOE系统的智能手机!------------------开个玩笑!! 8 | 9 | ----- 10 | ![LOGO](https://github.com/ianhom/MOE/blob/master/Documents/Pic/MOE_logo_V0_1e.png?raw=true) 11 | 12 | ## 简介 13 | :tada:**热烈欢迎MOE的弟弟LEON诞生**:tada: 14 | MOE是一个用于8/16/32位MCU多任务事件驱动型的调度系统。MOE的含义为"Minds Of Embedded system",同时也是我宝贝女儿的小名:smile:   15 | MOE特点如下: 16 | 17 | 特点 | 描述 18 | ----------------- | --------------------------------------------- 19 | [**事件驱动**](https://github.com/ianhom/MOE/blob/master/Documents/Design_Record.md/#关于事件驱动) | 可变的事件队列长度,支持高优先级事件插队. 20 | [**软件定时器**](https://github.com/ianhom/MOE/blob/master/Documents/Design_Record.md/#关于定时器) | 实用的软件定时器功能,支持回调. 21 | [**消息机制**](https://github.com/ianhom/MOE/blob/master/Documents/Design_Record.md/#再谈消息机制) | 易用的消息API轻松实现任务间通讯,支持“To All”消息(低RAM消耗). 22 | [**调试选项**](https://github.com/ianhom/MOE/blob/master/Documents/Design_Record.md/#关于调试选项) | 灵活的调试选项,每个模块可设置不同的调试信息打印等级;易用的ASSERT;支持Cortex M的错误跟踪[CmBacktrace](https://github.com/armink/CmBacktrace)(Hardfault backtrace for Cortex-M) 23 | [**Protothread**](https://github.com/ianhom/MOE/blob/master/Documents/Design_Record.md/#关于原型线程) | 应用模块支持Protothread的编写方式. 24 | 25 | 更多讨论欢迎加入我们的QQ群:**[475258651](https://jq.qq.com/?_wv=1027&k=41PrZvS)** 26 | 27 | ## 如何使用 28 | - **步骤 1**: 将MOE移植到您的硬件上,并为其提供“**系统毫秒时钟**”及“**需要时刻轮询的函数(如果有的话)**”,然后初始化并运行MOE. 29 | ```c 30 | /* 示例代码 */ 31 | uint16 GetMsClock(void) /* 获取系统毫秒时钟 */ 32 | { 33 | return sg_u16SysClk; /* 返回系统ms时钟,sg_u16SysClk每1毫秒自增1,例如在为定时1毫秒的硬件定时器中断中实现 */ 34 | } 35 | 36 | void Poll(void) /* 需要被轮询的程序 */ 37 | { 38 | /* 在这里添加需要轮询的程序 */ 39 | return; 40 | } 41 | 42 | void main(void) 43 | { 44 | .... /* 板级初始化 */ 45 | MOE_Init(GetMsClock, Poll); /* MOE初始化,提供系统毫秒获取时钟函数,及需要被轮询的函数(若无则填写NULL) */ 46 | MOE_Run(); /* 启动MOE, */ 47 | return; 48 | } 49 | ``` 50 | - **步骤 2**: **创建**您的TASK或**复用**已有的经过测试的TASK来实现您的应用功能. (以下仅展示了protothread风格的应用,Event handler风格请详见源码) 51 | ```c 52 | /* 示例代码 */ 53 | /* Task 1: LED闪烁*/ 54 | uint8 Task_PT_Demo_Process(uint8 u8Evt, void *pPara) 55 | { 56 | PT_INIT(); 57 | PT_BEGIN(); 58 | MOE_MANDATORY_INIT(); /* Mandatory init, shout call it here only */ 59 | 60 | while(1) 61 | { 62 | TASK_PT_DEMO_LED_Toggle(LED_RED); 63 | PT_DELAY(1000); 64 | 65 | TASK_PT_DEMO_LED_Toggle(LED_GREEN); 66 | PT_DELAY(1000); 67 | 68 | TASK_PT_DEMO_LED_Toggle(LED_BLUE); 69 | PT_DELAY(1000); 70 | } 71 | PT_END(); 72 | return SW_OK; 73 | } 74 | ``` 75 | 76 | ```c 77 | /* 示例代码 */ 78 | /* Task 2:周期打印 */ 79 | uint8 Task_PT_Demo2_Process(uint8 u8Evt, void *pPara) 80 | { 81 | PT_INIT(); 82 | PT_BEGIN(); 83 | MOE_MANDATORY_INIT(); /* Mandatory init, shout call it here only */ 84 | 85 | while(1) 86 | { 87 | DBG_PRINT("I am another Task!!\n"); 88 | PT_DELAY(1000); 89 | } 90 | PT_END(); 91 | return SW_OK; 92 | } 93 | ``` 94 | 95 | - **步骤 3**: 在**Project_Config.h**文件中[**注册**](https://github.com/ianhom/MOE/blob/master/Documents/Design_Record.md/#关于任务注册)需要运行的TASK,并在该文件中进行其它**相关配置**. 96 | ```c 97 | #define LIST_OF_REG_TASK \ 98 | REG_TASK(Task_PT_Demo_Proces)\ 99 | REG_TASK(Task_PT_Demo2_Proces) 100 | ``` 101 | - **步骤 4**: 运行,Enjoy. :smile: 102 | 103 | ## 项目目录 104 | 105 | 文件夹 | 说明 106 | :----- | :------------ 107 | [**App/**](https://github.com/ianhom/MOE/tree/master/App) | 应用任务模块,与具体工程无关,新工程可复用该文件夹下模块或根据需求添加模块 108 | [**Core/**](https://github.com/ianhom/MOE/tree/master/Core) | 内核文件,包含调度、事件驱动处理、定时器、消息处理 109 | [**Cpu/**](https://github.com/ianhom/MOE/tree/master/Cpu) | MCU芯片内核、时钟、启动相关文件 110 | [**Debug/**](https://github.com/ianhom/MOE/tree/master/Debug) | 实用的调试工具及模块 111 | [**Driver/**](https://github.com/ianhom/MOE/tree/master/Driver) | 驱动文件,包含MCU外设驱动、扩展设备驱动(RF模块,传感器等) 112 | [**Network/**](https://github.com/ianhom/MOE/tree/master/Network) | 各种网络通讯协议栈(待完成) 113 | [**Pub/**](https://github.com/ianhom/MOE/tree/master/Pub) | 项目公共文件,包含公共头文件、宏定义、调试文件 114 | [**Utility/**](https://github.com/ianhom/MOE/tree/master/Utility) | 常用功能模块,包含队列、链表、printf等 115 | [**project/**](https://github.com/ianhom/MOE/tree/master/project) | 具体工程相关文件,包含工程配置文件,硬件配置配件和main文件 116 | [**Documents/**](https://github.com/ianhom/MOE/tree/master/Documents) | 说明性文档,包含设计说明,API说明、图片 117 | [**Tools/**](https://github.com/ianhom/MOE/tree/master/Tools) | 配置、编译、调试、分析等实用工具 118 | 119 | ## 文档参考 120 | - [API说明](https://github.com/ianhom/MOE/blob/master/Documents/API_Description_Chinese.md) 121 | - [设计笔记](https://github.com/ianhom/MOE/blob/master/Documents/Design_Record.md) 122 | 123 | ## 特别感谢 124 | - :tada:**萌萌(MOE)的支持**:tada: 125 | - :tada:**蔡嘉楠小姐**对MOE Logo的精心绘制。:tada:   126 | -------------------------------------------------------------------------------- /Tools/README.md: -------------------------------------------------------------------------------- 1 | # Tools 2 | - Some useful tools like configuration tool 3 | -------------------------------------------------------------------------------- /Utility/MOE_Link_list.h: -------------------------------------------------------------------------------- 1 | /*/****************************************************************************** 2 | * File : MOE_Link_list.h 3 | * Function : General link list function. 4 | * Description: To be done. 5 | * Version : V1.00 6 | * Author : Ian 7 | * Date : 2nd Jun 2016 8 | * History : No. When Who What 9 | * 1 02/Jun/2016 Ian Create 10 | ******************************************************************************/ 11 | 12 | #ifndef _MOE_LINK_LIST_H_ 13 | #define _MOE_LINK_LIST_H_ 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | /* Check if specified option is set for debugging */ 20 | #ifndef __DEBUG_MODE_MOE_LINK_LIST 21 | #define __DEBUG_MODE __DEBUG_NONE /* Default: None debugging info */ 22 | #else 23 | #ifdef __DEBUG_MODE 24 | #undef __DEBUG_MODE 25 | #endif 26 | #define __DEBUG_MODE __DEBUG_MODE_MOE_LINK_LIST /* According the set from project_config.h */ 27 | #endif 28 | 29 | /****************************************************************************** 30 | * Name : static T_TIMER_NODE* Moe_Timer_Add() 31 | * Function : Add a timer node 32 | * Input : PF_TIMER_SRC pfSysTm Funtion which returns system time 33 | * Output: : None 34 | * Return : SW_OK Successful. 35 | * SW_ERR Failed. 36 | * Description: To be done. 37 | * Version : V1.00 38 | * Author : Ian 39 | * Date : 2nd Jun 2016 40 | ******************************************************************************/ 41 | void* Moe_Link_List_Add(void **pptHead, void **pptTail, void* ptNode); 42 | 43 | 44 | 45 | /****************************************************************************** 46 | * Name : static T_TIMER_NODE* Moe_Timer_Del(T_TIMER_NODE* ptNode) 47 | * Function : Delete a timer node 48 | * Input : T_TIMER_NODE* ptNode The timer node to be delete. 49 | * Output: : None 50 | * Return : NULL Fail to delete a timer. 51 | * T_TIMER_NODE* The pointer of the timer which is deleted. 52 | * description: To be done. 53 | * Version : V1.00 54 | * Author : Ian 55 | * Date : 6th May 2016 56 | ******************************************************************************/ 57 | void* Moe_Link_list_Del(void **pptHead, void **pptTail, void* ptNode); 58 | 59 | 60 | /****************************************************************************** 61 | * Name : static T_TIMER_NODE *Moe_Timer_Find(T_TIMER_NODE* ptNode) 62 | * Function : Try to find a node. 63 | * Input : T_TIMER_NODE* ptNode The pointer of node to be found 64 | * Output: : None 65 | * Return : NULL Fail to find the node. 66 | * T_TIMER_NODE* The pointer of the founed node. 67 | * Description: To be done. 68 | * Version : V1.00 69 | * Author : Ian 70 | * Date : 6th May 2016 71 | ******************************************************************************/ 72 | void *Moe_Link_list_Find(void **pptHead, uint16 u16OffSet, uint8 u8Size,uint8 u8Node, void **pptPre); 73 | 74 | 75 | /****************************************************************************** 76 | * Name : uint16 Moe_Timer_Cnt() 77 | * Function : Get the count of timers 78 | * Input : None 79 | * Output: : None 80 | * Return : uint16 The count of timers 81 | * Description: To be done. 82 | * Version : V1.00 83 | * Author : Ian 84 | * Date : 6th May 2016 85 | ******************************************************************************/ 86 | uint16 Moe_Link_list_Cnt(void **pptHead); 87 | 88 | 89 | 90 | 91 | 92 | #ifdef __cplusplus 93 | } 94 | #endif 95 | 96 | #endif /* _MOE_LINK_LIST_H_ */ 97 | 98 | /* End of file */ 99 | 100 | -------------------------------------------------------------------------------- /Utility/README.md: -------------------------------------------------------------------------------- 1 | # Utility 2 | 3 | Some useful module 4 | -------------------------------------------------------------------------------- /project/Basic_Demo_KL25/Board_Config.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * File : Board_Config.h 3 | * Function : Hardware configurations 4 | * Description: To be done. 5 | * Version : V1.00 6 | * Author : Ian 7 | * Date : 3rd Jul 2016 8 | * History : No. When Who What 9 | * 1 3/Jul/2016 Ian Create 10 | ******************************************************************************/ 11 | 12 | #ifndef _BOARD_CONFIG_H_ 13 | #define _BOARD_CONFIG_H_ 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | /* Check if specified option is set for debugging */ 20 | #ifndef __DEBUG_MODE_BOARD_CONFIG 21 | #define __DEBUG_MODE __DEBUG_NONE /* Default: None debugging info */ 22 | #else 23 | #ifdef __DEBUG_MODE 24 | #undef __DEBUG_MODE 25 | #endif 26 | #define __DEBUG_MODE __DEBUG_MODE_BOARD_CONFIG /* According the set from project_config.h */ 27 | #endif 28 | 29 | 30 | #define BOARD_CONFIG_BTN_ST_HIGH (1) /* The voltage state of pin is HIGH */ 31 | #define BOARD_CONFIG_BTN_ST_LOW (0) /* The voltage state of pin is LOW */ 32 | 33 | #define BOARD_CONFIG_LED_BLUE (3) /* Blue led */ 34 | #define BOARD_CONFIG_LED_RED (2) /* Red led */ 35 | #define BOARD_CONFIG_LED_YELLOW (1) /* Yellow led */ 36 | #define BOARD_CONFIG_LED_GREEN (0) /* Green led */ 37 | 38 | #define BOARD_CONFIG_LED_ON (0) /* led ON mode */ 39 | #define BOARD_CONFIG_LED_OFF (1) /* led OFF mode */ 40 | #define BOARD_CONFIG_LED_TOGGLE (3) /* led Toggle mode */ 41 | 42 | 43 | /****************************************************************************** 44 | * Name : void Gpio_Init(void) 45 | * Function : Init GPIOs 46 | * Input : None 47 | * Output: : None 48 | * Return : None 49 | * Description: To be done. 50 | * Version : V1.00 51 | * Author : Ian 52 | * Date : 3rd Jul 2016 53 | ******************************************************************************/ 54 | void Gpio_Init(void); 55 | 56 | /****************************************************************************** 57 | * Name : void LED_Toggle(uint8 u8Ch) 58 | * Function : LED toggle control 59 | * Input : uint8 u8Ch 0~255 Channel number of led 60 | * Output: : None 61 | * Return : None 62 | * Description: To be done. 63 | * Version : V1.00 64 | * Author : Ian 65 | * Date : 4th Jul 2016 66 | ******************************************************************************/ 67 | void LED_Toggle(uint8 u8Ch); 68 | 69 | /****************************************************************************** 70 | * Name : void LED_Off(uint8 u8Ch) 71 | * Function : LED Off control 72 | * Input : uint8 u8Ch 0~255 Channel number of led 73 | * Output: : None 74 | * Return : None 75 | * Description: To be done. 76 | * Version : V1.00 77 | * Author : Ian 78 | * Date : 4th Jul 2016 79 | ******************************************************************************/ 80 | void LED_Off(uint8 u8Ch); 81 | 82 | 83 | /****************************************************************************** 84 | * Name : void LED_On(uint8 u8Ch) 85 | * Function : LED On control 86 | * Input : uint8 u8Ch 0~255 Channel number of led 87 | * Output: : None 88 | * Return : None 89 | * Description: To be done. 90 | * Version : V1.00 91 | * Author : Ian 92 | * Date : 4th Jul 2016 93 | ******************************************************************************/ 94 | void LED_On(uint8 u8Ch); 95 | 96 | 97 | /****************************************************************************** 98 | * Name : uint8 Btn_St_Get(uint8 u8Ch) 99 | * Function : Get the current state of buttons. 100 | * Input : uint8 u8Ch 1~255 The channel number of button 101 | * Output: : None 102 | * Return : BOARD_CONFIG_BTN_ST_HIGH Pin with high voltage level 103 | * BOARD_CONFIG_BTN_ST_LOW Pin with low voltage level 104 | * SW_ERR Wrong cahnnel number 105 | * Description: To be done. 106 | * Version : V1.00 107 | * Author : Ian 108 | * Date : 3rd Jul 2016 109 | ******************************************************************************/ 110 | uint8 Btn_St_Get(uint8 u8Ch); 111 | 112 | void Board_Config_Reset_Ctrl(uint8 u8Val); 113 | 114 | 115 | #ifdef __cplusplus 116 | } 117 | #endif 118 | 119 | #endif /* _BOARD_CONFIG_H */ 120 | 121 | /* End of file */ 122 | 123 | 124 | -------------------------------------------------------------------------------- /project/Basic_Demo_KL25/MOE_main.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * File : Moe_main.c 3 | * Function : Main-start of the project. 4 | * Description: To be done. 5 | * Version : V1.00 6 | * Author : Ian 7 | * Date : 4th Nov 2016 8 | * History : No. When Who What 9 | * 1 24/May/2016 Ian Create 10 | ******************************************************************************/ 11 | #include "../../Pub/common.h" 12 | #include "../../Pub/common_head.h" 13 | #include "./project_config.h" 14 | #include "./Moe_main.h" 15 | #include "../../Pub/debug.h" 16 | #include "../../Core/MOE_Core.h" 17 | #include "../../Core/MOE_Timer.h" 18 | #include "../../Core/MOE_Msg.h" 19 | #include "./Board_Config.h" 20 | #include "KL25_Lpt_Time.h" 21 | 22 | /********************************************************************/ 23 | 24 | __root const char cg_au8Version[] = MOE_VERSION" ("__DATE__" - " __TIME__ ")"; 25 | 26 | void Poll_Process(void) 27 | { 28 | return; 29 | } 30 | 31 | 32 | int main (void) 33 | { 34 | uint8 u8Idx; 35 | 36 | Gpio_Init(); /* Init GPIOs */ 37 | Timer_Init(); /* Init Timer */ 38 | 39 | /* Print all loaded tasks */ 40 | DBG_PRINT("\n***** %s *****\n", cg_au8Version); 41 | DBG_PRINT("Task count is %d:\n",MAX_TASK_NUM); 42 | for(u8Idx = 0; u8Idx < MAX_TASK_NUM; u8Idx++) 43 | { 44 | DBG_PRINT("---Task No. is %3d : %s.\n", (u8Idx+1),cg_apu8TaskName[u8Idx]); 45 | } 46 | DBG_PRINT("\n\n"); 47 | 48 | /* Init MOE */ 49 | Moe_Init(App_GetSystemTime_ms, Poll_Process); 50 | 51 | /* Run MOE */ 52 | Moe_Run(); 53 | 54 | /* Never reach here */ 55 | return 0; 56 | } 57 | /********************************************************************/ 58 | 59 | -------------------------------------------------------------------------------- /project/Basic_Demo_KL25/MOE_main.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * File : Moe_main.h 3 | * Function : To be doen. 4 | * Description: To be done. 5 | * Version : V1.00 6 | * Author : Ian 7 | * Date : 24th May 2016 8 | * History : No. When Who What 9 | * 1 24/May/2016 Ian Create 10 | ******************************************************************************/ 11 | 12 | #ifndef _MOE_MAIN_H_ 13 | #define _MOE_MAIN_H_ 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | /* Check if specified option is set for debugging */ 20 | #ifndef __DEBUG_MODE_MAIN 21 | #define __DEBUG_MODE __DEBUG_NONE /* Default: None debugging info */ 22 | #else 23 | #ifdef __DEBUG_MODE 24 | #undef __DEBUG_MODE 25 | #endif 26 | #define __DEBUG_MODE __DEBUG_MODE_MAIN /* According the set from project_config.h */ 27 | #endif 28 | 29 | 30 | 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | 35 | #endif /* _MOE_MAIN_H */ 36 | 37 | /* End of file */ 38 | 39 | 40 | -------------------------------------------------------------------------------- /project/Basic_Demo_KL25/README.md: -------------------------------------------------------------------------------- 1 | # Basic_Demo_KL25 2 | -- | Descrption 3 | ---------- | ------------------------------ 4 | Name | Basic_Demo_KL25 5 | Function | Demo application of 3 event-process tasks 6 | Platform | FRDM-KL25Z 7 | MCU | KL25Z 8 | Type | ARM Cortex-M0+ 9 | Frequency | 48MHz 10 | RAM | 16K bytes 11 | ROM | 128K bytes 12 | peripheral | 3-color LED * 1 13 | -- | MMA8451Q Accelerate sensor * 1 14 | 15 | 16 | ![FRDM-KL25Z](https://github.com/ianhom/MOE/blob/master/Documents/Pic/FRDM-KL25Z.png?raw=true) 17 | -------------------------------------------------------------------------------- /project/Basic_Demo_KL25/project_config.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * File : project_config.h 3 | * Function : project configuration. 4 | * Description: To be done. 5 | * Version : V1.00 6 | * Author : Ian 7 | * Date : 24th May 2016 8 | * History : No. When Who What 9 | * 1 24/May/2016 Ian Create 10 | ******************************************************************************/ 11 | 12 | #ifndef _PROJECT_CONFIG_H_ 13 | #define _PROJECT_CONFIG_H_ 14 | 15 | 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | #include 22 | #include 23 | 24 | #define _STR(a) #a 25 | #define STR(a) _STR(a) 26 | /* Configure Zone */ 27 | 28 | /* Add your task process here */ 29 | #define LIST_OF_REG_TASK \ 30 | REG_TASK(Task1_Process)\ 31 | REG_TASK(Task2_Process)\ 32 | REG_TASK(Task_Process) 33 | 34 | #define REG_TASK(name) uint8 name(uint8 u8Evt, void *pPara); 35 | LIST_OF_REG_TASK 36 | #undef REG_TASK 37 | 38 | static const PF_TASK_PROCESS cg_apfTaskFn[] = 39 | { 40 | #define REG_TASK(name) name, 41 | LIST_OF_REG_TASK 42 | #undef REG_TASK 43 | }; 44 | 45 | static const uint8* cg_apu8TaskName[] = 46 | { 47 | #define REG_TASK(name) STR(name), 48 | LIST_OF_REG_TASK 49 | #undef REG_TASK 50 | }; 51 | 52 | #define MAX_TASK_NUM (sizeof(cg_apfTaskFn)/sizeof(cg_apfTaskFn[0])) /* Max number of tasks */ 53 | 54 | #define MAX_QUEUE_EVT_NUM (MAX_TASK_NUM * 10) 55 | 56 | #define __FLEXIBLE_ARRAY_NOT_SUPPORTED /* Complier does NOT support flexible array */ 57 | 58 | #define __TIMER_CALLBACK_SUPPORTED /* Timer callback is supported */ 59 | 60 | #define __DEBUG_ENABLE /* Debug mode is enabled */ 61 | 62 | #define __WANTED_A_LIVE_FOX /* Wanted: a live fox. */ 63 | 64 | //#define __MOE_SPI_ENABLE 65 | #define __MOE_UART_ENABLE 66 | 67 | /********************************************************************************* 68 | NOTE: You have four ways to use malloc: 69 | 1. Do not define __MALLOC_OPTION or define __MALLOC_OPTION as __MALLOC_STD, 70 | and Do not re-write the malloc and free function, you will use the standard 71 | malloc and free function in lib. 72 | 2. Do not define __MALLOC_OPTION or define __MALLOC_OPTION as __MALLOC_STD, 73 | and re-write the malloc and free function, you will use your malloc and free 74 | function, please NOTE that the whole project use your malloc and free function 75 | 3. Define __MALLOC_OPTION as __MALLOC_MY, now your can use your own malloc and 76 | free function, however, if you use the same name with "malloc" and "free", 77 | whole project use your malloc and free just like situation 2. 78 | 4. Define __MALLOC_OPTION as __MALLOC_MOE, the Moe_Malloc and Moe_Free will be 79 | used. 80 | 81 | Options for __MALLOC_OPTION: 82 | __MALLOC_STD Use standard malloc and free 83 | __MALLOC_MOE Use MOE malloc and free 84 | __MALLOC_MY Use your malloc and free 85 | *********************************************************************************/ 86 | #define __MALLOC_OPTION __MALLOC_STD /* Use standard malloc and free funciton */ 87 | 88 | 89 | #ifdef __DEBUG_ENABLE 90 | #define __DEBUG_MODE_MAIN __DEBUG_BASIC_INFO 91 | #define __DEBUG_MODE_MOE_CORE __DEBUG_NONE 92 | #define __DEBUG_MODE_MOE_APP __DEBUG_NONE 93 | #define __DEBUG_MODE_MOE_TIMER __DEBUG_NONE 94 | #define __DEBUG_MODE_MOE_LINK_LIST __DEBUG_BASIC_INFO 95 | #define __DEBUG_MODE_MOE_QUEUE __DEBUG_BASIC_INFO 96 | #define __DEBUG_MODE_MOE_MSG __DEBUG_NONE 97 | #define __DEBUG_MODE_TASK_LED_DEMO __DEBUG_BASIC_INFO 98 | #define __DEBUG_MODE_APP_TASK_1 __DEBUG_NONE 99 | #define __DEBUG_MODE_APP_TASK_2 __DEBUG_BASIC_INFO 100 | #define __DEBUG_MODE_APP_TASK_3 __DEBUG_BASIC_INFO 101 | #define __DEBUG_MODE_APP_TASK__DEMO_QUEUE __DEBUG_BASIC_INFO 102 | #define __DEBUG_MODE_MOE_EVENT __DEBUG_NONE 103 | #define __DEBUG_MODE_BOARD_CONFIG __DEBUG_BASIC_INFO 104 | #define __DEBUG_MODE_MOE_HAL __DEBUG_BASIC_INFO 105 | #define __DEBUG_MODE_PT_DEMO __DEBUG_BASIC_INFO 106 | #define __DEBUG_MODE_PT_DEMO2 __DEBUG_BASIC_INFO 107 | #define __DEBUG_MODE_MOE_HAL_SPI __DEBUG_BASIC_INFO 108 | #define __DEBUG_MODE_MOE_DRV_CC1101 __DEBUG_BASIC_INFO 109 | #define __DEBUG_MODE_KNX_RF_LL __DEBUG_BASIC_INFO 110 | #define __DEBUG_MODE_PT_IEC870_PL __DEBUG_BASIC_INFO 111 | #define __DEBUG_MODE_MOE_HAL_UART __DEBUG_FUNC_LINE_INFO 112 | #define __DEBUG_MODE_MOE_DRV_11XX __DEBUG_FUNC_LINE_INFO 113 | #define __DEBUG_MODE_PT_11XX_TEST __DEBUG_BASIC_INFO 114 | #endif 115 | 116 | 117 | #if (__MALLOC_OPTION == __MALLOC_MY) /* If you want to use your malloc and free */ 118 | #define MOE_MALLOC(size) My_Malloc(size) /* Add your malloc function here */ 119 | #define MOE_FREE(p) My_Free(p) /* Add your free function here */ 120 | #endif 121 | 122 | 123 | #ifdef __cplusplus 124 | } 125 | #endif 126 | 127 | #endif /* _PROJECT_CONFIG_H_ */ 128 | 129 | /* End of file */ 130 | 131 | 132 | -------------------------------------------------------------------------------- /project/PT_Demo_EFM32HG322_3400A/README.md: -------------------------------------------------------------------------------- 1 | # PT_Demo_EFM32HG322_3400A 2 | -- | Description 3 | ---------- | ------------------------------ 4 | Name | PT_Demo_EFM32HG322_3400A 5 | Function | Demo application of 2 protothread tasks: Task 1 controls the Green LED blinking; Task 2 print task infomation periodically 6 | Platform | EFM32HG332_3400A 7 | MCU | EFM32HG332F64 8 | Type | ARM Cortex-M0+ 9 | Frequency | 25MHz 10 | RAM | 8K bytes 11 | ROM | 64K bytes 12 | peripheral | LED * 2 13 | -- | Reset button * 1 14 | -- | User button * 2 15 | -- | Touch panel * 2 16 | -- | Memory LCD * 1 17 | 18 | 19 | 20 | ![](https://github.com/ianhom/MOE/blob/master/Documents/Pic/Board/HappyGecko%20Starter-kit.png?raw=true) 21 | 22 | -------------------------------------------------------------------------------- /project/PT_Demo_KL25/Board_Config.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * File : Board_Config.h 3 | * Function : Hardware configurations 4 | * Description: Used in PT_Demo_KL25 project. 5 | * Version : V1.00 6 | * Author : Ian 7 | * Date : 4th Nov 2016 8 | * History : No. When Who What 9 | * 1 04/Nov/2016 Ian Create 10 | ******************************************************************************/ 11 | 12 | #ifndef _BOARD_CONFIG_H_ 13 | #define _BOARD_CONFIG_H_ 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | /* Check if specified option is set for debugging */ 20 | #ifndef __DEBUG_MODE_BOARD_CONFIG 21 | #define __DEBUG_MODE __DEBUG_NONE /* Default: None debugging info */ 22 | #else 23 | #ifdef __DEBUG_MODE 24 | #undef __DEBUG_MODE 25 | #endif 26 | #define __DEBUG_MODE __DEBUG_MODE_BOARD_CONFIG /* According the set from project_config.h */ 27 | #endif 28 | 29 | 30 | #define BOARD_CONFIG_BTN_ST_HIGH (1) /* The voltage state of pin is HIGH */ 31 | #define BOARD_CONFIG_BTN_ST_LOW (0) /* The voltage state of pin is LOW */ 32 | 33 | #define BOARD_CONFIG_LED_BLUE (3) /* Blue led */ 34 | #define BOARD_CONFIG_LED_RED (2) /* Red led */ 35 | #define BOARD_CONFIG_LED_YELLOW (1) /* Yellow led */ 36 | #define BOARD_CONFIG_LED_GREEN (0) /* Green led */ 37 | 38 | #define BOARD_CONFIG_LED_ON (0) /* led ON mode */ 39 | #define BOARD_CONFIG_LED_OFF (1) /* led OFF mode */ 40 | #define BOARD_CONFIG_LED_TOGGLE (3) /* led Toggle mode */ 41 | 42 | 43 | /****************************************************************************** 44 | * Name : void Gpio_Init(void) 45 | * Function : Init GPIOs 46 | * Input : None 47 | * Output: : None 48 | * Return : None 49 | * Description: To be done. 50 | * Version : V1.00 51 | * Author : Ian 52 | * Date : 3rd Jul 2016 53 | ******************************************************************************/ 54 | void Gpio_Init(void); 55 | 56 | /****************************************************************************** 57 | * Name : void LED_Toggle(uint8 u8Ch) 58 | * Function : LED toggle control 59 | * Input : uint8 u8Ch 0~255 Channel number of led 60 | * Output: : None 61 | * Return : None 62 | * Description: To be done. 63 | * Version : V1.00 64 | * Author : Ian 65 | * Date : 4th Jul 2016 66 | ******************************************************************************/ 67 | void LED_Toggle(uint8 u8Ch); 68 | 69 | /****************************************************************************** 70 | * Name : void LED_Off(uint8 u8Ch) 71 | * Function : LED Off control 72 | * Input : uint8 u8Ch 0~255 Channel number of led 73 | * Output: : None 74 | * Return : None 75 | * Description: To be done. 76 | * Version : V1.00 77 | * Author : Ian 78 | * Date : 4th Jul 2016 79 | ******************************************************************************/ 80 | void LED_Off(uint8 u8Ch); 81 | 82 | 83 | /****************************************************************************** 84 | * Name : void LED_On(uint8 u8Ch) 85 | * Function : LED On control 86 | * Input : uint8 u8Ch 0~255 Channel number of led 87 | * Output: : None 88 | * Return : None 89 | * Description: To be done. 90 | * Version : V1.00 91 | * Author : Ian 92 | * Date : 4th Jul 2016 93 | ******************************************************************************/ 94 | void LED_On(uint8 u8Ch); 95 | 96 | 97 | /****************************************************************************** 98 | * Name : uint8 Btn_St_Get(uint8 u8Ch) 99 | * Function : Get the current state of buttons. 100 | * Input : uint8 u8Ch 1~255 The channel number of button 101 | * Output: : None 102 | * Return : BOARD_CONFIG_BTN_ST_HIGH Pin with high voltage level 103 | * BOARD_CONFIG_BTN_ST_LOW Pin with low voltage level 104 | * SW_ERR Wrong channel number 105 | * Description: To be done. 106 | * Version : V1.00 107 | * Author : Ian 108 | * Date : 3rd Jul 2016 109 | ******************************************************************************/ 110 | uint8 Btn_St_Get(uint8 u8Ch); 111 | 112 | void Board_Config_Reset_Ctrl(uint8 u8Val); 113 | 114 | 115 | #ifdef __cplusplus 116 | } 117 | #endif 118 | 119 | #endif /* _BOARD_CONFIG_H */ 120 | 121 | /* End of file */ 122 | 123 | -------------------------------------------------------------------------------- /project/PT_Demo_KL25/MOE_main.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * File : Moe_main.c 3 | * Function : Main-start of the project. 4 | * Description: To be done. 5 | * Version : V1.00 6 | * Author : Ian 7 | * Date : 4th Nov 2016 8 | * History : No. When Who What 9 | * 1 04/Nov/2016 Ian Create 10 | ******************************************************************************/ 11 | #include "common.h" 12 | #include "../../Pub/common_head.h" 13 | #include "./project_config.h" 14 | #include "./MOE_main.h" 15 | #include "../../Pub/debug.h" 16 | #include "../../Core/MOE_Core.h" 17 | #include "../../Core/MOE_Timer.h" 18 | #include "../../Core/MOE_Msg.h" 19 | #include "./Board_Config.h" 20 | #include "KL25_Lpt_Time.h" 21 | 22 | /********************************************************************/ 23 | 24 | __root const char cg_au8Version[] = MOE_VERSION" ("__DATE__" - " __TIME__ ")"; 25 | 26 | void Poll_Process(void) 27 | { 28 | return; 29 | } 30 | 31 | 32 | int main (void) 33 | { 34 | uint8 u8Idx; 35 | 36 | Gpio_Init(); /* Init GPIOs */ 37 | Timer_Init(); /* Init Timer */ 38 | 39 | /* Print all loaded tasks */ 40 | DBG_PRINT("\n***** %s *****\n", cg_au8Version); 41 | DBG_PRINT("Task count is %d:\n",MAX_TASK_NUM); 42 | for(u8Idx = 0; u8Idx < MAX_TASK_NUM; u8Idx++) 43 | { 44 | DBG_PRINT("---Task No. is %3d : %s.\n", (u8Idx+1),cg_apu8TaskName[u8Idx]); 45 | } 46 | DBG_PRINT("\n\n"); 47 | 48 | /* Init MOE */ 49 | Moe_Init(App_GetSystemTime_ms, Poll_Process); 50 | 51 | /* Run MOE */ 52 | Moe_Run(); 53 | 54 | /* Never reach here */ 55 | return 0; 56 | } 57 | 58 | /* End of file */ 59 | 60 | -------------------------------------------------------------------------------- /project/PT_Demo_KL25/MOE_main.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * File : Moe_main.h 3 | * Function : Main-start of the project. 4 | * Description: To be done. 5 | * Version : V1.00 6 | * Author : Ian 7 | * Date : 4th Nov 2016 8 | * History : No. When Who What 9 | * 1 04/Nov/2016 Ian Create 10 | ******************************************************************************/ 11 | 12 | #ifndef _MOE_MAIN_H_ 13 | #define _MOE_MAIN_H_ 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | /* Check if specified option is set for debugging */ 20 | #ifndef __DEBUG_MODE_MAIN 21 | #define __DEBUG_MODE __DEBUG_NONE /* Default: None debugging info */ 22 | #else 23 | #ifdef __DEBUG_MODE 24 | #undef __DEBUG_MODE 25 | #endif 26 | #define __DEBUG_MODE __DEBUG_MODE_MAIN /* According the set from project_config.h */ 27 | #endif 28 | 29 | 30 | 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | 35 | #endif /* _MOE_MAIN_H */ 36 | 37 | /* End of file */ 38 | 39 | -------------------------------------------------------------------------------- /project/PT_Demo_KL25/README.md: -------------------------------------------------------------------------------- 1 | # PT_Demo_KL25 2 | 3 | -- | Description 4 | ---------- | ------------------------------ 5 | Name | PT_Demo_KL25 6 | Function | Demo application of 2 protothread tasks: Task 1 controls the LEDs blinking; Task 2 print task infomation periodically 7 | Platform | FRDM-KL25Z 8 | MCU | KL25Z 9 | Type | ARM Cortex-M0+ 10 | Frequency | 48MHz 11 | RAM | 16K bytes 12 | ROM | 128K bytes 13 | peripheral | 3-color LED * 1 14 | -- | LED * 4 15 | -- | Button * 4 16 | -- | MMA8451Q Accelerate sensor * 1 17 | 18 | 19 | ![FRDM-Mini-Shield](https://github.com/ianhom/MOE/blob/master/Documents/Pic/mini-shield.png?raw=true) 20 | ![FRDM-KL25Z](https://github.com/ianhom/MOE/blob/master/Documents/Pic/FRDM-KL25Z.png?raw=true) 21 | -------------------------------------------------------------------------------- /project/PT_Demo_KL27_MiniBoard/Board_Config.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * File : Board_Config.h 3 | * Function : Hardware configurations 4 | * Description: Used in PT_Demo_KL27_MiniBoard project. 5 | * Version : V1.00 6 | * Author : Ian 7 | * Date : 4th Nov 2016 8 | * History : No. When Who What 9 | * 1 13/Nov/2016 Ian Create 10 | ******************************************************************************/ 11 | 12 | #ifndef _BOARD_CONFIG_H_ 13 | #define _BOARD_CONFIG_H_ 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | /* Check if specified option is set for debugging */ 20 | #ifndef __DEBUG_MODE_BOARD_CONFIG 21 | #define __DEBUG_MODE __DEBUG_NONE /* Default: None debugging info */ 22 | #else 23 | #ifdef __DEBUG_MODE 24 | #undef __DEBUG_MODE 25 | #endif 26 | #define __DEBUG_MODE __DEBUG_MODE_BOARD_CONFIG /* According the set from project_config.h */ 27 | #endif 28 | 29 | 30 | #define BOARD_CONFIG_BTN_ST_HIGH (1) /* The voltage state of pin is HIGH */ 31 | #define BOARD_CONFIG_BTN_ST_LOW (0) /* The voltage state of pin is LOW */ 32 | 33 | #define BOARD_CONFIG_LED_BLUE (3) /* Blue led */ 34 | #define BOARD_CONFIG_LED_RED (2) /* Red led */ 35 | #define BOARD_CONFIG_LED_YELLOW (1) /* Yellow led */ 36 | #define BOARD_CONFIG_LED_GREEN (0) /* Green led */ 37 | 38 | #define BOARD_CONFIG_LED_ON (0) /* led ON mode */ 39 | #define BOARD_CONFIG_LED_OFF (1) /* led OFF mode */ 40 | #define BOARD_CONFIG_LED_TOGGLE (3) /* led Toggle mode */ 41 | 42 | 43 | /****************************************************************************** 44 | * Name : void Gpio_Init(void) 45 | * Function : Init GPIOs 46 | * Input : None 47 | * Output: : None 48 | * Return : None 49 | * Description: To be done. 50 | * Version : V1.00 51 | * Author : Ian 52 | * Date : 3rd Jul 2016 53 | ******************************************************************************/ 54 | void Gpio_Init(void); 55 | 56 | /****************************************************************************** 57 | * Name : void LED_Toggle(uint8 u8Ch) 58 | * Function : LED toggle control 59 | * Input : uint8 u8Ch 0~255 Channel number of led 60 | * Output: : None 61 | * Return : None 62 | * Description: To be done. 63 | * Version : V1.00 64 | * Author : Ian 65 | * Date : 4th Jul 2016 66 | ******************************************************************************/ 67 | void LED_Toggle(uint8 u8Ch); 68 | 69 | /****************************************************************************** 70 | * Name : void LED_Off(uint8 u8Ch) 71 | * Function : LED Off control 72 | * Input : uint8 u8Ch 0~255 Channel number of led 73 | * Output: : None 74 | * Return : None 75 | * Description: To be done. 76 | * Version : V1.00 77 | * Author : Ian 78 | * Date : 4th Jul 2016 79 | ******************************************************************************/ 80 | void LED_Off(uint8 u8Ch); 81 | 82 | 83 | /****************************************************************************** 84 | * Name : void LED_On(uint8 u8Ch) 85 | * Function : LED On control 86 | * Input : uint8 u8Ch 0~255 Channel number of led 87 | * Output: : None 88 | * Return : None 89 | * Description: To be done. 90 | * Version : V1.00 91 | * Author : Ian 92 | * Date : 4th Jul 2016 93 | ******************************************************************************/ 94 | void LED_On(uint8 u8Ch); 95 | 96 | 97 | /****************************************************************************** 98 | * Name : uint8 Btn_St_Get(uint8 u8Ch) 99 | * Function : Get the current state of buttons. 100 | * Input : uint8 u8Ch 1~255 The channel number of button 101 | * Output: : None 102 | * Return : BOARD_CONFIG_BTN_ST_HIGH Pin with high voltage level 103 | * BOARD_CONFIG_BTN_ST_LOW Pin with low voltage level 104 | * SW_ERR Wrong channel number 105 | * Description: To be done. 106 | * Version : V1.00 107 | * Author : Ian 108 | * Date : 4th Nov 2016 109 | ******************************************************************************/ 110 | uint8 Btn_St_Get(uint8 u8Ch); 111 | 112 | void Board_Config_Reset_Ctrl(uint8 u8Val); 113 | 114 | 115 | #ifdef __cplusplus 116 | } 117 | #endif 118 | 119 | #endif /* _BOARD_CONFIG_H */ 120 | 121 | /* End of file */ 122 | -------------------------------------------------------------------------------- /project/PT_Demo_KL27_MiniBoard/MOE_main.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * File : Moe_main.c 3 | * Function : Main-start of the project. 4 | * Description: To be done. 5 | * Version : V1.00 6 | * Author : Ian 7 | * Date : 4th Nov 2016 8 | * History : No. When Who What 9 | * 1 13/Nov/2016 Ian Create 10 | ******************************************************************************/ 11 | #include "common.h" 12 | #include "../../Pub/common_head.h" 13 | #include "./project_config.h" 14 | #include "./Moe_main.h" 15 | #include "../../Pub/debug.h" 16 | #include "../../Core/MOE_Core.h" 17 | #include "../../Core/MOE_Timer.h" 18 | #include "../../Core/MOE_Msg.h" 19 | #include "Board_Config.h" 20 | 21 | /********************************************************************/ 22 | 23 | __root const char cg_au8Version[] = MOE_VERSION" ("__DATE__" - " __TIME__ ")"; 24 | 25 | 26 | int main (void) 27 | { 28 | uint8 u8Idx; 29 | 30 | Gpio_Init(); /* Init GPIOs */ 31 | Timer_Init(); /* Init Timer */ 32 | 33 | /* Print all loaded tasks */ 34 | DBG_PRINT("\n***** %s *****\n", cg_au8Version); 35 | DBG_PRINT("Project: %s:\n", MOE_PROJECT_NAME); 36 | DBG_PRINT("Task count is %d:\n",MAX_TASK_NUM); 37 | for(u8Idx = 0; u8Idx < MAX_TASK_NUM; u8Idx++) 38 | { 39 | DBG_PRINT("---Task No. is %3d : %s.\n", (u8Idx+1),cg_apu8TaskName[u8Idx]); 40 | } 41 | DBG_PRINT("\n\n"); 42 | 43 | /* Init MOE */ 44 | Moe_Init(App_GetSystemTime_ms, NULL); 45 | 46 | /* Run MOE */ 47 | Moe_Run(); 48 | 49 | /* Never reach here */ 50 | return 0; 51 | } 52 | 53 | /* End of file */ 54 | 55 | -------------------------------------------------------------------------------- /project/PT_Demo_KL27_MiniBoard/MOE_main.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * File : Moe_main.h 3 | * Function : Main-start of the project. 4 | * Description: To be done. 5 | * Version : V1.00 6 | * Author : Ian 7 | * Date : 4th Noc 2016 8 | * History : No. When Who What 9 | * 1 13/Nov/2016 Ian Create 10 | ******************************************************************************/ 11 | 12 | #ifndef _MOE_MAIN_H_ 13 | #define _MOE_MAIN_H_ 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | /* Check if specified option is set for debugging */ 20 | #ifndef __DEBUG_MODE_MAIN 21 | #define __DEBUG_MODE __DEBUG_NONE /* Default: None debugging info */ 22 | #else 23 | #ifdef __DEBUG_MODE 24 | #undef __DEBUG_MODE 25 | #endif 26 | #define __DEBUG_MODE __DEBUG_MODE_MAIN /* According the set from project_config.h */ 27 | #endif 28 | 29 | 30 | 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | 35 | #endif /* _MOE_MAIN_H */ 36 | 37 | /* End of file */ 38 | -------------------------------------------------------------------------------- /project/PT_Demo_KL27_MiniBoard/README.md: -------------------------------------------------------------------------------- 1 | # PT_Demo_KL27_MiniBoard 2 | -- | Description 3 | ---------- | ------------------------------ 4 | Name | PT_Demo_KL27_MiniBoard 5 | Function | Demo application of 2 protothread tasks: Task 1 controls the LEDs blinking; Task 2 print task infomation periodically 6 | Platform | KL27-MiniBoard 7 | MCU | KL27 8 | Type | ARM Cortex-M0+ 9 | Frequency | 48MHz 10 | RAM | 16K bytes 11 | ROM | 64K bytes 12 | peripheral | LED * 4 13 | -- | button * 4 14 | 15 | 16 | ![KL27-MiniBoard](https://github.com/ianhom/MOE/blob/master/Documents/Pic/KL27-MINIBOARD.png?raw=true) 17 | -------------------------------------------------------------------------------- /project/PT_Demo_KL27_MiniBoard/project_config.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * File : project_config.h 3 | * Function : project configuration. 4 | * Description: To be done. 5 | * Version : V1.00 6 | * Author : Ian 7 | * Date : 24th May 2016 8 | * History : No. When Who What 9 | * 1 13/Nov/2016 Ian Create 10 | ******************************************************************************/ 11 | 12 | #ifndef _PROJECT_CONFIG_H_ 13 | #define _PROJECT_CONFIG_H_ 14 | 15 | 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | #include 22 | #include 23 | 24 | #define _STR(a) #a 25 | #define STR(a) _STR(a) 26 | /* Configure Zone */ 27 | 28 | /* Add your task process here */ 29 | #define LIST_OF_REG_TASK \ 30 | REG_TASK(Task_PT_Demo_Process)\ 31 | REG_TASK(Task_PT_Demo2_Process) 32 | 33 | 34 | 35 | #define REG_TASK(name) uint8 name(uint8 u8Evt, void *pPara); 36 | LIST_OF_REG_TASK 37 | #undef REG_TASK 38 | 39 | 40 | static const PF_TASK_PROCESS cg_apfTaskFn[] = 41 | { 42 | #define REG_TASK(name) name, 43 | LIST_OF_REG_TASK 44 | #undef REG_TASK 45 | }; 46 | 47 | static const uint8* cg_apu8TaskName[] = 48 | { 49 | #define REG_TASK(name) STR(name), 50 | LIST_OF_REG_TASK 51 | #undef REG_TASK 52 | }; 53 | 54 | #define MAX_TASK_NUM (sizeof(cg_apfTaskFn)/sizeof(cg_apfTaskFn[0])) /* Max number of tasks */ 55 | 56 | #define MAX_QUEUE_EVT_NUM (MAX_TASK_NUM * 10) 57 | 58 | #define __FLEXIBLE_ARRAY_NOT_SUPPORTED /* Complier does NOT support flexible array */ 59 | 60 | #define __TIMER_CALLBACK_SUPPORTED /* Timer callback is supported */ 61 | 62 | #define __DEBUG_ENABLE /* Debug mode is enabled */ 63 | 64 | #define __WANTED_A_LIVE_FOX /* Wanted: a live fox. */ 65 | 66 | //#define __MOE_SPI_ENABLE 67 | #define __MOE_UART_ENABLE 68 | 69 | /****************************************************************************** 70 | NOTE: You have four ways to use malloc: 71 | 1. Do not define __MALLOC_OPTION or define __MALLOC_OPTION as __MALLOC_STD, 72 | and Do not re-write the malloc and free function, you will use the standard 73 | malloc and free function in lib. 74 | 2. Do not define __MALLOC_OPTION or define __MALLOC_OPTION as __MALLOC_STD, 75 | and re-write the malloc and free function, you will use your malloc and free 76 | function, please NOTE that the whole project use your malloc and free 77 | function. 78 | 3. Define __MALLOC_OPTION as __MALLOC_MY, now your can use your own malloc and 79 | free function, however, if you use the same name with "malloc" and "free", 80 | whole project use your malloc and free just like situation 2. 81 | 4. Define __MALLOC_OPTION as __MALLOC_MOE, the Moe_Malloc and Moe_Free will be 82 | used. 83 | Options for __MALLOC_OPTION: 84 | __MALLOC_STD Use standard malloc and free 85 | __MALLOC_MOE Use MOE malloc and free 86 | __MALLOC_MY Use your malloc and free 87 | ******************************************************************************/ 88 | #define __MALLOC_OPTION __MALLOC_STD /* Use standard malloc and free funciton */ 89 | 90 | 91 | #ifdef __DEBUG_ENABLE 92 | #define __DEBUG_MODE_MAIN __DEBUG_BASIC_INFO 93 | #define __DEBUG_MODE_MOE_CORE __DEBUG_NONE 94 | #define __DEBUG_MODE_MOE_APP __DEBUG_NONE 95 | #define __DEBUG_MODE_MOE_TIMER __DEBUG_NONE 96 | #define __DEBUG_MODE_MOE_QUEUE __DEBUG_BASIC_INFO 97 | #define __DEBUG_MODE_MOE_MSG __DEBUG_NONE 98 | #define __DEBUG_MODE_MOE_EVENT __DEBUG_NONE 99 | #define __DEBUG_MODE_BOARD_CONFIG __DEBUG_BASIC_INFO 100 | #define __DEBUG_MODE_MOE_HAL __DEBUG_BASIC_INFO 101 | #define __DEBUG_MODE_PT_DEMO __DEBUG_BASIC_INFO 102 | #define __DEBUG_MODE_PT_DEMO2 __DEBUG_BASIC_INFO 103 | #endif 104 | 105 | 106 | #if (__MALLOC_OPTION == __MALLOC_MY) /* If you want to use your malloc and free */ 107 | #define MOE_MALLOC(size) My_Malloc(size) /* Add your malloc function here */ 108 | #define MOE_FREE(p) My_Free(p) /* Add your free function here */ 109 | #endif 110 | 111 | void LED_Off(uint8 u8Ch); 112 | #define TASK1_LED_OFF LED_Off 113 | #define TASK_PT_DEMO_LED_OFF LED_Off 114 | 115 | 116 | void LED_On(uint8 u8Ch); 117 | #define TASK1_LED_ON LED_On 118 | #define TASK_PT_DEMO_LED_ON LED_On 119 | 120 | void LED_Toggle(uint8 u8Ch); 121 | #define TASK_PT_DEMO_LED_TOGGLE LED_Toggle 122 | 123 | #define LED_BLUE (3) /* Blue led */ 124 | #define LED_RED (2) /* Red led */ 125 | #define LED_GREEN (0) /* Green led */ 126 | 127 | 128 | 129 | #ifdef __cplusplus 130 | } 131 | #endif 132 | 133 | #endif /* _PROJECT_CONFIG_H_ */ 134 | 135 | /* End of file */ 136 | 137 | -------------------------------------------------------------------------------- /project/PT_Demo_MIMXRT1050-EVK/Board_Config.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * File : Board_Config.h 3 | * Function : Hardware configurations 4 | * Description: Used in PT_Demo_KL25 project. 5 | * Version : V1.00 6 | * Author : Ian 7 | * Date : 30th Nov 2017 8 | * History : No. When Who What 9 | * 1 30/Nov/2017 Ian Create 10 | ******************************************************************************/ 11 | 12 | #ifndef _BOARD_CONFIG_H_ 13 | #define _BOARD_CONFIG_H_ 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | /* Check if specified option is set for debugging */ 20 | #ifndef __DEBUG_MODE_BOARD_CONFIG 21 | #define __DEBUG_MODE __DEBUG_NONE /* Default: None debugging info */ 22 | #else 23 | #ifdef __DEBUG_MODE 24 | #undef __DEBUG_MODE 25 | #endif 26 | #define __DEBUG_MODE __DEBUG_MODE_BOARD_CONFIG /* According the set from project_config.h */ 27 | #endif 28 | 29 | 30 | #define BOARD_CONFIG_BTN_ST_HIGH (1) /* The voltage state of pin is HIGH */ 31 | #define BOARD_CONFIG_BTN_ST_LOW (0) /* The voltage state of pin is LOW */ 32 | 33 | #define BOARD_CONFIG_LED_BLUE (3) /* Blue led */ 34 | #define BOARD_CONFIG_LED_RED (2) /* Red led */ 35 | #define BOARD_CONFIG_LED_YELLOW (1) /* Yellow led */ 36 | #define BOARD_CONFIG_LED_GREEN (0) /* Green led */ 37 | 38 | #define BOARD_CONFIG_LED_ON (0) /* led ON mode */ 39 | #define BOARD_CONFIG_LED_OFF (1) /* led OFF mode */ 40 | #define BOARD_CONFIG_LED_TOGGLE (3) /* led Toggle mode */ 41 | 42 | 43 | /****************************************************************************** 44 | * Name : void Gpio_Init(void) 45 | * Function : Init GPIOs 46 | * Input : None 47 | * Output: : None 48 | * Return : None 49 | * Description: To be done. 50 | * Version : V1.00 51 | * Author : Ian 52 | * Date : 30th Nov 2017 53 | ******************************************************************************/ 54 | void Gpio_Init(void); 55 | 56 | /****************************************************************************** 57 | * Name : void LED_Toggle(uint8 u8Ch) 58 | * Function : LED toggle control 59 | * Input : uint8 u8Ch 0~255 Channel number of led 60 | * Output: : None 61 | * Return : None 62 | * Description: To be done. 63 | * Version : V1.00 64 | * Author : Ian 65 | * Date : 30th Nov 2017 66 | ******************************************************************************/ 67 | void LED_Toggle(uint8 u8Ch); 68 | 69 | /****************************************************************************** 70 | * Name : void LED_Off(uint8 u8Ch) 71 | * Function : LED Off control 72 | * Input : uint8 u8Ch 0~255 Channel number of led 73 | * Output: : None 74 | * Return : None 75 | * Description: To be done. 76 | * Version : V1.00 77 | * Author : Ian 78 | * Date : 30th Nov 2017 79 | ******************************************************************************/ 80 | void LED_Off(uint8 u8Ch); 81 | 82 | 83 | /****************************************************************************** 84 | * Name : void LED_On(uint8 u8Ch) 85 | * Function : LED On control 86 | * Input : uint8 u8Ch 0~255 Channel number of led 87 | * Output: : None 88 | * Return : None 89 | * Description: To be done. 90 | * Version : V1.00 91 | * Author : Ian 92 | * Date : 30th Nov 2017 93 | ******************************************************************************/ 94 | void LED_On(uint8 u8Ch); 95 | 96 | 97 | /****************************************************************************** 98 | * Name : uint8 Btn_St_Get(uint8 u8Ch) 99 | * Function : Get the current state of buttons. 100 | * Input : uint8 u8Ch 1~255 The channel number of button 101 | * Output: : None 102 | * Return : BOARD_CONFIG_BTN_ST_HIGH Pin with high voltage level 103 | * BOARD_CONFIG_BTN_ST_LOW Pin with low voltage level 104 | * SW_ERR Wrong channel number 105 | * Description: To be done. 106 | * Version : V1.00 107 | * Author : Ian 108 | * Date : 30th Nov 2017 109 | ******************************************************************************/ 110 | uint8 Btn_St_Get(uint8 u8Ch); 111 | 112 | void Board_Config_Reset_Ctrl(uint8 u8Val); 113 | 114 | 115 | #ifdef __cplusplus 116 | } 117 | #endif 118 | 119 | #endif /* _BOARD_CONFIG_H */ 120 | 121 | /* End of file */ 122 | 123 | -------------------------------------------------------------------------------- /project/PT_Demo_MIMXRT1050-EVK/MOE_main.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * File : Moe_main.c 3 | * Function : Main-start of the project. 4 | * Description: To be done. 5 | * Version : V1.00 6 | * Author : Ian 7 | * Date : 28th Nov 2017 8 | * History : No. When Who What 9 | * 1 28/Nov/2017 Ian Create 10 | ******************************************************************************/ 11 | #include "common.h" 12 | #include "../../Pub/common_head.h" 13 | #include "./project_config.h" 14 | #include "./Moe_main.h" 15 | #include "../../Pub/debug.h" 16 | #include "../../Core/MOE_Core.h" 17 | #include "../../Core/MOE_Timer.h" 18 | #include "../../Core/MOE_Msg.h" 19 | #include "./Board_Config.h" 20 | 21 | /********************************************************************/ 22 | 23 | __root const char cg_au8Version[] = MOE_VERSION" ("__DATE__" - " __TIME__ ")"; 24 | 25 | void Poll_Process(void) 26 | { 27 | return; 28 | } 29 | 30 | 31 | int main (void) 32 | { 33 | uint8 u8Idx; 34 | 35 | Gpio_Init(); /* Init GPIOs */ 36 | Timer_Init(); /* Init Timer */ 37 | 38 | /* Print all loaded tasks */ 39 | DBG_PRINT("\n***** %s *****\n", cg_au8Version); 40 | DBG_PRINT("Task count is %d:\n",MAX_TASK_NUM); 41 | for(u8Idx = 0; u8Idx < MAX_TASK_NUM; u8Idx++) 42 | { 43 | DBG_PRINT("---Task No. is %3d : %s.\n", (u8Idx+1),cg_apu8TaskName[u8Idx]); 44 | } 45 | DBG_PRINT("\n\n"); 46 | 47 | /* Init MOE */ 48 | Moe_Init(App_GetSystemTime_ms, Poll_Process); 49 | 50 | /* Run MOE */ 51 | Moe_Run(); 52 | 53 | /* Never reach here */ 54 | return 0; 55 | } 56 | 57 | /* End of file */ 58 | 59 | -------------------------------------------------------------------------------- /project/PT_Demo_MIMXRT1050-EVK/MOE_main.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * File : Moe_main.h 3 | * Function : Main-start of the project. 4 | * Description: To be done. 5 | * Version : V1.00 6 | * Author : Ian 7 | * Date : 29th Nov 2017 8 | * History : No. When Who What 9 | * 1 29/Nov/2019 Ian Create 10 | ******************************************************************************/ 11 | 12 | #ifndef _MOE_MAIN_H_ 13 | #define _MOE_MAIN_H_ 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | /* Check if specified option is set for debugging */ 20 | #ifndef __DEBUG_MODE_MAIN 21 | #define __DEBUG_MODE __DEBUG_NONE /* Default: None debugging info */ 22 | #else 23 | #ifdef __DEBUG_MODE 24 | #undef __DEBUG_MODE 25 | #endif 26 | #define __DEBUG_MODE __DEBUG_MODE_MAIN /* According the set from project_config.h */ 27 | #endif 28 | 29 | 30 | 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | 35 | #endif /* _MOE_MAIN_H */ 36 | 37 | /* End of file */ 38 | 39 | -------------------------------------------------------------------------------- /project/PT_Demo_MIMXRT1050-EVK/README.md: -------------------------------------------------------------------------------- 1 | # PT_Demo_MIMXRT1050-EVK 2 | 3 | -- | Description 4 | ---------- | ------------------------------ 5 | Name | PT_Demo_MIMXRT1050-EVK 6 | Function | Demo application of 2 protothread tasks: Task 1 controls the LEDs blinking; Task 2 print task infomation periodically 7 | Platform | PT_Demo_MIMXRT1050-EVK 8 | MCU | i.MX RT 1052 9 | Type | ARM Cortex-M7 10 | Frequency | 600MHz 11 | RAM | 512K bytes 12 | ROM | 16M bytes 13 | peripheral | LED * 1 14 | -- | Button * 3 15 | 16 | 17 | ![MIMXRT1050-EVK](../../Documents/Pic/Board/MIMXRT1050-EVK-DEVICE.jpg) 18 | 19 | ![MIMXRT1050-EVK-Screen](../../Documents/Pic/Board/MIMXRT1050-EVK-DEVICE2.jpg) 20 | -------------------------------------------------------------------------------- /project/PT_Demo_Navota_1/Board_Config.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * File : Board_Config.c 3 | * Function : Hardware configurations 4 | * Description: Used in PT_Demo_Navota_1 project. 5 | * Version : V1.00 6 | * Author : Ian 7 | * Date : 7th Dec 2016 8 | * History : No. When Who What 9 | * 1 7th/Dec/2016 Ian Create 10 | ******************************************************************************/ 11 | 12 | #include "common.h" 13 | #include "../../Pub/common_head.h" 14 | #include "./project_config.h" 15 | #include "../../Core/MOE_Core.h" 16 | #include "../../Core/MOE_Event.h" 17 | #include "./Board_Config.h" 18 | #include "../../Pub/debug.h" 19 | 20 | 21 | /****************************************************************************** 22 | * Name : void Gpio_Init(void) 23 | * Function : Init GPIOs 24 | * Input : None 25 | * Output: : None 26 | * Return : None 27 | * Description: To be done. 28 | * Version : V1.00 29 | * Author : Ian 30 | * Date : 7th Dec 2016 31 | ******************************************************************************/ 32 | void Gpio_Init(void) 33 | { 34 | /* Led configure */ 35 | PORTC_PCR8 = PORT_PCR_MUX(0x1); /* Configure as GPIO */ 36 | GPIOC_PSOR |= (1<<8); /* Turn off first */ 37 | GPIOC_PDDR |= (1<<8); /* Configure as output LED BLUE */ 38 | 39 | return; 40 | } 41 | 42 | /****************************************************************************** 43 | * Name : void LED_Toggle(uint8 u8Ch) 44 | * Function : LED toggle control 45 | * Input : uint8 u8Ch 0~255 Channel number of led 46 | * Output: : None 47 | * Return : None 48 | * Description: To be done. 49 | * Version : V1.00 50 | * Author : Ian 51 | * Date : 7th Dec 2016 52 | ******************************************************************************/ 53 | void LED_Toggle(uint8 u8Ch) 54 | { 55 | switch(u8Ch) 56 | { 57 | case BOARD_CONFIG_LED_BLUE: /* If it is blue led */ 58 | { 59 | GPIOC_PTOR |= (1<<8); 60 | break; 61 | } 62 | default: 63 | { 64 | break; 65 | } 66 | } 67 | return; 68 | } 69 | 70 | /****************************************************************************** 71 | * Name : void LED_Off(uint8 u8Ch) 72 | * Function : LED Off control 73 | * Input : uint8 u8Ch 0~255 Channel number of led 74 | * Output: : None 75 | * Return : None 76 | * Description: To be done. 77 | * Version : V1.00 78 | * Author : Ian 79 | * Date : 7th Dec 2016 80 | ******************************************************************************/ 81 | void LED_Off(uint8 u8Ch) 82 | { 83 | switch(u8Ch) 84 | { 85 | case BOARD_CONFIG_LED_BLUE: /* If it is blue led */ 86 | { 87 | GPIOC_PSOR |= (1<<8); 88 | break; 89 | } 90 | default: 91 | { 92 | break; 93 | } 94 | } 95 | return; 96 | } 97 | 98 | 99 | /****************************************************************************** 100 | * Name : void LED_On(uint8 u8Ch) 101 | * Function : LED On control 102 | * Input : uint8 u8Ch 0~255 Channel number of led 103 | * Output: : None 104 | * Return : None 105 | * Description: To be done. 106 | * Version : V1.00 107 | * Author : Ian 108 | * Date : 7th Dec 2016 109 | ******************************************************************************/ 110 | void LED_On(uint8 u8Ch) 111 | { 112 | switch(u8Ch) 113 | { 114 | case BOARD_CONFIG_LED_BLUE: /* If it is blue led */ 115 | { 116 | GPIOC_PCOR |= (1<<8); 117 | break; 118 | } 119 | default: 120 | { 121 | break; 122 | } 123 | } 124 | return; 125 | } 126 | 127 | 128 | /* End of file */ 129 | -------------------------------------------------------------------------------- /project/PT_Demo_Navota_1/Board_Config.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * File : Board_Config.h 3 | * Function : Hardware configurations 4 | * Description: Used in PT_Demo_Navota_1 project. 5 | * Version : V1.00 6 | * Author : Ian 7 | * Date : 7th Dec 2016 8 | * History : No. When Who What 9 | * 1 07/Dec/2016 Ian Create 10 | ******************************************************************************/ 11 | 12 | #ifndef _BOARD_CONFIG_H_ 13 | #define _BOARD_CONFIG_H_ 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | /* Check if specified option is set for debugging */ 20 | #ifndef __DEBUG_MODE_BOARD_CONFIG 21 | #define __DEBUG_MODE __DEBUG_NONE /* Default: None debugging info */ 22 | #else 23 | #ifdef __DEBUG_MODE 24 | #undef __DEBUG_MODE 25 | #endif 26 | #define __DEBUG_MODE __DEBUG_MODE_BOARD_CONFIG /* According the set from project_config.h */ 27 | #endif 28 | 29 | #define BOARD_CONFIG_LED_BLUE (3) /* Blue led */ 30 | 31 | #define BOARD_CONFIG_LED_ON (0) /* led ON mode */ 32 | #define BOARD_CONFIG_LED_OFF (1) /* led OFF mode */ 33 | #define BOARD_CONFIG_LED_TOGGLE (3) /* led Toggle mode */ 34 | 35 | 36 | /****************************************************************************** 37 | * Name : void Gpio_Init(void) 38 | * Function : Init GPIOs 39 | * Input : None 40 | * Output: : None 41 | * Return : None 42 | * Description: To be done. 43 | * Version : V1.00 44 | * Author : Ian 45 | * Date : 7th Dec 2016 46 | ******************************************************************************/ 47 | void Gpio_Init(void); 48 | 49 | /****************************************************************************** 50 | * Name : void LED_Toggle(uint8 u8Ch) 51 | * Function : LED toggle control 52 | * Input : uint8 u8Ch 0~255 Channel number of led 53 | * Output: : None 54 | * Return : None 55 | * Description: To be done. 56 | * Version : V1.00 57 | * Author : Ian 58 | * Date : 7th Dec 2016 59 | ******************************************************************************/ 60 | void LED_Toggle(uint8 u8Ch); 61 | 62 | /****************************************************************************** 63 | * Name : void LED_Off(uint8 u8Ch) 64 | * Function : LED Off control 65 | * Input : uint8 u8Ch 0~255 Channel number of led 66 | * Output: : None 67 | * Return : None 68 | * Description: To be done. 69 | * Version : V1.00 70 | * Author : Ian 71 | * Date : 7th Dec 2016 72 | ******************************************************************************/ 73 | void LED_Off(uint8 u8Ch); 74 | 75 | 76 | /****************************************************************************** 77 | * Name : void LED_On(uint8 u8Ch) 78 | * Function : LED On control 79 | * Input : uint8 u8Ch 0~255 Channel number of led 80 | * Output: : None 81 | * Return : None 82 | * Description: To be done. 83 | * Version : V1.00 84 | * Author : Ian 85 | * Date : 7th Dec 2016 86 | ******************************************************************************/ 87 | void LED_On(uint8 u8Ch); 88 | 89 | 90 | 91 | #ifdef __cplusplus 92 | } 93 | #endif 94 | 95 | #endif /* _BOARD_CONFIG_H */ 96 | 97 | /* End of file */ 98 | -------------------------------------------------------------------------------- /project/PT_Demo_Navota_1/MOE_Main.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * File : Moe_main.h 3 | * Function : Main start 4 | * Description: To be done. 5 | * Version : V1.00 6 | * Author : Ian 7 | * Date : 2nd Dec 2016 8 | * History : No. When Who What 9 | * 1 02/Dec/2016 Ian Create 10 | ******************************************************************************/ 11 | 12 | #ifndef _MOE_MAIN_H_ 13 | #define _MOE_MAIN_H_ 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | /* Check if specified option is set for debugging */ 20 | #ifndef __DEBUG_MODE_MAIN 21 | #define __DEBUG_MODE __DEBUG_NONE /* Default: None debugging info */ 22 | #else 23 | #ifdef __DEBUG_MODE 24 | #undef __DEBUG_MODE 25 | #endif 26 | #define __DEBUG_MODE __DEBUG_MODE_MAIN /* According the set from project_config.h */ 27 | #endif 28 | 29 | 30 | #ifdef __cplusplus 31 | } 32 | #endif 33 | 34 | #endif /* _MOE_MAIN_H */ 35 | 36 | /* End of file */ 37 | 38 | 39 | -------------------------------------------------------------------------------- /project/PT_Demo_Navota_1/MOE_main.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * File : Moe_main.c 3 | * Function : Main-start of the project. 4 | * Description: To be done. 5 | * Version : V1.00 6 | * Author : Ian 7 | * Date : 2nd Dec 2016 8 | * History : No. When Who What 9 | * 1 02/Dec/2016 Ian Create 10 | ******************************************************************************/ 11 | #include "type_def.h" 12 | #include "../../Pub/common_head.h" 13 | #include "./project_config.h" 14 | #include "./Moe_main.h" 15 | #include "../../Pub/debug.h" 16 | #include "../../Core/MOE_Core.h" 17 | #include "./Board_Config.h" 18 | 19 | __root const char cg_au8Version[] = MOE_VERSION" ("__DATE__" - " __TIME__ ")"; 20 | 21 | int main (void) 22 | { 23 | uint8 u8Idx; 24 | 25 | Board_Init(); /* Board init */ 26 | 27 | /* Print all loaded tasks */ 28 | DBG_PRINT("\n***** %s for %s*****\n", cg_au8Version, PLATFORM_NAME); 29 | DBG_PRINT("Task count is %d:\n",MAX_TASK_NUM); 30 | for(u8Idx = 0; u8Idx < MAX_TASK_NUM; u8Idx++) 31 | { 32 | DBG_PRINT("---Task No. is %3d : %s.\n", (u8Idx+1),cg_apu8TaskName[u8Idx]); 33 | } 34 | DBG_PRINT("\n\n"); 35 | 36 | /* Init MOE */ 37 | Moe_Init(SysTick_GetSysClk, NULL); 38 | 39 | /* Run MOE */ 40 | Moe_Run(); 41 | 42 | /* Never reach here */ 43 | return 0; 44 | } 45 | 46 | /* End of file */ 47 | 48 | 49 | -------------------------------------------------------------------------------- /project/PT_Demo_Navota_1/README.md: -------------------------------------------------------------------------------- 1 | # PT_Demo_Navota_1 2 | -- | Description 3 | ---------- | ------------------------------ 4 | Name | PT_Demo_Navota_1 5 | Function | Demo application of 2 protothread tasks: Task 1 controls the Green LED blinking; Task 2 print task infomation periodically 6 | Platform | Navota_1 7 | MCU | NV32F100F 8 | Type | ARM Cortex-M0+ 9 | Frequency | 48MHz 10 | RAM | 8K bytes 11 | ROM | 128K bytes 12 | peripheral | 3-color-LED * 1 13 | -- | Reset button * 1 14 | 15 | 16 | ![NV32F100F](https://github.com/ianhom/MOE/blob/master/Documents/Pic/Board/Navota-1.png?raw=true) 17 | 18 | 19 | -------------------------------------------------------------------------------- /project/PT_Demo_Navota_1/project_config.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * File : project_config.h 3 | * Function : project configuration. 4 | * Description: To be done. 5 | * Version : V1.00 6 | * Author : Ian 7 | * Date : 2nd DEC 2016 8 | * History : No. When Who What 9 | * 1 02/DEC/2016 Ian Create 10 | ******************************************************************************/ 11 | 12 | #ifndef _PROJECT_CONFIG_H_ 13 | #define _PROJECT_CONFIG_H_ 14 | 15 | 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | #include 22 | #include 23 | 24 | #define PLATFORM_NAME "NAVOTA" /* Platform name */ 25 | 26 | #define _STR(a) #a 27 | #define STR(a) _STR(a) 28 | /* Configure Zone */ 29 | 30 | /* Add your task process here */ 31 | #define LIST_OF_REG_TASK \ 32 | REG_TASK(Task_PT_Demo_Process)\ 33 | REG_TASK(Task_PT_Demo2_Process) 34 | 35 | 36 | #define REG_TASK(name) uint8 name(uint8 u8Evt, void *pPara); 37 | LIST_OF_REG_TASK 38 | #undef REG_TASK 39 | 40 | 41 | static const PF_TASK_PROCESS cg_apfTaskFn[] = 42 | { 43 | #define REG_TASK(name) name, 44 | LIST_OF_REG_TASK 45 | #undef REG_TASK 46 | }; 47 | 48 | static const uint8* cg_apu8TaskName[] = 49 | { 50 | #define REG_TASK(name) STR(name), 51 | LIST_OF_REG_TASK 52 | #undef REG_TASK 53 | }; 54 | 55 | #define MAX_TASK_NUM (sizeof(cg_apfTaskFn)/sizeof(cg_apfTaskFn[0])) /* Max number of tasks */ 56 | 57 | #define MAX_QUEUE_EVT_NUM (MAX_TASK_NUM * 10) 58 | 59 | #define __FLEXIBLE_ARRAY_NOT_SUPPORTED /* Complier does NOT support flexible array */ 60 | 61 | #define __TIMER_CALLBACK_SUPPORTED /* Timer callback is supported */ 62 | 63 | #define __DEBUG_ENABLE /* Debug mode is enabled */ 64 | 65 | #define __WANTED_A_LIVE_FOX /* Wanted: a live fox. */ 66 | 67 | /********************************************************* 68 | NOTE: You have four ways to use malloc: 69 | 1. Do not define __MALLOC_OPTION or define __MALLOC_OPTION 70 | as __MALLOC_STD, and Do not re-write the malloc and 71 | free function, you will use the standard malloc and 72 | free function in lib. 73 | 2. Do not define __MALLOC_OPTION or define __MALLOC_OPTION 74 | as __MALLOC_STD, and re-write the malloc and free 75 | function, you will use your malloc and free function, 76 | Please NOTE that the whole project use your malloc and 77 | free function 78 | 3. Define __MALLOC_OPTION as __MALLOC_MY, now your can use 79 | your own malloc and free function, however, if you use 80 | the same name with "malloc" and "free", whole project 81 | use your malloc and free just like situation 2. 82 | 4. Define __MALLOC_OPTION as __MALLOC_MOE, the Moe_Malloc 83 | and Moe_Free will be used. 84 | 85 | Options for __MALLOC_OPTION: 86 | __MALLOC_STD Use standard malloc and free 87 | __MALLOC_MOE Use MOE malloc and free 88 | __MALLOC_MY Use your malloc and free 89 | **********************************************************/ 90 | #define __MALLOC_OPTION __MALLOC_STD /* Use standard malloc and free funciton */ 91 | 92 | #ifdef __DEBUG_ENABLE 93 | #define __DEBUG_MODE_MAIN __DEBUG_BASIC_INFO 94 | #define __DEBUG_MODE_MOE_CORE __DEBUG_NONE 95 | #define __DEBUG_MODE_MOE_APP __DEBUG_NONE 96 | #define __DEBUG_MODE_MOE_TIMER __DEBUG_NONE 97 | #define __DEBUG_MODE_MOE_QUEUE __DEBUG_BASIC_INFO 98 | #define __DEBUG_MODE_MOE_MSG __DEBUG_NONE 99 | #define __DEBUG_MODE_MOE_EVENT __DEBUG_NONE 100 | #define __DEBUG_MODE_BOARD_CONFIG __DEBUG_BASIC_INFO 101 | #define __DEBUG_MODE_MOE_HAL __DEBUG_BASIC_INFO 102 | #define __DEBUG_MODE_PT_DEMO __DEBUG_BASIC_INFO 103 | #define __DEBUG_MODE_PT_DEMO2 __DEBUG_BASIC_INFO 104 | #endif 105 | 106 | #if (__MALLOC_OPTION == __MALLOC_MY) /* If you want to use your malloc and free */ 107 | #define MOE_MALLOC(size) My_Malloc(size) /* Add your malloc function here */ 108 | #define MOE_FREE(p) My_Free(p) /* Add your free function here */ 109 | #endif 110 | 111 | void LED_Off(uint8 u8Ch); 112 | #define TASK_PT_DEMO_LED_OFF LED_Off 113 | 114 | void LED_On(uint8 u8Ch); 115 | #define TASK_PT_DEMO_LED_ON LED_On 116 | 117 | #define LED_GREEN (3) /* Green led */ 118 | 119 | #ifdef __cplusplus 120 | } 121 | #endif 122 | 123 | #endif /* _PROJECT_CONFIG_H_ */ 124 | 125 | /* End of file */ 126 | 127 | 128 | -------------------------------------------------------------------------------- /project/PT_Demo_Nucleo_STM32L011K4/Board_Config.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * File : Board_Config.h 3 | * Function : Hardware configurations 4 | * Description: To be done. 5 | * Version : V1.00 6 | * Author : Ian 7 | * Date : 22nd Novl 2016 8 | * History : No. When Who What 9 | * 1 22/Nov/2016 Ian Create 10 | ******************************************************************************/ 11 | 12 | #ifndef _BOARD_CONFIG_H_ 13 | #define _BOARD_CONFIG_H_ 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | /* Check if specified option is set for debugging */ 20 | #ifndef __DEBUG_MODE_BOARD_CONFIG 21 | #define __DEBUG_MODE __DEBUG_NONE /* Default: None debugging info */ 22 | #else 23 | #ifdef __DEBUG_MODE 24 | #undef __DEBUG_MODE 25 | #endif 26 | #define __DEBUG_MODE __DEBUG_MODE_BOARD_CONFIG /* According the set from project_config.h */ 27 | #endif 28 | 29 | #define SYSTICK_CNT_FOR_1_MS (32000) 30 | 31 | #define BOARD_CONFIG_BTN_ST_HIGH (1) /* The voltage state of pin is HIGH */ 32 | #define BOARD_CONFIG_BTN_ST_LOW (0) /* The voltage state of pin is LOW */ 33 | 34 | #define BOARD_CONFIG_LED_BLUE (3) /* Blue led */ 35 | #define BOARD_CONFIG_LED_RED (2) /* Red led */ 36 | #define BOARD_CONFIG_LED_YELLOW (1) /* Yellow led */ 37 | #define BOARD_CONFIG_LED_GREEN (0) /* Green led */ 38 | 39 | #define BOARD_CONFIG_LED_ON (0) /* led ON mode */ 40 | #define BOARD_CONFIG_LED_OFF (1) /* led OFF mode */ 41 | #define BOARD_CONFIG_LED_TOGGLE (3) /* led Toggle mode */ 42 | 43 | 44 | /****************************************************************************** 45 | * Name : void LED_Off(uint8 u8Ch) 46 | * Function : LED Off control 47 | * Input : uint8 u8Ch 0~255 Channel number of led 48 | * Output: : None 49 | * Return : None 50 | * Description: To be done. 51 | * Version : V1.00 52 | * Author : Ian 53 | * Date : 22nd Nov 2016 54 | ******************************************************************************/ 55 | void LED_Off(uint8 u8Ch); 56 | 57 | /****************************************************************************** 58 | * Name : void LED_On(uint8 u8Ch) 59 | * Function : LED On control 60 | * Input : uint8 u8Ch 0~255 Channel number of led 61 | * Output: : None 62 | * Return : None 63 | * Description: To be done. 64 | * Version : V1.00 65 | * Author : Ian 66 | * Date : 22nd Nov 2016 67 | ******************************************************************************/ 68 | void LED_On(uint8 u8Ch); 69 | 70 | void Board_Init(void); 71 | void Board_Config_Reset_Ctrl(uint8 u8Val); 72 | void SysTick_Ms_Int_Init(uint32 u32Tick); 73 | uint32 SysTick_GetSysClk(void); 74 | 75 | #ifdef __cplusplus 76 | } 77 | #endif 78 | 79 | #endif /* _BOARD_CONFIG_H */ 80 | 81 | /* End of file */ 82 | 83 | 84 | -------------------------------------------------------------------------------- /project/PT_Demo_Nucleo_STM32L011K4/MOE_main.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * File : Moe_main.c 3 | * Function : Main-start of the project. 4 | * Description: To be done. 5 | * Version : V1.00 6 | * Author : Ian 7 | * Date : 21st Nov 2016 8 | * History : No. When Who What 9 | * 1 21/Nov/2016 Ian Create 10 | ******************************************************************************/ 11 | #include "type_def.h" 12 | #include "../../Pub/common_head.h" 13 | #include "./project_config.h" 14 | #include "./Moe_main.h" 15 | #include "../../Pub/debug.h" 16 | #include "../../Core/MOE_Core.h" 17 | #include "Board_Config.h" 18 | 19 | __root const char cg_au8Version[] = MOE_VERSION" ("__DATE__" - " __TIME__ ")"; 20 | 21 | int main (void) 22 | { 23 | uint8 u8Idx; 24 | 25 | Board_Init(); /* Board init */ 26 | 27 | /* Print all loaded tasks */ 28 | DBG_PRINT("\n***** %s for %s*****\n", cg_au8Version, PLATFORM_NAME); 29 | DBG_PRINT("Task count is %d:\n",MAX_TASK_NUM); 30 | for(u8Idx = 0; u8Idx < MAX_TASK_NUM; u8Idx++) 31 | { 32 | DBG_PRINT("---Task No. is %3d : %s.\n", (u8Idx+1),cg_apu8TaskName[u8Idx]); 33 | } 34 | DBG_PRINT("\n\n"); 35 | 36 | /* Init MOE */ 37 | Moe_Init(SysTick_GetSysClk, NULL); 38 | 39 | /* Run MOE */ 40 | Moe_Run(); 41 | 42 | /* Never reach here */ 43 | return 0; 44 | } 45 | 46 | /* End of file */ 47 | 48 | 49 | -------------------------------------------------------------------------------- /project/PT_Demo_Nucleo_STM32L011K4/MOE_main.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * File : Moe_main.h 3 | * Function : Main start 4 | * Description: To be done. 5 | * Version : V1.00 6 | * Author : Ian 7 | * Date : 22nd Nov 2016 8 | * History : No. When Who What 9 | * 1 22/Nov/2016 Ian Create 10 | ******************************************************************************/ 11 | 12 | #ifndef _MOE_MAIN_H_ 13 | #define _MOE_MAIN_H_ 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | /* Check if specified option is set for debugging */ 20 | #ifndef __DEBUG_MODE_MAIN 21 | #define __DEBUG_MODE __DEBUG_NONE /* Default: None debugging info */ 22 | #else 23 | #ifdef __DEBUG_MODE 24 | #undef __DEBUG_MODE 25 | #endif 26 | #define __DEBUG_MODE __DEBUG_MODE_MAIN /* According the set from project_config.h */ 27 | #endif 28 | 29 | 30 | #ifdef __cplusplus 31 | } 32 | #endif 33 | 34 | #endif /* _MOE_MAIN_H */ 35 | 36 | /* End of file */ 37 | 38 | 39 | -------------------------------------------------------------------------------- /project/PT_Demo_Nucleo_STM32L011K4/README.md: -------------------------------------------------------------------------------- 1 | # PT_Demo_Nucleo_STM32L011K4 2 | -- | Description 3 | ---------- | ------------------------------ 4 | Name | PT_Demo_Nucleo_STM32L011K4 5 | Function | Demo application of 2 protothread tasks: Task 1 controls the Green LED blinking; Task 2 print task infomation periodically 6 | Platform | Nucleo_STM32L011K4 7 | MCU | STM32L011K4 8 | Type | ARM Cortex-M0+ 9 | Frequency | 32MHz 10 | RAM | 2K bytes 11 | ROM | 16K bytes 12 | peripheral | LED * 1 13 | -- | Reset button * 1 14 | 15 | 16 | 17 | ![Nucleo_STM32L011K4](https://github.com/ianhom/MOE/blob/master/Documents/Pic/Nucleo-L011K4.jpg?raw=true) 18 | 19 | ## PinOut 20 | ![Nucleo_32_PinOut](https://github.com/ianhom/MOE/blob/master/Documents/Pic/Nucleo3_PinOut.png?raw=true) 21 | -------------------------------------------------------------------------------- /project/PT_Demo_Nucleo_STM32L011K4/project_config.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * File : project_config.h 3 | * Function : project configuration. 4 | * Description: To be done. 5 | * Version : V1.00 6 | * Author : Ian 7 | * Date : 22nd Nov 2016 8 | * History : No. When Who What 9 | * 1 22/Nov/2016 Ian Create 10 | ******************************************************************************/ 11 | 12 | #ifndef _PROJECT_CONFIG_H_ 13 | #define _PROJECT_CONFIG_H_ 14 | 15 | 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | #include 22 | #include 23 | 24 | #define PLATFORM_NAME "STM32L011K4" /* Platform name */ 25 | 26 | #define _STR(a) #a 27 | #define STR(a) _STR(a) 28 | /* Configure Zone */ 29 | 30 | /* Add your task process here */ 31 | #define LIST_OF_REG_TASK \ 32 | REG_TASK(Task_PT_Demo_Process)\ 33 | REG_TASK(Task_PT_Demo2_Process) 34 | 35 | 36 | #define REG_TASK(name) uint8 name(uint8 u8Evt, void *pPara); 37 | LIST_OF_REG_TASK 38 | #undef REG_TASK 39 | 40 | 41 | static const PF_TASK_PROCESS cg_apfTaskFn[] = 42 | { 43 | #define REG_TASK(name) name, 44 | LIST_OF_REG_TASK 45 | #undef REG_TASK 46 | }; 47 | 48 | static const uint8* cg_apu8TaskName[] = 49 | { 50 | #define REG_TASK(name) STR(name), 51 | LIST_OF_REG_TASK 52 | #undef REG_TASK 53 | }; 54 | 55 | /* Critical zone define */ 56 | #define ENTER_CRITICAL_ZONE(x) x=1; 57 | #define EXIT_CRITICAL_ZONE(x) if(1 == x) x=0; 58 | 59 | 60 | #define MAX_TASK_NUM (sizeof(cg_apfTaskFn)/sizeof(cg_apfTaskFn[0])) /* Max number of tasks */ 61 | 62 | #define MAX_QUEUE_EVT_NUM (MAX_TASK_NUM * 10) 63 | 64 | #define __FLEXIBLE_ARRAY_NOT_SUPPORTED /* Complier does NOT support flexible array */ 65 | 66 | #define __TIMER_CALLBACK_SUPPORTED /* Timer callback is supported */ 67 | 68 | #define __DEBUG_ENABLE /* Debug mode is enabled */ 69 | 70 | #define __WANTED_A_LIVE_FOX /* Wanted: a live fox. */ 71 | 72 | /********************************************************* 73 | NOTE: You have four ways to use malloc: 74 | 1. Do not define __MALLOC_OPTION or define __MALLOC_OPTION 75 | as __MALLOC_STD, and Do not re-write the malloc and 76 | free function, you will use the standard malloc and 77 | free function in lib. 78 | 2. Do not define __MALLOC_OPTION or define __MALLOC_OPTION 79 | as __MALLOC_STD, and re-write the malloc and free 80 | function, you will use your malloc and free function, 81 | Please NOTE that the whole project use your malloc and 82 | free function 83 | 3. Define __MALLOC_OPTION as __MALLOC_MY, now your can use 84 | your own malloc and free function, however, if you use 85 | the same name with "malloc" and "free", whole project 86 | use your malloc and free just like situation 2. 87 | 4. Define __MALLOC_OPTION as __MALLOC_MOE, the Moe_Malloc 88 | and Moe_Free will be used. 89 | 90 | Options for __MALLOC_OPTION: 91 | __MALLOC_STD Use standard malloc and free 92 | __MALLOC_MOE Use MOE malloc and free 93 | __MALLOC_MY Use your malloc and free 94 | **********************************************************/ 95 | #define __MALLOC_OPTION __MALLOC_STD /* Use standard malloc and free funciton */ 96 | 97 | #ifdef __DEBUG_ENABLE 98 | #define __DEBUG_MODE_MAIN __DEBUG_BASIC_INFO 99 | #define __DEBUG_MODE_MOE_CORE __DEBUG_NONE 100 | #define __DEBUG_MODE_MOE_APP __DEBUG_NONE 101 | #define __DEBUG_MODE_MOE_TIMER __DEBUG_NONE 102 | #define __DEBUG_MODE_MOE_QUEUE __DEBUG_BASIC_INFO 103 | #define __DEBUG_MODE_MOE_MSG __DEBUG_NONE 104 | #define __DEBUG_MODE_MOE_EVENT __DEBUG_NONE 105 | #define __DEBUG_MODE_BOARD_CONFIG __DEBUG_BASIC_INFO 106 | #define __DEBUG_MODE_MOE_HAL __DEBUG_BASIC_INFO 107 | #define __DEBUG_MODE_PT_DEMO __DEBUG_BASIC_INFO 108 | #define __DEBUG_MODE_PT_DEMO2 __DEBUG_BASIC_INFO 109 | #endif 110 | 111 | #if (__MALLOC_OPTION == __MALLOC_MY) /* If you want to use your malloc and free */ 112 | #define MOE_MALLOC(size) My_Malloc(size) /* Add your malloc function here */ 113 | #define MOE_FREE(p) My_Free(p) /* Add your free function here */ 114 | #endif 115 | 116 | void LED_Off(uint8 u8Ch); 117 | #define TASK_PT_DEMO_LED_OFF LED_Off 118 | 119 | void LED_On(uint8 u8Ch); 120 | #define TASK_PT_DEMO_LED_ON LED_On 121 | 122 | #define LED_GREEN (3) /* Green led */ 123 | 124 | #ifdef __cplusplus 125 | } 126 | #endif 127 | 128 | #endif /* _PROJECT_CONFIG_H_ */ 129 | 130 | /* End of file */ 131 | 132 | 133 | -------------------------------------------------------------------------------- /project/PT_Demo_STM32F407_SP1/Board_Config.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * File : Board_Config.c 3 | * Function : Hardware configurations 4 | * Description: To be done. 5 | * Version : V1.00 6 | * Author : Ian 7 | * Date : 22nd Nov 2016 8 | * History : No. When Who What 9 | * 1 22/Nov/2016 Ian Create 10 | ******************************************************************************/ 11 | #include "type_def.h" 12 | #include "../../Pub/common_head.h" 13 | #include "./project_config.h" 14 | #include "../../Core/MOE_Core.h" 15 | #include "../../Core/MOE_Event.h" 16 | #include "../../Core/MOE_Timer.h" 17 | #include "../../Core/MOE_Msg.h" 18 | #include "./Board_Config.h" 19 | #include "../../Pub/debug.h" 20 | #include "../../Driver/MCU/Common/ARM_Cortex_M/MOE_SysTick.h" 21 | #include "stm32f4xx_hal.h" 22 | 23 | UART_HandleTypeDef huart; 24 | 25 | /* Private function prototypes -----------------------------------------------*/ 26 | void SystemClock_Config(void); 27 | void Error_Handler(void); 28 | static void MX_GPIO_Init(void); 29 | static void MX_USART_UART_Init(void); 30 | 31 | volatile static uint32 sg_u32SysClk = 0; 32 | 33 | static uint16 au16LedPin[2] = {LED_1_PIN , LED_2_PIN}; 34 | static GPIO_TypeDef *aptLedPort[2] = {LED_1_PORT, LED_2_PORT}; 35 | /****************************************************************************** 36 | * Name : void Board_Init(void) 37 | * Function : Init board includes system clock, GPIOs, Uart and Systick 38 | * Input : None 39 | * Output: : None 40 | * Return : None 41 | * Description: To be done. 42 | * Version : V1.00 43 | * Author : Ian 44 | * Date : 21st Nov 2016 45 | ******************************************************************************/ 46 | void Board_Init(void) 47 | { 48 | HAL_Init(); 49 | 50 | /* Configure the system clock */ 51 | SystemClock_Config(); 52 | 53 | /* Initialize all configured peripherals */ 54 | MX_GPIO_Init(); 55 | MX_USART_UART_Init(); 56 | 57 | SysTick_Ms_Int_Init(SYSTICK_CNT_FOR_1_MS); 58 | return; 59 | } 60 | 61 | int fputc(int u8C, FILE *p) 62 | { 63 | while(!(USART1->SR & USART_SR_TXE)); 64 | USART1->DR = u8C; 65 | return 0; 66 | } 67 | 68 | /** System Clock Configuration*/ 69 | void SystemClock_Config(void) 70 | { 71 | 72 | RCC_OscInitTypeDef RCC_OscInitStruct; 73 | RCC_ClkInitTypeDef RCC_ClkInitStruct; 74 | 75 | __HAL_RCC_PWR_CLK_ENABLE(); 76 | 77 | __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); 78 | 79 | RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI; 80 | RCC_OscInitStruct.HSIState = RCC_HSI_ON; 81 | RCC_OscInitStruct.HSICalibrationValue = 16; 82 | RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE; 83 | if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) 84 | { 85 | Error_Handler(); 86 | } 87 | 88 | RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK 89 | |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; 90 | RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSI; 91 | RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; 92 | RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; 93 | RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; 94 | if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0) != HAL_OK) 95 | { 96 | Error_Handler(); 97 | } 98 | 99 | HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000); 100 | 101 | HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK); 102 | 103 | /* SysTick_IRQn interrupt configuration */ 104 | HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0); 105 | } 106 | 107 | /* USART init function */ 108 | static void MX_USART_UART_Init(void) 109 | { 110 | 111 | huart.Instance = USART_INSTANCE; 112 | huart.Init.BaudRate = 115200; 113 | huart.Init.WordLength = UART_WORDLENGTH_8B; 114 | huart.Init.StopBits = UART_STOPBITS_1; 115 | huart.Init.Parity = UART_PARITY_NONE; 116 | huart.Init.Mode = UART_MODE_TX_RX; 117 | huart.Init.HwFlowCtl = UART_HWCONTROL_NONE; 118 | huart.Init.OverSampling = UART_OVERSAMPLING_16; 119 | if (HAL_UART_Init(&huart) != HAL_OK) 120 | { 121 | Error_Handler(); 122 | } 123 | 124 | } 125 | 126 | /** Configure pins as 127 | * Analog 128 | * Input 129 | * Output 130 | * EVENT_OUT 131 | * EXTI 132 | */ 133 | static void MX_GPIO_Init(void) 134 | { 135 | 136 | GPIO_InitTypeDef GPIO_InitStruct; 137 | 138 | /* GPIO Ports Clock Enable */ 139 | __HAL_RCC_GPIOH_CLK_ENABLE(); 140 | __HAL_RCC_GPIOA_CLK_ENABLE(); 141 | 142 | /*Configure GPIO pin Output Level */ 143 | HAL_GPIO_WritePin(GPIOA, GPIO_PIN_6|GPIO_PIN_7, GPIO_PIN_RESET); 144 | 145 | /*Configure GPIO pins : PA6 PA7 */ 146 | GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_7; 147 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; 148 | GPIO_InitStruct.Pull = GPIO_NOPULL; 149 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 150 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); 151 | 152 | } 153 | 154 | void Board_LED_Toggle(uint8 u8Ch) 155 | { 156 | switch(u8Ch) 157 | { 158 | case LED_1: 159 | case LED_2: 160 | { 161 | HAL_GPIO_TogglePin(aptLedPort[u8Ch - LED_1], au16LedPin[u8Ch - LED_1]); 162 | break; 163 | } 164 | default: 165 | { 166 | break; 167 | } 168 | } 169 | return; 170 | } 171 | 172 | void Error_Handler(void) 173 | { 174 | while(1); 175 | } 176 | 177 | 178 | /* End of file */ 179 | 180 | -------------------------------------------------------------------------------- /project/PT_Demo_STM32F407_SP1/Board_Config.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * File : Board_Config.h 3 | * Function : Hardware configurations 4 | * Description: To be done. 5 | * Version : V1.00 6 | * Author : Ian 7 | * Date : 22nd Novl 2016 8 | * History : No. When Who What 9 | * 1 22/Nov/2016 Ian Create 10 | ******************************************************************************/ 11 | 12 | #ifndef _BOARD_CONFIG_H_ 13 | #define _BOARD_CONFIG_H_ 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | /* Check if specified option is set for debugging */ 20 | #ifndef __DEBUG_MODE_BOARD_CONFIG 21 | #define __DEBUG_MODE __DEBUG_NONE /* Default: None debugging info */ 22 | #else 23 | #ifdef __DEBUG_MODE 24 | #undef __DEBUG_MODE 25 | #endif 26 | #define __DEBUG_MODE __DEBUG_MODE_BOARD_CONFIG /* According the set from project_config.h */ 27 | #endif 28 | 29 | #define SYSTICK_CNT_FOR_1_MS (16000) 30 | 31 | #define BOARD_CONFIG_BTN_ST_HIGH (1) /* The voltage state of pin is HIGH */ 32 | #define BOARD_CONFIG_BTN_ST_LOW (0) /* The voltage state of pin is LOW */ 33 | 34 | #define BOARD_CONFIG_LED_BLUE (3) /* Blue led */ 35 | #define BOARD_CONFIG_LED_RED (2) /* Red led */ 36 | #define BOARD_CONFIG_LED_YELLOW (1) /* Yellow led */ 37 | #define BOARD_CONFIG_LED_GREEN (0) /* Green led */ 38 | 39 | #define BOARD_CONFIG_LED_ON (0) /* led ON mode */ 40 | #define BOARD_CONFIG_LED_OFF (1) /* led OFF mode */ 41 | #define BOARD_CONFIG_LED_TOGGLE (3) /* led Toggle mode */ 42 | 43 | 44 | /****************************************************************************** 45 | * Name : void LED_Off(uint8 u8Ch) 46 | * Function : LED Off control 47 | * Input : uint8 u8Ch 0~255 Channel number of led 48 | * Output: : None 49 | * Return : None 50 | * Description: To be done. 51 | * Version : V1.00 52 | * Author : Ian 53 | * Date : 22nd Nov 2016 54 | ******************************************************************************/ 55 | void LED_Off(uint8 u8Ch); 56 | 57 | /****************************************************************************** 58 | * Name : void LED_On(uint8 u8Ch) 59 | * Function : LED On control 60 | * Input : uint8 u8Ch 0~255 Channel number of led 61 | * Output: : None 62 | * Return : None 63 | * Description: To be done. 64 | * Version : V1.00 65 | * Author : Ian 66 | * Date : 22nd Nov 2016 67 | ******************************************************************************/ 68 | void LED_On(uint8 u8Ch); 69 | 70 | void Board_Init(void); 71 | void Board_Config_Reset_Ctrl(uint8 u8Val); 72 | void SysTick_Ms_Int_Init(uint32 u32Tick); 73 | uint32 SysTick_GetSysClk(void); 74 | 75 | #ifdef __cplusplus 76 | } 77 | #endif 78 | 79 | #endif /* _BOARD_CONFIG_H */ 80 | 81 | /* End of file */ 82 | 83 | 84 | -------------------------------------------------------------------------------- /project/PT_Demo_STM32F407_SP1/MOE_main.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * File : Moe_main.c 3 | * Function : Main-start of the project. 4 | * Description: To be done. 5 | * Version : V1.00 6 | * Author : Ian 7 | * Date : 21st Nov 2016 8 | * History : No. When Who What 9 | * 1 21/Nov/2016 Ian Create 10 | ******************************************************************************/ 11 | #include "type_def.h" 12 | #include "../../Pub/common_head.h" 13 | #include "./project_config.h" 14 | #include "./Moe_main.h" 15 | #include "../../Pub/debug.h" 16 | #include "../../Core/MOE_Core.h" 17 | #include "Board_Config.h" 18 | 19 | const char cg_au8Version[] = MOE_VERSION" ("__DATE__" - " __TIME__ ")"; 20 | 21 | int main (void) 22 | { 23 | uint8 u8Idx; 24 | 25 | Board_Init(); /* Board init */ 26 | 27 | /* Print all loaded tasks */ 28 | DBG_PRINT("\n***** %s for %s*****\n", cg_au8Version, PLATFORM_NAME); 29 | DBG_PRINT("Task count is %d:\n",MAX_TASK_NUM); 30 | for(u8Idx = 0; u8Idx < MAX_TASK_NUM; u8Idx++) 31 | { 32 | DBG_PRINT("---Task No. is %3d : %s.\n", (u8Idx+1),cg_apu8TaskName[u8Idx]); 33 | } 34 | DBG_PRINT("\n\n"); 35 | 36 | /* Init MOE */ 37 | Moe_Init(SysTick_GetSysClk, NULL); 38 | 39 | /* Run MOE */ 40 | Moe_Run(); 41 | 42 | /* Never reach here */ 43 | return 0; 44 | } 45 | 46 | /* End of file */ 47 | 48 | 49 | -------------------------------------------------------------------------------- /project/PT_Demo_STM32F407_SP1/MOE_main.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * File : Moe_main.h 3 | * Function : Main start 4 | * Description: To be done. 5 | * Version : V1.00 6 | * Author : Ian 7 | * Date : 22nd Nov 2016 8 | * History : No. When Who What 9 | * 1 22/Nov/2016 Ian Create 10 | ******************************************************************************/ 11 | 12 | #ifndef _MOE_MAIN_H_ 13 | #define _MOE_MAIN_H_ 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | /* Check if specified option is set for debugging */ 20 | #ifndef __DEBUG_MODE_MAIN 21 | #define __DEBUG_MODE __DEBUG_NONE /* Default: None debugging info */ 22 | #else 23 | #ifdef __DEBUG_MODE 24 | #undef __DEBUG_MODE 25 | #endif 26 | #define __DEBUG_MODE __DEBUG_MODE_MAIN /* According the set from project_config.h */ 27 | #endif 28 | 29 | 30 | #ifdef __cplusplus 31 | } 32 | #endif 33 | 34 | #endif /* _MOE_MAIN_H */ 35 | 36 | /* End of file */ 37 | 38 | 39 | -------------------------------------------------------------------------------- /project/PT_Demo_STM32F407_SP1/README.md: -------------------------------------------------------------------------------- 1 | # PT_Demo_STM32F407 2 | -- | Description 3 | ---------- | ------------------------------ 4 | Name | PT_Demo_STM32F407 5 | Function | Demo application of 2 protothread tasks: Task 1 controls the 2 LEDS blinking; Task 2 prints task infomation periodically 6 | Platform | HengBo_DEV_BOARD_STM32F407 7 | MCU | STM32F407 8 | Type | ARM Cortex-M4 9 | Frequency | 168MHz 10 | RAM | 192K bytes 11 | ROM | 512K bytes 12 | peripheral | LED * 2 13 | -- | Reset button * 1 14 | -- | User button * 2 15 | 16 | 17 | ![STM32F407](https://github.com/ianhom/MOE/blob/master/Documents/Pic/Board/STM32F407VE.png?raw=true) 18 | -------------------------------------------------------------------------------- /project/PT_Demo_STM32F407_SP1/project_config.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * File : project_config.h 3 | * Function : project configuration. 4 | * Description: To be done. 5 | * Version : V1.00 6 | * Author : Ian 7 | * Date : 22nd Nov 2016 8 | * History : No. When Who What 9 | * 1 22/Nov/2016 Ian Create 10 | ******************************************************************************/ 11 | 12 | #ifndef _PROJECT_CONFIG_H_ 13 | #define _PROJECT_CONFIG_H_ 14 | 15 | 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | #include 22 | #include 23 | 24 | #define PLATFORM_NAME "STM32F407VET6_SP1" /* Platform name */ 25 | 26 | #define _STR(a) #a 27 | #define STR(a) _STR(a) 28 | /* Configure Zone */ 29 | 30 | /* Add your task process here */ 31 | #define LIST_OF_REG_TASK\ 32 | REG_TASK(Task_PT_Demo_Process)\ 33 | REG_TASK(Task_PT_Demo2_Process)\ 34 | REG_TASK(Task_PT_Demo3_Process) 35 | 36 | #define REG_TASK(name) uint8 name(uint8 u8Evt, void *pPara); 37 | LIST_OF_REG_TASK 38 | #undef REG_TASK 39 | 40 | 41 | static const PF_TASK_PROCESS cg_apfTaskFn[] = 42 | { 43 | #define REG_TASK(name) name, 44 | LIST_OF_REG_TASK 45 | #undef REG_TASK 46 | }; 47 | 48 | static const uint8* cg_apu8TaskName[] = 49 | { 50 | #define REG_TASK(name) STR(name), 51 | LIST_OF_REG_TASK 52 | #undef REG_TASK 53 | }; 54 | 55 | /* Critical zone define */ 56 | #define ENTER_CRITICAL_ZONE(x) do{x=1;}while(0) 57 | #define EXIT_CRITICAL_ZONE(x) do{if(1 == x) x=0;}while(0) 58 | 59 | 60 | #define MAX_TASK_NUM (sizeof(cg_apfTaskFn)/sizeof(cg_apfTaskFn[0])) /* Max number of tasks */ 61 | 62 | #define MAX_QUEUE_EVT_NUM (MAX_TASK_NUM * 10) 63 | 64 | #define __FLEXIBLE_ARRAY_NOT_SUPPORTED /* Complier does NOT support flexible array */ 65 | 66 | #define __TIMER_CALLBACK_SUPPORTED /* Timer callback is supported */ 67 | 68 | #define __DEBUG_ENABLE /* Debug mode is enabled */ 69 | 70 | #define __WANTED_A_LIVE_FOX /* Wanted a live Fox */ 71 | 72 | /********************************************************* 73 | NOTE: You have four ways to use malloc: 74 | 1. Do not define __MALLOC_OPTION or define __MALLOC_OPTION 75 | as __MALLOC_STD, and Do not re-write the malloc and 76 | free function, you will use the standard malloc and 77 | free function in lib. 78 | 2. Do not define __MALLOC_OPTION or define __MALLOC_OPTION 79 | as __MALLOC_STD, and re-write the malloc and free 80 | function, you will use your malloc and free function, 81 | Please NOTE that the whole project use your malloc and 82 | free function 83 | 3. Define __MALLOC_OPTION as __MALLOC_MY, now your can use 84 | your own malloc and free function, however, if you use 85 | the same name with "malloc" and "free", whole project 86 | use your malloc and free just like situation 2. 87 | 4. Define __MALLOC_OPTION as __MALLOC_MOE, the Moe_Malloc 88 | and Moe_Free will be used. 89 | 90 | Options for __MALLOC_OPTION: 91 | __MALLOC_STD Use standard malloc and free 92 | __MALLOC_MOE Use MOE malloc and free 93 | __MALLOC_MY Use your malloc and free 94 | **********************************************************/ 95 | #define __MALLOC_OPTION __MALLOC_STD /* Use standard malloc and free funciton */ 96 | 97 | #ifdef __DEBUG_ENABLE 98 | #define __DEBUG_MODE_MAIN __DEBUG_BASIC_INFO 99 | #define __DEBUG_MODE_MOE_CORE __DEBUG_NONE 100 | #define __DEBUG_MODE_MOE_APP __DEBUG_NONE 101 | #define __DEBUG_MODE_MOE_TIMER __DEBUG_NONE 102 | #define __DEBUG_MODE_MOE_QUEUE __DEBUG_BASIC_INFO 103 | #define __DEBUG_MODE_MOE_MSG __DEBUG_NONE 104 | #define __DEBUG_MODE_MOE_EVENT __DEBUG_NONE 105 | #define __DEBUG_MODE_BOARD_CONFIG __DEBUG_BASIC_INFO 106 | #define __DEBUG_MODE_MOE_HAL __DEBUG_BASIC_INFO 107 | #define __DEBUG_MODE_PT_DEMO __DEBUG_BASIC_INFO 108 | #define __DEBUG_MODE_PT_DEMO2 __DEBUG_BASIC_INFO 109 | #define __DEBUG_MODE_PT_DEMO3 __DEBUG_BASIC_INFO 110 | #endif 111 | 112 | #if (__MALLOC_OPTION == __MALLOC_MY) /* If you want to use your malloc and free */ 113 | #define MOE_MALLOC(size) My_Malloc(size) /* Add your malloc function here */ 114 | #define MOE_FREE(p) My_Free(p) /* Add your free function here */ 115 | #endif 116 | 117 | 118 | void Board_LED_Toggle(uint8 u8Ch); 119 | #define TASK_PT_DEMO_LED_TOGGLE Board_LED_Toggle 120 | 121 | #define LED_1 (1) /* Led 1 */ 122 | #define LED_2 (2) /* Led 1 */ 123 | 124 | /* Pin description */ 125 | #define LED_1_PORT (GPIOA) 126 | #define LED_1_PIN (GPIO_PIN_6) 127 | 128 | #define LED_2_PORT (GPIOA) 129 | #define LED_2_PIN (GPIO_PIN_7) 130 | 131 | #define USART_INSTANCE (USART1) 132 | 133 | #ifdef __cplusplus 134 | } 135 | #endif 136 | 137 | #endif /* _PROJECT_CONFIG_H_ */ 138 | 139 | /* End of file */ 140 | 141 | 142 | -------------------------------------------------------------------------------- /project/README.md: -------------------------------------------------------------------------------- 1 | #MOE projects 2 | This folder contains applications of different projects 3 | 4 | Project | Description 5 | -------------------------- | ------------ 6 | Basic_Demo_KL25 | Basic project to demo mutli-task based on FRDM-KL25Z board 7 | PT_Demo_KL25 | Protothread demo project based on FRDM-KL25Z board 8 | PT_Demo_KL27_MiniBoard | Protothread demo project based on KL27_MiniBoard 9 | PT_Demo_Nucleo_STM32L011K4 | Protothread demo project based on Nucleo_STM32L011K4 10 | PT_Demo_Navota_1 | Protothread demo project based on Navota_1 11 | PT_Demo_EFM32HG322_3400A   | Protothread demo project based on EFM32HG322_3400A 12 | PT_Demo_MIMXRT1050-EVK | Protothread demo project based on MIMXRT1050-EVK 13 | --------------------------------------------------------------------------------