echristenson wrote on Wednesday, March 29, 2017:
Just ran into the overflow problem on this macro, as I’m using just 16-bit ticks, needing only a 10 second (10,000 tick) horizon for everything except the hourmeter:
"pound"define configUSE_16_BIT_TICKS 1
"pound"define configTICK_RATE_HZ ( ( TickType_t ) 1000 )
The problem with re-writing it really boils down to implementation details: If I use a constant argument that is computed at compile time, or even just once at startup, it doesn’t matter whether 64 bit types are implemented on the target or not. Modern, fast targets wouldn’t care if it was a run-time function, but I’m really not at all CPU-power conscious.
The “proper” size of the arguments in the calculation (defined by expectations as a naive user) would need to be sizeof(argument)+sizeof(TickType_t), which we can conservatively decide should be
2 * sizeof(TickType_t). Good luck properly expressing that in the C programming language, especially in a portable, simple way – you’d need some decent typedef magic.
A warning in the examples is probably best, as if the definition had been partially “fixed”,say, with uint32 casts, it just hides the problem until much later.
For myself, I’m modifying projdefs.h and putting my definition (with a warning) in FreeRTOSConfig.h.