diff --git a/TODO.md b/TODO.md index c9b1b3146dc82145f2165708cc0a2a666e06f3cd..389a9280f083f4da84b9b2ea49633d8a2837e896 100644 --- a/TODO.md +++ b/TODO.md @@ -1,4 +1,16 @@ # TODO +----------- +eLab V0.2 需要完成的内容 +1. 确保V0.1的程序能够正常运行。 +2. 完成版本说明里关于V0.1的内容。 +3. V0.2 export的健壮实现。 +4. V0.2 edf的实现,尤其是串口。 +5. V0.2 贪吃蛇的例程 +6. button设备 +7. LED设备 +8. OLED屏程序 +9. 开发板自测程序。 + ----------- 1. 【完成】printf的实现 2. 【完成】assert的实现 diff --git a/board/GoldenBoard/driver/drv_adc.c b/board/GoldenBoard/driver/drv_adc.c index bb517875ae7d89d70e254172d641e1f60caa0bde..32a8d2fa126818ff988519e17363008b2f4b9a3b 100644 --- a/board/GoldenBoard/driver/drv_adc.c +++ b/board/GoldenBoard/driver/drv_adc.c @@ -6,10 +6,10 @@ /* includes ----------------------------------------------------------------- */ #include -#include "eLab/edf/normal/elab_adc.h" -#include "eLab/common/elab_assert.h" -#include "eLab/common/elab_def.h" -#include "eLab/common/elab_export.h" +#include "elab/edf/normal/elab_adc.h" +#include "elab/common/elab_assert.h" +#include "elab/common/elab_def.h" +#include "elab/common/elab_export.h" #include "stm32g0xx_hal.h" #ifdef __cplusplus diff --git a/board/GoldenBoard/driver/drv_pin.c b/board/GoldenBoard/driver/drv_pin.c index a1039fcf9e49f50350c775d484639684460a7c04..5795dba06ec3af290cfc0eff3c8cbbda3438fd54 100644 --- a/board/GoldenBoard/driver/drv_pin.c +++ b/board/GoldenBoard/driver/drv_pin.c @@ -6,10 +6,10 @@ /* includes ----------------------------------------------------------------- */ #include -#include "eLab/edf/normal/elab_pin.h" -#include "eLab/common/elab_assert.h" -#include "eLab/common/elab_def.h" -#include "eLab/common/elab_export.h" +#include "elab/edf/normal/elab_pin.h" +#include "elab/common/elab_assert.h" +#include "elab/common/elab_def.h" +#include "elab/common/elab_export.h" #include "stm32g0xx_hal.h" #ifdef __cplusplus diff --git a/board/GoldenBoard/driver/drv_pwm.c b/board/GoldenBoard/driver/drv_pwm.c index 8265a99925a0528b8fcb796044b5599778751c27..9056ec2c43674304d30b60135b1fa71d8e7dbbbe 100644 --- a/board/GoldenBoard/driver/drv_pwm.c +++ b/board/GoldenBoard/driver/drv_pwm.c @@ -5,10 +5,10 @@ */ /* includes ----------------------------------------------------------------- */ -#include "eLab/edf/normal/elab_pwm.h" +#include "elab/edf/normal/elab_pwm.h" #include "stm32g0xx_hal.h" -#include "eLab/common/elab_export.h" -#include "eLab/common/elab_assert.h" +#include "elab/common/elab_export.h" +#include "elab/common/elab_assert.h" #ifdef __cplusplus extern "C" { diff --git a/board/GoldenBoard/driver/drv_spi.c b/board/GoldenBoard/driver/drv_spi.c index 090a2df8822b96b125a71e08f7826dc3f7c5f1c8..0aef4ab22382265c318ab9a47f3baeb23286b050 100644 --- a/board/GoldenBoard/driver/drv_spi.c +++ b/board/GoldenBoard/driver/drv_spi.c @@ -6,10 +6,10 @@ /* includes ----------------------------------------------------------------- */ #include -#include "eLab/edf/normal/elab_spi.h" -#include "eLab/common/elab_assert.h" -#include "eLab/common/elab_def.h" -#include "eLab/common/elab_export.h" +#include "elab/edf/normal/elab_spi.h" +#include "elab/common/elab_assert.h" +#include "elab/common/elab_def.h" +#include "elab/common/elab_export.h" #include "stm32g0xx_hal.h" #ifdef __cplusplus diff --git a/board/GoldenBoard/test/test_adc.c b/board/GoldenBoard/test/test_adc.c index 2b5131b2cdb82e182203598e5c59158f2e5a79c6..e91e9a0cba6fb183cb8acdc1a052d6884bc19a24 100644 --- a/board/GoldenBoard/test/test_adc.c +++ b/board/GoldenBoard/test/test_adc.c @@ -8,11 +8,11 @@ #include #include #include -#include "eLab/3rd/Shell/shell.h" -#include "eLab/edf/normal/elab_adc.h" +#include "elab/3rd/Shell/shell.h" +#include "elab/edf/normal/elab_adc.h" #define TAG "AdcTest" -#include "eLab/common/elab_log.h" +#include "elab/common/elab_log.h" #ifdef __cplusplus extern "C" { diff --git a/board/GoldenBoard/test/test_led.c b/board/GoldenBoard/test/test_led.c index e76e8c1b8f9b52aff67783e4c6a939b4d80d646c..aa07407c609a9cc71b647fb135b6379c66836775 100644 --- a/board/GoldenBoard/test/test_led.c +++ b/board/GoldenBoard/test/test_led.c @@ -8,8 +8,8 @@ #include #include #include -#include "eLab/3rd/Shell/shell.h" -#include "eLab/edf/normal/elab_pin.h" +#include "elab/3rd/Shell/shell.h" +#include "elab/edf/normal/elab_pin.h" #ifdef __cplusplus extern "C" { diff --git a/board/GoldenBoard/test/test_pwm.c b/board/GoldenBoard/test/test_pwm.c index 537066efaaff02e316402e14cab033ac8aed5e76..da6083609ac85a54d46bbbff548e25f208bf83f0 100644 --- a/board/GoldenBoard/test/test_pwm.c +++ b/board/GoldenBoard/test/test_pwm.c @@ -9,8 +9,8 @@ #include #include #include -#include "eLab/3rd/Shell/shell.h" -#include "eLab/edf/normal/elab_pwm.h" +#include "elab/3rd/Shell/shell.h" +#include "elab/edf/normal/elab_pwm.h" #ifdef __cplusplus extern "C" { diff --git a/elab/3rd/FreeRTOS/croutine.c b/elab/3rd/FreeRTOS/croutine.c index 9ce50030d3ffc1f7801f92cd35fb5073c39a8670..4dc208aacb243a5d6280bfb203b926888b22fb2c 100644 --- a/elab/3rd/FreeRTOS/croutine.c +++ b/elab/3rd/FreeRTOS/croutine.c @@ -25,9 +25,9 @@ * 1 tab == 4 spaces! */ -#include "FreeRTOS.h" -#include "task.h" -#include "croutine.h" +#include "include/FreeRTOS.h" +#include "include/task.h" +#include "include/croutine.h" /* Remove the whole file is co-routines are not being used. */ #if( configUSE_CO_ROUTINES != 0 ) diff --git a/elab/3rd/FreeRTOS/event_groups.c b/elab/3rd/FreeRTOS/event_groups.c index bf4ec246a84ca5a97b7d8f62e987005040e717ce..ae31f317d88db5c6c615dff1cc4cb069fdf8a446 100644 --- a/elab/3rd/FreeRTOS/event_groups.c +++ b/elab/3rd/FreeRTOS/event_groups.c @@ -34,10 +34,10 @@ task.h is included from an application file. */ #define MPU_WRAPPERS_INCLUDED_FROM_API_FILE /* FreeRTOS includes. */ -#include "FreeRTOS.h" -#include "task.h" -#include "timers.h" -#include "event_groups.h" +#include "include/FreeRTOS.h" +#include "include/task.h" +#include "include/timers.h" +#include "include/event_groups.h" /* Lint e961, e750 and e9021 are suppressed as a MISRA exception justified because the MPU ports require MPU_WRAPPERS_INCLUDED_FROM_API_FILE to be defined diff --git a/elab/3rd/FreeRTOS/include/portable.h b/elab/3rd/FreeRTOS/include/portable.h index a2099c33dd3c1e5390cf883676f2a11b9dd4fc2e..c3054ccaf94e1d0cb2f655f59000414c3d351c6e 100644 --- a/elab/3rd/FreeRTOS/include/portable.h +++ b/elab/3rd/FreeRTOS/include/portable.h @@ -49,8 +49,12 @@ did not result in a portmacro.h header file being included - and it should be included here. In this case the path to the correct portmacro.h header file must be set in the compiler's include path. */ #ifndef portENTER_CRITICAL +#if defined(_WIN32) + #include "../portable/mingw/portmacro.h" +#else #include "portmacro.h" #endif +#endif #if portBYTE_ALIGNMENT == 32 #define portBYTE_ALIGNMENT_MASK ( 0x001f ) diff --git a/elab/3rd/FreeRTOS/list.c b/elab/3rd/FreeRTOS/list.c index 7618ee8b864cf54e319792e1a70fd9e77f88d659..5bbeb1ae8bbfdcdf3c37212d3b06ac25360a2707 100644 --- a/elab/3rd/FreeRTOS/list.c +++ b/elab/3rd/FreeRTOS/list.c @@ -27,8 +27,8 @@ #include -#include "FreeRTOS.h" -#include "list.h" +#include "include/FreeRTOS.h" +#include "include/list.h" /*----------------------------------------------------------- * PUBLIC LIST API documented in list.h diff --git a/elab/3rd/FreeRTOS/portable/GCC/ARM_CM4F/port.c b/elab/3rd/FreeRTOS/portable/GCC/ARM_CM4F/port.c index 89a912c086c75f90b9bb40f23002d6edd3ad0905..60faa397a9ec9f8178ad7ddbcc3a3022a9cd3c39 100644 --- a/elab/3rd/FreeRTOS/portable/GCC/ARM_CM4F/port.c +++ b/elab/3rd/FreeRTOS/portable/GCC/ARM_CM4F/port.c @@ -30,8 +30,8 @@ *----------------------------------------------------------*/ /* Scheduler includes. */ -#include "FreeRTOS.h" -#include "task.h" +#include "../../../include/FreeRTOS.h" +#include "../../../include/task.h" #ifndef __VFP_FP__ #error This port can only be used when the project options are configured to enable hardware floating point support. diff --git a/elab/3rd/FreeRTOS/portable/mingw/port.c b/elab/3rd/FreeRTOS/portable/mingw/port.c index 019c767e97fe08d4ed813c7719beafde89a10247..599932d6aeedb76ad7f3503a9e538a461f111488 100644 --- a/elab/3rd/FreeRTOS/portable/mingw/port.c +++ b/elab/3rd/FreeRTOS/portable/mingw/port.c @@ -29,8 +29,8 @@ #include /* Scheduler includes. */ -#include "FreeRTOS.h" -#include "task.h" +#include "../../include/FreeRTOS.h" +#include "../../include/task.h" #pragma comment(lib, "winmm.lib") diff --git a/elab/3rd/FreeRTOS/queue.c b/elab/3rd/FreeRTOS/queue.c index b3203b806e0a6af14ccd4a4fc54ba2b7294ee162..7b79fed6ccc2302676e092b990d25e0b34aeabfa 100644 --- a/elab/3rd/FreeRTOS/queue.c +++ b/elab/3rd/FreeRTOS/queue.c @@ -33,9 +33,9 @@ all the API functions to use the MPU wrappers. That should only be done when task.h is included from an application file. */ #define MPU_WRAPPERS_INCLUDED_FROM_API_FILE -#include "FreeRTOS.h" -#include "task.h" -#include "queue.h" +#include "include/FreeRTOS.h" +#include "include/task.h" +#include "include/queue.h" #if ( configUSE_CO_ROUTINES == 1 ) #include "croutine.h" diff --git a/elab/3rd/FreeRTOS/stream_buffer.c b/elab/3rd/FreeRTOS/stream_buffer.c index 7ad5d54abbd4bdb0f8acfa53d1bc9c2461db94b2..75b53db71f1a04b9a8e323b492c8e658ab39c70f 100644 --- a/elab/3rd/FreeRTOS/stream_buffer.c +++ b/elab/3rd/FreeRTOS/stream_buffer.c @@ -35,9 +35,9 @@ task.h is included from an application file. */ #define MPU_WRAPPERS_INCLUDED_FROM_API_FILE /* FreeRTOS includes. */ -#include "FreeRTOS.h" -#include "task.h" -#include "stream_buffer.h" +#include "include/FreeRTOS.h" +#include "include/task.h" +#include "include/stream_buffer.h" #if( configUSE_TASK_NOTIFICATIONS != 1 ) #error configUSE_TASK_NOTIFICATIONS must be set to 1 to build stream_buffer.c diff --git a/elab/3rd/FreeRTOS/tasks.c b/elab/3rd/FreeRTOS/tasks.c index f6a6a9b42fd4f596a8336a48672d0900571f733d..c3620ba1ea124b3a00aa4580f2794230871af072 100644 --- a/elab/3rd/FreeRTOS/tasks.c +++ b/elab/3rd/FreeRTOS/tasks.c @@ -35,10 +35,10 @@ task.h is included from an application file. */ #define MPU_WRAPPERS_INCLUDED_FROM_API_FILE /* FreeRTOS includes. */ -#include "FreeRTOS.h" -#include "task.h" -#include "timers.h" -#include "stack_macros.h" +#include "include/FreeRTOS.h" +#include "include/task.h" +#include "include/timers.h" +#include "include/stack_macros.h" /* Lint e9021, e961 and e750 are suppressed as a MISRA exception justified because the MPU ports require MPU_WRAPPERS_INCLUDED_FROM_API_FILE to be defined diff --git a/elab/3rd/FreeRTOS/timers.c b/elab/3rd/FreeRTOS/timers.c index 00200b8f6375c3e9ee46640485c3eb077806da43..fe310f6034fbb9c30e8a4d96622bff534ac1ad26 100644 --- a/elab/3rd/FreeRTOS/timers.c +++ b/elab/3rd/FreeRTOS/timers.c @@ -33,10 +33,10 @@ all the API functions to use the MPU wrappers. That should only be done when task.h is included from an application file. */ #define MPU_WRAPPERS_INCLUDED_FROM_API_FILE -#include "FreeRTOS.h" -#include "task.h" -#include "queue.h" -#include "timers.h" +#include "include/FreeRTOS.h" +#include "include/task.h" +#include "include/queue.h" +#include "include/timers.h" #if ( INCLUDE_xTimerPendFunctionCall == 1 ) && ( configUSE_TIMERS == 0 ) #error configUSE_TIMERS must be set to 1 to make the xTimerPendFunctionCall() function available. diff --git a/elab/3rd/Shell/shell.c b/elab/3rd/Shell/shell.c index 36f4623bbd6e4779d04dd1ca4cf373dc0541b0fd..10a5e38dab68a9b98ae638a32c324e5413cafec9 100644 --- a/elab/3rd/Shell/shell.c +++ b/elab/3rd/Shell/shell.c @@ -14,7 +14,7 @@ #include #include "shell.h" #include "shell_ext.h" -#include "eLab/common/elab_assert.h" +#include "../../common/elab_assert.h" ELAB_TAG("LetterShell"); diff --git a/elab/3rd/Shell/shell.h b/elab/3rd/Shell/shell.h index 002c4e3ae4461d9cfa38c5b89280596d22ff6e91..e57d99f3fc7607d919ce2c013eae690a17d5501d 100644 --- a/elab/3rd/Shell/shell.h +++ b/elab/3rd/Shell/shell.h @@ -14,7 +14,7 @@ #include #include "shell_cfg.h" -#include "eLab/common/elab_def.h" +#include "../../common/elab_def.h" #define ESH_KEY_F1 (0x1B4F5000) #define ESH_KEY_F2 (0x1B4F5100) diff --git a/elab/3rd/modbus/mb.h b/elab/3rd/modbus/mb.h index 8b231312a422a1cd4f72887ce23ce72858bbc9d9..1c6f54d42d7e040131d8e727ebd0574866a0bbc9 100644 --- a/elab/3rd/modbus/mb.h +++ b/elab/3rd/modbus/mb.h @@ -52,7 +52,7 @@ #include "mb_cfg.h" #include "mb_def.h" -#include "../../RTOS/cmsis_os.h" +#include "../../os/cmsis_os.h" /* ******************************************************************************** diff --git a/elab/3rd/modbus/mb_bsp.c b/elab/3rd/modbus/mb_bsp.c index a13f9e33ee95f4e59502975c64519a9204c7258e..2970336657f605cc49e0fbb0acfc08b3935b0853 100644 --- a/elab/3rd/modbus/mb_bsp.c +++ b/elab/3rd/modbus/mb_bsp.c @@ -11,7 +11,7 @@ #include "elab_device.h" #include "elab_serial.h" #include "elab_pin.h" -#include "../../RTOS/cmsis_os.h" +#include "../../os/cmsis_os.h" #include "elab_def.h" #include "elab_rs485.h" #include "elab_log.h" diff --git a/elab/3rd/modbus/mb_os.c b/elab/3rd/modbus/mb_os.c index 5f7f2449ada53c8c10db65c23695eaea0e2ade24..68c508b6d23af2d50aa574564fd2454cacb2dc4b 100644 --- a/elab/3rd/modbus/mb_os.c +++ b/elab/3rd/modbus/mb_os.c @@ -8,7 +8,7 @@ #define MB_OS_MODULE #include "mb.h" -#include "../../RTOS/cmsis_os.h" +#include "../../os/cmsis_os.h" #include "../../common/elab_log.h" #include "../../common/elab_assert.h" diff --git a/elab/3rd/modbus/mbs_core.c b/elab/3rd/modbus/mbs_core.c index 3b77e25fa343b7aa70f26a4d8e1b52ab856fbcdd..659aaccb273287c2a7a2053df764e1edd767dbf8 100644 --- a/elab/3rd/modbus/mbs_core.c +++ b/elab/3rd/modbus/mbs_core.c @@ -32,7 +32,7 @@ #define MBS_MODULE -#include "eLab/common/elab_assert.h" +#include "elab/common/elab_assert.h" #include "mb.h" ELAB_TAG("ModbusSlaveCore"); diff --git a/elab/3rd/qpc/include/qpc.h b/elab/3rd/qpc/include/qpc.h index 1c324ae65982e6ee185f1f905bb0e586a4bbdb19..c1dd12cb229920d2bf98b8a88c5ff43078847620 100644 --- a/elab/3rd/qpc/include/qpc.h +++ b/elab/3rd/qpc/include/qpc.h @@ -51,7 +51,12 @@ extern "C" { #endif /****************************************************************************/ -#include "qf_port.h" /* QF/C port from the port directory */ +/* QF/C port from the port directory */ +#if defined(__linux__) +#include "../ports/posix/qf_port.h" +#else +#include "../ports/freertos/qf_port.h" +#endif #include "qassert.h" /* QP embedded systems-friendly assertions */ #ifdef Q_SPY /* software tracing enabled? */ diff --git a/elab/3rd/qpc/ports/freertos/qep_port.h b/elab/3rd/qpc/ports/freertos/qep_port.h index 4a6dda6728c455db0c584453adcc9213e0f3b4e7..a384a44670569144fc62add49ccb324715010d8e 100644 --- a/elab/3rd/qpc/ports/freertos/qep_port.h +++ b/elab/3rd/qpc/ports/freertos/qep_port.h @@ -43,6 +43,6 @@ #include /* Exact-width types. WG14/N843 C99 Standard */ #include /* Boolean type. WG14/N843 C99 Standard */ -#include "qep.h" /* QEP platform-independent public interface */ +#include "../../include/qep.h" /* QEP platform-independent public interface */ #endif /* QEP_PORT_H */ diff --git a/elab/3rd/qpc/ports/freertos/qf_port.c b/elab/3rd/qpc/ports/freertos/qf_port.c index adbacb8a546eda790966c466ebaa327bedd4d002..ca3de2a8dc38de7562166b9d558d4e79671fbf30 100644 --- a/elab/3rd/qpc/ports/freertos/qf_port.c +++ b/elab/3rd/qpc/ports/freertos/qf_port.c @@ -39,13 +39,13 @@ */ #define QP_IMPL /* this is QP implementation */ #include "qf_port.h" /* QF port */ -#include "qf_pkg.h" -#include "qassert.h" +#include "../../src/qf_pkg.h" +#include "../../include/qassert.h" #ifdef Q_SPY /* QS software tracing enabled? */ #include "qs_port.h" /* QS port */ #include "qs_pkg.h" /* QS package-scope internal interface */ #else - #include "qs_dummy.h" /* disable the QS software tracing */ + #include "../../include/qs_dummy.h" /* disable the QS software tracing */ #endif /* Q_SPY */ Q_DEFINE_THIS_MODULE("qf_port") @@ -75,8 +75,10 @@ int_t QF_run(void) { QS_BEGIN_PRE_(QS_QF_RUN, 0U) QS_END_PRE_() +#if 0 vTaskStartScheduler(); /* start the FreeRTOS scheduler */ Q_ERROR_ID(110); /* the FreeRTOS scheduler should never return */ +#endif return 0; /* dummy return to make the compiler happy */ } /*..........................................................................*/ diff --git a/elab/3rd/qpc/ports/freertos/qf_port.h b/elab/3rd/qpc/ports/freertos/qf_port.h index 3bc75845eede2f53699d8ff552826ac5b116faca..b2059b52b84199223a790171356397d1d8118328 100644 --- a/elab/3rd/qpc/ports/freertos/qf_port.h +++ b/elab/3rd/qpc/ports/freertos/qf_port.h @@ -56,13 +56,15 @@ #define QF_CRIT_ENTRY(stat_) taskENTER_CRITICAL() #define QF_CRIT_EXIT(stat_) taskEXIT_CRITICAL() -#include "FreeRTOS.h" /* FreeRTOS master include file, see NOTE4 */ -#include "task.h" /* FreeRTOS task management */ - -#include "qep_port.h" /* QEP port */ -#include "qequeue.h" /* this QP port uses the native QF event queue */ -#include "qmpool.h" /* this QP port uses the native QF memory pool */ -#include "qf.h" /* QF platform-independent public interface */ +/* FreeRTOS master include file, see NOTE4 */ +#include "../../../FreeRTOS/include/FreeRTOS.h" +/* FreeRTOS task management */ +#include "../../../FreeRTOS/include/task.h" + +#include "qep_port.h" /* QEP port */ +#include "../../include/qequeue.h" /* this QP port uses the native QF event queue */ +#include "../../include/qmpool.h" /* this QP port uses the native QF memory pool */ +#include "../../include/qf.h" /* QF platform-independent public interface */ /* the "FromISR" versions of the QF APIs, see NOTE3 */ #ifdef Q_SPY diff --git a/elab/3rd/qpc/ports/freertos/qs_port.h b/elab/3rd/qpc/ports/freertos/qs_port.h deleted file mode 100644 index 748b81b8ba86985cb04cd93818b8d330827ccb9c..0000000000000000000000000000000000000000 --- a/elab/3rd/qpc/ports/freertos/qs_port.h +++ /dev/null @@ -1,62 +0,0 @@ -/** -* @file -* @brief QS/C port to a 32-bit CPU and a generic C compiler. -* @ingroup qs -* @cond -****************************************************************************** -* Last Updated for Version: 6.0.4 -* Date of the Last Update: 2018-01-04 -* -* Q u a n t u m L e a P s -* --------------------------- -* innovating embedded systems -* -* Copyright (C) Quantum Leaps, LLC. state-machine.com. -* -* This program is open source software: you can redistribute it and/or -* modify it under the terms of the GNU General Public License as published -* by the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* Alternatively, this program may be distributed and modified under the -* terms of Quantum Leaps commercial licenses, which expressly supersede -* the GNU General Public License and are specifically designed for -* licensees interested in retaining the proprietary status of their code. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -* -* Contact information: -* -* -****************************************************************************** -* @endcond -*/ -#ifndef QS_PORT_H -#define QS_PORT_H - -/* QS time-stamp size in bytes */ -#define QS_TIME_SIZE 4 - -/* object pointer size in bytes */ -#define QS_OBJ_PTR_SIZE 4 - -/* function pointer size in bytes */ -#define QS_FUN_PTR_SIZE 4 - -/***************************************************************************** -* NOTE: QS might be used with or without other QP components, in which -* case the separate definitions of the macros Q_ROM, QF_CRIT_STAT_TYPE, -* QF_CRIT_ENTRY, and QF_CRIT_EXIT are needed. In this port QS is configured -* to be used with the other QP component, by simply including "qf_port.h" -* *before* "qs.h". -*/ -#include "qf_port.h" /* use QS with QF */ -#include "qs.h" /* QS platform-independent public interface */ - -#endif /* QS_PORT_H */ diff --git a/elab/3rd/qpc/ports/posix/README.txt b/elab/3rd/qpc/ports/posix/README.txt deleted file mode 100644 index 6714aa9c97655fb1d6f01ac07223f9f6a1e84a47..0000000000000000000000000000000000000000 --- a/elab/3rd/qpc/ports/posix/README.txt +++ /dev/null @@ -1,17 +0,0 @@ -This QP port to POSIX with P-threads is intended for building -multithreaded QP applications running on embedded POSIX targets. - -If you are interested in using a POSIX host for testing your -embedded QP applications, consider the following QP ports: - -- posix-qutest for running QUTest unit testing harness -- posix-qv single-threaded QP port to POSIX - - -NOTE: -Building of the QP libraries on the POSIX targets or hosts -is no longer necessary. The example projects for POSIX are -built directly from QP source files and don't need a library. - -Quantum Leaps -04/05/2018 \ No newline at end of file diff --git a/elab/3rd/qpc/ports/posix/qf_port.c b/elab/3rd/qpc/ports/posix/qf_port.c index 8221a20b7494e10ef1c42b5cb25813d366c6573d..bbd23f44edc94dbb39759b8e0d42cd451d26be1e 100644 --- a/elab/3rd/qpc/ports/posix/qf_port.c +++ b/elab/3rd/qpc/ports/posix/qf_port.c @@ -99,10 +99,6 @@ void QF_init(void) { l_tick.tv_sec = 0; l_tick.tv_nsec = NANOSLEEP_NSEC_PER_SEC/100L; /* default clock tick */ l_tickPrio = sched_get_priority_min(SCHED_FIFO); /* default tick prio */ - - /* install the SIGINT (Ctrl-C) signal handler */ - // sig_act.sa_handler = &sigIntHandler; - // sigaction(SIGINT, &sig_act, NULL); } /****************************************************************************/ @@ -137,14 +133,7 @@ int_t QF_run(void) { * calling QF_run() */ pthread_mutex_unlock(&l_startupMutex); - l_isRunning = true; - while (l_isRunning) { /* the clock tick loop... */ - QF_onClockTick(); /* clock tick callback (must call QF_TICK_X()) */ - - nanosleep(&l_tick, NULL); /* sleep for the number of ticks, NOTE05 */ - } - QF_onCleanup(); /* invoke cleanup callback */ pthread_mutex_destroy(&l_startupMutex); pthread_mutex_destroy(&QF_pThreadMutex_); diff --git a/elab/3rd/qpc/ports/posix/qs_port.c b/elab/3rd/qpc/ports/posix/qs_port.c deleted file mode 100644 index dfaeb64fd0362733e9356873516653963bb49be9..0000000000000000000000000000000000000000 --- a/elab/3rd/qpc/ports/posix/qs_port.c +++ /dev/null @@ -1,305 +0,0 @@ -/** -* @file -* @brief QS/C port to POSIX -* @ingroup ports -* @cond -****************************************************************************** -* Last updated for version 6.9.2 -* Last updated on 2021-01-14 -* -* Q u a n t u m L e a P s -* ------------------------ -* Modern Embedded Software -* -* Copyright (C) 2005-2021 Quantum Leaps, LLC. All rights reserved. -* -* This program is open source software: you can redistribute it and/or -* modify it under the terms of the GNU General Public License as published -* by the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* Alternatively, this program may be distributed and modified under the -* terms of Quantum Leaps commercial licenses, which expressly supersede -* the GNU General Public License and are specifically designed for -* licensees interested in retaining the proprietary status of their code. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -* -* Contact information: -* -* -****************************************************************************** -* @endcond -*/ -/* expose features from the 2008 POSIX standard (IEEE Standard 1003.1-2008) */ -#define _POSIX_C_SOURCE 200809L - -#ifndef Q_SPY - #error "Q_SPY must be defined to compile qs_port.c" -#endif /* Q_SPY */ - -#define QP_IMPL /* this is QP implementation */ -#include "qf_port.h" /* QF port */ -#include "qassert.h" /* QP embedded systems-friendly assertions */ -#include "qs_port.h" /* QS port */ -#include "qs_pkg.h" /* QS package-scope interface */ - -#include "safe_std.h" /* portable "safe" / facilities */ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/*Q_DEFINE_THIS_MODULE("qs_port")*/ - -#define QS_TX_SIZE (8*1024) -#define QS_RX_SIZE (2*1024) -#define QS_TX_CHUNK QS_TX_SIZE -#define QS_TIMEOUT_MS 10 - -#define INVALID_SOCKET -1 -#define SOCKET_ERROR -1 - -/* local variables .........................................................*/ -static int l_sock = INVALID_SOCKET; -static struct timespec const c_timeout = { 0, QS_TIMEOUT_MS*1000000L }; - -/*..........................................................................*/ -uint8_t QS_onStartup(void const *arg) { - static uint8_t qsBuf[QS_TX_SIZE]; /* buffer for QS-TX channel */ - static uint8_t qsRxBuf[QS_RX_SIZE]; /* buffer for QS-RX channel */ - char hostName[128]; - char const *serviceName = "6601"; /* default QSPY server port */ - char const *src; - char *dst; - int status; - - struct addrinfo *result = NULL; - struct addrinfo *rp = NULL; - struct addrinfo hints; - int sockopt_bool; - - /* initialize the QS transmit and receive buffers */ - QS_initBuf(qsBuf, sizeof(qsBuf)); - QS_rxInitBuf(qsRxBuf, sizeof(qsRxBuf)); - - /* extract hostName from 'arg' (hostName:port_remote)... */ - src = (arg != (void *)0) - ? (char const *)arg - : "localhost"; /* default QSPY host */ - dst = hostName; - while ((*src != '\0') - && (*src != ':') - && (dst < &hostName[sizeof(hostName) - 1])) - { - *dst++ = *src++; - } - *dst = '\0'; /* zero-terminate hostName */ - - /* extract serviceName from 'arg' (hostName:serviceName)... */ - if (*src == ':') { - serviceName = src + 1; - } - - memset(&hints, 0, sizeof(hints)); - hints.ai_family = AF_INET; - hints.ai_socktype = SOCK_STREAM; - hints.ai_protocol = IPPROTO_TCP; - status = getaddrinfo(hostName, serviceName, &hints, &result); - if (status != 0) { - FPRINTF_S(stderr, - " ERROR cannot resolve host Name=%s:%s,Err=%d\n", - hostName, serviceName, status); - goto error; - } - - for (rp = result; rp != NULL; rp = rp->ai_next) { - l_sock = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol); - if (l_sock != INVALID_SOCKET) { - if (connect(l_sock, rp->ai_addr, rp->ai_addrlen) - == SOCKET_ERROR) - { - close(l_sock); - l_sock = INVALID_SOCKET; - } - break; - } - } - - freeaddrinfo(result); - - /* socket could not be opened & connected? */ - if (l_sock == INVALID_SOCKET) { - FPRINTF_S(stderr, " ERROR cannot connect to QSPY at " - "host=%s:%s\n", - hostName, serviceName); - goto error; - } - - /* set the socket to non-blocking mode */ - status = fcntl(l_sock, F_GETFL, 0); - if (status == -1) { - FPRINTF_S(stderr, - " ERROR Socket configuration failed errno=%d\n", - errno); - QS_EXIT(); - goto error; - } - if (fcntl(l_sock, F_SETFL, status | O_NONBLOCK) != 0) { - FPRINTF_S(stderr, " ERROR Failed to set non-blocking socket " - "errno=%d\n", errno); - QS_EXIT(); - goto error; - } - - /* configure the socket to reuse the address and not to linger */ - sockopt_bool = 1; - setsockopt(l_sock, SOL_SOCKET, SO_REUSEADDR, - &sockopt_bool, sizeof(sockopt_bool)); - sockopt_bool = 0; /* negative option */ - setsockopt(l_sock, SOL_SOCKET, SO_LINGER, - &sockopt_bool, sizeof(sockopt_bool)); - QS_onFlush(); - - return 1U; /* success */ - -error: - return 0U; /* failure */ -} -/*..........................................................................*/ -void QS_onCleanup(void) { - if (l_sock != INVALID_SOCKET) { - close(l_sock); - l_sock = INVALID_SOCKET; - } - /*PRINTF_S(" Disconnected from QSPY\n");*/ -} -/*..........................................................................*/ -void QS_onReset(void) { - QS_onCleanup(); - exit(0); -} -/*..........................................................................*/ -void QS_onFlush(void) { - uint16_t nBytes; - uint8_t const *data; - QS_CRIT_STAT_ - - if (l_sock == INVALID_SOCKET) { /* socket NOT initialized? */ - FPRINTF_S(stderr, " ERROR %s\n", "invalid TCP socket"); - return; - } - - nBytes = QS_TX_CHUNK; - QS_CRIT_E_(); - while ((data = QS_getBlock(&nBytes)) != (uint8_t *)0) { - QS_CRIT_X_(); - for (;;) { /* for-ever until break or return */ - int nSent = send(l_sock, (char const *)data, (int)nBytes, 0); - if (nSent == SOCKET_ERROR) { /* sending failed? */ - if ((errno == EWOULDBLOCK) || (errno == EAGAIN)) { - /* sleep for the timeout and then loop back - * to send() the SAME data again - */ - nanosleep(&c_timeout, NULL); - } - else { /* some other socket error... */ - FPRINTF_S(stderr, " ERROR sending data over TCP," - "errno=%d\n", errno); - return; - } - } - else if (nSent < (int)nBytes) { /* sent fewer than requested? */ - nanosleep(&c_timeout, NULL); /* sleep for the timeout */ - /* adjust the data and loop back to send() the rest */ - data += nSent; - nBytes -= (uint16_t)nSent; - } - else { - break; - } - } - /* set nBytes for the next call to QS_getBlock() */ - nBytes = QS_TX_CHUNK; - QS_CRIT_E_(); - } - QS_CRIT_X_(); -} -/*..........................................................................*/ -QSTimeCtr QS_onGetTime(void) { - struct timespec tspec; - QSTimeCtr time; - clock_gettime(CLOCK_MONOTONIC_RAW, &tspec); - - /* convert to units of 0.1 microsecond */ - time = (QSTimeCtr)(tspec.tv_sec * 10000000 + tspec.tv_nsec / 100); - return time; -} - -/*..........................................................................*/ -void QS_output(void) { - uint16_t nBytes; - uint8_t const *data; - QS_CRIT_STAT_ - - if (l_sock == INVALID_SOCKET) { /* socket NOT initialized? */ - FPRINTF_S(stderr, " ERROR %s\n", "invalid TCP socket"); - return; - } - - nBytes = QS_TX_CHUNK; - QS_CRIT_E_(); - if ((data = QS_getBlock(&nBytes)) != (uint8_t *)0) { - QS_CRIT_X_(); - for (;;) { /* for-ever until break or return */ - int nSent = send(l_sock, (char const *)data, (int)nBytes, 0); - if (nSent == SOCKET_ERROR) { /* sending failed? */ - if ((errno == EWOULDBLOCK) || (errno == EAGAIN)) { - /* sleep for the timeout and then loop back - * to send() the SAME data again - */ - nanosleep(&c_timeout, NULL); - } - else { /* some other socket error... */ - FPRINTF_S(stderr, " ERROR sending data over TCP," - "errno=%d\n", errno); - return; - } - } - else if (nSent < (int)nBytes) { /* sent fewer than requested? */ - nanosleep(&c_timeout, NULL); /* sleep for the timeout */ - /* adjust the data and loop back to send() the rest */ - data += nSent; - nBytes -= (uint16_t)nSent; - } - else { - break; - } - } - } - else { - QS_CRIT_X_(); - } -} -/*..........................................................................*/ -void QS_rx_input(void) { - int status = recv(l_sock, - (char *)QS_rxPriv_.buf, (int)QS_rxPriv_.end, 0); - if (status > 0) { /* any data received? */ - QS_rxPriv_.tail = 0U; - QS_rxPriv_.head = status; /* # bytes received */ - QS_rxParse(); /* parse all received bytes */ - } -} - diff --git a/elab/3rd/qpc/ports/posix/qs_port.h b/elab/3rd/qpc/ports/posix/qs_port.h deleted file mode 100644 index cc398ca32cb6cc2574fbb0f5817a50bbf65619db..0000000000000000000000000000000000000000 --- a/elab/3rd/qpc/ports/posix/qs_port.h +++ /dev/null @@ -1,67 +0,0 @@ -/** -* @file -* @brief QS/C port to POSIX with GNU compiler -* @ingroup ports -* @cond -****************************************************************************** -* Last updated for version 6.8.0 -* Last updated on 2020-01-21 -* -* Q u a n t u m L e a P s -* ------------------------ -* Modern Embedded Software -* -* Copyright (C) 2005-2019 Quantum Leaps, LLC. All rights reserved. -* -* This program is open source software: you can redistribute it and/or -* modify it under the terms of the GNU General Public License as published -* by the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* Alternatively, this program may be distributed and modified under the -* terms of Quantum Leaps commercial licenses, which expressly supersede -* the GNU General Public License and are specifically designed for -* licensees interested in retaining the proprietary status of their code. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -* -* Contact information: -* -* -****************************************************************************** -* @endcond -*/ -#ifndef QS_PORT_H -#define QS_PORT_H - -#define QS_TIME_SIZE 4U - -#if defined(__LP64__) || defined(_LP64) /* 64-bit architecture? */ - #define QS_OBJ_PTR_SIZE 8U - #define QS_FUN_PTR_SIZE 8U -#else /* 32-bit architecture */ - #define QS_OBJ_PTR_SIZE 4U - #define QS_FUN_PTR_SIZE 4U -#endif - -void QS_output(void); /* handle the QS output */ -void QS_rx_input(void); /* handle the QS-RX input */ - -/***************************************************************************** -* NOTE: QS might be used with or without other QP components, in which -* case the separate definitions of the macros QF_CRIT_STAT_TYPE, -* QF_CRIT_ENTRY, and QF_CRIT_EXIT are needed. In this port QS is configured -* to be used with the other QP component, by simply including "qf_port.h" -* *before* "qs.h". -*/ -#include "qf_port.h" /* use QS with QF */ -#include "qs.h" /* QS platform-independent public interface */ - -#endif /* QS_PORT_H */ - diff --git a/elab/3rd/qpc/ports/win32/QSpy/qp.lib b/elab/3rd/qpc/ports/win32/QSpy/qp.lib deleted file mode 100644 index 6e130f9bfdd0d06e617f1a9a820dd51dc03ae44a..0000000000000000000000000000000000000000 Binary files a/elab/3rd/qpc/ports/win32/QSpy/qp.lib and /dev/null differ diff --git a/elab/3rd/qpc/ports/win32/QSpy/qp.pdb b/elab/3rd/qpc/ports/win32/QSpy/qp.pdb deleted file mode 100644 index cbc0021221ca4f78e56bc959fffb6486df53d58a..0000000000000000000000000000000000000000 Binary files a/elab/3rd/qpc/ports/win32/QSpy/qp.pdb and /dev/null differ diff --git a/elab/3rd/qpc/ports/win32/QSpy64/qp.lib b/elab/3rd/qpc/ports/win32/QSpy64/qp.lib deleted file mode 100644 index 435fe59190c26e29d895d34525a9bec787e9866a..0000000000000000000000000000000000000000 Binary files a/elab/3rd/qpc/ports/win32/QSpy64/qp.lib and /dev/null differ diff --git a/elab/3rd/qpc/ports/win32/QSpy64/qp.pdb b/elab/3rd/qpc/ports/win32/QSpy64/qp.pdb deleted file mode 100644 index 9ca269ce861210ca798ef3b30625df1cb6d4a335..0000000000000000000000000000000000000000 Binary files a/elab/3rd/qpc/ports/win32/QSpy64/qp.pdb and /dev/null differ diff --git a/elab/3rd/qpc/ports/win32/README.url b/elab/3rd/qpc/ports/win32/README.url deleted file mode 100644 index d6bafed132dbdaa0a5b8cd7577b6a70c08c03fe7..0000000000000000000000000000000000000000 --- a/elab/3rd/qpc/ports/win32/README.url +++ /dev/null @@ -1,8 +0,0 @@ -[InternetShortcut] -URL=https://www.state-machine.com/qpc/win32.html -IconFile=http://www.state-machine.com/qp.ico -IDList= -HotKey=0 - -[{000214A0-0000-0000-C000-000000000046}] -Prop3=19,11 diff --git a/elab/3rd/qpc/ports/win32/Release/qp.lib b/elab/3rd/qpc/ports/win32/Release/qp.lib deleted file mode 100644 index cd9593452813aec282e6e8ed7dc288b8b8a0ccad..0000000000000000000000000000000000000000 Binary files a/elab/3rd/qpc/ports/win32/Release/qp.lib and /dev/null differ diff --git a/elab/3rd/qpc/ports/win32/dbg/libqp.a b/elab/3rd/qpc/ports/win32/dbg/libqp.a deleted file mode 100644 index f893400c2a9fab23f174e483164af892b7684d8d..0000000000000000000000000000000000000000 Binary files a/elab/3rd/qpc/ports/win32/dbg/libqp.a and /dev/null differ diff --git a/elab/3rd/qpc/ports/win32/qep_port.h b/elab/3rd/qpc/ports/win32/qep_port.h index ba49196065e98f8d86f73d35cd94684b7a3dbabc..c3cc4c15bae1551a95f822ca42e6eee526073e3d 100644 --- a/elab/3rd/qpc/ports/win32/qep_port.h +++ b/elab/3rd/qpc/ports/win32/qep_port.h @@ -69,7 +69,7 @@ #endif -#include "qep.h" /* QEP platform-independent public interface */ +#include "../../include/qep.h" /* QEP platform-independent public interface */ #if (defined __cplusplus) && (defined _MSC_VER) #pragma warning (default: 4510 4512 4610) diff --git a/elab/3rd/qpc/ports/win32/qf_port.h b/elab/3rd/qpc/ports/win32/qf_port.h index 0b12a3ea954bfc5a609b73c2234931f022b85878..e8eb88c647c810913e333d24b942a3dd023b554a 100644 --- a/elab/3rd/qpc/ports/win32/qf_port.h +++ b/elab/3rd/qpc/ports/win32/qf_port.h @@ -68,10 +68,10 @@ /* QF_LOG2 not defined -- use the internal LOG2() implementation */ -#include "qep_port.h" /* QEP port */ -#include "qequeue.h" /* Win32 needs the native event-queue */ -#include "qmpool.h" /* Win32 needs the native memory-pool */ -#include "qf.h" /* QF platform-independent public interface */ +#include "qep_port.h" /* QEP port */ +#include "../../include/qequeue.h" /* Win32 needs the native event-queue */ +#include "../../include/qmpool.h" /* Win32 needs the native memory-pool */ +#include "../../include/qf.h" /* QF platform-independent public interface */ /* internal functions for critical section management */ void QF_enterCriticalSection_(void); diff --git a/elab/3rd/qpc/ports/win32/qp.sln b/elab/3rd/qpc/ports/win32/qp.sln deleted file mode 100644 index 19697b506070cc6bd3f050bde9ec7ae9a261c3cd..0000000000000000000000000000000000000000 --- a/elab/3rd/qpc/ports/win32/qp.sln +++ /dev/null @@ -1,42 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30804.86 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "qp", "qp.vcxproj", "{3E9F0C4A-01B7-4357-95C6-0FE86BACB6D9}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - QSpy|Win32 = QSpy|Win32 - QSpy|x64 = QSpy|x64 - QSpy64|Win32 = QSpy64|Win32 - QSpy64|x64 = QSpy64|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {3E9F0C4A-01B7-4357-95C6-0FE86BACB6D9}.Debug|Win32.ActiveCfg = Debug|Win32 - {3E9F0C4A-01B7-4357-95C6-0FE86BACB6D9}.Debug|Win32.Build.0 = Debug|Win32 - {3E9F0C4A-01B7-4357-95C6-0FE86BACB6D9}.Debug|x64.ActiveCfg = Debug|x64 - {3E9F0C4A-01B7-4357-95C6-0FE86BACB6D9}.Debug|x64.Build.0 = Debug|x64 - {3E9F0C4A-01B7-4357-95C6-0FE86BACB6D9}.QSpy|Win32.ActiveCfg = QSpy|Win32 - {3E9F0C4A-01B7-4357-95C6-0FE86BACB6D9}.QSpy|Win32.Build.0 = QSpy|Win32 - {3E9F0C4A-01B7-4357-95C6-0FE86BACB6D9}.QSpy|x64.ActiveCfg = QSpy|x64 - {3E9F0C4A-01B7-4357-95C6-0FE86BACB6D9}.QSpy|x64.Build.0 = QSpy|x64 - {3E9F0C4A-01B7-4357-95C6-0FE86BACB6D9}.QSpy64|Win32.ActiveCfg = QSpy64|Win32 - {3E9F0C4A-01B7-4357-95C6-0FE86BACB6D9}.QSpy64|Win32.Build.0 = QSpy64|Win32 - {3E9F0C4A-01B7-4357-95C6-0FE86BACB6D9}.QSpy64|x64.ActiveCfg = QSpy64|x64 - {3E9F0C4A-01B7-4357-95C6-0FE86BACB6D9}.QSpy64|x64.Build.0 = QSpy64|x64 - {3E9F0C4A-01B7-4357-95C6-0FE86BACB6D9}.Release|Win32.ActiveCfg = Release|Win32 - {3E9F0C4A-01B7-4357-95C6-0FE86BACB6D9}.Release|Win32.Build.0 = Release|Win32 - {3E9F0C4A-01B7-4357-95C6-0FE86BACB6D9}.Release|x64.ActiveCfg = Release|x64 - {3E9F0C4A-01B7-4357-95C6-0FE86BACB6D9}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {26B33241-845D-43F5-BCB4-456C2AB98376} - EndGlobalSection -EndGlobal diff --git a/elab/3rd/qpc/ports/win32/qp.vcxproj b/elab/3rd/qpc/ports/win32/qp.vcxproj deleted file mode 100644 index 2c64d6a38327a5558850c7c7ee0acb0eda8b0ad1..0000000000000000000000000000000000000000 --- a/elab/3rd/qpc/ports/win32/qp.vcxproj +++ /dev/null @@ -1,403 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - QSpy64 - Win32 - - - QSpy64 - x64 - - - QSpy - x64 - - - Release - Win32 - - - QSpy - Win32 - - - Release - x64 - - - - {3E9F0C4A-01B7-4357-95C6-0FE86BACB6D9} - qp - ManagedCProj - 10.0 - - - - StaticLibrary - NotSet - false - v142 - - - StaticLibrary - NotSet - false - v142 - - - StaticLibrary - NotSet - false - v142 - - - StaticLibrary - NotSet - false - v142 - - - StaticLibrary - NotSet - false - true - v142 - - - StaticLibrary - NotSet - false - true - v142 - - - StaticLibrary - NotSet - false - v142 - - - StaticLibrary - NotSet - false - v142 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.40219.1 - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - false - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - false - $(SolutionDir)$(Configuration)\ - QSpy64\ - $(Configuration)\ - QSpy64\ - false - false - false - false - - - QSpy64\ - QSpy64\ - - - - Disabled - .;../../include;../../src;%(AdditionalIncludeDirectories) - QWIN_GUI;_DEBUG;%(PreprocessorDefinitions) - - - MultiThreaded - NotUsing - Level4 - ProgramDatabase - Default - 4127;%(DisableSpecificWarnings) - - - Cleanup - del $(IntDir)*.obj $(IntDir)*.tlog $(IntDir)*.lastbuildstate - - - - - Disabled - .;../../include;../../src;%(AdditionalIncludeDirectories) - QWIN_GUI;_DEBUG;%(PreprocessorDefinitions) - - - MultiThreaded - NotUsing - Level4 - ProgramDatabase - Default - 4127;%(DisableSpecificWarnings) - - - Cleanup - del $(IntDir)*.obj $(IntDir)*.tlog $(IntDir)*.lastbuildstate - - - - - Full - .;../../include;../../src;%(AdditionalIncludeDirectories) - QWIN_GUI;NDEBUG;%(PreprocessorDefinitions) - - - MultiThreaded - NotUsing - Level4 - - - Default - 4127;%(DisableSpecificWarnings) - false - - - Cleanup - del $(IntDir)*.obj $(IntDir)*.tlog $(IntDir)*.lastbuildstate - - - - - Full - .;../../include;../../src;%(AdditionalIncludeDirectories) - QWIN_GUI;NDEBUG;%(PreprocessorDefinitions) - - - MultiThreaded - NotUsing - Level4 - - - Default - 4127;%(DisableSpecificWarnings) - false - - - Cleanup - del $(IntDir)*.obj $(IntDir)*.tlog $(IntDir)*.lastbuildstate - - - - - Disabled - .;../../include;../../src;%(AdditionalIncludeDirectories) - Q_SPY;QWIN_GUI;_DEBUG;%(PreprocessorDefinitions) - - - MultiThreaded - NotUsing - Level4 - ProgramDatabase - Default - 4127;%(DisableSpecificWarnings) - - - Cleanup - del $(IntDir)*.obj $(IntDir)*.tlog $(IntDir)*.lastbuildstate - - - - - Disabled - .;../../include;../../src;%(AdditionalIncludeDirectories) - Q_SPY;QWIN_GUI;_DEBUG;%(PreprocessorDefinitions) - - - MultiThreaded - NotUsing - Level4 - ProgramDatabase - Default - 4127;%(DisableSpecificWarnings) - - - Cleanup - del $(IntDir)*.obj $(IntDir)*.tlog $(IntDir)*.lastbuildstate - - - - - Disabled - .;../../include;../../src;%(AdditionalIncludeDirectories) - Q_SPY;QWIN_GUI;_DEBUG;%(PreprocessorDefinitions) - - - MultiThreaded - NotUsing - Level4 - ProgramDatabase - Default - 4127;%(DisableSpecificWarnings) - - - Cleanup - del $(IntDir)*.obj $(IntDir)*.tlog $(IntDir)*.lastbuildstate - - - - - Disabled - .;../../include;../../src;%(AdditionalIncludeDirectories) - Q_SPY;QWIN_GUI;_DEBUG;%(PreprocessorDefinitions) - - - MultiThreaded - NotUsing - Level4 - ProgramDatabase - Default - 4127;%(DisableSpecificWarnings) - - - Cleanup - del $(IntDir)*.obj $(IntDir)*.tlog $(IntDir)*.lastbuildstate - - - - - true - true - - - true - true - - - true - true - - - - - true - true - true - true - - - - - - - - - - - - - - - - - true - true - false - false - false - false - true - true - - - true - true - false - false - false - false - true - true - - - true - true - false - false - false - false - true - true - - - true - true - false - false - false - false - true - true - - - true - true - true - true - true - true - true - true - - - - true - true - true - true - - - - - - - - - - - - \ No newline at end of file diff --git a/elab/3rd/qpc/ports/win32/qp.vcxproj.filters b/elab/3rd/qpc/ports/win32/qp.vcxproj.filters deleted file mode 100644 index 7482ddb513af263b9b297b4374219fa7c6953c5e..0000000000000000000000000000000000000000 --- a/elab/3rd/qpc/ports/win32/qp.vcxproj.filters +++ /dev/null @@ -1,90 +0,0 @@ - - - - - {56273036-d67c-489b-bc4b-84d286c6a000} - - - {553ace6f-efbf-49d9-be33-15209894492c} - - - {f23cedd0-0f13-4d39-b4f1-77eaa32e87fd} - - - {a9d19e53-4919-44a0-b925-5b00e2189525} - - - - - QP_port - - - QWIN-GUI - - - QP - - - QP - - - QP - - - QP - - - QP - - - QP - - - QP - - - QP - - - QP - - - QP - - - QP - - - QP - - - QS - - - QS - - - QS - - - QS - - - QS - - - QP_port - - - - - QP_port - - - QP_port - - - QWIN-GUI - - - \ No newline at end of file diff --git a/elab/3rd/qpc/ports/win32/qs_port.c b/elab/3rd/qpc/ports/win32/qs_port.c deleted file mode 100644 index 69a91c4dd89ec08418a66305f3c9416851a312ae..0000000000000000000000000000000000000000 --- a/elab/3rd/qpc/ports/win32/qs_port.c +++ /dev/null @@ -1,307 +0,0 @@ -/** -* @file -* @brief QS/C port for Win32 API -* @ingroup ports -* @cond -****************************************************************************** -* Last updated for version 6.9.3 -* Last updated on 2021-03-16 -* -* Q u a n t u m L e a P s -* ------------------------ -* Modern Embedded Software -* -* Copyright (C) 2005-2021 Quantum Leaps, LLC. All rights reserved. -* -* This program is open source software: you can redistribute it and/or -* modify it under the terms of the GNU General Public License as published -* by the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* Alternatively, this program may be distributed and modified under the -* terms of Quantum Leaps commercial licenses, which expressly supersede -* the GNU General Public License and are specifically designed for -* licensees interested in retaining the proprietary status of their code. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -* -* Contact information: -* -* -****************************************************************************** -* @endcond -*/ -#ifndef Q_SPY - #error "Q_SPY must be defined to compile qs_port.c" -#endif /* Q_SPY */ - -#define QP_IMPL /* this is QP implementation */ -#include "qf_port.h" /* QF port */ -#include "qassert.h" /* QP embedded systems-friendly assertions */ -#include "qs_port.h" /* QS port */ -#include "qs_pkg.h" /* QS package-scope interface */ - -#include "safe_std.h" /* portable "safe" / facilities */ -#include -#include -#include - -/* Minimum required Windows version is Windows-XP or newer (0x0501) */ -#ifdef WINVER -#undef WINVER -#endif -#ifdef _WIN32_WINNT -#undef _WIN32_WINNT -#endif - -#define WINVER _WIN32_WINNT_WINXP -#define _WIN32_WINNT _WIN32_WINNT_WINXP - -#include - -/*Q_DEFINE_THIS_MODULE("qs_port")*/ - -#define QS_TX_SIZE (8*1024) -#define QS_RX_SIZE (2*1024) -#define QS_TX_CHUNK QS_TX_SIZE -#define QS_TIMEOUT_MS 10 - -/* local variables .........................................................*/ -static SOCKET l_sock = INVALID_SOCKET; - -/*..........................................................................*/ -uint8_t QS_onStartup(void const *arg) { - static uint8_t qsBuf[QS_TX_SIZE]; /* buffer for QS-TX channel */ - static uint8_t qsRxBuf[QS_RX_SIZE]; /* buffer for QS-RX channel */ - char hostName[128]; - char const *serviceName = "6601"; /* default QSPY server port */ - char const *src; - char *dst; - int status; - - struct addrinfo *result = NULL; - struct addrinfo *rp = NULL; - struct addrinfo hints; - BOOL sockopt_bool; - ULONG ioctl_opt; - WSADATA wsaData; - - /* initialize the QS transmit and receive buffers */ - QS_initBuf(qsBuf, sizeof(qsBuf)); - QS_rxInitBuf(qsRxBuf, sizeof(qsRxBuf)); - - /* initialize Windows sockets version 2.2 */ - if (WSAStartup(MAKEWORD(2, 2), &wsaData) != NO_ERROR) { - FPRINTF_S(stderr, " ERROR %s\n", - "Windows Sockets cannot be initialized"); - goto error; - } - - /* extract hostName from 'arg' (hostName:port_remote)... */ - src = (arg != (void *)0) - ? (char const *)arg - : "localhost"; /* default QSPY host */ - dst = hostName; - while ((*src != '\0') - && (*src != ':') - && (dst < &hostName[sizeof(hostName) - 1])) - { - *dst++ = *src++; - } - *dst = '\0'; /* zero-terminate hostName */ - - /* extract serviceName from 'arg' (hostName:serviceName)... */ - if (*src == ':') { - serviceName = src + 1; - } - - memset(&hints, 0, sizeof(hints)); - hints.ai_family = AF_INET; - hints.ai_socktype = SOCK_STREAM; - hints.ai_protocol = IPPROTO_TCP; - status = getaddrinfo(hostName, serviceName, &hints, &result); - if (status != 0) { - FPRINTF_S(stderr, - " ERROR cannot resolve host Name=%s:%s,Err=%d\n", - hostName, serviceName, status); - goto error; - } - - for (rp = result; rp != NULL; rp = rp->ai_next) { - l_sock = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol); - if (l_sock != INVALID_SOCKET) { - if (connect(l_sock, rp->ai_addr, (int)rp->ai_addrlen) - == SOCKET_ERROR) - { - closesocket(l_sock); - l_sock = INVALID_SOCKET; - } - break; - } - } - - freeaddrinfo(result); - - /* socket could not be opened & connected? */ - if (l_sock == INVALID_SOCKET) { - FPRINTF_S(stderr, " ERROR cannot connect to QSPY at " - "host=%s:%s\n", - hostName, serviceName); - goto error; - } - - /* set the socket to non-blocking mode */ - ioctl_opt = 1; - if (ioctlsocket(l_sock, FIONBIO, &ioctl_opt) != NO_ERROR) { - FPRINTF_S(stderr, " ERROR %s WASErr=%d\n,", - "Failed to set non-blocking socket", WSAGetLastError()); - goto error; - } - - /* configure the socket to reuse the address and not to linger */ - sockopt_bool = TRUE; - setsockopt(l_sock, SOL_SOCKET, SO_REUSEADDR, - (const char *)&sockopt_bool, sizeof(sockopt_bool)); - sockopt_bool = TRUE; - setsockopt(l_sock, SOL_SOCKET, SO_DONTLINGER, - (const char *)&sockopt_bool, sizeof(sockopt_bool)); - QS_onFlush(); - - return 1U; /* success */ - -error: - return 0U; /* failure */ -} -/*..........................................................................*/ -void QS_onCleanup(void) { - if (l_sock != INVALID_SOCKET) { - closesocket(l_sock); - l_sock = INVALID_SOCKET; - } - WSACleanup(); - /*PRINTF_S(" Disconnected from QSPY\n");*/ -} -/*..........................................................................*/ -void QS_onReset(void) { - QS_onCleanup(); - exit(0); -} -/*..........................................................................*/ -void QS_onFlush(void) { - uint16_t nBytes; - uint8_t const *data; - QS_CRIT_STAT_ - - if (l_sock == INVALID_SOCKET) { /* socket NOT initialized? */ - FPRINTF_S(stderr, " ERROR %s\n", - "invalid TCP socket"); - return; - } - - nBytes = QS_TX_CHUNK; - QS_CRIT_E_(); - while ((data = QS_getBlock(&nBytes)) != (uint8_t *)0) { - QS_CRIT_X_(); - for (;;) { /* for-ever until break or return */ - int nSent = send(l_sock, (char const *)data, (int)nBytes, 0); - if (nSent == SOCKET_ERROR) { /* sending failed? */ - int err = WSAGetLastError(); - if (err == WSAEWOULDBLOCK) { - /* sleep for the timeout and then loop back - * to send() the SAME data again - */ - Sleep(QS_TIMEOUT_MS); - } - else { /* some other socket error... */ - FPRINTF_S(stderr, " ERROR %s WASErr=%d\n", - "sending data over TCP", err); - return; - } - } - else if (nSent < (int)nBytes) { /* sent fewer than requested? */ - Sleep(QS_TIMEOUT_MS); /* sleep for the timeout */ - /* adjust the data and loop back to send() the rest */ - data += nSent; - nBytes -= (uint16_t)nSent; - } - else { - break; /* break out of the for-ever loop */ - } - } - /* set nBytes for the next call to QS_getBlock() */ - nBytes = QS_TX_CHUNK; - QS_CRIT_E_(); - } - QS_CRIT_X_(); -} -/*..........................................................................*/ -QSTimeCtr QS_onGetTime(void) { - LARGE_INTEGER time; - QueryPerformanceCounter(&time); - return (QSTimeCtr)time.QuadPart; -} - -/*..........................................................................*/ -void QS_output(void) { - uint16_t nBytes; - uint8_t const *data; - QS_CRIT_STAT_ - - if (l_sock == INVALID_SOCKET) { /* socket NOT initialized? */ - FPRINTF_S(stderr, " ERROR %s\n", - "invalid TCP socket"); - return; - } - - nBytes = QS_TX_CHUNK; - QS_CRIT_E_(); - if ((data = QS_getBlock(&nBytes)) != (uint8_t *)0) { - QS_CRIT_X_(); - for (;;) { /* for-ever until break or return */ - int nSent = send(l_sock, (char const *)data, (int)nBytes, 0); - if (nSent == SOCKET_ERROR) { /* sending failed? */ - int err = WSAGetLastError(); - if (err == WSAEWOULDBLOCK) { - /* sleep for the timeout and then loop back - * to send() the SAME data again - */ - Sleep(QS_TIMEOUT_MS); - } - else { /* some other socket error... */ - FPRINTF_S(stderr, " ERROR sending data over TCP," - "WASErr=%d\n", err); - return; - } - } - else if (nSent < (int)nBytes) { /* sent fewer than requested? */ - Sleep(QS_TIMEOUT_MS); /* sleep for the timeout */ - /* adjust the data and loop back to send() the rest */ - data += nSent; - nBytes -= (uint16_t)nSent; - } - else { - break; - } - } - } - else { - QS_CRIT_X_(); - } -} -/*..........................................................................*/ -void QS_rx_input(void) { - int status = recv(l_sock, - (char *)QS_rxPriv_.buf, (int)QS_rxPriv_.end, 0); - if (status > 0) { /* any data received? */ - QS_rxPriv_.tail = 0U; - QS_rxPriv_.head = status; /* # bytes received */ - QS_rxParse(); /* parse all received bytes */ - } -} - diff --git a/elab/3rd/qpc/ports/win32/qs_port.h b/elab/3rd/qpc/ports/win32/qs_port.h deleted file mode 100644 index e2e20c03a31a1bb8dbaac4134df6349bbc73a177..0000000000000000000000000000000000000000 --- a/elab/3rd/qpc/ports/win32/qs_port.h +++ /dev/null @@ -1,67 +0,0 @@ -/** -* @file -* @brief QS/C port to Win32 with GNU or Visual C++ compilers -* @ingroup ports -* @cond -****************************************************************************** -* Last Updated for Version: 6.3.6 -* Date of the Last Update: 2018-10-14 -* -* Q u a n t u m L e a P s -* ------------------------ -* Modern Embedded Software -* -* Copyright (C) 2005-2018 Quantum Leaps, LLC. All rights reserved. -* -* This program is open source software: you can redistribute it and/or -* modify it under the terms of the GNU General Public License as published -* by the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* Alternatively, this program may be distributed and modified under the -* terms of Quantum Leaps commercial licenses, which expressly supersede -* the GNU General Public License and are specifically designed for -* licensees interested in retaining the proprietary status of their code. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -* -* Contact information: -* -* -****************************************************************************** -* @endcond -*/ -#ifndef QS_PORT_H -#define QS_PORT_H - -#define QS_TIME_SIZE 4 - -#ifdef _WIN64 /* 64-bit architecture? */ - #define QS_OBJ_PTR_SIZE 8 - #define QS_FUN_PTR_SIZE 8 -#else /* 32-bit architecture */ - #define QS_OBJ_PTR_SIZE 4 - #define QS_FUN_PTR_SIZE 4 -#endif - -void QS_output(void); /* handle the QS output */ -void QS_rx_input(void); /* handle the QS-RX input */ - -/***************************************************************************** -* NOTE: QS might be used with or without other QP components, in which -* case the separate definitions of the macros QF_CRIT_STAT_TYPE, -* QF_CRIT_ENTRY, and QF_CRIT_EXIT are needed. In this port QS is configured -* to be used with the other QP component, by simply including "qf_port.h" -* *before* "qs.h". -*/ -#include "qf_port.h" /* use QS with QF */ -#include "qs.h" /* QS platform-independent public interface */ - -#endif /* QS_PORT_H */ - diff --git a/elab/3rd/qpc/ports/win32/rel/libqp.a b/elab/3rd/qpc/ports/win32/rel/libqp.a deleted file mode 100644 index 3bbf93c9a0c3f321af7f8d8e67ebd7c266b716a9..0000000000000000000000000000000000000000 Binary files a/elab/3rd/qpc/ports/win32/rel/libqp.a and /dev/null differ diff --git a/elab/3rd/qpc/ports/win32/spy/libqp.a b/elab/3rd/qpc/ports/win32/spy/libqp.a deleted file mode 100644 index 8c316b398c650d8011db19005c54a69bb812ea79..0000000000000000000000000000000000000000 Binary files a/elab/3rd/qpc/ports/win32/spy/libqp.a and /dev/null differ diff --git a/elab/3rd/qpc/qpc_export.c b/elab/3rd/qpc/qpc_export.c index 4a003a663d3d34f91e9ce034447dbe4a9d1940b0..645279ec776a7923d1f91dc4a3be2835f7a8acd6 100644 --- a/elab/3rd/qpc/qpc_export.c +++ b/elab/3rd/qpc/qpc_export.c @@ -8,7 +8,7 @@ #include #include "event_def.h" #include "include/qpc.h" -#include "eLab/elab.h" +#include "elab/elab.h" ELAB_TAG("QpExport"); @@ -21,20 +21,7 @@ static uint32_t time_ms_backup; static elab_event_t event_poll[ELAB_EVENT_POOL_SIZE]; #endif -static const osThreadAttr_t thread_attr = -{ - .name = "qp_export", - .attr_bits = osThreadDetached, - .priority = osPriorityRealtime, - .stack_size = 2048, -}; - /* Exported functions --------------------------------------------------------*/ -static void _thread_entry(void *para) -{ - QF_run(); -} - static void qpc_export(void) { #if (ELAB_QPC_EN != 0) @@ -48,11 +35,9 @@ static void qpc_export(void) /* Initialize event pool. */ QF_poolInit(event_poll, sizeof(event_poll), sizeof(elab_event_t)); - osThreadNew(_thread_entry, NULL, &thread_attr); - elog_debug("QPC export end."); + QF_run(); #endif } - INIT_EXPORT(qpc_export, 0); /* Exported functions --------------------------------------------------------*/ diff --git a/elab/3rd/qpc/src/qf/qep_hsm.c b/elab/3rd/qpc/src/qf/qep_hsm.c index 6e723be821f07b1665d21cc837b22afc8986f78b..f5a66fcbc40fb776e2bd8ad05b832b889f7dc673 100644 --- a/elab/3rd/qpc/src/qf/qep_hsm.c +++ b/elab/3rd/qpc/src/qf/qep_hsm.c @@ -38,7 +38,11 @@ * @endcond */ #define QP_IMPL /* this is QP implementation */ -#include "qep_port.h" /* QEP port */ +#if defined(__linux__) +#include "../../ports/posix/qf_port.h" /* QF port */ +#else +#include "../../ports/freertos/qf_port.h" /* QF port */ +#endif #include "../../include/qassert.h" /* QP embedded systems-friendly assertions */ #ifdef Q_SPY /* QS software tracing enabled? */ #include "qs_port.h" /* QS port */ diff --git a/elab/3rd/qpc/src/qf/qep_msm.c b/elab/3rd/qpc/src/qf/qep_msm.c index 0196c259ff453979d370f4ad9af42fde22002a54..d8263fa2965c7d04f97cd4db0d717b9e55963e26 100644 --- a/elab/3rd/qpc/src/qf/qep_msm.c +++ b/elab/3rd/qpc/src/qf/qep_msm.c @@ -38,7 +38,11 @@ * @endcond */ #define QP_IMPL /* this is QP implementation */ -#include "qep_port.h" /* QEP port */ +#if defined(__linux__) +#include "../../ports/posix/qf_port.h" /* QF port */ +#else +#include "../../ports/freertos/qf_port.h" /* QF port */ +#endif #include "../../include/qassert.h" /* QP embedded systems-friendly assertions */ #ifdef Q_SPY /* QS software tracing enabled? */ #include "qs_port.h" /* QS port */ diff --git a/elab/3rd/qpc/src/qf/qf_act.c b/elab/3rd/qpc/src/qf/qf_act.c index 4ab6296c1b94c35c7b63274be1095a5a6231344c..ffcf6b90d51abaa559f746d9d78f35eff5e8c793 100644 --- a/elab/3rd/qpc/src/qf/qf_act.c +++ b/elab/3rd/qpc/src/qf/qf_act.c @@ -38,7 +38,11 @@ * @endcond */ #define QP_IMPL /* this is QP implementation */ -#include "qf_port.h" /* QF port */ +#if defined(__linux__) +#include "../../ports/posix/qf_port.h" /* QF port */ +#else +#include "../../ports/freertos/qf_port.h" /* QF port */ +#endif #include "../qf_pkg.h" /* QF package-scope interface */ #include "../../include/qassert.h" /* QP embedded systems-friendly assertions */ #ifdef Q_SPY /* QS software tracing enabled? */ diff --git a/elab/3rd/qpc/src/qf/qf_actq.c b/elab/3rd/qpc/src/qf/qf_actq.c index f8266ea2c83d0ed00fb9622c5eadadd9ae12d281..c9ff1f36e970117f4ba5ec2a7a639f0c8da91aae 100644 --- a/elab/3rd/qpc/src/qf/qf_actq.c +++ b/elab/3rd/qpc/src/qf/qf_actq.c @@ -43,7 +43,11 @@ * @endcond */ #define QP_IMPL /* this is QP implementation */ -#include "qf_port.h" /* QF port */ +#if defined(__linux__) +#include "../../ports/posix/qf_port.h" /* QF port */ +#else +#include "../../ports/freertos/qf_port.h" /* QF port */ +#endif #include "../qf_pkg.h" /* QF package-scope interface */ #include "../../include/qassert.h" /* QP embedded systems-friendly assertions */ #ifdef Q_SPY /* QS software tracing enabled? */ diff --git a/elab/3rd/qpc/src/qf/qf_defer.c b/elab/3rd/qpc/src/qf/qf_defer.c index e1576e5bd844a5738394c8bae835c15b3fbaaf2b..a6edf17c1d98a7b717a4dec6036a1c25e862ab19 100644 --- a/elab/3rd/qpc/src/qf/qf_defer.c +++ b/elab/3rd/qpc/src/qf/qf_defer.c @@ -38,7 +38,11 @@ * @endcond */ #define QP_IMPL /* this is QP implementation */ -#include "qf_port.h" /* QF port */ +#if defined(__linux__) +#include "../../ports/posix/qf_port.h" /* QF port */ +#else +#include "../../ports/freertos/qf_port.h" /* QF port */ +#endif #include "../qf_pkg.h" /* QF package-scope interface */ #include "../../include/qassert.h" /* QP embedded systems-friendly assertions */ #ifdef Q_SPY /* QS software tracing enabled? */ diff --git a/elab/3rd/qpc/src/qf/qf_dyn.c b/elab/3rd/qpc/src/qf/qf_dyn.c index 272189cf69cfae8889f54151934ef89b98c52eb1..48c625b0e82e5995fdb32988005d95db9b3b1c49 100644 --- a/elab/3rd/qpc/src/qf/qf_dyn.c +++ b/elab/3rd/qpc/src/qf/qf_dyn.c @@ -38,7 +38,11 @@ * @endcond */ #define QP_IMPL /* this is QP implementation */ -#include "qf_port.h" /* QF port */ +#if defined(__linux__) +#include "../../ports/posix/qf_port.h" /* QF port */ +#else +#include "../../ports/freertos/qf_port.h" /* QF port */ +#endif #include "../qf_pkg.h" /* QF package-scope interface */ #include "../../include/qassert.h" /* QP embedded systems-friendly assertions */ #ifdef Q_SPY /* QS software tracing enabled? */ diff --git a/elab/3rd/qpc/src/qf/qf_mem.c b/elab/3rd/qpc/src/qf/qf_mem.c index 219861ea4710cd09d54b5fbbfc5560f31913f62a..6540388bf9f5db87aa709bae594b8abff1a10e2b 100644 --- a/elab/3rd/qpc/src/qf/qf_mem.c +++ b/elab/3rd/qpc/src/qf/qf_mem.c @@ -38,7 +38,11 @@ * @endcond */ #define QP_IMPL /* this is QP implementation */ -#include "qf_port.h" /* QF port */ +#if defined(__linux__) +#include "../../ports/posix/qf_port.h" /* QF port */ +#else +#include "../../ports/freertos/qf_port.h" /* QF port */ +#endif #include "../qf_pkg.h" /* QF package-scope interface */ #include "../../include/qassert.h" /* QP embedded systems-friendly assertions */ #ifdef Q_SPY /* QS software tracing enabled? */ diff --git a/elab/3rd/qpc/src/qf/qf_ps.c b/elab/3rd/qpc/src/qf/qf_ps.c index 01d66ac793cbec52a68977c428ee702a2c9e20ad..4f1475f6e7971bcae34b75e1401ad6ff795a005d 100644 --- a/elab/3rd/qpc/src/qf/qf_ps.c +++ b/elab/3rd/qpc/src/qf/qf_ps.c @@ -38,7 +38,11 @@ * @endcond */ #define QP_IMPL /* this is QP implementation */ -#include "qf_port.h" /* QF port */ +#if defined(__linux__) +#include "../../ports/posix/qf_port.h" /* QF port */ +#else +#include "../../ports/freertos/qf_port.h" /* QF port */ +#endif #include "../qf_pkg.h" /* QF package-scope interface */ #include "../../include/qassert.h" /* QP embedded systems-friendly assertions */ #ifdef Q_SPY /* QS software tracing enabled? */ diff --git a/elab/3rd/qpc/src/qf/qf_qact.c b/elab/3rd/qpc/src/qf/qf_qact.c index 9d65a7cbcc4bfb9f1fe39250a8e522c30d79efdb..f6e205472484b8604f68bfcc50e6384e313a3d04 100644 --- a/elab/3rd/qpc/src/qf/qf_qact.c +++ b/elab/3rd/qpc/src/qf/qf_qact.c @@ -46,7 +46,11 @@ * @endcond */ #define QP_IMPL /* this is QP implementation */ -#include "qf_port.h" /* QF port */ +#if defined(__linux__) +#include "../../ports/posix/qf_port.h" /* QF port */ +#else +#include "../../ports/freertos/qf_port.h" /* QF port */ +#endif #include "../qf_pkg.h" /* QF package-scope interface */ /*Q_DEFINE_THIS_MODULE("qf_qact")*/ diff --git a/elab/3rd/qpc/src/qf/qf_qeq.c b/elab/3rd/qpc/src/qf/qf_qeq.c index 6a30abeadc715e3a4c105b4903b47d7bac687a6d..6938d96b6b895c745b1a54fc9059bbf857b9c4b1 100644 --- a/elab/3rd/qpc/src/qf/qf_qeq.c +++ b/elab/3rd/qpc/src/qf/qf_qeq.c @@ -38,7 +38,11 @@ * @endcond */ #define QP_IMPL /* this is QP implementation */ -#include "qf_port.h" /* QF port */ +#if defined(__linux__) +#include "../../ports/posix/qf_port.h" /* QF port */ +#else +#include "../../ports/freertos/qf_port.h" /* QF port */ +#endif #include "../qf_pkg.h" /* QF package-scope interface */ #include "../../include/qassert.h" /* QP embedded systems-friendly assertions */ #ifdef Q_SPY /* QS software tracing enabled? */ diff --git a/elab/3rd/qpc/src/qf/qf_qmact.c b/elab/3rd/qpc/src/qf/qf_qmact.c index d4173b166b3500e86b15e3a01b2edf6dbe47f9d0..7342f7eb90464f521a952f180da4167270fd2bf3 100644 --- a/elab/3rd/qpc/src/qf/qf_qmact.c +++ b/elab/3rd/qpc/src/qf/qf_qmact.c @@ -46,7 +46,11 @@ * @endcond */ #define QP_IMPL /* this is QP implementation */ -#include "qf_port.h" /* QF port */ +#if defined(__linux__) +#include "../../ports/posix/qf_port.h" /* QF port */ +#else +#include "../../ports/freertos/qf_port.h" /* QF port */ +#endif #include "../qf_pkg.h" /* QF package-scope interface */ /*Q_DEFINE_THIS_MODULE("qf_qmact")*/ diff --git a/elab/3rd/qpc/src/qf/qf_time.c b/elab/3rd/qpc/src/qf/qf_time.c index 1b6bd77b29c7c3f7f6f02e2eb653dadc92e3d161..85ccf57c66a9e2b35fc484baf18e5b20a971d382 100644 --- a/elab/3rd/qpc/src/qf/qf_time.c +++ b/elab/3rd/qpc/src/qf/qf_time.c @@ -38,7 +38,11 @@ * @endcond */ #define QP_IMPL /* this is QP implementation */ -#include "qf_port.h" /* QF port */ +#if defined(__linux__) +#include "../../ports/posix/qf_port.h" /* QF port */ +#else +#include "../../ports/freertos/qf_port.h" /* QF port */ +#endif #include "../qf_pkg.h" /* QF package-scope interface */ #include "../../include/qassert.h" /* QP embedded systems-friendly assertions */ #ifdef Q_SPY /* QS software tracing enabled? */ diff --git a/elab/common/elab_assert.c b/elab/common/elab_assert.c index 932c9f53b510404706bc54c389f2f50982040714..a562cba7bc34576fafce3a0c71edf8238fc0b15a 100644 --- a/elab/common/elab_assert.c +++ b/elab/common/elab_assert.c @@ -10,7 +10,7 @@ #include "assert.h" #endif #if (ELAB_RTOS_CMSIS_OS_EN != 0) -#include "../RTOS/cmsis_os.h" +#include "../os/cmsis_os.h" #endif #if (ELAB_RTOS_BASIC_OS_EN != 0) #include "basic_os.h" diff --git a/elab/common/elab_common.c b/elab/common/elab_common.c index fedf0f2b1ea0b2557d6515a45d42cd65cf605bf1..9ebb899979e7cc464849802bbe1189e8522b113d 100644 --- a/elab/common/elab_common.c +++ b/elab/common/elab_common.c @@ -5,7 +5,71 @@ /* include ------------------------------------------------------------------ */ #include -#include "../elab.h" +#include +#include +#include +#include "elab_common.h" + +#if defined(__linux__) +#include +#include +#endif + +#if defined(_WIN32) +#include +#include "../os/cmsis_os.h" + +/* private defines ---------------------------------------------------------- */ +#define KEY_CTRL_C (0x03) // Value of the CTRL+C key +#define KEY_Fn (0x00) // The 1st byte of F1 - F12 +#define KEY_FUNCTION (0xE0) + +/* private typedef -----------------------------------------------------------*/ +typedef struct spec_func_key_data +{ + uint8_t count; + uint8_t v_linux[5]; + uint8_t v_win_terminal[2]; +} spec_func_key_data_t; + +/* private variables -------------------------------------------------------- */ +static const spec_func_key_data_t _sf_key_data[] = +{ + { 3, { 0x1B, 0x4F, 0x50, 0x00, 0x00 }, { 0x00, 0x3B } }, /* F1 */ + { 3, { 0x1B, 0x4F, 0x51, 0x00, 0x00 }, { 0x00, 0x3C } }, /* F2 */ + { 3, { 0x1B, 0x4F, 0x52, 0x00, 0x00 }, { 0x00, 0x3D } }, /* F3 */ + { 3, { 0x1B, 0x4F, 0x53, 0x00, 0x00 }, { 0x00, 0x3E } }, /* F4 */ + { 5, { 0x1B, 0x5B, 0x31, 0x35, 0x7E }, { 0x00, 0x3F } }, /* F5 */ + { 5, { 0x1B, 0x5B, 0x31, 0x37, 0x7E }, { 0x00, 0x40 } }, /* F6 */ + { 5, { 0x1B, 0x5B, 0x31, 0x38, 0x7E }, { 0x00, 0x41 } }, /* F7 */ + { 5, { 0x1B, 0x5B, 0x31, 0x39, 0x7E }, { 0x00, 0x42 } }, /* F8 */ + { 5, { 0x1B, 0x5B, 0x32, 0x30, 0x7E }, { 0x00, 0x43 } }, /* F9 */ + { 5, { 0x1B, 0x5B, 0x32, 0x31, 0x7E }, { 0x00, 0x44 } }, /* F10 */ + { 5, { 0x1B, 0x5B, 0x32, 0x32, 0x7E }, { 0x00, 0xFF } }, /* F11 */ + { 5, { 0x1B, 0x5B, 0x32, 0x33, 0x7E }, { 0xE0, 0x86 } }, /* F12 */ + + { 3, { 0x1B, 0x5B, 0x41, 0x00, 0x00 }, { 0xE0, 0x48 } }, /* UP */ + { 3, { 0x1B, 0x5B, 0x42, 0x00, 0x00 }, { 0xE0, 0x50 } }, /* DOWN */ + { 3, { 0x1B, 0x5B, 0x43, 0x00, 0x00 }, { 0xE0, 0x4B } }, /* LEFT */ + { 3, { 0x1B, 0x5B, 0x44, 0x00, 0x00 }, { 0xE0, 0x4D } }, /* RIGHT */ + + { 4, { 0x1B, 0x5B, 0x31, 0x7E, 0x00 }, { 0xE0, 0x47 } }, /* HOME */ + { 4, { 0x1B, 0x5B, 0x32, 0x7E, 0x00 }, { 0xE0, 0x52 } }, /* INSERT */ + { 4, { 0x1B, 0x5B, 0x33, 0x7E, 0x00 }, { 0xE0, 0x53 } }, /* DELECT */ + { 4, { 0x1B, 0x5B, 0x34, 0x7E, 0x00 }, { 0xE0, 0x4F } }, /* END */ + { 4, { 0x1B, 0x5B, 0x35, 0x7E, 0x00 }, { 0xE0, 0x49 } }, /* PAGEUP */ + { 4, { 0x1B, 0x5B, 0x36, 0x7E, 0x00 }, { 0xE0, 0x51 } }, /* PAGEDOWN */ +}; + +static osMessageQueueId_t mq_getch = NULL; + +/* private function prototypes -----------------------------------------------*/ +static void _entry_getch(void *para); +#endif + +#if defined(__linux__) +static int getch(void); +#endif /* public function ---------------------------------------------------------- */ uint32_t elab_version(void) @@ -13,6 +77,27 @@ uint32_t elab_version(void) return 000100; } +/** + * @brief eLab initialization exporting function. + * @param level init level. + * @retval None + */ +uint32_t elab_time_ms(void) +{ +#if !defined(__linux__) +#if (ELAB_RTOS_CMSIS_OS_EN != 0) + return osKernelGetTickCount() * ELAB_RTOS_TICK_MS; +#elif (ELAB_RTOS_BASIC_OS_EN != 0) + return bos_time(); +#else + return 0; +#endif +#else + return osKernelGetTickCount(); +#endif +} + +#if !defined(__linux__) && !defined(_WIN32) /** * @brief eLab debug uart weak initialization function. * @param baudrate The uart port baudrate. @@ -38,19 +123,178 @@ ELAB_WEAK int16_t elab_debug_uart_receive(void *buffer, uint16_t size) return 0; } +#endif -ELAB_WEAK void elab_debug_uart_buffer_clear(void) +#if !defined(__linux__) && !defined(_WIN32) +ELAB_WEAK +#endif +void *elab_malloc(uint32_t size) { + return malloc(size); } -ELAB_WEAK void *elab_malloc(uint32_t size) +#if !defined(__linux__) && !defined(_WIN32) +ELAB_WEAK +#endif +void elab_free(void *memory) { - return malloc(size); + if (memory != NULL) + { + free(memory); + } +} + +#if defined(_WIN32) || defined(__linux__) +/** + * @brief The weak initialization function for the debug uart. + * @param baudrate uart baud rate + * @retval none + */ +void elab_debug_uart_init(uint32_t baudrate) +{ + (void)baudrate; + +#if defined(_WIN32) + static const osThreadAttr_t attr = + { + .name = "debug_uart", + .attr_bits = osThreadDetached, + .priority = osPriorityBelowNormal, + .stack_size = 2048, + }; + osThreadNew(_entry_getch, NULL, &attr); + + mq_getch = osMessageQueueNew(16, 1, NULL); + assert(mq_getch != NULL); +#endif } +#endif -ELAB_WEAK void elab_free(void *memory) +#if defined(_WIN32) || defined(__linux__) +int16_t elab_debug_uart_send(void *buffer, uint16_t size) { - free(memory); + char *buff_tx = (char *)buffer; + + for (uint16_t i = 0; i < size; i ++) + { + printf("%c", buff_tx[i]); + } + fflush(stdout); + + return 0; +} +#endif + +#if defined(_WIN32) +int16_t elab_debug_uart_receive(void *buffer, uint16_t size) +{ + osStatus_t ret_os = osOK; + int32_t ret = 0; + uint8_t *buff = (uint8_t *)buffer; + + for (uint32_t i = 0; i < size; i ++) + { + ret_os = osMessageQueueGet(mq_getch, &buff[i], NULL, 10); + if (ret_os == osOK) + { + ret ++; + continue; + } + if (ret_os == osErrorTimeout) + { + break; + } + + assert(false); + } + + return ret; +} + +#endif + +#if defined(__linux__) +int16_t elab_debug_uart_receive(void *buffer, uint16_t size) +{ + assert(size == 1); + + uint8_t *buff = (uint8_t *)buffer; + buff[0] = (uint8_t)getch(); + + return 1; +} +#endif + +/* private functions -------------------------------------------------------- */ +#if defined(_WIN32) + +/** + * @brief Thread function for getch(). + */ +static void _entry_getch(void *para) +{ + uint8_t value = 0; + + while (1) + { + value = getch(); + if (value == KEY_CTRL_C) + { + break; + } + + if ((KEY_FUNCTION == value) || (KEY_Fn == value)) + { + uint8_t key_win[2]; + key_win[0] = value; + key_win[1] = getch(); + + for (uint32_t i = 0; + i < sizeof(_sf_key_data) / sizeof(spec_func_key_data_t); + i ++) + { + if (_sf_key_data[i].v_win_terminal[0] == key_win[0] && + _sf_key_data[i].v_win_terminal[1] == key_win[1]) + { + for (uint32_t j = 0; j < _sf_key_data[i].count; j ++) + { + osMessageQueuePut(mq_getch, + &_sf_key_data[i].v_linux[j], + 0, osWaitForever); + } + break; + } + } + + continue; + } + + osMessageQueuePut(mq_getch, &value, 0, osWaitForever); + } +} + +#endif + +#if defined(__linux__) +/** + * @brief The original getch function for Linux which can get the input char + * in the terminal. + * @retval Key id. + */ +static int getch(void) +{ + int ch; + + struct termios tm, tm_old; + tcgetattr(STDIN_FILENO, &tm); + tm_old = tm; + tm.c_lflag &= ~(ICANON | ECHO); + tcsetattr(STDIN_FILENO, TCSANOW, &tm); + ch = getchar(); + tcsetattr(STDIN_FILENO, TCSANOW, &tm_old); + + return ch; } +#endif /* ----------------------------- end of file -------------------------------- */ diff --git a/elab/common/elab_common.h b/elab/common/elab_common.h index 295649ad0017dd08fa4919e76cb01546a565e374..51a0009e8588c2bfa464050878d8dbb6938c919f 100644 --- a/elab/common/elab_common.h +++ b/elab/common/elab_common.h @@ -11,8 +11,7 @@ #include "elab_config.h" #if (ELAB_RTOS_CMSIS_OS_EN != 0) -#include "../port/elab_port.h" -#include "../RTOS/cmsis_os.h" +#include "../os/cmsis_os.h" #endif #ifdef __cplusplus @@ -37,18 +36,8 @@ void elab_mcu_reset(void); void elab_debug_uart_init(uint32_t baudrate); int16_t elab_debug_uart_send(void *buffer, uint16_t size); int16_t elab_debug_uart_receive(void *buffer, uint16_t size); -void elab_debug_uart_buffer_clear(void); void elab_assert_func(void); -#if (ELAB_RTOS_CMSIS_OS_EN != 0) -/* thread related. */ -osThreadId_t elab_thread_init(elab_thread_t *const me, - void (*entry)(void *parameter), - const char *name, void *data, - void *stack, uint32_t stack_size, - uint8_t priority); -#endif - #ifdef __cplusplus } #endif diff --git a/elab/common/elab_def.h b/elab/common/elab_def.h index dbdff66f8c52b220cec3c18130d4b4c726054618..e52f7c235ce58320f8e61c21d0df87a18261ce1c 100644 --- a/elab/common/elab_def.h +++ b/elab/common/elab_def.h @@ -37,24 +37,6 @@ typedef enum elab_err ELAB_ERR_BUS = -13, } elab_err_t; -enum elab_export_level -{ - EXPORT_LEVEL_HW_INDEPNEDENT = 0, - EXPORT_DRVIVER, - EXPORT_COM, - EXPORT_APP, - EXPORT_LEVEL_MAX, -#if (ELAB_RTOS_CMSIS_OS_EN != 0) - EXPORT_THREAD = EXPORT_LEVEL_MAX, -#endif -#if (ELAB_QPC_EN != 0) - EXPORT_HSM, -#endif - EXPORT_TEST, - - EXPORT_MAX, -}; - typedef struct elab_date { uint32_t year : 16; diff --git a/elab/common/elab_export.c b/elab/common/elab_export.c index a4a7f3f644368b9fbd8a214bf3e0986d05a65cb2..730f0684f6e700a138f5e7f7f3b15b27541fc664 100644 --- a/elab/common/elab_export.c +++ b/elab/common/elab_export.c @@ -17,20 +17,12 @@ ELAB_TAG("eLabExport"); #if (ELAB_RTOS_CMSIS_OS_EN != 0) -#include "../RTOS/cmsis_os.h" -#endif -#if (ELAB_RTOS_BASIC_OS_EN != 0) -#include "basic_os.h" +#include "../os/cmsis_os.h" #endif #if (ELAB_RTOS_BASIC_OS_EN != 0) #include "basic_os.h" #endif -#if (ELAB_QPC_EN != 0) -#include "../3rd/qpc/include/qpc.h" -Q_DEFINE_THIS_FILE -#endif - #ifdef __cplusplus extern "C" { #endif @@ -40,6 +32,8 @@ extern "C" { #define ELAB_GLOBAL_STACK_SIZE (4096) #endif +#define ELAB_POLL_PERIOD_MAX (2592000000) /* 30 days */ + #if defined(__linux__) #define STR_ENTER "\n" #else @@ -48,7 +42,12 @@ extern "C" { /* private function prototype ----------------------------------------------- */ static void module_null_init(void); -static void _export_func_execute(int8_t level); +static void _init_func_execute(int8_t level); +static void _exit_func_execute(int8_t level); +static void _get_poll_export_table(void); +static void _get_init_export_table(void); +static void elab_exit(void); + #if (ELAB_RTOS_CMSIS_OS_EN != 0 || ELAB_RTOS_BASIC_OS_EN != 0) static void _entry_start_poll(void *para); #endif @@ -58,13 +57,16 @@ INIT_EXPORT(module_null_init, 0); POLL_EXPORT(module_null_init, (1000 * 60 * 60)); static elab_export_t *export_init_table = NULL; +static uint32_t count_export_init = 0; static elab_export_t *export_poll_table = NULL; +static uint32_t count_export_poll = 0; +static int8_t export_level_max = INT8_MIN; #if (ELAB_RTOS_CMSIS_OS_EN != 0) /** * @brief The thread attribute for testing. */ -static const osThreadAttr_t thread_attr_start_poll = +static const osThreadAttr_t thread_attr_export_poll = { .name = "ThreadStartPoll", .attr_bits = osThreadDetached, @@ -80,191 +82,247 @@ static const osThreadAttr_t thread_attr_start_poll = */ void elab_unit_test(void) { - _export_func_execute(EXPORT_TEST); + _init_func_execute(EXPORT_UNIT_TEST); } -#if (ELAB_RTOS_CMSIS_OS_EN == 0 && ELAB_RTOS_BASIC_OS_EN == 0) -static bool app_exit = false; -#endif -#if (ELAB_RTOS_CMSIS_OS_EN != 0 || ELAB_RTOS_BASIC_OS_EN != 0) -static bool app_exit_end = false; -#endif - -#if defined(__linux__) +#if defined(__linux__) || defined(_WIN32) +/** + * @brief Signal handler function on WIN32 or Linux. + * @retval None + */ static void signal_handler(int sig) { printf("Elab Signal: %d.\n", sig); elab_exit(); +#if defined(__linux__) system("stty echo"); +#endif printf("\033[0;0m\n"); - - app_exit_end = true; exit(-1); } #endif /** - * @brief eLab polling exporting function. + * @brief eLab startup function. * @retval None */ void elab_run(void) { -#if defined(__linux__) +#if defined(__linux__) || defined(_WIN32) signal(SIGINT, signal_handler); /* Ctrl + C*/ signal(SIGTERM, signal_handler); /* kill pid */ signal(SIGABRT, signal_handler); +#if defined(__linux__) signal(SIGKILL, signal_handler); /* kill -9 pid */ signal(SIGHUP, signal_handler); +#endif signal(SIGSEGV, signal_handler); #endif /* Start polling function in metal eLab, or start the RTOS kernel in RTOS eLab. */ + _get_init_export_table(); + _get_poll_export_table(); #if (ELAB_RTOS_CMSIS_OS_EN != 0 || ELAB_RTOS_BASIC_OS_EN != 0) osKernelInitialize(); #endif #if (ELAB_RTOS_CMSIS_OS_EN != 0) osKernelInitialize(); - osThreadNew(_entry_start_poll, NULL, &thread_attr_start_poll); + osThreadNew(_entry_start_poll, NULL, &thread_attr_export_poll); #endif #if (ELAB_RTOS_CMSIS_OS_EN != 0 || ELAB_RTOS_BASIC_OS_EN != 0) osKernelStart(); - - if (!app_exit_end) - { - elab_exit(); - } #elif (ELAB_RTOS_BASIC_OS_EN != 0) static uint32_t stack[1024]; eos_init(stack, 4096); eos_run(); #else /* Initialize all module in eLab. */ - for (uint8_t level = EXPORT_LEVEL_HW_INDEPNEDENT; - level <= EXPORT_APP; level ++) + for (uint8_t level = 0; level < export_level_max; level ++) { - _export_func_execute(level); + _init_func_execute(level); } /* Start polling function in metal eLab. */ - while (!app_exit) + while (1) { - _export_func_execute(EXPORT_MAX); + _poll_func_execute(); } #endif } -void elab_exit(void) +/* private function --------------------------------------------------------- */ +#if defined(__linux__) || defined(_WIN32) +/** + * @brief eLab exit function on WIN32 or Linux. + * @retval None + */ +static void elab_exit(void) { /* Initialize all module in eLab. */ - for (int32_t level = -EXPORT_APP; level <= -EXPORT_LEVEL_HW_INDEPNEDENT; level ++) + for (int32_t level = export_level_max; level >= 0; level --) { - _export_func_execute(level - 1); + _exit_func_execute(level); } } +#endif -/* private function --------------------------------------------------------- */ /** - * @brief Get the export table. + * @brief Get the init export table. */ -static elab_export_t * _get_export_table(uint8_t level) +static void _get_init_export_table(void) { - elab_export_t *func_block = - level < EXPORT_MAX ? - ((elab_export_t *)&init_module_null_init) : - ((elab_export_t *)&poll_module_null_init); + elab_export_t *func_block = (elab_export_t *)&init_module_null_init; elab_pointer_t address_last; - uint32_t export_id = level == EXPORT_MAX ? EXPORT_ID_POLL : EXPORT_ID_INIT; while (1) { address_last = ((elab_pointer_t)func_block - sizeof(elab_export_t)); elab_export_t *table = (elab_export_t *)address_last; - if (table->magic_head != export_id || - table->magic_tail != export_id) + if (table->magic_head != EXPORT_ID_INIT || + table->magic_tail != EXPORT_ID_INIT) { break; } func_block = table; } + export_init_table = func_block; - return func_block; + uint32_t i = 0; + while (1) + { + if (export_init_table[i].magic_head == EXPORT_ID_INIT && + export_init_table[i].magic_tail == EXPORT_ID_INIT) + { + if (export_init_table[i].level > export_level_max) + { + export_level_max = export_init_table[i].level; + } + i ++; + } + else + { + break; + } + } + count_export_init = i; } /** - * @brief eLab exporting function executing. - * @param level export level. - * @retval None + * @brief Get the polling export table. */ -static void _export_func_execute(int8_t level) +static void _get_poll_export_table(void) { - bool is_init = level >= 0 ? true : false; - level = level < 0 ? (-level - 1) : level; - elab_assert(level <= EXPORT_MAX); - uint32_t export_id = level == EXPORT_MAX ? EXPORT_ID_POLL : EXPORT_ID_INIT; + elab_export_t *func_block = ((elab_export_t *)&poll_module_null_init); + elab_pointer_t address_last; + + while (1) + { + address_last = ((elab_pointer_t)func_block - sizeof(elab_export_t)); + elab_export_t *table = (elab_export_t *)address_last; + if (table->magic_head != EXPORT_ID_POLL || + table->magic_tail != EXPORT_ID_POLL) + { + break; + } + func_block = table; + } + export_poll_table = func_block; - /* Get the start address of exported poll table. */ - if (export_init_table == NULL) + uint32_t i = 0; + while (1) { - export_init_table = _get_export_table(EXPORT_LEVEL_HW_INDEPNEDENT); + if (export_poll_table[i].magic_head == EXPORT_ID_POLL && + export_poll_table[i].magic_tail == EXPORT_ID_POLL) + { + assert_name(export_poll_table[i].period_ms <= ELAB_POLL_PERIOD_MAX, + export_poll_table[i].name); + elab_export_poll_data_t *data = + (elab_export_poll_data_t *)export_poll_table[i].data; + data->timeout_ms = elab_time_ms() + export_poll_table[i].period_ms; + i ++; + } + else + { + break; + } } - if (export_poll_table == NULL) + count_export_poll = i; +} + +/** + * @brief eLab init exporting function executing. + * @retval None + */ +static void _init_func_execute(int8_t level) +{ + /* Execute the poll function in the specific level. */ + for (uint32_t i = 0; i < count_export_init; i ++) { - export_poll_table = _get_export_table(EXPORT_MAX); + if (export_init_table[i].level == level) + { + if (!export_init_table[i].exit) + { + printf("Export init %s." STR_ENTER, export_init_table[i].name); + ((void (*)(void))export_init_table[i].func)(); + } + } } +} +/** + * @brief eLab exit exporting function executing. + * @retval None + */ +static void _exit_func_execute(int8_t level) +{ + /* Execute the poll function in the specific level. */ + for (uint32_t i = 0; i < count_export_init; i ++) + { + if (export_init_table[i].level == level) + { + if (export_init_table[i].exit) + { + printf("Export exit %s." STR_ENTER, export_init_table[i].name); + ((void (*)(void))export_init_table[i].func)(); + } + } + } +} + +/** + * @brief eLab polling exporting function executing. + * @retval None + */ +static void _poll_func_execute(void) +{ /* Execute the poll function in the specific level. */ - elab_export_t *export_table = level < EXPORT_MAX ? - export_init_table : export_poll_table; for (uint32_t i = 0; ; i ++) { - if (export_table[i].magic_head == export_id && - export_table[i].magic_tail == export_id) + if (export_poll_table[i].magic_head == EXPORT_ID_POLL && + export_poll_table[i].magic_tail == EXPORT_ID_POLL) { - if (export_table[i].level == level && level <= EXPORT_APP) + elab_export_poll_data_t *data = export_poll_table[i].data; + + while (1) { - if (is_init && export_table[i].type == EXPORT_TYPE_INIT) + uint64_t _time = (uint64_t)elab_time_ms(); + if (_time < (uint64_t)data->timeout_ms && + ((uint64_t)data->timeout_ms - _time) <= + (UINT32_MAX - ELAB_POLL_PERIOD_MAX)) { - printf("Export init %s." STR_ENTER, export_table[i].name); - ((void (*)(void))export_table[i].func)(); + _time += (UINT32_MAX + 1); } - if (!is_init && export_table[i].type == EXPORT_TYPE_EXIT) + + if (_time >= (uint64_t)data->timeout_ms) { - printf("Export exit %s." STR_ENTER, export_table[i].name); - ((void (*)(void))export_table[i].func)(); + data->timeout_ms += export_poll_table[i].period_ms; + ((void (*)(void))export_poll_table[i].func)(); } - } -#if (ELAB_RTOS_CMSIS_OS_EN != 0) - else if (export_table[i].level == level && level == EXPORT_THREAD) - { - elab_thread_init((elab_thread_t *)export_table[i].object, - (void (*)(void *))export_table[i].func, - export_table[i].name, export_table[i].data, - export_table[i].stack, - export_table[i].stack_size, - export_table[i].priority); - } -#endif -#if (ELAB_QPC_EN != 0) - else if (export_table[i].level == level && level == EXPORT_HSM) - { - QActive_ctor((QActive *)export_table[i].object, - Q_STATE_CAST(export_table[i].func)); - QACTIVE_START((QActive *)export_table[i].object, - export_table[i].priority, - export_table[i].data, export_table[i].queue_size, - export_table[i].stack, export_table[i].stack_size, - (QEvt *)0); - } -#endif - else if (export_table[i].level == level && level == EXPORT_MAX) - { - elab_export_poll_data_t *data = export_table[i].data; - while (elab_time_ms() >= data->timeout_ms) + else { - data->timeout_ms += export_table[i].period_ms; - ((void (*)(void))export_table[i].func)(); + break; } } } @@ -283,24 +341,15 @@ static void _export_func_execute(int8_t level) static void _entry_start_poll(void *para) { /* Initialize all module in eLab. */ - for (uint8_t level = EXPORT_LEVEL_HW_INDEPNEDENT; - level < EXPORT_LEVEL_MAX; level ++) + for (uint8_t level = 0; level <= export_level_max; level ++) { - _export_func_execute(level); + _init_func_execute(level); } -#if (ELAB_RTOS_CMSIS_OS_EN != 0) -#if (ELAB_RTOS_CMSIS_OS_EN != 0) - _export_func_execute(EXPORT_THREAD); -#endif -#endif -#if (ELAB_QPC_EN != 0) - _export_func_execute(EXPORT_HSM); -#endif /* Start polling function in metal eLab. */ while (1) { - _export_func_execute(EXPORT_MAX); + _poll_func_execute(); #if (ELAB_RTOS_CMSIS_OS_EN != 0 || ELAB_RTOS_BASIC_OS_EN != 0) osDelay(10); #endif diff --git a/elab/common/elab_export.h b/elab/common/elab_export.h index ee22b4f8d78e9fe08898454544d62495e65722b7..00485be348613f9109a9bd260b50f780dc0e39be 100644 --- a/elab/common/elab_export.h +++ b/elab/common/elab_export.h @@ -8,14 +8,8 @@ /* include ------------------------------------------------------------------ */ #include +#include #include "elab_def.h" -#if (ELAB_RTOS_CMSIS_OS_EN != 0) -#include "../port/elab_port.h" -#endif - -#if (ELAB_QPC_EN != 0) -#include "../3rd/qpc/include/qpc.h" -#endif #ifdef __cplusplus extern "C" { @@ -26,10 +20,17 @@ extern "C" { #define EXPORT_ID_POLL (0xbeefbeef) /* public define ------------------------------------------------------------ */ -enum elab_export_type +enum elab_export_level { - EXPORT_TYPE_INIT = 0, - EXPORT_TYPE_EXIT, + EXPORT_POLL = -2, + EXPORT_UNIT_TEST = -1, + EXPORT_LEVEL_BSP = 0, + EXPORT_LEVEL_HW_INDEPNEDENT = 0, + EXPORT_DRVIVER = 1, + EXPORT_MIDWARE = 2, + EXPORT_DEVICE = 3, + EXPORT_APP = 4, + EXPORT_USER = 5, }; /* public typedef ----------------------------------------------------------- */ @@ -42,29 +43,29 @@ typedef struct elab_export { uint32_t magic_head; const char *name; - void *data; - void *stack; - void *object; void *func; - uint16_t stack_size; - uint16_t queue_size; - uint16_t priority; - uint8_t level; + void *data; + bool exit; + int8_t level; uint8_t type; uint32_t period_ms; +#if defined(_WIN32) + uint32_t temp[9]; +#elif defined(__linux__) + uint32_t temp[4]; +#endif uint32_t magic_tail; } elab_export_t; /* private function --------------------------------------------------------- */ void elab_unit_test(void); void elab_run(void); -void elab_exit(void); /* public export ------------------------------------------------------------ */ /** * @brief Initialization function exporting macro. - * @param _func The polling function. - * @param _level The export level. See enum elab_export_level. + * @param _func The initialization function. + * @param _level The export level, [0, 127]. * @retval None. */ #define INIT_EXPORT(_func, _level) \ @@ -73,7 +74,7 @@ void elab_exit(void); .name = #_func, \ .func = (void *)&_func, \ .level = _level, \ - .type = (uint8_t)EXPORT_TYPE_INIT, \ + .exit = false, \ .magic_head = EXPORT_ID_INIT, \ .magic_tail = EXPORT_ID_INIT, \ } @@ -81,7 +82,7 @@ void elab_exit(void); /** * @brief Exiting function exporting macro. * @param _func The polling function. - * @param _level The export level. See enum elab_export_level. + * @param _level The export level, [0, 127]. * @retval None. */ #define EXIT_EXPORT(_func, _level) \ @@ -90,104 +91,23 @@ void elab_exit(void); .name = #_func, \ .func = (void *)&_func, \ .level = _level, \ - .type = (uint8_t)EXPORT_TYPE_EXIT, \ - .magic_head = EXPORT_ID_INIT, \ - .magic_tail = EXPORT_ID_INIT, \ - } - -#if (ELAB_QPC_EN != 0) -#if (ELAB_RTOS_CMSIS_OS_EN != 0) -/** - * @brief State machine exporting macro. - * @param _name name of the state machine. - * @param me The state machine object. - * @param _state_init The initial state of the state machine. - * @param _priority The priority of the state machine. - * @param _queue_size The queue size of the state machine. - * @param _stack_size The stack size of the state machine's internal thread. - * @retval None. - */ -#define HSM_EXPORT(_name, me, _state_init, _priority, _queue_size, _stack_size)\ - static QEvt const * sm_##_name##_queue[_queue_size]; \ - static uint8_t sm_##_name##_stack[_stack_size]; \ - ELAB_USED const elab_export_t sm_##_name ELAB_SECTION("elab_export") = \ - { \ - .name = (const char *)#_name, \ - .object = (void *)me, \ - .func = (void *)(&_state_init), \ - .data = (void *)sm_##_name##_queue, \ - .queue_size = _queue_size, \ - .stack = (void *)sm_##_name##_stack, \ - .stack_size = _stack_size, \ - .priority = _priority, \ - .level = EXPORT_HSM, \ + .exit = true, \ .magic_head = EXPORT_ID_INIT, \ .magic_tail = EXPORT_ID_INIT, \ } -#else /** - * @brief State machine exporting macro. - * @param _name name of the state machine. - * @param me The state machine object. - * @param _state_init The initial state of the state machine. - * @param _priority The priority of the state machine. - * @param _queue_size The queue size of the state machine. + * @brief Unit test function exporting macro. + * @param _func The unit test function. * @retval None. */ -#define HSM_EXPORT(_name, me, _state_init, _priority, _queue_size) \ - static QEvt const * sm_##_name##_queue[_queue_size]; \ - ELAB_USED const elab_export_t sm_##_name ELAB_SECTION("elab_export") = \ - { \ - .name = (const char *)#_name, \ - .object = (void *)me, \ - .func = (void *)(&_state_init), \ - .data = (void *)sm_##_name##_queue, \ - .queue_size = _queue_size, \ - .priority = _priority, \ - .level = EXPORT_HSM, \ - .magic_head = EXPORT_ID_INIT, \ - .magic_tail = EXPORT_ID_INIT, \ - } -#endif -#else -#define HSM_EXPORT(_name, me, _state_init, _priority, _queue_size, _stack_size) -#endif - -#if (ELAB_RTOS_CMSIS_OS_EN != 0) -/** - * @brief Thread exporting macro. - * @param _name name of the state machine. - * @param _entry The thread entry function. - * @param _priority The priority of the state machine. - * @param _data user data. - * @param _stack_size The stack size of the state machine. - * @retval None. - */ -#define THREAD_EXPORT(_name, _entry, _priority, _data, _stack_size) \ - static elab_thread_t thread_##_name; \ - static uint8_t thread_##_name##_stack[_stack_size]; \ - ELAB_USED const elab_export_t thread##_name ELAB_SECTION("elab_export") = \ - { \ - .func = (void *)&_entry, \ - .name = #_name, \ - .data = (void *)_data, \ - .object = (void *)&thread_##_name, \ - .stack = (void *)thread_##_name##_stack, \ - .stack_size = _stack_size, \ - .priority = _priority, \ - .level = EXPORT_THREAD, \ - .magic_head = EXPORT_ID_INIT, \ - .magic_tail = EXPORT_ID_INIT, \ - } -#else -#define THREAD_EXPORT(_name, _entry, _priority, _data, _stack_size) -#endif +#define UNIT_TEST_EXPORT(_func) INIT_EXPORT(_func, EXPORT_UNIT_TEST) /** * @brief Poll function exporting macro. * @param _func The polling function. - * @param _period_ms The polling period in ms. + * @param _period_ms The polling period in ms. + * The max value is 30 days (2592000000ms). * @retval None. */ #define POLL_EXPORT(_func, _period_ms) \ @@ -200,7 +120,7 @@ void elab_exit(void); .name = "poll", \ .func = &_func, \ .data = (void *)&poll_##_func##_data, \ - .level = EXPORT_MAX, \ + .level = EXPORT_POLL, \ .period_ms = (uint32_t)(_period_ms), \ .magic_head = EXPORT_ID_POLL, \ .magic_tail = EXPORT_ID_POLL, \ diff --git a/elab/common/elab_log.c b/elab/common/elab_log.c index 27c6a2e6c831b3339304101e771d21d1c19cf316..935b338796313a397ff1df8f1f41cef9e9c1580d 100644 --- a/elab/common/elab_log.c +++ b/elab/common/elab_log.c @@ -11,7 +11,7 @@ #include "elab_common.h" #include "elab_config.h" #if (ELAB_RTOS_CMSIS_OS_EN != 0) -#include "../RTOS/cmsis_os.h" +#include "../os/cmsis_os.h" #endif #ifdef __cplusplus diff --git a/elab/edf/driver/simulator/simu_serial.c b/elab/edf/driver/simulator/simu_serial.c index e4d8d69062faef5c682a4e45661bc1f4dcc62de4..9f579c5052b6a2492acb51f86968f347807c918b 100644 --- a/elab/edf/driver/simulator/simu_serial.c +++ b/elab/edf/driver/simulator/simu_serial.c @@ -7,7 +7,7 @@ #include "simu_serial.h" #include "edf_simu_config.h" #include "../../../elib/elib_hash_table.h" -#include "../../../RTOS/cmsis_os.h" +#include "../../../os/cmsis_os.h" #include "../../../edf/normal/elab_serial.h" #include "../../../common/elab_common.h" #include "../../../common/elab_assert.h" diff --git a/elab/edf/elab_device.c b/elab/edf/elab_device.c index f546e75a8d538309d60caad59a3cb9d93f5ee67e..4c891ba4ff7f358cb374125cbbb83165022f7fd8 100644 --- a/elab/edf/elab_device.c +++ b/elab/edf/elab_device.c @@ -8,7 +8,7 @@ #include "elab_device_def.h" #include "../common/elab_assert.h" #include "../common/elab_log.h" -#include "../RTOS/cmsis_os.h" +#include "../os/cmsis_os.h" ELAB_TAG("EdfDevice"); diff --git a/elab/edf/elab_device.h b/elab/edf/elab_device.h index 57dc351570b99afb116f51fa410cee5b95d2257e..3b457de0e80593a850c6499dafb94ff606c4c1a9 100644 --- a/elab/edf/elab_device.h +++ b/elab/edf/elab_device.h @@ -11,7 +11,7 @@ #include #include #include "../common/elab_def.h" -#include "../RTOS/cmsis_os.h" +#include "../os/cmsis_os.h" #ifdef __cplusplus extern "C" { diff --git a/elab/edf/elab_device_null.c b/elab/edf/elab_device_null.c index 427227e3655d17224bcc13a3b8be2dfaac7c6da1..3129ea21275bd3d03ddf72e80f17b67fe8f25fba 100644 --- a/elab/edf/elab_device_null.c +++ b/elab/edf/elab_device_null.c @@ -5,7 +5,7 @@ /* includes ----------------------------------------------------------------- */ #include "elab_device.h" -#include "../RTOS/cmsis_os.h" +#include "../os/cmsis_os.h" #include "../common/elab_assert.h" #include "../common/elab_export.h" diff --git a/elab/edf/normal/elab_adc.h b/elab/edf/normal/elab_adc.h index f02671cf717b63d86e002a94ba87294b24898939..4c51da2e11df286875ebe517d03c14888ea9bdc9 100644 --- a/elab/edf/normal/elab_adc.h +++ b/elab/edf/normal/elab_adc.h @@ -8,7 +8,7 @@ /* includes ----------------------------------------------------------------- */ #include "../elab_device.h" -#include "../../RTOS/cmsis_os.h" +#include "../../os/cmsis_os.h" #include "../../elib/elib_queue.h" #ifdef __cplusplus diff --git a/elab/edf/normal/elab_can.h b/elab/edf/normal/elab_can.h index a68fb6377be8b60f5d3c7f839a624fca12019b8c..18c02222ae8564ebbaba3ced0d6107eb1f895744 100644 --- a/elab/edf/normal/elab_can.h +++ b/elab/edf/normal/elab_can.h @@ -8,7 +8,7 @@ /* include ------------------------------------------------------------------ */ #include "../elab_device.h" -#include "../../RTOS/cmsis_os.h" +#include "../../os/cmsis_os.h" #ifdef __cplusplus extern "C" { diff --git a/elab/edf/normal/elab_i2c.c b/elab/edf/normal/elab_i2c.c index 52ba49c546aa4cd39b2d7b32d308cf452c2b1476..c33a99e2475a75295bbd5d070f1284e50dae7aa3 100644 --- a/elab/edf/normal/elab_i2c.c +++ b/elab/edf/normal/elab_i2c.c @@ -8,7 +8,7 @@ #include "../elab_device.h" #include "../../common/elab_assert.h" #include "../../common/elab_log.h" -#include "../../RTOS/cmsis_os.h" +#include "../../os/cmsis_os.h" ELAB_TAG("Edf_I2C"); diff --git a/elab/edf/normal/elab_i2c.h b/elab/edf/normal/elab_i2c.h index 0bb1ef7ca4760c8e6e8c7cae2e115220e2efd9c8..8be0f85a860f62f3badf88e5a858e0686fe9d405 100644 --- a/elab/edf/normal/elab_i2c.h +++ b/elab/edf/normal/elab_i2c.h @@ -8,7 +8,7 @@ /* includes ----------------------------------------------------------------- */ #include "../elab_device.h" -#include "../../RTOS/cmsis_os.h" +#include "../../os/cmsis_os.h" #ifdef __cplusplus extern "C" { diff --git a/elab/edf/normal/elab_pin.c b/elab/edf/normal/elab_pin.c index 5e0658a2643cfcf2ea544e4acc59d7f3764b268c..0d57f445528e9431dd8ca3785114b1386a732aa3 100644 --- a/elab/edf/normal/elab_pin.c +++ b/elab/edf/normal/elab_pin.c @@ -78,8 +78,11 @@ bool elab_pin_get_status(elab_device_t *const me) elab_pin_t *pin = (elab_pin_t *)me; - pin->status = pin->ops->get_status(pin); - + if (pin->mode >= PIN_MODE_INPUT && pin->mode <= PIN_MODE_INPUT_PULLDOWN) + { + pin->status = pin->ops->get_status(pin); + } + return pin->status; } @@ -99,8 +102,7 @@ void elab_pin_set_status(elab_device_t *const me, bool status) if (status != ELAB_PIN_CAST(me)->status) { ELAB_PIN_CAST(me)->ops->set_status(ELAB_PIN_CAST(me), status); - elab_pin_get_status(me); - assert_name(ELAB_PIN_CAST(me)->status == status, me->attr.name); + ELAB_PIN_CAST(me)->status = status; } } diff --git a/elab/edf/normal/elab_serial.h b/elab/edf/normal/elab_serial.h index 0262edb04c8778d970dc17031515707c32fad30d..00df250a277af4e959eb8327e8f8c4f3f32136c4 100644 --- a/elab/edf/normal/elab_serial.h +++ b/elab/edf/normal/elab_serial.h @@ -8,7 +8,7 @@ /* includes ----------------------------------------------------------------- */ #include "../elab_device.h" -#include "../../RTOS/cmsis_os.h" +#include "../../os/cmsis_os.h" #ifdef __cplusplus extern "C" { diff --git a/elab/edf/normal/elab_spi.h b/elab/edf/normal/elab_spi.h index ecc85ce8f0d0ac66c115b243f1929a29722e8aec..8a931926012f35d08f7307d18e2fce32dab07078 100644 --- a/elab/edf/normal/elab_spi.h +++ b/elab/edf/normal/elab_spi.h @@ -9,7 +9,7 @@ /* includes ----------------------------------------------------------------- */ #include #include "../elab_device.h" -#include "../../RTOS/cmsis_os.h" +#include "../../os/cmsis_os.h" #ifdef __cplusplus extern "C" { diff --git a/elab/edf/user/elab_rs485.h b/elab/edf/user/elab_rs485.h index f8d4964a6b944b5c32817de241681511e4d9076b..695044aafb31e0bb9e32d38fdc2ba67add96f2c3 100644 --- a/elab/edf/user/elab_rs485.h +++ b/elab/edf/user/elab_rs485.h @@ -9,7 +9,7 @@ /* Includes ------------------------------------------------------------------*/ #include "../elab_device.h" -#include "../../RTOS/cmsis_os.h" +#include "../../os/cmsis_os.h" #ifdef __cplusplus extern "C" { diff --git a/elab/elab.h b/elab/elab.h index d49e43ed56c9cf0a79be3771241b5a5876700621..c9ec7eaf6e53e0f704ecb04176be3ee68aa57aa0 100644 --- a/elab/elab.h +++ b/elab/elab.h @@ -11,7 +11,6 @@ #include "common/elab_assert.h" #include "common/elab_export.h" #include "common/elab_common.h" -#include "port/elab_port.h" #if (ELAB_QPC_EN != 0) #include "3rd/qpc/include/qpc.h" @@ -19,7 +18,7 @@ #endif #if (ELAB_RTOS_CMSIS_OS_EN != 0) -#include "RTOS/cmsis_os.h" +#include "os/cmsis_os.h" #endif #if (ELAB_RTOS_BASIC_OS_EN != 0) diff --git a/elab/export/port_export.c b/elab/export/port_export.c index 1475111cdfac5621301401e450d72968525b06d1..f86ff65cd14a83a1d0d33c767c133a77ebc533ab 100644 --- a/elab/export/port_export.c +++ b/elab/export/port_export.c @@ -11,7 +11,7 @@ #include "../edf/driver/linux/driver_uart.h" #include "../common/elab_export.h" #include "../edf/driver/simulator/simu_serial.h" -#include "eLab/midware/edb/edb.h" +#include "elab/midware/edb/edb.h" #define PORT_EXPORT_BUFF_SIZE (256) #define PORT_SERIAL_NAME_SIZE (64) diff --git a/elab/export/shell_export.c b/elab/export/shell_export.c index ed353c5404e5d67b95195302cfcd0cb0c40982de..73206aad8552d85ef866472690392499568a31eb 100644 --- a/elab/export/shell_export.c +++ b/elab/export/shell_export.c @@ -6,11 +6,11 @@ /* include ------------------------------------------------------------------ */ #include -#include "eLab/3rd/Shell/shell.h" -#include "eLab/common/elab_assert.h" -#include "eLab/common/elab_export.h" -#include "eLab/common/elab_common.h" -#include "eLab/RTOS/cmsis_os.h" +#include "../3rd/Shell/shell.h" +#include "../common/elab_assert.h" +#include "../common/elab_export.h" +#include "../common/elab_common.h" +#include "../os/cmsis_os.h" ELAB_TAG("ShellExport"); diff --git a/elab/midware/edb/edb.c b/elab/midware/edb/edb.c index b2d4e862885767cd5c131106bf858f15b5516174..2deea56b69fd01e955f43bd4eb10aa6fc62ae71c 100644 --- a/elab/midware/edb/edb.c +++ b/elab/midware/edb/edb.c @@ -8,7 +8,7 @@ #include "edb.h" #include "../../common/elab_assert.h" #include "../../3rd/ini/ini.h" -#include "../../RTOS/cmsis_os.h" +#include "../../os/cmsis_os.h" ELAB_TAG("edb"); diff --git a/elab/os/posix/cmsis_os.c b/elab/os/posix/cmsis_os.c index 7955c405c3f91fb7ce45215c2148ca86b941ffcf..c0285d54dac110af3ba8953b9ac59b4613d70fcc 100644 --- a/elab/os/posix/cmsis_os.c +++ b/elab/os/posix/cmsis_os.c @@ -4,28 +4,25 @@ * Copyright (c) 2023, EventOS Team, */ +#if defined(__linux__) + /* includes ----------------------------------------------------------------- */ #include #include #include #include #include -#include #include #include #include -#include +#include #include "../cmsis_os.h" -#include "../../common/elab_assert.h" - -ELAB_TAG("CmsisOSPosix"); #define RTOS_TIMER_NUM_MAX (32) #define RTOS_TIMER_VALUE_MIN (5) static int get_pthread_priority(osPriority_t prio); static void _thread_entry_timer(void *para); -static int getch(void); /* ----------------------------------------------------------------------------- Data structure @@ -54,6 +51,27 @@ static const osMutexAttr_t mutex_attr_event_flag = 0U }; +enum timer_state +{ + TIMER_STATE_IDLE = 0, + TIMER_STATE_RUN, + TIMER_STATE_UNUSED, +}; + +typedef struct os_timer_data +{ + osTimerFunc_t func; + osTimerType_t type; + osTimerAttr_t attr; + void *argument; + uint32_t timeout; + uint32_t ticks; + uint8_t state; +} os_timer_data_t; + +static os_timer_data_t timer[RTOS_TIMER_NUM_MAX]; +static uint32_t timeout_min = 0; + static osMutexId_t mutex_timer = NULL; /* ----------------------------------------------------------------------------- @@ -61,6 +79,11 @@ OS Basic ----------------------------------------------------------------------------- */ osStatus_t osKernelInitialize(void) { + for (uint32_t i = 0; i < RTOS_TIMER_NUM_MAX; i ++) + { + timer[i].state = TIMER_STATE_UNUSED; + } + /* Create one thread for mutex function. */ mutex_timer = osMutexNew(&mutex_attr_timer); assert(mutex_timer != NULL); @@ -147,16 +170,6 @@ osStatus_t osKernelStart(void) return osOK; } -int16_t elab_debug_uart_receive(void *buffer, uint16_t size) -{ - assert(size == 1); - - uint8_t *buff = (uint8_t *)buffer; - buff[0] = (uint8_t)getch(); - - return 1; -} - /* ----------------------------------------------------------------------------- Thread ----------------------------------------------------------------------------- */ @@ -318,10 +331,10 @@ osStatus_t osMessageQueuePut(osMessageQueueId_t mq_id, os_mq_t *mq = (os_mq_t *)mq_id; ret_os = osSemaphoreAcquire(mq->sem_full, timeout); - elab_assert(ret_os == osOK); + assert(ret_os == osOK); ret_os = osMutexAcquire(mq->mutex, osWaitForever); - elab_assert(ret_os == osOK); + assert(ret_os == osOK); assert(mq->full == false || mq->empty == false); memcpy(&mq->memory[mq->head * mq->msg_size], msg_ptr, mq->msg_size); mq->head = (mq->head + 1) % mq->capacity; @@ -331,9 +344,9 @@ osStatus_t osMessageQueuePut(osMessageQueueId_t mq_id, mq->full = true; } ret_os = osMutexRelease(mq->mutex); - elab_assert(ret_os == osOK); + assert(ret_os == osOK); ret_os = osSemaphoreRelease(mq->sem_empty); - elab_assert(ret_os == osOK); + assert(ret_os == osOK); return osOK; } @@ -360,7 +373,7 @@ osStatus_t osMessageQueueGet(osMessageQueueId_t mq_id, } ret_os = osMutexAcquire(mq->mutex, osWaitForever); - elab_assert(ret_os == osOK); + assert(ret_os == osOK); assert(mq->full == false || mq->empty == false); memcpy(msg_ptr, &mq->memory[mq->tail * mq->msg_size], mq->msg_size); mq->tail = (mq->tail + 1) % mq->capacity; @@ -370,9 +383,9 @@ osStatus_t osMessageQueueGet(osMessageQueueId_t mq_id, mq->empty = true; } ret_os = osMutexRelease(mq->mutex); - elab_assert(ret_os == osOK); + assert(ret_os == osOK); ret_os = osSemaphoreRelease(mq->sem_full); - elab_assert(ret_os == osOK); + assert(ret_os == osOK); return osOK; } @@ -418,7 +431,7 @@ osStatus_t osMutexAcquire(osMutexId_t mutex_id, uint32_t timeout) assert(mutex_id != NULL); os_mutex_data_t *data = (os_mutex_data_t *)mutex_id; - assert_name(timeout == osWaitForever, data->attr.name); + assert(timeout == osWaitForever); int ret = pthread_mutex_lock(&data->mutex); if (ret != 0) @@ -531,27 +544,6 @@ osStatus_t osSemaphoreAcquire(osSemaphoreId_t semaphore_id, uint32_t timeout) /* ----------------------------------------------------------------------------- Timer ----------------------------------------------------------------------------- */ -enum timer_state -{ - TIMER_STATE_IDLE = 0, - TIMER_STATE_RUN, - TIMER_STATE_UNUSED, -}; - -typedef struct os_timer_data -{ - osTimerFunc_t func; - osTimerType_t type; - osTimerAttr_t attr; - void *argument; - uint32_t timeout; - uint32_t ticks; - uint8_t state; -} os_timer_data_t; - -static os_timer_data_t timer[RTOS_TIMER_NUM_MAX]; -static uint32_t timeout_min = 0; - osTimerId_t osTimerNew(osTimerFunc_t func, osTimerType_t type, void *argument, @@ -643,6 +635,7 @@ osStatus_t osTimerStart(osTimerId_t timer_id, uint32_t ticks) /* Start the timer. */ timer->timeout = ticks + osKernelGetTickCount(); timer->ticks = ticks; + timer->state = TIMER_STATE_RUN; timeout_min = timeout_min > timer->timeout ? timer->timeout : timeout_min; /* Unlock the mutex. */ @@ -734,12 +727,12 @@ typedef struct os_event_flags osEventFlagsId_t osEventFlagsNew(const osEventFlagsAttr_t *attr) { os_event_flags_t *evt_flags = malloc(sizeof(os_event_flags_t)); - elab_assert(evt_flags != NULL); + assert(evt_flags != NULL); evt_flags->sem = osSemaphoreNew(1, 0, NULL); - elab_assert(evt_flags->sem != NULL); + assert(evt_flags->sem != NULL); evt_flags->mutex = osMutexNew(&mutex_attr_event_flag); - elab_assert(evt_flags->mutex != NULL); + assert(evt_flags->mutex != NULL); evt_flags->flags = 0; evt_flags->flags_set = 0; @@ -783,7 +776,7 @@ uint32_t osEventFlagsWait (osEventFlagsId_t ef_id, uint32_t flags, uint32_t opti if (options & osFlagsWaitAll) { - if (evt_flags->flags_set != 0) + if (evt_flags->flags != 0) { if (timeout > 0U) { @@ -836,7 +829,7 @@ uint32_t osEventFlagsSet(osEventFlagsId_t ef_id, uint32_t flags) os_event_flags_t *evt_flags = (os_event_flags_t *)ef_id; evt_flags->flags_set = flags; ret_os = osSemaphoreRelease(evt_flags->sem); - elab_assert(ret_os == osOK); + assert(ret_os == osOK); return evt_flags->flags_set; } @@ -861,7 +854,7 @@ osStatus_t osEventFlagsDelete (osEventFlagsId_t ef_id) osStatus_t ret_os = osOK; os_event_flags_t *evt_flags = (os_event_flags_t *)ef_id; ret_os = osSemaphoreDelete(evt_flags->sem); - elab_assert(ret_os == osOK); + assert(ret_os == osOK); free(evt_flags); @@ -893,8 +886,12 @@ static void _thread_entry_timer(void *para) { for (uint32_t i = 0; i < RTOS_TIMER_NUM_MAX; i ++) { - if (timeout_min <= timer[i].timeout && - timer[i].state == TIMER_STATE_RUN) + if (timer[i].state != TIMER_STATE_RUN) + { + continue; + } + + if (osKernelGetTickCount() >= timer[i].timeout) { timer[i].func(timer[i].argument); if (timer[i].type == osTimerPeriodic) @@ -927,25 +924,6 @@ static void _thread_entry_timer(void *para) } } -/* private function --------------------------------------------------------- */ -/** - * @brief The original getch function for Linux which can get the input char - * in the terminal. - * @retval Key id. - */ -static int getch(void) -{ - int ch; - - struct termios tm, tm_old; - tcgetattr(STDIN_FILENO, &tm); - tm_old = tm; - tm.c_lflag &= ~(ICANON | ECHO); - tcsetattr(STDIN_FILENO, TCSANOW, &tm); - ch = getchar(); - tcsetattr(STDIN_FILENO, TCSANOW, &tm_old); - - return ch; -} +#endif /* ----------------------------- end of file -------------------------------- */ diff --git a/elab/os/win32/cmsis_os.c b/elab/os/win32/cmsis_os.c index a510ea0ccc157d95e0fdb9d94e310f965f142cd3..86df06c51df75d8685352fa9e3c27e26a7136f0a 100644 --- a/elab/os/win32/cmsis_os.c +++ b/elab/os/win32/cmsis_os.c @@ -1,13 +1,15 @@ + + /* Includes ------------------------------------------------------------------*/ #include #include #include -#include "cmsis_os.h" -#include "FreeRTOS.h" // ARM.FreeRTOS::RTOS:Core -#include "task.h" // ARM.FreeRTOS::RTOS:Core -#include "event_groups.h" // ARM.FreeRTOS::RTOS:Event Groups -#include "semphr.h" // ARM.FreeRTOS::RTOS:Core -#include "timers.h" +#include "../cmsis_os.h" +#include "../../3rd/FreeRTOS/include/FreeRTOS.h" +#include "../../3rd/FreeRTOS/include/task.h" +#include "../../3rd/FreeRTOS/include/event_groups.h" +#include "../../3rd/FreeRTOS/include/semphr.h" +#include "../../3rd/FreeRTOS/include/timers.h" /* Limits */ #define MAX_BITS_TASK_NOTIFY 31U @@ -31,7 +33,10 @@ static osKernelState_t KernelState = osKernelInactive; /* ----------------------------------------------------------------------------- OS Basic ----------------------------------------------------------------------------- */ - +osStatus_t osKernelInitialize (void) +{ + return osOK; +} int32_t osKernelLock (void) { int32_t lock; @@ -1208,23 +1213,6 @@ osStatus_t osEventFlagsDelete (osEventFlagsId_t ef_id) { return (stat); } - -/* ----------------------------------------------------------------------------- -Malloc & Free ------------------------------------------------------------------------------ */ -void * elab_malloc(uint32_t size) -{ - return pvPortMalloc(size); -} - -void elab_free(void *data) -{ - if (NULL != data) - { - vPortFree(data); - } -} - /* ----------------------------------------------------------------------------- Assert ----------------------------------------------------------------------------- */ diff --git a/elab/os/win32/cmsis_os_cb.c b/elab/os/win32/cmsis_os_cb.c index 6b29526a8723f3096c20c858a6b9ac02f1acbc13..295ba218fbf0e780cfc9b72e79dccd35cf368e1c 100644 --- a/elab/os/win32/cmsis_os_cb.c +++ b/elab/os/win32/cmsis_os_cb.c @@ -1,9 +1,9 @@ /* Includes ------------------------------------------------------------------*/ #include -#include "FreeRTOS.h" -#include "task.h" -#include "timers.h" -#include "cmsis_os.h" +#include "../../3rd/FreeRTOS/include/FreeRTOS.h" +#include "../../3rd/FreeRTOS/include/task.h" +#include "../../3rd/FreeRTOS/include/timers.h" +#include "../cmsis_os.h" void vApplicationGetIdleTaskMemory( StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize ) { diff --git a/elab/port/FreeRTOS/elab_port.c b/elab/port/FreeRTOS/elab_port.c deleted file mode 100644 index 96440b2cd5ccc00940d5fefbecfaae6ee85d1eb2..0000000000000000000000000000000000000000 --- a/elab/port/FreeRTOS/elab_port.c +++ /dev/null @@ -1,56 +0,0 @@ -/* - * eLab Project - * Copyright (c) 2023, EventOS Team, - */ - -/* include ------------------------------------------------------------------ */ -#include "eLab/elab.h" - -ELAB_TAG("eLab_Port_FreeRTOS"); - -/* public function ---------------------------------------------------------- */ - -/** - * @brief eLab initialization exporting function. - * @param level init level. - * @retval None - */ -uint32_t elab_time_ms(void) -{ -#if (ELAB_RTOS_CMSIS_OS_EN != 0) - return xTaskGetTickCount() * ELAB_RTOS_TICK_MS; -#elif (ELAB_RTOS_BASIC_OS_EN != 0) - return bos_time(); -#else - return 0; -#endif -} - -/** - * @brief eLab thread initialization function. - * @retval None - */ -#if (ELAB_RTOS_CMSIS_OS_EN != 0) -osThreadId_t elab_thread_init(elab_thread_t *const me, - void (*entry)(void *parameter), - const char *name, void *data, - void *stack, uint32_t stack_size, uint8_t priority) -{ - TaskHandle_t thread; - - thread = xTaskCreateStatic( - entry, /* the task function */ - name , /* the name of the task */ - (stack_size / sizeof(portSTACK_TYPE)), /* stack size */ - (void *)me, /* the 'pvParameters' parameter */ - (UBaseType_t)(priority + tskIDLE_PRIORITY), /* FreeRTOS priority */ - (StackType_t *)stack, /* stack storage */ - me); /* task buffer */ - - elab_assert(thread != (TaskHandle_t)0); /* must be created */ - - return (osThreadId_t)thread; -} -#endif - -/* ----------------------------- end of file -------------------------------- */ diff --git a/elab/port/elab_port.h b/elab/port/elab_port.h deleted file mode 100644 index 23358f6ff515e8e2d80b52241f348ce92f13e460..0000000000000000000000000000000000000000 --- a/elab/port/elab_port.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * eLab Project - * Copyright (c) 2023, EventOS Team, - */ - -#ifndef __ELAB_PORT_H__ -#define __ELAB_PORT_H__ - -#include "elab_config.h" - -#if (ELAB_RTOS_CMSIS_OS_EN != 0) - -/* public defines ----------------------------------------------------------- */ -#if defined(__linux__) - -#include "../RTOS/cmsis_os.h" -#define elab_thread_t osThreadId_t - -#elif defined(__free_rtos__) || defined(__win32__) - -#include "FreeRTOS.h" /* FreeRTOS master include file, see NOTE4 */ -#include "task.h" /* FreeRTOS task management */ - -#define elab_thread_t StaticTask_t - -#endif - -/* public typedef ----------------------------------------------------------- */ - -#endif -#endif /* __ELAB_PORT_H__ */ - -/* ----------------------------- end of file -------------------------------- */ diff --git a/elab/port/posix/elab_port.c b/elab/port/posix/elab_port.c deleted file mode 100644 index 01c81663765af325248342d90db4b369ee2e40d9..0000000000000000000000000000000000000000 --- a/elab/port/posix/elab_port.c +++ /dev/null @@ -1,87 +0,0 @@ -/* - * eLab Project - * Copyright (c) 2023, EventOS Team, - */ - -/* include ------------------------------------------------------------------ */ -#include -#include -#include -#include "../elab_port.h" -#include "../../RTOS/cmsis_os.h" -#include "../../common/elab_common.h" -#include "../../common/elab_def.h" -#include "../../common/elab_assert.h" - -ELAB_TAG("eLabPortPOSIX"); - -/* private define ----------------------------------------------------------- */ -#define ELAB_DEBUG_BUFF_SIZE (2048) - -/* private variables -------------------------------------------------------- */ -static char buff_tx[ELAB_DEBUG_BUFF_SIZE]; - -/* public function ---------------------------------------------------------- */ -/** - * @brief eLab initialization exporting function. - * @param level init level. - * @retval None - */ -uint32_t elab_time_ms(void) -{ -#if (ELAB_RTOS_CMSIS_OS_EN != 0) - return osKernelGetTickCount(); -#else - return 0; -#endif -} - -void *elab_malloc(uint32_t size) -{ - return malloc(size); -} - -void elab_free(void *memory) -{ - return free(memory); -} - -int16_t elab_debug_uart_send(void *buffer, uint16_t size) -{ - elab_assert(size < ELAB_DEBUG_BUFF_SIZE); - - memcpy(buff_tx, buffer, size); - buff_tx[size] = 0; - - printf("%s", buff_tx); - fflush(stdout); - - return 0; -} - -/** - * @brief eLab thread initialization function. - * @retval None - */ -#if (ELAB_RTOS_CMSIS_OS_EN != 0) -osThreadId_t elab_thread_init(elab_thread_t *const me, - void (*entry)(void *parameter), - const char *name, void *data, - void *stack, uint32_t stack_size, - uint8_t priority) -{ - (void)me; - - osThreadAttr_t thread_attr; - thread_attr.name = name; - thread_attr.stack_size = stack_size; - - osThreadId_t thread = osThreadNew(entry, data, &thread_attr); - - elab_assert(thread != (osThreadId_t)0); - - return thread; -} -#endif - -/* ----------------------------- end of file -------------------------------- */ diff --git a/elab/test/test_gpio.c b/elab/test/test_gpio.c index a0d498ffd6276e4d4111b3fbbb4d83e1cc1d9c38..c12ce052386eec5059b3e5964e6c1961592cee2f 100644 --- a/elab/test/test_gpio.c +++ b/elab/test/test_gpio.c @@ -9,10 +9,10 @@ #include #include #include -#include "eLab/3rd/Shell/shell.h" -#include "eLab/common/elab_log.h" -#include "eLab/edf/normal/elab_pin.h" -#include "eLab/edf/driver/simulator/simu_driver_pin.h" +#include "elab/3rd/Shell/shell.h" +#include "elab/common/elab_log.h" +#include "elab/edf/normal/elab_pin.h" +#include "elab/edf/driver/simulator/simu_driver_pin.h" ELAB_TAG("BaseTest"); diff --git a/elab/test/test_motor.c b/elab/test/test_motor.c index 3aaa8fe1d76228adadded98989b03150ff7f03c4..6a0c446a19562390214c9135b922ba36e08734f0 100644 --- a/elab/test/test_motor.c +++ b/elab/test/test_motor.c @@ -9,9 +9,9 @@ #include #include #include -#include "eLab/3rd/Shell/shell.h" -#include "eLab/common/elab_log.h" -#include "eLab/edf/elab_device.h" +#include "elab/3rd/Shell/shell.h" +#include "elab/common/elab_log.h" +#include "elab/edf/elab_device.h" #include "export/rbc_export.h" ELAB_TAG("MotorTest"); diff --git a/elab/test/test_mq.c b/elab/test/test_mq.c index 13df4620adb279753e39a0599c5a884b31baa15a..662d49969148c86dad8eed7eb56aee46db021466 100644 --- a/elab/test/test_mq.c +++ b/elab/test/test_mq.c @@ -9,10 +9,10 @@ #include #include #include -#include "eLab/3rd/Shell/shell.h" -#include "eLab/common/elab_log.h" -#include "eLab/common/elab_assert.h" -#include "eLab/edf/elab_device.h" +#include "elab/3rd/Shell/shell.h" +#include "elab/common/elab_log.h" +#include "elab/common/elab_assert.h" +#include "elab/edf/elab_device.h" ELAB_TAG("MotorTest"); diff --git a/elab/test/test_preemption_linux.c b/elab/test/test_preemption_linux.c new file mode 100644 index 0000000000000000000000000000000000000000..d6d0428408754532d051e34e254f0ebd551ad3d3 --- /dev/null +++ b/elab/test/test_preemption_linux.c @@ -0,0 +1,97 @@ + +/* + * eLab Project + * Copyright (c) 2023, EventOS Team, + */ + +#if defined(__linux__) + +/* includes ----------------------------------------------------------------- */ +#include +#include +#include +#include "../3rd/Shell/shell.h" +#include "../common/elab_log.h" +#include "../os/cmsis_os.h" + +ELAB_TAG("eLogTest"); + +#ifdef __cplusplus +extern "C" { +#endif + +/* private variables -------------------------------------------------------- */ +static const osThreadAttr_t thread_low_attr = +{ + .name = "test_preemption_low", + .stack_size = 2048, + .priority = (osPriority_t)osPriorityBelowNormal, +}; + +static const osThreadAttr_t thread_high_attr = +{ + .name = "test_preemption_high", + .stack_size = 2048, + .priority = (osPriority_t)osPriorityNormal, +}; + +/* private function prototype ----------------------------------------------- */ +static void _entry_thread_low_prio(void *para); +static void _entry_thread_high_prio(void *para); + +/* private functions -------------------------------------------------------- */ +/** + * @brief Testing function for eLog module. + * @retval None + */ +static int32_t test_preemption_linux(int32_t argc, char *argv[]) +{ + (void)argc; + (void)argv; + + osThreadNew(_entry_thread_low_prio, NULL, &thread_low_attr); + osThreadNew(_entry_thread_high_prio, NULL, &thread_high_attr); + + return 0; +} + +static void _entry_thread_low_prio(void *para) +{ + float a = 0.001; + + while (1) + { + printf("test a: %f, time: %u. ----------------------------------\n", + a, osKernelGetTickCount()); + for (uint32_t i = 0; i < 10000000; i ++) + { + a += 0.001; + } + printf("test a: %f, time: %u.\n", a, osKernelGetTickCount()); + } +} + +static void _entry_thread_high_prio(void *para) +{ + while (1) + { + osDelay(100); + printf(".\n"); + } +} + +/** + * @brief Test shell command export + */ +SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN), + test_preemption_linux, + test_preemption_linux, + Thread preemption testing on Linux); + +#ifdef __cplusplus +} +#endif + +#endif + +/* ----------------------------- end of file -------------------------------- */ diff --git a/elab/test/test_rs232.c b/elab/test/test_rs232.c index 5e255073326bb8f757256945910db42e3ef1dd1f..725886fb2f36737ed98e63347c88cf16fe33fdad 100644 --- a/elab/test/test_rs232.c +++ b/elab/test/test_rs232.c @@ -9,12 +9,12 @@ #include #include #include -#include "eLab/3rd/Shell/shell.h" -#include "eLab/common/elab_log.h" -#include "eLab/edf/elab_device.h" -#include "eLab/edf/normal/elab_serial.h" -#include "eLab/RTOS/cmsis_os.h" -#include "eLab/common/elab_assert.h" +#include "elab/3rd/Shell/shell.h" +#include "elab/common/elab_log.h" +#include "elab/edf/elab_device.h" +#include "elab/edf/normal/elab_serial.h" +#include "elab/os/cmsis_os.h" +#include "elab/common/elab_assert.h" ELAB_TAG("Rs232Test"); diff --git a/elab/test/test_spi.c b/elab/test/test_spi.c index 43cb3567a00e5e306b454b9f2a14b4d40893c09d..fab0d9c584e11fbdb3610ce7468b17c37bdaf95b 100644 --- a/elab/test/test_spi.c +++ b/elab/test/test_spi.c @@ -9,9 +9,9 @@ #include #include #include -#include "eLab/3rd/Shell/shell.h" -#include "eLab/common/elab_log.h" -#include "eLab/edf/normal/elab_spi.h" +#include "elab/3rd/Shell/shell.h" +#include "elab/common/elab_log.h" +#include "elab/edf/normal/elab_spi.h" ELAB_TAG("BaseTest"); diff --git a/example/cmsis_mingw/x_build.bat b/example/cmsis_mingw/x_build.bat deleted file mode 100644 index 7cc6be9a9ab6406140d4be6aeab9f5bd29398c78..0000000000000000000000000000000000000000 --- a/example/cmsis_mingw/x_build.bat +++ /dev/null @@ -1,23 +0,0 @@ -md build - -gcc -std=c99 -g ^ -main.c ^ -test_event.c ^ -test_malloc.c ^ -..\..\RTOS\CMSIS_OS_FreeRTOS\cmsis_os_cb.c ^ -..\..\RTOS\CMSIS_OS_FreeRTOS\cmsis_os.c ^ -..\..\3rd\FreeRTOS\croutine.c ^ -..\..\3rd\FreeRTOS\event_groups.c ^ -..\..\3rd\FreeRTOS\list.c ^ -..\..\3rd\FreeRTOS\queue.c ^ -..\..\3rd\FreeRTOS\stream_buffer.c ^ -..\..\3rd\FreeRTOS\tasks.c ^ -..\..\3rd\FreeRTOS\timers.c ^ -..\..\3rd\FreeRTOS\portable\MemMang\heap_4.c ^ -..\..\3rd\FreeRTOS\portable\mingw\port.c ^ --I ..\..\RTOS\CMSIS_OS_FreeRTOS ^ --I ..\..\3rd\FreeRTOS\include ^ --I ..\..\3rd\FreeRTOS\portable\mingw ^ --I . ^ --o build\cmsis_os ^ --l winmm \ No newline at end of file diff --git a/example/cmsis_mingw/x_build.sh b/example/cmsis_mingw/x_build.sh deleted file mode 100644 index 49b695c12fee68e7d6138b881141856db7987cd2..0000000000000000000000000000000000000000 --- a/example/cmsis_mingw/x_build.sh +++ /dev/null @@ -1,19 +0,0 @@ -mkdir build - -gcc -std=gnu99 -g \ -main.c \ -test_event.c \ -test_malloc.c \ -../../common/elab_common.c \ -../../port/posix/elab_port.c \ -../../RTOS/CMSIS_OS_POSIX/cmsis_os.c \ --I ../.. \ --I ../../RTOS/CMSIS_OS_POSIX \ --I ../../common \ --I ../../elib \ --I ../../port/posix \ --I ../../midware/esh \ --I export \ --I . \ --o build/cmsis \ --l pthread diff --git a/elab/os/win32/FreeRTOSConfig.h b/example/cmsis_rtos/FreeRTOSConfig.h similarity index 100% rename from elab/os/win32/FreeRTOSConfig.h rename to example/cmsis_rtos/FreeRTOSConfig.h diff --git a/example/cmsis_mingw/elab_config.h b/example/cmsis_rtos/elab_config.h similarity index 100% rename from example/cmsis_mingw/elab_config.h rename to example/cmsis_rtos/elab_config.h diff --git a/example/cmsis_mingw/main.c b/example/cmsis_rtos/main.c similarity index 95% rename from example/cmsis_mingw/main.c rename to example/cmsis_rtos/main.c index 98a6a87d22f229a4848ba35ce46c1e0880441b43..2b6b05ae63ff8f1fbf3e6bb3b0106c017e9beaf5 100644 --- a/example/cmsis_mingw/main.c +++ b/example/cmsis_rtos/main.c @@ -6,7 +6,7 @@ /* Includes ------------------------------------------------------------------*/ #include #include -#include "cmsis_os.h" +#include "elab/os/cmsis_os.h" #include "test.h" /* private variables ---------------------------------------------------------*/ @@ -31,6 +31,7 @@ static void timer_function(void *parameter); */ int main(int32_t argc, char **argv) { + osKernelInitialize(); osThreadNew(task_function_test, NULL, &thread_attr_test); /* Start the scheduler. */ @@ -67,7 +68,7 @@ static void task_function_test(void *parameter) static void timer_function(void *parameter) { - + printf("Timer test.\n"); } /* ----------------------------- end of file -------------------------------- */ diff --git a/example/cmsis_mingw/test.h b/example/cmsis_rtos/test.h similarity index 100% rename from example/cmsis_mingw/test.h rename to example/cmsis_rtos/test.h diff --git a/example/cmsis_mingw/test_event.c b/example/cmsis_rtos/test_event.c similarity index 98% rename from example/cmsis_mingw/test_event.c rename to example/cmsis_rtos/test_event.c index d42232a8b5440ce3fac510e0cdcd00905054e4d2..941ac895be307031a923a95429cb041d3742dba6 100644 --- a/example/cmsis_mingw/test_event.c +++ b/example/cmsis_rtos/test_event.c @@ -1,7 +1,7 @@ /* includes ------------------------------------------------------------------*/ #include #include "test.h" -#include "cmsis_os.h" +#include "elab/os/cmsis_os.h" /* private defines -----------------------------------------------------------*/ #define EVENT_TEST_THREAH_ONE (1 << 1) @@ -38,11 +38,11 @@ static void task_function_target(void *parameter); void test_event(void) { printf("test_event start. =============================================\n"); + event = osEventFlagsNew(&event_attr_test); + osThreadNew(task_function_one, NULL, &thread_attr_test); osThreadNew(task_function_two, NULL, &thread_attr_test); osThreadNew(task_function_target, NULL, &thread_attr_test); - - event = osEventFlagsNew(&event_attr_test); } /* private functions ---------------------------------------------------------*/ diff --git a/example/cmsis_mingw/test_malloc.c b/example/cmsis_rtos/test_malloc.c similarity index 95% rename from example/cmsis_mingw/test_malloc.c rename to example/cmsis_rtos/test_malloc.c index 122fb1d5b8de4592e41ddfec591a9db90caf8c65..8a7b5ba5af7d9f4e8d51cca7343ef704d8237a95 100644 --- a/example/cmsis_mingw/test_malloc.c +++ b/example/cmsis_rtos/test_malloc.c @@ -1,8 +1,8 @@ /* Includes ------------------------------------------------------------------*/ #include #include "test.h" -#include "cmsis_os.h" -#include "elab_common.h" +#include "elab/os/cmsis_os.h" +#include "elab/common/elab_common.h" /* private variables ---------------------------------------------------------*/ /** diff --git a/example/cmsis_rtos/x_build.bat b/example/cmsis_rtos/x_build.bat new file mode 100644 index 0000000000000000000000000000000000000000..4ecf42204cd54a60ca0583689180cc9650ac6deb --- /dev/null +++ b/example/cmsis_rtos/x_build.bat @@ -0,0 +1,16 @@ +md build + +gcc -std=c99 -g ^ +main.c ^ +test_event.c ^ +test_malloc.c ^ +..\..\elab\common\*.c ^ +..\..\elab\os\win32\cmsis_os_cb.c ^ +..\..\elab\os\win32\cmsis_os.c ^ +..\..\elab\3rd\FreeRTOS\*.c ^ +..\..\elab\3rd\FreeRTOS\portable\MemMang\heap_4.c ^ +..\..\elab\3rd\FreeRTOS\portable\mingw\port.c ^ +-I ..\.. ^ +-I . ^ +-o build\cmsis_os ^ +-l winmm \ No newline at end of file diff --git a/example/cmsis_rtos/x_build.sh b/example/cmsis_rtos/x_build.sh new file mode 100755 index 0000000000000000000000000000000000000000..4648479576d6541b00f4f1119b2513f249f09121 --- /dev/null +++ b/example/cmsis_rtos/x_build.sh @@ -0,0 +1,10 @@ +mkdir build + +gcc -std=gnu99 -g \ +*.c \ +../../elab/common/*.c \ +../../elab/os/posix/cmsis_os.c \ +-I ../.. \ +-I . \ +-o build/cmsis_os \ +-l pthread diff --git a/example/export/FreeRTOSConfig.h b/example/export/FreeRTOSConfig.h new file mode 100644 index 0000000000000000000000000000000000000000..10187681b29714a8d3b382b0e691c7541914e17d --- /dev/null +++ b/example/export/FreeRTOSConfig.h @@ -0,0 +1,161 @@ +/* + * FreeRTOS Kernel V10.3.1 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ +#ifndef FREERTOS_CONFIG_H +#define FREERTOS_CONFIG_H + +/*----------------------------------------------------------- + * Application specific definitions. + * + * These definitions should be adjusted for your particular hardware and + * application requirements. + * + * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE + * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE. See + * http://www.freertos.org/a00110.html + *----------------------------------------------------------*/ + +#define configUSE_PREEMPTION 1 +#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0 +#define configUSE_IDLE_HOOK 1 +#define configUSE_TICK_HOOK 1 +#define configUSE_DAEMON_TASK_STARTUP_HOOK 1 +#define configTICK_RATE_HZ ( 1000 ) /* In this non-real time simulated environment the tick frequency has to be at least a multiple of the Win32 tick frequency, and therefore very slow. */ +#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 70 ) /* In this simulated case, the stack only has to hold one small structure as the real stack is part of the win32 thread. */ +#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 32 * 1024 * 1024 ) ) +#define configMAX_TASK_NAME_LEN ( 12 ) +#define configUSE_TRACE_FACILITY 1 +#define configUSE_16_BIT_TICKS 0 +#define configIDLE_SHOULD_YIELD 1 +#define configUSE_MUTEXES 1 +#define configCHECK_FOR_STACK_OVERFLOW 0 +#define configUSE_RECURSIVE_MUTEXES 1 +#define configQUEUE_REGISTRY_SIZE 20 +#define configUSE_APPLICATION_TASK_TAG 1 +#define configUSE_COUNTING_SEMAPHORES 1 +#define configUSE_ALTERNATIVE_API 0 +#define configUSE_QUEUE_SETS 1 +#define configUSE_TASK_NOTIFICATIONS 1 +#define configSUPPORT_STATIC_ALLOCATION 1 + +/* Software timer related configuration options. The maximum possible task +priority is configMAX_PRIORITIES - 1. The priority of the timer task is +deliberately set higher to ensure it is correctly capped back to +configMAX_PRIORITIES - 1. */ +#define configUSE_TIMERS 1 +#define configTIMER_TASK_PRIORITY ( configMAX_PRIORITIES - 1 ) +#define configTIMER_QUEUE_LENGTH 20 +#define configTIMER_TASK_STACK_DEPTH ( configMINIMAL_STACK_SIZE * 2 ) + +#define configMAX_PRIORITIES ( 56 ) + +/* Run time stats gathering configuration options. */ +unsigned long ulGetRunTimeCounterValue( void ); /* Prototype of function that returns run time counter. */ +void vConfigureTimerForRunTimeStats( void ); /* Prototype of function that initialises the run time counter. */ +#define configGENERATE_RUN_TIME_STATS 1 +#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() vConfigureTimerForRunTimeStats() +#define portGET_RUN_TIME_COUNTER_VALUE() ulGetRunTimeCounterValue() + +/* Co-routine related configuration options. */ +#define configUSE_CO_ROUTINES 0 +#define configMAX_CO_ROUTINE_PRIORITIES ( 2 ) + +/* This demo can use of one or more example stats formatting functions. These +format the raw data provided by the uxTaskGetSystemState() function in to human +readable ASCII form. See the notes in the implementation of vTaskList() within +FreeRTOS/Source/tasks.c for limitations. */ +#define configUSE_STATS_FORMATTING_FUNCTIONS 0 + +/* Enables the test whereby a stack larger than the total heap size is +requested. */ +#define configSTACK_DEPTH_TYPE uint32_t + +/* Set the following definitions to 1 to include the API function, or zero +to exclude the API function. In most cases the linker will remove unused +functions anyway. */ +#define INCLUDE_vTaskPrioritySet 1 +#define INCLUDE_uxTaskPriorityGet 1 +#define INCLUDE_vTaskDelete 1 +#define INCLUDE_vTaskCleanUpResources 0 +#define INCLUDE_vTaskSuspend 1 +#define INCLUDE_vTaskDelayUntil 1 +#define INCLUDE_vTaskDelay 1 +#define INCLUDE_uxTaskGetStackHighWaterMark 1 +#define INCLUDE_uxTaskGetStackHighWaterMark2 1 +#define INCLUDE_xTaskGetSchedulerState 1 +#define INCLUDE_xTimerGetTimerDaemonTaskHandle 1 +#define INCLUDE_xTaskGetIdleTaskHandle 1 +#define INCLUDE_xTaskGetHandle 1 +#define INCLUDE_eTaskGetState 1 +#define INCLUDE_xSemaphoreGetMutexHolder 1 +#define INCLUDE_xTimerPendFunctionCall 1 +#define INCLUDE_xTaskAbortDelay 1 + +#define configINCLUDE_MESSAGE_BUFFER_AMP_DEMO 0 +#if ( configINCLUDE_MESSAGE_BUFFER_AMP_DEMO == 1 ) + extern void vGenerateCoreBInterrupt( void * xUpdatedMessageBuffer ); + #define sbSEND_COMPLETED( pxStreamBuffer ) vGenerateCoreBInterrupt( pxStreamBuffer ) +#endif /* configINCLUDE_MESSAGE_BUFFER_AMP_DEMO */ + +extern void vAssertCalled( unsigned long ulLine, const char * const pcFileName ); + +#define projCOVERAGE_TEST 0 +/* projCOVERAGE_TEST should be defined on the command line so this file can be +used with multiple project configurations. If it is + */ +#ifndef projCOVERAGE_TEST + #error projCOVERAGE_TEST should be defined to 1 or 0 on the command line. +#endif + +#if( projCOVERAGE_TEST == 1 ) + /* Insert NOPs in empty decision paths to ensure both true and false paths + are being tested. */ + #define mtCOVERAGE_TEST_MARKER() __asm volatile( "NOP" ) + + /* Ensure the tick count overflows during the coverage test. */ + #define configINITIAL_TICK_COUNT 0xffffd800UL + + /* Allows tests of trying to allocate more than the heap has free. */ + #define configUSE_MALLOC_FAILED_HOOK 0 + + /* To test builds that remove the static qualifier for debug builds. */ + #define portREMOVE_STATIC_QUALIFIER +#else + /* It is a good idea to define configASSERT() while developing. configASSERT() + uses the same semantics as the standard C assert() macro. Don't define + configASSERT() when performing code coverage tests though, as it is not + intended to asserts() to fail, some some code is intended not to run if no + errors are present. */ + #define configASSERT( x ) if( ( x ) == 0 ) vAssertCalled( __LINE__, __FILE__ ) + + #define configUSE_MALLOC_FAILED_HOOK 1 + + /* Include the FreeRTOS+Trace FreeRTOS trace macro definitions. */ + // #include "trcRecorder.h" +#endif + + +#endif /* FREERTOS_CONFIG_H */ diff --git a/example/export/elab_common_win32.c b/example/export/elab_common_win32.c deleted file mode 100644 index b007ac8c8fdec7e550e4496b7eb50f9078c2ccdc..0000000000000000000000000000000000000000 --- a/example/export/elab_common_win32.c +++ /dev/null @@ -1,33 +0,0 @@ -/* - * eLab Project - * Copyright (c) 2023, EventOS Team, - */ - -/* include ------------------------------------------------------------------ */ -#include "elab.h" -#include - -static uint64_t time_init = UINT64_MAX; - -/* public function ---------------------------------------------------------- */ -/** - * @brief eLab initialization exporting function. - * @param level init level. - * @retval None - */ -uint32_t elab_time_ms(void) -{ - struct timeval tt; - gettimeofday(&tt, NULL); - uint64_t time_current = (tt.tv_sec * 1000) + (tt.tv_usec / 1000); - - if (time_init == UINT64_MAX) - { - time_init = time_current; - } - - return (uint32_t)(time_current - time_init); - return 0; -} - -/* ----------------------------- end of file -------------------------------- */ diff --git a/example/export/elab_config.h b/example/export/elab_config.h index ace18b98709e3e86f08e30492ab7f34f5f653694..c5f53d3ddab9969e472b8d5ba24df96db0aedb61 100644 --- a/example/export/elab_config.h +++ b/example/export/elab_config.h @@ -8,7 +8,7 @@ /* public config ------------------------------------------------------------ */ /* CMSIS OS related -------------------------------------- */ -#define ELAB_RTOS_CMSIS_OS_EN (0) +#define ELAB_RTOS_CMSIS_OS_EN (1) #define ELAB_RTOS_TICK_MS (1) /* QPC related ------------------------------------------- */ diff --git a/example/export/main.c b/example/export/main.c index eaa9cd0c629ba09555a4882acee83dda852c9b05..0acc500262785ef0d943f1cde9e73895c15f26b6 100644 --- a/example/export/main.c +++ b/example/export/main.c @@ -4,9 +4,8 @@ */ /* Includes ------------------------------------------------------------------*/ -#include "elab.h" - -const elab_export_t ex[2]; +#include "elab/common/elab_common.h" +#include "elab/common/elab_export.h" /* public functions --------------------------------------------------------- */ /** @@ -15,7 +14,6 @@ const elab_export_t ex[2]; */ int main(void) { - printf("address: %u.\n", (uint32_t)((uint32_t)&ex[1] - (uint32_t)&ex[0])); elab_run(); } @@ -24,40 +22,43 @@ int main(void) static void _export_test_bsp(void) { - printf("export bsp testing passed.\n"); + printf("export bsp testing.\n"); } +INIT_EXPORT(_export_test_bsp, EXPORT_LEVEL_BSP); +EXIT_EXPORT(_export_test_bsp, EXPORT_LEVEL_BSP); static void _export_test_io_driver(void) { - printf("export io driver testing passed.\n"); + printf("export io driver testing.\n"); } +INIT_EXPORT(_export_test_io_driver, EXPORT_DRVIVER); +EXIT_EXPORT(_export_test_io_driver, EXPORT_DRVIVER); static void _export_test_component(void) { - printf("export component testing passed.\n"); + printf("export component testing.\n"); } +INIT_EXPORT(_export_test_component, EXPORT_MIDWARE); +EXIT_EXPORT(_export_test_component, EXPORT_MIDWARE); static void _export_test_device(void) { - printf("export device testing passed.\n"); + printf("export device testing.\n"); } +INIT_EXPORT(_export_test_device, EXPORT_DEVICE); +EXIT_EXPORT(_export_test_device, EXPORT_DEVICE); static void _export_test_app(void) { - printf("export app testing passed.\n"); + printf("export app testing.\n"); } +INIT_EXPORT(_export_test_app, EXPORT_APP); +EXIT_EXPORT(_export_test_app, EXPORT_APP); static void _export_test_poll(void) { - printf("export poll testing passed.\n"); + printf("export poll testing.\n"); } - -INIT_BSP_EXPORT(_export_test_bsp); -INIT_IO_DRIVER_EXPORT(_export_test_io_driver); -INIT_COMPONENT_EXPORT(_export_test_component); -INIT_DEV_EXPORT(_export_test_device); -INIT_APP_EXPORT(_export_test_app); - POLL_EXPORT(_export_test_poll, 1000); /* ----------------------------- end of file -------------------------------- */ diff --git a/example/export/x_build.bat b/example/export/x_build.bat index a956695304a5f238a5f02943d12a642c786a2eb0..905d2f39fb32e599b7fe40134e6c499d54e2ba19 100644 --- a/example/export/x_build.bat +++ b/example/export/x_build.bat @@ -1,11 +1,14 @@ md build gcc -std=c99 -g ^ -main.c ^ -elab_common_win32.c ^ -..\..\common\elab_export.c ^ --I ..\..\port\Metal ^ +*.c ^ +..\..\elab\common\*.c ^ +..\..\elab\os\win32\cmsis_os_cb.c ^ +..\..\elab\os\win32\cmsis_os.c ^ +..\..\elab\3rd\FreeRTOS\*.c ^ +..\..\elab\3rd\FreeRTOS\portable\MemMang\heap_4.c ^ +..\..\elab\3rd\FreeRTOS\portable\mingw\port.c ^ -I ..\.. ^ --I ..\..\common ^ -I . ^ --o build\elab_export_test \ No newline at end of file +-o build\export ^ +-l winmm \ No newline at end of file diff --git a/example/export/x_build.sh b/example/export/x_build.sh new file mode 100755 index 0000000000000000000000000000000000000000..0543a4f6160722e17b3cd7b7b3ca33e6f26ee162 --- /dev/null +++ b/example/export/x_build.sh @@ -0,0 +1,10 @@ +mkdir build + +gcc -std=gnu99 -g \ +main.c \ +../../elab/common/*.c \ +../../elab/os/posix/cmsis_os.c \ +-I ../.. \ +-I . \ +-o build/export \ +-l pthread diff --git a/example/qp_cmsis_os_win32/test_thread.c b/example/qp_cmsis_os_win32/test_thread.c deleted file mode 100644 index cc45455739d4c4c213002cc21c903786b52971c1..0000000000000000000000000000000000000000 --- a/example/qp_cmsis_os_win32/test_thread.c +++ /dev/null @@ -1,25 +0,0 @@ -/* - * eLab Project - * Copyright (c) 2023, EventOS Team, - */ - -/* includes ------------------------------------------------------------------*/ -#include -#include "elab.h" - -/* private state function prototypes -----------------------------------------*/ -static void _entry(void *para); - -THREAD_EXPORT(test, _entry, osPriorityNormal, NULL, 1024); - -/* private state function ----------------------------------------------------*/ -static void _entry(void *para) -{ - while (1) - { - printf("Thread exporting testing passed.\n"); - osDelay(1000); - } -} - -/* ----------------------------- end of file -------------------------------- */ diff --git a/example/qp_cmsis_os_win32/w_build.bat b/example/qp_cmsis_os_win32/w_build.bat deleted file mode 100644 index e6b46da34e81b5ce09c8ddda96b1e83c4135b61d..0000000000000000000000000000000000000000 --- a/example/qp_cmsis_os_win32/w_build.bat +++ /dev/null @@ -1,46 +0,0 @@ -md build - -gcc -std=c99 -g ^ -main.c ^ -test_qp.c ^ -test_thread.c ^ -..\..\common\elab_common.c ^ -..\..\common\elab_export.c ^ -..\..\port\FreeRTOS\elab_port.c ^ -..\..\RTOS\CMSIS_OS_FreeRTOS\cmsis_os_cb.c ^ -..\..\RTOS\CMSIS_OS_FreeRTOS\cmsis_os.c ^ -..\..\3rd\FreeRTOS\croutine.c ^ -..\..\3rd\FreeRTOS\event_groups.c ^ -..\..\3rd\FreeRTOS\list.c ^ -..\..\3rd\FreeRTOS\queue.c ^ -..\..\3rd\FreeRTOS\stream_buffer.c ^ -..\..\3rd\FreeRTOS\tasks.c ^ -..\..\3rd\FreeRTOS\timers.c ^ -..\..\3rd\FreeRTOS\portable\MemMang\heap_4.c ^ -..\..\3rd\FreeRTOS\portable\mingw\port.c ^ -..\..\3rd\QPC\src\qf\qep_hsm.c ^ -..\..\3rd\QPC\src\qf\qep_msm.c ^ -..\..\3rd\QPC\src\qf\qf_act.c ^ -..\..\3rd\QPC\src\qf\qf_actq.c ^ -..\..\3rd\QPC\src\qf\qf_defer.c ^ -..\..\3rd\QPC\src\qf\qf_dyn.c ^ -..\..\3rd\QPC\src\qf\qf_ps.c ^ -..\..\3rd\QPC\src\qf\qf_qact.c ^ -..\..\3rd\QPC\src\qf\qf_qmact.c ^ -..\..\3rd\QPC\src\qf\qf_time.c ^ -..\..\3rd\QPC\src\qf\qf_qeq.c ^ -..\..\3rd\QPC\src\qf\qf_mem.c ^ -..\..\3rd\QPC\ports\freertos\qf_port.c ^ -..\..\3rd\QPC\qpc_export.c ^ --I ..\.. ^ --I ..\..\port\FreeRTOS ^ --I ..\..\RTOS\CMSIS_OS_FreeRTOS ^ --I ..\..\3rd\FreeRTOS\include ^ --I ..\..\3rd\FreeRTOS\portable\mingw ^ --I ..\..\3rd\QPC\include ^ --I ..\..\3rd\QPC\src ^ --I ..\..\3rd ^ --I ..\..\3rd\QPC\ports\freertos ^ --I . ^ --o build\qpc_cmsis_os ^ --l winmm diff --git a/example/qp_cmsis_os_win32/x_linux.sh b/example/qp_cmsis_os_win32/x_linux.sh deleted file mode 100644 index 2e4a5c5bba34079cf16254ed2948b83d5727de5a..0000000000000000000000000000000000000000 --- a/example/qp_cmsis_os_win32/x_linux.sh +++ /dev/null @@ -1,42 +0,0 @@ -mkdir build - -gcc -std=gnu99 -g \ -main.c \ -test_qp.c \ -test_thread.c \ -../../common/elab_common.c \ -../../common/elab_assert.c \ -../../common/elab_export.c \ -../../port/posix/elab_port.c \ -../../RTOS/CMSIS_OS_POSIX/cmsis_os.c \ -../../3rd/Shell/shell_cmd_list.c \ -../../3rd/Shell/shell_companion.c \ -../../3rd/Shell/shell_ext.c \ -../../3rd/Shell/shell.c \ -../../midware/esh/esh.c \ -../../3rd/QPC/src/qf/qep_hsm.c \ -../../3rd/QPC/src/qf/qep_msm.c \ -../../3rd/QPC/src/qf/qf_act.c \ -../../3rd/QPC/src/qf/qf_actq.c \ -../../3rd/QPC/src/qf/qf_defer.c \ -../../3rd/QPC/src/qf/qf_dyn.c \ -../../3rd/QPC/src/qf/qf_ps.c \ -../../3rd/QPC/src/qf/qf_qact.c \ -../../3rd/QPC/src/qf/qf_qmact.c \ -../../3rd/QPC/src/qf/qf_time.c \ -../../3rd/QPC/src/qf/qf_qeq.c \ -../../3rd/QPC/src/qf/qf_mem.c \ -../../3rd/QPC/ports/posix/qf_port.c \ -../../3rd/QPC/qpc_export.c \ --I ../.. \ --I ../../common \ --I ../../port/posix \ --I ../../RTOS/CMSIS_OS_POSIX \ --I ../../3rd/QPC/include \ --I ../../3rd/QPC/src \ --I ../../3rd \ --I ../../3rd/QPC/ports/posix \ --I ../../midware/esh \ --I . \ --o build/qpc_cmsis_os \ --l pthread diff --git a/example/qpc_cmsis_os/FreeRTOSConfig.h b/example/qpc_cmsis_os/FreeRTOSConfig.h new file mode 100644 index 0000000000000000000000000000000000000000..10187681b29714a8d3b382b0e691c7541914e17d --- /dev/null +++ b/example/qpc_cmsis_os/FreeRTOSConfig.h @@ -0,0 +1,161 @@ +/* + * FreeRTOS Kernel V10.3.1 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ +#ifndef FREERTOS_CONFIG_H +#define FREERTOS_CONFIG_H + +/*----------------------------------------------------------- + * Application specific definitions. + * + * These definitions should be adjusted for your particular hardware and + * application requirements. + * + * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE + * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE. See + * http://www.freertos.org/a00110.html + *----------------------------------------------------------*/ + +#define configUSE_PREEMPTION 1 +#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0 +#define configUSE_IDLE_HOOK 1 +#define configUSE_TICK_HOOK 1 +#define configUSE_DAEMON_TASK_STARTUP_HOOK 1 +#define configTICK_RATE_HZ ( 1000 ) /* In this non-real time simulated environment the tick frequency has to be at least a multiple of the Win32 tick frequency, and therefore very slow. */ +#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 70 ) /* In this simulated case, the stack only has to hold one small structure as the real stack is part of the win32 thread. */ +#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 32 * 1024 * 1024 ) ) +#define configMAX_TASK_NAME_LEN ( 12 ) +#define configUSE_TRACE_FACILITY 1 +#define configUSE_16_BIT_TICKS 0 +#define configIDLE_SHOULD_YIELD 1 +#define configUSE_MUTEXES 1 +#define configCHECK_FOR_STACK_OVERFLOW 0 +#define configUSE_RECURSIVE_MUTEXES 1 +#define configQUEUE_REGISTRY_SIZE 20 +#define configUSE_APPLICATION_TASK_TAG 1 +#define configUSE_COUNTING_SEMAPHORES 1 +#define configUSE_ALTERNATIVE_API 0 +#define configUSE_QUEUE_SETS 1 +#define configUSE_TASK_NOTIFICATIONS 1 +#define configSUPPORT_STATIC_ALLOCATION 1 + +/* Software timer related configuration options. The maximum possible task +priority is configMAX_PRIORITIES - 1. The priority of the timer task is +deliberately set higher to ensure it is correctly capped back to +configMAX_PRIORITIES - 1. */ +#define configUSE_TIMERS 1 +#define configTIMER_TASK_PRIORITY ( configMAX_PRIORITIES - 1 ) +#define configTIMER_QUEUE_LENGTH 20 +#define configTIMER_TASK_STACK_DEPTH ( configMINIMAL_STACK_SIZE * 2 ) + +#define configMAX_PRIORITIES ( 56 ) + +/* Run time stats gathering configuration options. */ +unsigned long ulGetRunTimeCounterValue( void ); /* Prototype of function that returns run time counter. */ +void vConfigureTimerForRunTimeStats( void ); /* Prototype of function that initialises the run time counter. */ +#define configGENERATE_RUN_TIME_STATS 1 +#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() vConfigureTimerForRunTimeStats() +#define portGET_RUN_TIME_COUNTER_VALUE() ulGetRunTimeCounterValue() + +/* Co-routine related configuration options. */ +#define configUSE_CO_ROUTINES 0 +#define configMAX_CO_ROUTINE_PRIORITIES ( 2 ) + +/* This demo can use of one or more example stats formatting functions. These +format the raw data provided by the uxTaskGetSystemState() function in to human +readable ASCII form. See the notes in the implementation of vTaskList() within +FreeRTOS/Source/tasks.c for limitations. */ +#define configUSE_STATS_FORMATTING_FUNCTIONS 0 + +/* Enables the test whereby a stack larger than the total heap size is +requested. */ +#define configSTACK_DEPTH_TYPE uint32_t + +/* Set the following definitions to 1 to include the API function, or zero +to exclude the API function. In most cases the linker will remove unused +functions anyway. */ +#define INCLUDE_vTaskPrioritySet 1 +#define INCLUDE_uxTaskPriorityGet 1 +#define INCLUDE_vTaskDelete 1 +#define INCLUDE_vTaskCleanUpResources 0 +#define INCLUDE_vTaskSuspend 1 +#define INCLUDE_vTaskDelayUntil 1 +#define INCLUDE_vTaskDelay 1 +#define INCLUDE_uxTaskGetStackHighWaterMark 1 +#define INCLUDE_uxTaskGetStackHighWaterMark2 1 +#define INCLUDE_xTaskGetSchedulerState 1 +#define INCLUDE_xTimerGetTimerDaemonTaskHandle 1 +#define INCLUDE_xTaskGetIdleTaskHandle 1 +#define INCLUDE_xTaskGetHandle 1 +#define INCLUDE_eTaskGetState 1 +#define INCLUDE_xSemaphoreGetMutexHolder 1 +#define INCLUDE_xTimerPendFunctionCall 1 +#define INCLUDE_xTaskAbortDelay 1 + +#define configINCLUDE_MESSAGE_BUFFER_AMP_DEMO 0 +#if ( configINCLUDE_MESSAGE_BUFFER_AMP_DEMO == 1 ) + extern void vGenerateCoreBInterrupt( void * xUpdatedMessageBuffer ); + #define sbSEND_COMPLETED( pxStreamBuffer ) vGenerateCoreBInterrupt( pxStreamBuffer ) +#endif /* configINCLUDE_MESSAGE_BUFFER_AMP_DEMO */ + +extern void vAssertCalled( unsigned long ulLine, const char * const pcFileName ); + +#define projCOVERAGE_TEST 0 +/* projCOVERAGE_TEST should be defined on the command line so this file can be +used with multiple project configurations. If it is + */ +#ifndef projCOVERAGE_TEST + #error projCOVERAGE_TEST should be defined to 1 or 0 on the command line. +#endif + +#if( projCOVERAGE_TEST == 1 ) + /* Insert NOPs in empty decision paths to ensure both true and false paths + are being tested. */ + #define mtCOVERAGE_TEST_MARKER() __asm volatile( "NOP" ) + + /* Ensure the tick count overflows during the coverage test. */ + #define configINITIAL_TICK_COUNT 0xffffd800UL + + /* Allows tests of trying to allocate more than the heap has free. */ + #define configUSE_MALLOC_FAILED_HOOK 0 + + /* To test builds that remove the static qualifier for debug builds. */ + #define portREMOVE_STATIC_QUALIFIER +#else + /* It is a good idea to define configASSERT() while developing. configASSERT() + uses the same semantics as the standard C assert() macro. Don't define + configASSERT() when performing code coverage tests though, as it is not + intended to asserts() to fail, some some code is intended not to run if no + errors are present. */ + #define configASSERT( x ) if( ( x ) == 0 ) vAssertCalled( __LINE__, __FILE__ ) + + #define configUSE_MALLOC_FAILED_HOOK 1 + + /* Include the FreeRTOS+Trace FreeRTOS trace macro definitions. */ + // #include "trcRecorder.h" +#endif + + +#endif /* FREERTOS_CONFIG_H */ diff --git a/example/qp_cmsis_os_win32/elab_config.h b/example/qpc_cmsis_os/elab_config.h similarity index 100% rename from example/qp_cmsis_os_win32/elab_config.h rename to example/qpc_cmsis_os/elab_config.h diff --git a/example/qp_cmsis_os_win32/event_def.h b/example/qpc_cmsis_os/event_def.h similarity index 93% rename from example/qp_cmsis_os_win32/event_def.h rename to example/qpc_cmsis_os/event_def.h index c0d8d5e3496ba8b3bb7cab2e6d3496ffb78b0675..76da93504bdbf5a3df865e14fd66f58332e62025 100644 --- a/example/qp_cmsis_os_win32/event_def.h +++ b/example/qpc_cmsis_os/event_def.h @@ -7,7 +7,7 @@ #define __EVENT_DEF_H__ /* includes ----------------------------------------------------------------- */ -#include "qpc.h" +#include "elab/3rd/qpc/include/qpc.h" /* public typedef ----------------------------------------------------------- */ enum diff --git a/example/qp_cmsis_os_win32/main.c b/example/qpc_cmsis_os/main.c similarity index 32% rename from example/qp_cmsis_os_win32/main.c rename to example/qpc_cmsis_os/main.c index 0123152333f2d6da789a1931e06e62b26106b881..0079bb3385153720d60cee1af83aed2c79f4d8c5 100644 --- a/example/qp_cmsis_os_win32/main.c +++ b/example/qpc_cmsis_os/main.c @@ -4,7 +4,7 @@ */ /* Includes ------------------------------------------------------------------*/ -#include "elab.h" +#include "elab/elab.h" /* public functions --------------------------------------------------------- */ /** @@ -17,45 +17,3 @@ int main(void) } /* ----------------------------- end of file -------------------------------- */ - - -/* Private functions ---------------------------------------------------------*/ -#include - -static void _export_test_bsp(void) -{ - printf("export bsp testing passed.\n"); -} - -static void _export_test_io_driver(void) -{ - printf("export io driver testing passed.\n"); -} - -static void _export_test_component(void) -{ - printf("export component testing passed.\n"); -} - -static void _export_test_device(void) -{ - printf("export device testing passed.\n"); -} - -static void _export_test_app(void) -{ - printf("export app testing passed.\n"); -} - -static void _export_test_poll(void) -{ - printf("export poll testing passed.\n"); -} - -INIT_BSP_EXPORT(_export_test_bsp); -INIT_IO_DRIVER_EXPORT(_export_test_io_driver); -INIT_COMPONENT_EXPORT(_export_test_component); -INIT_DEV_EXPORT(_export_test_device); -INIT_APP_EXPORT(_export_test_app); - -POLL_EXPORT(_export_test_poll, 1000); \ No newline at end of file diff --git a/example/qp_cmsis_os_win32/test_qp.c b/example/qpc_cmsis_os/test_qp.c similarity index 47% rename from example/qp_cmsis_os_win32/test_qp.c rename to example/qpc_cmsis_os/test_qp.c index e17638538a7daec9f2c75f0658a4d3b33194c225..5d466dab08bbf8f82c74f4a69ca12e3274be168f 100644 --- a/example/qp_cmsis_os_win32/test_qp.c +++ b/example/qpc_cmsis_os/test_qp.c @@ -6,9 +6,11 @@ /* includes ------------------------------------------------------------------*/ #include #include "event_def.h" -#include "qpc.h" -#include "cmsis_os.h" -#include "elab.h" +#include "elab/3rd/qpc/include/qpc.h" +#include "elab/os/cmsis_os.h" +#include "elab/common/elab_export.h" + +Q_DEFINE_THIS_FILE /* private variables ---------------------------------------------------------*/ typedef struct ao_led @@ -19,29 +21,45 @@ typedef struct ao_led } ao_led_t; /* private state function prototypes -----------------------------------------*/ -static QState ao_led_initial(ao_led_t * const me, void const * const par); -static QState ao_led_on(ao_led_t * const me, QEvt const * const e); -static QState ao_led_off(ao_led_t * const me, QEvt const * const e); +static QState _state_initial(ao_led_t * const me, void const * const par); +static QState _state_on(ao_led_t * const me, QEvt const * const e); +static QState _state_off(ao_led_t * const me, QEvt const * const e); /* private variables ---------------------------------------------------------*/ static ao_led_t led; -HSM_EXPORT(sm_led, &led, ao_led_initial, osPriorityNormal, 32, 1024); +/* exported function ---------------------------------------------------------*/ +static void ao_led_init(void) +{ + ao_led_t *me = (ao_led_t *)&led; + QActive_ctor(&me->super, Q_STATE_CAST(&_state_initial)); + QTimeEvt_ctorX(&me->timeEvt, &me->super, Q_QPC_TEST_SIG, 0U); + + static uint8_t stack_led[1024]; + static QEvt const * led_evet_queue[32]; + + QACTIVE_START(&me->super, + osPriorityNormal, /* QP priority */ + led_evet_queue, Q_DIM(led_evet_queue), /* evt queue */ + (void *)stack_led, 1024U, /* no per-thread stack */ + (QEvt *)0); /* no initialization event */ +} +INIT_EXPORT(ao_led_init, EXPORT_APP); /* private state function ----------------------------------------------------*/ -static QState ao_led_initial(ao_led_t * const me, void const * const par) +static QState _state_initial(ao_led_t * const me, void const * const par) { (void)par; QTimeEvt_ctorX(&me->timeEvt, &me->super, Q_QPC_TEST_SIG, 0U); QTimeEvt_armX(&me->timeEvt, 1U, 500); - return Q_TRAN(&ao_led_off); + return Q_TRAN(&_state_off); } -static QState ao_led_on(ao_led_t * const me, QEvt const * const e) +static QState _state_on(ao_led_t * const me, QEvt const * const e) { - QState status_; + QState _status; switch (e->sig) { @@ -49,29 +67,29 @@ static QState ao_led_on(ao_led_t * const me, QEvt const * const e) { me->status = true; printf("Led on!\n"); - status_ = Q_HANDLED(); + _status = Q_HANDLED(); break; } case Q_QPC_TEST_SIG: { - status_ = Q_TRAN(&ao_led_off); + _status = Q_TRAN(&_state_off); break; } default: { - status_ = Q_SUPER(&QHsm_top); + _status = Q_SUPER(&QHsm_top); break; } } - return status_; + return _status; } -static QState ao_led_off(ao_led_t * const me, QEvt const * const e) +static QState _state_off(ao_led_t * const me, QEvt const * const e) { - QState status_; + QState _status; switch (e->sig) { @@ -79,23 +97,23 @@ static QState ao_led_off(ao_led_t * const me, QEvt const * const e) { me->status = false; printf("Led off!\n"); - status_ = Q_HANDLED(); + _status = Q_HANDLED(); break; } case Q_QPC_TEST_SIG: { - status_ = Q_TRAN(&ao_led_on); + _status = Q_TRAN(&_state_on); break; } default: { - status_ = Q_SUPER(&QHsm_top); + _status = Q_SUPER(&QHsm_top); break; } } - return status_; + return _status; } /* ----------------------------- end of file -------------------------------- */ diff --git a/example/qpc_cmsis_os/x_build.bat b/example/qpc_cmsis_os/x_build.bat new file mode 100644 index 0000000000000000000000000000000000000000..552812ac90b0d8dedcabd81062b9fa3577c167b6 --- /dev/null +++ b/example/qpc_cmsis_os/x_build.bat @@ -0,0 +1,17 @@ +md build + +gcc -std=c99 -g ^ +*.c ^ +..\..\elab\common\*.c ^ +..\..\elab\os\win32\cmsis_os_cb.c ^ +..\..\elab\os\win32\cmsis_os.c ^ +..\..\elab\3rd\FreeRTOS\*.c ^ +..\..\elab\3rd\FreeRTOS\portable\MemMang\heap_4.c ^ +..\..\elab\3rd\FreeRTOS\portable\mingw\port.c ^ +..\..\elab\3rd\qpc\src\qf\*.c ^ +..\..\elab\3rd\qpc\ports\freertos\qf_port.c ^ +..\..\elab\3rd\qpc\qpc_export.c ^ +-I ..\.. ^ +-I . ^ +-o build\qpc_cmsis_os ^ +-l winmm diff --git a/example/qpc_cmsis_os/x_build.sh b/example/qpc_cmsis_os/x_build.sh new file mode 100755 index 0000000000000000000000000000000000000000..ea942feda4672cfe34411def4ee1e8a5b353b236 --- /dev/null +++ b/example/qpc_cmsis_os/x_build.sh @@ -0,0 +1,13 @@ +mkdir build + +gcc -std=gnu99 -g \ +*.c \ +../../elab/common/*.c \ +../../elab/os/posix/cmsis_os.c \ +../../elab/3rd/qpc/src/qf/*.c \ +../../elab/3rd/qpc/ports/posix/qf_port.c \ +../../elab/3rd/qpc/qpc_export.c \ +-I ../.. \ +-I . \ +-o build/qpc_cmsis_os \ +-l pthread diff --git a/example/shell/FreeRTOSConfig.h b/example/shell/FreeRTOSConfig.h new file mode 100644 index 0000000000000000000000000000000000000000..10187681b29714a8d3b382b0e691c7541914e17d --- /dev/null +++ b/example/shell/FreeRTOSConfig.h @@ -0,0 +1,161 @@ +/* + * FreeRTOS Kernel V10.3.1 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ +#ifndef FREERTOS_CONFIG_H +#define FREERTOS_CONFIG_H + +/*----------------------------------------------------------- + * Application specific definitions. + * + * These definitions should be adjusted for your particular hardware and + * application requirements. + * + * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE + * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE. See + * http://www.freertos.org/a00110.html + *----------------------------------------------------------*/ + +#define configUSE_PREEMPTION 1 +#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0 +#define configUSE_IDLE_HOOK 1 +#define configUSE_TICK_HOOK 1 +#define configUSE_DAEMON_TASK_STARTUP_HOOK 1 +#define configTICK_RATE_HZ ( 1000 ) /* In this non-real time simulated environment the tick frequency has to be at least a multiple of the Win32 tick frequency, and therefore very slow. */ +#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 70 ) /* In this simulated case, the stack only has to hold one small structure as the real stack is part of the win32 thread. */ +#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 32 * 1024 * 1024 ) ) +#define configMAX_TASK_NAME_LEN ( 12 ) +#define configUSE_TRACE_FACILITY 1 +#define configUSE_16_BIT_TICKS 0 +#define configIDLE_SHOULD_YIELD 1 +#define configUSE_MUTEXES 1 +#define configCHECK_FOR_STACK_OVERFLOW 0 +#define configUSE_RECURSIVE_MUTEXES 1 +#define configQUEUE_REGISTRY_SIZE 20 +#define configUSE_APPLICATION_TASK_TAG 1 +#define configUSE_COUNTING_SEMAPHORES 1 +#define configUSE_ALTERNATIVE_API 0 +#define configUSE_QUEUE_SETS 1 +#define configUSE_TASK_NOTIFICATIONS 1 +#define configSUPPORT_STATIC_ALLOCATION 1 + +/* Software timer related configuration options. The maximum possible task +priority is configMAX_PRIORITIES - 1. The priority of the timer task is +deliberately set higher to ensure it is correctly capped back to +configMAX_PRIORITIES - 1. */ +#define configUSE_TIMERS 1 +#define configTIMER_TASK_PRIORITY ( configMAX_PRIORITIES - 1 ) +#define configTIMER_QUEUE_LENGTH 20 +#define configTIMER_TASK_STACK_DEPTH ( configMINIMAL_STACK_SIZE * 2 ) + +#define configMAX_PRIORITIES ( 56 ) + +/* Run time stats gathering configuration options. */ +unsigned long ulGetRunTimeCounterValue( void ); /* Prototype of function that returns run time counter. */ +void vConfigureTimerForRunTimeStats( void ); /* Prototype of function that initialises the run time counter. */ +#define configGENERATE_RUN_TIME_STATS 1 +#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() vConfigureTimerForRunTimeStats() +#define portGET_RUN_TIME_COUNTER_VALUE() ulGetRunTimeCounterValue() + +/* Co-routine related configuration options. */ +#define configUSE_CO_ROUTINES 0 +#define configMAX_CO_ROUTINE_PRIORITIES ( 2 ) + +/* This demo can use of one or more example stats formatting functions. These +format the raw data provided by the uxTaskGetSystemState() function in to human +readable ASCII form. See the notes in the implementation of vTaskList() within +FreeRTOS/Source/tasks.c for limitations. */ +#define configUSE_STATS_FORMATTING_FUNCTIONS 0 + +/* Enables the test whereby a stack larger than the total heap size is +requested. */ +#define configSTACK_DEPTH_TYPE uint32_t + +/* Set the following definitions to 1 to include the API function, or zero +to exclude the API function. In most cases the linker will remove unused +functions anyway. */ +#define INCLUDE_vTaskPrioritySet 1 +#define INCLUDE_uxTaskPriorityGet 1 +#define INCLUDE_vTaskDelete 1 +#define INCLUDE_vTaskCleanUpResources 0 +#define INCLUDE_vTaskSuspend 1 +#define INCLUDE_vTaskDelayUntil 1 +#define INCLUDE_vTaskDelay 1 +#define INCLUDE_uxTaskGetStackHighWaterMark 1 +#define INCLUDE_uxTaskGetStackHighWaterMark2 1 +#define INCLUDE_xTaskGetSchedulerState 1 +#define INCLUDE_xTimerGetTimerDaemonTaskHandle 1 +#define INCLUDE_xTaskGetIdleTaskHandle 1 +#define INCLUDE_xTaskGetHandle 1 +#define INCLUDE_eTaskGetState 1 +#define INCLUDE_xSemaphoreGetMutexHolder 1 +#define INCLUDE_xTimerPendFunctionCall 1 +#define INCLUDE_xTaskAbortDelay 1 + +#define configINCLUDE_MESSAGE_BUFFER_AMP_DEMO 0 +#if ( configINCLUDE_MESSAGE_BUFFER_AMP_DEMO == 1 ) + extern void vGenerateCoreBInterrupt( void * xUpdatedMessageBuffer ); + #define sbSEND_COMPLETED( pxStreamBuffer ) vGenerateCoreBInterrupt( pxStreamBuffer ) +#endif /* configINCLUDE_MESSAGE_BUFFER_AMP_DEMO */ + +extern void vAssertCalled( unsigned long ulLine, const char * const pcFileName ); + +#define projCOVERAGE_TEST 0 +/* projCOVERAGE_TEST should be defined on the command line so this file can be +used with multiple project configurations. If it is + */ +#ifndef projCOVERAGE_TEST + #error projCOVERAGE_TEST should be defined to 1 or 0 on the command line. +#endif + +#if( projCOVERAGE_TEST == 1 ) + /* Insert NOPs in empty decision paths to ensure both true and false paths + are being tested. */ + #define mtCOVERAGE_TEST_MARKER() __asm volatile( "NOP" ) + + /* Ensure the tick count overflows during the coverage test. */ + #define configINITIAL_TICK_COUNT 0xffffd800UL + + /* Allows tests of trying to allocate more than the heap has free. */ + #define configUSE_MALLOC_FAILED_HOOK 0 + + /* To test builds that remove the static qualifier for debug builds. */ + #define portREMOVE_STATIC_QUALIFIER +#else + /* It is a good idea to define configASSERT() while developing. configASSERT() + uses the same semantics as the standard C assert() macro. Don't define + configASSERT() when performing code coverage tests though, as it is not + intended to asserts() to fail, some some code is intended not to run if no + errors are present. */ + #define configASSERT( x ) if( ( x ) == 0 ) vAssertCalled( __LINE__, __FILE__ ) + + #define configUSE_MALLOC_FAILED_HOOK 1 + + /* Include the FreeRTOS+Trace FreeRTOS trace macro definitions. */ + // #include "trcRecorder.h" +#endif + + +#endif /* FREERTOS_CONFIG_H */ diff --git a/example/shell/arm_build.sh b/example/shell/arm_build.sh new file mode 100644 index 0000000000000000000000000000000000000000..29516d751ef71d37ccf1d835f940577c150d2632 --- /dev/null +++ b/example/shell/arm_build.sh @@ -0,0 +1,15 @@ +mkdir build + +arm-linux-gnueabihf-gcc -std=gnu99 -g \ +main.c \ +../../elab/common/*.c \ +../../elab/export/*.c \ +../../elab/test/test_elog.c \ +../../elab/test/test_preemption_linux.c \ +../../elab/3rd/Shell/*.c \ +../../elab/os/posix/cmsis_os.c \ +../../elab/port/posix/elab_port.c \ +-I ../.. \ +-I . \ +-o build/shell \ +-l pthread diff --git a/example/shell/elab_config.h b/example/shell/elab_config.h new file mode 100644 index 0000000000000000000000000000000000000000..c5f53d3ddab9969e472b8d5ba24df96db0aedb61 --- /dev/null +++ b/example/shell/elab_config.h @@ -0,0 +1,21 @@ +/* + * eLab Project + * Copyright (c) 2023, EventOS Team, + */ + +#ifndef ELAB_CONFIG_H +#define ELAB_CONFIG_H + +/* public config ------------------------------------------------------------ */ +/* CMSIS OS related -------------------------------------- */ +#define ELAB_RTOS_CMSIS_OS_EN (1) +#define ELAB_RTOS_TICK_MS (1) + +/* QPC related ------------------------------------------- */ +#define ELAB_QPC_EN (0) +#define ELAB_EVENT_DATA_SIZE (128) +#define ELAB_EVENT_POOL_SIZE (64) + +#endif /* ELAB_CONFIG_H */ + +/* ----------------------------- end of file -------------------------------- */ diff --git a/example/shell/main.c b/example/shell/main.c new file mode 100644 index 0000000000000000000000000000000000000000..1d89bfad09c0cba16cae20e358f57283bc7c8d2a --- /dev/null +++ b/example/shell/main.c @@ -0,0 +1,21 @@ +/* + * eLesson Project + * Copyright (c) 2023, EventOS Team, + */ + +/* Includes ------------------------------------------------------------------*/ +#include "elab/common/elab_common.h" +#include "elab/common/elab_export.h" + +/* public functions --------------------------------------------------------- */ +/** + * @brief The application entry point. + * @retval int + */ +int main(void) +{ + elab_debug_uart_init(115200); + elab_run(); +} + +/* ----------------------------- end of file -------------------------------- */ diff --git a/example/shell/shell_export.c b/example/shell/shell_export.c new file mode 100644 index 0000000000000000000000000000000000000000..0c47e036cd486e3def954ff35f900658c48281c6 --- /dev/null +++ b/example/shell/shell_export.c @@ -0,0 +1,6 @@ +/* + * eLesson Project + * Copyright (c) 2023, EventOS Team, + */ + +/* Includes ------------------------------------------------------------------*/ \ No newline at end of file diff --git a/example/shell/x_build.bat b/example/shell/x_build.bat new file mode 100644 index 0000000000000000000000000000000000000000..1407e5c5c4285f5c29c3d46a3b6b9aa92b5c4b3e --- /dev/null +++ b/example/shell/x_build.bat @@ -0,0 +1,17 @@ +md build + +gcc -std=c99 -g ^ +*.c ^ +..\..\elab\export\*.c ^ +..\..\elab\common\*.c ^ +..\..\elab\test\test_elog.c ^ +..\..\elab\os\win32\cmsis_os_cb.c ^ +..\..\elab\os\win32\cmsis_os.c ^ +..\..\elab\3rd\FreeRTOS\*.c ^ +..\..\elab\3rd\FreeRTOS\portable\MemMang\heap_4.c ^ +..\..\elab\3rd\FreeRTOS\portable\mingw\port.c ^ +..\..\elab\3rd\Shell\*.c ^ +-I ..\.. ^ +-I . ^ +-o build\shell ^ +-l winmm \ No newline at end of file diff --git a/example/shell/x_build.sh b/example/shell/x_build.sh new file mode 100755 index 0000000000000000000000000000000000000000..2f39feec7f916d9546b8d48d46717ed50315d5f2 --- /dev/null +++ b/example/shell/x_build.sh @@ -0,0 +1,13 @@ +mkdir build + +gcc -std=gnu99 -g \ +main.c \ +../../elab/common/*.c \ +../../elab/export/*.c \ +../../elab/test/test_elog.c \ +../../elab/3rd/Shell/*.c \ +../../elab/os/posix/cmsis_os.c \ +-I ../.. \ +-I . \ +-o build/shell \ +-l pthread diff --git a/lesson/ooc/lesson_10_edf/user/elab_uart_debug.c b/lesson/ooc/lesson_10_edf/user/elab_uart_debug.c index 87e6db06eca801d677640a26a9c7d357e8ad26b9..b594150f22c273142eb59b1023e7d8373525915f 100644 --- a/lesson/ooc/lesson_10_edf/user/elab_uart_debug.c +++ b/lesson/ooc/lesson_10_edf/user/elab_uart_debug.c @@ -4,8 +4,8 @@ */ /* includes ----------------------------------------------------------------- */ -#include "eLab/common/elab_common.h" -#include "eLab/elib/elib_queue.h" +#include "elab/common/elab_common.h" +#include "elab/elib/elib_queue.h" #include "stm32g0xx_hal.h" /* private config ----------------------------------------------------------- */ diff --git a/lesson/ooc/lesson_10_edf/user/main.c b/lesson/ooc/lesson_10_edf/user/main.c index 3ffc4f06392e9dc5c45a6280b04a5862fb2dad4a..240649c34d710a4c42d39bcbd62c16f67018b228 100644 --- a/lesson/ooc/lesson_10_edf/user/main.c +++ b/lesson/ooc/lesson_10_edf/user/main.c @@ -5,7 +5,7 @@ /* Includes ------------------------------------------------------------------*/ #include "bsp.h" -#include "eLab/common/elab_export.h" +#include "elab/common/elab_export.h" /* public functions --------------------------------------------------------- */ /** diff --git a/lesson/ooc/lesson_10_edf/user/oled.c b/lesson/ooc/lesson_10_edf/user/oled.c index 9dc81c3360b8bdbb6e2205c82f19adc9594ce883..29759bdc8a396307a47b7c5d4451ef51f3ee31a3 100644 --- a/lesson/ooc/lesson_10_edf/user/oled.c +++ b/lesson/ooc/lesson_10_edf/user/oled.c @@ -1,9 +1,9 @@ #include "oled.h" -#include "eLab/edf/normal/elab_spi.h" -#include "eLab/edf/normal/elab_pin.h" -#include "eLab/RTOS/cmsis_os.h" -#include "eLab/common/elab_assert.h" -#include "eLab/common/elab_export.h" +#include "elab/edf/normal/elab_spi.h" +#include "elab/edf/normal/elab_pin.h" +#include "elab/os/cmsis_os.h" +#include "elab/common/elab_assert.h" +#include "elab/common/elab_export.h" ELAB_TAG("OLED"); diff --git a/lesson/ooc/lesson_10_edf/user/shell_export.c b/lesson/ooc/lesson_10_edf/user/shell_export.c index 1a1c9ab426c73c44c8c31de88edea58a7c55e127..aceb1edaa79e616cb2bc3698b3c6f21f51516cd6 100644 --- a/lesson/ooc/lesson_10_edf/user/shell_export.c +++ b/lesson/ooc/lesson_10_edf/user/shell_export.c @@ -5,10 +5,10 @@ /* include ------------------------------------------------------------------ */ #include -#include "eLab/common/elab_common.h" -#include "eLab/common/elab_export.h" -#include "eLab/3rd/Shell/shell.h" -#include "eLab/common/elab_log.h" +#include "elab/common/elab_common.h" +#include "elab/common/elab_export.h" +#include "elab/3rd/Shell/shell.h" +#include "elab/common/elab_log.h" ELAB_TAG("ShellExport"); diff --git a/lesson/ooc/lesson_10_edf/user/test_oled.c b/lesson/ooc/lesson_10_edf/user/test_oled.c index 61b96e198b79f639ff6d39a736dfcd077c50a1f3..605625cb9d8d4767fe066c1d024e43c179e67089 100644 --- a/lesson/ooc/lesson_10_edf/user/test_oled.c +++ b/lesson/ooc/lesson_10_edf/user/test_oled.c @@ -9,7 +9,7 @@ #include #include #include -#include "eLab/3rd/Shell/shell.h" +#include "elab/3rd/Shell/shell.h" #include "oled.h" #ifdef __cplusplus diff --git a/test/func_test/test_os_event_flags.c b/test/func_test/test_os_event_flags.c new file mode 100644 index 0000000000000000000000000000000000000000..3bb16f3bfdd750732a42f90032ed292c537ae859 --- /dev/null +++ b/test/func_test/test_os_event_flags.c @@ -0,0 +1,99 @@ +/* + * eLab Project + * Copyright (c) 2023, EventOS Team, + */ + +/* Includes ------------------------------------------------------------------*/ +#include +#include +#include "elab/common/elab_common.h" +#include "elab/os/cmsis_os.h" +#include "elab/3rd/Shell/shell.h" +#include "elab/common/elab_log.h" + +ELAB_TAG("Test_OS_EventFlags"); + +/* private defines -----------------------------------------------------------*/ +#define EVENT_TEST_THREAH_ONE (1 << 1) +#define EVENT_TEST_THREAH_TWO (1 << 2) + +/* private variables ---------------------------------------------------------*/ +/** + * @brief The thread attribute for testing. + */ +static const osThreadAttr_t thread_attr_test = +{ + .name = "ThreadTest", + .attr_bits = osThreadDetached, + .priority = osPriorityNormal, + .stack_size = 2048, +}; + +static const osEventFlagsAttr_t event_attr_test = +{ + .name = "EventTest", + .attr_bits = osThreadDetached, + .cb_mem = NULL, + .cb_size = 0, +}; + +static osEventFlagsId_t event; + +/* private function prototypes -----------------------------------------------*/ +static void task_function_one(void *parameter); +static void task_function_two(void *parameter); +static void task_function_target(void *parameter); + +/* private functions ---------------------------------------------------------*/ +/** + * @brief Event flags in CMSIS OS testing. + * @param None + * @retval None + */ +static int32_t test_event_flags(int32_t argc, char *argv[]) +{ + osThreadNew(task_function_one, NULL, &thread_attr_test); + osThreadNew(task_function_two, NULL, &thread_attr_test); + osThreadNew(task_function_target, NULL, &thread_attr_test); +} + +SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN), + test_event_flags, + test_event_flags, + testing for event flags in CMSIS OS); + +/* private functions ---------------------------------------------------------*/ +static void task_function_one(void *parameter) +{ + while (1) + { + osDelay(1000); + printf("test_event task_function_one set event.\n"); + osEventFlagsSet(event, EVENT_TEST_THREAH_ONE); + osDelay(3000); + } +} + +static void task_function_two(void *parameter) +{ + while (1) + { + osDelay(3000); + printf("test_event task_function_two set event.\n"); + osEventFlagsSet(event, EVENT_TEST_THREAH_TWO); + osDelay(1000); + } +} + +static void task_function_target(void *parameter) +{ + while (1) + { + osEventFlagsWait(event, + (EVENT_TEST_THREAH_ONE | EVENT_TEST_THREAH_TWO), + osFlagsWaitAll, 10000); + elab_debug("test_event task_function_target pass."); + } +} + +/* ----------------------------- end of file -------------------------------- */ diff --git a/test/func_test/test_os_malloc_free.c b/test/func_test/test_os_malloc_free.c new file mode 100644 index 0000000000000000000000000000000000000000..dce4f35e6369c617f1d7a6699c52d5ee5273aa20 --- /dev/null +++ b/test/func_test/test_os_malloc_free.c @@ -0,0 +1,55 @@ +/* + * eLab Project + * Copyright (c) 2023, EventOS Team, + */ + +/* Includes ------------------------------------------------------------------*/ +#include +#include +#include "elab/common/elab_common.h" +#include "elab/os/cmsis_os.h" +#include "elab/3rd/Shell/shell.h" +#include "elab/common/elab_log.h" + +ELAB_TAG("Test_OS_Malloc_Free"); + +/* private functions ---------------------------------------------------------*/ +/** + * @brief Malloc & free testing. + * @param None + * @retval None + */ +static int32_t test_malloc_free(int32_t argc, char *argv[]) +{ + if (argc != 2) + { + elog_error("test_malloc_free Wrong argc. Actual: %d, expected: 2.", + argc); + return -1; + } + + int32_t malloc_size = atoi(argv[1]); + if (malloc_size <= 0) + { + elog_error("test_malloc_free Wrong malloc size %d.\n", malloc_size); + return -2; + } + + void *memory = elab_malloc(malloc_size); + if (memory == NULL) + { + elog_error("Malloc size %d bytes fails.\n", malloc_size); + return -3; + } + + elab_free(memory); + + return 0; +} + +SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN), + test_malloc_free, + test_malloc_free, + testing for elab malloc & free functions); + +/* ----------------------------- end of file -------------------------------- */ diff --git "a/\347\211\210\346\234\254\350\257\264\346\230\216.md" "b/\347\211\210\346\234\254\350\257\264\346\230\216.md" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391