66#define CMSIS_VERSION (m,mm ) ( ( ( m )<< 16 ) | ( mm ) )
77
88#if osCMSIS < CMSIS_VERSION(1, 2)
9- #error "Unsupported CMSIS version: This header requires a CMSIS implementation with at least version 1.2"
9+ #error "Unsupported CMSIS version: This header requires a CMSIS-RTOS API implementation with at least version 1.2"
1010#endif
1111
12- #if osCMSIS_RTX < CMSIS_VERSION(4, 75 )
12+ #if !defined( osCMSIS_RTX) || osCMSIS_RTX != CMSIS_VERSION(4, 78 )
1313// unfortunately the implementation of the osXxxxDef and other similar macros
1414// are implementation defined and, at least for CMSIS-RTX cannot be used to
1515// declare a C++ data member. Thus, this header is specific to a particular
1616// version of CMSIS-RTX and requires re-evaluation and verification on any
17- // later versions.
18- #error "Unsupported CMSIS-RTOS implementation: This header requires the CMSIS-RTX implementation of CMSIS-RTOS with version 4.75"
17+ // other versions. The structures can and have changed even on minor version
18+ // changes, so the check here is for an exact match on the supported version.
19+ #error "Unsupported CMSIS-RTOS implementation: This header requires the CMSIS-RTX v4.78 implementation of the CMSIS-RTOS API"
1920#endif
2021
2122// The following two fields are culled from the CMSIS-RTX header implementation
2526 uint32_t os_mutex_cb_##name[4 ]; /* = { 0 }; */ \
2627 osMutexDef_t os_mutex_def_##name/* = { (os_mutex_cb_##name) }*/
2728
28- // This variant of the standard CMSIS-RTOS macro allows use as a member initializer
29- // list for a constructor.
29+ // This macro is used in the C++ class constructor initializer list to create
30+ // default initialized members
3031#define osMutexInitMember ( name )\
32+ os_mutex_cb_##name()\
33+ ,os_mutex_def_##name()
34+
35+ // This variant of the standard CMSIS-RTOS macro constructs a member
36+ // since a standard constructor isn't available.
37+ #define osMutexConstructMember ( name )\
3138 memset ( &os_mutex_cb_##name, 0 , sizeof ( os_mutex_cb_##name ) );\
3239 memset ( &os_mutex_def_##name, 0 , sizeof ( os_mutex_def_##name ) );\
3340 os_mutex_def_##name.mutex = &os_mutex_cb_##name
3441
42+ // This macor is used to define a timer instance as a member of a class or struct
3543#define osTimerDefMember ( name )\
36- uint32_t os_timer_cb_##name[5 ]; /* = { 0 }*/ \
44+ uint32_t os_timer_cb_##name[6 ]; /* = { 0 }*/ \
3745 osTimerDef_t os_timer_def_##name /* = { (function), (os_timer_cb_##name) }*/
3846
47+ // This macro is used in the C++ class constructor initializer list to create
48+ // initialized members
3949#define osTimerInitMember ( name )\
4050 os_timer_cb_##name()\
4151 ,os_timer_def_##name()
4252
4353// ARMCC 5.04 and earlier don't support C++11 initializer list syntax for member initialization
4454// Therefore, this is used in the constructor to set the internal members as needed.
4555#define osTimerConstructMember ( name, function )\
56+ memset ( &os_timer_cb_##name, 0 , sizeof ( os_timer_cb_##name ) );\
4657 os_timer_def_##name.ptimer = function;\
4758 os_timer_def_##name.timer = &os_timer_cb_##name
4859
4960namespace MsOpenTech
5061{
5162 namespace CMSIS_RTOS
52- {
63+ {
5364 class Timer
5465 {
5566 public:
@@ -69,7 +80,7 @@ namespace MsOpenTech
6980 void Start ( uint32_t initialTimeout, bool periodic )
7081 {
7182 TimerId = osTimerCreate ( osTimer (TimerDef), periodic ? osTimerPeriodic : osTimerOnce, CallbackArg );
72- osTimerStart (TimerId, initialTimeout);
83+ osTimerStart (TimerId, initialTimeout);
7384 }
7485
7586 // C++11 move semantics not supported in the ARM compiler 5.04 and earlier
0 commit comments