From 046212dc4eb99aeb253eabf9a9f7c5d04b692263 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Wed, 18 Nov 2015 18:09:06 -0600 Subject: [PATCH 1/8] Update README --- configs/same70-xplained/README.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/configs/same70-xplained/README.txt b/configs/same70-xplained/README.txt index ca8a69e035f..9c056deedb6 100644 --- a/configs/same70-xplained/README.txt +++ b/configs/same70-xplained/README.txt @@ -25,7 +25,9 @@ Contents Status/Open Issues ================== -To be provided +[To be provided] + +See also configs/samv71-xult/README.txt Serial Console ============== From fb0145d0c8693144b42fabb8001746f359e9ebfd Mon Sep 17 00:00:00 2001 From: Marwan Ragab Date: Thu, 19 Nov 2015 11:11:12 -0500 Subject: [PATCH 2/8] added unique id implementation for nucleo-f303re --- configs/nucleo-f303re/src/Makefile | 4 ++ configs/nucleo-f303re/src/stm32_uid.c | 59 +++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 configs/nucleo-f303re/src/stm32_uid.c diff --git a/configs/nucleo-f303re/src/Makefile b/configs/nucleo-f303re/src/Makefile index 04c8eac1533..7d81b2cbe1b 100644 --- a/configs/nucleo-f303re/src/Makefile +++ b/configs/nucleo-f303re/src/Makefile @@ -78,4 +78,8 @@ ifeq ($(CONFIG_TIMER),y) CSRCS += stm32_timer.c endif +ifeq ($(CONFIG_BOARDCTL_UNIQUEID),y) +CSRCS += stm32_uid.c +endif + include $(TOPDIR)/configs/Board.mk diff --git a/configs/nucleo-f303re/src/stm32_uid.c b/configs/nucleo-f303re/src/stm32_uid.c new file mode 100644 index 00000000000..ba55160cab2 --- /dev/null +++ b/configs/nucleo-f303re/src/stm32_uid.c @@ -0,0 +1,59 @@ +/************************************************************************************ + * configs/nucleo-f303re/src/stm32_uid.c + * + * Copyright (C) 2015 Marawan Ragab. All rights reserved. + * Author: Marawan Ragab + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ************************************************************************************/ + +/************************************************************************************ + * Included Files + ************************************************************************************/ +#include +#include +#include "stm32_uid.h" + +#ifndef OK +# define OK 0 +#endif +#define ERR_NULL 1 + +/************************************************************************************ + * Public Functions + ************************************************************************************/ +#if defined(CONFIG_BOARDCTL_UNIQUEID) +int board_uniqueid(uint8_t *uniqueid) +{ + if(uniqueid == 0) + return -ERR_NULL; + stm32_get_uniqueid(uniqueid); + return OK; +} +#endif From f4213873f38d7c09c9134cea88d9d950ab3f0427 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 19 Nov 2015 10:23:01 -0600 Subject: [PATCH 3/8] board_uniqueid should return a negated errno value on failure --- configs/nucleo-f303re/src/stm32_uid.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/configs/nucleo-f303re/src/stm32_uid.c b/configs/nucleo-f303re/src/stm32_uid.c index ba55160cab2..5637650d336 100644 --- a/configs/nucleo-f303re/src/stm32_uid.c +++ b/configs/nucleo-f303re/src/stm32_uid.c @@ -36,23 +36,34 @@ /************************************************************************************ * Included Files ************************************************************************************/ + #include -#include + +#include #include "stm32_uid.h" +#include + +/************************************************************************************ + * Pre-processor Definitions + ************************************************************************************/ + #ifndef OK # define OK 0 #endif -#define ERR_NULL 1 /************************************************************************************ * Public Functions ************************************************************************************/ + #if defined(CONFIG_BOARDCTL_UNIQUEID) int board_uniqueid(uint8_t *uniqueid) { - if(uniqueid == 0) - return -ERR_NULL; + if (uniqueid == 0) + { + return -EINVAL; + } + stm32_get_uniqueid(uniqueid); return OK; } From 5106a8a9ca1fa83cb45880930f10e49e9bc3407d Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 19 Nov 2015 10:25:08 -0600 Subject: [PATCH 4/8] SAME70 Xplained: Updated README --- configs/same70-xplained/README.txt | 76 +++++++++++++++--------------- 1 file changed, 39 insertions(+), 37 deletions(-) diff --git a/configs/same70-xplained/README.txt b/configs/same70-xplained/README.txt index 9c056deedb6..3b17846aaef 100644 --- a/configs/same70-xplained/README.txt +++ b/configs/same70-xplained/README.txt @@ -44,8 +44,8 @@ use either the VCOM or an external RS-232 driver. Here are some options. Pin on SAME70 Arduino Arduino SAME70 J503 PIO Name Pin Function ------ ------ ------- ------- -------- - 1 PD28 RX0 0 URXD3 - 2 PD30 TX0 1 UTXD3 + 1 PD28 D0/RX0 0 URXD3 + 2 PD30 D1/TX0 1 UTXD3 ------ ------ ------- ------- -------- In this configuration, an external RS232 driver can also be used @@ -62,47 +62,49 @@ use either the VCOM or an external RS-232 driver. Here are some options. --------- ----------- - Arduino Communications. Additional UART/USART connections are available - on the Arduino Communications connection J505: + on the Arduino Communications connection J505 and J507: - ------ ------ ------- ------- -------- - Pin on SAME70 Arduino Arduino SAME70 - J503 PIO Name Pin Function - ------ ------ ------- ------- -------- - 3 PD18 RX1 0 URXD4 - 4 PD19 TX1 0 UTXD4 - 5 PD15 RX2 0 RXD2 - 6 PD16 TX2 0 TXD2 - 7 PB0 RX3 0 RXD0 - 8 PB1 TX3 1 TXD0 - ------ ------ ------- ------- -------- + --------- ---------- -------------------------------- + Connector SAME70 Pin Description + --------- ---------- -------------------------------- + J503 1 URXD3 PD28 Standard Arduino serial (D0/RXD) + J503 2 UTXD3 PD30 Standard Arduino serial (D1/TXD) + --------- ---------- -------------------------------- + J505 3 URXD4 PD18 Arduino D19 + J505 4 UTXD4 PD19 Arduino D18 + J505 5 RXD2 PD15 Arduino D17 + J505 6 TXD2 PD16 Arduino D16 + J505 7 RXD0 PB0 Arduino D15 + J505 8 TXD0 PB1 Arduino D14 + --------- ---------- -------------------------------- + J507 27 RXD1 PA21 Arduino D46 + J507 28 TXD1 PB4 Arduino D47 + --------- ---------- -------------------------------- - SAMV7-XULT EXTn connectors. USART pins are also available the EXTn connectors. The following are labelled in the User Guide for USART functionality: - ---- -------- ------ -------- - EXT1 EXTI1 SAME70 SAME70 - Pin Name PIO Function - ---- -------- ------ -------- - 13 USART_RX PB00 RXD0 - 14 USART_TX PB01 TXD0 - - ---- -------- ------ -------- - EXT2 EXTI2 SAME70 SAME70 - Pin Name PIO Function - ---- -------- ------ -------- - 13 USART_RX PA21 RXD1 - 14 USART_TX PB04 TXD1 + SAME70 Xplained Connectors + --------- ---------- -------------------------------- + Connector SAME70 Pin Description + --------- ---------- -------------------------------- + J401 13 RXD0 PB0 EXT1 UART_RX + J401 14 TXD0 PB1 EXT1 UART_7X + --------- ---------- -------------------------------- + J402 13 RXD1 PA21 EXT2 UART_RX + J402 14 TXD1 PB4 EXT2 UART_TX + --------- ---------- -------------------------------- - VCOM. The Virtual Com Port gateway is available on USART1: - ------ -------- - SAME70 SAME70 - PIO Function - ------ -------- - PB04 TXD1 - PA21 RXD1 - ------ -------- + EDBG VCOM Interface + ---------------- --------- -------------------------- + EDBG Singal SAME70 + ---------------- --------- -------------------------- + EDBG_CDC_UART_RX TXD1 PB4 + EDBG_CDC_UART_TX RXD1 PA21 + ---------------- --------- -------------------------- Any of these options can be selected as the serial console by: @@ -1129,9 +1131,9 @@ Configuration sub-directories NOTES: - 1. The serial console is configured by default for use with and Arduino - serial shield (UART3). You will need to reconfigure if you will - to use a different U[S]ART. + 1. The serial console is configured by default for use with the EDBG VCOM + (USART1). You will need to reconfigure if you will to use a different + U[S]ART. 2. Default stack sizes are large and should really be tuned to reduce the RAM footprint: From cedec09f8f7d95dd4a752f6084725d3195bf3c03 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 19 Nov 2015 12:15:13 -0600 Subject: [PATCH 5/8] SAME70 Xplained: Update README; switch to USART1 --- configs/same70-xplained/README.txt | 10 ++++++++- configs/same70-xplained/nsh/defconfig | 32 ++++++++++++++------------- 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/configs/same70-xplained/README.txt b/configs/same70-xplained/README.txt index 3b17846aaef..971db2afd9e 100644 --- a/configs/same70-xplained/README.txt +++ b/configs/same70-xplained/README.txt @@ -25,7 +25,15 @@ Contents Status/Open Issues ================== -[To be provided] +Although this configuration is not particualarly different from the +SAMV71-XULT board, my initial attempts to debug the board have not been +successful. The code is just not behaving correctly in excuting the first +few instructions after reset. I have very early realease boards and I am +suspected some tool/board issue: It appears that I write the code +correctly to FLASH and the GPNVM is configured so that the FLASH lies at +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. See also configs/samv71-xult/README.txt diff --git a/configs/same70-xplained/nsh/defconfig b/configs/same70-xplained/nsh/defconfig index b5fbd8c6e06..40f1cc5bf3a 100644 --- a/configs/same70-xplained/nsh/defconfig +++ b/configs/same70-xplained/nsh/defconfig @@ -245,12 +245,12 @@ CONFIG_SAMV7_TWIHS0=y # CONFIG_SAMV7_UART0 is not set # CONFIG_SAMV7_UART1 is not set # CONFIG_SAMV7_UART2 is not set -CONFIG_SAMV7_UART3=y +# CONFIG_SAMV7_UART3 is not set # CONFIG_SAMV7_UART4 is not set # CONFIG_SAMV7_USBDEVHS is not set # CONFIG_SAMV7_USBHOSTHS is not set # CONFIG_SAMV7_USART0 is not set -# CONFIG_SAMV7_USART1 is not set +CONFIG_SAMV7_USART1=y # CONFIG_SAMV7_USART2 is not set # CONFIG_SAMV7_WDT0 is not set # CONFIG_SAMV7_WDT1 is not set @@ -583,7 +583,7 @@ CONFIG_SERIAL=y # CONFIG_ARCH_HAVE_UART0 is not set # CONFIG_ARCH_HAVE_UART1 is not set # CONFIG_ARCH_HAVE_UART2 is not set -CONFIG_ARCH_HAVE_UART3=y +# CONFIG_ARCH_HAVE_UART3 is not set # CONFIG_ARCH_HAVE_UART4 is not set # CONFIG_ARCH_HAVE_UART5 is not set # CONFIG_ARCH_HAVE_UART6 is not set @@ -592,7 +592,7 @@ CONFIG_ARCH_HAVE_UART3=y # CONFIG_ARCH_HAVE_SCI0 is not set # CONFIG_ARCH_HAVE_SCI1 is not set # CONFIG_ARCH_HAVE_USART0 is not set -# CONFIG_ARCH_HAVE_USART1 is not set +CONFIG_ARCH_HAVE_USART1=y # CONFIG_ARCH_HAVE_USART2 is not set # CONFIG_ARCH_HAVE_USART3 is not set # CONFIG_ARCH_HAVE_USART4 is not set @@ -605,28 +605,30 @@ CONFIG_ARCH_HAVE_UART3=y # # USART Configuration # +CONFIG_USART1_ISUART=y CONFIG_MCU_SERIAL=y CONFIG_STANDARD_SERIAL=y # CONFIG_SERIAL_IFLOWCONTROL is not set # CONFIG_SERIAL_OFLOWCONTROL is not set # CONFIG_SERIAL_DMA is not set CONFIG_ARCH_HAVE_SERIAL_TERMIOS=y -CONFIG_UART3_SERIAL_CONSOLE=y +CONFIG_USART1_SERIAL_CONSOLE=y +# CONFIG_UART3_SERIAL_CONSOLE is not set # CONFIG_OTHER_SERIAL_CONSOLE is not set # CONFIG_NO_SERIAL_CONSOLE is not set # -# UART3 Configuration +# USART1 Configuration # -CONFIG_UART3_RXBUFSIZE=256 -CONFIG_UART3_TXBUFSIZE=256 -CONFIG_UART3_BAUD=115200 -CONFIG_UART3_BITS=8 -CONFIG_UART3_PARITY=0 -CONFIG_UART3_2STOP=0 -# CONFIG_UART3_IFLOWCONTROL is not set -# CONFIG_UART3_OFLOWCONTROL is not set -# CONFIG_UART3_DMA is not set +CONFIG_USART1_RXBUFSIZE=256 +CONFIG_USART1_TXBUFSIZE=256 +CONFIG_USART1_BAUD=115200 +CONFIG_USART1_BITS=8 +CONFIG_USART1_PARITY=0 +CONFIG_USART1_2STOP=0 +# CONFIG_USART1_IFLOWCONTROL is not set +# CONFIG_USART1_OFLOWCONTROL is not set +# CONFIG_USART1_DMA is not set # CONFIG_USBDEV is not set # CONFIG_USBHOST is not set # CONFIG_WIRELESS is not set From e9abfb0de8da70f4e66e0c9f5f90f48b683e3365 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 19 Nov 2015 14:52:52 -0600 Subject: [PATCH 6/8] SAMV71-XULT: Add support for an external I2C RTC --- configs/same70-xplained/README.txt | 4 +++ configs/samv71-xult/src/sam_bringup.c | 37 +++++++++++++++++++++++++++ configs/samv71-xult/src/samv71-xult.h | 22 ++++++++++++++++ 3 files changed, 63 insertions(+) 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. From 0ca9047488600a813259c1ed5845fe18318774f7 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 19 Nov 2015 17:16:11 -0600 Subject: [PATCH 7/8] SAME70 Xplained: Update some PHY pin definitions --- configs/same70-xplained/README.txt | 51 +++++++++---------- configs/same70-xplained/src/same70-xplained.h | 39 +++++++------- 2 files changed, 42 insertions(+), 48 deletions(-) diff --git a/configs/same70-xplained/README.txt b/configs/same70-xplained/README.txt index e4bc01fcabe..ee314897525 100644 --- a/configs/same70-xplained/README.txt +++ b/configs/same70-xplained/README.txt @@ -302,15 +302,13 @@ contains a MAC address for use with the Ethernet interface. Connectivity: - ------ -------- -------- ------------------------------------------ - SAME70 SAME70 I2C Shared - Pin Function Function Functionality - ------ -------- -------- ------------------------------------------ - PA03 TWID0 SDA EXT1, EXT2, EDBG I2C, LCD, Camera, and - Shield - PA04 TWICK0 SCL EXT1, EXT2, EDBG I2C, LCD, Camera, and, - Shield - ------ -------- -------- ------------------------------------------ + ------ -------- -------- + SAME70 SAME70 I2C + Pin Function Function + ------ -------- -------- + PA03 TWID0 SDA + PA04 TWICK0 SCL + ------ -------- -------- I2C address: @@ -345,27 +343,26 @@ The configuration data device will appear at /dev/config. Networking ========== -KSZ8061RNBVA Connections +KSZ8081RNACA Connections ------------------------ - ------ --------- --------- -------------------------- - SAME70 SAME70 Ethernet Shared functionality - Pin Function Function - ------ --------- --------- -------------------------- - PD00 GTXCK REF_CLK Shield - PD01 GTXEN TXEN - PD02 GTX0 TXD0 - PD03 GTX1 TXD1 - PD04 GRXDV CRS_DV Trace - PD05 GRX0 RXD0 Trace - PD06 GRX1 RXD1 Trace - PD07 GRXER RXER Trace - PD08 GMDC MDC Trace - PD09 GMDIO MDIO - PA19 GPIO INTERRUPT EXT1, Shield - PA29 GPIO SIGDET + ------ --------- --------- + SAME70 SAME70 Ethernet + Pin Function Functio + ------ --------- --------- + PD0 GTXCK REF_CLK + PD1 GTXEN TXEN + PD2 GTX0 TXD0 + PD3 GTX1 TXD1 + PD4 GRXDV CRS_DV + PD5 GRX0 RXD0 + PD6 GRX1 RXD1 + PD7 GRXER RXER + PD8 GMDC MDC + PD9 GMDIO MDIO + PA14 GPIO INTERRUPT PC10 GPIO RESET - ------ --------- --------- -------------------------- + ------ --------- --------- Selecting the GMAC peripheral ----------------------------- diff --git a/configs/same70-xplained/src/same70-xplained.h b/configs/same70-xplained/src/same70-xplained.h index f65f501a14a..cffe2159ec8 100644 --- a/configs/same70-xplained/src/same70-xplained.h +++ b/configs/same70-xplained/src/same70-xplained.h @@ -194,33 +194,30 @@ /* Ethernet MAC. * - * KSZ8061RNBVA Connections + * KSZ8081RNACA Connections * ------------------------ * - * ------ --------- --------- -------------------------- - * SAME70 SAME70 Ethernet Shared functionality - * Pin Function Function - * ------ --------- --------- -------------------------- - * PD00 GTXCK REF_CLK Shield - * PD01 GTXEN TXEN - * PD02 GTX0 TXD0 - * PD03 GTX1 TXD1 - * PD04 GRXDV CRS_DV Trace - * PD05 GRX0 RXD0 Trace - * PD06 GRX1 RXD1 Trace - * PD07 GRXER RXER Trace - * PD08 GMDC MDC Trace - * PD09 GMDIO MDIO - * PA19 GPIO INTERRUPT EXT1, Shield - * PA29 GPIO SIGDET + * ------ --------- --------- + * SAME70 SAME70 Ethernet + * Pin Function Functio + * ------ --------- --------- + * PD0 GTXCK REF_CLK + * PD1 GTXEN TXEN + * PD2 GTX0 TXD0 + * PD3 GTX1 TXD1 + * PD4 GRXDV CRS_DV + * PD5 GRX0 RXD0 + * PD6 GRX1 RXD1 + * PD7 GRXER RXER + * PD8 GMDC MDC + * PD9 GMDIO MDIO + * PA14 GPIO INTERRUPT * PC10 GPIO RESET - * ------ --------- --------- -------------------------- + * ------ --------- --------- */ #define GPIO_EMAC0_INT (GPIO_INPUT | GPIO_CFG_PULLUP | GPIO_CFG_DEGLITCH | \ - GPIO_INT_FALLING | GPIO_PORT_PIOA | GPIO_PIN19) -#define GPIO_EMAC0_SIGDET (GPIO_INPUT | GPIO_CFG_DEFAULT | \ - GPIO_PORT_PIOA | GPIO_PIN29) + GPIO_INT_FALLING | GPIO_PORT_PIOA | GPIO_PIN14) #define GPIO_EMAC0_RESET (GPIO_OUTPUT | GPIO_CFG_PULLUP | GPIO_OUTPUT_SET | \ GPIO_PORT_PIOC | GPIO_PIN10) From abb7171a8916868ca034cd27bbebc79231a8d487 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sat, 21 Nov 2015 07:14:05 -0600 Subject: [PATCH 8/8] SAMV71-XULT: Add hooks for testing the PCF85263 RTC --- configs/samv71-xult/src/sam_bringup.c | 36 ++++++++++++++++++++++++--- configs/samv71-xult/src/samv71-xult.h | 32 ++++++++++++++++++++---- 2 files changed, 59 insertions(+), 9 deletions(-) diff --git a/configs/samv71-xult/src/sam_bringup.c b/configs/samv71-xult/src/sam_bringup.c index 49b00ced58d..760ee92bd61 100644 --- a/configs/samv71-xult/src/sam_bringup.c +++ b/configs/samv71-xult/src/sam_bringup.c @@ -70,10 +70,14 @@ # include "sam_progmem.h" #endif -#ifdef HAVE_RTC_DSXXXX +#if defined(HAVE_RTC_DSXXXX) || defined(HAVE_RTC_PCF85263) # include # include +#ifdef HAVE_RTC_DSXXXX # include +#else +# include +#endif # include "sam_twihs.h" #endif @@ -117,7 +121,7 @@ int sam_bringup(void) #if defined(HAVE_S25FL1) || defined(HAVE_PROGMEM_CHARDEV) FAR struct mtd_dev_s *mtd; #endif -#ifdef HAVE_RTC_DSXXXX +#if defined(HAVE_RTC_DSXXXX) || defined(HAVE_RTC_PCF85263) FAR struct i2c_dev_s *i2c; #endif #if defined(HAVE_S25FL1_CHARDEV) || defined(HAVE_PROGMEM_CHARDEV) @@ -126,7 +130,32 @@ int sam_bringup(void) #endif 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 */ i2c = up_i2cinitialize(DSXXXX_TWI_BUS); @@ -150,7 +179,6 @@ int sam_bringup(void) clock_synchronize(); } } - #endif #ifdef HAVE_MACADDR diff --git a/configs/samv71-xult/src/samv71-xult.h b/configs/samv71-xult/src/samv71-xult.h index cbbfd268277..060bc458ee3 100644 --- a/configs/samv71-xult/src/samv71-xult.h +++ b/configs/samv71-xult/src/samv71-xult.h @@ -69,6 +69,7 @@ #define HAVE_WM8904 1 #define HAVE_AUDIO_NULL 1 #define HAVE_RTC_DSXXXX 1 +#define HAVE_RTC_PCF85263 1 /* HSMCI */ /* Can't support MMC/SD if the card interface is not enabled */ @@ -301,23 +302,44 @@ /* 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). + * For testing purposes, I have connected Maximum Integrated DS1307 and NXP + * 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 #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) # undef HAVE_RTC_DSXXXX +# undef HAVE_RTC_PCF85263 +#endif + +#if defined(HAVE_RTC_DSXXXX) && defined(HAVE_RTC_PCF85263) +# 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 +# define DSXXXX_TWI_BUS 0 +# define DSXXXX_I2C_ADDRESS 0x68 +#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 *************************************************/