The KSDK provides a driver for the Port Control and Interrupts (PORT) module of Kinetis devices.
Typical configuration case
Input PORT Configuration
I2C PORT Configuration
|
enum | _port_pull {
kPORT_PullDisable = 0U,
kPORT_PullDown = 2U,
kPORT_PullUp = 3U
} |
| Internal resistor pull feature selection. More...
|
|
enum | _port_slew_rate {
kPORT_FastSlewRate = 0U,
kPORT_SlowSlewRate = 1U
} |
| Slew rate selection. More...
|
|
enum | _port_passive_filter_enable {
kPORT_PassiveFilterDisable = 0U,
kPORT_PassiveFilterEnable = 1U
} |
| Passive filter feature enable/disable. More...
|
|
enum | _port_drive_strength {
kPORT_LowDriveStrength = 0U,
kPORT_HighDriveStrength = 1U
} |
| Configures the drive strength. More...
|
|
enum | port_mux_t {
kPORT_PinDisabledOrAnalog = 0U,
kPORT_MuxAsGpio = 1U,
kPORT_MuxAlt2 = 2U,
kPORT_MuxAlt3 = 3U,
kPORT_MuxAlt4 = 4U,
kPORT_MuxAlt5 = 5U,
kPORT_MuxAlt6 = 6U,
kPORT_MuxAlt7 = 7U
} |
| Pin mux selection. More...
|
|
enum | port_interrupt_t {
kPORT_InterruptOrDMADisabled = 0x0U,
kPORT_InterruptLogicZero = 0x8U,
kPORT_InterruptRisingEdge = 0x9U,
kPORT_InterruptFallingEdge = 0xAU,
kPORT_InterruptEitherEdge = 0xBU,
kPORT_InterruptLogicOne = 0xCU
} |
| Configures the interrupt generation condition. More...
|
|
Data Fields |
uint16_t | pullSelect: 2 |
| no-pull/pull-down/pull-up select
|
|
uint16_t | slewRate: 1 |
| fast/slow slew rate Configure
|
|
uint16_t | passiveFilterEnable: 1 |
| passive filter enable/disable
|
|
uint16_t | driveStrength: 1 |
| fast/slow drive strength configure
|
|
uint16_t | mux: 3 |
| pin mux Configure
|
|
Enumerator |
---|
kPORT_PullDisable |
internal pull-up/down resistor is disabled.
|
kPORT_PullDown |
internal pull-down resistor is enabled.
|
kPORT_PullUp |
internal pull-up resistor is enabled.
|
Enumerator |
---|
kPORT_FastSlewRate |
fast slew rate is configured.
|
kPORT_SlowSlewRate |
slow slew rate is configured.
|
Enumerator |
---|
kPORT_PassiveFilterDisable |
fast slew rate is configured.
|
kPORT_PassiveFilterEnable |
slow slew rate is configured.
|
Enumerator |
---|
kPORT_LowDriveStrength |
low drive strength is configured.
|
kPORT_HighDriveStrength |
high drive strength is configured.
|
Enumerator |
---|
kPORT_PinDisabledOrAnalog |
corresponding pin is disabled, but is used as an analog pin.
|
kPORT_MuxAsGpio |
corresponding pin is configured as GPIO.
|
kPORT_MuxAlt2 |
chip-specific
|
kPORT_MuxAlt3 |
chip-specific
|
kPORT_MuxAlt4 |
chip-specific
|
kPORT_MuxAlt5 |
chip-specific
|
kPORT_MuxAlt6 |
chip-specific
|
kPORT_MuxAlt7 |
chip-specific
|
Enumerator |
---|
kPORT_InterruptOrDMADisabled |
Interrupt/DMA request is disabled.
|
kPORT_InterruptLogicZero |
Interrupt when logic zero.
|
kPORT_InterruptRisingEdge |
Interrupt on rising edge.
|
kPORT_InterruptFallingEdge |
Interrupt on falling edge.
|
kPORT_InterruptEitherEdge |
Interrupt on either edge.
|
kPORT_InterruptLogicOne |
Interrupt when logic one.
|
static void PORT_SetPinConfig |
( |
PORT_Type * |
base, |
|
|
uint32_t |
pin, |
|
|
const port_pin_config_t * |
config |
|
) |
| |
|
inlinestatic |
This is an example to define an input pin or output pin PCR configuration:
kPORT_OpenDrainDisable,
kPORT_UnLockRegister,
};
- Parameters
-
base | PORT peripheral base pointer. |
pin | PORT pin number. |
config | PORT PCR register configure structure. |
static void PORT_SetMultiplePinsConfig |
( |
PORT_Type * |
base, |
|
|
uint32_t |
mask, |
|
|
const port_pin_config_t * |
config |
|
) |
| |
|
inlinestatic |
This is an example to define input pins or output pins PCR configuration:
kPORT_PullEnable,
kPORT_OpenDrainDisable,
kPORT_UnlockRegister,
};
- Parameters
-
base | PORT peripheral base pointer. |
mask | PORT pins' numbers macro. |
config | PORT PCR register configure structure. |
static void PORT_SetPinMux |
( |
PORT_Type * |
base, |
|
|
uint32_t |
pin, |
|
|
port_mux_t |
mux |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | PORT peripheral base pointer. |
pin | PORT pin number. |
mux | pin muxing slot selection.
- kPORT_PinDisabledOrAnalog: Pin disabled or work in analog function.
- kPORT_MuxAsGpio : Set as GPIO.
- kPORT_MuxAlt2 : chip-specific.
- kPORT_MuxAlt3 : chip-specific.
- kPORT_MuxAlt4 : chip-specific.
- kPORT_MuxAlt5 : chip-specific.
- kPORT_MuxAlt6 : chip-specific.
- kPORT_MuxAlt7 : chip-specific. : This function is NOT recommended to use together with the PORT_SetPinsConfig, because the PORT_SetPinsConfig need to configure the pin mux anyway (Otherwise the pin mux will be reset to zero : kPORT_PinDisabledOrAnalog). This function is recommended to use in the case you just need to reset the pin mux
|
static void PORT_SetPinInterruptConfig |
( |
PORT_Type * |
base, |
|
|
uint32_t |
pin, |
|
|
port_interrupt_t |
config |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | PORT peripheral base pointer. |
pin | PORT pin number. |
config | PORT pin interrupt configuration.
- kPORT_InterruptOrDMADisabled: Interrupt/DMA request disabled.
- #kPORT_DMARisingEdge : DMA request on rising edge(if the DMA requests exit).
- #kPORT_DMAFallingEdge: DMA request on falling edge(if the DMA requests exit).
- #kPORT_DMAEitherEdge : DMA request on either edge(if the DMA requests exit).
- #kPORT_FlagRisingEdge : Flag sets on rising edge(if the Flag states exit).
- #kPORT_FlagFallingEdge : Flag sets on falling edge(if the Flag states exit).
- #kPORT_FlagEitherEdge : Flag sets on either edge(if the Flag states exit).
- kPORT_InterruptLogicZero : Interrupt when logic zero.
- kPORT_InterruptRisingEdge : Interrupt on rising edge.
- kPORT_InterruptFallingEdge: Interrupt on falling edge.
- kPORT_InterruptEitherEdge : Interrupt on either edge.
- kPORT_InterruptLogicOne : Interrupt when logic one.
- #kPORT_ActiveHighTriggerOutputEnable : Enable active high trigger output(if the trigger states exit).
- #kPORT_ActiveLowTriggerOutputEnable : Enable active low trigger output(if the trigger states exit).
|
static uint32_t PORT_GetPinsInterruptFlags |
( |
PORT_Type * |
base | ) |
|
|
inlinestatic |
If a pin is configured to generate the DMA request, the corresponding flag is cleared automatically at the completion of the requested DMA transfer. Otherwise, the flag remains set until a logic one is written to that flag. If configured for a level sensitive interrupt that remains asserted, the flag is set again immediately.
- Parameters
-
base | PORT peripheral base pointer. |
- Returns
- Current port interrupt status flags, for example, 0x00010001 means the pin 0 and 17 have the interrupt.
static void PORT_ClearPinsInterruptFlags |
( |
PORT_Type * |
base, |
|
|
uint32_t |
mask |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | PORT peripheral base pointer. |
mask | PORT pins' numbers macro. |