2011/4/7 Rob Hamerling <[email protected]>

>
>
> On 2011/04/07 15:42, Sebastien Lelong wrote:
>
>  Another comment: it's not clear when RTCC peripheral is enabled or not.
>>
>
> It is enabled by rtc_init()


It is also when calling rtc_set_hhmmss_bcd(), because it calls
itself _rtc_write() and _rtc_write goes like this:

  1. RTCCFG_RTCEN = false
  2. update rtc registers
  3. RTCCFG_RTCEN = true

so even if I'm not calling rtc_init(), setting a date or time will enable
it.



>
>
>  I understand (from API point of view) rtc_init() actually enable the
>> peripheral. But reading code, it's also enabled each time _rtc_write()
>> is called, this means at each RTC setting (rtc_set, ...).
>>
>
> The datasheet says that the rtc registers should be written to only when
> the rtcc is disabled. Therefore the write routines contain a disable
> operation at entrance and a enable operation before returning.
> Did you overlook something or did I?


No, I think we agree, but according to my previous comment, this process
could go like this:

-- global state
var bit _rtc_enabled = false

procedure _rtc_write() is
   ...
   -- disable in any case
   RTCCFG_RTCEN = false                         -- disable rtc (temporary)
   ...
   -- enable it if it was previously enabled
   RTCCFG_RTCEN = _rtc_enabled
   ...
end procedure

procedure rtc_enable() is -- or rtc_init()
   ...
   _rtc_enabled = true
end procedure

procedure rtc_disable() is
   _rtc_enabled = false
end procedure


This way, I know when RTC will be enabled, because I'm controlling it.


>
> I cannot think why - once started - one would want to disable the rtcc
> module as a whole, but such a procedure could be added easily.


API point of view: if it can be started, then it should be stoppable too
(that's just a rule I'd stick too, a matter of taste). But I can see a real
life example. If you want to build a stopwatch, you'll need to be able have
control on start/stop state.


Cheers,
Seb

-- 
You received this message because you are subscribed to the Google Groups 
"jallib" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/jallib?hl=en.

Reply via email to