Fix LPC178x I2C mode GPIO configuration

This commit is contained in:
Gregory Nutt 2013-04-06 08:04:17 -06:00
parent c6790e79de
commit 11b7df0794
3 changed files with 15 additions and 12 deletions

View File

@ -348,17 +348,17 @@
/* Slew rate modes */
#define IOCON_SLEWMODE_NORMAL (0 << IOCON_SLEW_SHIFT)
#define IOCON_SLEWMODE_FAST (1 << IOCON_SLEW_SHIFT)
#define IOCON_SLEWMODE_NORMAL (0 << IOCON_SLEW_SHIFT)
#define IOCON_SLEWMODE_FAST (1 << IOCON_SLEW_SHIFT)
/* I2C modes */
#define IOCON_I2CMODE_SHIFT (IOCON_I2CHS_SHIFT)
#define IOCON_I2CMODE_MASK (3 << IOCON_I2CMODE_SHIFT)
#define IOCON_I2CMODE_FAST (0 << IOCON_I2CMODE_SHIFT)
#define IOCON_I2CMODE_FASTPLUS (1 << IOCON_I2CMODE_SHIFT)/* */
#define IOCON_I2CMODE_HIOPENDRAIN (2 << IOCON_I2CMODE_SHIFT)/* */
#define IOCON_I2CMODE_OPENDRAIN (3 << IOCON_I2CMODE_SHIFT)/* */
#define IOCON_I2CMODE_SHIFT (IOCON_I2CHS_SHIFT)
#define IOCON_I2CMODE_MASK (3 << IOCON_I2CMODE_SHIFT)
# define IOCON_I2CMODE_FAST (0 << IOCON_I2CMODE_SHIFT)
# define IOCON_I2CMODE_FASTPLUS (1 << IOCON_I2CMODE_SHIFT)/* */
# define IOCON_I2CMODE_HIOPENDRAIN (2 << IOCON_I2CMODE_SHIFT)/* */
# define IOCON_I2CMODE_OPENDRAIN (3 << IOCON_I2CMODE_SHIFT)/* */
/************************************************************************************
* Public Types

View File

@ -803,9 +803,9 @@ static int lpc17_configalternate(lpc17_pinset_t cfgset, unsigned int port,
if ((cfgset & (GPIO_I2CHS | GPIO_HIDRIVE)) != 0)
{
/* WARNING: Using literal values (14) is a maintenance problem */
/* Isolate the I2C mode bits */
i2cmode = ((cfgset & (GPIO_I2CHS | GPIO_HIDRIVE)) >> 14);
i2cmode = ((cfgset & GPIO_I2CMODE_MASK) >> GPIO_I2CMODE_SHIFT);
/* Set I2C Modes */

View File

@ -67,8 +67,11 @@
# define GPIO_ADMODE (1 << 19) /* Bit 19: A/D Modes: 0-Analog, 1-Digital */
# define GPIO_FILTER (1 << 20) /* Bit 20: Filter: 0-Off, 1-ON */
# define GPIO_DACEN (1 << 21) /* Bit 21: DAC: 0-Disabled, 1-Enabled, P0:26 only */
# define GPIO_I2CHS (1 << 22) /* Bit 22: Filter and Rate Control: 0-Enabled, 1-Disabled */
# define GPIO_HIDRIVE (1 << 23) /* Bit 23: Current Sink: 0-4mA, 1-20mA P5:2 and P5:3 only,*/
# define GPIO_I2CMODE_SHIFT (22) /* Bits 22-23: I2C mode */
# define GPIO_I2CMODE_MASK (3 << GPIO_I2CMODE_SHIFT)
# define GPIO_I2CHS (1 << 22) /* Bit 22: Filter and Rate Control: 0-Enabled, 1-Disabled */
# define GPIO_HIDRIVE (1 << 23) /* Bit 23: Current Sink: 0-4mA, 1-20mA P5:2 and P5:3 only,*/
/* Pin Function bits: FFFF
* Only meaningful when the GPIO function is GPIO_PIN