123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278 |
- #ifndef _FSL_IOCON_H_
- #define _FSL_IOCON_H_
- #include "fsl_common.h"
- #ifndef FSL_COMPONENT_ID
- #define FSL_COMPONENT_ID "platform.drivers.lpc_iocon"
- #endif
- #define FSL_IOCON_DRIVER_VERSION (MAKE_VERSION(2, 0, 0))
- typedef struct _iocon_group
- {
- uint32_t port : 8;
- uint32_t pin : 8;
- uint32_t ionumber : 8;
- uint32_t modefunc : 16;
- } iocon_group_t;
- #if defined(FSL_FEATURE_IOCON_FUNC_FIELD_WIDTH) && (FSL_FEATURE_IOCON_FUNC_FIELD_WIDTH == 4)
- #define IOCON_FUNC0 0x0
- #define IOCON_FUNC1 0x1
- #define IOCON_FUNC2 0x2
- #define IOCON_FUNC3 0x3
- #define IOCON_FUNC4 0x4
- #define IOCON_FUNC5 0x5
- #define IOCON_FUNC6 0x6
- #define IOCON_FUNC7 0x7
- #define IOCON_FUNC8 0x8
- #define IOCON_FUNC9 0x9
- #define IOCON_FUNC10 0xA
- #define IOCON_FUNC11 0xB
- #define IOCON_FUNC12 0xC
- #define IOCON_FUNC13 0xD
- #define IOCON_FUNC14 0xE
- #define IOCON_FUNC15 0xF
- #if defined(IOCON_PIO_MODE_SHIFT)
- #define IOCON_MODE_INACT (0x0 << IOCON_PIO_MODE_SHIFT)
- #define IOCON_MODE_PULLDOWN (0x1 << IOCON_PIO_MODE_SHIFT)
- #define IOCON_MODE_PULLUP (0x2 << IOCON_PIO_MODE_SHIFT)
- #define IOCON_MODE_REPEATER (0x3 << IOCON_PIO_MODE_SHIFT)
- #endif
- #if defined(IOCON_PIO_I2CSLEW_SHIFT)
- #define IOCON_GPIO_MODE (0x1 << IOCON_PIO_I2CSLEW_SHIFT)
- #define IOCON_I2C_SLEW (0x0 << IOCON_PIO_I2CSLEW_SHIFT)
- #endif
- #if defined(IOCON_PIO_SLEW_SHIFT)
- #define IOCON_SLEW_STANDARD (0x0 << IOCON_PIO_SLEW_SHIFT)
- #define IOCON_SLEW_FAST (0x1 << IOCON_PIO_SLEW_SHIFT)
- #endif
- #if defined(IOCON_PIO_INVERT_SHIFT)
- #define IOCON_INV_EN (0x1 << IOCON_PIO_INVERT_SHIFT)
- #endif
- #if defined(IOCON_PIO_DIGIMODE_SHIFT)
- #define IOCON_ANALOG_EN (0x0 << IOCON_PIO_DIGIMODE_SHIFT)
- #define IOCON_DIGITAL_EN \
- (0x1 << IOCON_PIO_DIGIMODE_SHIFT)
- #endif
- #if defined(IOCON_PIO_FILTEROFF_SHIFT)
- #define IOCON_INPFILT_OFF (0x1 << IOCON_PIO_FILTEROFF_SHIFT)
- #define IOCON_INPFILT_ON (0x0 << IOCON_PIO_FILTEROFF_SHIFT)
- #endif
- #if defined(IOCON_PIO_I2CDRIVE_SHIFT)
- #define IOCON_I2C_LOWDRIVER (0x0 << IOCON_PIO_I2CDRIVE_SHIFT)
- #define IOCON_I2C_HIGHDRIVER (0x1 << IOCON_PIO_I2CDRIVE_SHIFT)
- #endif
- #if defined(IOCON_PIO_OD_SHIFT)
- #define IOCON_OPENDRAIN_EN (0x1 << IOCON_PIO_OD_SHIFT)
- #endif
- #if defined(IOCON_PIO_I2CFILTER_SHIFT)
- #define IOCON_I2CFILTER_OFF (0x1 << IOCON_PIO_I2CFILTER_SHIFT)
- #define IOCON_I2CFILTER_ON (0x0 << IOCON_PIO_I2CFILTER_SHIFT)
- #endif
- #if defined(IOCON_PIO_ASW_SHIFT)
- #define IOCON_AWS_EN (0x1 << IOCON_PIO_ASW_SHIFT)
- #endif
- #if defined(IOCON_PIO_SSEL_SHIFT)
- #define IOCON_SSEL_3V3 (0x0 << IOCON_PIO_SSEL_SHIFT)
- #define IOCON_SSEL_1V8 (0x1 << IOCON_PIO_SSEL_SHIFT)
- #endif
- #if defined(IOCON_PIO_ECS_SHIFT)
- #define IOCON_ECS_OFF (0x0 << IOCON_PIO_ECS_SHIFT)
- #define IOCON_ECS_ON (0x1 << IOCON_PIO_ECS_SHIFT)
- #endif
- #if defined(IOCON_PIO_S_MODE_SHIFT)
- #define IOCON_S_MODE_0CLK (0x0 << IOCON_PIO_S_MODE_SHIFT)
- #define IOCON_S_MODE_1CLK \
- (0x1 << IOCON_PIO_S_MODE_SHIFT)
- #define IOCON_S_MODE_2CLK \
- (0x2 << IOCON_PIO_S_MODE_SHIFT)
- #define IOCON_S_MODE_3CLK \
- (0x3 << IOCON_PIO_S_MODE_SHIFT)
- #define IOCON_S_MODE(clks) ((clks) << IOCON_PIO_S_MODE_SHIFT)
- #endif
- #if defined(IOCON_PIO_CLK_DIV_SHIFT)
- #define IOCON_CLKDIV(div) \
- ((div) \
- << IOCON_PIO_CLK_DIV_SHIFT)
- #endif
- #else
- #define IOCON_FUNC0 0x0
- #define IOCON_FUNC1 0x1
- #define IOCON_FUNC2 0x2
- #define IOCON_FUNC3 0x3
- #define IOCON_FUNC4 0x4
- #define IOCON_FUNC5 0x5
- #define IOCON_FUNC6 0x6
- #define IOCON_FUNC7 0x7
- #if defined(IOCON_PIO_MODE_SHIFT)
- #define IOCON_MODE_INACT (0x0 << IOCON_PIO_MODE_SHIFT)
- #define IOCON_MODE_PULLDOWN (0x1 << IOCON_PIO_MODE_SHIFT)
- #define IOCON_MODE_PULLUP (0x2 << IOCON_PIO_MODE_SHIFT)
- #define IOCON_MODE_REPEATER (0x3 << IOCON_PIO_MODE_SHIFT)
- #endif
- #if defined(IOCON_PIO_I2CSLEW_SHIFT)
- #define IOCON_GPIO_MODE (0x1 << IOCON_PIO_I2CSLEW_SHIFT)
- #define IOCON_I2C_SLEW (0x0 << IOCON_PIO_I2CSLEW_SHIFT)
- #endif
- #if defined(IOCON_PIO_INVERT_SHIFT)
- #define IOCON_INV_EN (0x1 << IOCON_PIO_INVERT_SHIFT)
- #endif
- #if defined(IOCON_PIO_DIGIMODE_SHIFT)
- #define IOCON_ANALOG_EN (0x0 << IOCON_PIO_DIGIMODE_SHIFT)
- #define IOCON_DIGITAL_EN \
- (0x1 << IOCON_PIO_DIGIMODE_SHIFT)
- #endif
- #if defined(IOCON_PIO_FILTEROFF_SHIFT)
- #define IOCON_INPFILT_OFF (0x1 << IOCON_PIO_FILTEROFF_SHIFT)
- #define IOCON_INPFILT_ON (0x0 << IOCON_PIO_FILTEROFF_SHIFT)
- #endif
- #if defined(IOCON_PIO_I2CDRIVE_SHIFT)
- #define IOCON_I2C_LOWDRIVER (0x0 << IOCON_PIO_I2CDRIVE_SHIFT)
- #define IOCON_I2C_HIGHDRIVER (0x1 << IOCON_PIO_I2CDRIVE_SHIFT)
- #endif
- #if defined(IOCON_PIO_OD_SHIFT)
- #define IOCON_OPENDRAIN_EN (0x1 << IOCON_PIO_OD_SHIFT)
- #endif
- #if defined(IOCON_PIO_I2CFILTER_SHIFT)
- #define IOCON_I2CFILTER_OFF (0x1 << IOCON_PIO_I2CFILTER_SHIFT)
- #define IOCON_I2CFILTER_ON (0x0 << IOCON_PIO_I2CFILTER_SHIFT)
- #endif
- #if defined(IOCON_PIO_S_MODE_SHIFT)
- #define IOCON_S_MODE_0CLK (0x0 << IOCON_PIO_S_MODE_SHIFT)
- #define IOCON_S_MODE_1CLK \
- (0x1 << IOCON_PIO_S_MODE_SHIFT)
- #define IOCON_S_MODE_2CLK \
- (0x2 << IOCON_PIO_S_MODE_SHIFT)
- #define IOCON_S_MODE_3CLK \
- (0x3 << IOCON_PIO_S_MODE_SHIFT)
- #define IOCON_S_MODE(clks) ((clks) << IOCON_PIO_S_MODE_SHIFT)
- #endif
- #if defined(IOCON_PIO_CLK_DIV_SHIFT)
- #define IOCON_CLKDIV(div) \
- ((div) \
- << IOCON_PIO_CLK_DIV_SHIFT)
- #endif
- #endif
- #if defined(__cplusplus)
- extern "C" {
- #endif
- #if (defined(FSL_FEATURE_IOCON_ONE_DIMENSION) && (FSL_FEATURE_IOCON_ONE_DIMENSION == 1))
- __STATIC_INLINE void IOCON_PinMuxSet(IOCON_Type *base, uint8_t ionumber, uint32_t modefunc)
- {
- base->PIO[ionumber] = modefunc;
- }
- #else
- __STATIC_INLINE void IOCON_PinMuxSet(IOCON_Type *base, uint8_t port, uint8_t pin, uint32_t modefunc)
- {
- base->PIO[port][pin] = modefunc;
- }
- #endif
- __STATIC_INLINE void IOCON_SetPinMuxing(IOCON_Type *base, const iocon_group_t *pinArray, uint32_t arrayLength)
- {
- uint32_t i;
- for (i = 0; i < arrayLength; i++)
- {
- #if (defined(FSL_FEATURE_IOCON_ONE_DIMENSION) && (FSL_FEATURE_IOCON_ONE_DIMENSION == 1))
- IOCON_PinMuxSet(base, pinArray[i].ionumber, pinArray[i].modefunc);
- #else
- IOCON_PinMuxSet(base, pinArray[i].port, pinArray[i].pin, pinArray[i].modefunc);
- #endif
- }
- }
- #if defined(__cplusplus)
- }
- #endif
- #endif
|