Hi Giovanni,
There is any example how to convert RTCDateTime to struct tm or unix timestamp?
The RTC driver topic
- Giovanni
- Site Admin
- Posts: 14893
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: The RTC driver topic
Hi,
I found error in STM32 RTCv2: wrong mask for WDU (not 1, should be 7).
I found error in STM32 RTCv2: wrong mask for WDU (not 1, should be 7).
Code: Select all
141 timespec->dayofweek = (dr >> RTC_DR_WDU_OFFSET) & 1;
- Giovanni
- Site Admin
- Posts: 14893
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: The RTC driver topic
Hi.
There is no definition 'typedef struct RTCTime RTCTime;' and if I try to use RTC in V.3.0 (current trunk) then errors occured.
There is no definition 'typedef struct RTCTime RTCTime;' and if I try to use RTC in V.3.0 (current trunk) then errors occured.
Re: The RTC driver topic
Hi Giovanni.
I am currently working on RTCv1 porting to ChibiOS-3. Most work done but I have some questions.
1) What functions better to use for conversion from counter to RTCDateTime and vise versa? Provided in compiler's stdlib or this ones:
http://stackoverflow.com/questions/1118 ... 2#11197532
http://stackoverflow.com/questions/7960 ... vice-versa
or any other?
2) Time conversion functions is time consumed (especially on platforms without hardware division) and that functions calls inside osalSysLock. I think that OS's mutual exclusion on RTC access will be better in this case.
I am currently working on RTCv1 porting to ChibiOS-3. Most work done but I have some questions.
1) What functions better to use for conversion from counter to RTCDateTime and vise versa? Provided in compiler's stdlib or this ones:
http://stackoverflow.com/questions/1118 ... 2#11197532
http://stackoverflow.com/questions/7960 ... vice-versa
or any other?
2) Time conversion functions is time consumed (especially on platforms without hardware division) and that functions calls inside osalSysLock. I think that OS's mutual exclusion on RTC access will be better in this case.
- Giovanni
- Site Admin
- Posts: 14893
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: The RTC driver topic
Hi,
I think it is better to use the library unless you think that code is really more efficient and there are not copyright problems.
About the critical zone, I am wondering if it is correct to have rtc functions in critical zones, there isn't even a state machine to protect. Do you think we should just remove all the lock/unlock and declare them simply non-reentrant? (all functions would be X-class, I-class variants would be removed)
Giovanni
I think it is better to use the library unless you think that code is really more efficient and there are not copyright problems.
About the critical zone, I am wondering if it is correct to have rtc functions in critical zones, there isn't even a state machine to protect. Do you think we should just remove all the lock/unlock and declare them simply non-reentrant? (all functions would be X-class, I-class variants would be removed)
Giovanni
Re: The RTC driver topic
Giovanni wrote:I think it is better to use the library unless you think that code is really more efficient and there are not copyright problems.
I am not think that that code is better even if it is faster. And copyright problems will cause headaches. Let it be library code. It can be easily replaced in future if needed.
Giovanni wrote:I am wondering if it is correct to have rtc functions in critical zones
Conversion functions do not need protection. But RTC registers' sequences need it. Any way, what is non-reentrant functions in terms of ChibiOS?
- Giovanni
- Site Admin
- Posts: 14893
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: The RTC driver topic
Lets use the library then.
A non reentrant function is a function that cannot be called from 2 threads concurrently or from an ISR and a thread. RTC functions would be non reentrant for the exact reason you stated, register accesses must not be interrupted by other RTC operations.
Giovanni
A non reentrant function is a function that cannot be called from 2 threads concurrently or from an ISR and a thread. RTC functions would be non reentrant for the exact reason you stated, register accesses must not be interrupted by other RTC operations.
Giovanni
Re: The RTC driver topic
Understand.
I think that code have to be in rtc.c(h) files.
Just a curious. Can you remember how rtc ISRs worked without EXTI in v-2.6 testhal?
Vooon wrote:There is any example how to convert RTCDateTime to struct tm or unix timestamp?
I think that code have to be in rtc.c(h) files.
Just a curious. Can you remember how rtc ISRs worked without EXTI in v-2.6 testhal?