Test program to use rtc.c and spi.c library routines


Compile with
 icc11 -l rtc_ex.c -l libhc11.a -b:text=0x2000 -bdata:0x0100 -d_stack:0x9fff

#include <hc11.h>
#include "rtc.h"
#include "spi.h"

struct rtc_regs rtc;

main()
{

    setup_spi(SPI_MASTER|SPI_INT_DISABLE|SPI_CPOL_ZERO|SPI_CPHASE_ONE|
              SPI_CLOCK_E_DIV2);

    /* Set RTC clock to 08:15:00 27 April 1998  */
    rtc.sec = 0x00;
    rtc.min = 0x15;
    rtc.hour = 0x08;
    rtc.dow = 0x02;
    rtc.dom = 0x27;
    rtc.month = 0x04;
    rtc.year = 0x99;
    rtc.clk_control = RTC_CLOCKON|RTC_XTAL_32KHZ|RTC_CLKOUT_DISABLE;
    rtc.int_control = RTC_PERIODIC_1HZ;

    write_rtc(&rtc);
}