S32 SDK
Port Control and Interrupts (PORT)

Detailed Description

This module covers the functionality of the PORT peripheral.

PORT HAL provides the API for reading and writing register bit-fields belonging to the PORT module.

Enumerations

enum  port_pull_config_t { PORT_INTERNAL_PULL_NOT_ENABLED = 0U, PORT_INTERNAL_PULL_DOWN_ENABLED = 1U, PORT_INTERNAL_PULL_UP_ENABLED = 2U }
 Internal resistor pull feature selection Implements : port_pull_config_t_Class. More...
 
enum  port_drive_strength_t { PORT_LOW_DRIVE_STRENGTH = 0U, PORT_HIGH_DRIVE_STRENGTH = 1U }
 Configures the drive strength. Implements : port_drive_strength_t_Class. More...
 
enum  port_mux_t {
  PORT_PIN_DISABLED = 0U, PORT_MUX_AS_GPIO = 1U, PORT_MUX_ALT2 = 2U, PORT_MUX_ALT3 = 3U,
  PORT_MUX_ALT4 = 4U, PORT_MUX_ALT5 = 5U, PORT_MUX_ALT6 = 6U, PORT_MUX_ALT7 = 7U
}
 Pin mux selection Implements : port_mux_t_Class. More...
 
enum  port_digital_filter_clock_source_t { PORT_BUS_CLOCK = 0U, PORT_LPO_CLOCK = 1U }
 Digital filter clock source selection Implements : port_digital_filter_clock_source_t_Class. More...
 
enum  port_interrupt_config_t {
  PORT_DMA_INT_DISABLED = 0x0U, PORT_DMA_RISING_EDGE = 0x1U, PORT_DMA_FALLING_EDGE = 0x2U, PORT_DMA_EITHER_EDGE = 0x3U,
  PORT_INT_LOGIC_ZERO = 0x8U, PORT_INT_RISING_EDGE = 0x9U, PORT_INT_FALLING_EDGE = 0xAU, PORT_INT_EITHER_EDGE = 0xBU,
  PORT_INT_LOGIC_ONE = 0xCU
}
 Configures the interrupt generation condition. Implements : port_interrupt_config_t_Class. More...
 

Configuration

static void PORT_HAL_SetPullSel (PORT_Type *const base, const uint32_t pin, const port_pull_config_t pullConfig)
 Configures the internal resistor. More...
 
static void PORT_HAL_SetPassiveFilterMode (PORT_Type *const base, const uint32_t pin, const bool isPassiveFilterEnabled)
 Configures the passive filter if the pin is used as a digital input. More...
 
static void PORT_HAL_SetDriveStrengthMode (PORT_Type *const base, const uint32_t pin, const port_drive_strength_t driveSelect)
 Configures the drive strength if the pin is used as a digital output. More...
 
static void PORT_HAL_SetMuxModeSel (PORT_Type *const base, const uint32_t pin, const port_mux_t mux)
 Configures the pin muxing. More...
 
static void PORT_HAL_SetPinCtrlLockMode (PORT_Type *const base, const uint32_t pin, const bool isPinLockEnabled)
 Locks or unlocks the pin control register bits[15:0]. More...
 
static void PORT_HAL_SetDigitalFilterMode (PORT_Type *const base, const uint32_t pin, const bool isDigitalFilterEnabled)
 Enables or disables the digital filter in one single port. Each bit of the 32-bit register represents one pin. More...
 
static void PORT_HAL_SetDigitalFilterClock (PORT_Type *const base, const port_digital_filter_clock_source_t clockSource)
 Configures the clock source for the digital input filters. Changing the filter clock source should only be done after disabling all enabled filters. Every pin in one port uses the same clock source. More...
 
static void PORT_HAL_SetDigitalFilterWidth (PORT_Type *const base, const uint8_t width)
 Configures the maximum size of the glitches (in clock cycles) that the digital filter absorbs for enabled digital filters. Glitches that are longer than this register setting (in clock cycles) pass through the digital filter, while glitches that are equal to or less than this register setting (in clock cycles) are filtered. Changing the filter length should only be done after disabling all enabled filters. More...
 
void PORT_HAL_SetLowGlobalPinCtrlCmd (PORT_Type *const base, const uint16_t lowPinSelect, const uint16_t config)
 Configures the low half of the pin control register for the same settings. This function operates pin 0 -15 of one specific port. More...
 
void PORT_HAL_SetHighGlobalPinCtrlCmd (PORT_Type *const base, const uint16_t highPinSelect, const uint16_t config)
 Configures the high half of pin control register for the same settings. This function operates pin 16 -31 of one specific port. More...
 

