mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 00:14:22 +08:00
SAMA5D4-EK: NSH configuration now has TWI0 enabled and supports the I2C tool
This commit is contained in:
@@ -420,6 +420,7 @@
|
|||||||
#define PMC_PCR_CMD (1 << 12) /* Bit 12: Command */
|
#define PMC_PCR_CMD (1 << 12) /* Bit 12: Command */
|
||||||
|
|
||||||
#ifdef ATSAMA5D3
|
#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_SHIFT (16) /* Bits 16-17: Divisor Value */
|
||||||
# define PMC_PCR_DIV_MASK (3 << PMC_PCR_DIV_SHIFT)
|
# define PMC_PCR_DIV_MASK (3 << PMC_PCR_DIV_SHIFT)
|
||||||
# define PMC_PCR_DIV1 (0 << PMC_PCR_DIV_SHIFT) /* Peripheral clock is MCK */
|
# define PMC_PCR_DIV1 (0 << PMC_PCR_DIV_SHIFT) /* Peripheral clock is MCK */
|
||||||
|
|||||||
@@ -1167,8 +1167,9 @@ static void twi_hw_initialize(struct twi_dev_s *priv, unsigned int pid,
|
|||||||
/* Determine the maximum valid frequency setting */
|
/* Determine the maximum valid frequency setting */
|
||||||
|
|
||||||
mck = BOARD_MCK_FREQUENCY;
|
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)
|
if (mck <= TWI_MAX_FREQUENCY)
|
||||||
{
|
{
|
||||||
priv->frequency = mck;
|
priv->frequency = mck;
|
||||||
@@ -1190,6 +1191,14 @@ static void twi_hw_initialize(struct twi_dev_s *priv, unsigned int pid,
|
|||||||
regval = PMC_PCR_DIV8;
|
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 */
|
/* Set the TWI peripheral input clock to the maximum, valid frequency */
|
||||||
|
|
||||||
regval |= PMC_PCR_PID(pid) | PMC_PCR_CMD | PMC_PCR_EN;
|
regval |= PMC_PCR_PID(pid) | PMC_PCR_CMD | PMC_PCR_EN;
|
||||||
|
|||||||
Reference in New Issue
Block a user