MKE02Z4

ACMP: Analog Comparator Driver

void ACMP_Init(ACMP_Type *base, const acmp_config_t *config)

Initialize the ACMP.

The default configuration can be got by calling ACMP_GetDefaultConfig().

Parameters:
  • base – ACMP peripheral base address.

  • config – Pointer to ACMP configuration structure.

void ACMP_Deinit(ACMP_Type *base)

De-Initialize the ACMP.

Parameters:
  • base – ACMP peripheral basic address.

void ACMP_GetDefaultConfig(acmp_config_t *config)

Gets the default configuration for ACMP.

This function initializes the user configuration structure to default value. The default value are: Example:

config->enablePinOut = false;
config->hysteresisMode = kACMP_HysterisisLevel1;

Parameters:
  • config – Pointer to ACMP configuration structure.

static inline void ACMP_Enable(ACMP_Type *base, bool enable)

Enable/Disable the ACMP module.

Parameters:
  • base – ACMP peripheral base address.

  • enable – Switcher to enable/disable ACMP module.

void ACMP_EnableInterrupt(ACMP_Type *base, acmp_interrupt_mode_t mode)

Enable the ACMP interrupt and determines the sensitivity modes of the interrupt trigger.

Parameters:
  • base – ACMP peripheral base address.

  • mode – Select one interrupt mode to generate interrupt.

static inline void ACMP_DisableInterrupt(ACMP_Type *base)

Disable the ACMP interrupt.

Parameters:
  • base – ACMP peripheral base address.

void ACMP_SetChannelConfig(ACMP_Type *base, acmp_input_channel_selection_t PositiveInput, acmp_input_channel_selection_t negativeInout)

Configure the ACMP positive and negative input channel.

Parameters:
  • base – ACMP peripheral base address.

  • PositiveInput – ACMP Positive Input Select. Refer to “acmp_input_channel_selection_t”.

  • negativeInout – ACMP Negative Input Select. Refer to “acmp_input_channel_selection_t”.

void ACMP_SetDACConfig(ACMP_Type *base, const acmp_dac_config_t *config)
void ACMP_EnableInputPin(ACMP_Type *base, uint32_t mask, bool enable)

Enable/Disable ACMP input pin. The API controls if the corresponding ACMP external pin can be driven by an analog input.

Parameters:
  • base – ACMP peripheral base address.

  • mask – The mask of the pin associated with channel ADx. Valid range is AD0:0x1U ~ AD3:0x4U. For example: If enable AD0, AD1 and AD2 pins, mask should be set to 0x7U(0x1 | 0x2 | 0x4).

  • enable – Switcher to enable/disable ACMP module.

static inline uint8_t ACMP_GetStatusFlags(ACMP_Type *base)

Get ACMP status flags.

Parameters:
  • base – ACMP peripheral base address.

Returns:

Flags’ mask if indicated flags are asserted. See “_acmp_status_flags”.

static inline void ACMP_ClearInterruptFlags(ACMP_Type *base)

Clear interrupts status flag.

Parameters:
  • base – ACMP peripheral base address.

FSL_ACMP_DRIVER_VERSION

ACMP driver version 2.0.2.

enum _acmp_hysterisis_mode

Analog Comparator Hysterisis Selection.

Values:

enumerator kACMP_HysterisisLevel1

ACMP hysterisis is 20mv. >

enumerator kACMP_HysterisisLevel2

ACMP hysterisis is 30mv. >

enum _acmp_reference_voltage_source

DAC Voltage Reference source.

Values:

enumerator kACMP_VrefSourceVin1

The DAC selects Bandgap as the reference.

enumerator kACMP_VrefSourceVin2

The DAC selects VDDA as the reference.

enum _acmp_interrupt_mode

The sensitivity modes of the interrupt trigger.

Values:

enumerator kACMP_OutputFallingInterruptMode

ACMP interrupt on output falling edge. >

enumerator kACMP_OutputRisingInterruptMode

ACMP interrupt on output rising edge. >

enumerator kACMP_OutputBothEdgeInterruptMode

ACMP interrupt on output falling or rising edge. >

enum _acmp_input_channel_selection

The ACMP input channel selection.

Values:

enumerator kACMP_ExternalReference0

External reference 0 is selected to as input channel. >

enumerator kACMP_ExternalReference1

External reference 1 is selected to as input channel. >

enumerator kACMP_ExternalReference2

External reference 2 is selected to as input channel. >

enumerator kACMP_InternalDACOutput

Internal DAC putput is selected to as input channel. >

enum _acmp_status_flags

The ACMP status flags.

Values:

enumerator kACMP_InterruptFlag

ACMP interrupt on output valid edge. >

enumerator kACMP_OutputFlag

The current value of the analog comparator output. >

typedef enum _acmp_hysterisis_mode acmp_hysterisis_mode_t

Analog Comparator Hysterisis Selection.

typedef enum _acmp_reference_voltage_source acmp_reference_voltage_source_t

DAC Voltage Reference source.

typedef enum _acmp_interrupt_mode acmp_interrupt_mode_t

The sensitivity modes of the interrupt trigger.

typedef enum _acmp_input_channel_selection acmp_input_channel_selection_t

The ACMP input channel selection.

typedef struct _acmp_config acmp_config_t

Configuration for ACMP.

typedef struct _acmp_dac_config acmp_dac_config_t

Configuration for Internal DAC.

struct _acmp_config
#include <fsl_acmp.h>

Configuration for ACMP.

Public Members

bool enablePinOut

The comparator output is available on the associated pin.

acmp_hysterisis_mode_t hysteresisMode

Hysteresis mode.

struct _acmp_dac_config
#include <fsl_acmp.h>

Configuration for Internal DAC.

Public Members

uint8_t DACValue

Value for DAC Output Voltage. Available range is 0-63.

acmp_reference_voltage_source_t referenceVoltageSource

Supply voltage reference source.

ADC: 12-bit Analog to Digital Converter Driver

void ADC_Init(ADC_Type *base, const adc_config_t *config)

Initializes the ADC module.

Parameters:
  • base – ADC peripheral base address.

  • config – Pointer to configuration structure. See “adc_config_t”.

void ADC_Deinit(ADC_Type *base)

De-initialize the ADC module.

Parameters:
  • base – ADC peripheral base address.

void ADC_GetDefaultConfig(adc_config_t *config)

Gets an available pre-defined settings for the converter’s configuration.

This function initializes the converter configuration structure with available settings. The default values are as follows.

config->referenceVoltageSource = kADC_ReferenceVoltageSourceAlt0;
config->enableLowPower = false;
config->enableLongSampleTime = false;
config->clockDivider = kADC_ClockDivider1;
config->ResolutionMode = kADC_Resolution8BitMode;
config->clockSource = kADC_ClockSourceAlt0;

Parameters:
  • config – Pointer to the configuration structure.

static inline void ADC_EnableHardwareTrigger(ADC_Type *base, bool enable)

Enable the hardware trigger mode.

Parameters:
  • base – ADC peripheral base address.

  • enable – Switcher of the hardware trigger feature. “true” means enabled, “false” means not enabled.

void ADC_SetHardwareCompare(ADC_Type *base, const adc_hardware_compare_config_t *config)

Configure the hardware compare mode.

The compare function can be configured to check for an upper or lower limit. After the input is sampled and converted, the result is added to the complement of the compare value (ADC_CV).

Parameters:
  • base – ADC peripheral base address.

  • config – Pointer to “adc_hardware_compare_config_t” structure.

void ADC_SetFifoConfig(ADC_Type *base, const adc_fifo_config_t *config)

Configure the Fifo mode.

The ADC module supports FIFO operation to minimize the interrupts to CPU in order to reduce CPU loading in ADC interrupt service routines. This module contains two FIFOs to buffer analog input channels and analog results respectively.

Parameters:
  • base – ADC peripheral base address.

  • config – Pointer to “adc_fifo_config_t” structure.

void ADC_GetDefaultFIFOConfig(adc_fifo_config_t *config)

Gets an available pre-defined settings for the FIFO’s configuration.

Parameters:
  • config – Pointer to the FIFO configuration structure, please refer to adc_fifo_config_t for details.

void ADC_SetChannelConfig(ADC_Type *base, const adc_channel_config_t *config)

Configures the conversion channel.

This operation triggers the conversion when in software trigger mode. When in hardware trigger mode, this API configures the channel while the external trigger source helps to trigger the conversion.

Parameters:
  • base – ADC peripheral base address.

  • config – Pointer to “adc_channel_config_t” structure.

bool ADC_GetChannelStatusFlags(ADC_Type *base)

Get the status flags of channel.

Parameters:
  • base – ADC peripheral base address.

Returns:

“True” means conversion has completed and “false” means conversion has not completed.

uint32_t ADC_GetStatusFlags(ADC_Type *base)

Get the ADC status flags.

Parameters:
  • base – ADC peripheral base address.

Returns:

Flags’ mask if indicated flags are asserted. See “_adc_status_flags”.

static inline void ADC_EnableAnalogInput(ADC_Type *base, uint32_t mask, bool enable)

Disables the I/O port control of the pins used as analog inputs.

When a pin control register bit is set, the following conditions are forced for the associated MCU pin: -The output buffer is forced to its high impedance state. -The input buffer is disabled. A read of the I/O port returns a zero for any pin with its input buffer disabled. -The pullup is disabled.

Parameters:
  • base – ADC peripheral base address.

  • mask – The mask of the pin associated with channel ADx. Valid range is AD0:0x1U ~ AD15:0x8000U. For example: If enable AD0, AD1 and AD2 pins, mask should be set to 0x7U.

  • enable – The “true” means enabled, “false” means not enabled.

static inline uint32_t ADC_GetChannelConversionValue(ADC_Type *base)

Gets the conversion value.

Parameters:
  • base – ADC peripheral base address.

Returns:

Conversion value.

static inline void ADC_SetHardwareTriggerMaskMode(ADC_Type *base, adc_hardware_trigger_mask_mode_t mode)
enum _adc_reference_voltage_source

Reference voltage source.

Values:

enumerator kADC_ReferenceVoltageSourceAlt0

Default voltage reference pin pair (VREFH/VREFL). >

enumerator kADC_ReferenceVoltageSourceAlt1

Analog supply pin pair (VDDA/VSSA). >

enum _adc_clock_divider

Clock divider for the converter.

Values:

enumerator kADC_ClockDivider1

Divide ration = 1, and clock rate = Input clock. >

enumerator kADC_ClockDivider2

Divide ration = 2, and clock rate = Input clock / 2. >

enumerator kADC_ClockDivider4

Divide ration = 3, and clock rate = Input clock / 4. >

enumerator kADC_ClockDivider8

Divide ration = 4, and clock rate = Input clock / 8. >

enum _adc_resolution_mode

ADC converter resolution mode.

Values:

enumerator kADC_Resolution8BitMode

8-bit conversion (N = 8). >

enumerator kADC_Resolution10BitMode

10-bit conversion (N = 10) >

enumerator kADC_Resolution12BitMode

12-bit conversion (N = 12) >

enum _adc_clock_source

ADC input Clock source.

Values:

enumerator kADC_ClockSourceAlt0

Bus clock. >

enumerator kADC_ClockSourceAlt1

Bus clock divided by 2. >

enumerator kADC_ClockSourceAlt2

Alternate clock (ALTCLK). >

enumerator kADC_ClockSourceAlt3

Asynchronous clock (ADACK). >

enum _adc_compare_mode

Compare function mode.

Values:

enumerator kADC_CompareDisableMode

Compare function disabled. >

enumerator kADC_CompareLessMode

Compare triggers when input is less than compare level. >

enumerator kADC_CompareGreaterOrEqualMode

Compare triggers when input is greater than or equal to compare level. >

enum _adc_status_flags

ADC status flags mask.

Values:

enumerator kADC_ActiveFlag

Indicates that a conversion is in progress. >

enumerator kADC_FifoEmptyFlag

Indicates that ADC result FIFO have no valid new data. >

enumerator kADC_FifoFullFlag

Indicates that ADC result FIFO is full. >

enum _adc_hardware_trigger_mask_mode

Hardware tigger mask mode.

Values:

enumerator kADC_HWTriggerMaskDisableMode

Hardware trigger mask disable and hardware trigger can trigger ADC conversion. >

enumerator kADC_HWTriggerMaskAutoMode

Hardware trigger mask automatically when data fifo is not empty. >

enumerator kADC_HWTriggerMaskEnableMode

Hardware trigger mask enable and hardware trigger cannot trigger ADC conversion. >

typedef enum _adc_reference_voltage_source adc_reference_voltage_source_t

Reference voltage source.

typedef enum _adc_clock_divider adc_clock_divider_t

Clock divider for the converter.

typedef enum _adc_resolution_mode adc_resolution_mode_t

ADC converter resolution mode.

typedef enum _adc_clock_source adc_clock_source_t

ADC input Clock source.

typedef enum _adc_compare_mode adc_compare_mode_t

Compare function mode.

typedef enum _adc_hardware_trigger_mask_mode adc_hardware_trigger_mask_mode_t

Hardware tigger mask mode.

typedef struct _adc_config adc_config_t

ADC converter configuration.

typedef struct _adc_hardware_compare_config adc_hardware_compare_config_t

ADC hardware comparison configuration.

typedef struct _adc_fifo_config adc_fifo_config_t

ADC FIFO configuration.

typedef struct _adc_channel_config adc_channel_config_t

ADC channel conversion configuration.

FSL_ADC_DRIVER_VERSION

ADC driver version.

Version 2.1.0.

struct _adc_config
#include <fsl_adc.h>

ADC converter configuration.

Public Members

adc_reference_voltage_source_t referenceVoltageSource

Selects the voltage reference source used for conversions. >

bool enableLowPower

Enable low power mode. The power is reduced at the expense of maximum clock speed. >

bool enableLongSampleTime

Enable long sample time mode. >

adc_clock_divider_t clockDivider

Select the divider of input clock source. >

adc_resolution_mode_t ResolutionMode

Select the sample resolution mode. >

adc_clock_source_t clockSource

Select the input Clock source. >

struct _adc_hardware_compare_config
#include <fsl_adc.h>

ADC hardware comparison configuration.

Public Members

uint32_t compareValue

Setting the compare value. The value are compared to the conversion result. >

adc_compare_mode_t compareMode

Setting the compare mode. Refer to “adc_compare_mode_t”. >

struct _adc_fifo_config
#include <fsl_adc.h>

ADC FIFO configuration.

Public Members

bool enableHWTriggerMultConv

The field is valid when FIFO is enabled.Enable hardware trigger multiple conversion. One hardware trigger pulse triggers multiple conversions in fifo mode. >

bool enableFifoScanMode

The field is valid when FIFO is enabled. Enable the FIFO scan mode. If enable, ADC will repeat using the first FIFO channel as the conversion channel until the result FIFO is fulfilled. >

bool enableCompareAndMode

The field is valid when FIFO is enabled. If enable, ADC will AND all of compare triggers and set COCO after all of compare triggers occur. If disable, ADC will OR all of compare triggers and set COCO after at least one of compare trigger occurs. >

uint32_t FifoDepth

Setting the depth of FIFO. Depth of fifo is FifoDepth + 1. When FifoDepth = 0U, the FIFO is DISABLED. When FifoDepth is set to nonzero, the FIFO function is ENABLED and the depth is indicated by the FifoDepth field. >

struct _adc_channel_config
#include <fsl_adc.h>

ADC channel conversion configuration.

Public Members

uint32_t channelNumber

Setting the conversion channel number. The available range is 0-31. See channel connection information for each chip in Reference Manual document.

bool enableContinuousConversion

enables continuous conversions. >

bool enableInterruptOnConversionCompleted

Generate an interrupt request once the conversion is completed.

Clock Driver

enum _clock_name

Clock name used to get clock frequency.

Values:

enumerator kCLOCK_CoreSysClk

Core/system clock

enumerator kCLOCK_PlatClk

Platform clock

enumerator kCLOCK_BusClk

Bus clock

enumerator kCLOCK_FlashClk

Flash clock

enumerator kCLOCK_Osc0ErClk

OSC0 external reference clock (OSC0ERCLK)

enumerator kCLOCK_ICSFixedFreqClk

ICS fixed frequency clock (ICSFFCLK)

enumerator kCLOCK_ICSInternalRefClk

ICS internal reference clock (ICSIRCLK)

enumerator kCLOCK_ICSFllClk

ICSFLLCLK

enumerator kCLOCK_ICSOutClk

ICS Output clock

enumerator kCLOCK_LpoClk

LPO clock

enum _clock_ip_name

Clock gate name used for CLOCK_EnableClock/CLOCK_DisableClock.

Values:

enumerator kCLOCK_IpInvalid
enumerator kCLOCK_I2c0
enumerator kCLOCK_Uart0
enumerator kCLOCK_Uart1
enumerator kCLOCK_Uart2
enumerator kCLOCK_Acmp0
enumerator kCLOCK_Acmp1
enumerator kCLOCK_Spi0
enumerator kCLOCK_Spi1
enumerator kCLOCK_Irq0
enumerator kCLOCK_Kbi0
enumerator kCLOCK_Kbi1
enumerator kCLOCK_Adc0
enumerator kCLOCK_Crc0
enumerator kCLOCK_Ftm0
enumerator kCLOCK_Ftm1
enumerator kCLOCK_Ftm2
enumerator kCLOCK_Pit0
enumerator kCLOCK_Rtc0
enum _osc_work_mode

OSC work mode.

Values:

enumerator kOSC_ModeExt

OSC source from external clock.

enumerator kOSC_ModeOscLowPower

Oscillator low freq low power.

enumerator kOSC_ModeOscHighGain

Oscillator low freq high gain.

enum _osc_enable_mode

OSC enable mode.

Values:

enumerator kOSC_Enable

Enable.

enumerator kOSC_EnableInStop

Enable in stop mode.

enum _ics_fll_src

ICS FLL reference clock source select.

Values:

enumerator kICS_FllSrcExternal

External reference clock is selected

enumerator kICS_FllSrcInternal

The slow internal reference clock is selected

enum _ics_clkout_src

ICSOUT clock source.

Values:

enumerator kICS_ClkOutSrcFll

Output of the FLL is selected (reset default)

enumerator kICS_ClkOutSrcInternal

Internal reference clock is selected, FLL is bypassed

enumerator kICS_ClkOutSrcExternal

External reference clock is selected, FLL is bypassed

ICS status. .

Values:

enumerator kStatus_ICS_ModeUnreachable

Can’t switch to target mode.

enumerator kStatus_ICS_SourceUsed

Can’t change the clock source because it is in use.

enum _ics_irclk_enable_mode

ICS internal reference clock (ICSIRCLK) enable mode definition.

Values:

enumerator kICS_IrclkDisable

ICSIRCLK disable.

enumerator kICS_IrclkEnable

ICSIRCLK enable.

enumerator kICS_IrclkEnableInStop

ICSIRCLK enable in stop mode.

enum _ics_mode

ICS mode definitions.

Values:

enumerator kICS_ModeFEI

FEI - FLL Engaged Internal

enumerator kICS_ModeFBI

FBI - FLL Bypassed Internal

enumerator kICS_ModeBILP

BILP - Bypassed Low Power Internal

enumerator kICS_ModeFEE

FEE - FLL Engaged External

enumerator kICS_ModeFBE

FBE - FLL Bypassed External

enumerator kICS_ModeBELP

BELP - Bypassed Low Power External

enumerator kICS_ModeError

Unknown mode

typedef enum _clock_name clock_name_t

Clock name used to get clock frequency.

typedef enum _clock_ip_name clock_ip_name_t

Clock gate name used for CLOCK_EnableClock/CLOCK_DisableClock.

typedef struct _sim_clock_config sim_clock_config_t

SIM configuration structure for clock setting.

typedef struct _osc_config osc_config_t

OSC Initialization Configuration Structure.

Defines the configuration data structure to initialize the OSC. When porting to a new board, set the following members according to the board setting:

  1. freq: The external frequency.

  2. workMode: The OSC module mode.

  3. enableMode: The OSC enable mode.

typedef enum _ics_fll_src ics_fll_src_t

ICS FLL reference clock source select.

typedef enum _ics_clkout_src ics_clkout_src_t

ICSOUT clock source.

typedef enum _ics_mode ics_mode_t

ICS mode definitions.

typedef struct _ics_config ics_config_t

ICS configuration structure.

When porting to a new board, set the following members according to the board setting:

  1. icsMode: ICS mode

  2. irClkEnableMode: ICSIRCLK enable mode

  3. rDiv: If the FLL uses the external reference clock, set this value to ensure that the external reference clock divided by rDiv is in the 31.25 kHz to 39.0625 kHz range.

  4. bDiv, this divider determine the ISCOUT clock

volatile uint32_t g_xtal0Freq

External XTAL0 (OSC0) clock frequency.

The XTAL0/EXTAL0 (OSC0) clock frequency in Hz. When the clock is set up, use the function CLOCK_SetXtal0Freq to set the value in the clock driver. For example, if XTAL0 is 8 MHz:

CLOCK_InitOsc0(...);
CLOCK_SetXtal0Freq(80000000)

This is important for the multicore platforms where only one core needs to set up the OSC0 using the CLOCK_InitOsc0. All other cores need to call the CLOCK_SetXtal0Freq to get a valid clock frequency.

static inline void CLOCK_EnableClock(clock_ip_name_t name)

Enable the clock for specific IP.

Parameters:
  • name – Which clock to enable, see clock_ip_name_t.

static inline void CLOCK_DisableClock(clock_ip_name_t name)

Disable the clock for specific IP.

Parameters:
  • name – Which clock to disable, see clock_ip_name_t.

static inline void CLOCK_SetBusClkDiv(uint32_t busDiv)

clock divider

Set the SIM_BUSDIV. Carefully configure the SIM_BUSDIV to avoid bus/flash clock frequency higher than 24MHZ.

Parameters:
  • busDiv – bus clock output divider value.

uint32_t CLOCK_GetFreq(clock_name_t clockName)

Gets the clock frequency for a specific clock name.

This function checks the current clock configurations and then calculates the clock frequency for a specific clock name defined in clock_name_t. The ICS must be properly configured before using this function.

Parameters:
  • clockName – Clock names defined in clock_name_t

Returns:

Clock frequency value in Hertz

uint32_t CLOCK_GetCoreSysClkFreq(void)

Get the core clock or system clock frequency.

Returns:

Clock frequency in Hz.

uint32_t CLOCK_GetBusClkFreq(void)

Get the bus clock frequency.

Returns:

Clock frequency in Hz.

uint32_t CLOCK_GetFlashClkFreq(void)

Get the flash clock frequency.

Returns:

Clock frequency in Hz.

uint32_t CLOCK_GetOsc0ErClkFreq(void)

Get the OSC0 external reference clock frequency (OSC0ERCLK).

Returns:

Clock frequency in Hz.

void CLOCK_SetSimConfig(sim_clock_config_t const *config)

Set the clock configure in SIM module.

This function sets system layer clock settings in SIM module.

Parameters:
  • config – Pointer to the configure structure.

static inline void CLOCK_SetSimSafeDivs(void)

Set the system clock dividers in SIM to safe value.

The system level clocks (core clock, bus clock, and flash clock) must be in allowed ranges. During ICS clock mode switch, the ICS output clock changes then the system level clocks may be out of range. This function could be used before ICS mode change, to make sure system level clocks are in allowed range.

FSL_CLOCK_DRIVER_VERSION

CLOCK driver version 2.2.3.

SDK_DEVICE_MAXIMUM_CPU_CLOCK_FREQUENCY
UART_CLOCKS

Clock ip name array for UART.

ADC_CLOCKS

Clock ip name array for ADC16.

IRQ_CLOCKS

Clock ip name array for IRQ.

KBI_CLOCKS

Clock ip name array for KBI.

SPI_CLOCKS

Clock ip name array for SPI.

I2C_CLOCKS

Clock ip name array for I2C.

FTM_CLOCKS

Clock ip name array for FTM.

ACMP_CLOCKS

Clock ip name array for CMP.

CRC_CLOCKS

Clock ip name array for CRC.

PIT_CLOCKS

Clock ip name array for PIT.

RTC_CLOCKS

Clock ip name array for RTC.

LPO_CLK_FREQ

LPO clock frequency.

CLK_GATE_REG_OFFSET_SHIFT
CLK_GATE_REG_OFFSET_MASK
CLK_GATE_BIT_SHIFT_SHIFT
CLK_GATE_BIT_SHIFT_MASK
CLK_GATE_DEFINE(reg_offset, bit_shift)
CLK_GATE_ABSTRACT_REG_OFFSET(x)
CLK_GATE_ABSTRACT_BITS_SHIFT(x)
uint32_t CLOCK_GetICSOutClkFreq(void)

Gets the ICS output clock (ICSOUTCLK) frequency.

This function gets the ICS output clock frequency in Hz based on the current ICS register value.

Returns:

The frequency of ICSOUTCLK.

uint32_t CLOCK_GetFllFreq(void)

Gets the ICS FLL clock (ICSFLLCLK) frequency.

This function gets the ICS FLL clock frequency in Hz based on the current ICS register value. The FLL is enabled in FEI/FBI/FEE/FBE mode and disabled in low power state in other modes.

Returns:

The frequency of ICSFLLCLK.

uint32_t CLOCK_GetInternalRefClkFreq(void)

Gets the ICS internal reference clock (ICSIRCLK) frequency.

This function gets the ICS internal reference clock frequency in Hz based on the current ICS register value.

Returns:

The frequency of ICSIRCLK.

uint32_t CLOCK_GetICSFixedFreqClkFreq(void)

Gets the ICS fixed frequency clock (ICSFFCLK) frequency.

This function gets the ICS fixed frequency clock frequency in Hz based on the current ICS register value.

Returns:

The frequency of ICSFFCLK.

static inline void CLOCK_SetLowPowerEnable(bool enable)

Enables or disables the ICS low power.

Enabling the ICS low power disables the PLL and FLL in bypass modes. In other words, in FBE and PBE modes, enabling low power sets the ICS to BELP mode. In FBI and PBI modes, enabling low power sets the ICS to BILP mode. When disabling the ICS low power, the PLL or FLL are enabled based on ICS settings.

Parameters:
  • enable – True to enable ICS low power, false to disable ICS low power.

static inline void CLOCK_SetInternalRefClkConfig(uint8_t enableMode)

Configures the Internal Reference clock (ICSIRCLK).

This function sets the ICSIRCLK base on parameters. This function also sets whether the ICSIRCLK is enabled in stop mode.

Parameters:
  • enableMode – ICSIRCLK enable mode, OR’ed value of _ICS_irclk_enable_mode.

Return values:
  • kStatus_ICS_SourceUsed – Because the internal reference clock is used as a clock source, the configuration should not be changed. Otherwise, a glitch occurs.

  • kStatus_Success – ICSIRCLK configuration finished successfully.

static inline void CLOCK_SetFllExtRefDiv(uint8_t rdiv)

Set the FLL external reference clock divider value.

Sets the FLL external reference clock divider value, the register ICS_C1[RDIV]. Resulting frequency must be in the range 31.25KHZ to 39.0625KHZ.

Parameters:
  • rdiv – The FLL external reference clock divider value, ICS_C1[RDIV].

static inline void CLOCK_SetOsc0MonitorMode(bool enable)

Sets the OSC0 clock monitor mode.

This function sets the OSC0 clock monitor mode. See ics_monitor_mode_t for details.

Parameters:
  • enable – True to enable clock monitor, false to disable clock monitor.

void CLOCK_InitOsc0(osc_config_t const *config)

Initializes the OSC0.

This function initializes the OSC0 according to the board configuration.

Parameters:
  • config – Pointer to the OSC0 configuration structure.

void CLOCK_DeinitOsc0(void)

Deinitializes the OSC0.

This function deinitializes the OSC0.

static inline void CLOCK_SetXtal0Freq(uint32_t freq)

Sets the XTAL0 frequency based on board settings.

Parameters:
  • freq – The XTAL0/EXTAL0 input clock frequency in Hz.

static inline void CLOCK_SetOsc0Enable(uint8_t enable)

Sets the OSC enable.

Parameters:
  • enable – osc enable mode.

ics_mode_t CLOCK_GetMode(void)

Gets the current ICS mode.

This function checks the ICS registers and determines the current ICS mode.

Returns:

Current ICS mode or error code; See ics_mode_t.

status_t CLOCK_SetFeiMode(uint8_t bDiv)

Sets the ICS to FEI mode.

This function sets the ICS to FEI mode. If setting to FEI mode fails from the current mode, this function returns an error.

Parameters:
  • bDiv – bus clock divider

Return values:
  • kStatus_ICS_ModeUnreachable – Could not switch to the target mode.

  • kStatus_Success – Switched to the target mode successfully.

status_t CLOCK_SetFeeMode(uint8_t bDiv, uint8_t rDiv)

Sets the ICS to FEE mode.

This function sets the ICS to FEE mode. If setting to FEE mode fails from the current mode, this function returns an error.

Parameters:
  • bDiv – bus clock divider

  • rDiv – FLL reference clock divider setting, RDIV.

Return values:
  • kStatus_ICS_ModeUnreachable – Could not switch to the target mode.

  • kStatus_Success – Switched to the target mode successfully.

status_t CLOCK_SetFbiMode(uint8_t bDiv)

Sets the ICS to FBI mode.

This function sets the ICS to FBI mode. If setting to FBI mode fails from the current mode, this function returns an error.

Parameters:
  • bDiv – bus clock divider

Return values:
  • kStatus_ICS_ModeUnreachable – Could not switch to the target mode.

  • kStatus_Success – Switched to the target mode successfully.s

status_t CLOCK_SetFbeMode(uint8_t bDiv, uint8_t rDiv)

Sets the ICS to FBE mode.

This function sets the ICS to FBE mode. If setting to FBE mode fails from the current mode, this function returns an error.

Parameters:
  • bDiv – bus clock divider

  • rDiv – FLL reference clock divider setting, RDIV.

Return values:
  • kStatus_ICS_ModeUnreachable – Could not switch to the target mode.

  • kStatus_Success – Switched to the target mode successfully.

status_t CLOCK_SetBilpMode(uint8_t bDiv)

Sets the ICS to BILP mode.

This function sets the ICS to BILP mode. If setting to BILP mode fails from the current mode, this function returns an error.

Parameters:
  • bDiv – bus clock divider

Return values:
  • kStatus_ICS_ModeUnreachable – Could not switch to the target mode.

  • kStatus_Success – Switched to the target mode successfully.

status_t CLOCK_SetBelpMode(uint8_t bDiv)

Sets the ICS to BELP mode.

This function sets the ICS to BELP mode. If setting to BELP mode fails from the current mode, this function returns an error.

Parameters:
  • bDiv – bus clock divider

Return values:
  • kStatus_ICS_ModeUnreachable – Could not switch to the target mode.

  • kStatus_Success – Switched to the target mode successfully.

status_t CLOCK_BootToFeiMode(uint8_t bDiv)

Sets the ICS to FEI mode during system boot up.

This function sets the ICS to FEI mode from the reset mode. It can also be used to set up ICS during system boot up.

Parameters:
  • bDiv – bus clock divider.

Return values:
  • kStatus_ICS_ModeUnreachable – Could not switch to the target mode.

  • kStatus_Success – Switched to the target mode successfully.

status_t CLOCK_BootToFeeMode(uint8_t bDiv, uint8_t rDiv)

Sets the ICS to FEE mode during system bootup.

This function sets ICS to FEE mode from the reset mode. It can also be used to set up the ICS during system boot up.

Parameters:
  • bDiv – bus clock divider.

  • rDiv – FLL reference clock divider setting, RDIV.

Return values:
  • kStatus_ICS_ModeUnreachable – Could not switch to the target mode.

  • kStatus_Success – Switched to the target mode successfully.

status_t CLOCK_BootToBilpMode(uint8_t bDiv)

Sets the ICS to BILP mode during system boot up.

This function sets the ICS to BILP mode from the reset mode. It can also be used to set up the ICS during system boot up.

Parameters:
  • bDiv – bus clock divider.

Return values:
  • kStatus_ICS_SourceUsed – Could not change ICSIRCLK setting.

  • kStatus_Success – Switched to the target mode successfully.

status_t CLOCK_BootToBelpMode(uint8_t bDiv)

Sets the ICS to BELP mode during system boot up.

This function sets the ICS to BELP mode from the reset mode. It can also be used to set up the ICS during system boot up.

Parameters:
  • bDiv – bus clock divider.

Return values:
  • kStatus_ICS_ModeUnreachable – Could not switch to the target mode.

  • kStatus_Success – Switched to the target mode successfully.

status_t CLOCK_SetIcsConfig(ics_config_t const *config)

Sets the ICS to a target mode.

This function sets ICS to a target mode defined by the configuration structure. If switching to the target mode fails, this function chooses the correct path.

Note

If the external clock is used in the target mode, ensure that it is enabled. For example, if the OSC0 is used, set up OSC0 correctly before calling this function.

Parameters:
  • config – Pointer to the target ICS mode configuration structure.

Returns:

Return kStatus_Success if switched successfully; Otherwise, it returns an error code _ICS_status.

uint32_t busDiv

SIM_BUSDIV.

uint8_t busClkPrescaler

A option prescaler for bus clock

uint32_t freq

External clock frequency.

uint8_t workMode

OSC work mode setting.

uint8_t enableMode

Configuration for OSCERCLK.

ics_mode_t icsMode

ICS mode.

uint8_t irClkEnableMode

ICSIRCLK enable mode.

uint8_t rDiv

Divider for external reference clock, ICS_C1[RDIV].

uint8_t bDiv

Divider for ICS output clock ICS_C2[BDIV].

ICS_CONFIG_CHECK_PARAM

Configures whether to check a parameter in a function.

Some ICS settings must be changed with conditions, for example:

  1. ICSIRCLK settings, such as the source, divider, and the trim value should not change when ICSIRCLK is used as a system clock source.

  2. ICS_C7[OSCSEL] should not be changed when the external reference clock is used as a system clock source. For example, in FBE/BELP/PBE modes.

  3. The users should only switch between the supported clock modes.

ICS functions check the parameter and ICS status before setting, if not allowed to change, the functions return error. The parameter checking increases code size, if code size is a critical requirement, change ICS_CONFIG_CHECK_PARAM to 0 to disable parameter checking.

FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL

Configure whether driver controls clock.

When set to 0, peripheral drivers will enable clock in initialize function and disable clock in de-initialize function. When set to 1, peripheral driver will not control the clock, application could control the clock out of the driver.

Note

All drivers share this feature switcher. If it is set to 1, application should handle clock enable and disable for all drivers.

struct _sim_clock_config
#include <fsl_clock.h>

SIM configuration structure for clock setting.

struct _osc_config
#include <fsl_clock.h>

OSC Initialization Configuration Structure.