Interrupt

static void PORT_HAL_SetPinIntSel (PORT_Type *const base, const uint32_t pin, const port_interrupt_config_t intConfig)
 Configures the port pin interrupt/DMA request. More...
 
static port_interrupt_config_t PORT_HAL_GetPinIntSel (const PORT_Type *const base, const uint32_t pin)
 Gets the current port pin interrupt/DMA request configuration. More...
 
static bool PORT_HAL_GetPinIntMode (const PORT_Type *const base, const uint32_t pin)
 Reads the individual pin-interrupt status flag. More...
 
static void PORT_HAL_ClearPinIntFlagCmd (PORT_Type *const base, const uint32_t pin)
 Clears the individual pin-interrupt status flag. More...
 
static uint32_t PORT_HAL_GetPortIntFlag (const PORT_Type *const base)
 Reads the entire port interrupt status flag. More...
 
static void PORT_HAL_ClearPortIntFlagCmd (PORT_Type *const base)
 Clears the entire port interrupt status flag. More...
 

Enumeration Type Documentation

Digital filter clock source selection Implements : port_digital_filter_clock_source_t_Class.

Enumerator
PORT_BUS_CLOCK 

Digital filters are clocked by the bus clock.

PORT_LPO_CLOCK 

Digital filters are clocked by the 1 kHz LPO clock.

Definition at line 113 of file port_hal.h.

Configures the drive strength. Implements : port_drive_strength_t_Class.

Enumerator
PORT_LOW_DRIVE_STRENGTH 

low drive strength is configured.

PORT_HIGH_DRIVE_STRENGTH 

high drive strength is configured.

Definition at line 87 of file port_hal.h.

Configures the interrupt generation condition. Implements : port_interrupt_config_t_Class.

Enumerator
PORT_DMA_INT_DISABLED 

Interrupt/DMA request is disabled.

PORT_DMA_RISING_EDGE 

DMA request on rising edge.

PORT_DMA_FALLING_EDGE 

DMA request on falling edge.

PORT_DMA_EITHER_EDGE 

DMA request on either edge.

PORT_INT_LOGIC_ZERO 

Interrupt when logic zero.

PORT_INT_RISING_EDGE 

Interrupt on rising edge.

PORT_INT_FALLING_EDGE 

Interrupt on falling edge.

PORT_INT_EITHER_EDGE 

Interrupt on either edge.

PORT_INT_LOGIC_ONE 

Interrupt when logic one.

Definition at line 123 of file port_hal.h.

enum port_mux_t

Pin mux selection Implements : port_mux_t_Class.

Enumerator
PORT_PIN_DISABLED 

corresponding pin is disabled, but is used as an analog pin.

PORT_MUX_AS_GPIO 

corresponding pin is configured as GPIO.

PORT_MUX_ALT2 

chip-specific

PORT_MUX_ALT3 

chip-specific

PORT_MUX_ALT4 

chip-specific

PORT_MUX_ALT5 

chip-specific

PORT_MUX_ALT6 

chip-specific

PORT_MUX_ALT7 

chip-specific

Definition at line 97 of file port_hal.h.

Internal resistor pull feature selection Implements : port_pull_config_t_Class.

Enumerator
PORT_INTERNAL_PULL_NOT_ENABLED 

internal pull-down or pull-up resistor is not enabled.

PORT_INTERNAL_PULL_DOWN_ENABLED 

internal pull-down resistor is enabled.

PORT_INTERNAL_PULL_UP_ENABLED 

internal pull-up resistor is enabled.

Definition at line 64 of file port_hal.h.

Function Documentation

static void PORT_HAL_ClearPinIntFlagCmd ( PORT_Type *const  base,
const uint32_t  pin 
)
inlinestatic

Clears the individual pin-interrupt status flag.

Parameters
[in]baseport base pointer
[in]pinport pin number Implements : PORT_HAL_ClearPinIntFlagCmd_Activity

Definition at line 517 of file port_hal.h.

static void PORT_HAL_ClearPortIntFlagCmd ( PORT_Type *const  base)
inlinestatic

Clears the entire port interrupt status flag.

Parameters
[in]baseport base pointer Implements : PORT_HAL_ClearPortIntFlagCmd_Activity

Definition at line 547 of file port_hal.h.

static bool PORT_HAL_GetPinIntMode ( const PORT_Type *const  base,
const uint32_t  pin 
)
inlinestatic

Reads the individual pin-interrupt status flag.

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
[in]baseport base pointer
[in]pinport pin number
Returns
current pin interrupt status flag
  • 0: interrupt is not detected.
  • 1: interrupt is detected. Implements : PORT_HAL_GetPinIntMode_Activity

