Explain how to use rtc driver.
#include <dev/spi.h> #include <dev/rtc.h> //init SPI driver requried for rtc //register driver in system if (NutRegisterDevice(&devSpi0, 0, 0)) { NutPrintFormat(0, "Registering spi device failed\r\n"); } else { NutPrintFormat(0, "Registering spi device sucess.\r\n"); } //open SPI devSpi = NutDeviceOpen("spi0"); //init SPI (*devSpi->dev_init)(devSpi); //init RTC //register in system if (NutRegisterDevice(&devRtcSpi, 0, 0)) { NutPrintFormat(0, "Registering rtc device failed.\r\n"); } else { NutPrintFormat(0, "Registering rtc device sucess.\r\n"); } //open RTC devRtc = NutDeviceOpen("rtc0"); //init RTC (*devRtc->dev_init)(devRtc); //set time t.tm_sec=10; t.tm_min=20; t.tm_hour=23; t.tm_mday=31; t.tm_mon=12; t.tm_year=2003-1900; setTime(&t); //get time from RTC and conwert it to ASCII NutSleep(5000); NutPrintFormat(0, "\r\n%s", timeToAscii(getTime()));