Defines the configuration data structure to initialize the OSC. When porting to a new board, set the following members according to the board setting:

  1. freq: The external frequency.

  2. workMode: The OSC module mode.

  3. enableMode: The OSC enable mode.

struct _ics_config
#include <fsl_clock.h>

ICS configuration structure.

When porting to a new board, set the following members according to the board setting:

  1. icsMode: ICS mode

  2. irClkEnableMode: ICSIRCLK enable mode

  3. rDiv: If the FLL uses the external reference clock, set this value to ensure that the external reference clock divided by rDiv is in the 31.25 kHz to 39.0625 kHz range.

  4. bDiv, this divider determine the ISCOUT clock

CRC: Cyclic Redundancy Check Driver

FSL_CRC_DRIVER_VERSION

CRC driver version. Version 2.0.4.

Current version: 2.0.4

Change log:

  • Version 2.0.4

    • Release peripheral from reset if necessary in init function.

  • Version 2.0.3

    • Fix MISRA issues

  • Version 2.0.2

    • Fix MISRA issues

  • Version 2.0.1

    • move DATA and DATALL macro definition from header file to source file

enum _crc_bits

CRC bit width.

Values:

enumerator kCrcBits16

Generate 16-bit CRC code

enumerator kCrcBits32

Generate 32-bit CRC code

enum _crc_result

CRC result type.

Values:

enumerator kCrcFinalChecksum

CRC data register read value is the final checksum. Reflect out and final xor protocol features are applied.

enumerator kCrcIntermediateChecksum

CRC data register read value is intermediate checksum (raw value). Reflect out and final xor protocol feature are not applied. Intermediate checksum can be used as a seed for CRC_Init() to continue adding data to this checksum.

typedef enum _crc_bits crc_bits_t

CRC bit width.

typedef enum _crc_result crc_result_t

CRC result type.

typedef struct _crc_config crc_config_t

CRC protocol configuration.

This structure holds the configuration for the CRC protocol.

void CRC_Init(CRC_Type *base, const crc_config_t *config)

Enables and configures the CRC peripheral module.

This function enables the clock gate in the SIM module for the CRC peripheral. It also configures the CRC module and starts a checksum computation by writing the seed.

Parameters:
  • base – CRC peripheral address.

  • config – CRC module configuration structure.

static inline void CRC_Deinit(CRC_Type *base)

Disables the CRC peripheral module.

This function disables the clock gate in the SIM module for the CRC peripheral.

Parameters:
  • base – CRC peripheral address.

void CRC_GetDefaultConfig(crc_config_t *config)

Loads default values to the CRC protocol configuration structure.

Loads default values to the CRC protocol configuration structure. The default values are as follows.

config->polynomial = 0x1021;
config->seed = 0xFFFF;
config->reflectIn = false;
config->reflectOut = false;
config->complementChecksum = false;
config->crcBits = kCrcBits16;
config->crcResult = kCrcFinalChecksum;

Parameters:
  • config – CRC protocol configuration structure.

void CRC_WriteData(CRC_Type *base, const uint8_t *data, size_t dataSize)

Writes data to the CRC module.

Writes input data buffer bytes to the CRC data register. The configured type of transpose is applied.

Parameters:
  • base – CRC peripheral address.

  • data – Input data stream, MSByte in data[0].

  • dataSize – Size in bytes of the input data buffer.

uint32_t CRC_Get32bitResult(CRC_Type *base)

Reads the 32-bit checksum from the CRC module.

Reads the CRC data register (either an intermediate or the final checksum). The configured type of transpose and complement is applied.

Parameters:
  • base – CRC peripheral address.

Returns:

An intermediate or the final 32-bit checksum, after configured transpose and complement operations.

uint16_t CRC_Get16bitResult(CRC_Type *base)

Reads a 16-bit checksum from the CRC module.

Reads the CRC data register (either an intermediate or the final checksum). The configured type of transpose and complement is applied.

Parameters:
  • base – CRC peripheral address.

Returns:

An intermediate or the final 16-bit checksum, after configured transpose and complement operations.

CRC_DRIVER_USE_CRC16_CCIT_FALSE_AS_DEFAULT

Default configuration structure filled by CRC_GetDefaultConfig(). Use CRC16-CCIT-FALSE as defeault.

struct _crc_config
#include <fsl_crc.h>

CRC protocol configuration.

This structure holds the configuration for the CRC protocol.

Public Members

uint32_t polynomial

CRC Polynomial, MSBit first. Example polynomial: 0x1021 = 1_0000_0010_0001 = x^12+x^5+1

uint32_t seed

Starting checksum value

bool reflectIn

Reflect bits on input.

bool reflectOut

Reflect bits on output.

bool complementChecksum

True if the result shall be complement of the actual checksum.

crc_bits_t crcBits

Selects 16- or 32- bit CRC protocol.

crc_result_t crcResult

Selects final or intermediate checksum return from CRC_Get16bitResult() or CRC_Get32bitResult()

FGPIO Driver

void FGPIO_PortInit(gpio_port_num_t port)

Initializes the FGPIO peripheral.

This function ungates the FGPIO clock.

Parameters:
  • port – FGPIO PORT number, see “gpio_port_num_t”. For each group FGPIO (FGPIOA, FGPIOB,etc) control registers, they handles four PORT number controls. FGPIOA serial registers –&#8212; PTA 0 ~ 7, PTB 0 ~7 … PTD 0 ~ 7. FGPIOB serial registers –&#8212; PTE 0 ~ 7, PTF 0 ~7 … PTH 0 ~ 7. …

void FGPIO_PinInit(gpio_port_num_t port, uint8_t pin, const gpio_pin_config_t *config)

Initializes a FGPIO pin used by the board.

To initialize the FGPIO driver, define a pin configuration, as either input or output, in the user file. Then, call the FGPIO_PinInit() function.

This is an example to define an input pin or an output pin configuration:

Define a digital input pin configuration,
gpio_pin_config_t config =
{
  kGPIO_DigitalInput,
  0,
}
Define a digital output pin configuration,
gpio_pin_config_t config =
{
  kGPIO_DigitalOutput,
  0,
}

Parameters:
  • port – FGPIO PORT number, see “gpio_port_num_t”. For each group FGPIO (FGPIOA, FGPIOB,etc) control registers, they handles four PORT number controls. FGPIOA serial registers –&#8212; PTA 0 ~ 7, PTB 0 ~7 … PTD 0 ~ 7. FGPIOB serial registers –&#8212; PTE 0 ~ 7, PTF 0 ~7 … PTH 0 ~ 7. …

  • pin – FGPIO port pin number

  • config – FGPIO pin configuration pointer

void FGPIO_PinWrite(gpio_port_num_t port, uint8_t pin, uint8_t output)

Sets the output level of the multiple FGPIO pins to the logic 1 or 0.

Parameters:
  • port – FGPIO PORT number, see “gpio_port_num_t”. For each group FGPIO (FGPIOA, FGPIOB,etc) control registers, they handles four PORT number controls. FGPIOA serial registers –&#8212; PTA 0 ~ 7, PTB 0 ~7 … PTD 0 ~ 7. FGPIOB serial registers –&#8212; PTE 0 ~ 7, PTF 0 ~7 … PTH 0 ~ 7. …

  • pin – FGPIO pin number

  • output – FGPIOpin output logic level.

    • 0: corresponding pin output low-logic level.

    • 1: corresponding pin output high-logic level.

void FGPIO_PortSet(gpio_port_num_t port, uint8_t mask)

Sets the output level of the multiple FGPIO pins to the logic 1.

Parameters:
  • port – FGPIO PORT number, see “gpio_port_num_t”. For each group FGPIO (FGPIOA, FGPIOB,etc) control registers, they handles four PORT number controls. FGPIOA serial registers –&#8212; PTA 0 ~ 7, PTB 0 ~7 … PTD 0 ~ 7. FGPIOB serial registers –&#8212; PTE 0 ~ 7, PTF 0 ~7 … PTH 0 ~ 7. …

  • mask – FGPIO pin number macro

void FGPIO_PortClear(gpio_port_num_t port, uint8_t mask)

Sets the output level of the multiple FGPIO pins to the logic 0.

Parameters:
  • port – FGPIO PORT number, see “gpio_port_num_t”. For each group FGPIO (FGPIOA, FGPIOB,etc) control registers, they handles four PORT number controls. FGPIOA serial registers –&#8212; PTA 0 ~ 7, PTB 0 ~7 … PTD 0 ~ 7. FGPIOB serial registers –&#8212; PTE 0 ~ 7, PTF 0 ~7 … PTH 0 ~ 7. …

  • mask – FGPIO pin number macro

void FGPIO_PortToggle(gpio_port_num_t port, uint8_t mask)

Reverses the current output logic of the multiple FGPIO pins.

Parameters:
  • port – FGPIO PORT number, see “gpio_port_num_t”. For each group FGPIO (FGPIOA, FGPIOB,etc) control registers, they handles four PORT number controls. FGPIOA serial registers –&#8212; PTA 0 ~ 7, PTB 0 ~7 … PTD 0 ~ 7. FGPIOB serial registers –&#8212; PTE 0 ~ 7, PTF 0 ~7 … PTH 0 ~ 7. …

  • mask – FGPIO pin number macro

uint32_t FGPIO_PinRead(gpio_port_num_t port, uint8_t pin)

Reads the current input value of the FGPIO port.

Parameters:
  • port – FGPIO PORT number, see “gpio_port_num_t”. For each group FGPIO (FGPIOA, FGPIOB,etc) control registers, they handles four PORT number controls. FGPIOA serial registers –&#8212; PTA 0 ~ 7, PTB 0 ~7 … PTD 0 ~ 7. FGPIOB serial registers –&#8212; PTE 0 ~ 7, PTF 0 ~7 … PTH 0 ~ 7. …

  • pin – FGPIO pin number

Return values:

FGPIO – port input value

  • 0: corresponding pin input low-logic level.

  • 1: corresponding pin input high-logic level.

FTMRx Flash Driver

enum _flash_driver_version_constants

Flash driver version for ROM.

Values:

enumerator kFLASH_DriverVersionName

Flash driver version name.

enumerator kFLASH_DriverVersionMajor

Major flash driver version.

enumerator kFLASH_DriverVersionMinor

Minor flash driver version.

enumerator kFLASH_DriverVersionBugfix

Bugfix for flash driver version.

MAKE_VERSION(major, minor, bugfix)

Constructs the version number for drivers.

FSL_FLASH_DRIVER_VERSION

Flash driver version for SDK.

Version 2.1.2.

Flash driver status codes.

Values:

enumerator kStatus_FLASH_Success

API is executed successfully

enumerator kStatus_FLASH_InvalidArgument

Invalid argument

enumerator kStatus_FLASH_SizeError

Error size

enumerator kStatus_FLASH_AlignmentError

Parameter is not aligned with the specified baseline

enumerator kStatus_FLASH_AddressError

Address is out of range

enumerator kStatus_FLASH_AccessError

Invalid instruction codes and out-of bound addresses

enumerator kStatus_FLASH_ProtectionViolation

The program/erase operation is requested to execute on protected areas

enumerator kStatus_FLASH_CommandFailure

Run-time error during command execution.

enumerator kStatus_FLASH_UnknownProperty

Unknown property.

enumerator kStatus_FLASH_EraseKeyError

API erase key is invalid.

enumerator kStatus_FLASH_RegionExecuteOnly

The current region is execute-only.

enumerator kStatus_FLASH_ExecuteInRamFunctionNotReady

Execute-in-RAM function is not available.

enumerator kStatus_FLASH_PartitionStatusUpdateFailure

Failed to update partition status.

enumerator kStatus_FLASH_SetFlexramAsEepromError

Failed to set FlexRAM as EEPROM.

enumerator kStatus_FLASH_RecoverFlexramAsRamError

Failed to recover FlexRAM as RAM.

enumerator kStatus_FLASH_SetFlexramAsRamError

Failed to set FlexRAM as RAM.

enumerator kStatus_FLASH_RecoverFlexramAsEepromError

Failed to recover FlexRAM as EEPROM.

enumerator kStatus_FLASH_CommandNotSupported

Flash API is not supported.

enumerator kStatus_FLASH_SwapSystemNotInUninitialized

Swap system is not in an uninitialzed state.

enumerator kStatus_FLASH_SwapIndicatorAddressError

The swap indicator address is invalid.

enumerator kStatus_FLASH_ReadOnlyProperty

The flash property is read-only.

enumerator kStatus_FLASH_InvalidPropertyValue

The flash property value is out of range.

enumerator kStatus_FLASH_InvalidSpeculationOption

The option of flash prefetch speculation is invalid.

enumerator kStatus_FLASH_ClockDivider

Flash clock prescaler is wrong

enumerator kStatus_FLASH_EepromDoubleBitFault

A double bit fault was detected in the stored parity.

enumerator kStatus_FLASH_EepromSingleBitFault

A single bit fault was detected in the stored parity.

kStatusGroupGeneric

Flash driver status group.

kStatusGroupFlashDriver
MAKE_STATUS(group, code)

Constructs a status code value from a group and a code number.

enum _flash_driver_api_keys

Enumeration for Flash driver API keys.

Note

The resulting value is built with a byte order such that the string being readable in expected order when viewed in a hex editor, if the value is treated as a 32-bit little endian value.

Values:

enumerator kFLASH_ApiEraseKey

Key value used to validate all flash erase APIs.

FOUR_CHAR_CODE(a, b, c, d)

Constructs the four character code for the Flash driver API key.

status_t FLASH_Init(flash_config_t *config)

Initializes the global flash properties structure members.

This function checks and initializes the Flash module for the other Flash APIs.

Parameters:
  • config – Pointer to the storage for the driver runtime state.

Return values:
  • kStatus_FLASH_Success – API was executed successfully.

  • kStatus_FLASH_InvalidArgument – An invalid argument is provided.

  • kStatus_FLASH_ClockDivider – Flash clock prescaler is wrong.

  • kStatus_FLASH_ExecuteInRamFunctionNotReady – Execute-in-RAM function is not available.

status_t FLASH_SetCallback(flash_config_t *config, flash_callback_t callback)

Sets the desired flash callback function.

Parameters:
  • config – Pointer to the storage for the driver runtime state.

  • callback – A callback function to be stored in the driver.

Return values:
  • kStatus_FLASH_Success – API was executed successfully.

  • kStatus_FLASH_InvalidArgument – An invalid argument is provided.

status_t FLASH_PrepareExecuteInRamFunctions(flash_config_t *config)

Prepares flash execute-in-RAM functions.

Parameters:
  • config – Pointer to the storage for the driver runtime state.

Return values:
  • kStatus_FLASH_Success – API was executed successfully.

  • kStatus_FLASH_InvalidArgument – An invalid argument is provided.

status_t FLASH_EraseAll(flash_config_t *config, uint32_t key)

Erases entire flash.

Parameters:
  • config – Pointer to the storage for the driver runtime state.

  • key – A value used to validate all flash erase APIs.

Return values:
  • kStatus_FLASH_Success – API was executed successfully.

  • kStatus_FLASH_InvalidArgument – An invalid argument is provided.

  • kStatus_FLASH_EraseKeyError – API erase key is invalid.

  • kStatus_FLASH_ExecuteInRamFunctionNotReady – Execute-in-RAM function is not available.

  • kStatus_FLASH_AccessError – Invalid instruction codes and out-of bounds addresses.

  • kStatus_FLASH_ProtectionViolation – The program/erase operation is requested to execute on protected areas.

  • kStatus_FLASH_CommandFailure – Run-time error during command execution.

  • kStatus_FLASH_EepromSingleBitFault – EEPROM single bit fault error code.

  • kStatus_FLASH_EepromDoubleBitFault – EEPROM double bit fault error code.

status_t FLASH_Erase(flash_config_t *config, uint32_t start, uint32_t lengthInBytes, uint32_t key)

Erases the flash sectors encompassed by parameters passed into function.

This function erases the appropriate number of flash sectors based on the desired start address and length.

Parameters:
  • config – The pointer to the storage for the driver runtime state.

  • start – The start address of the desired flash memory to be erased. The start address does not need to be sector-aligned but must be word-aligned.

  • lengthInBytes – The length, given in bytes (not words or long-words) to be erased. Must be word-aligned.

  • key – The value used to validate all flash erase APIs.

Return values:
  • kStatus_FLASH_Success – API was executed successfully.

  • kStatus_FLASH_InvalidArgument – An invalid argument is provided.

  • kStatus_FLASH_AlignmentError – The parameter is not aligned with the specified baseline.

  • kStatus_FLASH_AddressError – The address is out of range.

  • kStatus_FLASH_EraseKeyError – The API erase key is invalid.

  • kStatus_FLASH_ExecuteInRamFunctionNotReady – Execute-in-RAM function is not available.

  • kStatus_FLASH_AccessError – Invalid instruction codes and out-of bounds addresses.

  • kStatus_FLASH_ProtectionViolation – The program/erase operation is requested to execute on protected areas.

  • kStatus_FLASH_CommandFailure – Run-time error during the command execution.

status_t FLASH_EraseEEprom(flash_config_t *config, uint32_t start, uint32_t lengthInBytes, uint32_t key)

Erases the eeprom sectors encompassed by parameters passed into function.

This function erases the appropriate number of eeprom sectors based on the desired start address and length.

Parameters:
  • config – The pointer to the storage for the driver runtime state.

  • start – The start address of the desired eeprom memory to be erased. The start address does not need to be sector-aligned but must be word-aligned.

  • lengthInBytes – The length, given in bytes (not words or long-words) to be erased. Must be word-aligned.

  • key – The value used to validate all eeprom erase APIs.

Return values:
  • kStatus_FLASH_Success – API was executed successfully.

  • kStatus_FLASH_InvalidArgument – An invalid argument is provided.

  • kStatus_FLASH_AlignmentError – The parameter is not aligned with the specified baseline.

  • kStatus_FLASH_AddressError – The address is out of range.

  • kStatus_FLASH_EraseKeyError – The API erase key is invalid.

  • kStatus_FLASH_ExecuteInRamFunctionNotReady – Execute-in-RAM function is not available.

  • kStatus_FLASH_AccessError – Invalid instruction codes and out-of bounds addresses.

  • kStatus_FLASH_ProtectionViolation – The program/erase operation is requested to execute on protected areas.

  • kStatus_FLASH_CommandFailure – Run-time error during the command execution.

status_t FLASH_EraseAllUnsecure(flash_config_t *config, uint32_t key)

Erases the entire flash, including protected sectors.

Parameters:
  • config – Pointer to the storage for the driver runtime state.

  • key – A value used to validate all flash erase APIs.

Return values:
  • kStatus_FLASH_Success – API was executed successfully.

  • kStatus_FLASH_InvalidArgument – An invalid argument is provided.

  • kStatus_FLASH_EraseKeyError – API erase key is invalid.

  • kStatus_FLASH_ExecuteInRamFunctionNotReady – Execute-in-RAM function is not available.

  • kStatus_FLASH_AccessError – Invalid instruction codes and out-of bounds addresses.

  • kStatus_FLASH_ProtectionViolation – The program/erase operation is requested to execute on protected areas.

  • kStatus_FLASH_CommandFailure – Run-time error during command execution.

  • kStatus_FLASH_EepromSingleBitFault – EEPROM single bit fault error code.

  • kStatus_FLASH_EepromDoubleBitFault – EEPROM double bit fault error code.

status_t FLASH_Program(flash_config_t *config, uint32_t start, uint32_t *src, uint32_t lengthInBytes)

Programs flash with data at locations passed in through parameters.

This function programs the flash memory with the desired data for a given flash area as determined by the start address and the length.

Parameters:
  • config – A pointer to the storage for the driver runtime state.

  • start – The start address of the desired flash memory to be programmed. Must be word-aligned.

  • src – A pointer to the source buffer of data that is to be programmed into the flash.

  • lengthInBytes – The length, given in bytes (not words or long-words), to be programmed. Must be word-aligned.

Return values:
  • kStatus_FLASH_Success – API was executed successfully.

  • kStatus_FLASH_InvalidArgument – An invalid argument is provided.

  • kStatus_FLASH_AlignmentError – Parameter is not aligned with the specified baseline.

  • kStatus_FLASH_AddressError – Address is out of range.

  • kStatus_FLASH_ExecuteInRamFunctionNotReady – Execute-in-RAM function is not available.

  • kStatus_FLASH_AccessError – Invalid instruction codes and out-of bounds addresses.

  • kStatus_FLASH_ProtectionViolation – The program/erase operation is requested to execute on protected areas.

  • kStatus_FLASH_CommandFailure – Run-time error during the command execution.

status_t FLASH_ProgramOnce(flash_config_t *config, uint32_t index, uint32_t *src, uint32_t lengthInBytes)

Programs Program Once Field through parameters.

This function programs the Program Once Field with the desired data for a given flash area as determined by the index and length.

Parameters:
  • config – A pointer to the storage for the driver runtime state.

  • index – The index indicating which area of the Program Once Field to be programmed.

  • src – A pointer to the source buffer of data that is to be programmed into the Program Once Field.

  • lengthInBytes – The length, given in bytes (not words or long-words), to be programmed. Must be word-aligned.

Return values:
  • kStatus_FLASH_Success – API was executed successfully.

  • kStatus_FLASH_InvalidArgument – An invalid argument is provided.

  • kStatus_FLASH_ExecuteInRamFunctionNotReady – Execute-in-RAM function is not available.

  • kStatus_FLASH_AccessError – Invalid instruction codes and out-of bounds addresses.

  • kStatus_FLASH_ProtectionViolation – The program/erase operation is requested to execute on protected areas.

  • kStatus_FLASH_CommandFailure – Run-time error during the command execution.

status_t FLASH_EepromWrite(flash_config_t *config, uint32_t start, uint8_t *src, uint32_t lengthInBytes)

Programs the EEPROM with data at locations passed in through parameters.

This function programs the emulated EEPROM with the desired data for a given flash area as determined by the start address and length.

Parameters:
  • config – A pointer to the storage for the driver runtime state.

  • start – The start address of the desired flash memory to be programmed. Must be word-aligned.

  • src – A pointer to the source buffer of data that is to be programmed into the flash.

  • lengthInBytes – The length, given in bytes (not words or long-words), to be programmed. Must be word-aligned.

Return values:
  • kStatus_FLASH_Success – API was executed successfully.

  • kStatus_FLASH_InvalidArgument – An invalid argument is provided.

  • kStatus_FLASH_AddressError – Address is out of range.

  • kStatus_FLASH_ProtectionViolation – The program/erase operation is requested to execute on protected areas.

  • kStatus_FLASH_EepromSingleBitFault – EEPROM single bit fault error code.

  • kStatus_FLASH_EepromDoubleBitFault – EEPROM double bit fault error code.

status_t FLASH_ReadOnce(flash_config_t *config, uint32_t index, uint32_t *dst, uint32_t lengthInBytes)

Reads the Program Once Field through parameters.

This function reads the read once feild with given index and length.

Parameters:
  • config – A pointer to the storage for the driver runtime state.

  • index – The index indicating the area of program once field to be read.

  • dst – A pointer to the destination buffer of data that is used to store data to be read.

  • lengthInBytes – The length, given in bytes (not words or long-words), to be programmed. Must be word-aligned.

Return values:
  • kStatus_FLASH_Success – API was executed successfully.

  • kStatus_FLASH_InvalidArgument – An invalid argument is provided.

  • kStatus_FLASH_ExecuteInRamFunctionNotReady – Execute-in-RAM function is not available.

  • kStatus_FLASH_AccessError – Invalid instruction codes and out-of bounds addresses.

  • kStatus_FLASH_ProtectionViolation – The program/erase operation is requested to execute on protected areas.

  • kStatus_FLASH_CommandFailure – Run-time error during the command execution.

status_t FLASH_GetSecurityState(flash_config_t *config, flash_security_state_t *state)

Returns the security state via the pointer passed into the function.

This function retrieves the current flash security status, including the security enabling state and the backdoor key enabling state.

Parameters:
  • config – A pointer to storage for the driver runtime state.

  • state – A pointer to the value returned for the current security status code:

Return values:
  • kStatus_FLASH_Success – API was executed successfully.

  • kStatus_FLASH_InvalidArgument – An invalid argument is provided.

status_t FLASH_SecurityBypass(flash_config_t *config, const uint8_t *backdoorKey)

Allows users to bypass security with a backdoor key.

If the MCU is in secured state, this function unsecures the MCU by comparing the provided backdoor key with ones in the flash configuration field.

Parameters:
  • config – A pointer to the storage for the driver runtime state.

  • backdoorKey – A pointer to the user buffer containing the backdoor key.

Return values:
  • kStatus_FLASH_Success – API was executed successfully.

  • kStatus_FLASH_InvalidArgument – An invalid argument is provided.

  • kStatus_FLASH_ExecuteInRamFunctionNotReady – Execute-in-RAM function is not available.

  • kStatus_FLASH_AccessError – Invalid instruction codes and out-of bounds addresses.

  • kStatus_FLASH_ProtectionViolation – The program/erase operation is requested to execute on protected areas.

  • kStatus_FLASH_CommandFailure – Run-time error during the command execution.

status_t FLASH_VerifyEraseAll(flash_config_t *config, flash_margin_value_t margin)

Verifies erasure of the entire flash at a specified margin level.

This function checks whether the flash is erased to the specified read margin level.

Parameters:
  • config – A pointer to the storage for the driver runtime state.

  • margin – Read margin choice.

Return values:
  • kStatus_FLASH_Success – API was executed successfully.

  • kStatus_FLASH_InvalidArgument – An invalid argument is provided.

  • kStatus_FLASH_ExecuteInRamFunctionNotReady – Execute-in-RAM function is not available.

  • kStatus_FLASH_AccessError – Invalid instruction codes and out-of bounds addresses.

  • kStatus_FLASH_ProtectionViolation – The program/erase operation is requested to execute on protected areas.

  • kStatus_FLASH_CommandFailure – Run-time error during the command execution.

  • kStatus_FLASH_EepromSingleBitFault – EEPROM single bit fault error code.

  • kStatus_FLASH_EepromDoubleBitFault – EEPROM double bit fault error code.

status_t FLASH_VerifyErase(flash_config_t *config, uint32_t start, uint32_t lengthInBytes, flash_margin_value_t margin)

Verifies an erasure of the desired flash area at a specified margin level.

This function checks the appropriate number of flash sectors based on the desired start address and length to check whether the flash is erased to the specified read margin level.

Parameters:
  • config – A pointer to the storage for the driver runtime state.

  • margin – Read margin choice.

  • start – The start address of the desired flash memory to be verified. The start address does not need to be sector-aligned but must be word-aligned.

  • lengthInBytes – The length, given in bytes (not words or long-words), to be verified. Must be word-aligned.

Return values:
  • kStatus_FLASH_Success – API was executed successfully.

  • kStatus_FLASH_InvalidArgument – An invalid argument is provided.

  • kStatus_FLASH_AlignmentError – Parameter is not aligned with specified baseline.

  • kStatus_FLASH_AddressError – Address is out of range.

  • kStatus_FLASH_ExecuteInRamFunctionNotReady – Execute-in-RAM function is not available.

  • kStatus_FLASH_AccessError – Invalid instruction codes and out-of bounds addresses.

  • kStatus_FLASH_ProtectionViolation – The program/erase operation is requested to execute on protected areas.

  • kStatus_FLASH_CommandFailure – Run-time error during the command execution.

status_t FLASH_IsProtected(flash_config_t *config, uint32_t start, uint32_t lengthInBytes, flash_protection_state_t *protection_state)

Returns the protection state of the desired flash area via the pointer passed into the function.

This function retrieves the current flash protect status for a given flash area as determined by the start address and length.

Parameters:
  • config – A pointer to the storage for the driver runtime state.

  • start – The start address of the desired flash memory to be checked. Must be word-aligned.

  • lengthInBytes – The length, given in bytes (not words or long-words) to be checked. Must be word-aligned.

  • protection_state – A pointer to the value returned for the current protection status code for the desired flash area.

Return values:
  • kStatus_FLASH_Success – API was executed successfully.

  • kStatus_FLASH_InvalidArgument – An invalid argument is provided.

  • kStatus_FLASH_AlignmentError – Parameter is not aligned with specified baseline.

  • kStatus_FLASH_AddressError – The address is out of range.

status_t FLASH_GetProperty(flash_config_t *config, flash_property_tag_t whichProperty, uint32_t *value)

Returns the desired flash property.

Parameters:
  • config – A pointer to the storage for the driver runtime state.

  • whichProperty – The desired property from the list of properties in enum flash_property_tag_t

  • value – A pointer to the value returned for the desired flash property.

Return values:
  • kStatus_FLASH_Success – API was executed successfully.

  • kStatus_FLASH_InvalidArgument – An invalid argument is provided.

  • kStatus_FLASH_UnknownProperty – An unknown property tag.

status_t FLASH_SetProperty(flash_config_t *config, flash_property_tag_t whichProperty, uint32_t value)

Sets the desired flash property.

Parameters:
  • config – A pointer to the storage for the driver runtime state.

  • whichProperty – The desired property from the list of properties in enum flash_property_tag_t

  • value – A to set for the desired flash property.

Return values:
  • kStatus_FLASH_Success – API was executed successfully.

  • kStatus_FLASH_InvalidArgument – An invalid argument is provided.

  • kStatus_FLASH_UnknownProperty – An unknown property tag.

  • kStatus_FLASH_InvalidPropertyValue – An invalid property value.

  • kStatus_FLASH_ReadOnlyProperty – An read-only property tag.

status_t FLASH_PflashSetProtection(flash_config_t *config, pflash_protection_status_t *protectStatus)

Sets the PFlash Protection to the intended protection status.

Parameters:
  • config – A pointer to storage for the driver runtime state.

  • protectStatus – The expected protect status to set to the PFlash protection register.

Return values:
  • kStatus_FLASH_Success – API was executed successfully.

  • kStatus_FLASH_InvalidArgument – An invalid argument is provided.

  • kStatus_FLASH_CommandFailure – Run-time error during command execution.

status_t FLASH_PflashGetProtection(flash_config_t *config, pflash_protection_status_t *protectStatus)

Gets the PFlash protection status.

Parameters:
  • config – A pointer to the storage for the driver runtime state.

  • protectStatus – Protect status returned by the PFlash IP.

Return values:
  • kStatus_FLASH_Success – API was executed successfully.

  • kStatus_FLASH_InvalidArgument – An invalid argument is provided.

status_t FLASH_EepromSetProtection(flash_config_t *config, uint8_t protectStatus)

Sets the EEPROM protection to the intended protection status.

Parameters:
  • config – A pointer to the storage for the driver runtime state.

  • protectStatus – The expected protect status to set to the EEPROM protection register.

Return values:
  • kStatus_FLASH_Success – API was executed successfully.

  • kStatus_FLASH_InvalidArgument – An invalid argument is provided.

  • kStatus_FLASH_CommandNotSupported – Flash API is not supported.

  • kStatus_FLASH_CommandFailure – Run-time error during command execution.

status_t FLASH_EepromGetProtection(flash_config_t *config, uint8_t *protectStatus)

Gets the EEPROM protection status.

Parameters:
  • config – A pointer to the storage for the driver runtime state.

  • protectStatus – EEPROM Protect status returned by the EEPROM IP.

Return values:
  • kStatus_FLASH_Success – API was executed successfully.

  • kStatus_FLASH_InvalidArgument – An invalid argument is provided.

  • kStatus_FLASH_CommandNotSupported – Flash API is not supported.

status_t FLASH_PflashSetPrefetchSpeculation(flash_prefetch_speculation_status_t *speculationStatus)

Sets the PFlash prefetch speculation to the intended speculation status.

Parameters:
  • speculationStatus – The expected protect status to set to the PFlash protection register. Each bit is

Return values:
  • kStatus_FLASH_Success – API was executed successfully.

  • kStatus_FLASH_InvalidSpeculationOption – An invalid speculation option argument is provided.

status_t FLASH_PflashGetPrefetchSpeculation(flash_prefetch_speculation_status_t *speculationStatus)

Gets the PFlash prefetch speculation status.

Parameters:
  • speculationStatus – Speculation status returned by the PFlash IP.

Return values:

kStatus_FLASH_Success – API was executed successfully.

FLASH_SSD_CONFIG_ENABLE_EEPROM_SUPPORT

Indicates whether to support EEPROM in the Flash driver.

Enables the EEPROM support.

FLASH_SSD_IS_EEPROM_ENABLED

Indicates whether the EEPROM is enabled in the Flash driver.

FLASH_SSD_CONFIG_ENABLE_SECONDARY_FLASH_SUPPORT

Indicates whether to support Secondary flash in the Flash driver.

Enables the secondary flash support by default.

FLASH_SSD_IS_SECONDARY_FLASH_ENABLED

Indicates whether the secondary flash is supported in the Flash driver.

FLASH_DRIVER_IS_FLASH_RESIDENT

Flash driver location.

Used for the flash resident application.

FLASH_DRIVER_IS_EXPORTED

Flash Driver Export option.

Used for the MCUXpresso SDK application.

FLASH_ENABLE_STALLING_FLASH_CONTROLLER

Enable flash stalling controller.

enum _flash_user_margin_value

Enumeration for supported flash user margin levels.

Values:

enumerator kFLASH_ReadMarginValueNormal

Use the ‘normal’ read level for 1s.

enumerator kFLASH_UserMarginValue1

Apply the ‘User’ margin to the normal read-1 level.

enumerator kFLASH_UserMarginValue0

Apply the ‘User’ margin to the normal read-0 level.

enum _flash_factory_margin_value

Enumeration for supported factory margin levels.

Values:

enumerator kFLASH_FactoryMarginValue1

Apply the ‘Factory’ margin to the normal read-1 level.

enumerator kFLASH_FactoryMarginValue0

Apply the ‘Factory’ margin to the normal read-0 level.

enum _flash_margin_value

Enumeration for supported flash margin levels.

Values:

enumerator kFLASH_MarginValueNormal

Use the ‘normal’ read level for 1s.

enumerator kFLASH_MarginValueUser

Apply the ‘User’ margin to the normal read-1 level.

enumerator kFLASH_MarginValueFactory

Apply the ‘Factory’ margin to the normal read-1 level.

enumerator kFLASH_MarginValueInvalid

Not real margin level, Used to determine the range of valid margin level.

enum _flash_security_state

Enumeration for the three possible flash security states.

Values:

enumerator kFLASH_SecurityStateNotSecure

Flash is not secure.

enumerator kFLASH_SecurityStateBackdoorEnabled

Flash backdoor is enabled.

enumerator kFLASH_SecurityStateBackdoorDisabled

Flash backdoor is disabled.

enum _flash_protection_state

Enumeration for the three possible flash protection levels.

Values:

enumerator kFLASH_ProtectionStateUnprotected

Flash region is not protected.

enumerator kFLASH_ProtectionStateProtected

Flash region is protected.