Definition at line 502 of file port_hal.h.

static port_interrupt_config_t PORT_HAL_GetPinIntSel ( const PORT_Type *const  base,
const uint32_t  pin 
)
inlinestatic

Gets the current port pin interrupt/DMA request configuration.

Parameters
[in]baseport base pointer
[in]pinport pin number
Returns
interrupt configuration
  • PORT_INT_DISABLED : Interrupt/DMA request disabled.
  • PORT_DMA_RISING_EDGE : DMA request on rising edge.
  • PORT_DMA_FALLING_EDGE: DMA request on falling edge.
  • PORT_DMA_EITHER_EDGE : DMA request on either edge.
  • PORT_INT_LOGIC_ZERO : Interrupt when logic zero.
  • PORT_INT_RISING_EDGE : Interrupt on rising edge.
  • PORT_INT_FALLING_EDGE: Interrupt on falling edge.
  • PORT_INT_EITHER_EDGE : Interrupt on either edge.
  • PORT_INT_LOGIC_ONE : Interrupt when logic one. Implements : PORT_HAL_GetPinIntSel_Activity

Definition at line 478 of file port_hal.h.

static uint32_t PORT_HAL_GetPortIntFlag ( const PORT_Type *const  base)
inlinestatic

Reads the entire port interrupt status flag.

Parameters
[in]baseport base pointer
Returns
all 32 pin interrupt status flags. For specific bit:
  • 0: interrupt is not detected.
  • 1: interrupt is detected. Implements : PORT_HAL_GetPortIntFlag_Activity

Definition at line 535 of file port_hal.h.

static void PORT_HAL_SetDigitalFilterClock ( PORT_Type *const  base,
const port_digital_filter_clock_source_t  clockSource 
)
inlinestatic

Configures the clock source for the digital input filters. Changing the filter clock source should only be done after disabling all enabled filters. Every pin in one port uses the same clock source.

Parameters
[in]baseport base pointer
[in]clockSourcechose which clock source to use for current port
  • PORT_BUS_CLOCK: digital filters are clocked by the bus clock.
  • PORT_LPO_CLOCK: digital filters are clocked by the 1 kHz LPO clock. Implements : PORT_HAL_SetDigitalFilterClock_Activity

Definition at line 379 of file port_hal.h.

static void PORT_HAL_SetDigitalFilterMode ( PORT_Type *const  base,
const uint32_t  pin,
const bool  isDigitalFilterEnabled 
)
inlinestatic

Enables or disables the digital filter in one single port. Each bit of the 32-bit register represents one pin.

Parameters
[in]baseport base pointer
[in]pinport pin number
[in]isDigitalFilterEnableddigital filter enable/disable
  • false: digital filter is disabled on the corresponding pin.
  • true : digital filter is enabled on the corresponding pin. Implements : PORT_HAL_SetDigitalFilterMode_Activity

Definition at line 355 of file port_hal.h.

static void PORT_HAL_SetDigitalFilterWidth ( PORT_Type *const  base,
const uint8_t  width 
)
inlinestatic

Configures the maximum size of the glitches (in clock cycles) that the digital filter absorbs for enabled digital filters. Glitches that are longer than this register setting (in clock cycles) pass through the digital filter, while glitches that are equal to or less than this register setting (in clock cycles) are filtered. Changing the filter length should only be done after disabling all enabled filters.

Parameters
[in]baseport base pointer
[in]widthconfigure digital filter width (should be less than 5 bits). Implements : PORT_HAL_SetDigitalFilterWidth_Activity

Definition at line 396 of file port_hal.h.

static void PORT_HAL_SetDriveStrengthMode ( PORT_Type *const  base,
const uint32_t  pin,
const port_drive_strength_t  driveSelect 
)
inlinestatic

Configures the drive strength if the pin is used as a digital output.

Parameters
[in]baseport base pointer
[in]pinport pin number
[in]driveSelectdrive strength selection
  • PORT_LOW_DRIVE_STRENGTH : low drive strength is configured.
  • PORT_HIGH_DRIVE_STRENGTH: high drive strength is configured. Implements : PORT_HAL_SetDriveStrengthMode_Activity

Definition at line 284 of file port_hal.h.

void PORT_HAL_SetHighGlobalPinCtrlCmd ( PORT_Type *const  base,
const uint16_t  highPinSelect,
const uint16_t  config 
)

Configures the high half of pin control register for the same settings. This function operates pin 16 -31 of one specific port.

