summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--firmware/drivers/rtc/rtc_rx5x348ab.c23
-rw-r--r--firmware/export/config-mrobe500.h2
-rw-r--r--firmware/target/arm/tms320dm320/spi-dm320.c5
3 files changed, 23 insertions, 7 deletions
diff --git a/firmware/drivers/rtc/rtc_rx5x348ab.c b/firmware/drivers/rtc/rtc_rx5x348ab.c
index 4899d99..429a221 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 <stdbool.h>
-
+/* 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 9cd7a7c..04f3d83 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 e9dd2e0..f80c388 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;