enumerator kFLASH_ProtectionStateMixed

Flash is mixed with protected and unprotected region.

enum _flash_property_tag

Enumeration for various flash properties.

Values:

enumerator kFLASH_PropertyPflashSectorSize

Pflash sector size property.

enumerator kFLASH_PropertyPflashTotalSize

Pflash total size property.

enumerator kFLASH_PropertyPflashBlockSize

Pflash block size property.

enumerator kFLASH_PropertyPflashBlockCount

Pflash block count property.

enumerator kFLASH_PropertyPflashBlockBaseAddr

Pflash block base address property.

enumerator kFLASH_PropertyPflashFacSupport

Pflash fac support property.

enumerator kFLASH_PropertyEepromTotalSize

EEPROM total size property.

enumerator kFLASH_PropertyFlashMemoryIndex

Flash memory index property.

enumerator kFLASH_PropertyFlashCacheControllerIndex

Flash cache controller index property.

enumerator kFLASH_PropertyEepromBlockBaseAddr

EEPROM block base address property.

enumerator kFLASH_PropertyEepromSectorSize

EEPROM sector size property.

enumerator kFLASH_PropertyEepromBlockSize

EEPROM block size property.

enumerator kFLASH_PropertyEepromBlockCount

EEPROM block count property.

enumerator kFLASH_PropertyFlashClockFrequency

Flash peripheral clock property.

Constants for execute-in-RAM flash function. _flash_execute_in_ram_function_constants.

Values:

enumerator kFLASH_ExecuteInRamFunctionMaxSizeInWords

The maximum size of execute-in-RAM function.

enumerator kFLASH_ExecuteInRamFunctionTotalNum

Total number of execute-in-RAM functions.

enum _flash_memory_index

Enumeration for the flash memory index.

Values:

enumerator kFLASH_MemoryIndexPrimaryFlash

Current flash memory is primary flash.

enumerator kFLASH_MemoryIndexSecondaryFlash

Current flash memory is secondary flash.

enum _flash_cache_controller_index

Enumeration for the flash cache controller index.

Values:

enumerator kFLASH_CacheControllerIndexForCore0

Current flash cache controller is for core 0.

enumerator kFLASH_CacheControllerIndexForCore1

Current flash cache controller is for core 1.

enum _flash_prefetch_speculation_option

Enumeration for the two possible options of flash prefetch speculation.

Values:

enumerator kFLASH_prefetchSpeculationOptionEnable
enumerator kFLASH_prefetchSpeculationOptionDisable
enum _flash_cache_clear_process

Flash cache clear process code.

Values:

enumerator kFLASH_CacheClearProcessPre

Pre flash cache clear process.

enumerator kFLASH_CacheClearProcessPost

Post flash cache clear process.

typedef enum _flash_user_margin_value flash_user_margin_value_t

Enumeration for supported flash user margin levels.

typedef enum _flash_factory_margin_value flash_factory_margin_value_t

Enumeration for supported factory margin levels.

typedef enum _flash_margin_value flash_margin_value_t

Enumeration for supported flash margin levels.

typedef enum _flash_security_state flash_security_state_t

Enumeration for the three possible flash security states.

typedef enum _flash_protection_state flash_protection_state_t

Enumeration for the three possible flash protection levels.

typedef enum _flash_property_tag flash_property_tag_t

Enumeration for various flash properties.

typedef struct _pflash_protection_status pflash_protection_status_t

PFlash protection status - full.

typedef enum _flash_memory_index flash_memory_index_t

Enumeration for the flash memory index.

typedef enum _flash_cache_controller_index flash_cache_controller_index_t

Enumeration for the flash cache controller index.

typedef void (*flash_callback_t)(void)

A callback type used for the Pflash block.

typedef enum _flash_prefetch_speculation_option flash_prefetch_speculation_option_t

Enumeration for the two possible options of flash prefetch speculation.

typedef struct _flash_prefetch_speculation_status flash_prefetch_speculation_status_t

Flash prefetch speculation status.

typedef enum _flash_cache_clear_process flash_cache_clear_process_t

Flash cache clear process code.

typedef struct _flash_protection_config flash_protection_config_t

Active flash protection information for the current operation.

typedef struct _flash_operation_config flash_operation_config_t

Active flash information for the current operation.

typedef struct _flash_execute_in_ram_function_config flash_execute_in_ram_function_config_t

Flash execute-in-RAM function information.

typedef struct _flash_config flash_config_t

Flash driver state information.

An instance of this structure is allocated by the user of the flash driver and passed into each of the driver APIs.

struct _pflash_protection_status
#include <fsl_flash.h>

PFlash protection status - full.

Public Members

uint8_t fprotvalue

FPROT[7:0] .

struct _flash_prefetch_speculation_status
#include <fsl_flash.h>

Flash prefetch speculation status.

Public Members

flash_prefetch_speculation_option_t instructionOption

Instruction speculation.

flash_prefetch_speculation_option_t dataOption

Data speculation.

struct _flash_protection_config
#include <fsl_flash.h>

Active flash protection information for the current operation.

Public Members

uint32_t lowRegionStart

Start address of flash protection low region.

uint32_t lowRegionEnd

End address of flash protection low region.

uint32_t highRegionStart

Start address of flash protection high region.

uint32_t highRegionEnd

End address of flash protection high region.

struct _flash_operation_config
#include <fsl_flash.h>

Active flash information for the current operation.

Public Members

uint32_t convertedAddress

A converted address for the current flash type.

uint32_t activeSectorSize

A sector size of the current flash type.

uint32_t activeBlockSize

A block size of the current flash type.

uint32_t blockWriteUnitSize

The write unit size.

uint32_t sectorCmdAddressAligment

An erase sector command address alignment.

uint32_t sectionCmdAddressAligment

A program/verify section command address alignment.

uint32_t programCmdAddressAligment

A program flash command address alignment.

union function_run_command_t
#include <fsl_flash.h>

Flash execute-in-RAM command.

Public Members

uint32_t commadAddr
void (*callFlashCommand)(volatile uint8_t *FTMRx_fstat)
union function_common_bit_operation_t
#include <fsl_flash.h>

Public Members

uint32_t bitOperationAddr
void (*callCommonBitOperationCommand)(volatile uint32_t *base, uint32_t bitMask, uint32_t bitShift, uint32_t bitValue)
struct _flash_execute_in_ram_function_config
#include <fsl_flash.h>

Flash execute-in-RAM function information.

Public Members

uint32_t activeFunctionCount

Number of available execute-in-RAM functions.

function_run_command_t runCmdFuncAddr

Execute-in-RAM function: flash_run_command.

struct _flash_config
#include <fsl_flash.h>

Flash driver state information.

An instance of this structure is allocated by the user of the flash driver and passed into each of the driver APIs.

Public Members

uint32_t PFlashBlockBase

A base address of the first PFlash block

uint32_t PFlashTotalSize

The size of the combined PFlash block.

uint8_t PFlashBlockCount

A number of PFlash blocks.

uint8_t FlashMemoryIndex

0 - primary flash; 1 - secondary flash

uint8_t FlashCacheControllerIndex

0 - Controller for core 0; 1 - Controller for core 1

uint8_t Reserved0

Reserved field 0

uint32_t PFlashSectorSize

The size in bytes of a sector of PFlash.

flash_callback_t PFlashCallback

The callback function for the flash API.

uint32_t *flashExecuteInRamFunctionInfo

An information structure of the flash execute-in-RAM function.

uint32_t EEpromTotalSize

For the FlexNVM device, this is the size in bytes of the EEPROM area which was partitioned from FlexRAM For the non-FlexNVM device, this field is unused

uint32_t EEpromBlockBase

This is the base address of the Eeprom For the non-Eeprom device, this field is unused

uint8_t EEpromBlockCount

A number of EEPROM blocks. For the non-Eeprom device, this field is unused

uint8_t EEpromSectorSize

The size in bytes of a sector of EEPROM. For the non-Eeprom device, this field is unused

uint8_t Reserved1[2]

Reserved field 1

uint32_t PFlashClockFreq

The flash peripheral clock frequency

uint32_t PFlashMarginLevel

The margin level

FTM: FlexTimer Driver

status_t FTM_Init(FTM_Type *base, const ftm_config_t *config)

Ungates the FTM clock and configures the peripheral for basic operation.

Note

This API should be called at the beginning of the application which is using the FTM driver. If the FTM instance has only TPM features, please use the TPM driver.

Parameters:
  • base – FTM peripheral base address

  • config – Pointer to the user configuration structure.

Returns:

kStatus_Success indicates success; Else indicates failure.

void FTM_Deinit(FTM_Type *base)

Gates the FTM clock.

Parameters:
  • base – FTM peripheral base address

void FTM_GetDefaultConfig(ftm_config_t *config)

Fills in the FTM configuration structure with the default settings.

The default values are:

config->prescale = kFTM_Prescale_Divide_1;
config->bdmMode = kFTM_BdmMode_0;
config->pwmSyncMode = kFTM_SoftwareTrigger;
config->reloadPoints = 0;
config->faultMode = kFTM_Fault_Disable;
config->faultFilterValue = 0;
config->deadTimePrescale = kFTM_Deadtime_Prescale_1;
config->deadTimeValue =  0;
config->extTriggers = 0;
config->chnlInitState = 0;
config->chnlPolarity = 0;
config->useGlobalTimeBase = false;
config->hwTriggerResetCount = false;
config->swTriggerResetCount = true;

Parameters:
  • config – Pointer to the user configuration structure.

static inline ftm_clock_prescale_t FTM_CalculateCounterClkDiv(FTM_Type *base, uint32_t counterPeriod_Hz, uint32_t srcClock_Hz)

brief Calculates the counter clock prescaler.

This function calculates the values for SC[PS] bit.

param base FTM peripheral base address param counterPeriod_Hz The desired frequency in Hz which corresponding to the time when the counter reaches the mod value param srcClock_Hz FTM counter clock in Hz

return Calculated clock prescaler value, see ftm_clock_prescale_t.

status_t FTM_SetupPwm(FTM_Type *base, const ftm_chnl_pwm_signal_param_t *chnlParams, uint8_t numOfChnls, ftm_pwm_mode_t mode, uint32_t pwmFreq_Hz, uint32_t srcClock_Hz)

Configures the PWM signal parameters.

Call this function to configure the PWM signal period, mode, duty cycle, and edge. Use this function to configure all FTM channels that are used to output a PWM signal.

Parameters:
  • base – FTM peripheral base address

  • chnlParams – Array of PWM channel parameters to configure the channel(s)

  • numOfChnls – Number of channels to configure; This should be the size of the array passed in

  • mode – PWM operation mode, options available in enumeration ftm_pwm_mode_t

  • pwmFreq_Hz – PWM signal frequency in Hz

  • srcClock_Hz – FTM counter clock in Hz

Returns:

kStatus_Success if the PWM setup was successful kStatus_Error on failure

status_t FTM_UpdatePwmDutycycle(FTM_Type *base, ftm_chnl_t chnlNumber, ftm_pwm_mode_t currentPwmMode, uint8_t dutyCyclePercent)

Updates the duty cycle of an active PWM signal.

Parameters:
  • base – FTM peripheral base address

  • chnlNumber – The channel/channel pair number. In combined mode, this represents the channel pair number

  • currentPwmMode – The current PWM mode set during PWM setup

  • dutyCyclePercent – New PWM pulse width; The value should be between 0 to 100 0=inactive signal(0% duty cycle)… 100=active signal (100% duty cycle)

Returns:

kStatus_Success if the PWM update was successful kStatus_Error on failure

void FTM_UpdateChnlEdgeLevelSelect(FTM_Type *base, ftm_chnl_t chnlNumber, uint8_t level)

Updates the edge level selection for a channel.

Parameters:
  • base – FTM peripheral base address

  • chnlNumber – The channel number

  • level – The level to be set to the ELSnB:ELSnA field; Valid values are 00, 01, 10, 11. See the Kinetis SoC reference manual for details about this field.

status_t FTM_SetupPwmMode(FTM_Type *base, const ftm_chnl_pwm_config_param_t *chnlParams, uint8_t numOfChnls, ftm_pwm_mode_t mode)

Configures the PWM mode parameters.

Call this function to configure the PWM signal mode, duty cycle in ticks, and edge. Use this function to configure all FTM channels that are used to output a PWM signal. Please note that: This API is similar with FTM_SetupPwm() API, but will not set the timer period, and this API will set channel match value in timer ticks, not period percent.

Parameters:
  • base – FTM peripheral base address

  • chnlParams – Array of PWM channel parameters to configure the channel(s)

  • numOfChnls – Number of channels to configure; This should be the size of the array passed in

  • mode – PWM operation mode, options available in enumeration ftm_pwm_mode_t

Returns:

kStatus_Success if the PWM setup was successful kStatus_Error on failure

void FTM_SetupInputCapture(FTM_Type *base, ftm_chnl_t chnlNumber, ftm_input_capture_edge_t captureMode, uint32_t filterValue)

Enables capturing an input signal on the channel using the function parameters.

When the edge specified in the captureMode argument occurs on the channel, the FTM counter is captured into the CnV register. The user has to read the CnV register separately to get this value. The filter function is disabled if the filterVal argument passed in is 0. The filter function is available only for channels 0, 1, 2, 3.

Parameters:
  • base – FTM peripheral base address

  • chnlNumber – The channel number

  • captureMode – Specifies which edge to capture

  • filterValue – Filter value, specify 0 to disable filter. Available only for channels 0-3.

void FTM_SetupOutputCompare(FTM_Type *base, ftm_chnl_t chnlNumber, ftm_output_compare_mode_t compareMode, uint32_t compareValue)

Configures the FTM to generate timed pulses.

When the FTM counter matches the value of compareVal argument (this is written into CnV reg), the channel output is changed based on what is specified in the compareMode argument.

Parameters:
  • base – FTM peripheral base address

  • chnlNumber – The channel number

  • compareMode – Action to take on the channel output when the compare condition is met

  • compareValue – Value to be programmed in the CnV register.

void FTM_SetupDualEdgeCapture(FTM_Type *base, ftm_chnl_t chnlPairNumber, const ftm_dual_edge_capture_param_t *edgeParam, uint32_t filterValue)

Configures the dual edge capture mode of the FTM.

This function sets up the dual edge capture mode on a channel pair. The capture edge for the channel pair and the capture mode (one-shot or continuous) is specified in the parameter argument. The filter function is disabled if the filterVal argument passed is zero. The filter function is available only on channels 0 and 2. The user has to read the channel CnV registers separately to get the capture values.

Parameters:
  • base – FTM peripheral base address

  • chnlPairNumber – The FTM channel pair number; options are 0, 1, 2, 3

  • edgeParam – Sets up the dual edge capture function

  • filterValue – Filter value, specify 0 to disable filter. Available only for channel pair 0 and 1.

void FTM_EnableInterrupts(FTM_Type *base, uint32_t mask)

Enables the selected FTM interrupts.

Parameters:
  • base – FTM peripheral base address

  • mask – The interrupts to enable. This is a logical OR of members of the enumeration ftm_interrupt_enable_t

void FTM_DisableInterrupts(FTM_Type *base, uint32_t mask)

Disables the selected FTM interrupts.

Parameters:
  • base – FTM peripheral base address

  • mask – The interrupts to enable. This is a logical OR of members of the enumeration ftm_interrupt_enable_t

uint32_t FTM_GetEnabledInterrupts(FTM_Type *base)

Gets the enabled FTM interrupts.

Parameters:
  • base – FTM peripheral base address

Returns:

The enabled interrupts. This is the logical OR of members of the enumeration ftm_interrupt_enable_t

uint32_t FTM_GetInstance(FTM_Type *base)

Gets the instance from the base address.

Parameters:
  • base – FTM peripheral base address

Returns:

The FTM instance

uint32_t FTM_GetStatusFlags(FTM_Type *base)

Gets the FTM status flags.

Parameters:
  • base – FTM peripheral base address

Returns:

The status flags. This is the logical OR of members of the enumeration ftm_status_flags_t

void FTM_ClearStatusFlags(FTM_Type *base, uint32_t mask)

Clears the FTM status flags.

Parameters:
  • base – FTM peripheral base address

  • mask – The status flags to clear. This is a logical OR of members of the enumeration ftm_status_flags_t

static inline void FTM_SetTimerPeriod(FTM_Type *base, uint32_t ticks)

Sets the timer period in units of ticks.

Timers counts from 0 until it equals the count value set here. The count value is written to the MOD register.

Note

  1. This API allows the user to use the FTM module as a timer. Do not mix usage of this API with FTM’s PWM setup API’s.

  2. Call the utility macros provided in the fsl_common.h to convert usec or msec to ticks.

Parameters:
  • base – FTM peripheral base address

  • ticks – A timer period in units of ticks, which should be equal or greater than 1.

static inline uint32_t FTM_GetCurrentTimerCount(FTM_Type *base)

Reads the current timer counting value.

This function returns the real-time timer counting value in a range from 0 to a timer period.

Note

Call the utility macros provided in the fsl_common.h to convert ticks to usec or msec.

Parameters:
  • base – FTM peripheral base address

Returns:

The current counter value in ticks

static inline uint32_t FTM_GetInputCaptureValue(FTM_Type *base, ftm_chnl_t chnlNumber)

Reads the captured value.

This function returns the captured value of a FTM channel configured in input capture or dual edge capture mode.

Note

Call the utility macros provided in the fsl_common.h to convert ticks to usec or msec.

Parameters:
  • base – FTM peripheral base address

  • chnlNumber – Channel to be read

Returns:

The captured FTM counter value of the input modes.

static inline void FTM_StartTimer(FTM_Type *base, ftm_clock_source_t clockSource)

Starts the FTM counter.

Parameters:
  • base – FTM peripheral base address

  • clockSource – FTM clock source; After the clock source is set, the counter starts running.

static inline void FTM_StopTimer(FTM_Type *base)

Stops the FTM counter.

Parameters:
  • base – FTM peripheral base address

static inline void FTM_SetSoftwareCtrlEnable(FTM_Type *base, ftm_chnl_t chnlNumber, bool value)

Enables or disables the channel software output control.

Parameters:
  • base – FTM peripheral base address

  • chnlNumber – Channel to be enabled or disabled

  • value – true: channel output is affected by software output control false: channel output is unaffected by software output control

static inline void FTM_SetSoftwareCtrlVal(FTM_Type *base, ftm_chnl_t chnlNumber, bool value)

Sets the channel software output control value.

Parameters:
  • base – FTM peripheral base address.

  • chnlNumber – Channel to be configured

  • value – true to set 1, false to set 0

static inline void FTM_SetFaultControlEnable(FTM_Type *base, ftm_chnl_t chnlPairNumber, bool value)

This function enables/disables the fault control in a channel pair.

Parameters:
  • base – FTM peripheral base address

  • chnlPairNumber – The FTM channel pair number; options are 0, 1, 2, 3

  • value – true: Enable fault control for this channel pair; false: No fault control

static inline void FTM_SetDeadTimeEnable(FTM_Type *base, ftm_chnl_t chnlPairNumber, bool value)

This function enables/disables the dead time insertion in a channel pair.

Parameters:
  • base – FTM peripheral base address

  • chnlPairNumber – The FTM channel pair number; options are 0, 1, 2, 3

  • value – true: Insert dead time in this channel pair; false: No dead time inserted

static inline void FTM_SetComplementaryEnable(FTM_Type *base, ftm_chnl_t chnlPairNumber, bool value)

This function enables/disables complementary mode in a channel pair.

Parameters:
  • base – FTM peripheral base address

  • chnlPairNumber – The FTM channel pair number; options are 0, 1, 2, 3

  • value – true: enable complementary mode; false: disable complementary mode

static inline void FTM_SetInvertEnable(FTM_Type *base, ftm_chnl_t chnlPairNumber, bool value)

This function enables/disables inverting control in a channel pair.

Parameters:
  • base – FTM peripheral base address

  • chnlPairNumber – The FTM channel pair number; options are 0, 1, 2, 3

  • value – true: enable inverting; false: disable inverting

void FTM_SetupQuadDecode(FTM_Type *base, const ftm_phase_params_t *phaseAParams, const ftm_phase_params_t *phaseBParams, ftm_quad_decode_mode_t quadMode)

Configures the parameters and activates the quadrature decoder mode.

Parameters:
  • base – FTM peripheral base address

  • phaseAParams – Phase A configuration parameters

  • phaseBParams – Phase B configuration parameters

  • quadMode – Selects encoding mode used in quadrature decoder mode

static inline void FTM_SetQuadDecoderModuloValue(FTM_Type *base, uint32_t startValue, uint32_t overValue)

Sets the modulo values for Quad Decoder.

The modulo values configure the minimum and maximum values that the Quad decoder counter can reach. After the counter goes over, the counter value goes to the other side and decrease/increase again.

Parameters:
  • base – FTM peripheral base address.

  • startValue – The low limit value for Quad Decoder counter.

  • overValue – The high limit value for Quad Decoder counter.

static inline uint32_t FTM_GetQuadDecoderCounterValue(FTM_Type *base)

Gets the current Quad Decoder counter value.

Parameters:
  • base – FTM peripheral base address.

Returns:

Current quad Decoder counter value.

static inline void FTM_ClearQuadDecoderCounterValue(FTM_Type *base)

Clears the current Quad Decoder counter value.

The counter is set as the initial value.

Parameters:
  • base – FTM peripheral base address.

FSL_FTM_DRIVER_VERSION

FTM driver version 2.6.1.

enum _ftm_chnl

List of FTM channels.

Note

Actual number of available channels is SoC dependent

Values:

enumerator kFTM_Chnl_0

FTM channel number 0

enumerator kFTM_Chnl_1

FTM channel number 1

enumerator kFTM_Chnl_2

FTM channel number 2

enumerator kFTM_Chnl_3

FTM channel number 3

enumerator kFTM_Chnl_4

FTM channel number 4

enumerator kFTM_Chnl_5

FTM channel number 5

enumerator kFTM_Chnl_6

FTM channel number 6

enumerator kFTM_Chnl_7

FTM channel number 7

enum _ftm_fault_input

List of FTM faults.

Values:

enumerator kFTM_Fault_0

FTM fault 0 input pin

enumerator kFTM_Fault_1

FTM fault 1 input pin

enumerator kFTM_Fault_2

FTM fault 2 input pin

enumerator kFTM_Fault_3

FTM fault 3 input pin

enum _ftm_pwm_mode

FTM PWM operation modes.

Values:

enumerator kFTM_EdgeAlignedPwm

Edge-aligned PWM

enumerator kFTM_CenterAlignedPwm

Center-aligned PWM

enumerator kFTM_EdgeAlignedCombinedPwm

Edge-aligned combined PWM

enumerator kFTM_CenterAlignedCombinedPwm

Center-aligned combined PWM

enumerator kFTM_AsymmetricalCombinedPwm

Asymmetrical combined PWM

enum _ftm_pwm_level_select

FTM PWM output pulse mode: high-true, low-true or no output.

Values:

enumerator kFTM_NoPwmSignal

No PWM output on pin

enumerator kFTM_LowTrue

Low true pulses

enumerator kFTM_HighTrue

High true pulses

enum _ftm_output_compare_mode

FlexTimer output compare mode.

Values:

enumerator kFTM_NoOutputSignal

No channel output when counter reaches CnV

enumerator kFTM_ToggleOnMatch

Toggle output

enumerator kFTM_ClearOnMatch

Clear output

enumerator kFTM_SetOnMatch

Set output

enum _ftm_input_capture_edge

FlexTimer input capture edge.

Values:

enumerator kFTM_RisingEdge

Capture on rising edge only

enumerator kFTM_FallingEdge

Capture on falling edge only

enumerator kFTM_RiseAndFallEdge

Capture on rising or falling edge

enum _ftm_dual_edge_capture_mode

FlexTimer dual edge capture modes.

Values:

enumerator kFTM_OneShot

One-shot capture mode

enumerator kFTM_Continuous

Continuous capture mode

enum _ftm_quad_decode_mode

FlexTimer quadrature decode modes.

Values:

enumerator kFTM_QuadPhaseEncode

Phase A and Phase B encoding mode

enumerator kFTM_QuadCountAndDir

Count and direction encoding mode

enum _ftm_phase_polarity

FlexTimer quadrature phase polarities.

Values:

enumerator kFTM_QuadPhaseNormal

Phase input signal is not inverted

enumerator kFTM_QuadPhaseInvert

Phase input signal is inverted

enum _ftm_deadtime_prescale

FlexTimer pre-scaler factor for the dead time insertion.

Values:

enumerator kFTM_Deadtime_Prescale_1

Divide by 1

enumerator kFTM_Deadtime_Prescale_4

Divide by 4

enumerator kFTM_Deadtime_Prescale_16

Divide by 16

enum _ftm_clock_source

FlexTimer clock source selection.

Values:

enumerator kFTM_SystemClock

System clock selected

enumerator kFTM_FixedClock

Fixed frequency clock

enumerator kFTM_ExternalClock

External clock

enum _ftm_clock_prescale

FlexTimer pre-scaler factor selection for the clock source.

Values:

enumerator kFTM_Prescale_Divide_1

Divide by 1

enumerator kFTM_Prescale_Divide_2

Divide by 2

enumerator kFTM_Prescale_Divide_4

Divide by 4

enumerator kFTM_Prescale_Divide_8

Divide by 8

enumerator kFTM_Prescale_Divide_16

Divide by 16

enumerator kFTM_Prescale_Divide_32

Divide by 32

enumerator kFTM_Prescale_Divide_64

Divide by 64

enumerator kFTM_Prescale_Divide_128

Divide by 128

enum _ftm_bdm_mode

Options for the FlexTimer behaviour in BDM Mode.

Values:

enumerator kFTM_BdmMode_0

FTM counter stopped, CH(n)F bit can be set, FTM channels in functional mode, writes to MOD,CNTIN and C(n)V registers bypass the register buffers

enumerator kFTM_BdmMode_1

FTM counter stopped, CH(n)F bit is not set, FTM channels outputs are forced to their safe value , writes to MOD,CNTIN and C(n)V registers bypass the register buffers

enumerator kFTM_BdmMode_2

FTM counter stopped, CH(n)F bit is not set, FTM channels outputs are frozen when chip enters in BDM mode, writes to MOD,CNTIN and C(n)V registers bypass the register buffers

enumerator kFTM_BdmMode_3

FTM counter in functional mode, CH(n)F bit can be set, FTM channels in functional mode, writes to MOD,CNTIN and C(n)V registers is in fully functional mode

enum _ftm_fault_mode

Options for the FTM fault control mode.

Values:

enumerator kFTM_Fault_Disable

Fault control is disabled for all channels

enumerator kFTM_Fault_EvenChnls

Enabled for even channels only(0,2,4,6) with manual fault clearing

enumerator kFTM_Fault_AllChnlsMan

Enabled for all channels with manual fault clearing

enumerator kFTM_Fault_AllChnlsAuto

Enabled for all channels with automatic fault clearing

enum _ftm_external_trigger

FTM external trigger options.

Note

Actual available external trigger sources are SoC-specific

Values:

enumerator kFTM_Chnl0Trigger

Generate trigger when counter equals chnl 0 CnV reg

enumerator kFTM_Chnl1Trigger

Generate trigger when counter equals chnl 1 CnV reg

enumerator kFTM_Chnl2Trigger

Generate trigger when counter equals chnl 2 CnV reg

enumerator kFTM_Chnl3Trigger

Generate trigger when counter equals chnl 3 CnV reg

enumerator kFTM_Chnl4Trigger

Generate trigger when counter equals chnl 4 CnV reg

enumerator kFTM_Chnl5Trigger

Generate trigger when counter equals chnl 5 CnV reg

enumerator kFTM_Chnl6Trigger

Available on certain SoC’s, generate trigger when counter equals chnl 6 CnV reg

enumerator kFTM_Chnl7Trigger

Available on certain SoC’s, generate trigger when counter equals chnl 7 CnV reg

enumerator kFTM_InitTrigger

Generate Trigger when counter is updated with CNTIN

enumerator kFTM_ReloadInitTrigger

Available on certain SoC’s, trigger on reload point

enum _ftm_pwm_sync_method

FlexTimer PWM sync options to update registers with buffer.

Values:

enumerator kFTM_SoftwareTrigger

Software triggers PWM sync

enumerator kFTM_HardwareTrigger_0

Hardware trigger 0 causes PWM sync

enumerator kFTM_HardwareTrigger_1

Hardware trigger 1 causes PWM sync

enumerator kFTM_HardwareTrigger_2

Hardware trigger 2 causes PWM sync

enum _ftm_reload_point

FTM options available as loading point for register reload.

Note

Actual available reload points are SoC-specific

Values:

enumerator kFTM_Chnl0Match

Channel 0 match included as a reload point

enumerator kFTM_Chnl1Match

Channel 1 match included as a reload point

enumerator kFTM_Chnl2Match

Channel 2 match included as a reload point

enumerator kFTM_Chnl3Match

Channel 3 match included as a reload point

enumerator kFTM_Chnl4Match

Channel 4 match included as a reload point

enumerator kFTM_Chnl5Match

Channel 5 match included as a reload point

enumerator kFTM_Chnl6Match

Channel 6 match included as a reload point

enumerator kFTM_Chnl7Match

Channel 7 match included as a reload point

enumerator kFTM_CntMax

Use in up-down count mode only, reload when counter reaches the maximum value

enumerator kFTM_CntMin

Use in up-down count mode only, reload when counter reaches the minimum value

enumerator kFTM_HalfCycMatch

Available on certain SoC’s, half cycle match reload point

enum _ftm_interrupt_enable

List of FTM interrupts.

Note

Actual available interrupts are SoC-specific

Values:

enumerator kFTM_Chnl0InterruptEnable

Channel 0 interrupt

enumerator kFTM_Chnl1InterruptEnable

Channel 1 interrupt

enumerator kFTM_Chnl2InterruptEnable

Channel 2 interrupt

enumerator kFTM_Chnl3InterruptEnable

Channel 3 interrupt

enumerator kFTM_Chnl4InterruptEnable

Channel 4 interrupt

enumerator kFTM_Chnl5InterruptEnable

Channel 5 interrupt

enumerator kFTM_Chnl6InterruptEnable

Channel 6 interrupt

enumerator kFTM_Chnl7InterruptEnable

Channel 7 interrupt

enumerator kFTM_FaultInterruptEnable

Fault interrupt

enumerator kFTM_TimeOverflowInterruptEnable

Time overflow interrupt

enumerator kFTM_ReloadInterruptEnable

Reload interrupt; Available only on certain SoC’s

enum _ftm_status_flags

List of FTM flags.

Note

Actual available flags are SoC-specific

Values:

enumerator kFTM_Chnl0Flag

Channel 0 Flag

enumerator kFTM_Chnl1Flag

Channel 1 Flag

enumerator kFTM_Chnl2Flag

Channel 2 Flag

enumerator kFTM_Chnl3Flag

Channel 3 Flag

enumerator kFTM_Chnl4Flag

Channel 4 Flag

enumerator kFTM_Chnl5Flag

Channel 5 Flag

enumerator kFTM_Chnl6Flag

Channel 6 Flag

enumerator kFTM_Chnl7Flag

Channel 7 Flag

enumerator kFTM_FaultFlag

Fault Flag

enumerator kFTM_TimeOverflowFlag

Time overflow Flag

enumerator kFTM_ChnlTriggerFlag

Channel trigger Flag

enumerator kFTM_ReloadFlag

Reload Flag; Available only on certain SoC’s

typedef enum _ftm_chnl ftm_chnl_t

List of FTM channels.

Note

Actual number of available channels is SoC dependent

typedef enum _ftm_fault_input ftm_fault_input_t

List of FTM faults.

typedef enum _ftm_pwm_mode ftm_pwm_mode_t

FTM PWM operation modes.

typedef enum _ftm_pwm_level_select ftm_pwm_level_select_t

FTM PWM output pulse mode: high-true, low-true or no output.

typedef struct _ftm_chnl_pwm_signal_param ftm_chnl_pwm_signal_param_t

Options to configure a FTM channel’s PWM signal.

typedef struct _ftm_chnl_pwm_config_param ftm_chnl_pwm_config_param_t

Options to configure a FTM channel using precise setting.

typedef enum _ftm_output_compare_mode ftm_output_compare_mode_t

FlexTimer output compare mode.

typedef enum _ftm_input_capture_edge ftm_input_capture_edge_t

FlexTimer input capture edge.

typedef enum _ftm_dual_edge_capture_mode ftm_dual_edge_capture_mode_t

FlexTimer dual edge capture modes.

typedef struct _ftm_dual_edge_capture_param ftm_dual_edge_capture_param_t

FlexTimer dual edge capture parameters.

typedef enum _ftm_quad_decode_mode ftm_quad_decode_mode_t

FlexTimer quadrature decode modes.

typedef enum _ftm_phase_polarity ftm_phase_polarity_t

FlexTimer quadrature phase polarities.

typedef struct _ftm_phase_param ftm_phase_params_t

FlexTimer quadrature decode phase parameters.

typedef struct _ftm_fault_param ftm_fault_param_t

Structure is used to hold the parameters to configure a FTM fault.

typedef enum _ftm_deadtime_prescale ftm_deadtime_prescale_t

FlexTimer pre-scaler factor for the dead time insertion.

typedef enum _ftm_clock_source ftm_clock_source_t

FlexTimer clock source selection.

typedef enum _ftm_clock_prescale ftm_clock_prescale_t

FlexTimer pre-scaler factor selection for the clock source.

typedef enum _ftm_bdm_mode ftm_bdm_mode_t

Options for the FlexTimer behaviour in BDM Mode.

typedef enum _ftm_fault_mode ftm_fault_mode_t

Options for the FTM fault control mode.

typedef enum _ftm_external_trigger ftm_external_trigger_t

FTM external trigger options.

Note

Actual available external trigger sources are SoC-specific

typedef enum _ftm_pwm_sync_method ftm_pwm_sync_method_t

FlexTimer PWM sync options to update registers with buffer.

typedef enum _ftm_reload_point ftm_reload_point_t

FTM options available as loading point for register reload.

Note

Actual available reload points are SoC-specific

typedef enum _ftm_interrupt_enable ftm_interrupt_enable_t

List of FTM interrupts.

Note

Actual available interrupts are SoC-specific

typedef enum _ftm_status_flags ftm_status_flags_t

List of FTM flags.

Note

Actual available flags are SoC-specific

typedef struct _ftm_config ftm_config_t

FTM configuration structure.

This structure holds the configuration settings for the FTM peripheral. To initialize this structure to reasonable defaults, call the FTM_GetDefaultConfig() function and pass a pointer to the configuration structure instance.

The configuration structure can be made constant so as to reside in flash.

void FTM_SetupFaultInput(FTM_Type *base, ftm_fault_input_t faultNumber, const ftm_fault_param_t *faultParams)

