diff --git a/configs/same70-xplained/README.txt b/configs/same70-xplained/README.txt index 971db2afd9e..e4bc01fcabe 100644 --- a/configs/same70-xplained/README.txt +++ b/configs/same70-xplained/README.txt @@ -35,6 +35,10 @@ address 0x00000000, but trying to step through with AtmelStudio 7 results in uninterpretble behavior. Using the Segger J-Link, I get errors trying to reset and halt the board so I am unable to use that debugger either. +WARNING: This README derives heavily from the SAMV71-XULT README file and +may still contain some logic that pertains only to that board. This is a +work in progress + See also configs/samv71-xult/README.txt Serial Console diff --git a/configs/samv71-xult/src/sam_bringup.c b/configs/samv71-xult/src/sam_bringup.c index 39795bd356b..49b00ced58d 100644 --- a/configs/samv71-xult/src/sam_bringup.c +++ b/configs/samv71-xult/src/sam_bringup.c @@ -70,6 +70,13 @@ # include "sam_progmem.h" #endif +#ifdef HAVE_RTC_DSXXXX +# include +# include +# include +# include "sam_twihs.h" +#endif + #ifdef HAVE_ROMFS # include #endif @@ -110,12 +117,42 @@ int sam_bringup(void) #if defined(HAVE_S25FL1) || defined(HAVE_PROGMEM_CHARDEV) FAR struct mtd_dev_s *mtd; #endif +#ifdef HAVE_RTC_DSXXXX + FAR struct i2c_dev_s *i2c; +#endif #if defined(HAVE_S25FL1_CHARDEV) || defined(HAVE_PROGMEM_CHARDEV) char blockdev[18]; char chardev[12]; #endif int ret; +#ifdef HAVE_RTC_DSXXXX + /* Get an instance of the TWIHS0 I2C interface */ + + i2c = up_i2cinitialize(DSXXXX_TWI_BUS); + if (i2c == NULL) + { + SYSLOG("ERROR: up_i2cinitialize(%d) failed\n", DSXXXX_TWI_BUS); + } + else + { + /* Use the I2C interface to initialize the DSXXXX timer */ + + ret = dsxxxx_rtc_initialize(i2c); + if (ret < 0) + { + SYSLOG("ERROR: dsxxxx_rtc_initialize() failed: %d\n", ret); + } + else + { + /* Synchronize the system time to the RTC time */ + + clock_synchronize(); + } + } + +#endif + #ifdef HAVE_MACADDR /* Read the Ethernet MAC address from the AT24 FLASH and configure the * Ethernet driver with that address. diff --git a/configs/samv71-xult/src/samv71-xult.h b/configs/samv71-xult/src/samv71-xult.h index 2f7a11c5ece..cbbfd268277 100644 --- a/configs/samv71-xult/src/samv71-xult.h +++ b/configs/samv71-xult/src/samv71-xult.h @@ -68,6 +68,7 @@ #define HAVE_PROGMEM_CHARDEV 1 #define HAVE_WM8904 1 #define HAVE_AUDIO_NULL 1 +#define HAVE_RTC_DSXXXX 1 /* HSMCI */ /* Can't support MMC/SD if the card interface is not enabled */ @@ -298,6 +299,27 @@ # endif #endif +/* DS3231/DS1307 RTC + * + * For testing purposes, I have connected a Maximum Integrated I2C RTC TWIHS0 + * (available on either EXT or EXT2 pins 11 and 12). + */ + +#if !defined(CONFIG_SAMV7_TWIHS0) || !defined(CONFIG_RTC_DSXXXX) +# undef HAVE_RTC_DSXXXX +#endif + +#if !defined(CONFIG_RTC) || !defined(CONFIG_RTC_DATETIME) +# undef HAVE_RTC_DSXXXX +#endif + +#ifdef HAVE_RTC_DSXXXX +/* The DS3231/1307 RTC communicates on TWI0, I2C address 0x68 */ + +# define DSXXXX_TWI_BUS 0 +# define DSXXXX_I2C_ADDRESS 0x68 +#endif + /* SAMV71-XULT GPIO Pin Definitions *************************************************/ /* Ethernet MAC.