Page 18 of 23

Re: The RTC driver topic

Posted: Tue Sep 30, 2014 7:15 am
by Vooon
Hi Giovanni,

There is any example how to convert RTCDateTime to struct tm or unix timestamp?

Re: The RTC driver topic

Posted: Tue Sep 30, 2014 7:46 am
by Giovanni
Sorry, not yet, the driver is experimental.

Giovanni

Re: The RTC driver topic

Posted: Tue Sep 30, 2014 11:01 am
by Vooon
Hi,

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;

Re: The RTC driver topic

Posted: Tue Sep 30, 2014 11:23 am
by Giovanni
Fixed thanks.

Giovanni

Re: The RTC driver topic

Posted: Thu Oct 23, 2014 2:42 am
by alexblack
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.

Re: The RTC driver topic

Posted: Wed Oct 29, 2014 6:57 pm
by barthess
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.

Re: The RTC driver topic

Posted: Wed Oct 29, 2014 7:09 pm
by Giovanni
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

Re: The RTC driver topic

Posted: Wed Oct 29, 2014 7:30 pm
by barthess
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?

Re: The RTC driver topic

Posted: Wed Oct 29, 2014 7:34 pm
by Giovanni
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

Re: The RTC driver topic

Posted: Wed Oct 29, 2014 7:48 pm
by barthess
Understand.
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?