[Updated on OS6] TimerEvent is no longer existing!! Checked TimerEvent function on os5 latest version. Result is okay on FRDM-K64F but STM32 series are NOT okay e.g. Nucleo-L152RE, -F446RE, -L432KC and so on. This TimerEvent is using SoftSerial library and works well on old os2 but not OS5 latest version STM32 series Mbed board.
Forum discussion.
https://forums.mbed.com/t/how-to-port-software-serial-to-os5-6/12641
https://forums.mbed.com/t/softserial-problem-l432kc/8288
Revision 1:3e3b7ec1f33d, committed 2021-03-30
- Comitter:
- kenjiArai
- Date:
- Tue Mar 30 07:30:39 2021 +0000
- Parent:
- 0:0a78edc7ac85
- Commit message:
- checked on OS6.8.0 (Online compile) & OS6.9.0(Mbed Studio 1.4.0 GCC)
Changed in this revision
--- a/check_revision.cpp Tue May 12 01:15:04 2020 +0000 +++ b/check_revision.cpp Tue Mar 30 07:30:39 2021 +0000 @@ -1,23 +1,27 @@ /* * Check Mbed revision * - * Copyright (c) 2020 Kenji Arai / JH1PJL + * Copyright (c) 2020,'21 Kenji Arai / JH1PJL * http://www7b.biglobe.ne.jp/~kenjia/ * https://os.mbed.com/users/kenjiArai/ * Created: May 12th, 2020 - * Revised: May 12th, 2020 + * Revised: March 30th, 2021 */ +#include "mbed.h" -#include "mbed.h" - +// RUN ONLY ON mbed-os-6.8.0 or 6.9.0 +// https://github.com/ARMmbed/mbed-os/releases/tag/mbed-os-6.9.0 +#if (MBED_MAJOR_VERSION == 6) &&\ + ((MBED_MINOR_VERSION == 8) || (MBED_MINOR_VERSION == 9))&&\ + (MBED_PATCH_VERSION == 0) // RUN ONLY ON mbed-os-5.15.3 // https://github.com/ARMmbed/mbed-os/releases/tag/mbed-os-5.15.3 -#if (MBED_MAJOR_VERSION == 5) &&\ +#elif (MBED_MAJOR_VERSION == 5) &&\ (MBED_MINOR_VERSION == 15) &&\ (MBED_PATCH_VERSION == 3) #elif (MBED_MAJOR_VERSION == 2) &&\ (MBED_MINOR_VERSION == 0) &&\ - (MBED_PATCH_VERSION == 132) + (MBED_PATCH_VERSION == 162) #else - #error "Please use mbed-os-5.15.3 or mbed-os-2.132" + #error "Please use mbed-os-5.15.3 or mbed-os-2.162 or os-6.8.0/6.9.0!" #endif
--- a/main.cpp Tue May 12 01:15:04 2020 +0000 +++ b/main.cpp Tue Mar 30 07:30:39 2021 +0000 @@ -1,23 +1,55 @@ /* - * Mbed-OS5 & OS-2 - * Check EventTimer behavior + * Mbed-OS5 & OS-2 --> Added OS6 + * Check EventTimer(on OS6, change name Ticker) behavior * - * Copyright (c) 2020 Kenji Arai / JH1PJL + * Copyright (c) 2020,'21 Kenji Arai / JH1PJL * http://www7b.biglobe.ne.jp/~kenjia/ * https://os.mbed.com/users/kenjiArai/ - * Revised: May 12th, 2020 - * Revised: May 12th, 2020 + * Created: May 12th, 2020 + * Revised: March 30th, 2021 + */ +/* + test result target = 50uS + Nucleo-L432KC + 2.162 + 0= 223, 1= 51, 2= 49, 3= 50, 4= 51, 5= 49, 6= 50, 7= 51, 8= 49 + 5.15.3 + 0= 109, 1= 50, 2= 50, 3= 48, 4= 51, 5= 52, 6= 47, 7= 52, 8= 48 + 6.8.0 + 0= 613, 1= 51, 2= 50, 3= 51, 4= 50, 5= 51, 6= 50, 7= 51, 8= 50 + + Nucleo-F446RE + 2.162 + 0= 85, 1= 50, 2= 50, 3= 50, 4= 50, 5= 50, 6= 50, 7= 50, 8= 50 + 5.15.3 + 0= 136, 1= 50, 2= 50, 3= 50, 4= 50, 5= 50, 6= 50, 7= 50, 8= 50 + 6.8.0 + 0= 138, 1= 50, 2= 50, 3= 50, 4= 50, 5= 50, 6= 50, 7= 50, 8= 50 + + FRDM-K64F + 2.162 + 0= 61, 1= 51, 2= 49, 3= 51, 4= 49, 5= 51, 6= 49, 7= 51, 8= 49 + 5.15.3 + 0= 61, 1= 53, 2= 49, 3= 48, 4= 49, 5= 53, 6= 49, 7= 49, 8= 50 + 6.8.0 + 0= 66, 1= 51, 2= 48, 3= 50, 4= 51, 5= 51, 6= 51, 7= 47, 8= 50 + + */ #include "mbed.h" +#if (MBED_MAJOR_VERSION == 6) +class FlexTicker: public Ticker +#else class FlexTicker: public TimerEvent +#endif { public: void attach(void(*fptr)(void)) { _function = Callback<void()>(fptr);} void detach() { remove();} void setNext(int delay) { insert(event.timestamp + delay);} - void prime() { event.timestamp = us_ticker_read();} + void prime() { event.timestamp = us_ticker_read();} protected: virtual void handler() { _function.call();} unsigned int _delay; @@ -57,11 +89,16 @@ tk.prime(); led = 0; tk.setNext(TARGET_TIME); +#if (MBED_MAJOR_VERSION == 6) + ThisThread::sleep_for(500ms); +#elif (MBED_MAJOR_VERSION == 5) thread_sleep_for(500); - //wait_ms(500); +#else + wait_ms(500); +#endif for (uint32_t i = 0; i < 9; i++) { printf("%d=%4d, ", i, time_data[i+1] - time_data[i]); } - printf("No=time[us]\r\n"); + printf("(<- No=time[us] (target %dus))\r\n", TARGET_TIME); } }
--- a/mbed-os.lib Tue May 12 01:15:04 2020 +0000 +++ b/mbed-os.lib Tue Mar 30 07:30:39 2021 +0000 @@ -1,1 +1,1 @@ -https://github.com/ARMmbed/mbed-os/#b6370b4c37f3d4665ed1cdcb1afea85396bba1b3 +https://github.com/ARMmbed/mbed-os/#bfde5aa1e74802771eaeacfa74789f71677325cb