Sets up the working of the FTM fault inputs protection.

FTM can have up to 4 fault inputs. This function sets up fault parameters, fault level, and input filter.

Parameters:
  • base – FTM peripheral base address

  • faultNumber – FTM fault to configure.

  • faultParams – Parameters passed in to set up the fault

static inline void FTM_SetGlobalTimeBaseOutputEnable(FTM_Type *base, bool enable)

Enables or disables the FTM global time base signal generation to other FTMs.

Parameters:
  • base – FTM peripheral base address

  • enable – true to enable, false to disable

static inline void FTM_SetOutputMask(FTM_Type *base, ftm_chnl_t chnlNumber, bool mask)

Sets the FTM peripheral timer channel output mask.

Parameters:
  • base – FTM peripheral base address

  • chnlNumber – Channel to be configured

  • mask – true: masked, channel is forced to its inactive state; false: unmasked

static inline void FTM_SetPwmOutputEnable(FTM_Type *base, ftm_chnl_t chnlNumber, bool value)

Allows users to enable an output on an FTM channel.

To enable the PWM channel output call this function with val=true. For input mode, call this function with val=false.

Parameters:
  • base – FTM peripheral base address

  • chnlNumber – Channel to be configured

  • value – true: enable output; false: output is disabled, used in input mode

static inline void FTM_SetSoftwareTrigger(FTM_Type *base, bool enable)

Enables or disables the FTM software trigger for PWM synchronization.

Parameters:
  • base – FTM peripheral base address

  • enable – true: software trigger is selected, false: software trigger is not selected

static inline void FTM_SetWriteProtection(FTM_Type *base, bool enable)

Enables or disables the FTM write protection.

Parameters:
  • base – FTM peripheral base address

  • enable – true: Write-protection is enabled, false: Write-protection is disabled

static inline void FTM_EnableDmaTransfer(FTM_Type *base, ftm_chnl_t chnlNumber, bool enable)

Enable DMA transfer or not.

Note: CHnIE bit needs to be set when calling this API. The channel DMA transfer request is generated and the channel interrupt is not generated if (CHnF = 1) when DMA and CHnIE bits are set.

Parameters:
  • base – FTM peripheral base address.

  • chnlNumber – Channel to be configured

  • enable – true to enable, false to disable

static inline void FTM_SetLdok(FTM_Type *base, bool value)

Enable the LDOK bit.

This function enables loading updated values.

Parameters:
  • base – FTM peripheral base address

  • value – true: loading updated values is enabled; false: loading updated values is disabled.

static inline void FTM_SetHalfCycReloadMatchValue(FTM_Type *base, uint32_t ticks)

Sets the half cycle relade period in units of ticks.

This function can be callled to set the half-cycle reload value when half-cycle matching is enabled as a reload point. Note: Need enable kFTM_HalfCycMatch as reload point, and when this API call after FTM_StartTimer(), the new HCR value will not be active until next reload point (need call FTM_SetLdok to set LDOK) or register synchronization.

Parameters:
  • base – FTM peripheral base address

  • ticks – A timer period in units of ticks, which should be equal or greater than 1.

static inline void FTM_SetLoadFreq(FTM_Type *base, uint32_t loadfreq)

Set load frequency value.

Parameters:
  • base – FTM peripheral base address.

  • loadfreq – PWM reload frequency, range: 0 ~ 31.

struct _ftm_chnl_pwm_signal_param
#include <fsl_ftm.h>

Options to configure a FTM channel’s PWM signal.

Public Members

ftm_chnl_t chnlNumber

The channel/channel pair number. In combined mode, this represents the channel pair number.

ftm_pwm_level_select_t level

PWM output active level select.

uint8_t dutyCyclePercent

PWM pulse width, value should be between 0 to 100 0 = inactive signal(0% duty cycle)… 100 = always active signal (100% duty cycle).

uint8_t firstEdgeDelayPercent

Used only in kFTM_AsymmetricalCombinedPwm mode to generate an asymmetrical PWM. Specifies the delay to the first edge in a PWM period. If unsure leave as 0; Should be specified as a percentage of the PWM period

bool enableComplementary

Used only in combined PWM mode. true: The combined channels output complementary signals; false: The combined channels output same signals;

bool enableDeadtime

Used only in combined PWM mode with enable complementary. true: The deadtime insertion in this pair of channels is enabled; false: The deadtime insertion in this pair of channels is disabled.

struct _ftm_chnl_pwm_config_param
#include <fsl_ftm.h>

Options to configure a FTM channel using precise setting.

Public Members

ftm_chnl_t chnlNumber

The channel/channel pair number. In combined mode, this represents the channel pair number.

ftm_pwm_level_select_t level

PWM output active level select.

uint16_t dutyValue

PWM pulse width, the uint of this value is timer ticks.

uint16_t firstEdgeValue

Used only in kFTM_AsymmetricalCombinedPwm mode to generate an asymmetrical PWM. Specifies the delay to the first edge in a PWM period. If unsure leave as 0, uint of this value is timer ticks.

bool enableComplementary

Used only in combined PWM mode. true: The combined channels output complementary signals; false: The combined channels output same signals;

bool enableDeadtime

Used only in combined PWM mode with enable complementary. true: The deadtime insertion in this pair of channels is enabled; false: The deadtime insertion in this pair of channels is disabled.

struct _ftm_dual_edge_capture_param
#include <fsl_ftm.h>

FlexTimer dual edge capture parameters.

Public Members

ftm_dual_edge_capture_mode_t mode

Dual Edge Capture mode

ftm_input_capture_edge_t currChanEdgeMode

Input capture edge select for channel n

ftm_input_capture_edge_t nextChanEdgeMode

Input capture edge select for channel n+1

struct _ftm_phase_param
#include <fsl_ftm.h>

FlexTimer quadrature decode phase parameters.

Public Members

bool enablePhaseFilter

True: enable phase filter; false: disable filter

uint32_t phaseFilterVal

Filter value, used only if phase filter is enabled

ftm_phase_polarity_t phasePolarity

Phase polarity

struct _ftm_fault_param
#include <fsl_ftm.h>

Structure is used to hold the parameters to configure a FTM fault.

Public Members

bool enableFaultInput

True: Fault input is enabled; false: Fault input is disabled

bool faultLevel

True: Fault polarity is active low; in other words, ‘0’ indicates a fault; False: Fault polarity is active high

bool useFaultFilter

True: Use the filtered fault signal; False: Use the direct path from fault input

struct _ftm_config
#include <fsl_ftm.h>

FTM configuration structure.

This structure holds the configuration settings for the FTM peripheral. To initialize this structure to reasonable defaults, call the FTM_GetDefaultConfig() function and pass a pointer to the configuration structure instance.

The configuration structure can be made constant so as to reside in flash.

Public Members

ftm_clock_prescale_t prescale

FTM clock prescale value

ftm_bdm_mode_t bdmMode

FTM behavior in BDM mode

uint32_t pwmSyncMode

Synchronization methods to use to update buffered registers; Multiple update modes can be used by providing an OR’ed list of options available in enumeration ftm_pwm_sync_method_t.

uint32_t reloadPoints

FTM reload points; When using this, the PWM synchronization is not required. Multiple reload points can be used by providing an OR’ed list of options available in enumeration ftm_reload_point_t.

ftm_fault_mode_t faultMode

FTM fault control mode

uint8_t faultFilterValue

Fault input filter value

ftm_deadtime_prescale_t deadTimePrescale

The dead time prescalar value

uint32_t deadTimeValue

The dead time value deadTimeValue’s available range is 0-1023 when register has DTVALEX, otherwise its available range is 0-63.

uint32_t extTriggers

External triggers to enable. Multiple trigger sources can be enabled by providing an OR’ed list of options available in enumeration ftm_external_trigger_t.

uint8_t chnlInitState

Defines the initialization value of the channels in OUTINT register

uint8_t chnlPolarity

Defines the output polarity of the channels in POL register

bool useGlobalTimeBase

True: Use of an external global time base is enabled; False: disabled

bool swTriggerResetCount

FTM counter synchronization activated by software trigger, avtive when (syncMethod & FTM_SYNC_SWSYNC_MASK) != 0U

bool hwTriggerResetCount

FTM counter synchronization activated by hardware trigger, avtive when (syncMethod & (FTM_SYNC_TRIG0_MASK | FTM_SYNC_TRIG1_MASK | FTM_SYNC_TRIG2_MASK)) != 0U

GPIO: General-Purpose Input/Output Driver

FSL_GPIO_DRIVER_VERSION

GPIO driver version.

enum _gpio_port_num

PORT definition.

Values:

enumerator kGPIO_PORTA
enumerator kGPIO_PORTB
enumerator kGPIO_PORTC
enumerator kGPIO_PORTD
enumerator kGPIO_PORTE
enumerator kGPIO_PORTF
enumerator kGPIO_PORTG
enumerator kGPIO_PORTH
enum _gpio_pin_direction

GPIO direction definition.

Values:

enumerator kGPIO_DigitalInput

Set current pin as digital input

enumerator kGPIO_DigitalOutput

Set current pin as digital output

typedef enum _gpio_port_num gpio_port_num_t

PORT definition.

typedef enum _gpio_pin_direction gpio_pin_direction_t

GPIO direction definition.

typedef struct _gpio_pin_config gpio_pin_config_t

The GPIO pin configuration structure.

Each pin can only be configured as either an output pin or an input pin at a time. If configured as an input pin, leave the outputConfig unused. Note that in some use cases, the corresponding port property should be configured in advance with the PORT_SetPinConfig().

struct _gpio_pin_config
#include <fsl_gpio.h>

The GPIO pin configuration structure.

Each pin can only be configured as either an output pin or an input pin at a time. If configured as an input pin, leave the outputConfig unused. Note that in some use cases, the corresponding port property should be configured in advance with the PORT_SetPinConfig().

Public Members

gpio_pin_direction_t pinDirection

GPIO direction, input or output

uint8_t outputLogic

Set a default output logic, which has no use in input

GPIO Driver

void GPIO_PinInit(gpio_port_num_t port, uint8_t pin, const gpio_pin_config_t *config)

Initializes a GPIO pin used by the board.

To initialize the GPIO, define a pin configuration, as either input or output, in the user file. Then, call the GPIO_PinInit() function.

This is an example to define an input pin or an output pin configuration.

Define a digital input pin configuration,
gpio_pin_config_t config =
{
  kGPIO_DigitalInput,
  0,
}
Define a digital output pin configuration,
gpio_pin_config_t config =
{
  kGPIO_DigitalOutput,
  0,
}

Parameters:
  • port – GPIO PORT number, see “gpio_port_num_t”. For each group GPIO (GPIOA, GPIOB,etc) control registers, they handles four PORT number controls. GPIOA serial registers –&#8212; PTA 0 ~ 7, PTB 0 ~7 … PTD 0 ~ 7. GPIOB serial registers –&#8212; PTE 0 ~ 7, PTF 0 ~7 … PTH 0 ~ 7. …

  • pin – GPIO port pin number

  • config – GPIO pin configuration pointer

void GPIO_PinWrite(gpio_port_num_t port, uint8_t pin, uint8_t output)

Sets the output level of the multiple GPIO pins to the logic 1 or 0.

Parameters:
  • port – GPIO PORT number, see “gpio_port_num_t”. For each group GPIO (GPIOA, GPIOB,etc) control registers, they handles four PORT number controls. GPIOA serial registers –&#8212; PTA 0 ~ 7, PTB 0 ~7 … PTD 0 ~ 7. GPIOB serial registers –&#8212; PTE 0 ~ 7, PTF 0 ~7 … PTH 0 ~ 7. …

  • pin – GPIO pin number

  • output – GPIO pin output logic level.

    • 0: corresponding pin output low-logic level.

    • 1: corresponding pin output high-logic level.

void GPIO_PortSet(gpio_port_num_t port, uint8_t mask)

Sets the output level of the multiple GPIO pins to the logic 1.

Parameters:
  • port – GPIO PORT number, see “gpio_port_num_t”. For each group GPIO (GPIOA, GPIOB,etc) control registers, they handles four PORT number controls. GPIOA serial registers –&#8212; PTA 0 ~ 7, PTB 0 ~7 … PTD 0 ~ 7. GPIOB serial registers –&#8212; PTE 0 ~ 7, PTF 0 ~7 … PTH 0 ~ 7. …

  • mask – GPIO pin number macro

void GPIO_PortClear(gpio_port_num_t port, uint8_t mask)

Sets the output level of the multiple GPIO pins to the logic 0.

Parameters:
  • port – GPIO PORT number, see “gpio_port_num_t”. For each group GPIO (GPIOA, GPIOB,etc) control registers, they handles four PORT number controls. GPIOA serial registers –&#8212; PTA 0 ~ 7, PTB 0 ~7 … PTD 0 ~ 7. GPIOB serial registers –&#8212; PTE 0 ~ 7, PTF 0 ~7 … PTH 0 ~ 7. …

  • mask – GPIO pin number macro

void GPIO_PortToggle(gpio_port_num_t port, uint8_t mask)

Reverses the current output logic of the multiple GPIO pins.

Parameters:
  • port – GPIO PORT number, see “gpio_port_num_t”. For each group GPIO (GPIOA, GPIOB,etc) control registers, they handles four PORT number controls. GPIOA serial registers –&#8212; PTA 0 ~ 7, PTB 0 ~7 … PTD 0 ~ 7. GPIOB serial registers –&#8212; PTE 0 ~ 7, PTF 0 ~7 … PTH 0 ~ 7. …

  • mask – GPIO pin number macro

uint32_t GPIO_PinRead(gpio_port_num_t port, uint8_t pin)

Reads the current input value of the GPIO port.

Parameters:
  • port – GPIO PORT number, see “gpio_port_num_t”. For each group GPIO (GPIOA, GPIOB,etc) control registers, they handles four PORT number controls. GPIOA serial registers –&#8212; PTA 0 ~ 7, PTB 0 ~7 … PTD 0 ~ 7. GPIOB serial registers –&#8212; PTE 0 ~ 7, PTF 0 ~7 … PTH 0 ~ 7. …

  • pin – GPIO pin number

Return values:

GPIO – port input value

  • 0: corresponding pin input low-logic level.

  • 1: corresponding pin input high-logic level.

I2C: Inter-Integrated Circuit Driver

I2C Driver

void I2C_MasterInit(I2C_Type *base, const i2c_master_config_t *masterConfig, uint32_t srcClock_Hz)

Initializes the I2C peripheral. Call this API to ungate the I2C clock and configure the I2C with master configuration.

Note

This API should be called at the beginning of the application. Otherwise, any operation to the I2C module can cause a hard fault because the clock is not enabled. The configuration structure can be custom filled or it can be set with default values by using the I2C_MasterGetDefaultConfig(). After calling this API, the master is ready to transfer. This is an example.

i2c_master_config_t config = {
.enableMaster = true,
.enableStopHold = false,
.highDrive = false,
.baudRate_Bps = 100000,
.glitchFilterWidth = 0
};
I2C_MasterInit(I2C0, &config, 12000000U);

Parameters:
  • base – I2C base pointer

  • masterConfig – A pointer to the master configuration structure

  • srcClock_Hz – I2C peripheral clock frequency in Hz

void I2C_SlaveInit(I2C_Type *base, const i2c_slave_config_t *slaveConfig, uint32_t srcClock_Hz)

Initializes the I2C peripheral. Call this API to ungate the I2C clock and initialize the I2C with the slave configuration.

Note

This API should be called at the beginning of the application. Otherwise, any operation to the I2C module can cause a hard fault because the clock is not enabled. The configuration structure can partly be set with default values by I2C_SlaveGetDefaultConfig() or it can be custom filled by the user. This is an example.

i2c_slave_config_t config = {
.enableSlave = true,
.enableGeneralCall = false,
.addressingMode = kI2C_Address7bit,
.slaveAddress = 0x1DU,
.enableWakeUp = false,
.enablehighDrive = false,
.enableBaudRateCtl = false,
.sclStopHoldTime_ns = 4000
};
I2C_SlaveInit(I2C0, &config, 12000000U);

Parameters:
  • base – I2C base pointer

  • slaveConfig – A pointer to the slave configuration structure

  • srcClock_Hz – I2C peripheral clock frequency in Hz

void I2C_MasterDeinit(I2C_Type *base)

De-initializes the I2C master peripheral. Call this API to gate the I2C clock. The I2C master module can’t work unless the I2C_MasterInit is called.

Parameters:
  • base – I2C base pointer

void I2C_SlaveDeinit(I2C_Type *base)

De-initializes the I2C slave peripheral. Calling this API gates the I2C clock. The I2C slave module can’t work unless the I2C_SlaveInit is called to enable the clock.

Parameters:
  • base – I2C base pointer

uint32_t I2C_GetInstance(I2C_Type *base)

Get instance number for I2C module.

Parameters:
  • base – I2C peripheral base address.

void I2C_MasterGetDefaultConfig(i2c_master_config_t *masterConfig)

Sets the I2C master configuration structure to default values.

The purpose of this API is to get the configuration structure initialized for use in the I2C_MasterConfigure(). Use the initialized structure unchanged in the I2C_MasterConfigure() or modify the structure before calling the I2C_MasterConfigure(). This is an example.

i2c_master_config_t config;
I2C_MasterGetDefaultConfig(&config);

Parameters:
  • masterConfig – A pointer to the master configuration structure.

void I2C_SlaveGetDefaultConfig(i2c_slave_config_t *slaveConfig)

Sets the I2C slave configuration structure to default values.

The purpose of this API is to get the configuration structure initialized for use in the I2C_SlaveConfigure(). Modify fields of the structure before calling the I2C_SlaveConfigure(). This is an example.

i2c_slave_config_t config;
I2C_SlaveGetDefaultConfig(&config);

Parameters:
  • slaveConfig – A pointer to the slave configuration structure.

static inline void I2C_Enable(I2C_Type *base, bool enable)

Enables or disables the I2C peripheral operation.

Parameters:
  • base – I2C base pointer

  • enable – Pass true to enable and false to disable the module.

uint32_t I2C_MasterGetStatusFlags(I2C_Type *base)

Gets the I2C status flags.

Parameters:
  • base – I2C base pointer

Returns:

status flag, use status flag to AND _i2c_flags to get the related status.

static inline uint32_t I2C_SlaveGetStatusFlags(I2C_Type *base)

Gets the I2C status flags.

Parameters:
  • base – I2C base pointer

Returns:

status flag, use status flag to AND _i2c_flags to get the related status.

static inline void I2C_MasterClearStatusFlags(I2C_Type *base, uint32_t statusMask)

Clears the I2C status flag state.

The following status register flags can be cleared kI2C_ArbitrationLostFlag and kI2C_IntPendingFlag.

Parameters:
  • base – I2C base pointer

  • statusMask – The status flag mask, defined in type i2c_status_flag_t. The parameter can be any combination of the following values:

    • kI2C_StartDetectFlag (if available)

    • kI2C_StopDetectFlag (if available)

    • kI2C_ArbitrationLostFlag

    • kI2C_IntPendingFlagFlag

static inline void I2C_SlaveClearStatusFlags(I2C_Type *base, uint32_t statusMask)

Clears the I2C status flag state.

The following status register flags can be cleared kI2C_ArbitrationLostFlag and kI2C_IntPendingFlag

Parameters:
  • base – I2C base pointer

  • statusMask – The status flag mask, defined in type i2c_status_flag_t. The parameter can be any combination of the following values:

    • kI2C_StartDetectFlag (if available)

    • kI2C_StopDetectFlag (if available)

    • kI2C_ArbitrationLostFlag

    • kI2C_IntPendingFlagFlag

void I2C_EnableInterrupts(I2C_Type *base, uint32_t mask)

Enables I2C interrupt requests.

Parameters:
  • base – I2C base pointer

  • mask – interrupt source The parameter can be combination of the following source if defined:

    • kI2C_GlobalInterruptEnable

    • kI2C_StopDetectInterruptEnable/kI2C_StartDetectInterruptEnable

    • kI2C_SdaTimeoutInterruptEnable

void I2C_DisableInterrupts(I2C_Type *base, uint32_t mask)

Disables I2C interrupt requests.

Parameters:
  • base – I2C base pointer

  • mask – interrupt source The parameter can be combination of the following source if defined:

    • kI2C_GlobalInterruptEnable

    • kI2C_StopDetectInterruptEnable/kI2C_StartDetectInterruptEnable

    • kI2C_SdaTimeoutInterruptEnable

static inline void I2C_EnableDMA(I2C_Type *base, bool enable)

Enables/disables the I2C DMA interrupt.

Parameters:
  • base – I2C base pointer

  • enable – true to enable, false to disable

static inline uint32_t I2C_GetDataRegAddr(I2C_Type *base)

Gets the I2C tx/rx data register address. This API is used to provide a transfer address for I2C DMA transfer configuration.

Parameters:
  • base – I2C base pointer

Returns:

data register address

void I2C_MasterSetBaudRate(I2C_Type *base, uint32_t baudRate_Bps, uint32_t srcClock_Hz)

Sets the I2C master transfer baud rate.

Parameters:
  • base – I2C base pointer

  • baudRate_Bps – the baud rate value in bps

  • srcClock_Hz – Source clock

status_t I2C_MasterStart(I2C_Type *base, uint8_t address, i2c_direction_t direction)

Sends a START on the I2C bus.

This function is used to initiate a new master mode transfer by sending the START signal. The slave address is sent following the I2C START signal.

Parameters:
  • base – I2C peripheral base pointer

  • address – 7-bit slave device address.

  • direction – Master transfer directions(transmit/receive).

Return values:
  • kStatus_Success – Successfully send the start signal.

  • kStatus_I2C_Busy – Current bus is busy.

status_t I2C_MasterStop(I2C_Type *base)

Sends a STOP signal on the I2C bus.

Return values:
  • kStatus_Success – Successfully send the stop signal.

  • kStatus_I2C_Timeout – Send stop signal failed, timeout.

status_t I2C_MasterRepeatedStart(I2C_Type *base, uint8_t address, i2c_direction_t direction)

Sends a REPEATED START on the I2C bus.

Parameters:
  • base – I2C peripheral base pointer

  • address – 7-bit slave device address.

  • direction – Master transfer directions(transmit/receive).

Return values:
  • kStatus_Success – Successfully send the start signal.

  • kStatus_I2C_Busy – Current bus is busy but not occupied by current I2C master.

status_t I2C_MasterWriteBlocking(I2C_Type *base, const uint8_t *txBuff, size_t txSize, uint32_t flags)

Performs a polling send transaction on the I2C bus.

Parameters:
  • base – The I2C peripheral base pointer.

  • txBuff – The pointer to the data to be transferred.

  • txSize – The length in bytes of the data to be transferred.

  • flags – Transfer control flag to decide whether need to send a stop, use kI2C_TransferDefaultFlag to issue a stop and kI2C_TransferNoStop to not send a stop.

Return values:
  • kStatus_Success – Successfully complete the data transmission.

  • kStatus_I2C_ArbitrationLost – Transfer error, arbitration lost.

  • kStataus_I2C_Nak – Transfer error, receive NAK during transfer.

status_t I2C_MasterReadBlocking(I2C_Type *base, uint8_t *rxBuff, size_t rxSize, uint32_t flags)

Performs a polling receive transaction on the I2C bus.

Note

The I2C_MasterReadBlocking function stops the bus before reading the final byte. Without stopping the bus prior for the final read, the bus issues another read, resulting in garbage data being read into the data register.

Parameters:
  • base – I2C peripheral base pointer.

  • rxBuff – The pointer to the data to store the received data.

  • rxSize – The length in bytes of the data to be received.

  • flags – Transfer control flag to decide whether need to send a stop, use kI2C_TransferDefaultFlag to issue a stop and kI2C_TransferNoStop to not send a stop.

Return values:
  • kStatus_Success – Successfully complete the data transmission.

  • kStatus_I2C_Timeout – Send stop signal failed, timeout.

status_t I2C_SlaveWriteBlocking(I2C_Type *base, const uint8_t *txBuff, size_t txSize)

Performs a polling send transaction on the I2C bus.

Parameters:
  • base – The I2C peripheral base pointer.

  • txBuff – The pointer to the data to be transferred.

  • txSize – The length in bytes of the data to be transferred.

Return values:
  • kStatus_Success – Successfully complete the data transmission.

  • kStatus_I2C_ArbitrationLost – Transfer error, arbitration lost.

  • kStataus_I2C_Nak – Transfer error, receive NAK during transfer.

status_t I2C_SlaveReadBlocking(I2C_Type *base, uint8_t *rxBuff, size_t rxSize)

Performs a polling receive transaction on the I2C bus.

Parameters:
  • base – I2C peripheral base pointer.

  • rxBuff – The pointer to the data to store the received data.

  • rxSize – The length in bytes of the data to be received.

Return values:
  • kStatus_Success – Successfully complete data receive.

  • kStatus_I2C_Timeout – Wait status flag timeout.

status_t I2C_MasterTransferBlocking(I2C_Type *base, i2c_master_transfer_t *xfer)

Performs a master polling transfer on the I2C bus.

Note

The API does not return until the transfer succeeds or fails due to arbitration lost or receiving a NAK.

Parameters:
  • base – I2C peripheral base address.

  • xfer – Pointer to the transfer structure.

Return values:
  • kStatus_Success – Successfully complete the data transmission.

  • kStatus_I2C_Busy – Previous transmission still not finished.

  • kStatus_I2C_Timeout – Transfer error, wait signal timeout.

  • kStatus_I2C_ArbitrationLost – Transfer error, arbitration lost.

  • kStataus_I2C_Nak – Transfer error, receive NAK during transfer.

void I2C_MasterTransferCreateHandle(I2C_Type *base, i2c_master_handle_t *handle, i2c_master_transfer_callback_t callback, void *userData)

Initializes the I2C handle which is used in transactional functions.

Parameters:
  • base – I2C base pointer.

  • handle – pointer to i2c_master_handle_t structure to store the transfer state.

  • callback – pointer to user callback function.

  • userData – user parameter passed to the callback function.

status_t I2C_MasterTransferNonBlocking(I2C_Type *base, i2c_master_handle_t *handle, i2c_master_transfer_t *xfer)

Performs a master interrupt non-blocking transfer on the I2C bus.

Note

Calling the API returns immediately after transfer initiates. The user needs to call I2C_MasterGetTransferCount to poll the transfer status to check whether the transfer is finished. If the return status is not kStatus_I2C_Busy, the transfer is finished.

Parameters:
  • base – I2C base pointer.

  • handle – pointer to i2c_master_handle_t structure which stores the transfer state.

  • xfer – pointer to i2c_master_transfer_t structure.

Return values:
  • kStatus_Success – Successfully start the data transmission.

  • kStatus_I2C_Busy – Previous transmission still not finished.

  • kStatus_I2C_Timeout – Transfer error, wait signal timeout.

status_t I2C_MasterTransferGetCount(I2C_Type *base, i2c_master_handle_t *handle, size_t *count)

Gets the master transfer status during a interrupt non-blocking transfer.

Parameters:
  • base – I2C base pointer.

  • handle – pointer to i2c_master_handle_t structure which stores the transfer state.

  • count – Number of bytes transferred so far by the non-blocking transaction.

Return values:
  • kStatus_InvalidArgument – count is Invalid.

  • kStatus_Success – Successfully return the count.

status_t I2C_MasterTransferAbort(I2C_Type *base, i2c_master_handle_t *handle)

Aborts an interrupt non-blocking transfer early.

Note

This API can be called at any time when an interrupt non-blocking transfer initiates to abort the transfer early.

Parameters:
  • base – I2C base pointer.

  • handle – pointer to i2c_master_handle_t structure which stores the transfer state

Return values:
  • kStatus_I2C_Timeout – Timeout during polling flag.

  • kStatus_Success – Successfully abort the transfer.

void I2C_MasterTransferHandleIRQ(I2C_Type *base, void *i2cHandle)

Master interrupt handler.

Parameters:
  • base – I2C base pointer.

  • i2cHandle – pointer to i2c_master_handle_t structure.

void I2C_SlaveTransferCreateHandle(I2C_Type *base, i2c_slave_handle_t *handle, i2c_slave_transfer_callback_t callback, void *userData)

Initializes the I2C handle which is used in transactional functions.

Parameters:
  • base – I2C base pointer.

  • handle – pointer to i2c_slave_handle_t structure to store the transfer state.

  • callback – pointer to user callback function.

  • userData – user parameter passed to the callback function.

status_t I2C_SlaveTransferNonBlocking(I2C_Type *base, i2c_slave_handle_t *handle, uint32_t eventMask)

Starts accepting slave transfers.

Call this API after calling the I2C_SlaveInit() and I2C_SlaveTransferCreateHandle() to start processing transactions driven by an I2C master. The slave monitors the I2C bus and passes events to the callback that was passed into the call to I2C_SlaveTransferCreateHandle(). The callback is always invoked from the interrupt context.

The set of events received by the callback is customizable. To do so, set the eventMask parameter to the OR’d combination of i2c_slave_transfer_event_t enumerators for the events you wish to receive. The kI2C_SlaveTransmitEvent and kLPI2C_SlaveReceiveEvent events are always enabled and do not need to be included in the mask. Alternatively, pass 0 to get a default set of only the transmit and receive events that are always enabled. In addition, the kI2C_SlaveAllEvents constant is provided as a convenient way to enable all events.

Parameters:
  • base – The I2C peripheral base address.

  • handle – Pointer to i2c_slave_handle_t structure which stores the transfer state.

  • eventMask – Bit mask formed by OR’ing together i2c_slave_transfer_event_t enumerators to specify which events to send to the callback. Other accepted values are 0 to get a default set of only the transmit and receive events, and kI2C_SlaveAllEvents to enable all events.

Return values:
  • kStatus_Success – Slave transfers were successfully started.

  • kStatus_I2C_Busy – Slave transfers have already been started on this handle.

void I2C_SlaveTransferAbort(I2C_Type *base, i2c_slave_handle_t *handle)

Aborts the slave transfer.

Note

This API can be called at any time to stop slave for handling the bus events.

Parameters:
  • base – I2C base pointer.

  • handle – pointer to i2c_slave_handle_t structure which stores the transfer state.

status_t I2C_SlaveTransferGetCount(I2C_Type *base, i2c_slave_handle_t *handle, size_t *count)

Gets the slave transfer remaining bytes during a interrupt non-blocking transfer.

Parameters:
  • base – I2C base pointer.

  • handle – pointer to i2c_slave_handle_t structure.

  • count – Number of bytes transferred so far by the non-blocking transaction.

Return values:
  • kStatus_InvalidArgument – count is Invalid.

  • kStatus_Success – Successfully return the count.

void I2C_SlaveTransferHandleIRQ(I2C_Type *base, void *i2cHandle)

Slave interrupt handler.

Parameters:
  • base – I2C base pointer.

  • i2cHandle – pointer to i2c_slave_handle_t structure which stores the transfer state

FSL_I2C_DRIVER_VERSION

I2C driver version.

I2C status return codes.

Values:

enumerator kStatus_I2C_Busy

I2C is busy with current transfer.

enumerator kStatus_I2C_Idle

Bus is Idle.

enumerator kStatus_I2C_Nak

NAK received during transfer.

enumerator kStatus_I2C_ArbitrationLost

Arbitration lost during transfer.

enumerator kStatus_I2C_Timeout

Timeout polling status flags.

enumerator kStatus_I2C_Addr_Nak

NAK received during the address probe.

enum _i2c_flags

I2C peripheral flags.

Note

These enumerations are meant to be OR’d together to form a bit mask.

Values:

enumerator kI2C_ReceiveNakFlag

I2C receive NAK flag.

enumerator kI2C_IntPendingFlag

I2C interrupt pending flag. This flag can be cleared.

enumerator kI2C_TransferDirectionFlag

I2C transfer direction flag.

enumerator kI2C_RangeAddressMatchFlag

I2C range address match flag.

enumerator kI2C_ArbitrationLostFlag

I2C arbitration lost flag. This flag can be cleared.

enumerator kI2C_BusBusyFlag

I2C bus busy flag.

enumerator kI2C_AddressMatchFlag

I2C address match flag.

enumerator kI2C_TransferCompleteFlag

I2C transfer complete flag.

enumerator kI2C_StopDetectFlag

I2C stop detect flag. This flag can be cleared.

enumerator kI2C_StartDetectFlag

I2C start detect flag. This flag can be cleared.

enum _i2c_interrupt_enable

I2C feature interrupt source.

Values:

enumerator kI2C_GlobalInterruptEnable

I2C global interrupt.

enumerator kI2C_StopDetectInterruptEnable

I2C stop detect interrupt.

enumerator kI2C_StartStopDetectInterruptEnable

I2C start&stop detect interrupt.

enum _i2c_direction

The direction of master and slave transfers.

Values:

enumerator kI2C_Write

Master transmits to the slave.

enumerator kI2C_Read

Master receives from the slave.

enum _i2c_slave_address_mode

Addressing mode.

Values:

enumerator kI2C_Address7bit

7-bit addressing mode.

enumerator kI2C_RangeMatch

Range address match addressing mode.

enum _i2c_master_transfer_flags

I2C transfer control flag.

Values:

enumerator kI2C_TransferDefaultFlag

A transfer starts with a start signal, stops with a stop signal.

enumerator kI2C_TransferNoStartFlag

A transfer starts without a start signal, only support write only or write+read with no start flag, do not support read only with no start flag.

enumerator kI2C_TransferRepeatedStartFlag

A transfer starts with a repeated start signal.

enumerator kI2C_TransferNoStopFlag

A transfer ends without a stop signal.

enum _i2c_slave_transfer_event

Set of events sent to the callback for nonblocking slave transfers.

These event enumerations are used for two related purposes. First, a bit mask created by OR’ing together events is passed to I2C_SlaveTransferNonBlocking() to specify which events to enable. Then, when the slave callback is invoked, it is passed the current event through its transfer parameter.

Note

These enumerations are meant to be OR’d together to form a bit mask of events.

Values:

enumerator kI2C_SlaveAddressMatchEvent

Received the slave address after a start or repeated start.

enumerator kI2C_SlaveTransmitEvent

A callback is requested to provide data to transmit (slave-transmitter role).

enumerator kI2C_SlaveReceiveEvent

A callback is requested to provide a buffer in which to place received data (slave-receiver role).

enumerator kI2C_SlaveTransmitAckEvent

A callback needs to either transmit an ACK or NACK.

enumerator kI2C_SlaveStartEvent

A start/repeated start was detected.

enumerator kI2C_SlaveCompletionEvent

A stop was detected or finished transfer, completing the transfer.

enumerator kI2C_SlaveGenaralcallEvent

Received the general call address after a start or repeated start.

enumerator kI2C_SlaveAllEvents

A bit mask of all available events.

Common sets of flags used by the driver.

Values:

enumerator kClearFlags

All flags which are cleared by the driver upon starting a transfer.