Parameters
[in]baseport base pointer
[in]highPinSelectupdate corresponding pin control register or not. For a specific bit:
  • 0: corresponding high half of pin control register won't be updated according to configuration.
  • 1: corresponding high half of pin control register will be updated according to configuration.
[in]configvalue is written to a high half port control register bits[15:0].
void PORT_HAL_SetLowGlobalPinCtrlCmd ( PORT_Type *const  base,
const uint16_t  lowPinSelect,
const uint16_t  config 
)

Configures the low half of the pin control register for the same settings. This function operates pin 0 -15 of one specific port.

Parameters
[in]baseport base pointer
[in]lowPinSelectupdate corresponding pin control register or not. For a specific bit:
  • 0: corresponding low half of pin control register won't be updated according to configuration.
  • 1: corresponding low half of pin control register will be updated according to configuration.
[in]configvalue is written to a low half port control register bits[15:0].
static void PORT_HAL_SetMuxModeSel ( PORT_Type *const  base,
const uint32_t  pin,
const port_mux_t  mux 
)
inlinestatic

Configures the pin muxing.

Parameters
[in]baseport base pointer
[in]pinport pin number
[in]muxpin muxing slot selection
  • PORT_PIN_DISABLED: Pin disabled.
  • PORT_MUX_AS_GPIO : Set as GPIO.
  • others : chip-specific. Implements : PORT_HAL_SetMuxModeSel_Activity

Definition at line 309 of file port_hal.h.

static void PORT_HAL_SetPassiveFilterMode ( PORT_Type *const  base,
const uint32_t  pin,
const bool  isPassiveFilterEnabled 
)
inlinestatic

Configures the passive filter if the pin is used as a digital input.

If enabled, a low pass filter (10 MHz to 30 MHz bandwidth) is enabled on the digital input path. Disable the Passive Input Filter when supporting high speed interfaces (> 2 MHz) on the pin.

Parameters
[in]baseport base pointer
[in]pinport pin number
[in]isPassiveFilterEnabledpassive filter configuration
  • false: passive filter is disabled.
  • true : passive filter is enabled. Implements : PORT_HAL_SetPassiveFilterMode_Activity

Definition at line 239 of file port_hal.h.

static void PORT_HAL_SetPinCtrlLockMode ( PORT_Type *const  base,
const uint32_t  pin,
const bool  isPinLockEnabled 
)
inlinestatic

Locks or unlocks the pin control register bits[15:0].

Parameters
[in]baseport base pointer
[in]pinport pin number
[in]isPinLockEnabledlock pin control register or not
  • false: pin control register bit[15:0] are not locked.
  • true : pin control register bit[15:0] are locked, cannot be updated till system reset. Implements : PORT_HAL_SetPinCtrlLockMode_Activity

Definition at line 331 of file port_hal.h.

static void PORT_HAL_SetPinIntSel ( PORT_Type *const  base,
const uint32_t  pin,
const port_interrupt_config_t  intConfig 
)
inlinestatic

Configures the port pin interrupt/DMA request.

Parameters
[in]baseport base pointer.
[in]pinport pin number
[in]intConfiginterrupt configuration
  • PORT_INT_DISABLED : Interrupt/DMA request disabled.
  • PORT_DMA_RISING_EDGE : DMA request on rising edge.
  • PORT_DMA_FALLING_EDGE: DMA request on falling edge.
  • PORT_DMA_EITHER_EDGE : DMA request on either edge.
  • PORT_INT_LOGIC_ZERO : Interrupt when logic zero.
  • PORT_INT_RISING_EDGE : Interrupt on rising edge.
  • PORT_INT_FALLING_EDGE: Interrupt on falling edge.
  • PORT_INT_EITHER_EDGE : Interrupt on either edge.
  • PORT_INT_LOGIC_ONE : Interrupt when logic one. Implements : PORT_HAL_SetPinIntSel_Activity

Definition at line 450 of file port_hal.h.

static void PORT_HAL_SetPullSel ( PORT_Type *const  base,
const uint32_t  pin,
const port_pull_config_t  pullConfig 
)
inlinestatic

Configures the internal resistor.

Pull configuration is valid in all digital pin muxing modes.

Parameters
[in]baseport base pointer.
[in]pinport pin number
[in]pullConfiginternal resistor pull feature selection
  • PORT_PULL_NOT_ENABLED: internal pull-down or pull-up resistor is not enabled.
  • PORT_PULL_DOWN_ENABLED: internal pull-down resistor is enabled.
  • PORT_PULL_UP_ENABLED: internal pull-up resistor is enabled. Implements : PORT_HAL_SetPullSel_Activity

Definition at line 164 of file port_hal.h.