DS1302/DS1202 RTC driver

Alan

Happy new year!

This pull request is for a driver for the DS1302/DS1202 RTC chip which is used on both p112 and n8vem-mark4.

It is structured in a similar style to the SD driver, ie one generic driver that knows how to talk to the chip, and per-platform drivers that implement the actual hardware operations. The platform drivers are both written in assembler as I found sdcc generated quite verbose code for small functions when I wrote them in C. I also tried using one C function that manipulated all the hardware pins but it just made the code hard to follow.

On boot the ds1302_init() function is called from the platform setup code. This reads out the full RTC date and time, converts to posix time, and calls wrtime(). One problem I found with this was that naively telling the compiler to multiply 32-bit values pulls in the __mullong helper which is huge (nearly 500 bytes) and which lives in the _HOME segment, which the linker didn't know where to place; hilarity ensues. Instead of this I've written a small function to do 8x32 bit mulitplies which turns out to be all we need for the time conversion.

Please be aware that there is a slightly hacky trick in ds1302.c to get all the startup code into the DISCARD segment without separating the driver into two files and complicating the platform Makefile. This is done by jamming ".area _DISCARD" into the assembler output at the right point.

Reading the RTC is quite an expensive operation on these platforms, so the final commit introduces an optional value CONFIG_RTC_INTERVAL which sets the number of deciseconds between calls to rtc_secs().

Best wishes

Will