enumerator kIrqFlags
typedef enum _i2c_direction i2c_direction_t

The direction of master and slave transfers.

typedef enum _i2c_slave_address_mode i2c_slave_address_mode_t

Addressing mode.

typedef enum _i2c_slave_transfer_event i2c_slave_transfer_event_t

Set of events sent to the callback for nonblocking slave transfers.

These event enumerations are used for two related purposes. First, a bit mask created by OR’ing together events is passed to I2C_SlaveTransferNonBlocking() to specify which events to enable. Then, when the slave callback is invoked, it is passed the current event through its transfer parameter.

Note

These enumerations are meant to be OR’d together to form a bit mask of events.

typedef struct _i2c_master_config i2c_master_config_t

I2C master user configuration.

typedef struct _i2c_slave_config i2c_slave_config_t

I2C slave user configuration.

typedef struct _i2c_master_handle i2c_master_handle_t

I2C master handle typedef.

typedef void (*i2c_master_transfer_callback_t)(I2C_Type *base, i2c_master_handle_t *handle, status_t status, void *userData)

I2C master transfer callback typedef.

typedef struct _i2c_slave_handle i2c_slave_handle_t

I2C slave handle typedef.

typedef struct _i2c_master_transfer i2c_master_transfer_t

I2C master transfer structure.

typedef struct _i2c_slave_transfer i2c_slave_transfer_t

I2C slave transfer structure.

typedef void (*i2c_slave_transfer_callback_t)(I2C_Type *base, i2c_slave_transfer_t *xfer, void *userData)

I2C slave transfer callback typedef.

I2C_RETRY_TIMES

Retry times for waiting flag.

I2C_MASTER_FACK_CONTROL

Mater Fast ack control, control if master needs to manually write ack, this is used to low the speed of transfer for SoCs with feature FSL_FEATURE_I2C_HAS_DOUBLE_BUFFERING.

I2C_HAS_STOP_DETECT
struct _i2c_master_config
#include <fsl_i2c.h>

I2C master user configuration.

Public Members

bool enableMaster

Enables the I2C peripheral at initialization time.

bool enableStopHold

Controls the stop hold enable.

bool enableDoubleBuffering

Controls double buffer enable; notice that enabling the double buffer disables the clock stretch.

uint32_t baudRate_Bps

Baud rate configuration of I2C peripheral.

uint8_t glitchFilterWidth

Controls the width of the glitch.

struct _i2c_slave_config
#include <fsl_i2c.h>

I2C slave user configuration.

Public Members

bool enableSlave

Enables the I2C peripheral at initialization time.

bool enableGeneralCall

Enables the general call addressing mode.

bool enableWakeUp

Enables/disables waking up MCU from low-power mode.

bool enableDoubleBuffering

Controls a double buffer enable; notice that enabling the double buffer disables the clock stretch.

bool enableBaudRateCtl

Enables/disables independent slave baud rate on SCL in very fast I2C modes.

uint16_t slaveAddress

A slave address configuration.

uint16_t upperAddress

A maximum boundary slave address used in a range matching mode.

i2c_slave_address_mode_t addressingMode

An addressing mode configuration of i2c_slave_address_mode_config_t.

uint32_t sclStopHoldTime_ns

the delay from the rising edge of SCL (I2C clock) to the rising edge of SDA (I2C data) while SCL is high (stop condition), SDA hold time and SCL start hold time are also configured according to the SCL stop hold time.

struct _i2c_master_transfer
#include <fsl_i2c.h>

I2C master transfer structure.

Public Members

uint32_t flags

A transfer flag which controls the transfer.

uint8_t slaveAddress

7-bit slave address.

i2c_direction_t direction

A transfer direction, read or write.

uint32_t subaddress

A sub address. Transferred MSB first.

uint8_t subaddressSize

A size of the command buffer.

uint8_t *volatile data

A transfer buffer.

volatile size_t dataSize

A transfer size.

struct _i2c_master_handle
#include <fsl_i2c.h>

I2C master handle structure.

Public Members

i2c_master_transfer_t transfer

I2C master transfer copy.

size_t transferSize

Total bytes to be transferred.

uint8_t state

A transfer state maintained during transfer.

i2c_master_transfer_callback_t completionCallback

A callback function called when the transfer is finished.

void *userData

A callback parameter passed to the callback function.

struct _i2c_slave_transfer
#include <fsl_i2c.h>

I2C slave transfer structure.

Public Members

i2c_slave_transfer_event_t event

A reason that the callback is invoked.

uint8_t *volatile data

A transfer buffer.

volatile size_t dataSize

A transfer size.

status_t completionStatus

Success or error code describing how the transfer completed. Only applies for kI2C_SlaveCompletionEvent.

size_t transferredCount

A number of bytes actually transferred since the start or since the last repeated start.

struct _i2c_slave_handle
#include <fsl_i2c.h>

I2C slave handle structure.

Public Members

volatile bool isBusy

Indicates whether a transfer is busy.

i2c_slave_transfer_t transfer

I2C slave transfer copy.

uint32_t eventMask

A mask of enabled events.

i2c_slave_transfer_callback_t callback

A callback function called at the transfer event.

void *userData

A callback parameter passed to the callback.

Irq

uint32_t IRQ_GetInstance(IRQ_Type *base)

Get irq instance.

Parameters:
  • base – IRQ peripheral base pointer

Return values:

Irq – instance number.

void IRQ_Init(IRQ_Type *base, const irq_config_t *config)

Initializes the IRQ pin used by the board.

To initialize the IRQ pin, define a irq configuration, specify whhether enable pull-up, the edge and detect mode. Then, call the IRQ_Init() function.

This is an example to initialize irq configuration.

irq_config_t config =
{
  true,
  kIRQ_FallingEdgeorLowlevel,
  kIRQ_DetectOnEdgesOnly
}

Parameters:
  • base – IRQ peripheral base pointer

  • config – IRQ configuration pointer

void IRQ_Deinit(IRQ_Type *base)

Deinitialize IRQ peripheral.

This function disables the IRQ clock.

Parameters:
  • base – IRQ peripheral base pointer.

Return values:

None.

static inline void IRQ_Enable(IRQ_Type *base, bool enable)

Enable/disable IRQ pin.

Parameters:
  • base – IRQ peripheral base pointer.

  • enable – true to enable IRQ pin, else disable IRQ pin.

Return values:

None.

static inline void IRQ_EnableInterrupt(IRQ_Type *base, bool enable)

Enable/disable IRQ pin interrupt.

Parameters:
  • base – IRQ peripheral base pointer.

  • enable – true to enable IRQF assert interrupt request, else disable.

Return values:

None.

static inline void IRQ_ClearIRQFlag(IRQ_Type *base)

Clear IRQF flag.

This function clears the IRQF flag.

Parameters:
  • base – IRQ peripheral base pointer.

Return values:

None.

static inline uint32_t IRQ_GetIRQFlag(IRQ_Type *base)

Get IRQF flag.

This function returns the IRQF flag.

Parameters:
  • base – IRQ peripheral base pointer.

Return values:

status – = 0 IRQF flag deasserted. = 1 IRQF flag asserted.

FSL_IRQ_DRIVER_VERSION

Version 2.0.2.

enum _irq_edge

Interrupt Request (IRQ) Edge Select.

Values:

enumerator kIRQ_FallingEdgeorLowlevel

IRQ is falling-edge or falling-edge/low-level sensitive

enumerator kIRQ_RisingEdgeorHighlevel

IRQ is rising-edge or rising-edge/high-level sensitive

enum _irq_mode

Interrupt Request (IRQ) Detection Mode.

Values:

enumerator kIRQ_DetectOnEdgesOnly

IRQ event is detected only on falling/rising edges

enumerator kIRQ_DetectOnEdgesAndEdges

IRQ event is detected on falling/rising edges and low/high levels

typedef enum _irq_edge irq_edge_t

Interrupt Request (IRQ) Edge Select.

typedef enum _irq_mode irq_mode_t

Interrupt Request (IRQ) Detection Mode.

typedef struct _irq_config irq_config_t

The IRQ pin configuration structure.

struct _irq_config
#include <fsl_irq.h>

The IRQ pin configuration structure.

Public Members

bool enablePullDevice

Enable/disable the internal pullup device when the IRQ pin is enabled

irq_edge_t edgeSelect

Select the polarity of edges or levels on the IRQ pin that cause IRQF to be set

irq_mode_t detectMode

select either edge-only detection or edge-and-level detection

IRQ: external interrupt (IRQ) module

KBI: Keyboard interrupt Driver

void KBI_Init(KBI_Type *base, kbi_config_t *configure)

KBI initialize. This function ungates the KBI clock and initializes KBI. This function must be called before calling any other KBI driver functions.

Parameters:
  • base – KBI peripheral base address.

  • configure – The KBI configuration structure pointer.

void KBI_Deinit(KBI_Type *base)

Deinitializes the KBI module and gates the clock. This function gates the KBI clock. As a result, the KBI module doesn’t work after calling this function.

Parameters:
  • base – KBI peripheral base address.

static inline void KBI_EnableInterrupts(KBI_Type *base)

Enables the interrupt.

Parameters:
  • base – KBI peripheral base address.

static inline void KBI_DisableInterrupts(KBI_Type *base)

Disables the interrupt.

Parameters:
  • base – KBI peripheral base address.

static inline bool KBI_IsInterruptRequestDetected(KBI_Type *base)

Gets the KBI interrupt event status.

Parameters:
  • base – KBI peripheral base address.

Returns:

The status of the KBI interrupt request is detected.

static inline void KBI_ClearInterruptFlag(KBI_Type *base)

Clears KBI status flag.

Parameters:
  • base – KBI peripheral base address.

static inline uint32_t KBI_GetSourcePinStatus(KBI_Type *base)

Gets the KBI Source pin status.

Parameters:
  • base – KBI peripheral base address.

Returns:

The status indicates the active pin defined as keyboard interrupt which is pushed.

FSL_KBI_DRIVER_VERSION

KBI driver version.

enum _kbi_detect_mode

KBI detection mode.

Values:

enumerator kKBI_EdgesDetect

The keyboard detects edges only.

enumerator kKBI_EdgesLevelDetect

The keyboard detects both edges and levels.

typedef uint32_t kbi_reg_t
typedef enum _kbi_detect_mode kbi_detect_mode_t

KBI detection mode.

typedef struct _kbi_config kbi_config_t

KBI configuration.

struct _kbi_config
#include <fsl_kbi.h>

KBI configuration.

Public Members

uint32_t pinsEnabled

The eight kbi pins, set 1 to enable the corresponding KBI interrupt pins.

uint32_t pinsEdge

The edge selection for each kbi pin: 1 &#8212; rinsing edge, 0 &#8212; falling edge.

kbi_detect_mode_t mode

The kbi detection mode.

Common Driver

FSL_COMMON_DRIVER_VERSION

common driver version.

DEBUG_CONSOLE_DEVICE_TYPE_NONE

No debug console.

DEBUG_CONSOLE_DEVICE_TYPE_UART

Debug console based on UART.

DEBUG_CONSOLE_DEVICE_TYPE_LPUART

Debug console based on LPUART.

DEBUG_CONSOLE_DEVICE_TYPE_LPSCI

Debug console based on LPSCI.

DEBUG_CONSOLE_DEVICE_TYPE_USBCDC

Debug console based on USBCDC.

DEBUG_CONSOLE_DEVICE_TYPE_FLEXCOMM

Debug console based on FLEXCOMM.

DEBUG_CONSOLE_DEVICE_TYPE_IUART

Debug console based on i.MX UART.

DEBUG_CONSOLE_DEVICE_TYPE_VUSART

Debug console based on LPC_VUSART.

DEBUG_CONSOLE_DEVICE_TYPE_MINI_USART

Debug console based on LPC_USART.

DEBUG_CONSOLE_DEVICE_TYPE_SWO

Debug console based on SWO.

DEBUG_CONSOLE_DEVICE_TYPE_QSCI

Debug console based on QSCI.

MIN(a, b)

Computes the minimum of a and b.

MAX(a, b)

Computes the maximum of a and b.

UINT16_MAX

Max value of uint16_t type.

UINT32_MAX

Max value of uint32_t type.

SDK_ATOMIC_LOCAL_ADD(addr, val)

Add value val from the variable at address address.

SDK_ATOMIC_LOCAL_SUB(addr, val)

Subtract value val to the variable at address address.

SDK_ATOMIC_LOCAL_SET(addr, bits)

Set the bits specifiled by bits to the variable at address address.

SDK_ATOMIC_LOCAL_CLEAR(addr, bits)

Clear the bits specifiled by bits to the variable at address address.

SDK_ATOMIC_LOCAL_TOGGLE(addr, bits)

Toggle the bits specifiled by bits to the variable at address address.

SDK_ATOMIC_LOCAL_CLEAR_AND_SET(addr, clearBits, setBits)

For the variable at address address, clear the bits specifiled by clearBits and set the bits specifiled by setBits.

SDK_ATOMIC_LOCAL_COMPARE_AND_SET(addr, expected, newValue)

For the variable at address address, check whether the value equal to expected. If value same as expected then update newValue to address and return true , else return false .

SDK_ATOMIC_LOCAL_TEST_AND_SET(addr, newValue)

For the variable at address address, set as newValue value and return old value.

USEC_TO_COUNT(us, clockFreqInHz)

Macro to convert a microsecond period to raw count value

COUNT_TO_USEC(count, clockFreqInHz)

Macro to convert a raw count value to microsecond

MSEC_TO_COUNT(ms, clockFreqInHz)

Macro to convert a millisecond period to raw count value

COUNT_TO_MSEC(count, clockFreqInHz)

Macro to convert a raw count value to millisecond

SDK_ISR_EXIT_BARRIER
SDK_SIZEALIGN(var, alignbytes)

Macro to define a variable with L1 d-cache line size alignment

Macro to define a variable with L2 cache line size alignment

Macro to change a value to a given size aligned value

AT_NONCACHEABLE_SECTION(var)

Define a variable var, and place it in non-cacheable section.

AT_NONCACHEABLE_SECTION_ALIGN(var, alignbytes)

Define a variable var, and place it in non-cacheable section, the start address of the variable is aligned to alignbytes.

AT_NONCACHEABLE_SECTION_INIT(var)

Define a variable var with initial value, and place it in non-cacheable section.

AT_NONCACHEABLE_SECTION_ALIGN_INIT(var, alignbytes)

Define a variable var with initial value, and place it in non-cacheable section, the start address of the variable is aligned to alignbytes.

enum _status_groups

Status group numbers.

Values:

enumerator kStatusGroup_Generic

Group number for generic status codes.

enumerator kStatusGroup_FLASH

Group number for FLASH status codes.

enumerator kStatusGroup_LPSPI

Group number for LPSPI status codes.

enumerator kStatusGroup_FLEXIO_SPI

Group number for FLEXIO SPI status codes.

enumerator kStatusGroup_DSPI

Group number for DSPI status codes.

enumerator kStatusGroup_FLEXIO_UART

Group number for FLEXIO UART status codes.

enumerator kStatusGroup_FLEXIO_I2C

Group number for FLEXIO I2C status codes.

enumerator kStatusGroup_LPI2C

Group number for LPI2C status codes.

enumerator kStatusGroup_UART

Group number for UART status codes.

enumerator kStatusGroup_I2C

Group number for UART status codes.

enumerator kStatusGroup_LPSCI

Group number for LPSCI status codes.

enumerator kStatusGroup_LPUART

Group number for LPUART status codes.

enumerator kStatusGroup_SPI

Group number for SPI status code.

enumerator kStatusGroup_XRDC

Group number for XRDC status code.

enumerator kStatusGroup_SEMA42

Group number for SEMA42 status code.

enumerator kStatusGroup_SDHC

Group number for SDHC status code

enumerator kStatusGroup_SDMMC

Group number for SDMMC status code

enumerator kStatusGroup_SAI

Group number for SAI status code

enumerator kStatusGroup_MCG

Group number for MCG status codes.

enumerator kStatusGroup_SCG

Group number for SCG status codes.

enumerator kStatusGroup_SDSPI

Group number for SDSPI status codes.

enumerator kStatusGroup_FLEXIO_I2S

Group number for FLEXIO I2S status codes

enumerator kStatusGroup_FLEXIO_MCULCD

Group number for FLEXIO LCD status codes

enumerator kStatusGroup_FLASHIAP

Group number for FLASHIAP status codes

enumerator kStatusGroup_FLEXCOMM_I2C

Group number for FLEXCOMM I2C status codes

enumerator kStatusGroup_I2S

Group number for I2S status codes

enumerator kStatusGroup_IUART

Group number for IUART status codes

enumerator kStatusGroup_CSI

Group number for CSI status codes

enumerator kStatusGroup_MIPI_DSI

Group number for MIPI DSI status codes

enumerator kStatusGroup_SDRAMC

Group number for SDRAMC status codes.

enumerator kStatusGroup_POWER

Group number for POWER status codes.

enumerator kStatusGroup_ENET

Group number for ENET status codes.

enumerator kStatusGroup_PHY

Group number for PHY status codes.

enumerator kStatusGroup_TRGMUX

Group number for TRGMUX status codes.

enumerator kStatusGroup_SMARTCARD

Group number for SMARTCARD status codes.

enumerator kStatusGroup_LMEM

Group number for LMEM status codes.

enumerator kStatusGroup_QSPI

Group number for QSPI status codes.

enumerator kStatusGroup_DMA

Group number for DMA status codes.

enumerator kStatusGroup_EDMA

Group number for EDMA status codes.

enumerator kStatusGroup_DMAMGR

Group number for DMAMGR status codes.

enumerator kStatusGroup_FLEXCAN

Group number for FlexCAN status codes.

enumerator kStatusGroup_LTC

Group number for LTC status codes.

enumerator kStatusGroup_FLEXIO_CAMERA

Group number for FLEXIO CAMERA status codes.

enumerator kStatusGroup_LPC_SPI

Group number for LPC_SPI status codes.

enumerator kStatusGroup_LPC_USART

Group number for LPC_USART status codes.

enumerator kStatusGroup_DMIC

Group number for DMIC status codes.

enumerator kStatusGroup_SDIF

Group number for SDIF status codes.

enumerator kStatusGroup_SPIFI

Group number for SPIFI status codes.

enumerator kStatusGroup_OTP

Group number for OTP status codes.

enumerator kStatusGroup_MCAN

Group number for MCAN status codes.

enumerator kStatusGroup_CAAM

Group number for CAAM status codes.

enumerator kStatusGroup_ECSPI

Group number for ECSPI status codes.

enumerator kStatusGroup_USDHC

Group number for USDHC status codes.

enumerator kStatusGroup_LPC_I2C

Group number for LPC_I2C status codes.

enumerator kStatusGroup_DCP

Group number for DCP status codes.

enumerator kStatusGroup_MSCAN

Group number for MSCAN status codes.

enumerator kStatusGroup_ESAI

Group number for ESAI status codes.

enumerator kStatusGroup_FLEXSPI

Group number for FLEXSPI status codes.

enumerator kStatusGroup_MMDC

Group number for MMDC status codes.

enumerator kStatusGroup_PDM

Group number for MIC status codes.

enumerator kStatusGroup_SDMA

Group number for SDMA status codes.

enumerator kStatusGroup_ICS

Group number for ICS status codes.

enumerator kStatusGroup_SPDIF

Group number for SPDIF status codes.

enumerator kStatusGroup_LPC_MINISPI

Group number for LPC_MINISPI status codes.

enumerator kStatusGroup_HASHCRYPT

Group number for Hashcrypt status codes

enumerator kStatusGroup_LPC_SPI_SSP

Group number for LPC_SPI_SSP status codes.

enumerator kStatusGroup_I3C

Group number for I3C status codes

enumerator kStatusGroup_LPC_I2C_1

Group number for LPC_I2C_1 status codes.

enumerator kStatusGroup_NOTIFIER

Group number for NOTIFIER status codes.

enumerator kStatusGroup_DebugConsole

Group number for debug console status codes.

enumerator kStatusGroup_SEMC

Group number for SEMC status codes.

enumerator kStatusGroup_ApplicationRangeStart

Starting number for application groups.

enumerator kStatusGroup_IAP

Group number for IAP status codes

enumerator kStatusGroup_SFA

Group number for SFA status codes

enumerator kStatusGroup_SPC

Group number for SPC status codes.

enumerator kStatusGroup_PUF

Group number for PUF status codes.

enumerator kStatusGroup_TOUCH_PANEL

Group number for touch panel status codes

enumerator kStatusGroup_VBAT

Group number for VBAT status codes

enumerator kStatusGroup_XSPI

Group number for XSPI status codes

enumerator kStatusGroup_PNGDEC

Group number for PNGDEC status codes

enumerator kStatusGroup_JPEGDEC

Group number for JPEGDEC status codes

enumerator kStatusGroup_HAL_GPIO

Group number for HAL GPIO status codes.

enumerator kStatusGroup_HAL_UART

Group number for HAL UART status codes.

enumerator kStatusGroup_HAL_TIMER

Group number for HAL TIMER status codes.

enumerator kStatusGroup_HAL_SPI

Group number for HAL SPI status codes.

enumerator kStatusGroup_HAL_I2C

Group number for HAL I2C status codes.

enumerator kStatusGroup_HAL_FLASH

Group number for HAL FLASH status codes.

enumerator kStatusGroup_HAL_PWM

Group number for HAL PWM status codes.

enumerator kStatusGroup_HAL_RNG

Group number for HAL RNG status codes.

enumerator kStatusGroup_HAL_I2S

Group number for HAL I2S status codes.

enumerator kStatusGroup_HAL_ADC_SENSOR

Group number for HAL ADC SENSOR status codes.

enumerator kStatusGroup_TIMERMANAGER

Group number for TiMER MANAGER status codes.

enumerator kStatusGroup_SERIALMANAGER

Group number for SERIAL MANAGER status codes.

enumerator kStatusGroup_LED

Group number for LED status codes.

enumerator kStatusGroup_BUTTON

Group number for BUTTON status codes.

enumerator kStatusGroup_EXTERN_EEPROM

Group number for EXTERN EEPROM status codes.

enumerator kStatusGroup_SHELL

Group number for SHELL status codes.

enumerator kStatusGroup_MEM_MANAGER

Group number for MEM MANAGER status codes.

enumerator kStatusGroup_LIST

Group number for List status codes.

enumerator kStatusGroup_OSA

Group number for OSA status codes.

enumerator kStatusGroup_COMMON_TASK

Group number for Common task status codes.

enumerator kStatusGroup_MSG

Group number for messaging status codes.

enumerator kStatusGroup_SDK_OCOTP

Group number for OCOTP status codes.

enumerator kStatusGroup_SDK_FLEXSPINOR

Group number for FLEXSPINOR status codes.

enumerator kStatusGroup_CODEC

Group number for codec status codes.

enumerator kStatusGroup_ASRC

Group number for codec status ASRC.

enumerator kStatusGroup_OTFAD

Group number for codec status codes.

enumerator kStatusGroup_SDIOSLV

Group number for SDIOSLV status codes.

enumerator kStatusGroup_MECC

Group number for MECC status codes.

enumerator kStatusGroup_ENET_QOS

Group number for ENET_QOS status codes.

enumerator kStatusGroup_LOG

Group number for LOG status codes.

enumerator kStatusGroup_I3CBUS

Group number for I3CBUS status codes.

enumerator kStatusGroup_QSCI

Group number for QSCI status codes.

enumerator kStatusGroup_ELEMU

Group number for ELEMU status codes.

enumerator kStatusGroup_QUEUEDSPI

Group number for QSPI status codes.

enumerator kStatusGroup_POWER_MANAGER

Group number for POWER_MANAGER status codes.

enumerator kStatusGroup_IPED

Group number for IPED status codes.

enumerator kStatusGroup_ELS_PKC

Group number for ELS PKC status codes.

enumerator kStatusGroup_CSS_PKC

Group number for CSS PKC status codes.

enumerator kStatusGroup_HOSTIF

Group number for HOSTIF status codes.

enumerator kStatusGroup_CLIF

Group number for CLIF status codes.

enumerator kStatusGroup_BMA

Group number for BMA status codes.

enumerator kStatusGroup_NETC

Group number for NETC status codes.

enumerator kStatusGroup_ELE

Group number for ELE status codes.

enumerator kStatusGroup_GLIKEY

Group number for GLIKEY status codes.

enumerator kStatusGroup_AON_POWER

Group number for AON_POWER status codes.

enumerator kStatusGroup_AON_COMMON

Group number for AON_COMMON status codes.

enumerator kStatusGroup_ENDAT3

Group number for ENDAT3 status codes.

enumerator kStatusGroup_HIPERFACE

Group number for HIPERFACE status codes.

Generic status return codes.

Values:

enumerator kStatus_Success

Generic status for Success.

enumerator kStatus_Fail

Generic status for Fail.

enumerator kStatus_ReadOnly

Generic status for read only failure.

enumerator kStatus_OutOfRange

Generic status for out of range access.

enumerator kStatus_InvalidArgument

Generic status for invalid argument check.

enumerator kStatus_Timeout

Generic status for timeout.

enumerator kStatus_NoTransferInProgress

Generic status for no transfer in progress.

enumerator kStatus_Busy

Generic status for module is busy.

enumerator kStatus_NoData

Generic status for no data is found for the operation.

typedef int32_t status_t

Type used for all status and error return values.

void *SDK_Malloc(size_t size, size_t alignbytes)

Allocate memory with given alignment and aligned size.

This is provided to support the dynamically allocated memory used in cache-able region.

Parameters:
  • size – The length required to malloc.

  • alignbytes – The alignment size.

Return values:

The – allocated memory.

void SDK_Free(void *ptr)

Free memory.

Parameters:
  • ptr – The memory to be release.

void SDK_DelayAtLeastUs(uint32_t delayTime_us, uint32_t coreClock_Hz)

Delay at least for some time. Please note that, this API uses while loop for delay, different run-time environments make the time not precise, if precise delay count was needed, please implement a new delay function with hardware timer.

Parameters:
  • delayTime_us – Delay time in unit of microsecond.

  • coreClock_Hz – Core clock frequency with Hz.

static inline status_t EnableIRQ(IRQn_Type interrupt)

Enable specific interrupt.

Enable LEVEL1 interrupt. For some devices, there might be multiple interrupt levels. For example, there are NVIC and intmux. Here the interrupts connected to NVIC are the LEVEL1 interrupts, because they are routed to the core directly. The interrupts connected to intmux are the LEVEL2 interrupts, they are routed to NVIC first then routed to core.

This function only enables the LEVEL1 interrupts. The number of LEVEL1 interrupts is indicated by the feature macro FSL_FEATURE_NUMBER_OF_LEVEL1_INT_VECTORS.

Parameters:
  • interrupt – The IRQ number.

Return values:
  • kStatus_Success – Interrupt enabled successfully

  • kStatus_Fail – Failed to enable the interrupt

static inline status_t DisableIRQ(IRQn_Type interrupt)

Disable specific interrupt.

Disable LEVEL1 interrupt. For some devices, there might be multiple interrupt levels. For example, there are NVIC and intmux. Here the interrupts connected to NVIC are the LEVEL1 interrupts, because they are routed to the core directly. The interrupts connected to intmux are the LEVEL2 interrupts, they are routed to NVIC first then routed to core.

This function only disables the LEVEL1 interrupts. The number of LEVEL1 interrupts is indicated by the feature macro FSL_FEATURE_NUMBER_OF_LEVEL1_INT_VECTORS.

Parameters:
  • interrupt – The IRQ number.

Return values:
  • kStatus_Success – Interrupt disabled successfully

  • kStatus_Fail – Failed to disable the interrupt

static inline status_t EnableIRQWithPriority(IRQn_Type interrupt, uint8_t priNum)

Enable the IRQ, and also set the interrupt priority.

Only handle LEVEL1 interrupt. For some devices, there might be multiple interrupt levels. For example, there are NVIC and intmux. Here the interrupts connected to NVIC are the LEVEL1 interrupts, because they are routed to the core directly. The interrupts connected to intmux are the LEVEL2 interrupts, they are routed to NVIC first then routed to core.

This function only handles the LEVEL1 interrupts. The number of LEVEL1 interrupts is indicated by the feature macro FSL_FEATURE_NUMBER_OF_LEVEL1_INT_VECTORS.

Parameters:
  • interrupt – The IRQ to Enable.

  • priNum – Priority number set to interrupt controller register.

Return values:
  • kStatus_Success – Interrupt priority set successfully

  • kStatus_Fail – Failed to set the interrupt priority.

static inline status_t IRQ_SetPriority(IRQn_Type interrupt, uint8_t priNum)

Set the IRQ priority.

Only handle LEVEL1 interrupt. For some devices, there might be multiple interrupt levels. For example, there are NVIC and intmux. Here the interrupts connected to NVIC are the LEVEL1 interrupts, because they are routed to the core directly. The interrupts connected to intmux are the LEVEL2 interrupts, they are routed to NVIC first then routed to core.

This function only handles the LEVEL1 interrupts. The number of LEVEL1 interrupts is indicated by the feature macro FSL_FEATURE_NUMBER_OF_LEVEL1_INT_VECTORS.

Parameters:
  • interrupt – The IRQ to set.

  • priNum – Priority number set to interrupt controller register.

Return values:
  • kStatus_Success – Interrupt priority set successfully

  • kStatus_Fail – Failed to set the interrupt priority.

static inline status_t IRQ_ClearPendingIRQ(IRQn_Type interrupt)

Clear the pending IRQ flag.

Only handle LEVEL1 interrupt. For some devices, there might be multiple interrupt levels. For example, there are NVIC and intmux. Here the interrupts connected to NVIC are the LEVEL1 interrupts, because they are routed to the core directly. The interrupts connected to intmux are the LEVEL2 interrupts, they are routed to NVIC first then routed to core.

This function only handles the LEVEL1 interrupts. The number of LEVEL1 interrupts is indicated by the feature macro FSL_FEATURE_NUMBER_OF_LEVEL1_INT_VECTORS.

Parameters:
  • interrupt – The flag which IRQ to clear.

Return values:
  • kStatus_Success – Interrupt priority set successfully

  • kStatus_Fail – Failed to set the interrupt priority.

static inline uint32_t DisableGlobalIRQ(void)

Disable the global IRQ.

Disable the global interrupt and return the current primask register. User is required to provided the primask register for the EnableGlobalIRQ().

Returns:

Current primask value.

static inline void EnableGlobalIRQ(uint32_t primask)

Enable the global IRQ.

Set the primask register with the provided primask value but not just enable the primask. The idea is for the convenience of integration of RTOS. some RTOS get its own management mechanism of primask. User is required to use the EnableGlobalIRQ() and DisableGlobalIRQ() in pair.

Parameters:
  • primask – value of primask register to be restored. The primask value is supposed to be provided by the DisableGlobalIRQ().

static inline bool _SDK_AtomicLocalCompareAndSet(uint32_t *addr, uint32_t expected, uint32_t newValue)
static inline uint32_t _SDK_AtomicTestAndSet(uint32_t *addr, uint32_t newValue)
FSL_DRIVER_TRANSFER_DOUBLE_WEAK_IRQ

Macro to use the default weak IRQ handler in drivers.

MAKE_STATUS(group, code)

Construct a status code value from a group and code number.

MAKE_VERSION(major, minor, bugfix)

Construct the version number for drivers.

The driver version is a 32-bit number, for both 32-bit platforms(such as Cortex M) and 16-bit platforms(such as DSC).

| Unused    || Major Version || Minor Version ||  Bug Fix    |
31        25  24           17  16            9  8            0
ARRAY_SIZE(x)

Computes the number of elements in an array.

UINT64_H(X)

Macro to get upper 32 bits of a 64-bit value

UINT64_L(X)

Macro to get lower 32 bits of a 64-bit value

SUPPRESS_FALL_THROUGH_WARNING()

For switch case code block, if case section ends without “break;” statement, there wil be fallthrough warning with compiler flag -Wextra or -Wimplicit-fallthrough=n when using armgcc. To suppress this warning, “SUPPRESS_FALL_THROUGH_WARNING();” need to be added at the end of each case section which misses “break;”statement.

MSDK_REG_SECURE_ADDR(x)

Convert the register address to the one used in secure mode.

MSDK_REG_NONSECURE_ADDR(x)

Convert the register address to the one used in non-secure mode.

MCM: Miscellaneous Control Module

FSL_MCM_DRIVER_VERSION

MCM driver version.

Enum _mcm_interrupt_flag. Interrupt status flag mask. .

Values:

enumerator kMCM_CacheWriteBuffer

Cache Write Buffer Error Enable.

enumerator kMCM_ParityError

Cache Parity Error Enable.

enumerator kMCM_FPUInvalidOperation

FPU Invalid Operation Interrupt Enable.

enumerator kMCM_FPUDivideByZero

FPU Divide-by-zero Interrupt Enable.

enumerator kMCM_FPUOverflow

FPU Overflow Interrupt Enable.

enumerator kMCM_FPUUnderflow

FPU Underflow Interrupt Enable.

enumerator kMCM_FPUInexact

FPU Inexact Interrupt Enable.

enumerator kMCM_FPUInputDenormalInterrupt

FPU Input Denormal Interrupt Enable.

typedef union _mcm_buffer_fault_attribute mcm_buffer_fault_attribute_t

The union of buffer fault attribute.

typedef union _mcm_lmem_fault_attribute mcm_lmem_fault_attribute_t

The union of LMEM fault attribute.

static inline void MCM_EnableCrossbarRoundRobin(MCM_Type *base, bool enable)

Enables/Disables crossbar round robin.

Parameters:
  • base – MCM peripheral base address.

  • enable – Used to enable/disable crossbar round robin.

    • true Enable crossbar round robin.

    • false disable crossbar round robin.

static inline void MCM_EnableInterruptStatus(MCM_Type *base, uint32_t mask)

Enables the interrupt.

Parameters:
  • base – MCM peripheral base address.

  • mask – Interrupt status flags mask(_mcm_interrupt_flag).

static inline void MCM_DisableInterruptStatus(MCM_Type *base, uint32_t mask)

Disables the interrupt.

Parameters:
  • base – MCM peripheral base address.

  • mask – Interrupt status flags mask(_mcm_interrupt_flag).

static inline uint16_t MCM_GetInterruptStatus(MCM_Type *base)

Gets the Interrupt status .

Parameters:
  • base – MCM peripheral base address.

static inline void MCM_ClearCacheWriteBufferErroStatus(MCM_Type *base)

Clears the Interrupt status .

Parameters:
  • base – MCM peripheral base address.

static inline uint32_t MCM_GetBufferFaultAddress(MCM_Type *base)

Gets buffer fault address.

Parameters:
  • base – MCM peripheral base address.

static inline void MCM_GetBufferFaultAttribute(MCM_Type *base, mcm_buffer_fault_attribute_t *bufferfault)

