Thanks, guys, for the work on this. I look forward to trying out the RTC support soon.
Giovanni wrote:I agree with that, I also included some definitions about FAT date/time in rtc.h. In a small system it is probably more useful than Unix time or some invented format.
In my experience, which is mostly in the field of 802.15.4 wireless networked control and sensor monitoring, a linear time format makes time and date operation much cleaner since I'm usually doing arithmetic like computing the difference between points in time, comparing points in time, or adding a time duration to a point in time. These operations are single operations for linear time representations, but mean a lot of fancy carrying and knowledge of calendar formats including leap year and daylight savings time if you want to use the “calendar†YYYYMMDDhhmmss format. Certainly you can convert from Y-M-D h:m:s format to a linear scale (e.g., seconds since the epoch), but I would prefer to only do that for display purposes. It's an uphill battle, however, since most RTCs including NXP LPC1700 the STM32 RTCv2 at least are designed for the YMDhms format (and may unfortunately have seconds as the finest time unit!).
So, do whatever makes sense in ChibiOS to make it map well to hardware. Only, I hope it can provide subsecond precision when the hardware makes it possible. Will ChibiOS's RTC driver support the STM32 RTCv1 with a divider of less than 32768 so that millisecond precision is obtainable?