summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--nuttx/arch/arm/src/sama5/chip/sam_pmc.h1
-rw-r--r--nuttx/arch/arm/src/sama5/sam_twi.c11
-rw-r--r--nuttx/configs/sama5d4-ek/README.txt43
-rw-r--r--nuttx/configs/sama5d4-ek/nsh/defconfig21
4 files changed, 54 insertions, 22 deletions
diff --git a/nuttx/arch/arm/src/sama5/chip/sam_pmc.h b/nuttx/arch/arm/src/sama5/chip/sam_pmc.h
index feb796d7f..449abc489 100644
--- a/nuttx/arch/arm/src/sama5/chip/sam_pmc.h
+++ b/nuttx/arch/arm/src/sama5/chip/sam_pmc.h
@@ -420,6 +420,7 @@
#define PMC_PCR_CMD (1 << 12) /* Bit 12: Command */
#ifdef ATSAMA5D3
+# define SAMA5_HAVE_PMC_PCR 1 /* Supports conditional compilation */
# define PMC_PCR_DIV_SHIFT (16) /* Bits 16-17: Divisor Value */
# define PMC_PCR_DIV_MASK (3 << PMC_PCR_DIV_SHIFT)
# define PMC_PCR_DIV1 (0 << PMC_PCR_DIV_SHIFT) /* Peripheral clock is MCK */
diff --git a/nuttx/arch/arm/src/sama5/sam_twi.c b/nuttx/arch/arm/src/sama5/sam_twi.c
index a2899729a..9d3e2f72c 100644
--- a/nuttx/arch/arm/src/sama5/sam_twi.c
+++ b/nuttx/arch/arm/src/sama5/sam_twi.c
@@ -1167,8 +1167,9 @@ static void twi_hw_initialize(struct twi_dev_s *priv, unsigned int pid,
/* Determine the maximum valid frequency setting */
mck = BOARD_MCK_FREQUENCY;
- DEBUGASSERT((mck >> 3) <= TWI_MAX_FREQUENCY);
+#ifdef SAMA5_HAVE_PMC_PCR_DIV
+ DEBUGASSERT((mck >> 3) <= TWI_MAX_FREQUENCY);
if (mck <= TWI_MAX_FREQUENCY)
{
priv->frequency = mck;
@@ -1190,6 +1191,14 @@ static void twi_hw_initialize(struct twi_dev_s *priv, unsigned int pid,
regval = PMC_PCR_DIV8;
}
+#else
+ /* No DIV field in the PCR register */
+
+ priv->frequency = mck;
+ regval = 0;
+
+#endif /* SAMA5_HAVE_PMC_PCR_DIV */
+
/* Set the TWI peripheral input clock to the maximum, valid frequency */
regval |= PMC_PCR_PID(pid) | PMC_PCR_CMD | PMC_PCR_EN;
diff --git a/nuttx/configs/sama5d4-ek/README.txt b/nuttx/configs/sama5d4-ek/README.txt
index ce3c469f7..7eeaa4563 100644
--- a/nuttx/configs/sama5d4-ek/README.txt
+++ b/nuttx/configs/sama5d4-ek/README.txt
@@ -2318,9 +2318,9 @@ I2C Tool
CONFIG_SAMA5_TWI2=y : Enable TWI2
System Type -> TWI device driver options
- SAMA5_TWI0_FREQUENCY=100000 : Select a TWI0 frequency
- SAMA5_TWI1_FREQUENCY=100000 : Select a TWI1 frequency
- SAMA5_TWI2_FREQUENCY=100000 : Select a TWI2 frequency
+ SAMA5_TWI0_FREQUENCY=100000 : Select a TWI0 frequency (default)
+ SAMA5_TWI1_FREQUENCY=100000 : Select a TWI1 frequency (default)
+ SAMA5_TWI2_FREQUENCY=100000 : Select a TWI2 frequency (default)
Device Drivers -> I2C Driver Support
CONFIG_I2C=y : Enable I2C support
@@ -3286,6 +3286,9 @@ Configurations
CONFIG_DEV_RANDOM=y : Enables /dev/random
6. This configuration has support for NSH built-in applications enabled.
+ Only one built-in application is included by default, however: The
+ I2C Tool. See the section above entitle "I2C Tool" and the note with
+ regar to I2C below.
7. This configuration has support for the FAT, ROMFS, and PROCFS file
systems built in.
@@ -3318,7 +3321,7 @@ Configurations
`- init.d/
`- rcS : Start-up script
- (There will, of course, be other devices uner /dev include /dev/console,
+ (There will, of course, be other devices under /dev including /dev/console,
/dev/null, /dev/zero, /dev/random, etc.).
Relevant configuration options include:
@@ -3360,20 +3363,20 @@ Configurations
| `- ram1 : RAM disk block driver
|- etc/
| `- init.d/
- `- rcS : Start-up script
+ | `- rcS : Start-up script
|- proc/
| |- 0/ : Information about Task ID 0
- | | |- cmdline
- | | |- stack
- | | |- status
- | | `- group/
- | | |- fd
- | | `- status
+ | | |- cmdline : Command line used to start the task
+ | | |- stack : Stack allocation
+ | | |- status : Current task status
+ | | `- group/ : Information about the task group
+ | | |- fd : File descriptors open in the group
+ | | `- status : Status of the group
| |- 1/ : Information about Task ID 1
| | `- ... : Same psuedo-directories as for Task ID 0
| |- ... : ...
| |- n/ : Information about Task ID n
- | | `- ...
+ | | `- ... : Same psuedo-directories as for Task ID 0
| |- uptime : Processor uptime
`- tmp/
@@ -3465,23 +3468,25 @@ Configurations
See the "kludge" for EMAC that is documented in the To-Do list at
the end of this README file.
- 12. The SAMA5D4-EK includes for an AT25 serial DataFlash. That support is
+ 12. I2C Tool. This configuration enables TWI0 (only) as an I2C master
+ device. This configuration also supports the I2C tool at
+ apps/system/i2c that can be used to peek and poke I2C devices on the
+ TIW0 bus. See the discussion above under "I2C Tool" for detailed
+ configuration settings.
+
+ 13. The SAMA5D4-EK includes for an AT25 serial DataFlash. That support is
NOT enabled in this configuration. Support for that serial FLASH can
be enabled by modifying the NuttX configuration as described above in
the paragraph entitled "AT25 Serial FLASH".
- 13. Support the USB low-, high- and full-speed OHCI host driver can be
+ 14. Support the USB low-, high- and full-speed OHCI host driver can be
enabled by changing the NuttX configuration file as described in the
section entitled "USB High-Speed Host" above.
- 14. Support the USB high-speed USB device driver (UDPHS) can be enabled
+ 15. Support the USB high-speed USB device driver (UDPHS) can be enabled
by changing the NuttX configuration file as described above in the
section entitled "USB High-Speed Device."
- 15. I2C Tool. NuttX supports an I2C tool at apps/system/i2c that can be
- used to peek and poke I2C devices. See the discussion above under
- "I2C Tool" for detailed configuration settings.
-
16. This example can be configured to exercise the watchdog timer test
(apps/examples/watchdog). See the detailed configuration settings in
the section entitled "Watchdog Timer" above.
diff --git a/nuttx/configs/sama5d4-ek/nsh/defconfig b/nuttx/configs/sama5d4-ek/nsh/defconfig
index a15fe9f1d..d865a51cd 100644
--- a/nuttx/configs/sama5d4-ek/nsh/defconfig
+++ b/nuttx/configs/sama5d4-ek/nsh/defconfig
@@ -186,7 +186,7 @@ CONFIG_SAMA5_HSMC=y
# CONFIG_SAMA5_USART2 is not set
CONFIG_SAMA5_USART3=y
CONFIG_SAMA5_USART4=y
-# CONFIG_SAMA5_TWI0 is not set
+CONFIG_SAMA5_TWI0=y
# CONFIG_SAMA5_TWI1 is not set
# CONFIG_SAMA5_TWI2 is not set
# CONFIG_SAMA5_TWI3 is not set
@@ -250,6 +250,11 @@ CONFIG_SAMA5_EMAC0_PHYSR_100FD=0x6
CONFIG_SAMA5_EMAC0_ISETH0=y
#
+# TWI device driver options
+#
+CONFIG_SAMA5_TWI0_FREQUENCY=100000
+
+#
# HSMCI device driver options
#
CONFIG_SAMA5_HSMCI0_XDMAC1=y
@@ -452,7 +457,12 @@ CONFIG_DEV_RANDOM=y
# CONFIG_ARCH_HAVE_PWM_PULSECOUNT is not set
# CONFIG_PWM is not set
# CONFIG_ARCH_HAVE_I2CRESET is not set
-# CONFIG_I2C is not set
+CONFIG_I2C=y
+# CONFIG_I2C_SLAVE is not set
+CONFIG_I2C_TRANSFER=y
+CONFIG_I2C_WRITEREAD=y
+# CONFIG_I2C_POLLED is not set
+# CONFIG_I2C_TRACE is not set
# CONFIG_SPI is not set
# CONFIG_I2S is not set
CONFIG_RTC=y
@@ -1065,6 +1075,13 @@ CONFIG_NSH_MAX_ROUNDTRIP=20
#
# I2C tool
#
+CONFIG_SYSTEM_I2CTOOL=y
+CONFIG_I2CTOOL_MINBUS=0
+CONFIG_I2CTOOL_MAXBUS=0
+CONFIG_I2CTOOL_MINADDR=0x03
+CONFIG_I2CTOOL_MAXADDR=0x77
+CONFIG_I2CTOOL_MAXREGADDR=0xff
+CONFIG_I2CTOOL_DEFFREQ=100000
#
# INI File Parser