Gets buffer fault attributes.

Parameters:
  • base – MCM peripheral base address.

static inline uint32_t MCM_GetBufferFaultData(MCM_Type *base)

Gets buffer fault data.

Parameters:
  • base – MCM peripheral base address.

static inline void MCM_LimitCodeCachePeripheralWriteBuffering(MCM_Type *base, bool enable)

Limit code cache peripheral write buffering.

Parameters:
  • base – MCM peripheral base address.

  • enable – Used to enable/disable limit code cache peripheral write buffering.

    • true Enable limit code cache peripheral write buffering.

    • false disable limit code cache peripheral write buffering.

static inline void MCM_BypassFixedCodeCacheMap(MCM_Type *base, bool enable)

Bypass fixed code cache map.

Parameters:
  • base – MCM peripheral base address.

  • enable – Used to enable/disable bypass fixed code cache map.

    • true Enable bypass fixed code cache map.

    • false disable bypass fixed code cache map.

static inline void MCM_EnableCodeBusCache(MCM_Type *base, bool enable)

Enables/Disables code bus cache.

Parameters:
  • base – MCM peripheral base address.

  • enable – Used to disable/enable code bus cache.

    • true Enable code bus cache.

    • false disable code bus cache.

static inline void MCM_ForceCodeCacheToNoAllocation(MCM_Type *base, bool enable)

Force code cache to no allocation.

Parameters:
  • base – MCM peripheral base address.

  • enable – Used to force code cache to allocation or no allocation.

    • true Force code cache to no allocation.

    • false Force code cache to allocation.

static inline void MCM_EnableCodeCacheWriteBuffer(MCM_Type *base, bool enable)

Enables/Disables code cache write buffer.

Parameters:
  • base – MCM peripheral base address.

  • enable – Used to enable/disable code cache write buffer.

    • true Enable code cache write buffer.

    • false Disable code cache write buffer.

static inline void MCM_ClearCodeBusCache(MCM_Type *base)

Clear code bus cache.

Parameters:
  • base – MCM peripheral base address.

static inline void MCM_EnablePcParityFaultReport(MCM_Type *base, bool enable)

Enables/Disables PC Parity Fault Report.

Parameters:
  • base – MCM peripheral base address.

  • enable – Used to enable/disable PC Parity Fault Report.

    • true Enable PC Parity Fault Report.

    • false disable PC Parity Fault Report.

static inline void MCM_EnablePcParity(MCM_Type *base, bool enable)

Enables/Disables PC Parity.

Parameters:
  • base – MCM peripheral base address.

  • enable – Used to enable/disable PC Parity.

    • true Enable PC Parity.

    • false disable PC Parity.

static inline void MCM_LockConfigState(MCM_Type *base)

Lock the configuration state.

Parameters:
  • base – MCM peripheral base address.

static inline void MCM_EnableCacheParityReporting(MCM_Type *base, bool enable)

Enables/Disables cache parity reporting.

Parameters:
  • base – MCM peripheral base address.

  • enable – Used to enable/disable cache parity reporting.

    • true Enable cache parity reporting.

    • false disable cache parity reporting.

static inline uint32_t MCM_GetLmemFaultAddress(MCM_Type *base)

Gets LMEM fault address.

Parameters:
  • base – MCM peripheral base address.

static inline void MCM_GetLmemFaultAttribute(MCM_Type *base, mcm_lmem_fault_attribute_t *lmemFault)

Get LMEM fault attributes.

Parameters:
  • base – MCM peripheral base address.

static inline uint64_t MCM_GetLmemFaultData(MCM_Type *base)

Gets LMEM fault data.

Parameters:
  • base – MCM peripheral base address.

MCM_LMFATR_TYPE_MASK
MCM_LMFATR_MODE_MASK
MCM_LMFATR_BUFF_MASK
MCM_LMFATR_CACH_MASK
MCM_ISCR_STAT_MASK
MCM_ISCR_CPEE_MASK
FSL_COMPONENT_ID
union _mcm_buffer_fault_attribute
#include <fsl_mcm.h>

The union of buffer fault attribute.

Public Members

uint32_t attribute

Indicates the faulting attributes, when a properly-enabled cache write buffer error interrupt event is detected.

struct _mcm_buffer_fault_attribute._mcm_buffer_fault_attribut attribute_memory
struct _mcm_buffer_fault_attribut
#include <fsl_mcm.h>

Public Members

uint32_t busErrorDataAccessType

Indicates the type of cache write buffer access.

uint32_t busErrorPrivilegeLevel

Indicates the privilege level of the cache write buffer access.

uint32_t busErrorSize

Indicates the size of the cache write buffer access.

uint32_t busErrorAccess

Indicates the type of system bus access.

uint32_t busErrorMasterID

Indicates the crossbar switch bus master number of the captured cache write buffer bus error.

uint32_t busErrorOverrun

Indicates if another cache write buffer bus error is detected.

union _mcm_lmem_fault_attribute
#include <fsl_mcm.h>

The union of LMEM fault attribute.

Public Members

uint32_t attribute

Indicates the attributes of the LMEM fault detected.

struct _mcm_lmem_fault_attribute._mcm_lmem_fault_attribut attribute_memory
struct _mcm_lmem_fault_attribut
#include <fsl_mcm.h>

Public Members

uint32_t parityFaultProtectionSignal

Indicates the features of parity fault protection signal.

uint32_t parityFaultMasterSize

Indicates the parity fault master size.

uint32_t parityFaultWrite

Indicates the parity fault is caused by read or write.

uint32_t backdoorAccess

Indicates the LMEM access fault is initiated by core access or backdoor access.

uint32_t parityFaultSyndrome

Indicates the parity fault syndrome.

uint32_t overrun

Indicates the number of faultss.

PIT: Periodic Interrupt Timer

void PIT_Init(PIT_Type *base, const pit_config_t *config)

Ungates the PIT clock, enables the PIT module, and configures the peripheral for basic operations.

Note

This API should be called at the beginning of the application using the PIT driver.

Parameters:
  • base – PIT peripheral base address

  • config – Pointer to the user’s PIT config structure

void PIT_Deinit(PIT_Type *base)

Gates the PIT clock and disables the PIT module.

Parameters:
  • base – PIT peripheral base address

static inline void PIT_GetDefaultConfig(pit_config_t *config)

Fills in the PIT configuration structure with the default settings.

The default values are as follows.

config->enableRunInDebug = false;

Parameters:
  • config – Pointer to the configuration structure.

static inline void PIT_SetTimerChainMode(PIT_Type *base, pit_chnl_t channel, bool enable)

Enables or disables chaining a timer with the previous timer.

When a timer has a chain mode enabled, it only counts after the previous timer has expired. If the timer n-1 has counted down to 0, counter n decrements the value by one. Each timer is 32-bits, which allows the developers to chain timers together and form a longer timer (64-bits and larger). The first timer (timer 0) can’t be chained to any other timer.

Parameters:
  • base – PIT peripheral base address

  • channel – Timer channel number which is chained with the previous timer

  • enable – Enable or disable chain. true: Current timer is chained with the previous timer. false: Timer doesn’t chain with other timers.

static inline void PIT_EnableInterrupts(PIT_Type *base, pit_chnl_t channel, uint32_t mask)

Enables the selected PIT interrupts.

Parameters:
  • base – PIT peripheral base address

  • channel – Timer channel number

  • mask – The interrupts to enable. This is a logical OR of members of the enumeration pit_interrupt_enable_t

static inline void PIT_DisableInterrupts(PIT_Type *base, pit_chnl_t channel, uint32_t mask)

Disables the selected PIT interrupts.

Parameters:
  • base – PIT peripheral base address

  • channel – Timer channel number

  • mask – The interrupts to disable. This is a logical OR of members of the enumeration pit_interrupt_enable_t

static inline uint32_t PIT_GetEnabledInterrupts(PIT_Type *base, pit_chnl_t channel)

Gets the enabled PIT interrupts.

Parameters:
  • base – PIT peripheral base address

  • channel – Timer channel number

Returns:

The enabled interrupts. This is the logical OR of members of the enumeration pit_interrupt_enable_t

static inline uint32_t PIT_GetStatusFlags(PIT_Type *base, pit_chnl_t channel)

Gets the PIT status flags.

Parameters:
  • base – PIT peripheral base address

  • channel – Timer channel number

Returns:

The status flags. This is the logical OR of members of the enumeration pit_status_flags_t

static inline void PIT_ClearStatusFlags(PIT_Type *base, pit_chnl_t channel, uint32_t mask)

Clears the PIT status flags.

Parameters:
  • base – PIT peripheral base address

  • channel – Timer channel number

  • mask – The status flags to clear. This is a logical OR of members of the enumeration pit_status_flags_t

static inline void PIT_SetTimerPeriod(PIT_Type *base, pit_chnl_t channel, uint32_t count)

Sets the timer period in units of count.

Timers begin counting from the value set by this function until it reaches 0, then it generates an interrupt and load this register value again. Writing a new value to this register does not restart the timer. Instead, the value is loaded after the timer expires.

Note

Users can call the utility macros provided in fsl_common.h to convert to ticks.

Parameters:
  • base – PIT peripheral base address

  • channel – Timer channel number

  • count – Timer period in units of ticks

static inline uint32_t PIT_GetCurrentTimerCount(PIT_Type *base, pit_chnl_t channel)

Reads the current timer counting value.

This function returns the real-time timer counting value, in a range from 0 to a timer period.

Note

Users can call the utility macros provided in fsl_common.h to convert ticks to usec or msec.

Parameters:
  • base – PIT peripheral base address

  • channel – Timer channel number

Returns:

Current timer counting value in ticks

static inline void PIT_StartTimer(PIT_Type *base, pit_chnl_t channel)

Starts the timer counting.

After calling this function, timers load period value, count down to 0 and then load the respective start value again. Each time a timer reaches 0, it generates a trigger pulse and sets the timeout interrupt flag.

Parameters:
  • base – PIT peripheral base address

  • channel – Timer channel number.

static inline void PIT_StopTimer(PIT_Type *base, pit_chnl_t channel)

Stops the timer counting.

This function stops every timer counting. Timers reload their periods respectively after the next time they call the PIT_DRV_StartTimer.

Parameters:
  • base – PIT peripheral base address

  • channel – Timer channel number.

FSL_PIT_DRIVER_VERSION

PIT Driver Version 2.0.5.

enum _pit_chnl

List of PIT channels.

Note

Actual number of available channels is SoC dependent

Values:

enumerator kPIT_Chnl_0

PIT channel number 0

enumerator kPIT_Chnl_1

PIT channel number 1

enumerator kPIT_Chnl_2

PIT channel number 2

enumerator kPIT_Chnl_3

PIT channel number 3

enum _pit_interrupt_enable

List of PIT interrupts.

Values:

enumerator kPIT_TimerInterruptEnable

Timer interrupt enable

enum _pit_status_flags

List of PIT status flags.

Values:

enumerator kPIT_TimerFlag

Timer flag

typedef enum _pit_chnl pit_chnl_t

List of PIT channels.

Note

Actual number of available channels is SoC dependent

typedef enum _pit_interrupt_enable pit_interrupt_enable_t

List of PIT interrupts.

typedef enum _pit_status_flags pit_status_flags_t

List of PIT status flags.

typedef struct _pit_config pit_config_t

PIT configuration structure.

This structure holds the configuration settings for the PIT peripheral. To initialize this structure to reasonable defaults, call the PIT_GetDefaultConfig() function and pass a pointer to your config structure instance.

The configuration structure can be made constant so it resides in flash.

uint64_t PIT_GetLifetimeTimerCount(PIT_Type *base)

Reads the current lifetime counter value.

The lifetime timer is a 64-bit timer which chains timer 0 and timer 1 together. Timer 0 and 1 are chained by calling the PIT_SetTimerChainMode before using this timer. The period of lifetime timer is equal to the “period of timer 0 * period of timer 1”. For the 64-bit value, the higher 32-bit has the value of timer 1, and the lower 32-bit has the value of timer 0.

Parameters:
  • base – PIT peripheral base address

Returns:

Current lifetime timer value

struct _pit_config
#include <fsl_pit.h>

PIT configuration structure.

This structure holds the configuration settings for the PIT peripheral. To initialize this structure to reasonable defaults, call the PIT_GetDefaultConfig() function and pass a pointer to your config structure instance.

The configuration structure can be made constant so it resides in flash.

Public Members

bool enableRunInDebug

true: Timers run in debug mode; false: Timers stop in debug mode

PORT Driver

enum _port_module_t

Module or peripheral for port pin selection.

Values:

enumerator kPORT_NMI

NMI port pin select.

enumerator kPORT_RESET

RESET pin select.

enumerator kPORT_SWDE

Single wire debug port pin.

enumerator kPORT_RTC

RTCO port pin select.

enumerator kPORT_I2C0

I2C0 Port pin select.

enumerator kPORT_SPI0

SPI0 port pin select.

enumerator kPORT_UART0

UART0 port pin select.

enumerator kPORT_FTM0CH0

FTM0_CH0 port pin select.

enumerator kPORT_FTM0CH1

FTM0_CH1 port pin select.

enumerator kPORT_FTM1CH0

FTM1_CH0 port pin select.

enumerator kPORT_FTM1CH1

FTM1_CH1 port pin select.

enumerator kPORT_FTM2CH0

FTM2_CH0 port pin select.

enumerator kPORT_FTM2CH1

FTM2_CH1 port pin select.

enumerator kPORT_FTM2CH2

FTM2_CH2 port pin select.

enumerator kPORT_FTM2CH3

FTM2_CH3 port pin select.

enum _port_type_t

Port type.

Values:

enumerator kPORT_PTA

PORT PTA.

enumerator kPORT_PTB

PORT PTB.

enumerator kPORT_PTC

PORT PTC.

enumerator kPORT_PTD

PORT PTD.

enumerator kPORT_PTE

PORT PTE.

enumerator kPORT_PTF

PORT PTF.

enumerator kPORT_PTG

PORT PTG.

enumerator kPORT_PTH

PORT PTH.

enum _port_pin_index_t

Pin number, Notice this index enum has been deprecated and it will be removed in the next release.

Values:

enumerator kPORT_PinIdx0

PORT PIN index 0.

enumerator kPORT_PinIdx1

PORT PIN index 1.

enumerator kPORT_PinIdx2

PORT PIN index 2.

enumerator kPORT_PinIdx3

PORT PIN index 3.

enumerator kPORT_PinIdx4

PORT PIN index 4.

enumerator kPORT_PinIdx5

PORT PIN index 5.

enumerator kPORT_PinIdx6

PORT PIN index 6.

enumerator kPORT_PinIdx7

PORT PIN index 7.

enum _port_pin_select_t

Pin selection.

Values:

enumerator kPORT_NMI_OTHERS

PTB4/FTM2_CH4 etc function as PTB4/FTM2_CH4 etc

enumerator kPORT_NMI_NMIE

PTB4/FTM2_CH4 etc function as NMI.

enumerator kPORT_RST_OTHERS

PTA5/IRQ etc function as PTA5/IRQ etc.

enumerator kPORT_RST_RSTPE

PTA5/IRQ etc function as REST.

enumerator kPORT_SWDE_OTHERS

PTA4/ACMP0 etc function as PTA4/ACMP0 etc.

enumerator kPORT_SWDE_SWDE

PTA4/ACMP0 etc function as SWD.

enumerator kPORT_RTCO_PTC4

RTCO is mapped to PTC4.

enumerator kPORT_RTCO_PTC5

RTCO is mapped to PTC5.

enumerator kPORT_I2C0_SCLPTA3_SDAPTA2

I2C0_SCL and I2C0_SDA are mapped on PTA3 and PTA2, respectively.

enumerator kPORT_I2C0_SCLPTB7_SDAPTB6

I2C0_SCL and I2C0_SDA are mapped on PTB7 and PTB6, respectively.

enumerator kPORT_SPI0_SCKPTB2_MOSIPTB3_MISOPTB4_PCSPTB5

SPI0_SCK/MOSI/MISO/PCS0 are mapped on PTB2/PTB3/PTB4/PTB5.

enumerator kPORT_SPI0_SCKPTE0_MOSIPTE1_MISOPTE2_PCSPTE3

SPI0_SCK/MOSI/MISO/PCS0 are mapped on PTE0/PTE1/PTE2/PTE3.

enumerator kPORT_UART0_RXPTB0_TXPTB1

UART0_RX and UART0_TX are mapped on PTB0 and PTB1.

enumerator kPORT_UART0_RXPTA2_TXPTA3

UART0_RX and UART0_TX are mapped on PTA2 and PTA3.

enumerator kPORT_FTM0_CH0_PTA0

FTM0_CH0 channels are mapped on PTA0.

enumerator kPORT_FTM0_CH0_PTB2

FTM0_CH0 channels are mapped on PTB2.

enumerator kPORT_FTM0_CH1_PTA1

FTM0_CH1 channels are mapped on PTA1.

enumerator kPORT_FTM0_CH1_PTB3

FTM0_CH1 channels are mapped on PTB3.

enumerator kPORT_FTM1_CH0_PTC4

FTM1_CH0 channels are mapped on PTC4.

enumerator kPORT_FTM1_CH0_PTH2

FTM1_CH0 channels are mapped on PTH2.

enumerator kPORT_FTM1_CH1_PTC5

FTM1_CH1 channels are mapped on PTC5.

enumerator kPORT_FTM1_CH1_PTE7

FTM1_CH1 channels are mapped on PTE7.

enumerator kPORT_FTM2_CH0_PTC0

FTM2_CH0 channels are mapped on PTC0.

enumerator kPORT_FTM2_CH0_PTH0

FTM2_CH0 channels are mapped on PTH0.

enumerator kPORT_FTM2_CH1_PTC1

FTM2_CH1 channels are mapped on PTC1.

enumerator kPORT_FTM2_CH1_PTH1

FTM2_CH1 channels are mapped on PTH1.

enumerator kPORT_FTM2_CH2_PTC2

FTM2_CH2 channels are mapped on PTC2.

enumerator kPORT_FTM2_CH2_PTD0

FTM2_CH2 channels are mapped on PTD0.

enumerator kPORT_FTM2_CH3_PTC3

FTM2_CH3 channels are mapped on PTC3.

enumerator kPORT_FTM2_CH3_PTD1

FTM2_CH3 channels are mapped on PTD1.

enum _port_filter_pin_t

The PORT pins for input glitch filter configure.

Values:

enumerator kPORT_FilterPTA

Filter for input from PTA.

enumerator kPORT_FilterPTB

Filter for input from PTB.

enumerator kPORT_FilterPTC

Filter for input from PTC.

enumerator kPORT_FilterPTD

Filter for input from PTD.

enumerator kPORT_FilterPTE

Filter for input from PTE.

enumerator kPORT_FilterPTF

Filter for input from PTF.

enumerator kPORT_FilterPTG

Filter for input from PTG.

enumerator kPORT_FilterPTH

Filter for input from PTH.

enumerator kPORT_FilterRST

Filter for input from RESET/IRQ.

enumerator kPORT_FilterKBI0

Filter for input from KBI0.

enumerator kPORT_FilterKBI1

Filter for input from KBI1.

enumerator kPORT_FilterNMI

Filter for input from NMI.

enum _port_filter_select_t

The Filter selection for input pins.

Values:

enumerator kPORT_BUSCLK_OR_NOFILTER

Filter section BUSCLK for PTA~PTH, No filter for REST/KBI0/KBI1/NMI.

enumerator kPORT_FILTERDIV1

Filter Division Set 1.

enumerator kPORT_FILTERDIV2

Filter Division Set 2.

enumerator kPORT_FILTERDIV3

Filter Division Set 3.

enum _port_highdrive_pin_t

Port pin for high driver enable/disable control.

Values:

enumerator kPORT_HighDrive_PTB4

PTB4.

enumerator kPORT_HighDrive_PTB5

PTB5.

enumerator kPORT_HighDrive_PTD0

PTD0.

enumerator kPORT_HighDrive_PTD1

PTD1.

enumerator kPORT_HighDrive_PTE0

PTE0.

enumerator kPORT_HighDrive_PTE1

PTE1.

enumerator kPORT_HighDrive_PTH0

PTH0.

enumerator kPORT_HighDrive_PTH1

PTH1.

typedef enum _port_module_t port_module_t

Module or peripheral for port pin selection.

typedef enum _port_type_t port_type_t

Port type.

typedef enum _port_pin_index_t port_pin_index_t

Pin number, Notice this index enum has been deprecated and it will be removed in the next release.

typedef enum _port_pin_select_t port_pin_select_t

Pin selection.

typedef enum _port_filter_pin_t port_filter_pin_t

The PORT pins for input glitch filter configure.

typedef enum _port_filter_select_t port_filter_select_t

The Filter selection for input pins.

typedef enum _port_highdrive_pin_t port_highdrive_pin_t

Port pin for high driver enable/disable control.

FSL_PORT_DRIVER_VERSION

Version 2.0.2.

FSL_PORT_FILTER_SELECT_BITMASK

The IOFLT Filter selection bit mask .

void PORT_SetPinSelect(port_module_t module, port_pin_select_t pin)

Selects pin for modules.

This API is used to select the port pin for the module with multiple port pin selection. For example the FTM Channel 0 can be mapped to ether PTA0 or PTB2. Select FTM channel 0 map to PTA0 port pin as:

PORT_SetPinSelect(kPORT_FTM0CH0, kPORT_FTM0_CH0_PTA0);

If you want to select a specified ALT for a given port pin, please add two more steps after calling PORT_SetPinSelect:

  1. Enable module or the port control in the module for the ALT you want to select. For I2C ALT feature:all port enable is controlled by the module enable, so set IICEN in I2CX_C1 to enable the port pins for I2C feature. For KBI ALT feature:each port pin is controlled independently by each bit in KBIx_PE. set related bit in this register to enable the KBI feature in the port pin.

  2. Make sure there is no module enabled with higher priority than the ALT module feature you want to select.

Note

This API doesn’t support to select specified ALT for a given port pin. The ALT feature is automatically selected by hardware according to the ALT priority: Low —–> high: Alt1, Alt2, … when peripheral modules has been enabled.

Parameters:
  • module – Modules for pin selection. For NMI/RST module are write-once attribute after reset.

  • pin – Port pin selection for modules.

static inline void PORT_SetFilterSelect(PORT_Type *base, port_filter_pin_t port, port_filter_select_t filter)

Selects the glitch filter for input pins.

Parameters:
  • base – PORT peripheral base pointer.

  • port – PORT pin, see “port_filter_pin_t”.

  • filter – Filter select, see “port_filter_select_t”.

static inline void PORT_SetFilterDIV1WidthThreshold(PORT_Type *base, uint8_t threshold)

Sets the width threshold for glitch filter division set 1. `.

Parameters:
  • base – PORT peripheral base pointer.

  • threshold – PORT glitch filter width threshold, take refer to reference manual for detail information. 0 - LPOCLK 1 - LPOCLK/2 2 - LPOCLK/4 3 - LPOCLK/8 4 - LPOCLK/16 5 - LPOCLK/32 6 - LPOCLK/64 7 - LPOCLK/128

static inline void PORT_SetFilterDIV2WidthThreshold(PORT_Type *base, uint8_t threshold)

Sets the width threshold for glitch filter division set 2. `.

Parameters:
  • base – PORT peripheral base pointer.

  • threshold – PORT glitch filter width threshold, take refer to reference manual for detail information. 0 - BUSCLK/32 1 - BUSCLK/64 2 - BUSCLK/128 3 - BUSCLK/256 4 - BUSCLK/512 5 - BUSCLK/1024 6 - BUSCLK/2048 7 - BUSCLK/4096

static inline void PORT_SetFilterDIV3WidthThreshold(PORT_Type *base, uint8_t threshold)

