From f9366236430cfd8f36944b25e76836dbfc826032 Mon Sep 17 00:00:00 2001 From: jdgordon Date: Tue, 23 Oct 2007 14:22:44 +0000 Subject: [PATCH] enable the RTC on the mrobe. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15279 a1c6a512-1295-4272-9138-f99709370657 --- firmware/drivers/rtc/rtc_rx5x348ab.c | 23 ++++++++++++++++++++--- firmware/export/config-mrobe500.h | 2 +- firmware/target/arm/tms320dm320/spi-dm320.c | 5 ++--- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/firmware/drivers/rtc/rtc_rx5x348ab.c b/firmware/drivers/rtc/rtc_rx5x348ab.c index 4899d9956..429a221b1 100644 --- a/firmware/drivers/rtc/rtc_rx5x348ab.c +++ b/firmware/drivers/rtc/rtc_rx5x348ab.c @@ -21,15 +21,32 @@ #include "spi.h" #include "rtc.h" #include - +/* Choose one of: */ +#define ADDR_READ 0x04 +#define ADDR_WRITE 0x00 +/* and one of: */ +#define ADDR_ONE 0x08 +#define ADDR_BURST 0x00 void rtc_init(void) { } - + int rtc_read_datetime(unsigned char* buf) { - char command = 0x04; /* burst read from the start of the time/date reg */ + char command = ADDR_READ|ADDR_BURST; /* burst read from the start of the time/date reg */ spi_block_transfer(SPI_target_RX5X348AB, &command, 1, buf, 7); return 1; } +int rtc_write_datetime(unsigned char* buf) +{ + char command = ADDR_WRITE|ADDR_BURST; /* burst read from the start of the time/date reg */ + char data[8]; + int i; + data[0] = command; + for (i=1;i<8;i++) + data[i] = buf[i-1]; + spi_block_transfer(SPI_target_RX5X348AB, + data, 8, NULL, 0); + return 1; +} diff --git a/firmware/export/config-mrobe500.h b/firmware/export/config-mrobe500.h index 9cd7a7c47..04f3d8340 100644 --- a/firmware/export/config-mrobe500.h +++ b/firmware/export/config-mrobe500.h @@ -84,7 +84,7 @@ #define CONFIG_CODEC SWCODEC /* define this if you have a real-time clock */ -//#define CONFIG_RTC RTC_RX5X348AB +#define CONFIG_RTC RTC_RX5X348AB /* Define this for LCD backlight available */ #define HAVE_BACKLIGHT diff --git a/firmware/target/arm/tms320dm320/spi-dm320.c b/firmware/target/arm/tms320dm320/spi-dm320.c index e9dd2e01a..f80c3884f 100644 --- a/firmware/target/arm/tms320dm320/spi-dm320.c +++ b/firmware/target/arm/tms320dm320/spi-dm320.c @@ -92,9 +92,8 @@ int spi_block_transfer(enum SPI_target target, void spi_init(void) { spinlock_init(&spi_lock); - /* Set SCLK idle level = 0 */ - IO_SERIAL0_MODE |= (1<<10); - + /* Set SCLK idle level = 1 */ + IO_SERIAL0_MODE &= ~(1<<10); /* Enable TX */ IO_SERIAL0_TX_ENABLE = 0x0001; -- 2.11.4.GIT