The RTC driver topic

This forum is dedicated to feedback, discussions about ongoing or future developments, ideas and suggestions regarding the ChibiOS projects are welcome. This forum is NOT for support.
Vooon
Posts: 15
Joined: Tue Feb 01, 2011 11:13 pm

Re: The RTC driver topic

Post by Vooon »

Hi Giovanni,

There is any example how to convert RTCDateTime to struct tm or unix timestamp?
User avatar
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

Post by Giovanni »

Sorry, not yet, the driver is experimental.

Giovanni
Vooon
Posts: 15
Joined: Tue Feb 01, 2011 11:13 pm

Re: The RTC driver topic

Post 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;
User avatar
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

Post by Giovanni »

Fixed thanks.

Giovanni
alexblack
Posts: 277
Joined: Mon Sep 24, 2012 3:52 pm
Been thanked: 33 times

Re: The RTC driver topic

Post 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.
User avatar
barthess
Posts: 861
Joined: Wed Dec 08, 2010 7:55 pm
Been thanked: 7 times

Re: The RTC driver topic

Post 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.
User avatar
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

Post 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
User avatar
barthess
Posts: 861
Joined: Wed Dec 08, 2010 7:55 pm
Been thanked: 7 times

Re: The RTC driver topic

Post 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?
User avatar
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

Post 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
User avatar
barthess
Posts: 861
Joined: Wed Dec 08, 2010 7:55 pm
Been thanked: 7 times

Re: The RTC driver topic

Post 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?
Post Reply