Sets the width threshold for glitch filter division set 3. `.

Parameters:
  • base – PORT peripheral base pointer.

  • threshold – PORT glitch filter width threshold, take refer to reference manual for detail information. 0 - BUSCLK/2 1 - BUSCLK/4 2 - BUSCLK/8 3 - BUSCLK/16

void PORT_SetPinPullUpEnable(PORT_Type *base, port_type_t port, uint8_t num, bool enable)

Enables or disables the port pull up.

Parameters:
  • base – PORT peripheral base pointer.

  • port – PORT type, such as PTA/PTB/PTC etc, see “port_type_t”.

  • num – PORT Pin number, such as 0, 1, 2…. There are seven pins not exists in this device: PTG: PTG4, PTG5, PTG6, PTG7. PTH: PTH3, PTH4, PTH5. so, when set PTG, and PTH, please don’t set the pins mentioned above. Please take refer to the reference manual.

  • enable – Enable or disable the pull up feature switch.

static inline void PORT_SetHighDriveEnable(PORT_Type *base, port_highdrive_pin_t pin, bool enable)

Set High drive for port pins.

Parameters:
  • base – PORT peripheral base pointer.

  • pin – PORT pin support high drive.

  • enable – Enable or disable the high driver feature switch.

RTC: Real Time Clock

void RTC_Init(RTC_Type *base, const rtc_config_t *config)

Ungates the RTC clock and configures the peripheral for basic operation.

Note

This API should be called at the beginning of the application using the RTC driver.

Parameters:
  • base – RTC peripheral base address

  • config – Pointer to the user’s RTC configuration structure.

void RTC_Deinit(RTC_Type *base)

Stops the timer and gate the RTC clock.

Parameters:
  • base – RTC peripheral base address

void RTC_GetDefaultConfig(rtc_config_t *config)

Fills in the RTC config struct with the default settings.

The default values are as follows.

config->clockSource = kRTC_BusClock;
config->prescaler = kRTC_ClockDivide_16_2048;
config->time_us = 1000000U;

Parameters:
  • config – Pointer to the user’s RTC configuration structure.

status_t RTC_SetDatetime(rtc_datetime_t *datetime)

Sets the RTC date and time according to the given time structure.

Parameters:
  • datetime – Pointer to the structure where the date and time details are stored.

Returns:

kStatus_Success: Success in setting the time and starting the RTC kStatus_InvalidArgument: Error because the datetime format is incorrect

void RTC_GetDatetime(rtc_datetime_t *datetime)

Gets the RTC time and stores it in the given time structure.

Parameters:
  • datetime – Pointer to the structure where the date and time details are stored.

void RTC_SetAlarm(uint32_t second)

Sets the RTC alarm time.

Parameters:
  • second – Second value. User input the number of second. After seconds user input, alarm occurs.

void RTC_GetAlarm(rtc_datetime_t *datetime)

Returns the RTC alarm time.

Parameters:
  • datetime – Pointer to the structure where the alarm date and time details are stored.

void RTC_SetAlarmCallback(rtc_alarm_callback_t callback)

Set the RTC alarm callback.

Parameters:
  • callback – The callback function.

static inline void RTC_SelectSourceClock(RTC_Type *base, rtc_clock_source_t clock, rtc_clock_prescaler_t divide)

Select Real-Time Clock Source and Clock Prescaler.

Parameters:
  • base – RTC peripheral base address

  • clock – Select RTC clock source

  • divide – Select RTC clock prescaler value

uint32_t RTC_GetDivideValue(RTC_Type *base)

Get the RTC Divide value.

Note

This API should be called after selecting clock source and clock prescaler.

Parameters:
  • base – RTC peripheral base address

Returns:

The Divider value. The Divider value depends on clock source and clock prescaler

static inline void RTC_EnableInterrupts(RTC_Type *base, uint32_t mask)

Enables the selected RTC interrupts.

Parameters:
  • base – RTC peripheral base address

  • mask – The interrupts to enable. This is a logical OR of members of the enumeration rtc_interrupt_enable_t

static inline void RTC_DisableInterrupts(RTC_Type *base, uint32_t mask)

Disables the selected RTC interrupts.

Parameters:
  • base – PIT peripheral base address

  • mask – The interrupts to disable. This is a logical OR of members of the enumeration rtc_interrupt_enable_t

static inline uint32_t RTC_GetEnabledInterrupts(RTC_Type *base)

Gets the enabled RTC interrupts.

Parameters:
  • base – RTC peripheral base address

Returns:

The enabled interrupts. This is the logical OR of members of the enumeration rtc_interrupt_enable_t

static inline uint32_t RTC_GetInterruptFlags(RTC_Type *base)

Gets the RTC interrupt flags.

Parameters:
  • base – RTC peripheral base address

Returns:

The interrupt flags. This is the logical OR of members of the enumeration rtc_interrupt_flags_t

static inline void RTC_ClearInterruptFlags(RTC_Type *base, uint32_t mask)

Clears the RTC interrupt flags.

Parameters:
  • base – RTC peripheral base address

  • mask – The interrupt flags to clear. This is a logical OR of members of the enumeration rtc_interrupt_flags_t

static inline void RTC_EnableOutput(RTC_Type *base, uint32_t mask)

Enable the RTC output. If RTC output is enabled, the RTCO pinout will be toggled when RTC counter overflows.

Parameters:
  • base – RTC peripheral base address

  • mask – The Output to enable. This is a logical OR of members of the enumeration rtc_output_enable_t

static inline void RTC_DisableOutput(RTC_Type *base, uint32_t mask)

Disable the RTC output.

Parameters:
  • base – RTC peripheral base address

  • mask – The Output to disable. This is a logical OR of members of the enumeration rtc_output_enable_t

static inline void RTC_SetModuloValue(RTC_Type *base, uint32_t value)

Set the RTC module value.

Parameters:
  • base – RTC peripheral base address

  • value – The Module Value. The RTC Modulo register allows the compare value to be set to any value from 0x0000 to 0xFFFF

static inline uint16_t RTC_GetCountValue(RTC_Type *base)

Get the RTC Count value.

Parameters:
  • base – RTC peripheral base address

Returns:

The Count Value. The Count Value is allowed from 0x0000 to 0xFFFF

FSL_RTC_DRIVER_VERSION

Version 2.0.4

enum _rtc_clock_source

List of RTC clock source.

Values:

enumerator kRTC_ExternalClock

External clock source

enumerator kRTC_LPOCLK

Real-time clock source is 1 kHz (LPOCLK)

enumerator kRTC_ICSIRCLK

Internal reference clock (ICSIRCLK)

enumerator kRTC_BusClock

Bus clock

enum _rtc_clock_prescaler

List of RTC clock prescaler.

Values:

enumerator kRTC_ClockDivide_off

Off

enumerator kRTC_ClockDivide_1_128

If RTCLKS = x0, it is 1; if RTCLKS = x1, it is 128

enumerator kRTC_ClockDivide_2_256

If RTCLKS = x0, it is 2; if RTCLKS = x1, it is 256

enumerator kRTC_ClockDivide_4_512

If RTCLKS = x0, it is 4; if RTCLKS = x1, it is 512

enumerator kRTC_ClockDivide_8_1024

If RTCLKS = x0, it is 8; if RTCLKS = x1, it is 1024

enumerator kRTC_ClockDivide_16_2048

If RTCLKS = x0, it is 16; if RTCLKS = x1, it is 2048

enumerator kRTC_ClockDivide_32_100

If RTCLKS = x0, it is 32; if RTCLKS = x1, it is 100

enumerator kRTC_ClockDivide_64_1000

If RTCLKS = x0, it is 64; if RTCLKS = x1, it is 1000

enum _rtc_interrupt_enable

List of RTC interrupts.

Values:

enumerator kRTC_InterruptEnable

Interrupt enable

enum _RTC_interrupt_flags

List of RTC Interrupt flags.

Values:

enumerator kRTC_InterruptFlag

Interrupt flag

enum _RTC_output_enable

List of RTC Output.

Values:

enumerator kRTC_OutputEnable

Output enable

typedef struct _rtc_datetime rtc_datetime_t

Structure is used to hold the date and time.

typedef enum _rtc_clock_source rtc_clock_source_t

List of RTC clock source.

typedef enum _rtc_clock_prescaler rtc_clock_prescaler_t

List of RTC clock prescaler.

typedef enum _rtc_interrupt_enable rtc_interrupt_enable_t

List of RTC interrupts.

typedef enum _RTC_interrupt_flags rtc_interrupt_flags_t

List of RTC Interrupt flags.

typedef enum _RTC_output_enable rtc_output_enable_t

List of RTC Output.

typedef struct _rtc_config rtc_config_t

RTC config structure.

This structure holds the configuration settings for the RTC peripheral. To initialize this structure to reasonable defaults, call the RTC_GetDefaultConfig() function and pass a pointer to your config structure instance.

typedef void (*rtc_alarm_callback_t)(void)

RTC alarm callback function.

struct _rtc_datetime
#include <fsl_rtc.h>

Structure is used to hold the date and time.

Public Members

uint16_t year

Range from 1970 to 2099.

uint8_t month

Range from 1 to 12.

uint8_t day

Range from 1 to 31 (depending on month).

uint8_t hour

Range from 0 to 23.

uint8_t minute

Range from 0 to 59.

uint8_t second

Range from 0 to 59.

struct _rtc_config
#include <fsl_rtc.h>

RTC config structure.

This structure holds the configuration settings for the RTC peripheral. To initialize this structure to reasonable defaults, call the RTC_GetDefaultConfig() function and pass a pointer to your config structure instance.

SPI: Serial Peripheral Interface Driver

SPI Driver

void SPI_MasterGetDefaultConfig(spi_master_config_t *config)

Sets the SPI master configuration structure to default values.

The purpose of this API is to get the configuration structure initialized for use in SPI_MasterInit(). User may use the initialized structure unchanged in SPI_MasterInit(), or modify some fields of the structure before calling SPI_MasterInit(). After calling this API, the master is ready to transfer. Example:

spi_master_config_t config;
SPI_MasterGetDefaultConfig(&config);

Parameters:
  • config – pointer to master config structure

void SPI_MasterInit(SPI_Type *base, const spi_master_config_t *config, uint32_t srcClock_Hz)

Initializes the SPI with master configuration.

The configuration structure can be filled by user from scratch, or be set with default values by SPI_MasterGetDefaultConfig(). After calling this API, the slave is ready to transfer. Example

spi_master_config_t config = {
.baudRate_Bps = 400000,
...
};
SPI_MasterInit(SPI0, &config);

Parameters:
  • base – SPI base pointer

  • config – pointer to master configuration structure

  • srcClock_Hz – Source clock frequency.

void SPI_SlaveGetDefaultConfig(spi_slave_config_t *config)

Sets the SPI slave configuration structure to default values.

The purpose of this API is to get the configuration structure initialized for use in SPI_SlaveInit(). Modify some fields of the structure before calling SPI_SlaveInit(). Example:

spi_slave_config_t config;
SPI_SlaveGetDefaultConfig(&config);

Parameters:
  • config – pointer to slave configuration structure

void SPI_SlaveInit(SPI_Type *base, const spi_slave_config_t *config)

Initializes the SPI with slave configuration.

The configuration structure can be filled by user from scratch or be set with default values by SPI_SlaveGetDefaultConfig(). After calling this API, the slave is ready to transfer. Example

spi_slave_config_t config = {
.polarity = kSPIClockPolarity_ActiveHigh;
.phase = kSPIClockPhase_FirstEdge;
.direction = kSPIMsbFirst;
...
};
SPI_MasterInit(SPI0, &config);

Parameters:
  • base – SPI base pointer

  • config – pointer to master configuration structure

void SPI_Deinit(SPI_Type *base)

De-initializes the SPI.

Calling this API resets the SPI module, gates the SPI clock. The SPI module can’t work unless calling the SPI_MasterInit/SPI_SlaveInit to initialize module.

Parameters:
  • base – SPI base pointer

static inline void SPI_Enable(SPI_Type *base, bool enable)

Enables or disables the SPI.

Parameters:
  • base – SPI base pointer

  • enable – pass true to enable module, false to disable module

uint32_t SPI_GetStatusFlags(SPI_Type *base)

Gets the status flag.

Parameters:
  • base – SPI base pointer

Returns:

SPI Status, use status flag to AND _spi_flags could get the related status.

static inline void SPI_ClearInterrupt(SPI_Type *base, uint8_t mask)

Clear the interrupt if enable INCTLR.

Parameters:
  • base – SPI base pointer

  • mask – Interrupt need to be cleared The parameter could be any combination of the following values:

    • kSPI_RxFullAndModfInterruptEnable

    • kSPI_TxEmptyInterruptEnable

    • kSPI_MatchInterruptEnable

    • kSPI_RxFifoNearFullInterruptEnable

    • kSPI_TxFifoNearEmptyInterruptEnable

void SPI_EnableInterrupts(SPI_Type *base, uint32_t mask)

Enables the interrupt for the SPI.

Parameters:
  • base – SPI base pointer

  • mask – SPI interrupt source. The parameter can be any combination of the following values:

    • kSPI_RxFullAndModfInterruptEnable

    • kSPI_TxEmptyInterruptEnable

    • kSPI_MatchInterruptEnable

    • kSPI_RxFifoNearFullInterruptEnable

    • kSPI_TxFifoNearEmptyInterruptEnable

void SPI_DisableInterrupts(SPI_Type *base, uint32_t mask)

Disables the interrupt for the SPI.

Parameters:
  • base – SPI base pointer

  • mask – SPI interrupt source. The parameter can be any combination of the following values:

    • kSPI_RxFullAndModfInterruptEnable

    • kSPI_TxEmptyInterruptEnable

    • kSPI_MatchInterruptEnable

    • kSPI_RxFifoNearFullInterruptEnable

    • kSPI_TxFifoNearEmptyInterruptEnable

static inline void SPI_EnableDMA(SPI_Type *base, uint8_t mask, bool enable)

Enables the DMA source for SPI.

Parameters:
  • base – SPI base pointer

  • mask – SPI DMA source.

  • enable – True means enable DMA, false means disable DMA

static inline uint32_t SPI_GetDataRegisterAddress(SPI_Type *base)

Gets the SPI tx/rx data register address.

This API is used to provide a transfer address for the SPI DMA transfer configuration.

Parameters:
  • base – SPI base pointer

Returns:

data register address

uint32_t SPI_GetInstance(SPI_Type *base)

Get the instance for SPI module.

Parameters:
  • base – SPI base address

static inline void SPI_SetPinMode(SPI_Type *base, spi_pin_mode_t pinMode)

Sets the pin mode for transfer.

Parameters:
  • base – SPI base pointer

  • pinMode – pin mode for transfer AND _spi_pin_mode could get the related configuration.

void SPI_MasterSetBaudRate(SPI_Type *base, uint32_t baudRate_Bps, uint32_t srcClock_Hz)

Sets the baud rate for SPI transfer. This is only used in master.

Parameters:
  • base – SPI base pointer

  • baudRate_Bps – baud rate needed in Hz.

  • srcClock_Hz – SPI source clock frequency in Hz.

static inline void SPI_SetMatchData(SPI_Type *base, uint32_t matchData)

Sets the match data for SPI.

The match data is a hardware comparison value. When the value received in the SPI receive data buffer equals the hardware comparison value, the SPI Match Flag in the S register (S[SPMF]) sets. This can also generate an interrupt if the enable bit sets.

Parameters:
  • base – SPI base pointer

  • matchData – Match data.

void SPI_EnableFIFO(SPI_Type *base, bool enable)

Enables or disables the FIFO if there is a FIFO.

Parameters:
  • base – SPI base pointer

  • enable – True means enable FIFO, false means disable FIFO.

status_t SPI_WriteBlocking(SPI_Type *base, uint8_t *buffer, size_t size)

Sends a buffer of data bytes using a blocking method.

Note

This function blocks via polling until all bytes have been sent.

Parameters:
  • base – SPI base pointer

  • buffer – The data bytes to send

  • size – The number of data bytes to send

Returns:

kStatus_SPI_Timeout The transfer timed out and was aborted.

void SPI_WriteData(SPI_Type *base, uint16_t data)

Writes a data into the SPI data register.

Parameters:
  • base – SPI base pointer

  • data – needs to be write.

uint16_t SPI_ReadData(SPI_Type *base)

Gets a data from the SPI data register.

Parameters:
  • base – SPI base pointer

Returns:

Data in the register.

void SPI_SetDummyData(SPI_Type *base, uint8_t dummyData)

Set up the dummy data.

Parameters:
  • base – SPI peripheral address.

  • dummyData – Data to be transferred when tx buffer is NULL.

void SPI_MasterTransferCreateHandle(SPI_Type *base, spi_master_handle_t *handle, spi_master_callback_t callback, void *userData)

Initializes the SPI master handle.

This function initializes the SPI master handle which can be used for other SPI master transactional APIs. Usually, for a specified SPI instance, call this API once to get the initialized handle.

Parameters:
  • base – SPI peripheral base address.

  • handle – SPI handle pointer.

  • callback – Callback function.

  • userData – User data.

status_t SPI_MasterTransferBlocking(SPI_Type *base, spi_transfer_t *xfer)

Transfers a block of data using a polling method.

Parameters:
  • base – SPI base pointer

  • xfer – pointer to spi_xfer_config_t structure

Return values:
  • kStatus_Success – Successfully start a transfer.

  • kStatus_InvalidArgument – Input argument is invalid.

status_t SPI_MasterTransferNonBlocking(SPI_Type *base, spi_master_handle_t *handle, spi_transfer_t *xfer)

Performs a non-blocking SPI interrupt transfer.

Note

The API immediately returns after transfer initialization is finished. Call SPI_GetStatusIRQ() to get the transfer status.

Note

If SPI transfer data frame size is 16 bits, the transfer size cannot be an odd number.

Parameters:
  • base – SPI peripheral base address.

  • handle – pointer to spi_master_handle_t structure which stores the transfer state

  • xfer – pointer to spi_xfer_config_t structure

Return values:
  • kStatus_Success – Successfully start a transfer.

  • kStatus_InvalidArgument – Input argument is invalid.

  • kStatus_SPI_Busy – SPI is not idle, is running another transfer.

status_t SPI_MasterTransferGetCount(SPI_Type *base, spi_master_handle_t *handle, size_t *count)

Gets the bytes of the SPI interrupt transferred.

Parameters:
  • base – SPI peripheral base address.

  • handle – Pointer to SPI transfer handle, this should be a static variable.

  • count – Transferred bytes of SPI master.

Return values:
  • kStatus_SPI_Success – Succeed get the transfer count.

  • kStatus_NoTransferInProgress – There is not a non-blocking transaction currently in progress.

void SPI_MasterTransferAbort(SPI_Type *base, spi_master_handle_t *handle)

Aborts an SPI transfer using interrupt.

Parameters:
  • base – SPI peripheral base address.

  • handle – Pointer to SPI transfer handle, this should be a static variable.

void SPI_MasterTransferHandleIRQ(SPI_Type *base, spi_master_handle_t *handle)

Interrupts the handler for the SPI.

Parameters:
  • base – SPI peripheral base address.

  • handle – pointer to spi_master_handle_t structure which stores the transfer state.

void SPI_SlaveTransferCreateHandle(SPI_Type *base, spi_slave_handle_t *handle, spi_slave_callback_t callback, void *userData)

Initializes the SPI slave handle.

This function initializes the SPI slave handle which can be used for other SPI slave transactional APIs. Usually, for a specified SPI instance, call this API once to get the initialized handle.

Parameters:
  • base – SPI peripheral base address.

  • handle – SPI handle pointer.

  • callback – Callback function.

  • userData – User data.

status_t SPI_SlaveTransferNonBlocking(SPI_Type *base, spi_slave_handle_t *handle, spi_transfer_t *xfer)

Performs a non-blocking SPI slave interrupt transfer.

Note

The API returns immediately after the transfer initialization is finished. Call SPI_GetStatusIRQ() to get the transfer status.

Note

If SPI transfer data frame size is 16 bits, the transfer size cannot be an odd number.

Parameters:
  • base – SPI peripheral base address.

  • handle – pointer to spi_slave_handle_t structure which stores the transfer state

  • xfer – pointer to spi_xfer_config_t structure

Return values:
  • kStatus_Success – Successfully start a transfer.

  • kStatus_InvalidArgument – Input argument is invalid.

  • kStatus_SPI_Busy – SPI is not idle, is running another transfer.

static inline status_t SPI_SlaveTransferGetCount(SPI_Type *base, spi_slave_handle_t *handle, size_t *count)

Gets the bytes of the SPI interrupt transferred.

Parameters:
  • base – SPI peripheral base address.

  • handle – Pointer to SPI transfer handle, this should be a static variable.

  • count – Transferred bytes of SPI slave.

Return values:
  • kStatus_SPI_Success – Succeed get the transfer count.

  • kStatus_NoTransferInProgress – There is not a non-blocking transaction currently in progress.

static inline void SPI_SlaveTransferAbort(SPI_Type *base, spi_slave_handle_t *handle)

Aborts an SPI slave transfer using interrupt.

Parameters:
  • base – SPI peripheral base address.

  • handle – Pointer to SPI transfer handle, this should be a static variable.

void SPI_SlaveTransferHandleIRQ(SPI_Type *base, spi_slave_handle_t *handle)

Interrupts a handler for the SPI slave.

Parameters:
  • base – SPI peripheral base address.

  • handle – pointer to spi_slave_handle_t structure which stores the transfer state

FSL_SPI_DRIVER_VERSION

SPI driver version.

Return status for the SPI driver.

Values:

enumerator kStatus_SPI_Busy

SPI bus is busy

enumerator kStatus_SPI_Idle

SPI is idle

enumerator kStatus_SPI_Error

SPI error

enumerator kStatus_SPI_Timeout

SPI timeout polling status flags.

enum _spi_clock_polarity

SPI clock polarity configuration.

Values:

enumerator kSPI_ClockPolarityActiveHigh

Active-high SPI clock (idles low).

enumerator kSPI_ClockPolarityActiveLow

Active-low SPI clock (idles high).

enum _spi_clock_phase

SPI clock phase configuration.

Values:

enumerator kSPI_ClockPhaseFirstEdge

First edge on SPSCK occurs at the middle of the first cycle of a data transfer.

enumerator kSPI_ClockPhaseSecondEdge

First edge on SPSCK occurs at the start of the first cycle of a data transfer.

enum _spi_shift_direction

SPI data shifter direction options.

Values:

enumerator kSPI_MsbFirst

Data transfers start with most significant bit.

enumerator kSPI_LsbFirst

Data transfers start with least significant bit.

enum _spi_ss_output_mode

SPI slave select output mode options.

Values:

enumerator kSPI_SlaveSelectAsGpio

Slave select pin configured as GPIO.

enumerator kSPI_SlaveSelectFaultInput

Slave select pin configured for fault detection.

enumerator kSPI_SlaveSelectAutomaticOutput

Slave select pin configured for automatic SPI output.

enum _spi_pin_mode

SPI pin mode options.

Values:

enumerator kSPI_PinModeNormal

Pins operate in normal, single-direction mode.

enumerator kSPI_PinModeInput

Bidirectional mode. Master: MOSI pin is input; Slave: MISO pin is input.

enumerator kSPI_PinModeOutput

Bidirectional mode. Master: MOSI pin is output; Slave: MISO pin is output.

enum _spi_data_bitcount_mode

SPI data length mode options.

Values:

enumerator kSPI_8BitMode

8-bit data transmission mode

enumerator kSPI_16BitMode

16-bit data transmission mode

enum _spi_interrupt_enable

SPI interrupt sources.

Values:

enumerator kSPI_RxFullAndModfInterruptEnable

Receive buffer full (SPRF) and mode fault (MODF) interrupt

enumerator kSPI_TxEmptyInterruptEnable

Transmit buffer empty interrupt

enumerator kSPI_MatchInterruptEnable

Match interrupt

enumerator kSPI_RxFifoNearFullInterruptEnable

Receive FIFO nearly full interrupt

enumerator kSPI_TxFifoNearEmptyInterruptEnable

Transmit FIFO nearly empty interrupt

enum _spi_flags

SPI status flags.

Values:

enumerator kSPI_RxBufferFullFlag

Read buffer full flag

enumerator kSPI_MatchFlag

Match flag

enumerator kSPI_TxBufferEmptyFlag

Transmit buffer empty flag

enumerator kSPI_ModeFaultFlag

Mode fault flag

enumerator kSPI_RxFifoNearFullFlag

Rx FIFO near full

enumerator kSPI_TxFifoNearEmptyFlag

Tx FIFO near empty

enumerator kSPI_TxFifoFullFlag

Tx FIFO full

enumerator kSPI_RxFifoEmptyFlag

Rx FIFO empty

enumerator kSPI_TxFifoError

Tx FIFO error

enumerator kSPI_RxFifoError

Rx FIFO error

enumerator kSPI_TxOverflow

Tx FIFO Overflow

enumerator kSPI_RxOverflow

Rx FIFO Overflow

enum _spi_w1c_interrupt

SPI FIFO write-1-to-clear interrupt flags.

Values:

enumerator kSPI_RxFifoFullClearInterrupt

Receive FIFO full interrupt

enumerator kSPI_TxFifoEmptyClearInterrupt

Transmit FIFO empty interrupt

enumerator kSPI_RxNearFullClearInterrupt

Receive FIFO nearly full interrupt

enumerator kSPI_TxNearEmptyClearInterrupt

Transmit FIFO nearly empty interrupt

enum _spi_txfifo_watermark

SPI TX FIFO watermark settings.

Values:

enumerator kSPI_TxFifoOneFourthEmpty

SPI tx watermark at 1/4 FIFO size

enumerator kSPI_TxFifoOneHalfEmpty

SPI tx watermark at 1/2 FIFO size

enum _spi_rxfifo_watermark

SPI RX FIFO watermark settings.

Values:

enumerator kSPI_RxFifoThreeFourthsFull

SPI rx watermark at 3/4 FIFO size

enumerator kSPI_RxFifoOneHalfFull

SPI rx watermark at 1/2 FIFO size

enum _spi_dma_enable_t

SPI DMA source.

Values:

enumerator kSPI_TxDmaEnable

Tx DMA request source

enumerator kSPI_RxDmaEnable

Rx DMA request source

enumerator kSPI_DmaAllEnable

All DMA request source

typedef enum _spi_clock_polarity spi_clock_polarity_t

SPI clock polarity configuration.

typedef enum _spi_clock_phase spi_clock_phase_t

SPI clock phase configuration.

typedef enum _spi_shift_direction spi_shift_direction_t

SPI data shifter direction options.

typedef enum _spi_ss_output_mode spi_ss_output_mode_t

SPI slave select output mode options.

typedef enum _spi_pin_mode spi_pin_mode_t

SPI pin mode options.

typedef enum _spi_data_bitcount_mode spi_data_bitcount_mode_t

SPI data length mode options.

typedef enum _spi_w1c_interrupt spi_w1c_interrupt_t

SPI FIFO write-1-to-clear interrupt flags.

typedef enum _spi_txfifo_watermark spi_txfifo_watermark_t

SPI TX FIFO watermark settings.

typedef enum _spi_rxfifo_watermark spi_rxfifo_watermark_t

SPI RX FIFO watermark settings.

typedef struct _spi_master_config spi_master_config_t

SPI master user configure structure.

typedef struct _spi_slave_config spi_slave_config_t

SPI slave user configure structure.

typedef struct _spi_transfer spi_transfer_t

SPI transfer structure.

typedef struct _spi_master_handle spi_master_handle_t
typedef spi_master_handle_t spi_slave_handle_t

Slave handle is the same with master handle

typedef void (*spi_master_callback_t)(SPI_Type *base, spi_master_handle_t *handle, status_t status, void *userData)

SPI master callback for finished transmit.

typedef void (*spi_slave_callback_t)(SPI_Type *base, spi_slave_handle_t *handle, status_t status, void *userData)

SPI master callback for finished transmit.

volatile uint8_t g_spiDummyData[]

Global variable for dummy data value setting.

SPI_DUMMYDATA

SPI dummy transfer data, the data is sent while txBuff is NULL.

SPI_RETRY_TIMES

Retry times for waiting flag.

struct _spi_master_config
#include <fsl_spi.h>

SPI master user configure structure.

Public Members

bool enableMaster

Enable SPI at initialization time

bool enableStopInWaitMode

SPI stop in wait mode

spi_clock_polarity_t polarity

Clock polarity

spi_clock_phase_t phase

Clock phase

spi_shift_direction_t direction

MSB or LSB

spi_data_bitcount_mode_t dataMode

8bit or 16bit mode

spi_txfifo_watermark_t txWatermark

Tx watermark settings

spi_rxfifo_watermark_t rxWatermark

Rx watermark settings

spi_ss_output_mode_t outputMode

SS pin setting

spi_pin_mode_t pinMode

SPI pin mode select

uint32_t baudRate_Bps

Baud Rate for SPI in Hz

struct _spi_slave_config
#include <fsl_spi.h>

SPI slave user configure structure.

Public Members

bool enableSlave

Enable SPI at initialization time

bool enableStopInWaitMode

SPI stop in wait mode

spi_clock_polarity_t polarity

Clock polarity

spi_clock_phase_t phase

Clock phase

spi_shift_direction_t direction

MSB or LSB

spi_data_bitcount_mode_t dataMode

8bit or 16bit mode

spi_txfifo_watermark_t txWatermark

Tx watermark settings

spi_rxfifo_watermark_t rxWatermark

Rx watermark settings

spi_pin_mode_t pinMode

SPI pin mode select

struct _spi_transfer
#include <fsl_spi.h>

SPI transfer structure.

Public Members

const uint8_t *txData

Send buffer

uint8_t *rxData

Receive buffer

size_t dataSize

Transfer bytes

uint32_t flags

SPI control flag, useless to SPI.

struct _spi_master_handle
#include <fsl_spi.h>

SPI transfer handle structure.

Public Members

const uint8_t *volatile txData

Transfer buffer

uint8_t *volatile rxData

Receive buffer

volatile size_t txRemainingBytes

Send data remaining in bytes

volatile size_t rxRemainingBytes

Receive data remaining in bytes

volatile uint32_t state

SPI internal state

size_t transferSize

Bytes to be transferred

uint8_t bytePerFrame

SPI mode, 2bytes or 1byte in a frame

uint8_t watermark

Watermark value for SPI transfer

spi_master_callback_t callback

SPI callback

void *userData

Callback parameter

TPM: Timer PWM Module

uint32_t TPM_GetInstance(TPM_Type *base)

Gets the instance from the base address.

Parameters:
  • base – TPM peripheral base address

Returns:

The TPM instance

void TPM_Init(TPM_Type *base, const tpm_config_t *config)

Ungates the TPM clock and configures the peripheral for basic operation.

Note

This API should be called at the beginning of the application using the TPM driver.

Parameters:
  • base – TPM peripheral base address

  • config – Pointer to user’s TPM config structure.

void TPM_Deinit(TPM_Type *base)

Stops the counter and gates the TPM clock.

Parameters:
  • base – TPM peripheral base address

void TPM_GetDefaultConfig(tpm_config_t *config)

Fill in the TPM config struct with the default settings.

The default values are:

     config->prescale = kTPM_Prescale_Divide_1;
     config->useGlobalTimeBase = false;
     config->syncGlobalTimeBase = false;
     config->dozeEnable = false;
     config->dbgMode = false;
     config->enableReloadOnTrigger = false;
     config->enableStopOnOverflow = false;
     config->enableStartOnTrigger = false;
#if FSL_FEATURE_TPM_HAS_PAUSE_COUNTER_ON_TRIGGER
     config->enablePauseOnTrigger = false;
#endif
     config->triggerSelect = kTPM_Trigger_Select_0;
#if FSL_FEATURE_TPM_HAS_EXTERNAL_TRIGGER_SELECTION
     config->triggerSource = kTPM_TriggerSource_External;
     config->extTriggerPolarity = kTPM_ExtTrigger_Active_High;
#endif
#if defined(FSL_FEATURE_TPM_HAS_POL) && FSL_FEATURE_TPM_HAS_POL
     config->chnlPolarity = 0U;
#endif

Parameters:
  • config – Pointer to user’s TPM config structure.

tpm_clock_prescale_t TPM_CalculateCounterClkDiv(TPM_Type *base, uint32_t counterPeriod_Hz, uint32_t srcClock_Hz)

Calculates the counter clock prescaler.

This function calculates the values for SC[PS].

return Calculated clock prescaler value.

Parameters:
  • base – TPM peripheral base address

  • counterPeriod_Hz – The desired frequency in Hz which corresponding to the time when the counter reaches the mod value

  • srcClock_Hz – TPM counter clock in Hz

status_t TPM_SetupPwm(TPM_Type *base, const tpm_chnl_pwm_signal_param_t *chnlParams, uint8_t numOfChnls, tpm_pwm_mode_t mode, uint32_t pwmFreq_Hz, uint32_t srcClock_Hz)

Configures the PWM signal parameters.

User calls this function to configure the PWM signals period, mode, dutycycle and edge. Use this function to configure all the TPM channels that will be used to output a PWM signal

Parameters:
  • base – TPM peripheral base address

  • chnlParams – Array of PWM channel parameters to configure the channel(s)

  • numOfChnls – Number of channels to configure, this should be the size of the array passed in

  • mode – PWM operation mode, options available in enumeration tpm_pwm_mode_t

  • pwmFreq_Hz – PWM signal frequency in Hz

  • srcClock_Hz – TPM counter clock in Hz

Returns:

kStatus_Success if the PWM setup was successful, kStatus_Error on failure

status_t TPM_UpdatePwmDutycycle(TPM_Type *base, tpm_chnl_t chnlNumber, tpm_pwm_mode_t currentPwmMode, uint8_t dutyCyclePercent)

Update the duty cycle of an active PWM signal.

Parameters:
  • base – TPM peripheral base address

  • chnlNumber – The channel number. In combined mode, this represents the channel pair number

  • currentPwmMode – The current PWM mode set during PWM setup

  • dutyCyclePercent – New PWM pulse width, value should be between 0 to 100 0=inactive signal(0% duty cycle)… 100=active signal (100% duty cycle)

Returns:

kStatus_Success if the PWM setup was successful, kStatus_Error on failure

void TPM_UpdateChnlEdgeLevelSelect(TPM_Type *base, tpm_chnl_t chnlNumber, uint8_t level)

Update the edge level selection for a channel.

Note

When the TPM has PWM pause level select feature (FSL_FEATURE_TPM_HAS_PAUSE_LEVEL_SELECT = 1), the PWM output cannot be turned off by selecting the output level. In this case, must use TPM_DisableChannel API to close the PWM output.

Parameters:
  • base – TPM peripheral base address

  • chnlNumber – The channel number

  • level – The level to be set to the ELSnB:ELSnA field; valid values are 00, 01, 10, 11. See the appropriate SoC reference manual for details about this field.

static inline uint8_t TPM_GetChannelContorlBits(TPM_Type *base, tpm_chnl_t chnlNumber)

Get the channel control bits value (mode, edge and level bit fileds).

This function disable the channel by clear all mode and level control bits.

Parameters:
  • base – TPM peripheral base address

  • chnlNumber – The channel number

Returns:

The contorl bits value. This is the logical OR of members of the enumeration tpm_chnl_control_bit_mask_t.

static inline void TPM_DisableChannel(TPM_Type *base, tpm_chnl_t chnlNumber)

Dsiable the channel.

This function disable the channel by clear all mode and level control bits.

Parameters:
  • base – TPM peripheral base address

  • chnlNumber – The channel number

static inline void TPM_EnableChannel(TPM_Type *base, tpm_chnl_t chnlNumber, uint8_t control)

Enable the channel according to mode and level configs.

This function enable the channel output according to input mode/level config parameters.

Parameters:
  • base – TPM peripheral base address

  • chnlNumber – The channel number

  • control – The contorl bits value. This is the logical OR of members of the enumeration tpm_chnl_control_bit_mask_t.

void TPM_SetupInputCapture(TPM_Type *base, tpm_chnl_t chnlNumber, tpm_input_capture_edge_t captureMode)

Enables capturing an input signal on the channel using the function parameters.

When the edge specified in the captureMode argument occurs on the channel, the TPM counter is captured into the CnV register. The user has to read the CnV register separately to get this value.

Parameters:
  • base – TPM peripheral base address

  • chnlNumber – The channel number

  • captureMode – Specifies which edge to capture

void TPM_SetupOutputCompare(TPM_Type *base, tpm_chnl_t chnlNumber, tpm_output_compare_mode_t compareMode, uint32_t compareValue)

Configures the TPM to generate timed pulses.

When the TPM counter matches the value of compareVal argument (this is written into CnV reg), the channel output is changed based on what is specified in the compareMode argument.

Parameters:
  • base – TPM peripheral base address

  • chnlNumber – The channel number

  • compareMode – Action to take on the channel output when the compare condition is met

  • compareValue – Value to be programmed in the CnV register.

void TPM_EnableInterrupts(TPM_Type *base, uint32_t mask)

Enables the selected TPM interrupts.

Parameters:
  • base – TPM peripheral base address

  • mask – The interrupts to enable. This is a logical OR of members of the enumeration tpm_interrupt_enable_t

void TPM_DisableInterrupts(TPM_Type *base, uint32_t mask)

Disables the selected TPM interrupts.

Parameters:
  • base – TPM peripheral base address

  • mask – The interrupts to disable. This is a logical OR of members of the enumeration tpm_interrupt_enable_t

uint32_t TPM_GetEnabledInterrupts(TPM_Type *base)

Gets the enabled TPM interrupts.

Parameters:
  • base – TPM peripheral base address

Returns:

The enabled interrupts. This is the logical OR of members of the enumeration tpm_interrupt_enable_t

void TPM_RegisterCallBack(TPM_Type *base, tpm_callback_t callback)

Register callback.

If channel or overflow interrupt is enabled by the user, then a callback can be registered which will be invoked when the interrupt is triggered.

Parameters:
  • base – TPM peripheral base address

  • callback – Callback function

static inline uint32_t TPM_GetChannelValue(TPM_Type *base, tpm_chnl_t chnlNumber)

Gets the TPM channel value.

Note

The TPM channel value contain the captured TPM counter value for the input modes or the match value for the output modes.

Parameters:
  • base – TPM peripheral base address

  • chnlNumber – The channel number

Returns:

The channle CnV regisyer value.

static inline uint32_t TPM_GetStatusFlags(TPM_Type *base)

Gets the TPM status flags.

Parameters:
  • base – TPM peripheral base address

Returns:

The status flags. This is the logical OR of members of the enumeration tpm_status_flags_t

static inline void TPM_ClearStatusFlags(TPM_Type *base, uint32_t mask)

Clears the TPM status flags.

Parameters:
  • base – TPM peripheral base address

  • mask – The status flags to clear. This is a logical OR of members of the enumeration tpm_status_flags_t

static inline void TPM_SetTimerPeriod(TPM_Type *base, uint32_t ticks)

Sets the timer period in units of ticks.

Timers counts from 0 until it equals the count value set here. The count value is written to the MOD register.

Note

  1. This API allows the user to use the TPM module as a timer. Do not mix usage of this API with TPM’s PWM setup API’s.

  2. Call the utility macros provided in the fsl_common.h to convert usec or msec to ticks.

Parameters:
  • base – TPM peripheral base address

  • ticks – A timer period in units of ticks, which should be equal or greater than 1.

static inline uint32_t TPM_GetCurrentTimerCount(TPM_Type *base)

Reads the current timer counting value.

This function returns the real-time timer counting value in a range from 0 to a timer period.

Note

Call the utility macros provided in the fsl_common.h to convert ticks to usec or msec.

Parameters:
  • base – TPM peripheral base address

Returns:

The current counter value in ticks

static inline void TPM_StartTimer(TPM_Type *base, tpm_clock_source_t clockSource)

Starts the TPM counter.

Parameters:
  • base – TPM peripheral base address

  • clockSource – TPM clock source; once clock source is set the counter will start running

static inline void TPM_StopTimer(TPM_Type *base)

Stops the TPM counter.

Parameters:
  • base – TPM peripheral base address

FSL_TPM_DRIVER_VERSION

TPM driver version 2.3.2.

enum _tpm_chnl

List of TPM channels.

Note

Actual number of available channels is SoC dependent

Values:

enumerator kTPM_Chnl_0

TPM channel number 0

enumerator kTPM_Chnl_1

TPM channel number 1

enumerator kTPM_Chnl_2

TPM channel number 2

enumerator kTPM_Chnl_3

TPM channel number 3

enumerator kTPM_Chnl_4

TPM channel number 4

enumerator kTPM_Chnl_5

TPM channel number 5

enumerator kTPM_Chnl_6

TPM channel number 6

enumerator kTPM_Chnl_7

TPM channel number 7

enum _tpm_pwm_mode

TPM PWM operation modes.

Values:

enumerator kTPM_EdgeAlignedPwm

Edge aligned PWM

enumerator kTPM_CenterAlignedPwm

Center aligned PWM

enum _tpm_pwm_level_select

TPM PWM output pulse mode: high-true, low-true or no output.

Note

When the TPM has PWM pause level select feature, the PWM output cannot be turned off by selecting the output level. In this case, the channel must be closed to close the PWM output.

Values:

enumerator kTPM_NoPwmSignal

No PWM output on pin

enumerator kTPM_LowTrue

Low true pulses

enumerator kTPM_HighTrue

High true pulses

enum _tpm_chnl_control_bit_mask

List of TPM channel modes and level control bit mask.

Values:

enumerator kTPM_ChnlELSnAMask

Channel ELSA bit mask.

enumerator kTPM_ChnlELSnBMask

Channel ELSB bit mask.

enumerator kTPM_ChnlMSAMask

Channel MSA bit mask.

enumerator kTPM_ChnlMSBMask

Channel MSB bit mask.

enum _tpm_output_compare_mode

TPM output compare modes.

Values:

enumerator kTPM_NoOutputSignal

No channel output when counter reaches CnV

enumerator kTPM_ToggleOnMatch

Toggle output

enumerator kTPM_ClearOnMatch

Clear output

enumerator kTPM_SetOnMatch

Set output

enumerator kTPM_HighPulseOutput

Pulse output high

enumerator kTPM_LowPulseOutput

Pulse output low

enum _tpm_input_capture_edge

TPM input capture edge.

Values:

enumerator kTPM_RisingEdge

Capture on rising edge only

enumerator kTPM_FallingEdge

Capture on falling edge only

enumerator kTPM_RiseAndFallEdge

Capture on rising or falling edge

enum _tpm_clock_source

TPM clock source selection.

Values:

enumerator kTPM_SystemClock

System clock

enumerator kTPM_FixedClock

Fixed frequency clock

enumerator kTPM_ExternalClock

External TPM_EXTCLK pin clock

enum _tpm_clock_prescale

TPM prescale value selection for the clock source.

Values:

enumerator kTPM_Prescale_Divide_1

Divide by 1

enumerator kTPM_Prescale_Divide_2

Divide by 2

enumerator kTPM_Prescale_Divide_4

Divide by 4

enumerator kTPM_Prescale_Divide_8

Divide by 8

enumerator kTPM_Prescale_Divide_16

Divide by 16

enumerator kTPM_Prescale_Divide_32

Divide by 32

enumerator kTPM_Prescale_Divide_64

Divide by 64

enumerator kTPM_Prescale_Divide_128

Divide by 128

enum _tpm_interrupt_enable

List of TPM interrupts.

Values:

enumerator kTPM_Chnl0InterruptEnable

Channel 0 interrupt.

enumerator kTPM_Chnl1InterruptEnable

Channel 1 interrupt.

enumerator kTPM_Chnl2InterruptEnable

Channel 2 interrupt.

enumerator kTPM_Chnl3InterruptEnable

Channel 3 interrupt.

enumerator kTPM_Chnl4InterruptEnable

Channel 4 interrupt.

enumerator kTPM_Chnl5InterruptEnable

Channel 5 interrupt.

enumerator kTPM_Chnl6InterruptEnable

Channel 6 interrupt.

enumerator kTPM_Chnl7InterruptEnable

Channel 7 interrupt.

enumerator kTPM_TimeOverflowInterruptEnable

Time overflow interrupt.

enum _tpm_status_flags

List of TPM flags.

Values:

enumerator kTPM_Chnl0Flag

Channel 0 flag

enumerator kTPM_Chnl1Flag

Channel 1 flag

enumerator kTPM_Chnl2Flag

Channel 2 flag

enumerator kTPM_Chnl3Flag

Channel 3 flag

enumerator kTPM_Chnl4Flag

Channel 4 flag

enumerator kTPM_Chnl5Flag

Channel 5 flag

enumerator kTPM_Chnl6Flag

Channel 6 flag

enumerator kTPM_Chnl7Flag

Channel 7 flag

enumerator kTPM_TimeOverflowFlag

Time overflow flag

typedef enum _tpm_chnl tpm_chnl_t

List of TPM channels.

Note

Actual number of available channels is SoC dependent

typedef enum _tpm_pwm_mode tpm_pwm_mode_t

TPM PWM operation modes.

typedef enum _tpm_pwm_level_select tpm_pwm_level_select_t

TPM PWM output pulse mode: high-true, low-true or no output.

Note

When the TPM has PWM pause level select feature, the PWM output cannot be turned off by selecting the output level. In this case, the channel must be closed to close the PWM output.

typedef enum _tpm_chnl_control_bit_mask tpm_chnl_control_bit_mask_t

List of TPM channel modes and level control bit mask.

typedef struct _tpm_chnl_pwm_signal_param tpm_chnl_pwm_signal_param_t

Options to configure a TPM channel’s PWM signal.

typedef enum _tpm_output_compare_mode tpm_output_compare_mode_t

TPM output compare modes.

typedef enum _tpm_input_capture_edge tpm_input_capture_edge_t

TPM input capture edge.

typedef enum _tpm_clock_source tpm_clock_source_t

TPM clock source selection.

typedef enum _tpm_clock_prescale tpm_clock_prescale_t

TPM prescale value selection for the clock source.

typedef struct _tpm_config tpm_config_t

TPM config structure.

This structure holds the configuration settings for the TPM peripheral. To initialize this structure to reasonable defaults, call the TPM_GetDefaultConfig() function and pass a pointer to your config structure instance.

The config struct can be made const so it resides in flash

typedef enum _tpm_interrupt_enable tpm_interrupt_enable_t

List of TPM interrupts.

typedef enum _tpm_status_flags tpm_status_flags_t

List of TPM flags.

typedef void (*tpm_callback_t)(TPM_Type *base)

TPM callback function pointer.

Param base:

TPM peripheral base address.

TPM_MAX_COUNTER_VALUE(x)

Help macro to get the max counter value.

struct _tpm_chnl_pwm_signal_param
#include <fsl_tpm.h>

Options to configure a TPM channel’s PWM signal.

Public Members

tpm_chnl_t chnlNumber

TPM channel to configure. In combined mode (available in some SoC’s), this represents the channel pair number

tpm_pwm_level_select_t level

PWM output active level select

uint8_t dutyCyclePercent

PWM pulse width, value should be between 0 to 100 0=inactive signal(0% duty cycle)… 100=always active signal (100% duty cycle)

struct _tpm_config
#include <fsl_tpm.h>

TPM config structure.

This structure holds the configuration settings for the TPM peripheral. To initialize this structure to reasonable defaults, call the TPM_GetDefaultConfig() function and pass a pointer to your config structure instance.

The config struct can be made const so it resides in flash

Public Members

tpm_clock_prescale_t prescale

Select TPM clock prescale value

UART: Universal Asynchronous Receiver/Transmitter Driver

UART Driver

status_t UART_Init(UART_Type *base, const uart_config_t *config, uint32_t srcClock_Hz)

Initializes a UART instance with a user configuration structure and peripheral clock.

This function configures the UART module with the user-defined settings. The user can configure the configuration structure and also get the default configuration by using the UART_GetDefaultConfig() function. The example below shows how to use this API to configure UART.

uart_config_t uartConfig;
uartConfig.baudRate_Bps = 115200U;
uartConfig.parityMode = kUART_ParityDisabled;
uartConfig.stopBitCount = kUART_OneStopBit;
uartConfig.txFifoWatermark = 0;
uartConfig.rxFifoWatermark = 1;
UART_Init(UART1, &uartConfig, 20000000U);

Parameters:
  • base – UART peripheral base address.

  • config – Pointer to the user-defined configuration structure.

  • srcClock_Hz – UART clock source frequency in HZ.

Return values:
  • kStatus_UART_BaudrateNotSupport – Baudrate is not support in current clock source.

  • kStatus_Success – Status UART initialize succeed

void UART_Deinit(UART_Type *base)

Deinitializes a UART instance.

This function waits for TX complete, disables TX and RX, and disables the UART clock.

Parameters:
  • base – UART peripheral base address.

void UART_GetDefaultConfig(uart_config_t *config)

Gets the default configuration structure.

This function initializes the UART configuration structure to a default value. The default values are as follows. uartConfig->baudRate_Bps = 115200U; uartConfig->bitCountPerChar = kUART_8BitsPerChar; uartConfig->parityMode = kUART_ParityDisabled; uartConfig->stopBitCount = kUART_OneStopBit; uartConfig->txFifoWatermark = 0; uartConfig->rxFifoWatermark = 1; uartConfig->idleType = kUART_IdleTypeStartBit; uartConfig->enableTx = false; uartConfig->enableRx = false;

Parameters:
  • config – Pointer to configuration structure.

status_t UART_SetBaudRate(UART_Type *base, uint32_t baudRate_Bps, uint32_t srcClock_Hz)

Sets the UART instance baud rate.

This function configures the UART module baud rate. This function is used to update the UART module baud rate after the UART module is initialized by the UART_Init.

UART_SetBaudRate(UART1, 115200U, 20000000U);

Parameters:
  • base – UART peripheral base address.

  • baudRate_Bps – UART baudrate to be set.

  • srcClock_Hz – UART clock source frequency in Hz.

Return values:
  • kStatus_UART_BaudrateNotSupport – Baudrate is not support in the current clock source.

  • kStatus_Success – Set baudrate succeeded.

void UART_Enable9bitMode(UART_Type *base, bool enable)

Enable 9-bit data mode for UART.

This function set the 9-bit mode for UART module. The 9th bit is not used for parity thus can be modified by user.

Parameters:
  • base – UART peripheral base address.

  • enable – true to enable, flase to disable.

static inline void UART_SetMatchAddress(UART_Type *base, uint8_t address1, uint8_t address2)

Set the UART slave address.

This function configures the address for UART module that works as slave in 9-bit data mode. One or two address fields can be configured. When the address field’s match enable bit is set, the frame it receices with MSB being 1 is considered as an address frame, otherwise it is considered as data frame. Once the address frame matches one of slave’s own addresses, this slave is addressed. This address frame and its following data frames are stored in the receive buffer, otherwise the frames will be discarded. To un-address a slave, just send an address frame with unmatched address.

Note

Any UART instance joined in the multi-slave system can work as slave. The position of the address mark is the same as the parity bit when parity is enabled for 8 bit and 9 bit data formats.

Parameters:
  • base – UART peripheral base address.

  • address1 – UART slave address 1.

  • address2 – UART slave address 2.

static inline void UART_EnableMatchAddress(UART_Type *base, bool match1, bool match2)

Enable the UART match address feature.

Parameters:
  • base – UART peripheral base address.

  • match1 – true to enable match address1, false to disable.

  • match2 – true to enable match address2, false to disable.

static inline void UART_Set9thTransmitBit(UART_Type *base)

Set UART 9th transmit bit.

Parameters:
  • base – UART peripheral base address.

static inline void UART_Clear9thTransmitBit(UART_Type *base)

Clear UART 9th transmit bit.

Parameters:
  • base – UART peripheral base address.

uint32_t UART_GetStatusFlags(UART_Type *base)

Gets UART status flags.

This function gets all UART status flags. The flags are returned as the logical OR value of the enumerators _uart_flags. To check a specific status, compare the return value with enumerators in _uart_flags. For example, to check whether the TX is empty, do the following.

if (kUART_TxDataRegEmptyFlag & UART_GetStatusFlags(UART1))
{
    ...
}

Parameters:
  • base – UART peripheral base address.

Returns:

UART status flags which are ORed by the enumerators in the _uart_flags.

status_t UART_ClearStatusFlags(UART_Type *base, uint32_t mask)

Clears status flags with the provided mask.

This function clears UART status flags with a provided mask. An automatically cleared flag can’t be cleared by this function. These flags can only be cleared or set by hardware. kUART_TxDataRegEmptyFlag, kUART_TransmissionCompleteFlag, kUART_RxDataRegFullFlag, kUART_RxActiveFlag, kUART_NoiseErrorInRxDataRegFlag, kUART_ParityErrorInRxDataRegFlag, kUART_TxFifoEmptyFlag,kUART_RxFifoEmptyFlag

Note

that this API should be called when the Tx/Rx is idle. Otherwise it has no effect.

Parameters:
  • base – UART peripheral base address.

  • mask – The status flags to be cleared; it is logical OR value of _uart_flags.

Return values:
  • kStatus_UART_FlagCannotClearManually – The flag can’t be cleared by this function but it is cleared automatically by hardware.

  • kStatus_Success – Status in the mask is cleared.

void UART_EnableInterrupts(UART_Type *base, uint32_t mask)

Enables UART interrupts according to the provided mask.

This function enables the UART interrupts according to the provided mask. The mask is a logical OR of enumeration members. See _uart_interrupt_enable. For example, to enable TX empty interrupt and RX full interrupt, do the following.

UART_EnableInterrupts(UART1,kUART_TxDataRegEmptyInterruptEnable | kUART_RxDataRegFullInterruptEnable);

Parameters:
  • base – UART peripheral base address.

  • mask – The interrupts to enable. Logical OR of _uart_interrupt_enable.

void UART_DisableInterrupts(UART_Type *base, uint32_t mask)

Disables the UART interrupts according to the provided mask.

This function disables the UART interrupts according to the provided mask. The mask is a logical OR of enumeration members. See _uart_interrupt_enable. For example, to disable TX empty interrupt and RX full interrupt do the following.

UART_DisableInterrupts(UART1,kUART_TxDataRegEmptyInterruptEnable | kUART_RxDataRegFullInterruptEnable);

Parameters:
  • base – UART peripheral base address.

  • mask – The interrupts to disable. Logical OR of _uart_interrupt_enable.

uint32_t UART_GetEnabledInterrupts(UART_Type *base)

Gets the enabled UART interrupts.

This function gets the enabled UART interrupts. The enabled interrupts are returned as the logical OR value of the enumerators _uart_interrupt_enable. To check a specific interrupts enable status, compare the return value with enumerators in _uart_interrupt_enable. For example, to check whether TX empty interrupt is enabled, do the following.

uint32_t enabledInterrupts = UART_GetEnabledInterrupts(UART1);

if (kUART_TxDataRegEmptyInterruptEnable & enabledInterrupts)
{
    ...
}

Parameters:
  • base – UART peripheral base address.

Returns:

UART interrupt flags which are logical OR of the enumerators in _uart_interrupt_enable.

static inline uint32_t UART_GetDataRegisterAddress(UART_Type *base)

Gets the UART data register address.

This function returns the UART data register address, which is mainly used by DMA/eDMA.

Parameters:
  • base – UART peripheral base address.

Returns:

UART data register addresses which are used both by the transmitter and the receiver.

static inline void UART_EnableTxDMA(UART_Type *base, bool enable)

Enables or disables the UART transmitter DMA request.

This function enables or disables the transmit data register empty flag, S1[TDRE], to generate the DMA requests.

Parameters:
  • base – UART peripheral base address.

  • enable – True to enable, false to disable.

static inline void UART_EnableRxDMA(UART_Type *base, bool enable)

Enables or disables the UART receiver DMA.

This function enables or disables the receiver data register full flag, S1[RDRF], to generate DMA requests.

Parameters:
  • base – UART peripheral base address.

  • enable – True to enable, false to disable.

static inline void UART_EnableTx(UART_Type *base, bool enable)

Enables or disables the UART transmitter.

This function enables or disables the UART transmitter.

Parameters:
  • base – UART peripheral base address.

  • enable – True to enable, false to disable.

static inline void UART_EnableRx(UART_Type *base, bool enable)

Enables or disables the UART receiver.

This function enables or disables the UART receiver.

Parameters:
  • base – UART peripheral base address.

  • enable – True to enable, false to disable.

static inline void UART_WriteByte(UART_Type *base, uint8_t data)

Writes to the TX register.

This function writes data to the TX register directly. The upper layer must ensure that the TX register is empty or TX FIFO has empty room before calling this function.

Parameters:
  • base – UART peripheral base address.

  • data – The byte to write.

static inline uint8_t UART_ReadByte(UART_Type *base)

Reads the RX register directly.

This function reads data from the RX register directly. The upper layer must ensure that the RX register is full or that the TX FIFO has data before calling this function.

Parameters:
  • base – UART peripheral base address.

Returns:

The byte read from UART data register.

static inline uint8_t UART_GetRxFifoCount(UART_Type *base)

Gets the rx FIFO data count.

Parameters:
  • base – UART peripheral base address.

Returns:

rx FIFO data count.

static inline uint8_t UART_GetTxFifoCount(UART_Type *base)

Gets the tx FIFO data count.

Parameters:
  • base – UART peripheral base address.

Returns:

tx FIFO data count.

void UART_SendAddress(UART_Type *base, uint8_t address)

Transmit an address frame in 9-bit data mode.

Parameters:
  • base – UART peripheral base address.

  • address – UART slave address.

status_t UART_WriteBlocking(UART_Type *base, const uint8_t *data, size_t length)

Writes to the TX register using a blocking method.

This function polls the TX register, waits for the TX register to be empty or for the TX FIFO to have room and writes data to the TX buffer.

Parameters:
  • base – UART peripheral base address.

  • data – Start address of the data to write.

  • length – Size of the data to write.

Return values:
  • kStatus_UART_Timeout – Transmission timed out and was aborted.

  • kStatus_Success – Successfully wrote all data.

status_t UART_ReadBlocking(UART_Type *base, uint8_t *data, size_t length)

Read RX data register using a blocking method.

This function polls the RX register, waits for the RX register to be full or for RX FIFO to have data, and reads data from the TX register.

Parameters:
  • base – UART peripheral base address.

  • data – Start address of the buffer to store the received data.

  • length – Size of the buffer.

Return values:
  • kStatus_UART_RxHardwareOverrun – Receiver overrun occurred while receiving data.

  • kStatus_UART_NoiseError – A noise error occurred while receiving data.

  • kStatus_UART_FramingError – A framing error occurred while receiving data.

  • kStatus_UART_ParityError – A parity error occurred while receiving data.

  • kStatus_UART_Timeout – Transmission timed out and was aborted.

  • kStatus_Success – Successfully received all data.

void UART_TransferCreateHandle(UART_Type *base, uart_handle_t *handle, uart_transfer_callback_t callback, void *userData)

Initializes the UART handle.

This function initializes the UART handle which can be used for other UART transactional APIs. Usually, for a specified UART instance, call this API once to get the initialized handle.

Parameters:
  • base – UART peripheral base address.

  • handle – UART handle pointer.

  • callback – The callback function.

  • userData – The parameter of the callback function.

void UART_TransferStartRingBuffer(UART_Type *base, uart_handle_t *handle, uint8_t *ringBuffer, size_t ringBufferSize)

Sets up the RX ring buffer.

This function sets up the RX ring buffer to a specific UART handle.

When the RX ring buffer is used, data received are stored into the ring buffer even when the user doesn’t call the UART_TransferReceiveNonBlocking() API. If data is already received in the ring buffer, the user can get the received data from the ring buffer directly.

Note

When using the RX ring buffer, one byte is reserved for internal use. In other words, if ringBufferSize is 32, only 31 bytes are used for saving data.

Parameters:
  • base – UART peripheral base address.

  • handle – UART handle pointer.

  • ringBuffer – Start address of the ring buffer for background receiving. Pass NULL to disable the ring buffer.

  • ringBufferSize – Size of the ring buffer.

void UART_TransferStopRingBuffer(UART_Type *base, uart_handle_t *handle)

Aborts the background transfer and uninstalls the ring buffer.

This function aborts the background transfer and uninstalls the ring buffer.

Parameters:
  • base – UART peripheral base address.

  • handle – UART handle pointer.

size_t UART_TransferGetRxRingBufferLength(uart_handle_t *handle)

Get the length of received data in RX ring buffer.

Parameters:
  • handle – UART handle pointer.

Returns:

Length of received data in RX ring buffer.

status_t UART_TransferSendNonBlocking(UART_Type *base, uart_handle_t *handle, uart_transfer_t *xfer)

Transmits a buffer of data using the interrupt method.

This function sends data using an interrupt method. This is a non-blocking function, which returns directly without waiting for all data to be written to the TX register. When all data is written to the TX register in the ISR, the UART driver calls the callback function and passes the kStatus_UART_TxIdle as status parameter.

Note

The kStatus_UART_TxIdle is passed to the upper layer when all data is written to the TX register. However, it does not ensure that all data is sent out. Before disabling the TX, check the kUART_TransmissionCompleteFlag to ensure that the TX is finished.

Parameters:
  • base – UART peripheral base address.

  • handle – UART handle pointer.

  • xfer – UART transfer structure. See uart_transfer_t.

Return values:
  • kStatus_Success – Successfully start the data transmission.

  • kStatus_UART_TxBusy – Previous transmission still not finished; data not all written to TX register yet.

  • kStatus_InvalidArgument – Invalid argument.

void UART_TransferAbortSend(UART_Type *base, uart_handle_t *handle)

Aborts the interrupt-driven data transmit.

This function aborts the interrupt-driven data sending. The user can get the remainBytes to find out how many bytes are not sent out.

Parameters:
  • base – UART peripheral base address.

  • handle – UART handle pointer.

status_t UART_TransferGetSendCount(UART_Type *base, uart_handle_t *handle, uint32_t *count)

Gets the number of bytes sent out to bus.

This function gets the number of bytes sent out to bus by using the interrupt method.

Parameters:
  • base – UART peripheral base address.

  • handle – UART handle pointer.

  • count – Send bytes count.

Return values:
  • kStatus_NoTransferInProgress – No send in progress.

  • kStatus_InvalidArgument – The parameter is invalid.

  • kStatus_Success – Get successfully through the parameter count;

status_t UART_TransferReceiveNonBlocking(UART_Type *base, uart_handle_t *handle, uart_transfer_t *xfer, size_t *receivedBytes)

Receives a buffer of data using an interrupt method.

This function receives data using an interrupt method. This is a non-blocking function, which returns without waiting for all data to be received. If the RX ring buffer is used and not empty, the data in the ring buffer is copied and the parameter receivedBytes shows how many bytes are copied from the ring buffer. After copying, if the data in the ring buffer is not enough to read, the receive request is saved by the UART driver. When the new data arrives, the receive request is serviced first. When all data is received, the UART driver notifies the upper layer through a callback function and passes the status parameter kStatus_UART_RxIdle. For example, the upper layer needs 10 bytes but there are only 5 bytes in the ring buffer. The 5 bytes are copied to the xfer->data and this function returns with the parameter receivedBytes set to 5. For the left 5 bytes, newly arrived data is saved from the xfer->data[5]. When 5 bytes are received, the UART driver notifies the upper layer. If the RX ring buffer is not enabled, this function enables the RX and RX interrupt to receive data to the xfer->data. When all data is received, the upper layer is notified.

Parameters:
  • base – UART peripheral base address.

  • handle – UART handle pointer.

  • xfer – UART transfer structure, see uart_transfer_t.

  • receivedBytes – Bytes received from the ring buffer directly.

Return values:
  • kStatus_Success – Successfully queue the transfer into transmit queue.

  • kStatus_UART_RxBusy – Previous receive request is not finished.

  • kStatus_InvalidArgument – Invalid argument.

void UART_TransferAbortReceive(UART_Type *base, uart_handle_t *handle)

Aborts the interrupt-driven data receiving.

This function aborts the interrupt-driven data receiving. The user can get the remainBytes to know how many bytes are not received yet.

Parameters:
  • base – UART peripheral base address.

  • handle – UART handle pointer.

status_t UART_TransferGetReceiveCount(UART_Type *base, uart_handle_t *handle, uint32_t *count)

Gets the number of bytes that have been received.

This function gets the number of bytes that have been received.

Parameters:
  • base – UART peripheral base address.

  • handle – UART handle pointer.

  • count – Receive bytes count.

Return values:
  • kStatus_NoTransferInProgress – No receive in progress.

  • kStatus_InvalidArgument – Parameter is invalid.

  • kStatus_Success – Get successfully through the parameter count;

status_t UART_EnableTxFIFO(UART_Type *base, bool enable)

Enables or disables the UART Tx FIFO.

This function enables or disables the UART Tx FIFO.

param base UART peripheral base address. param enable true to enable, false to disable. retval kStatus_Success Successfully turn on or turn off Tx FIFO. retval kStatus_Fail Fail to turn on or turn off Tx FIFO.

status_t UART_EnableRxFIFO(UART_Type *base, bool enable)

Enables or disables the UART Rx FIFO.

This function enables or disables the UART Rx FIFO.

param base UART peripheral base address. param enable true to enable, false to disable. retval kStatus_Success Successfully turn on or turn off Rx FIFO. retval kStatus_Fail Fail to turn on or turn off Rx FIFO.

static inline void UART_SetRxFifoWatermark(UART_Type *base, uint8_t water)

Sets the rx FIFO watermark.

Parameters:
  • base – UART peripheral base address.

  • water – Rx FIFO watermark.

static inline void UART_SetTxFifoWatermark(UART_Type *base, uint8_t water)

Sets the tx FIFO watermark.

Parameters:
  • base – UART peripheral base address.

  • water – Tx FIFO watermark.

void UART_TransferHandleIRQ(UART_Type *base, void *irqHandle)

UART IRQ handle function.

This function handles the UART transmit and receive IRQ request.

Parameters:
  • base – UART peripheral base address.

  • irqHandle – UART handle pointer.

void UART_TransferHandleErrorIRQ(UART_Type *base, void *irqHandle)

UART Error IRQ handle function.

This function handles the UART error IRQ request.

Parameters:
  • base – UART peripheral base address.

  • irqHandle – UART handle pointer.

FSL_UART_DRIVER_VERSION

UART driver version.

Error codes for the UART driver.

Values:

enumerator kStatus_UART_TxBusy

Transmitter is busy.

enumerator kStatus_UART_RxBusy

Receiver is busy.

enumerator kStatus_UART_TxIdle

UART transmitter is idle.

enumerator kStatus_UART_RxIdle

UART receiver is idle.

enumerator kStatus_UART_TxWatermarkTooLarge

TX FIFO watermark too large

enumerator kStatus_UART_RxWatermarkTooLarge

RX FIFO watermark too large

enumerator kStatus_UART_FlagCannotClearManually

UART flag can’t be manually cleared.

enumerator kStatus_UART_Error

Error happens on UART.

enumerator kStatus_UART_RxRingBufferOverrun

UART RX software ring buffer overrun.

enumerator kStatus_UART_RxHardwareOverrun

UART RX receiver overrun.

enumerator kStatus_UART_NoiseError

UART noise error.

enumerator kStatus_UART_FramingError

UART framing error.

enumerator kStatus_UART_ParityError

UART parity error.

enumerator kStatus_UART_BaudrateNotSupport

Baudrate is not support in current clock source

enumerator kStatus_UART_IdleLineDetected

UART IDLE line detected.

enumerator kStatus_UART_Timeout

UART times out.

enum _uart_parity_mode

UART parity mode.

Values:

enumerator kUART_ParityDisabled

Parity disabled

enumerator kUART_ParityEven

Parity enabled, type even, bit setting: PE|PT = 10

enumerator kUART_ParityOdd

Parity enabled, type odd, bit setting: PE|PT = 11

enum _uart_stop_bit_count

UART stop bit count.

Values:

enumerator kUART_OneStopBit

One stop bit

enumerator kUART_TwoStopBit

Two stop bits

enum _uart_idle_type_select

UART idle type select.

Values:

enumerator kUART_IdleTypeStartBit

Start counting after a valid start bit.

enumerator kUART_IdleTypeStopBit

Start counting after a stop bit.

enum _uart_interrupt_enable

UART interrupt configuration structure, default settings all disabled.

This structure contains the settings for all of the UART interrupt configurations.

Values:

enumerator kUART_LinBreakInterruptEnable

LIN break detect interrupt.

enumerator kUART_RxActiveEdgeInterruptEnable

RX active edge interrupt.

enumerator kUART_TxDataRegEmptyInterruptEnable

Transmit data register empty interrupt.

enumerator kUART_TransmissionCompleteInterruptEnable

Transmission complete interrupt.

enumerator kUART_RxDataRegFullInterruptEnable

Receiver data register full interrupt.

enumerator kUART_IdleLineInterruptEnable

Idle line interrupt.

enumerator kUART_RxOverrunInterruptEnable

Receiver overrun interrupt.

enumerator kUART_NoiseErrorInterruptEnable

Noise error flag interrupt.

enumerator kUART_FramingErrorInterruptEnable

Framing error flag interrupt.

enumerator kUART_ParityErrorInterruptEnable

Parity error flag interrupt.

enumerator kUART_RxFifoOverflowInterruptEnable

RX FIFO overflow interrupt.

enumerator kUART_TxFifoOverflowInterruptEnable

TX FIFO overflow interrupt.

enumerator kUART_RxFifoUnderflowInterruptEnable

RX FIFO underflow interrupt.

enumerator kUART_AllInterruptsEnable

UART status flags.

This provides constants for the UART status flags for use in the UART functions.

Values:

enumerator kUART_TxDataRegEmptyFlag

TX data register empty flag.

enumerator kUART_TransmissionCompleteFlag

Transmission complete flag.

enumerator kUART_RxDataRegFullFlag

RX data register full flag.

enumerator kUART_IdleLineFlag

Idle line detect flag.

enumerator kUART_RxOverrunFlag

RX overrun flag.

enumerator kUART_NoiseErrorFlag

RX takes 3 samples of each received bit. If any of these samples differ, noise flag sets

enumerator kUART_FramingErrorFlag

Frame error flag, sets if logic 0 was detected where stop bit expected

enumerator kUART_ParityErrorFlag

If parity enabled, sets upon parity error detection

enumerator kUART_LinBreakFlag

LIN break detect interrupt flag, sets when LIN break char detected and LIN circuit enabled

enumerator kUART_RxActiveEdgeFlag

RX pin active edge interrupt flag,sets when active edge detected

enumerator kUART_RxActiveFlag

Receiver Active Flag (RAF), sets at beginning of valid start bit

enumerator kUART_NoiseErrorInRxDataRegFlag

Noisy bit, sets if noise detected.

enumerator kUART_ParityErrorInRxDataRegFlag

Parity bit, sets if parity error detected.

enumerator kUART_TxFifoEmptyFlag

TXEMPT bit, sets if TX buffer is empty

enumerator kUART_RxFifoEmptyFlag

RXEMPT bit, sets if RX buffer is empty

enumerator kUART_TxFifoOverflowFlag

TXOF bit, sets if TX buffer overflow occurred

enumerator kUART_RxFifoOverflowFlag

RXOF bit, sets if receive buffer overflow

enumerator kUART_RxFifoUnderflowFlag

RXUF bit, sets if receive buffer underflow

typedef enum _uart_parity_mode uart_parity_mode_t

UART parity mode.

typedef enum _uart_stop_bit_count uart_stop_bit_count_t

UART stop bit count.

typedef enum _uart_idle_type_select uart_idle_type_select_t

UART idle type select.

typedef struct _uart_config uart_config_t

UART configuration structure.

typedef struct _uart_transfer uart_transfer_t

UART transfer structure.

typedef struct _uart_handle uart_handle_t
typedef void (*uart_transfer_callback_t)(UART_Type *base, uart_handle_t *handle, status_t status, void *userData)

UART transfer callback function.

typedef void (*uart_isr_t)(UART_Type *base, void *handle)
void *s_uartHandle[]

Pointers to uart handles for each instance.

const IRQn_Type s_uartIRQ[]
uart_isr_t s_uartIsr

Pointer to uart IRQ handler for each instance.

uint32_t UART_GetInstance(UART_Type *base)

Get the UART instance from peripheral base address.

Parameters:
  • base – UART peripheral base address.

Returns:

UART instance.

UART_RETRY_TIMES

Retry times for waiting flag.

struct _uart_config
#include <fsl_uart.h>

UART configuration structure.

Public Members

uint32_t baudRate_Bps

UART baud rate

uart_parity_mode_t parityMode

Parity mode, disabled (default), even, odd

uart_stop_bit_count_t stopBitCount

Number of stop bits, 1 stop bit (default) or 2 stop bits

uint8_t txFifoWatermark

TX FIFO watermark

uint8_t rxFifoWatermark

RX FIFO watermark

bool enableRxRTS

RX RTS enable

bool enableTxCTS

TX CTS enable

uart_idle_type_select_t idleType

IDLE type select.

bool enableTx

Enable TX

bool enableRx

Enable RX

struct _uart_transfer
#include <fsl_uart.h>

UART transfer structure.

Public Members

size_t dataSize

The byte count to be transfer.

struct _uart_handle
#include <fsl_uart.h>

UART handle structure.

Public Members

const uint8_t *volatile txData

Address of remaining data to send.

volatile size_t txDataSize

Size of the remaining data to send.

size_t txDataSizeAll

Size of the data to send out.

uint8_t *volatile rxData

Address of remaining data to receive.

volatile size_t rxDataSize

Size of the remaining data to receive.

size_t rxDataSizeAll

Size of the data to receive.

uint8_t *rxRingBuffer

Start address of the receiver ring buffer.

size_t rxRingBufferSize

Size of the ring buffer.

volatile uint16_t rxRingBufferHead

Index for the driver to store received data into ring buffer.

volatile uint16_t rxRingBufferTail

Index for the user to get data from the ring buffer.

uart_transfer_callback_t callback

Callback function.

void *userData

UART callback function parameter.

volatile uint8_t txState

TX transfer state.

volatile uint8_t rxState

RX transfer state

union __unnamed11__

Public Members

uint8_t *data

The buffer of data to be transfer.

uint8_t *rxData

The buffer to receive data.

const uint8_t *txData

The buffer of data to be sent.

WDOG8: 8-bit Watchdog Timer

void WDOG8_GetDefaultConfig(wdog8_config_t *config)

Initializes the WDOG8 configuration structure.

This function initializes the WDOG8 configuration structure to default values. The default values are:

wdog8Config->enableWdog8 = true;
wdog8Config->clockSource = kWDOG8_ClockSource1;
wdog8Config->prescaler = kWDOG8_ClockPrescalerDivide1;
wdog8Config->workMode.enableWait = true;
wdog8Config->workMode.enableStop = false;
wdog8Config->workMode.enableDebug = false;
wdog8Config->testMode = kWDOG8_TestModeDisabled;
wdog8Config->enableUpdate = true;
wdog8Config->enableInterrupt = false;
wdog8Config->enableWindowMode = false;
wdog8Config->windowValue = 0U;
wdog8Config->timeoutValue = 0xFFFFU;

See also

wdog8_config_t

Parameters:
  • config – Pointer to the WDOG8 configuration structure.

void WDOG8_Init(WDOG_Type *base, const wdog8_config_t *config)

Initializes the WDOG8 module.

This function initializes the WDOG8. To reconfigure the WDOG8 without forcing a reset first, enableUpdate must be set to true in the configuration.

Example:

wdog8_config_t config;
WDOG8_GetDefaultConfig(&config);
config.timeoutValue = 0x7ffU;
config.enableUpdate = true;
WDOG8_Init(wdog_base,&config);

Parameters:
  • base – WDOG8 peripheral base address.

  • config – The configuration of the WDOG8.

void WDOG8_Deinit(WDOG_Type *base)

De-initializes the WDOG8 module.

This function shuts down the WDOG8. Ensure that the WDOG_CS1.UPDATE is 1, which means that the register update is enabled.

Parameters:
  • base – WDOG8 peripheral base address.

static inline void WDOG8_Enable(WDOG_Type *base)

Enables the WDOG8 module.

This function writes a value into the WDOG_CS1 register to enable the WDOG8. The WDOG_CS1 register is a write-once register. Ensure that the WCT window is still open and this register has not been written in this WCT while the function is called.

Parameters:
  • base – WDOG8 peripheral base address.

static inline void WDOG8_Disable(WDOG_Type *base)

Disables the WDOG8 module.

This function writes a value into the WDOG_CS1 register to disable the WDOG8. The WDOG_CS1 register is a write-once register. Ensure that the WCT window is still open and this register has not been written in this WCT while the function is called.

Parameters:
  • base – WDOG8 peripheral base address

static inline void WDOG8_EnableInterrupts(WDOG_Type *base, uint8_t mask)

Enables the WDOG8 interrupt.

This function writes a value into the WDOG_CS1 register to enable the WDOG8 interrupt. The WDOG_CS1 register is a write-once register. Ensure that the WCT window is still open and this register has not been written in this WCT while the function is called.

Parameters:
  • base – WDOG8 peripheral base address.

  • mask – The interrupts to enable. The parameter can be a combination of the following source if defined:

    • kWDOG8_InterruptEnable

static inline void WDOG8_DisableInterrupts(WDOG_Type *base, uint8_t mask)

Disables the WDOG8 interrupt.

This function writes a value into the WDOG_CS register to disable the WDOG8 interrupt. The WDOG_CS register is a write-once register. Ensure that the WCT window is still open and this register has not been written in this WCT while the function is called.

Parameters:
  • base – WDOG8 peripheral base address.

  • mask – The interrupts to disabled. The parameter can be a combination of the following source if defined:

    • kWDOG8_InterruptEnable

static inline uint8_t WDOG8_GetStatusFlags(WDOG_Type *base)

Gets the WDOG8 all status flags.

This function gets all status flags.

Example to get the running flag:

uint32_t status;
status = WDOG8_GetStatusFlags(wdog_base) & kWDOG8_RunningFlag;

See also

_wdog8_status_flags_t

  • true: related status flag has been set.

  • false: related status flag is not set.

Parameters:
  • base – WDOG8 peripheral base address

Returns:

State of the status flag: asserted (true) or not-asserted (false).

void WDOG8_ClearStatusFlags(WDOG_Type *base, uint8_t mask)

Clears the WDOG8 flag.

This function clears the WDOG8 status flag.

Example to clear an interrupt flag:

WDOG8_ClearStatusFlags(wdog_base,kWDOG8_InterruptFlag);

Parameters:
  • base – WDOG8 peripheral base address.

  • mask – The status flags to clear. The parameter can be any combination of the following values:

    • kWDOG8_InterruptFlag

static inline void WDOG8_SetTimeoutValue(WDOG_Type *base, uint16_t timeoutCount)

Sets the WDOG8 timeout value.

This function writes a timeout value into the WDOG_TOVALH/L register. The WDOG_TOVALH/L register is a write-once register. Ensure that the WCT window is still open and this register has not been written in this WCT while the function is called.

Parameters:
  • base – WDOG8 peripheral base address

  • timeoutCount – WDOG8 timeout value, count of WDOG8 clock ticks.

static inline void WDOG8_SetWindowValue(WDOG_Type *base, uint16_t windowValue)

Sets the WDOG8 window value.

This function writes a window value into the WDOG_WINH/L register. The WDOG_WINH/L register is a write-once register. Ensure that the WCT window is still open and this register has not been written in this WCT while the function is called.

Parameters:
  • base – WDOG8 peripheral base address.

  • windowValue – WDOG8 window value.

static inline void WDOG8_Unlock(WDOG_Type *base)

Unlocks the WDOG8 register written.

This function unlocks the WDOG8 register written.

Before starting the unlock sequence and following the configuration, disable the global interrupts. Otherwise, an interrupt could effectively invalidate the unlock sequence and the WCT may expire. After the configuration finishes, re-enable the global interrupts.

Parameters:
  • base – WDOG8 peripheral base address

static inline void WDOG8_Refresh(WDOG_Type *base)

Refreshes the WDOG8 timer.

This function feeds the WDOG8. This function should be called before the Watchdog timer is in timeout. Otherwise, a reset is asserted.

Parameters:
  • base – WDOG8 peripheral base address

static inline uint16_t WDOG8_GetCounterValue(WDOG_Type *base)

Gets the WDOG8 counter value.

This function gets the WDOG8 counter value.

Parameters:
  • base – WDOG8 peripheral base address.

Returns:

Current WDOG8 counter value.