elua/elua — pull request #9 by naves-thiago (2012-02-10 20:55:08+00:00)
Title: RTC module for STR912

Merging the RTC module we've been using here @led-lab on a private fork.
I've added the alarm interrupt functionality to this module ( I didn't write the rest of the module, btw ) and I thought this could be merged into the official repo.

The interface for setting the alarm is:
str9.rtc.setalarm( , "HH:MM:SS" )

The new interrupt type is:
cpu.INT_RTC_ALARM

Here's a code example:

function asd(b)
print("Alarm")
end

str9.rtc.setdate("01/01/2012" )
str9.rtc.settime( "01:00:00" )
print(str9.rtc.gettime("*s"))
str9.rtc.setalarm( 1, "01:00:10" )
cpu.set_int_handler( cpu.INT_RTC_ALARM, asd )
cpu.sei( cpu.INT_RTC_ALARM, 0 )

while (true) do
if (uart.getchar( 0, 0 ) ~= "") then
break;
end
end