diff options
Diffstat (limited to 'nuttx/arch/arm/src/lm/lm_gpio.h')
-rw-r--r-- | nuttx/arch/arm/src/lm/lm_gpio.h | 127 |
1 files changed, 80 insertions, 47 deletions
diff --git a/nuttx/arch/arm/src/lm/lm_gpio.h b/nuttx/arch/arm/src/lm/lm_gpio.h index 5938b7891..6aa847e07 100644 --- a/nuttx/arch/arm/src/lm/lm_gpio.h +++ b/nuttx/arch/arm/src/lm/lm_gpio.h @@ -56,87 +56,120 @@ /* Bit-encoded input to lm_configgpio() *********************************************/ /* Encoding: - * FFFS SPPP IIIn nnnn nnnn nnnn VPPP PBBB * - * These bits set the primary function of the pin: - * FFFn nnnn nnnn nnnn nnnn nnnn nnnn nnnn + * LM3S: FFFS SPPP III. .... .... .... VPPP PBBB + * LM4F: FFFS SPPP III. AAAA .... .... VPPP PBBB + * + * TODO: The LM4F also supports configuration of pins to trigger ADC and/or uDMA. + * That configuratin is not addressed in this this encoding. + */ + +/* These bits set the primary function of the pin: + * FFFn .... .... .... .... .... .... .... */ #define GPIO_FUNC_SHIFT 29 /* Bit 31-29: GPIO function */ #define GPIO_FUNC_MASK (7 << GPIO_FUNC_SHIFT) /* (See table 9-1 in data sheet) */ -#define GPIO_FUNC_INPUT (0 << GPIO_FUNC_SHIFT) /* Digital GPIO input */ -#define GPIO_FUNC_OUTPUT (1 << GPIO_FUNC_SHIFT) /* Digital GPIO output */ -#define GPIO_FUNC_ODINPUT (2 << GPIO_FUNC_SHIFT) /* Open-drain GPIO input */ -#define GPIO_FUNC_ODOUTPUT (3 << GPIO_FUNC_SHIFT) /* Open-drain GPIO output */ -#define GPIO_FUNC_PFODIO (4 << GPIO_FUNC_SHIFT) /* Open-drain input/output (I2C) */ -#define GPIO_FUNC_PFINPUT (5 << GPIO_FUNC_SHIFT) /* Digital input (Timer, CCP) */ -#define GPIO_FUNC_PFOUTPUT (5 << GPIO_FUNC_SHIFT) /* Digital output (Timer, PWM, Comparator) */ -#define GPIO_FUNC_PFIO (5 << GPIO_FUNC_SHIFT) /* Digital input/output (SSI, UART) */ -#define GPIO_FUNC_ANINPUT (6 << GPIO_FUNC_SHIFT) /* Analog input (Comparator) */ -#define GPIO_FUNC_INTERRUPT (7 << GPIO_FUNC_SHIFT) /* Interrupt function */ -#define GPIO_FUNC_MAX GPIO_FUNC_INTERRUPT +# define GPIO_FUNC_INPUT (0 << GPIO_FUNC_SHIFT) /* Digital GPIO input */ +# define GPIO_FUNC_OUTPUT (1 << GPIO_FUNC_SHIFT) /* Digital GPIO output */ +# define GPIO_FUNC_ODINPUT (2 << GPIO_FUNC_SHIFT) /* Open-drain GPIO input */ +# define GPIO_FUNC_ODOUTPUT (3 << GPIO_FUNC_SHIFT) /* Open-drain GPIO output */ +# define GPIO_FUNC_PFODIO (4 << GPIO_FUNC_SHIFT) /* Open-drain input/output (I2C) */ +# define GPIO_FUNC_PFINPUT (5 << GPIO_FUNC_SHIFT) /* Digital input (Timer, CCP) */ +# define GPIO_FUNC_PFOUTPUT (5 << GPIO_FUNC_SHIFT) /* Digital output (Timer, PWM, Comparator) */ +# define GPIO_FUNC_PFIO (5 << GPIO_FUNC_SHIFT) /* Digital input/output (SSI, UART) */ +# define GPIO_FUNC_ANINPUT (6 << GPIO_FUNC_SHIFT) /* Analog input (ADC, Comparator) */ +# define GPIO_FUNC_ANIO (6 << GPIO_FUNC_SHIFT) /* REVISIT: Analog input/output (USB) */ +# define GPIO_FUNC_INTERRUPT (7 << GPIO_FUNC_SHIFT) /* Interrupt function */ +# define GPIO_FUNC_MAX GPIO_FUNC_INTERRUPT /* That primary may be modified by the following options - * nnnS SPPP nnnn nnnn nnnn nnnn nnnn nnnn + * ...S SPPP .... .... .... .... .... .... */ #define GPIO_STRENGTH_SHIFT 27 /* Bits 28-27: Pad drive strength */ #define GPIO_STRENGTH_MASK (3 << GPIO_STRENGTH_SHIFT) -#define GPIO_STRENGTH_2MA (0 << GPIO_STRENGTH_SHIFT) /* 2mA pad drive strength */ -#define GPIO_STRENGTH_4MA (1 << GPIO_STRENGTH_SHIFT) /* 4mA pad drive strength */ -#define GPIO_STRENGTH_8MA (2 << GPIO_STRENGTH_SHIFT) /* 8mA pad drive strength */ -#define GPIO_STRENGTH_8MASC (3 << GPIO_STRENGTH_SHIFT) /* 8mA Pad drive with slew rate control */ -#define GPIO_STRENGTH_MAX GPIO_STRENGTH_8MASC +# define GPIO_STRENGTH_2MA (0 << GPIO_STRENGTH_SHIFT) /* 2mA pad drive strength */ +# define GPIO_STRENGTH_4MA (1 << GPIO_STRENGTH_SHIFT) /* 4mA pad drive strength */ +# define GPIO_STRENGTH_8MA (2 << GPIO_STRENGTH_SHIFT) /* 8mA pad drive strength */ +# define GPIO_STRENGTH_8MASC (3 << GPIO_STRENGTH_SHIFT) /* 8mA Pad drive with slew rate control */ +# define GPIO_STRENGTH_MAX GPIO_STRENGTH_8MASC #define GPIO_PADTYPE_SHIFT 24 /* Bits 26-24: Pad type */ #define GPIO_PADTYPE_MASK (7 << GPIO_PADTYPE_SHIFT) -#define GPIO_PADTYPE_STD (0 << GPIO_PADTYPE_SHIFT) /* Push-pull */ -#define GPIO_PADTYPE_STDWPU (1 << GPIO_PADTYPE_SHIFT) /* Push-pull with weak pull-up */ -#define GPIO_PADTYPE_STDWPD (2 << GPIO_PADTYPE_SHIFT) /* Push-pull with weak pull-down */ -#define GPIO_PADTYPE_OD (3 << GPIO_PADTYPE_SHIFT) /* Open-drain */ -#define GPIO_PADTYPE_ODWPU (4 << GPIO_PADTYPE_SHIFT) /* Open-drain with weak pull-up */ -#define GPIO_PADTYPE_ODWPD (5 << GPIO_PADTYPE_SHIFT) /* Open-drain with weak pull-down */ -#define GPIO_PADTYPE_ANALOG (6 << GPIO_PADTYPE_SHIFT) /* Analog comparator */ +# define GPIO_PADTYPE_STD (0 << GPIO_PADTYPE_SHIFT) /* Push-pull */ +# define GPIO_PADTYPE_STDWPU (1 << GPIO_PADTYPE_SHIFT) /* Push-pull with weak pull-up */ +# define GPIO_PADTYPE_STDWPD (2 << GPIO_PADTYPE_SHIFT) /* Push-pull with weak pull-down */ +# define GPIO_PADTYPE_OD (3 << GPIO_PADTYPE_SHIFT) /* Open-drain */ +# define GPIO_PADTYPE_ODWPU (4 << GPIO_PADTYPE_SHIFT) /* Open-drain with weak pull-up */ +# define GPIO_PADTYPE_ODWPD (5 << GPIO_PADTYPE_SHIFT) /* Open-drain with weak pull-down */ +# define GPIO_PADTYPE_ANALOG (6 << GPIO_PADTYPE_SHIFT) /* Analog comparator */ /* If the pin is an interrupt, then the following options apply - * nnnn nnnn IIIn nnnn nnnn nnnn nnnn nnnn + * .... .... III. .... .... .... .... .... */ #define GPIO_INT_SHIFT 21 /* Bits 23-21: Interrupt type */ #define GPIO_INT_MASK (7 << GPIO_INT_SHIFT) -#define GPIO_INT_FALLINGEDGE (0 << GPIO_INT_SHIFT) /* Interrupt on falling edge */ -#define GPIO_INT_RISINGEDGE (1 << GPIO_INT_SHIFT) /* Interrupt on rising edge */ -#define GPIO_INT_BOTHEDGES (2 << GPIO_INT_SHIFT) /* Interrupt on both edges */ -#define GPIO_INT_LOWLEVEL (3 << GPIO_INT_SHIFT) /* Interrupt on low level */ -#define GPIO_INT_HIGHLEVEL (4 << GPIO_INT_SHIFT) /* Interrupt on high level */ +# define GPIO_INT_FALLINGEDGE (0 << GPIO_INT_SHIFT) /* Interrupt on falling edge */ +# define GPIO_INT_RISINGEDGE (1 << GPIO_INT_SHIFT) /* Interrupt on rising edge */ +# define GPIO_INT_BOTHEDGES (2 << GPIO_INT_SHIFT) /* Interrupt on both edges */ +# define GPIO_INT_LOWLEVEL (3 << GPIO_INT_SHIFT) /* Interrupt on low level */ +# define GPIO_INT_HIGHLEVEL (4 << GPIO_INT_SHIFT) /* Interrupt on high level */ + +/* The LM4F120 supports up to 15 alternate functions per pin: + * LM4F: .... .... .... AAAA .... .... .... .... + */ + +#ifdef LM4F +# define GPIO_ALT_SHIFT 16 /* Bits 16-19: Alternate function */ +# define GPIO_ALT_MASK (15 << GPIO_INT_SHIFT) +# define GPIO_ALT(n) ((n) << GPIO_INT_SHIFT) +# define GPIO_ALT_NONE (0 << GPIO_INT_SHIFT) +# define GPIO_ALT_1 (1 << GPIO_INT_SHIFT) +# define GPIO_ALT_2 (2 << GPIO_INT_SHIFT) +# define GPIO_ALT_3 (3 << GPIO_INT_SHIFT) +# define GPIO_ALT_4 (4 << GPIO_INT_SHIFT) +# define GPIO_ALT_5 (5 << GPIO_INT_SHIFT) +# define GPIO_ALT_6 (6 << GPIO_INT_SHIFT) +# define GPIO_ALT_7 (7 << GPIO_INT_SHIFT) +# define GPIO_ALT_8 (8 << GPIO_INT_SHIFT) +# define GPIO_ALT_9 (9 << GPIO_INT_SHIFT) +# define GPIO_ALT_10 (10 << GPIO_INT_SHIFT) +# define GPIO_ALT_11 (11 << GPIO_INT_SHIFT) +# define GPIO_ALT_12 (12 << GPIO_INT_SHIFT) +# define GPIO_ALT_13 (13 << GPIO_INT_SHIFT) +# define GPIO_ALT_14 (14 << GPIO_INT_SHIFT) +# define GPIO_ALT_15 (15 << GPIO_INT_SHIFT) +#endif /* If the pin is an GPIO digital output, then this identifies the initial output value: - * nnnn nnnn nnnn nnnn nnnn nnnn Vnnn nnnn + * .... .... .... .... .... .... V... .... */ #define GPIO_VALUE_SHIFT 7 /* Bit 7: If output, inital value of output */ #define GPIO_VALUE_MASK (1 << GPIO_VALUE_SHIFT) -#define GPIO_VALUE_ZERO (0 << GPIO_VALUE_SHIFT) /* Initial value is zero */ -#define GPIO_VALUE_ONE (1 << GPIO_VALUE_SHIFT) /* Initial value is one */ +# define GPIO_VALUE_ZERO (0 << GPIO_VALUE_SHIFT) /* Initial value is zero */ +# define GPIO_VALUE_ONE (1 << GPIO_VALUE_SHIFT) /* Initial value is one */ /* This identifies the GPIO port - * nnnn nnnn nnnn nnnn nnnn nnnn nPPP Pnnn + * .... .... .... .... .... .... .PPP P... */ #define GPIO_PORT_SHIFT 3 /* Bit 3-6: Port number */ #define GPIO_PORT_MASK (15 << GPIO_PORT_SHIFT) -#define GPIO_PORTA (0 << GPIO_PORT_SHIFT) /* GPIOA */ -#define GPIO_PORTB (1 << GPIO_PORT_SHIFT) /* GPIOB */ -#define GPIO_PORTC (2 << GPIO_PORT_SHIFT) /* GPIOC */ -#define GPIO_PORTD (3 << GPIO_PORT_SHIFT) /* GPIOD */ -#define GPIO_PORTE (4 << GPIO_PORT_SHIFT) /* GPIOE */ -#define GPIO_PORTF (5 << GPIO_PORT_SHIFT) /* GPIOF */ -#define GPIO_PORTG (6 << GPIO_PORT_SHIFT) /* GPIOG */ -#define GPIO_PORTH (7 << GPIO_PORT_SHIFT) /* GPIOH */ -#define GPIO_PORTJ (8 << GPIO_PORT_SHIFT) /* GPIOJ */ +# define GPIO_PORTA (0 << GPIO_PORT_SHIFT) /* GPIOA */ +# define GPIO_PORTB (1 << GPIO_PORT_SHIFT) /* GPIOB */ +# define GPIO_PORTC (2 << GPIO_PORT_SHIFT) /* GPIOC */ +# define GPIO_PORTD (3 << GPIO_PORT_SHIFT) /* GPIOD */ +# define GPIO_PORTE (4 << GPIO_PORT_SHIFT) /* GPIOE */ +# define GPIO_PORTF (5 << GPIO_PORT_SHIFT) /* GPIOF */ +# define GPIO_PORTG (6 << GPIO_PORT_SHIFT) /* GPIOG */ +# define GPIO_PORTH (7 << GPIO_PORT_SHIFT) /* GPIOH */ +# define GPIO_PORTJ (8 << GPIO_PORT_SHIFT) /* GPIOJ */ /* This identifies the pin number in the port: - * nnnn nnnn nnnn nnnn nnnn nnnn nnnn nBBB + * .... .... .... .... .... .... .... .BBB */ #define GPIO_PIN_SHIFT 0 /* Bits 0-2: GPIO pin: 0-7 */ |