SAMV71-XULT: Add hooks for testing the PCF85263 RTC

This commit is contained in:
Gregory Nutt
2015-11-21 07:14:05 -06:00
parent 0ca9047488
commit abb7171a89
2 changed files with 59 additions and 9 deletions
+32 -4
View File
@@ -70,10 +70,14 @@
# include "sam_progmem.h" # include "sam_progmem.h"
#endif #endif
#ifdef HAVE_RTC_DSXXXX #if defined(HAVE_RTC_DSXXXX) || defined(HAVE_RTC_PCF85263)
# include <nuttx/clock.h> # include <nuttx/clock.h>
# include <nuttx/i2c.h> # include <nuttx/i2c.h>
#ifdef HAVE_RTC_DSXXXX
# include <nuttx/timers/ds3231.h> # include <nuttx/timers/ds3231.h>
#else
# include <nuttx/timers/pcf85263.h>
#endif
# include "sam_twihs.h" # include "sam_twihs.h"
#endif #endif
@@ -117,7 +121,7 @@ int sam_bringup(void)
#if defined(HAVE_S25FL1) || defined(HAVE_PROGMEM_CHARDEV) #if defined(HAVE_S25FL1) || defined(HAVE_PROGMEM_CHARDEV)
FAR struct mtd_dev_s *mtd; FAR struct mtd_dev_s *mtd;
#endif #endif
#ifdef HAVE_RTC_DSXXXX #if defined(HAVE_RTC_DSXXXX) || defined(HAVE_RTC_PCF85263)
FAR struct i2c_dev_s *i2c; FAR struct i2c_dev_s *i2c;
#endif #endif
#if defined(HAVE_S25FL1_CHARDEV) || defined(HAVE_PROGMEM_CHARDEV) #if defined(HAVE_S25FL1_CHARDEV) || defined(HAVE_PROGMEM_CHARDEV)
@@ -126,7 +130,32 @@ int sam_bringup(void)
#endif #endif
int ret; int ret;
#ifdef HAVE_RTC_DSXXXX #if defined(HAVE_RTC_PCF85263)
/* Get an instance of the TWIHS0 I2C interface */
i2c = up_i2cinitialize(PCF85263_TWI_BUS);
if (i2c == NULL)
{
SYSLOG("ERROR: up_i2cinitialize(%d) failed\n", PCF85263_TWI_BUS);
}
else
{
/* Use the I2C interface to initialize the PCF2863 timer */
ret = pcf85263_rtc_initialize(i2c);
if (ret < 0)
{
SYSLOG("ERROR: pcf85263_rtc_initialize() failed: %d\n", ret);
}
else
{
/* Synchronize the system time to the RTC time */
clock_synchronize();
}
}
#else /* if defined(HAVE_RTC_DSXXXX) */
/* Get an instance of the TWIHS0 I2C interface */ /* Get an instance of the TWIHS0 I2C interface */
i2c = up_i2cinitialize(DSXXXX_TWI_BUS); i2c = up_i2cinitialize(DSXXXX_TWI_BUS);
@@ -150,7 +179,6 @@ int sam_bringup(void)
clock_synchronize(); clock_synchronize();
} }
} }
#endif #endif
#ifdef HAVE_MACADDR #ifdef HAVE_MACADDR
+25 -3
View File
@@ -69,6 +69,7 @@
#define HAVE_WM8904 1 #define HAVE_WM8904 1
#define HAVE_AUDIO_NULL 1 #define HAVE_AUDIO_NULL 1
#define HAVE_RTC_DSXXXX 1 #define HAVE_RTC_DSXXXX 1
#define HAVE_RTC_PCF85263 1
/* HSMCI */ /* HSMCI */
/* Can't support MMC/SD if the card interface is not enabled */ /* Can't support MMC/SD if the card interface is not enabled */
@@ -301,16 +302,30 @@
/* DS3231/DS1307 RTC /* DS3231/DS1307 RTC
* *
* For testing purposes, I have connected a Maximum Integrated I2C RTC TWIHS0 * For testing purposes, I have connected Maximum Integrated DS1307 and NXP
* (available on either EXT or EXT2 pins 11 and 12). * PCF85263 I2C RTC TWIHS0 (available on either EXT or EXT2 pins 11 and 12).
*/ */
#if !defined(CONFIG_SAMV7_TWIHS0) || !defined(CONFIG_RTC_DSXXXX) #ifndef CONFIG_RTC_DSXXXX
# undef HAVE_RTC_DSXXXX # undef HAVE_RTC_DSXXXX
#endif #endif
#ifndef CONFIG_RTC_PCF85263
# undef HAVE_RTC_PCF85263
#endif
#ifndef CONFIG_SAMV7_TWIHS0
# undef HAVE_RTC_DSXXXX
# undef HAVE_RTC_PCF85263
#endif
#if !defined(CONFIG_RTC) || !defined(CONFIG_RTC_DATETIME) #if !defined(CONFIG_RTC) || !defined(CONFIG_RTC_DATETIME)
# undef HAVE_RTC_DSXXXX # undef HAVE_RTC_DSXXXX
# undef HAVE_RTC_PCF85263
#endif
#if defined(HAVE_RTC_DSXXXX) && defined(HAVE_RTC_PCF85263)
# undef HAVE_RTC_DSXXXX
#endif #endif
#ifdef HAVE_RTC_DSXXXX #ifdef HAVE_RTC_DSXXXX
@@ -320,6 +335,13 @@
# define DSXXXX_I2C_ADDRESS 0x68 # define DSXXXX_I2C_ADDRESS 0x68
#endif #endif
#ifdef HAVE_RTC_PCF85263
/* The PCF85263 RTC communicates on TWI0, I2C address 0x51 */
# define PCF85263_TWI_BUS 0
# define PCF85263_I2C_ADDRESS 0x51
#endif
/* SAMV71-XULT GPIO Pin Definitions *************************************************/ /* SAMV71-XULT GPIO Pin Definitions *************************************************/
/* Ethernet MAC. /* Ethernet MAC.