mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2026-09-21 22:54:14 +08:00
bsps/imxrt: Adapt to new mcux-sdk version
Remove the old NXP MCUXpresso SDK and adapt the BSP so that it uses the new mcux-sdk.
This commit is contained in:
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -83,6 +83,7 @@ uint32_t imxrt_systick_frequency(void);
|
||||
void imxrt_lpspi_init(void);
|
||||
void imxrt_lpi2c_init(void);
|
||||
void imxrt_ffec_init(void);
|
||||
void BOARD_InitDEBUG_UARTPins(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
#include "MIMXRT1052.h"
|
||||
#include "MIMXRT1052_features.h"
|
||||
#include <fsl_device_registers.h>
|
||||
|
||||
@@ -1,427 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016-2020 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#ifndef _FSL_ADC_H_
|
||||
#define _FSL_ADC_H_
|
||||
|
||||
#include "fsl_common.h"
|
||||
|
||||
/*!
|
||||
* @addtogroup adc_12b1msps_sar
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
/*! @brief ADC driver version */
|
||||
#define FSL_ADC_DRIVER_VERSION (MAKE_VERSION(2, 0, 3)) /*!< Version 2.0.3. */
|
||||
|
||||
/*!
|
||||
* @brief Converter's status flags.
|
||||
*/
|
||||
typedef enum _adc_status_flags
|
||||
{
|
||||
kADC_ConversionActiveFlag = ADC_GS_ADACT_MASK, /*!< Conversion is active,not support w1c. */
|
||||
kADC_CalibrationFailedFlag = ADC_GS_CALF_MASK, /*!< Calibration is failed,support w1c. */
|
||||
kADC_AsynchronousWakeupInterruptFlag =
|
||||
ADC_GS_AWKST_MASK, /*!< Asynchronous wakeup interrupt occurred, support w1c. */
|
||||
} adc_status_flags_t;
|
||||
|
||||
/*!
|
||||
* @brief Reference voltage source.
|
||||
*/
|
||||
typedef enum _adc_reference_voltage_source
|
||||
{
|
||||
kADC_ReferenceVoltageSourceAlt0 = 0U, /*!< For external pins pair of VrefH and VrefL. */
|
||||
} adc_reference_voltage_source_t;
|
||||
|
||||
/*!
|
||||
* @brief Sample time duration.
|
||||
*/
|
||||
typedef enum _adc_sample_period_mode
|
||||
{
|
||||
/* This group of enumeration is for internal use which is related to register setting. */
|
||||
kADC_SamplePeriod2or12Clocks = 0U, /*!< Long sample 12 clocks or short sample 2 clocks. */
|
||||
kADC_SamplePeriod4or16Clocks = 1U, /*!< Long sample 16 clocks or short sample 4 clocks. */
|
||||
kADC_SamplePeriod6or20Clocks = 2U, /*!< Long sample 20 clocks or short sample 6 clocks. */
|
||||
kADC_SamplePeriod8or24Clocks = 3U, /*!< Long sample 24 clocks or short sample 8 clocks. */
|
||||
/* This group of enumeration is for a public user. */
|
||||
/* For long sample mode. */
|
||||
kADC_SamplePeriodLong12Clcoks = kADC_SamplePeriod2or12Clocks, /*!< Long sample 12 clocks. */
|
||||
kADC_SamplePeriodLong16Clcoks = kADC_SamplePeriod4or16Clocks, /*!< Long sample 16 clocks. */
|
||||
kADC_SamplePeriodLong20Clcoks = kADC_SamplePeriod6or20Clocks, /*!< Long sample 20 clocks. */
|
||||
kADC_SamplePeriodLong24Clcoks = kADC_SamplePeriod8or24Clocks, /*!< Long sample 24 clocks. */
|
||||
/* For short sample mode. */
|
||||
kADC_SamplePeriodShort2Clocks = kADC_SamplePeriod2or12Clocks, /*!< Short sample 2 clocks. */
|
||||
kADC_SamplePeriodShort4Clocks = kADC_SamplePeriod4or16Clocks, /*!< Short sample 4 clocks. */
|
||||
kADC_SamplePeriodShort6Clocks = kADC_SamplePeriod6or20Clocks, /*!< Short sample 6 clocks. */
|
||||
kADC_SamplePeriodShort8Clocks = kADC_SamplePeriod8or24Clocks, /*!< Short sample 8 clocks. */
|
||||
} adc_sample_period_mode_t;
|
||||
|
||||
/*!
|
||||
* @brief Clock source.
|
||||
*/
|
||||
typedef enum _adc_clock_source
|
||||
{
|
||||
kADC_ClockSourceIPG = 0U, /*!< Select IPG clock to generate ADCK. */
|
||||
kADC_ClockSourceIPGDiv2 = 1U, /*!< Select IPG clock divided by 2 to generate ADCK. */
|
||||
#if !(defined(FSL_FEATURE_ADC_SUPPORT_ALTCLK_REMOVE) && FSL_FEATURE_ADC_SUPPORT_ALTCLK_REMOVE)
|
||||
kADC_ClockSourceALT = 2U, /*!< Select alternate clock to generate ADCK. */
|
||||
#endif
|
||||
kADC_ClockSourceAD = 3U, /*!< Select Asynchronous clock to generate ADCK. */
|
||||
} adc_clock_source_t;
|
||||
|
||||
/*!
|
||||
* @brief Clock divider for the converter.
|
||||
*/
|
||||
typedef enum _adc_clock_drvier
|
||||
{
|
||||
kADC_ClockDriver1 = 0U, /*!< For divider 1 from the input clock to the module. */
|
||||
kADC_ClockDriver2 = 1U, /*!< For divider 2 from the input clock to the module. */
|
||||
kADC_ClockDriver4 = 2U, /*!< For divider 4 from the input clock to the module. */
|
||||
kADC_ClockDriver8 = 3U, /*!< For divider 8 from the input clock to the module. */
|
||||
} adc_clock_driver_t;
|
||||
|
||||
/*!
|
||||
* @brief Converter's resolution.
|
||||
*/
|
||||
typedef enum _adc_resolution
|
||||
{
|
||||
kADC_Resolution8Bit = 0U, /*!< Single End 8-bit resolution. */
|
||||
kADC_Resolution10Bit = 1U, /*!< Single End 10-bit resolution. */
|
||||
kADC_Resolution12Bit = 2U, /*!< Single End 12-bit resolution. */
|
||||
} adc_resolution_t;
|
||||
|
||||
/*!
|
||||
* @brief Converter hardware compare mode.
|
||||
*/
|
||||
typedef enum _adc_hardware_compare_mode
|
||||
{
|
||||
kADC_HardwareCompareMode0 = 0U, /*!< Compare true if the result is less than the value1. */
|
||||
kADC_HardwareCompareMode1 = 1U, /*!< Compare true if the result is greater than or equal to value1. */
|
||||
kADC_HardwareCompareMode2 = 2U, /*!< Value1 <= Value2, compare true if the result is less than value1 Or
|
||||
the result is Greater than value2.
|
||||
Value1 > Value2, compare true if the result is less than value1 And the
|
||||
result is greater than value2*/
|
||||
kADC_HardwareCompareMode3 = 3U, /*!< Value1 <= Value2, compare true if the result is greater than or equal
|
||||
to value1 And the result is less than or equal to value2.
|
||||
Value1 > Value2, compare true if the result is greater than or equal to
|
||||
value1 Or the result is less than or equal to value2. */
|
||||
} adc_hardware_compare_mode_t;
|
||||
|
||||
/*!
|
||||
* @brief Converter hardware average mode.
|
||||
*/
|
||||
typedef enum _adc_hardware_average_mode
|
||||
{
|
||||
kADC_HardwareAverageCount4 = 0U, /*!< For hardware average with 4 samples. */
|
||||
kADC_HardwareAverageCount8 = 1U, /*!< For hardware average with 8 samples. */
|
||||
kADC_HardwareAverageCount16 = 2U, /*!< For hardware average with 16 samples. */
|
||||
kADC_HardwareAverageCount32 = 3U, /*!< For hardware average with 32 samples. */
|
||||
kADC_HardwareAverageDiasable = 4U, /*!< Disable the hardware average function. */
|
||||
} adc_hardware_average_mode_t;
|
||||
|
||||
/*!
|
||||
* @brief Converter configuration.
|
||||
*/
|
||||
typedef struct _adc_config
|
||||
{
|
||||
bool enableOverWrite; /*!< Enable the overwriting. */
|
||||
bool enableContinuousConversion; /*!< Enable the continuous conversion mode. */
|
||||
bool enableHighSpeed; /*!< Enable the high-speed mode. */
|
||||
bool enableLowPower; /*!< Enable the low power mode. */
|
||||
bool enableLongSample; /*!< Enable the long sample mode. */
|
||||
bool enableAsynchronousClockOutput; /*!< Enable the asynchronous clock output. */
|
||||
adc_reference_voltage_source_t referenceVoltageSource; /*!< Select the reference voltage source. */
|
||||
adc_sample_period_mode_t samplePeriodMode; /*!< Select the sample period in long sample mode or short mode. */
|
||||
adc_clock_source_t clockSource; /*!< Select the input clock source to generate the internal clock ADCK. */
|
||||
adc_clock_driver_t clockDriver; /*!< Select the divide ratio used by the ADC to generate the internal clock ADCK. */
|
||||
adc_resolution_t resolution; /*!< Select the ADC resolution mode. */
|
||||
} adc_config_t;
|
||||
|
||||
/*!
|
||||
* @brief Converter Offset configuration.
|
||||
*/
|
||||
typedef struct _adc_offest_config
|
||||
{
|
||||
bool enableSigned; /*!< if false,The offset value is added with the raw result.
|
||||
if true,The offset value is subtracted from the raw converted value. */
|
||||
uint32_t offsetValue; /*!< User configurable offset value(0-4095). */
|
||||
} adc_offest_config_t;
|
||||
|
||||
/*!
|
||||
* @brief ADC hardware compare configuration.
|
||||
*
|
||||
* In kADC_HardwareCompareMode0, compare true if the result is less than the value1.
|
||||
* In kADC_HardwareCompareMode1, compare true if the result is greater than or equal to value1.
|
||||
* In kADC_HardwareCompareMode2, Value1 <= Value2, compare true if the result is less than value1 Or the result is
|
||||
* Greater than value2.
|
||||
* Value1 > Value2, compare true if the result is less than value1 And the result is
|
||||
* Greater than value2.
|
||||
* In kADC_HardwareCompareMode3, Value1 <= Value2, compare true if the result is greater than or equal to value1 And the
|
||||
* result is less than or equal to value2.
|
||||
* Value1 > Value2, compare true if the result is greater than or equal to value1 Or the
|
||||
* result is less than or equal to value2.
|
||||
*/
|
||||
typedef struct _adc_hardware_compare_config
|
||||
{
|
||||
adc_hardware_compare_mode_t hardwareCompareMode; /*!< Select the hardware compare mode.
|
||||
See "adc_hardware_compare_mode_t". */
|
||||
uint16_t value1; /*!< Setting value1(0-4095) for hardware compare mode. */
|
||||
uint16_t value2; /*!< Setting value2(0-4095) for hardware compare mode. */
|
||||
} adc_hardware_compare_config_t;
|
||||
|
||||
/*!
|
||||
* @brief ADC channel conversion configuration.
|
||||
*/
|
||||
typedef struct _adc_channel_config
|
||||
{
|
||||
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 enableInterruptOnConversionCompleted; /*!< Generate an interrupt request once the conversion is completed. */
|
||||
} adc_channel_config_t;
|
||||
/*******************************************************************************
|
||||
* API
|
||||
******************************************************************************/
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* @name Initialization
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @brief Initialize the ADC module.
|
||||
*
|
||||
* @param base ADC peripheral base address.
|
||||
* @param config Pointer to "adc_config_t" structure.
|
||||
*/
|
||||
void ADC_Init(ADC_Type *base, const adc_config_t *config);
|
||||
|
||||
/*!
|
||||
* @brief De-initializes the ADC module.
|
||||
*
|
||||
* @param base ADC peripheral base address.
|
||||
*/
|
||||
void ADC_Deinit(ADC_Type *base);
|
||||
|
||||
/*!
|
||||
* @brief 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:
|
||||
* @code
|
||||
* config->enableAsynchronousClockOutput = true;
|
||||
* config->enableOverWrite = false;
|
||||
* config->enableContinuousConversion = false;
|
||||
* config->enableHighSpeed = false;
|
||||
* config->enableLowPower = false;
|
||||
* config->enableLongSample = false;
|
||||
* config->referenceVoltageSource = kADC_ReferenceVoltageSourceAlt0;
|
||||
* config->samplePeriodMode = kADC_SamplePeriod2or12Clocks;
|
||||
* config->clockSource = kADC_ClockSourceAD;
|
||||
* config->clockDriver = kADC_ClockDriver1;
|
||||
* config->resolution = kADC_Resolution12Bit;
|
||||
* @endcode
|
||||
* @param config Pointer to the configuration structure.
|
||||
*/
|
||||
void ADC_GetDefaultConfig(adc_config_t *config);
|
||||
|
||||
/*!
|
||||
* @brief 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.
|
||||
*
|
||||
* Note that the "Channel Group" has a detailed description.
|
||||
* To allow sequential conversions of the ADC to be triggered by internal peripherals, the ADC has more than one
|
||||
* group of status and control registers, one for each conversion. The channel group parameter indicates which group of
|
||||
* registers are used, for example channel group 0 is for Group A registers and channel group 1 is for Group B
|
||||
* registers. The
|
||||
* channel groups are used in a "ping-pong" approach to control the ADC operation. At any point, only one of
|
||||
* the channel groups is actively controlling ADC conversions. The channel group 0 is used for both software and
|
||||
* hardware
|
||||
* trigger modes. Channel groups 1 and greater indicate potentially multiple channel group registers for
|
||||
* use only in hardware trigger mode. See the chip configuration information in the appropriate MCU reference manual
|
||||
* about the
|
||||
* number of SC1n registers (channel groups) specific to this device. None of the channel groups 1 or greater are used
|
||||
* for software trigger operation. Therefore, writing to these channel groups does not initiate a new conversion.
|
||||
* Updating the channel group 0 while a different channel group is actively controlling a conversion is allowed and
|
||||
* vice versa. Writing any of the channel group registers while that specific channel group is actively controlling a
|
||||
* conversion aborts the current conversion.
|
||||
*
|
||||
* @param base ADC peripheral base address.
|
||||
* @param channelGroup Channel group index.
|
||||
* @param config Pointer to the "adc_channel_config_t" structure for the conversion channel.
|
||||
*/
|
||||
void ADC_SetChannelConfig(ADC_Type *base, uint32_t channelGroup, const adc_channel_config_t *config);
|
||||
|
||||
/*!
|
||||
* @brief Gets the conversion value.
|
||||
*
|
||||
* @param base ADC peripheral base address.
|
||||
* @param channelGroup Channel group index.
|
||||
*
|
||||
* @return Conversion value.
|
||||
*/
|
||||
static inline uint32_t ADC_GetChannelConversionValue(ADC_Type *base, uint32_t channelGroup)
|
||||
{
|
||||
assert(channelGroup < FSL_FEATURE_ADC_CONVERSION_CONTROL_COUNT);
|
||||
|
||||
return base->R[channelGroup];
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Gets the status flags of channel.
|
||||
*
|
||||
* A conversion is completed when the result of the conversion is transferred into the data
|
||||
* result registers. (provided the compare function & hardware averaging is disabled), this is
|
||||
* indicated by the setting of COCOn. If hardware averaging is enabled, COCOn sets only,
|
||||
* if the last of the selected number of conversions is complete. If the compare function is
|
||||
* enabled, COCOn sets and conversion result data is transferred only if the compare
|
||||
* condition is true. If both hardware averaging and compare functions are enabled, then
|
||||
* COCOn sets only if the last of the selected number of conversions is complete and the
|
||||
* compare condition is true.
|
||||
*
|
||||
* @param base ADC peripheral base address.
|
||||
* @param channelGroup Channel group index.
|
||||
*
|
||||
* @return Status flags of channel.return 0 means COCO flag is 0,return 1 means COCOflag is 1.
|
||||
*/
|
||||
static inline uint32_t ADC_GetChannelStatusFlags(ADC_Type *base, uint32_t channelGroup)
|
||||
{
|
||||
assert(channelGroup < FSL_FEATURE_ADC_CONVERSION_CONTROL_COUNT);
|
||||
|
||||
/* If flag is set,return 1,otherwise, return 0. */
|
||||
return (((base->HS) & (1UL << channelGroup)) >> channelGroup);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Automates the hardware calibration.
|
||||
*
|
||||
* This auto calibration helps to adjust the plus/minus side gain automatically.
|
||||
* Execute the calibration before using the converter. Note that the software trigger should be used
|
||||
* during calibration.
|
||||
*
|
||||
* @param base ADC peripheral base address.
|
||||
*
|
||||
* @return Execution status.
|
||||
* @retval kStatus_Success Calibration is done successfully.
|
||||
* @retval kStatus_Fail Calibration has failed.
|
||||
*/
|
||||
status_t ADC_DoAutoCalibration(ADC_Type *base);
|
||||
|
||||
/*!
|
||||
* @brief Set user defined offset.
|
||||
*
|
||||
* @param base ADC peripheral base address.
|
||||
* @param config Pointer to "adc_offest_config_t" structure.
|
||||
*/
|
||||
void ADC_SetOffsetConfig(ADC_Type *base, const adc_offest_config_t *config);
|
||||
|
||||
/*!
|
||||
* @brief Enables generating the DMA trigger when the conversion is complete.
|
||||
*
|
||||
* @param base ADC peripheral base address.
|
||||
* @param enable Switcher of the DMA feature. "true" means enabled, "false" means not enabled.
|
||||
*/
|
||||
static inline void ADC_EnableDMA(ADC_Type *base, bool enable)
|
||||
{
|
||||
if (enable)
|
||||
{
|
||||
base->GC |= ADC_GC_DMAEN_MASK;
|
||||
}
|
||||
else
|
||||
{
|
||||
base->GC &= ~ADC_GC_DMAEN_MASK;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Enables the hardware trigger mode.
|
||||
*
|
||||
* @param base ADC peripheral base address.
|
||||
* @param enable Switcher of the trigger mode. "true" means hardware tirgger mode,"false" means software mode.
|
||||
*/
|
||||
#if !(defined(FSL_FEATURE_ADC_SUPPORT_HARDWARE_TRIGGER_REMOVE) && FSL_FEATURE_ADC_SUPPORT_HARDWARE_TRIGGER_REMOVE)
|
||||
static inline void ADC_EnableHardwareTrigger(ADC_Type *base, bool enable)
|
||||
{
|
||||
if (enable)
|
||||
{
|
||||
base->CFG |= ADC_CFG_ADTRG_MASK;
|
||||
}
|
||||
else
|
||||
{
|
||||
base->CFG &= ~ADC_CFG_ADTRG_MASK;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* @brief Configures the hardware compare mode.
|
||||
*
|
||||
* The hardware compare mode provides a way to process the conversion result automatically by using hardware. Only the
|
||||
* result
|
||||
* in the compare range is available. To compare the range, see "adc_hardware_compare_mode_t" or the appopriate
|
||||
* reference
|
||||
* manual for more information.
|
||||
*
|
||||
* @param base ADC peripheral base address.
|
||||
* @param config Pointer to "adc_hardware_compare_config_t" structure.
|
||||
*
|
||||
*/
|
||||
void ADC_SetHardwareCompareConfig(ADC_Type *base, const adc_hardware_compare_config_t *config);
|
||||
|
||||
/*!
|
||||
* @brief Configures the hardware average mode.
|
||||
*
|
||||
* The hardware average mode provides a way to process the conversion result automatically by using hardware. The
|
||||
* multiple
|
||||
* conversion results are accumulated and averaged internally making them easier to read.
|
||||
*
|
||||
* @param base ADC peripheral base address.
|
||||
* @param mode Setting the hardware average mode. See "adc_hardware_average_mode_t".
|
||||
*/
|
||||
void ADC_SetHardwareAverageConfig(ADC_Type *base, adc_hardware_average_mode_t mode);
|
||||
|
||||
/*!
|
||||
* @brief Gets the converter's status flags.
|
||||
*
|
||||
* @param base ADC peripheral base address.
|
||||
*
|
||||
* @return Flags' mask if indicated flags are asserted. See "adc_status_flags_t".
|
||||
*/
|
||||
static inline uint32_t ADC_GetStatusFlags(ADC_Type *base)
|
||||
{
|
||||
return base->GS;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Clears the converter's status falgs.
|
||||
*
|
||||
* @param base ADC peripheral base address.
|
||||
* @param mask Mask value for the cleared flags. See "adc_status_flags_t".
|
||||
*/
|
||||
void ADC_ClearStatusFlags(ADC_Type *base, uint32_t mask);
|
||||
|
||||
/*!
|
||||
*@}
|
||||
*/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
/*!
|
||||
*@}
|
||||
*/
|
||||
|
||||
#endif /* _FSL_ADC_H_ */
|
||||
@@ -1,336 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016-2020 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#ifndef _FSL_ADC_ETC_H_
|
||||
#define _FSL_ADC_ETC_H_
|
||||
|
||||
#include "fsl_common.h"
|
||||
|
||||
/*!
|
||||
* @addtogroup adc_etc
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
/*! @brief ADC_ETC driver version */
|
||||
#define FSL_ADC_ETC_DRIVER_VERSION (MAKE_VERSION(2, 1, 0)) /*!< Version 2.1.0. */
|
||||
/*! @brief The mask of status flags cleared by writing 1. */
|
||||
#define ADC_ETC_DMA_CTRL_TRGn_REQ_MASK 0xFF0000U
|
||||
|
||||
/*!
|
||||
* @brief ADC_ETC customized status flags mask.
|
||||
*/
|
||||
enum _adc_etc_status_flag_mask
|
||||
{
|
||||
kADC_ETC_Done0StatusFlagMask = 1U << 0U,
|
||||
kADC_ETC_Done1StatusFlagMask = 1U << 1U,
|
||||
kADC_ETC_Done2StatusFlagMask = 1U << 2U,
|
||||
#if defined(FSL_FEATURE_ADC_ETC_HAS_TRIGm_CHAIN_a_b_IEn_EN) && FSL_FEATURE_ADC_ETC_HAS_TRIGm_CHAIN_a_b_IEn_EN
|
||||
kADC_ETC_Done3StatusFlagMask = 1U << 3U,
|
||||
kADC_ETC_ErrorStatusFlagMask = 1U << 4U,
|
||||
#else
|
||||
kADC_ETC_ErrorStatusFlagMask = 1U << 3U,
|
||||
#endif /* FSL_FEATURE_ADC_ETC_HAS_TRIGm_CHAIN_a_b_IEn_EN */
|
||||
};
|
||||
|
||||
/*!
|
||||
* @brief External triggers sources.
|
||||
*/
|
||||
typedef enum _adc_etc_external_trigger_source
|
||||
{
|
||||
/* External XBAR sources. Support HW or SW mode. */
|
||||
kADC_ETC_Trg0TriggerSource = 0U, /* External XBAR trigger0 source. */
|
||||
kADC_ETC_Trg1TriggerSource = 1U, /* External XBAR trigger1 source. */
|
||||
kADC_ETC_Trg2TriggerSource = 2U, /* External XBAR trigger2 source. */
|
||||
kADC_ETC_Trg3TriggerSource = 3U, /* External XBAR trigger3 source. */
|
||||
kADC_ETC_Trg4TriggerSource = 4U, /* External XBAR trigger4 source. */
|
||||
kADC_ETC_Trg5TriggerSource = 5U, /* External XBAR trigger5 source. */
|
||||
kADC_ETC_Trg6TriggerSource = 6U, /* External XBAR trigger6 source. */
|
||||
kADC_ETC_Trg7TriggerSource = 7U, /* External XBAR trigger7 source. */
|
||||
/* External TSC sources. Only support HW mode. */
|
||||
kADC_ETC_TSC0TriggerSource = 8U, /* External TSC trigger0 source. */
|
||||
kADC_ETC_TSC1TriggerSource = 9U, /* External TSC trigger1 source. */
|
||||
} adc_etc_external_trigger_source_t;
|
||||
|
||||
/*!
|
||||
* @brief Interrupt enable/disable mask.
|
||||
*/
|
||||
typedef enum _adc_etc_interrupt_enable
|
||||
{
|
||||
#if defined(FSL_FEATURE_ADC_ETC_HAS_TRIGm_CHAIN_a_b_IEn_EN) && FSL_FEATURE_ADC_ETC_HAS_TRIGm_CHAIN_a_b_IEn_EN
|
||||
kADC_ETC_Done0InterruptEnable = 0U, /* Enable the DONE0 interrupt when ADC conversions complete. */
|
||||
kADC_ETC_Done1InterruptEnable = 1U, /* Enable the DONE1 interrupt when ADC conversions complete. */
|
||||
kADC_ETC_Done2InterruptEnable = 2U, /* Enable the DONE2 interrupt when ADC conversions complete. */
|
||||
kADC_ETC_Done3InterruptEnable = 3U, /* Enable the DONE3 interrupt when ADC conversions complete. */
|
||||
#else
|
||||
kADC_ETC_InterruptDisable = 0U, /* Disable the ADC_ETC interrupt. */
|
||||
kADC_ETC_Done0InterruptEnable = 1U, /* Enable the DONE0 interrupt when ADC conversions complete. */
|
||||
kADC_ETC_Done1InterruptEnable = 2U, /* Enable the DONE1 interrupt when ADC conversions complete. */
|
||||
kADC_ETC_Done2InterruptEnable = 3U, /* Enable the DONE2 interrupt when ADC conversions complete. */
|
||||
#endif /* FSL_FEATURE_ADC_ETC_HAS_TRIGm_CHAIN_a_b_IEn_EN */
|
||||
} adc_etc_interrupt_enable_t;
|
||||
|
||||
#if defined(FSL_FEATURE_ADC_ETC_HAS_CTRL_DMA_MODE_SEL) && FSL_FEATURE_ADC_ETC_HAS_CTRL_DMA_MODE_SEL
|
||||
/*!
|
||||
* @brief DMA mode selection.
|
||||
*/
|
||||
typedef enum _adc_etc_dma_mode_selection
|
||||
{
|
||||
kADC_ETC_TrigDMAWithLatchedSignal =
|
||||
0U, /* Trig DMA_REQ with latched signal, REQ will be cleared when ACK and source request cleared. */
|
||||
kADC_ETC_TrigDMAWithPulsedSignal = 1U, /* Trig DMA_REQ with pulsed signal, REQ will be cleared by ACK only. */
|
||||
} adc_etc_dma_mode_selection_t;
|
||||
#endif /*FSL_FEATURE_ADC_ETC_HAS_CTRL_DMA_MODE_SEL*/
|
||||
|
||||
/*!
|
||||
* @brief ADC_ETC configuration.
|
||||
*/
|
||||
typedef struct _adc_etc_config
|
||||
{
|
||||
bool enableTSCBypass; /* If bypass TSC, TSC would trigger ADC directly.
|
||||
Otherwise TSC would trigger ADC through ADC_ETC. */
|
||||
bool enableTSC0Trigger; /* Enable external TSC0 trigger. It is valid when enableTSCBypass = false. */
|
||||
bool enableTSC1Trigger; /* Enable external TSC1 trigger. It is valid when enableTSCBypass = false.*/
|
||||
#if defined(FSL_FEATURE_ADC_ETC_HAS_CTRL_DMA_MODE_SEL) && FSL_FEATURE_ADC_ETC_HAS_CTRL_DMA_MODE_SEL
|
||||
adc_etc_dma_mode_selection_t dmaMode; /* Select the ADC_ETC DMA mode. */
|
||||
#endif /*FSL_FEATURE_ADC_ETC_HAS_CTRL_DMA_MODE_SEL*/
|
||||
uint32_t TSC0triggerPriority; /* External TSC0 trigger priority, 7 is highest, 0 is lowest. */
|
||||
uint32_t TSC1triggerPriority; /* External TSC1 trigger priority, 7 is highest, 0 is lowest. */
|
||||
uint32_t clockPreDivider; /* Pre-divider for trig delay and interval. Available range is 0-255.
|
||||
Clock would be divided by (clockPreDivider+1). */
|
||||
uint32_t XBARtriggerMask; /* Enable the corresponding trigger source. Available range is trigger0:0x01 to
|
||||
trigger7:0x80
|
||||
For example, XBARtriggerMask = 0x7U, which means trigger0, trigger1 and trigger2 is
|
||||
enabled. */
|
||||
} adc_etc_config_t;
|
||||
|
||||
/*!
|
||||
* @brief ADC_ETC trigger chain configuration.
|
||||
*/
|
||||
typedef struct _adc_etc_trigger_chain_config
|
||||
{
|
||||
bool enableB2BMode; /* Enable ADC_ETC BackToBack mode. when not enabled B2B mode,
|
||||
wait until interval delay is reached. */
|
||||
uint32_t ADCHCRegisterSelect; /* Select relevant ADC_HCx register to trigger. 1U : HC0, 2U: HC1, 4U: HC2 ... */
|
||||
uint32_t ADCChannelSelect; /* Select ADC sample channel. */
|
||||
adc_etc_interrupt_enable_t InterruptEnable; /* Enable/disable Interrupt. */
|
||||
#if defined(FSL_FEATURE_ADC_ETC_HAS_TRIGm_CHAIN_a_b_IEn_EN) && FSL_FEATURE_ADC_ETC_HAS_TRIGm_CHAIN_a_b_IEn_EN
|
||||
bool enableIrq; /* Enable IRQ for selected interrupt enable choice in "InterruptEnable" */
|
||||
#endif /* FSL_FEATURE_ADC_ETC_HAS_TRIGm_CHAIN_a_b_IEn_EN */
|
||||
} adc_etc_trigger_chain_config_t;
|
||||
|
||||
/*!
|
||||
* @brief ADC_ETC trigger configuration.
|
||||
*/
|
||||
typedef struct _adc_etc_trigger_config
|
||||
{
|
||||
bool enableSyncMode; /* Enable the sync Mode, In SyncMode ADC1 and ADC2 are controlled by the same trigger source.
|
||||
In AsyncMode ADC1 and ADC2 are controlled by separate trigger source. */
|
||||
bool enableSWTriggerMode; /* Enable the sofware trigger mode. */
|
||||
uint32_t triggerChainLength; /* TRIG chain length to the ADC. 0: Trig length is 1. ... 7: Trig length is 8. */
|
||||
uint32_t triggerPriority; /* External trigger priority, 7 is highest, 0 is lowest. */
|
||||
uint32_t sampleIntervalDelay; /* Set sampling interval delay. */
|
||||
uint32_t initialDelay; /* Set trigger initial delay. */
|
||||
} adc_etc_trigger_config_t;
|
||||
|
||||
/*******************************************************************************
|
||||
* API
|
||||
******************************************************************************/
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* @name Initialization
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @brief Initialize the ADC_ETC module.
|
||||
*
|
||||
* @param base ADC_ETC peripheral base address.
|
||||
* @param config Pointer to "adc_etc_config_t" structure.
|
||||
*/
|
||||
void ADC_ETC_Init(ADC_ETC_Type *base, const adc_etc_config_t *config);
|
||||
|
||||
/*!
|
||||
* @brief De-Initialize the ADC_ETC module.
|
||||
*
|
||||
* @param base ADC_ETC peripheral base address.
|
||||
*/
|
||||
void ADC_ETC_Deinit(ADC_ETC_Type *base);
|
||||
|
||||
/*!
|
||||
* @brief Gets an available pre-defined settings for the ADC_ETC's configuration.
|
||||
* This function initializes the ADC_ETC's configuration structure with available settings. The default values are:
|
||||
* @code
|
||||
* config->enableTSCBypass = true;
|
||||
* config->enableTSC0Trigger = false;
|
||||
* config->enableTSC1Trigger = false;
|
||||
* config->TSC0triggerPriority = 0U;
|
||||
* config->TSC1triggerPriority = 0U;
|
||||
* config->clockPreDivider = 0U;
|
||||
* config->XBARtriggerMask = 0U;
|
||||
* @endcode
|
||||
*
|
||||
* @param config Pointer to "adc_etc_config_t" structure.
|
||||
*/
|
||||
void ADC_ETC_GetDefaultConfig(adc_etc_config_t *config);
|
||||
|
||||
/*!
|
||||
* @brief Set the external XBAR trigger configuration.
|
||||
*
|
||||
* @param base ADC_ETC peripheral base address.
|
||||
* @param triggerGroup Trigger group index.
|
||||
* @param config Pointer to "adc_etc_trigger_config_t" structure.
|
||||
*/
|
||||
void ADC_ETC_SetTriggerConfig(ADC_ETC_Type *base, uint32_t triggerGroup, const adc_etc_trigger_config_t *config);
|
||||
|
||||
/*!
|
||||
* @brief Set the external XBAR trigger chain configuration.
|
||||
* For example, if triggerGroup is set to 0U and chainGroup is set to 1U, which means Trigger0 source's chain1 would be
|
||||
* configurated.
|
||||
*
|
||||
* @param base ADC_ETC peripheral base address.
|
||||
* @param triggerGroup Trigger group index. Available number is 0~7.
|
||||
* @param chainGroup Trigger chain group index. Available number is 0~7.
|
||||
* @param config Pointer to "adc_etc_trigger_chain_config_t" structure.
|
||||
*/
|
||||
void ADC_ETC_SetTriggerChainConfig(ADC_ETC_Type *base,
|
||||
uint32_t triggerGroup,
|
||||
uint32_t chainGroup,
|
||||
const adc_etc_trigger_chain_config_t *config);
|
||||
|
||||
/*!
|
||||
* @brief Gets the interrupt status flags of external XBAR and TSC triggers.
|
||||
*
|
||||
* @param base ADC_ETC peripheral base address.
|
||||
* @param sourceIndex trigger source index.
|
||||
*
|
||||
* @return Status flags mask of trigger. Refer to "_adc_etc_status_flag_mask".
|
||||
*/
|
||||
uint32_t ADC_ETC_GetInterruptStatusFlags(ADC_ETC_Type *base, adc_etc_external_trigger_source_t sourceIndex);
|
||||
|
||||
/*!
|
||||
* @brief Clears the ADC_ETC's interrupt status falgs.
|
||||
*
|
||||
* @param base ADC_ETC peripheral base address.
|
||||
* @param sourceIndex trigger source index.
|
||||
* @param mask Status flags mask of trigger. Refer to "_adc_etc_status_flag_mask".
|
||||
*/
|
||||
void ADC_ETC_ClearInterruptStatusFlags(ADC_ETC_Type *base,
|
||||
adc_etc_external_trigger_source_t sourceIndex,
|
||||
uint32_t mask);
|
||||
|
||||
/*!
|
||||
* @brief Enable the DMA corresponding to each trigger source.
|
||||
*
|
||||
* @param base ADC_ETC peripheral base address.
|
||||
* @param triggerGroup Trigger group index. Available number is 0~7.
|
||||
*/
|
||||
static inline void ADC_ETC_EnableDMA(ADC_ETC_Type *base, uint32_t triggerGroup)
|
||||
{
|
||||
/* Avoid clearing status flags at the same time. */
|
||||
base->DMA_CTRL = (base->DMA_CTRL | ((uint32_t)ADC_ETC_DMA_CTRL_TRIG0_ENABLE_MASK << (uint32_t)triggerGroup)) &
|
||||
~ADC_ETC_DMA_CTRL_TRGn_REQ_MASK;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Disable the DMA corresponding to each trigger sources.
|
||||
*
|
||||
* @param base ADC_ETC peripheral base address.
|
||||
* @param triggerGroup Trigger group index. Available number is 0~7.
|
||||
*/
|
||||
static inline void ADC_ETC_DisableDMA(ADC_ETC_Type *base, uint32_t triggerGroup)
|
||||
{
|
||||
/* Avoid clearing status flags at the same time. */
|
||||
base->DMA_CTRL = (base->DMA_CTRL & ~((uint32_t)ADC_ETC_DMA_CTRL_TRIG0_ENABLE_MASK << (uint32_t)triggerGroup)) &
|
||||
~ADC_ETC_DMA_CTRL_TRGn_REQ_MASK;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Get the DMA request status falgs. Only external XBAR sources support DMA request.
|
||||
*
|
||||
* @param base ADC_ETC peripheral base address.
|
||||
* @return Mask of external XBAR tirgger's DMA request asserted flags. Available range is trigger0:0x01 to
|
||||
* trigger7:0x80.
|
||||
*/
|
||||
static inline uint32_t ADC_ETC_GetDMAStatusFlags(ADC_ETC_Type *base)
|
||||
{
|
||||
return (((base->DMA_CTRL) & ADC_ETC_DMA_CTRL_TRGn_REQ_MASK) >> ADC_ETC_DMA_CTRL_TRIG0_REQ_SHIFT);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Clear the DMA request status falgs. Only external XBAR sources support DMA request.
|
||||
*
|
||||
* @param base ADC_ETC peripheral base address.
|
||||
* @param mask Mask of external XBAR tirgger's DMA request asserted flags. Available range is trigger0:0x01 to
|
||||
* trigger7:0x80.
|
||||
*/
|
||||
static inline void ADC_ETC_ClearDMAStatusFlags(ADC_ETC_Type *base, uint32_t mask)
|
||||
{
|
||||
base->DMA_CTRL = ((base->DMA_CTRL) & ~ADC_ETC_DMA_CTRL_TRGn_REQ_MASK) | (mask << ADC_ETC_DMA_CTRL_TRIG0_REQ_SHIFT);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief When enable, all logical will be reset.
|
||||
*
|
||||
* @param base ADC_ETC peripheral base address.
|
||||
* @param enable Enable/Disable the software reset.
|
||||
*/
|
||||
static inline void ADC_ETC_DoSoftwareReset(ADC_ETC_Type *base, bool enable)
|
||||
{
|
||||
if (enable)
|
||||
{
|
||||
base->CTRL |= ADC_ETC_CTRL_SOFTRST_MASK;
|
||||
}
|
||||
else
|
||||
{
|
||||
base->CTRL &= ~ADC_ETC_CTRL_SOFTRST_MASK;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Do software trigger corresponding to each XBAR trigger sources.
|
||||
* Each XBAR trigger sources can be configured as HW or SW trigger mode. In hardware trigger mode,
|
||||
* trigger source is from XBAR. In software mode, trigger source is from software tigger. TSC trigger sources
|
||||
* can only work in hardware trigger mode.
|
||||
*
|
||||
* @param base ADC_ETC peripheral base address.
|
||||
* @param triggerGroup Trigger group index. Available number is 0~7.
|
||||
*/
|
||||
static inline void ADC_ETC_DoSoftwareTrigger(ADC_ETC_Type *base, uint32_t triggerGroup)
|
||||
{
|
||||
assert(triggerGroup < ADC_ETC_TRIGn_CTRL_COUNT);
|
||||
|
||||
base->TRIG[triggerGroup].TRIGn_CTRL |= ADC_ETC_TRIGn_CTRL_SW_TRIG_MASK;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Get ADC conversion result from external XBAR sources.
|
||||
* For example, if triggerGroup is set to 0U and chainGroup is set to 1U, which means the API would
|
||||
* return Trigger0 source's chain1 conversion result.
|
||||
*
|
||||
* @param base ADC_ETC peripheral base address.
|
||||
* @param triggerGroup Trigger group index. Available number is 0~7.
|
||||
* @param chainGroup Trigger chain group index. Available number is 0~7.
|
||||
* @return ADC conversion result value.
|
||||
*/
|
||||
uint32_t ADC_ETC_GetADCConversionValue(ADC_ETC_Type *base, uint32_t triggerGroup, uint32_t chainGroup);
|
||||
|
||||
/* @} */
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* @} */
|
||||
|
||||
#endif /* _FSL_ADC_ETC_H_ */
|
||||
@@ -1,134 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Freescale Semiconductor, Inc.
|
||||
* Copyright 2020 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
#ifndef _FSL_AIPSTZ_H_
|
||||
#define _FSL_AIPSTZ_H_
|
||||
|
||||
#include "fsl_common.h"
|
||||
|
||||
/*!
|
||||
* @addtogroup aipstz
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
|
||||
/*! @name Driver version */
|
||||
/*@{*/
|
||||
#define FSL_AIPSTZ_DRIVER_VERSION (MAKE_VERSION(2, 0, 1)) /*!< Version 2.0.1 */
|
||||
/*@}*/
|
||||
|
||||
/*! @brief List of AIPSTZ privilege configuration.*/
|
||||
typedef enum _aipstz_master_privilege_level
|
||||
{
|
||||
kAIPSTZ_MasterBufferedWriteEnable = (1U << 3), /*!< Write accesses from this master are allowed to be buffered. */
|
||||
kAIPSTZ_MasterTrustedForReadEnable = (1U << 2), /*!< This master is trusted for read accesses. */
|
||||
kAIPSTZ_MasterTrustedForWriteEnable = (1U << 1), /*!< This master is trusted for write accesses. */
|
||||
kAIPSTZ_MasterForceUserModeEnable = 1U /*!< Accesses from this master are forced to user-mode. */
|
||||
} aipstz_master_privilege_level_t;
|
||||
|
||||
/*! @brief List of AIPSTZ masters. Organized by width for the 8-15 bits and shift for lower 8 bits.*/
|
||||
typedef enum _aipstz_master
|
||||
{
|
||||
kAIPSTZ_Master0 = (0x400U | 28U),
|
||||
kAIPSTZ_Master1 = (0x400U | 24U),
|
||||
kAIPSTZ_Master2 = (0x400U | 20U),
|
||||
kAIPSTZ_Master3 = (0x400U | 16U),
|
||||
kAIPSTZ_Master5 = (0x400U | 8U)
|
||||
} aipstz_master_t;
|
||||
|
||||
/*! @brief List of AIPSTZ peripheral access control configuration.*/
|
||||
typedef enum _aipstz_peripheral_access_control
|
||||
{
|
||||
kAIPSTZ_PeripheralAllowUntrustedMaster = 1U,
|
||||
kAIPSTZ_PeripheralWriteProtected = (1U << 1),
|
||||
kAIPSTZ_PeripheralRequireSupervisor = (1U << 2),
|
||||
kAIPSTZ_PeripheralAllowBufferedWrite = (1U << 3)
|
||||
} aipstz_peripheral_access_control_t;
|
||||
|
||||
/*! @brief List of AIPSTZ peripherals. Organized by register offset for higher 32 bits, width for the 8-15 bits and
|
||||
* shift for lower 8 bits.*/
|
||||
typedef enum _aipstz_peripheral
|
||||
{
|
||||
kAIPSTZ_Peripheral0 = ((0x40 << 16) | (4 << 8) | 28),
|
||||
kAIPSTZ_Peripheral1 = ((0x40 << 16) | (4 << 8) | 24),
|
||||
kAIPSTZ_Peripheral2 = ((0x40 << 16) | (4 << 8) | 20),
|
||||
kAIPSTZ_Peripheral3 = ((0x40 << 16) | (4 << 8) | 16),
|
||||
kAIPSTZ_Peripheral4 = ((0x40 << 16) | (4 << 8) | 12),
|
||||
kAIPSTZ_Peripheral5 = ((0x40 << 16) | (4 << 8) | 8),
|
||||
kAIPSTZ_Peripheral6 = ((0x40 << 16) | (4 << 8) | 4),
|
||||
kAIPSTZ_Peripheral7 = ((0x40 << 16) | (4 << 8) | 0),
|
||||
kAIPSTZ_Peripheral8 = ((0x44 << 16) | (4 << 8) | 28),
|
||||
kAIPSTZ_Peripheral9 = ((0x44 << 16) | (4 << 8) | 24),
|
||||
kAIPSTZ_Peripheral10 = ((0x44 << 16) | (4 << 8) | 20),
|
||||
kAIPSTZ_Peripheral11 = ((0x44 << 16) | (4 << 8) | 16),
|
||||
kAIPSTZ_Peripheral12 = ((0x44 << 16) | (4 << 8) | 12),
|
||||
kAIPSTZ_Peripheral13 = ((0x44 << 16) | (4 << 8) | 8),
|
||||
kAIPSTZ_Peripheral14 = ((0x44 << 16) | (4 << 8) | 4),
|
||||
kAIPSTZ_Peripheral15 = ((0x44 << 16) | (4 << 8) | 0),
|
||||
kAIPSTZ_Peripheral16 = ((0x48 << 16) | (4 << 8) | 28),
|
||||
kAIPSTZ_Peripheral17 = ((0x48 << 16) | (4 << 8) | 24),
|
||||
kAIPSTZ_Peripheral18 = ((0x48 << 16) | (4 << 8) | 20),
|
||||
kAIPSTZ_Peripheral19 = ((0x48 << 16) | (4 << 8) | 16),
|
||||
kAIPSTZ_Peripheral20 = ((0x48 << 16) | (4 << 8) | 12),
|
||||
kAIPSTZ_Peripheral21 = ((0x48 << 16) | (4 << 8) | 8),
|
||||
kAIPSTZ_Peripheral22 = ((0x48 << 16) | (4 << 8) | 4),
|
||||
kAIPSTZ_Peripheral23 = ((0x48 << 16) | (4 << 8) | 0),
|
||||
kAIPSTZ_Peripheral24 = ((0x4C << 16) | (4 << 8) | 28),
|
||||
kAIPSTZ_Peripheral25 = ((0x4C << 16) | (4 << 8) | 24),
|
||||
kAIPSTZ_Peripheral26 = ((0x4C << 16) | (4 << 8) | 20),
|
||||
kAIPSTZ_Peripheral27 = ((0x4C << 16) | (4 << 8) | 16),
|
||||
kAIPSTZ_Peripheral28 = ((0x4C << 16) | (4 << 8) | 12),
|
||||
kAIPSTZ_Peripheral29 = ((0x4C << 16) | (4 << 8) | 8),
|
||||
kAIPSTZ_Peripheral30 = ((0x4C << 16) | (4 << 8) | 4),
|
||||
kAIPSTZ_Peripheral31 = ((0x4C << 16) | (4 << 8) | 0),
|
||||
kAIPSTZ_Peripheral32 = ((0x50 << 16) | (4 << 8) | 28),
|
||||
kAIPSTZ_Peripheral33 = ((0x50 << 16) | (4 << 8) | 24)
|
||||
} aipstz_peripheral_t;
|
||||
|
||||
/*******************************************************************************
|
||||
* API
|
||||
******************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* @name Initialization and deinitialization
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @brief Configure the privilege level for master.
|
||||
*
|
||||
* @param base AIPSTZ peripheral base pointer
|
||||
* @param master Masters for AIPSTZ.
|
||||
* @param privilegeConfig Configuration is ORed from @ref aipstz_master_privilege_level_t.
|
||||
*/
|
||||
void AIPSTZ_SetMasterPriviledgeLevel(AIPSTZ_Type *base, aipstz_master_t master, uint32_t privilegeConfig);
|
||||
|
||||
/*!
|
||||
* @brief Configure the access for peripheral.
|
||||
*
|
||||
* @param base AIPSTZ peripheral base pointer
|
||||
* @param peripheral Peripheral for AIPSTZ.
|
||||
* @param accessControl Configuration is ORed from @ref aipstz_peripheral_access_control_t.
|
||||
*/
|
||||
void AIPSTZ_SetPeripheralAccessControl(AIPSTZ_Type *base, aipstz_peripheral_t peripheral, uint32_t accessControl);
|
||||
|
||||
/*! @}*/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
/*! @}*/
|
||||
|
||||
#endif /* _FSL_AIPSTZ_H_ */
|
||||
@@ -1,186 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016-2019 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
#ifndef _FSL_AOI_H_
|
||||
#define _FSL_AOI_H_
|
||||
|
||||
#include "fsl_common.h"
|
||||
|
||||
/*!
|
||||
* @addtogroup aoi
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
#ifndef AOI
|
||||
#define AOI AOI0 /*!< AOI peripheral address */
|
||||
#endif
|
||||
|
||||
/*! @name Driver version */
|
||||
/*@{*/
|
||||
#define FSL_AOI_DRIVER_VERSION (MAKE_VERSION(2, 0, 1)) /*!< Version 2.0.1. */
|
||||
/*@}*/
|
||||
|
||||
/*!
|
||||
* @brief AOI input configurations.
|
||||
*
|
||||
* The selection item represents the Boolean evaluations.
|
||||
*/
|
||||
typedef enum _aoi_input_config
|
||||
{
|
||||
kAOI_LogicZero = 0x0U, /*!< Forces the input to logical zero. */
|
||||
kAOI_InputSignal = 0x1U, /*!< Passes the input signal. */
|
||||
kAOI_InvInputSignal = 0x2U, /*!< Inverts the input signal. */
|
||||
kAOI_LogicOne = 0x3U /*!< Forces the input to logical one. */
|
||||
} aoi_input_config_t;
|
||||
|
||||
/*!
|
||||
* @brief AOI event indexes, where an event is the collection of the four product
|
||||
* terms (0, 1, 2, and 3) and the four signal inputs (A, B, C, and D).
|
||||
*/
|
||||
typedef enum _aoi_event
|
||||
{
|
||||
kAOI_Event0 = 0x0U, /*!< Event 0 index */
|
||||
kAOI_Event1 = 0x1U, /*!< Event 1 index */
|
||||
kAOI_Event2 = 0x2U, /*!< Event 2 index */
|
||||
kAOI_Event3 = 0x3U /*!< Event 3 index */
|
||||
} aoi_event_t;
|
||||
|
||||
/*!
|
||||
* @brief AOI event configuration structure
|
||||
*
|
||||
* Defines structure _aoi_event_config and use the AOI_SetEventLogicConfig() function to make
|
||||
* whole event configuration.
|
||||
*/
|
||||
typedef struct _aoi_event_config
|
||||
{
|
||||
aoi_input_config_t PT0AC; /*!< Product term 0 input A */
|
||||
aoi_input_config_t PT0BC; /*!< Product term 0 input B */
|
||||
aoi_input_config_t PT0CC; /*!< Product term 0 input C */
|
||||
aoi_input_config_t PT0DC; /*!< Product term 0 input D */
|
||||
aoi_input_config_t PT1AC; /*!< Product term 1 input A */
|
||||
aoi_input_config_t PT1BC; /*!< Product term 1 input B */
|
||||
aoi_input_config_t PT1CC; /*!< Product term 1 input C */
|
||||
aoi_input_config_t PT1DC; /*!< Product term 1 input D */
|
||||
aoi_input_config_t PT2AC; /*!< Product term 2 input A */
|
||||
aoi_input_config_t PT2BC; /*!< Product term 2 input B */
|
||||
aoi_input_config_t PT2CC; /*!< Product term 2 input C */
|
||||
aoi_input_config_t PT2DC; /*!< Product term 2 input D */
|
||||
aoi_input_config_t PT3AC; /*!< Product term 3 input A */
|
||||
aoi_input_config_t PT3BC; /*!< Product term 3 input B */
|
||||
aoi_input_config_t PT3CC; /*!< Product term 3 input C */
|
||||
aoi_input_config_t PT3DC; /*!< Product term 3 input D */
|
||||
} aoi_event_config_t;
|
||||
|
||||
/*******************************************************************************
|
||||
* API
|
||||
******************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif /* __cplusplus*/
|
||||
|
||||
/*!
|
||||
* @name AOI Initialization
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @brief Initializes an AOI instance for operation.
|
||||
*
|
||||
* This function un-gates the AOI clock.
|
||||
*
|
||||
* @param base AOI peripheral address.
|
||||
*/
|
||||
void AOI_Init(AOI_Type *base);
|
||||
|
||||
/*!
|
||||
* @brief Deinitializes an AOI instance for operation.
|
||||
*
|
||||
* This function shutdowns AOI module.
|
||||
*
|
||||
* @param base AOI peripheral address.
|
||||
*/
|
||||
void AOI_Deinit(AOI_Type *base);
|
||||
|
||||
/*@}*/
|
||||
|
||||
/*!
|
||||
* @name AOI Get Set Operation
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @brief Gets the Boolean evaluation associated.
|
||||
*
|
||||
* This function returns the Boolean evaluation associated.
|
||||
*
|
||||
* Example:
|
||||
@code
|
||||
aoi_event_config_t demoEventLogicStruct;
|
||||
|
||||
AOI_GetEventLogicConfig(AOI, kAOI_Event0, &demoEventLogicStruct);
|
||||
@endcode
|
||||
*
|
||||
* @param base AOI peripheral address.
|
||||
* @param event Index of the event which will be set of type aoi_event_t.
|
||||
* @param config Selected input configuration .
|
||||
*/
|
||||
void AOI_GetEventLogicConfig(AOI_Type *base, aoi_event_t event, aoi_event_config_t *config);
|
||||
|
||||
/*!
|
||||
* @brief Configures an AOI event.
|
||||
*
|
||||
* This function configures an AOI event according
|
||||
* to the aoiEventConfig structure. This function configures all inputs (A, B, C, and D)
|
||||
* of all product terms (0, 1, 2, and 3) of a desired event.
|
||||
*
|
||||
* Example:
|
||||
@code
|
||||
aoi_event_config_t demoEventLogicStruct;
|
||||
|
||||
demoEventLogicStruct.PT0AC = kAOI_InvInputSignal;
|
||||
demoEventLogicStruct.PT0BC = kAOI_InputSignal;
|
||||
demoEventLogicStruct.PT0CC = kAOI_LogicOne;
|
||||
demoEventLogicStruct.PT0DC = kAOI_LogicOne;
|
||||
|
||||
demoEventLogicStruct.PT1AC = kAOI_LogicZero;
|
||||
demoEventLogicStruct.PT1BC = kAOI_LogicOne;
|
||||
demoEventLogicStruct.PT1CC = kAOI_LogicOne;
|
||||
demoEventLogicStruct.PT1DC = kAOI_LogicOne;
|
||||
|
||||
demoEventLogicStruct.PT2AC = kAOI_LogicZero;
|
||||
demoEventLogicStruct.PT2BC = kAOI_LogicOne;
|
||||
demoEventLogicStruct.PT2CC = kAOI_LogicOne;
|
||||
demoEventLogicStruct.PT2DC = kAOI_LogicOne;
|
||||
|
||||
demoEventLogicStruct.PT3AC = kAOI_LogicZero;
|
||||
demoEventLogicStruct.PT3BC = kAOI_LogicOne;
|
||||
demoEventLogicStruct.PT3CC = kAOI_LogicOne;
|
||||
demoEventLogicStruct.PT3DC = kAOI_LogicOne;
|
||||
|
||||
AOI_SetEventLogicConfig(AOI, kAOI_Event0, demoEventLogicStruct);
|
||||
@endcode
|
||||
*
|
||||
* @param base AOI peripheral address.
|
||||
* @param event Event which will be configured of type aoi_event_t.
|
||||
* @param eventConfig Pointer to type aoi_event_config_t structure. The user is responsible for
|
||||
* filling out the members of this structure and passing the pointer to this function.
|
||||
*/
|
||||
void AOI_SetEventLogicConfig(AOI_Type *base, aoi_event_t event, const aoi_event_config_t *eventConfig);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif /* __cplusplus*/
|
||||
|
||||
/*@}*/
|
||||
|
||||
/*!* @} */
|
||||
|
||||
#endif /* _FSL_AOI_H_*/
|
||||
@@ -1,254 +0,0 @@
|
||||
/*
|
||||
* Copyright 2017, 2019 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#ifndef _FSL_BEE_H_
|
||||
#define _FSL_BEE_H_
|
||||
|
||||
#include "fsl_common.h"
|
||||
|
||||
/*!
|
||||
* @addtogroup bee
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
*******************************************************************************/
|
||||
|
||||
/*! @name Driver version */
|
||||
/*@{*/
|
||||
/*! @brief BEE driver version. Version 2.0.2.
|
||||
*
|
||||
* Current version: 2.0.2
|
||||
*
|
||||
* Change log:
|
||||
*
|
||||
* - 2.0.2
|
||||
* - Bug Fixes
|
||||
* - Fixed MISRA issue.
|
||||
*
|
||||
* - 2.0.1
|
||||
* - Bug Fixes
|
||||
* - Fixed bug in key user key loading sequence. BEE must be enabled during loading of user key.
|
||||
* - Fixed typos in comments.
|
||||
* - New Features
|
||||
* - Added configuration setting for endian swap, access permission and region security level.
|
||||
* - Improvements
|
||||
* - Setting of AES nonce was moved from BEE_SetRegionKey() into separate BEE_SetRegionNonce() function.
|
||||
* - Changed handling of region settings. Both regions are configured simultaneously by BEE_SetConfig() function.
|
||||
* Configuration of FAC start and end address using IOMUXC_GPRs was moved to application.
|
||||
* - Default value for region address offset was changed to 0.
|
||||
*
|
||||
* - 2.0.0
|
||||
* - Initial version
|
||||
*/
|
||||
#define FSL_BEE_DRIVER_VERSION (MAKE_VERSION(2, 0, 2))
|
||||
/*@}*/
|
||||
|
||||
/*! @brief BEE aes mode. */
|
||||
typedef enum _bee_aes_mode
|
||||
{
|
||||
kBEE_AesEcbMode = 0U, /*!< AES ECB Mode */
|
||||
kBEE_AesCtrMode = 1U /*!< AES CTR Mode */
|
||||
} bee_aes_mode_t;
|
||||
|
||||
/*! @brief BEE region. */
|
||||
typedef enum _bee_region
|
||||
{
|
||||
kBEE_Region0 = 0U, /*!< BEE region 0 */
|
||||
kBEE_Region1 = 1U /*!< BEE region 1 */
|
||||
} bee_region_t;
|
||||
|
||||
/*! @brief BEE ac prot enable. */
|
||||
typedef enum _bee_ac_prot_enable
|
||||
{
|
||||
kBEE_AccessProtDisabled = 0U, /*!< BEE access permission control disabled */
|
||||
kBEE_AccessProtEnabled = 1U /*!< BEE access permission control enabled */
|
||||
} bee_ac_prot_enable;
|
||||
|
||||
/*! @brief BEE endian swap enable. */
|
||||
typedef enum _bee_endian_swap_enable
|
||||
{
|
||||
kBEE_EndianSwapDisabled = 1U, /*!< BEE endian swap disabled */
|
||||
kBEE_EndianSwapEnabled = 0U /*!< BEE endian swap enabled */
|
||||
} bee_endian_swap_enable;
|
||||
|
||||
/*! @brief BEE security level. */
|
||||
typedef enum _bee_security_level
|
||||
{
|
||||
kBEE_SecurityLevel0 = 0U, /*!< BEE security level 0 */
|
||||
kBEE_SecurityLevel1 = 1U, /*!< BEE security level 1 */
|
||||
kBEE_SecurityLevel2 = 2U, /*!< BEE security level 2 */
|
||||
kBEE_SecurityLevel3 = 3U /*!< BEE security level 3 */
|
||||
} bee_security_level;
|
||||
|
||||
/*! @brief BEE status flags. */
|
||||
typedef enum _bee_status_flags
|
||||
{
|
||||
kBEE_DisableAbortFlag = 1U, /*!< Disable abort flag. */
|
||||
kBEE_Reg0ReadSecViolation = 2U, /*!< Region-0 read channel security violation */
|
||||
kBEE_ReadIllegalAccess = 4U, /*!< Read channel illegal access detected */
|
||||
kBEE_Reg1ReadSecViolation = 8U, /*!< Region-1 read channel security violation */
|
||||
kBEE_Reg0AccessViolation = 16U, /*!< Protected region-0 access violation */
|
||||
kBEE_Reg1AccessViolation = 32U, /*!< Protected region-1 access violation */
|
||||
kBEE_IdleFlag = BEE_STATUS_BEE_IDLE_MASK /*!< Idle flag */
|
||||
} bee_status_flags_t;
|
||||
|
||||
/*! @brief BEE region configuration structure. */
|
||||
typedef struct _bee_region_config
|
||||
{
|
||||
bee_aes_mode_t region0Mode; /*!< AES mode used for encryption/decryption for region 0 */
|
||||
bee_aes_mode_t region1Mode; /*!< AES mode used for encryption/decryption for region 1 */
|
||||
uint32_t region0AddrOffset; /*!< Region 0 address offset */
|
||||
uint32_t region1AddrOffset; /*!< Region 1 address offset */
|
||||
bee_security_level region0SecLevel; /*!< Region 0 security level */
|
||||
bee_security_level region1SecLevel; /*!< Region 1 security level */
|
||||
uint32_t region1Bot; /*!< Region 1 bottom address */
|
||||
uint32_t region1Top; /*!< Region 1 top address */
|
||||
bee_ac_prot_enable accessPermission; /*!< Access permission control enable/disable */
|
||||
bee_endian_swap_enable endianSwapEn; /*!< Endian swap enable/disable */
|
||||
} bee_region_config_t;
|
||||
|
||||
/*******************************************************************************
|
||||
* API
|
||||
******************************************************************************/
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* @brief Resets BEE module to factory default values.
|
||||
*
|
||||
* This function performs hardware reset of BEE module. Attributes and keys from software for both regions are cleared.
|
||||
*
|
||||
* @param base BEE peripheral address.
|
||||
*/
|
||||
void BEE_Init(BEE_Type *base);
|
||||
|
||||
/*!
|
||||
* @brief Resets BEE module, clears keys for both regions and disables clock to the BEE.
|
||||
*
|
||||
* This function performs hardware reset of BEE module and disables clocks. Attributes and keys from software for both
|
||||
* regions are cleared.
|
||||
*
|
||||
* @param base BEE peripheral address.
|
||||
*/
|
||||
void BEE_Deinit(BEE_Type *base);
|
||||
|
||||
/*!
|
||||
* @brief Enables BEE decryption.
|
||||
*
|
||||
* This function enables decryption using BEE.
|
||||
*
|
||||
* @param base BEE peripheral address.
|
||||
*/
|
||||
static inline void BEE_Enable(BEE_Type *base)
|
||||
{
|
||||
base->CTRL |= BEE_CTRL_BEE_ENABLE_MASK;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Disables BEE decryption.
|
||||
*
|
||||
* This function disables decryption using BEE.
|
||||
*
|
||||
* @param base BEE peripheral address.
|
||||
*/
|
||||
static inline void BEE_Disable(BEE_Type *base)
|
||||
{
|
||||
base->CTRL &= ~BEE_CTRL_BEE_ENABLE_MASK;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Loads default values to the BEE region configuration structure.
|
||||
*
|
||||
* Loads default values to the BEE region configuration structure. The default values are as follows:
|
||||
* @code
|
||||
* config->region0Mode = kBEE_AesCtrMode;
|
||||
* config->region1Mode = kBEE_AesCtrMode;
|
||||
* config->region0AddrOffset = 0U;
|
||||
* config->region1AddrOffset = 0U;
|
||||
* config->region0SecLevel = kBEE_SecurityLevel3;
|
||||
* config->region1SecLevel = kBEE_SecurityLevel3;
|
||||
* config->region1Bot = 0U;
|
||||
* config->region1Top = 0U;
|
||||
* config->accessPermission = kBEE_AccessProtDisabled;
|
||||
* config->endianSwapEn = kBEE_EndianSwapEnabled;
|
||||
* @endcode
|
||||
*
|
||||
* @param config Configuration structure for BEE peripheral.
|
||||
*/
|
||||
void BEE_GetDefaultConfig(bee_region_config_t *config);
|
||||
|
||||
/*!
|
||||
* @brief Sets BEE configuration.
|
||||
*
|
||||
* This function sets BEE peripheral and BEE region settings accorging to given configuration structure.
|
||||
*
|
||||
* @param base BEE peripheral address.
|
||||
* @param config Configuration structure for BEE.
|
||||
*/
|
||||
void BEE_SetConfig(BEE_Type *base, const bee_region_config_t *config);
|
||||
|
||||
/*!
|
||||
* @brief Loads the AES key for selected region into BEE key registers.
|
||||
*
|
||||
* This function loads given AES key to BEE register for the given region.
|
||||
* The key must be 32-bit aligned and stored in little-endian format.
|
||||
*
|
||||
* Please note, that eFuse BEE_KEYx_SEL must be set accordingly to be able to load and use key loaded in BEE registers.
|
||||
* Otherwise, key cannot loaded and BEE will use key from OTPMK or SW_GP2.
|
||||
*
|
||||
* @param base BEE peripheral address.
|
||||
* @param region Selection of the BEE region to be configured.
|
||||
* @param key AES key (in little-endian format).
|
||||
* @param keySize Size of AES key.
|
||||
*/
|
||||
status_t BEE_SetRegionKey(BEE_Type *base, bee_region_t region, const uint8_t *key, size_t keySize);
|
||||
|
||||
/*!
|
||||
* @brief Loads the nonce for selected region into BEE nonce registers.
|
||||
*
|
||||
* This function loads given nonce(only AES CTR mode) to BEE register for the given region.
|
||||
* The nonce must be 32-bit aligned and stored in little-endian format.
|
||||
*
|
||||
* @param base BEE peripheral address.
|
||||
* @param region Selection of the BEE region to be configured.
|
||||
* @param nonce AES nonce (in little-endian format).
|
||||
* @param nonceSize Size of AES nonce.
|
||||
*/
|
||||
status_t BEE_SetRegionNonce(BEE_Type *base, bee_region_t region, const uint8_t *nonce, size_t nonceSize);
|
||||
|
||||
/*!
|
||||
* @brief Gets the BEE status flags.
|
||||
*
|
||||
* This function returns status of BEE peripheral.
|
||||
*
|
||||
* @param base BEE peripheral address.
|
||||
*
|
||||
* @return The status flags. This is the logical OR of members of the
|
||||
* enumeration ::bee_status_flags_t
|
||||
*/
|
||||
uint32_t BEE_GetStatusFlags(BEE_Type *base);
|
||||
|
||||
/*!
|
||||
* @brief Clears the BEE status flags.
|
||||
*
|
||||
* @param base BEE peripheral base address.
|
||||
* @param mask The status flags to clear. This is a logical OR of members of the
|
||||
* enumeration ::bee_status_flags_t
|
||||
*/
|
||||
void BEE_ClearStatusFlags(BEE_Type *base, uint32_t mask);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
/*@}*/
|
||||
|
||||
#endif /* _FSL_BEE_H_ */
|
||||
@@ -1,457 +0,0 @@
|
||||
/*
|
||||
* Copyright 2016-2019 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
#ifndef _FSL_CACHE_H_
|
||||
#define _FSL_CACHE_H_
|
||||
|
||||
#include "fsl_common.h"
|
||||
|
||||
/*!
|
||||
* @addtogroup cache
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
|
||||
/*! @name Driver version */
|
||||
/*@{*/
|
||||
/*! @brief cache driver version 2.0.3. */
|
||||
#define FSL_CACHE_DRIVER_VERSION (MAKE_VERSION(2, 0, 3))
|
||||
/*@}*/
|
||||
|
||||
#if defined(FSL_FEATURE_SOC_L2CACHEC_COUNT) && FSL_FEATURE_SOC_L2CACHEC_COUNT
|
||||
#ifndef FSL_SDK_DISBLE_L2CACHE_PRESENT
|
||||
#define FSL_SDK_DISBLE_L2CACHE_PRESENT 0
|
||||
#endif
|
||||
#endif /* FSL_FEATURE_SOC_L2CACHEC_COUNT */
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
#if defined(FSL_FEATURE_SOC_L2CACHEC_COUNT) && FSL_FEATURE_SOC_L2CACHEC_COUNT
|
||||
|
||||
/*! @brief Number of level 2 cache controller ways. */
|
||||
typedef enum _l2cache_way_num
|
||||
{
|
||||
kL2CACHE_8ways = 0, /*!< 8 ways. */
|
||||
#if defined(FSL_FEATURE_L2CACHE_SUPPORT_16_WAY_ASSOCIATIVITY) && FSL_FEATURE_L2CACHE_SUPPORT_16_WAY_ASSOCIATIVITY
|
||||
kL2CACHE_16ways /*!< 16 ways. */
|
||||
#endif /* FSL_FEATURE_L2CACHE_SUPPORT_16_WAY_ASSOCIATIVITY */
|
||||
} l2cache_way_num_t;
|
||||
|
||||
/*! @brief Level 2 cache controller way size. */
|
||||
typedef enum _l2cache_way_size
|
||||
{
|
||||
kL2CACHE_16KBSize = 1, /*!< 16 KB way size. */
|
||||
kL2CACHE_32KBSize = 2, /*!< 32 KB way size. */
|
||||
kL2CACHE_64KBSize = 3, /*!< 64 KB way size. */
|
||||
kL2CACHE_128KBSize = 4, /*!< 128 KB way size. */
|
||||
kL2CACHE_256KBSize = 5, /*!< 256 KB way size. */
|
||||
kL2CACHE_512KBSize = 6 /*!< 512 KB way size. */
|
||||
} l2cache_way_size;
|
||||
|
||||
/*! @brief Level 2 cache controller replacement policy. */
|
||||
typedef enum _l2cache_replacement
|
||||
{
|
||||
kL2CACHE_Pseudorandom = 0U, /*!< Peseudo-random replacement policy using an lfsr. */
|
||||
kL2CACHE_Roundrobin /*!< Round-robin replacemnt policy. */
|
||||
} l2cache_replacement_t;
|
||||
|
||||
/*! @brief Level 2 cache controller force write allocate options. */
|
||||
typedef enum _l2cache_writealloc
|
||||
{
|
||||
kL2CACHE_UseAwcache = 0, /*!< Use AWCAHE attribute for the write allocate. */
|
||||
kL2CACHE_NoWriteallocate, /*!< Force no write allocate. */
|
||||
kL2CACHE_forceWriteallocate /*!< Force write allocate when write misses. */
|
||||
} l2cache_writealloc_t;
|
||||
|
||||
/*! @brief Level 2 cache controller tag/data ram latency. */
|
||||
typedef enum _l2cache_latency
|
||||
{
|
||||
kL2CACHE_1CycleLate = 0, /*!< 1 cycle of latency. */
|
||||
kL2CACHE_2CycleLate, /*!< 2 cycle of latency. */
|
||||
kL2CACHE_3CycleLate, /*!< 3 cycle of latency. */
|
||||
kL2CACHE_4CycleLate, /*!< 4 cycle of latency. */
|
||||
kL2CACHE_5CycleLate, /*!< 5 cycle of latency. */
|
||||
kL2CACHE_6CycleLate, /*!< 6 cycle of latency. */
|
||||
kL2CACHE_7CycleLate, /*!< 7 cycle of latency. */
|
||||
kL2CACHE_8CycleLate /*!< 8 cycle of latency. */
|
||||
} l2cache_latency_t;
|
||||
|
||||
/*! @brief Level 2 cache controller tag/data ram latency configure structure. */
|
||||
typedef struct _l2cache_latency_config
|
||||
{
|
||||
l2cache_latency_t tagWriteLate; /*!< Tag write latency. */
|
||||
l2cache_latency_t tagReadLate; /*!< Tag Read latency. */
|
||||
l2cache_latency_t tagSetupLate; /*!< Tag setup latency. */
|
||||
l2cache_latency_t dataWriteLate; /*!< Data write latency. */
|
||||
l2cache_latency_t dataReadLate; /*!< Data Read latency. */
|
||||
l2cache_latency_t dataSetupLate; /*!< Data setup latency. */
|
||||
} L2cache_latency_config_t;
|
||||
|
||||
/*! @brief Level 2 cache controller configure structure. */
|
||||
typedef struct _l2cache_config
|
||||
{
|
||||
/* ------------------------ l2 cachec basic settings ---------------------------- */
|
||||
l2cache_way_num_t wayNum; /*!< The number of ways. */
|
||||
l2cache_way_size waySize; /*!< The way size = Cache Ram size / wayNum. */
|
||||
l2cache_replacement_t repacePolicy; /*!< Replacemnet policy. */
|
||||
/* ------------------------ tag/data ram latency settings ----------------------- */
|
||||
L2cache_latency_config_t *lateConfig; /*!< Tag/data latency configure. Set NUll if not required. */
|
||||
/* ------------------------ Prefetch enable settings ---------------------------- */
|
||||
bool istrPrefetchEnable; /*!< Instruction prefetch enable. */
|
||||
bool dataPrefetchEnable; /*!< Data prefetch enable. */
|
||||
/* ------------------------ Non-secure access settings -------------------------- */
|
||||
bool nsLockdownEnable; /*!< None-secure lockdown enable. */
|
||||
/* ------------------------ other settings -------------------------------------- */
|
||||
l2cache_writealloc_t writeAlloc; /*!< Write allcoate force option. */
|
||||
} l2cache_config_t;
|
||||
#endif /* FSL_FEATURE_SOC_L2CACHEC_COUNT */
|
||||
/*******************************************************************************
|
||||
* API
|
||||
******************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* @name Control for cortex-m7 L1 cache
|
||||
*@{
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @brief Enables cortex-m7 L1 instruction cache.
|
||||
*
|
||||
*/
|
||||
static inline void L1CACHE_EnableICache(void)
|
||||
{
|
||||
SCB_EnableICache();
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Disables cortex-m7 L1 instruction cache.
|
||||
*
|
||||
*/
|
||||
static inline void L1CACHE_DisableICache(void)
|
||||
{
|
||||
SCB_DisableICache();
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Invalidate cortex-m7 L1 instruction cache.
|
||||
*
|
||||
*/
|
||||
static inline void L1CACHE_InvalidateICache(void)
|
||||
{
|
||||
SCB_InvalidateICache();
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Invalidate cortex-m7 L1 instruction cache by range.
|
||||
*
|
||||
* @param address The start address of the memory to be invalidated.
|
||||
* @param size_byte The memory size.
|
||||
* @note The start address and size_byte should be 32-byte(FSL_FEATURE_L1ICACHE_LINESIZE_BYTE) aligned.
|
||||
* The startAddr here will be forced to align to L1 I-cache line size if
|
||||
* startAddr is not aligned. For the size_byte, application should make sure the
|
||||
* alignment or make sure the right operation order if the size_byte is not aligned.
|
||||
*/
|
||||
void L1CACHE_InvalidateICacheByRange(uint32_t address, uint32_t size_byte);
|
||||
|
||||
/*!
|
||||
* @brief Enables cortex-m7 L1 data cache.
|
||||
*
|
||||
*/
|
||||
static inline void L1CACHE_EnableDCache(void)
|
||||
{
|
||||
SCB_EnableDCache();
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Disables cortex-m7 L1 data cache.
|
||||
*
|
||||
*/
|
||||
static inline void L1CACHE_DisableDCache(void)
|
||||
{
|
||||
SCB_DisableDCache();
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Invalidates cortex-m7 L1 data cache.
|
||||
*
|
||||
*/
|
||||
static inline void L1CACHE_InvalidateDCache(void)
|
||||
{
|
||||
SCB_InvalidateDCache();
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Cleans cortex-m7 L1 data cache.
|
||||
*
|
||||
*/
|
||||
static inline void L1CACHE_CleanDCache(void)
|
||||
{
|
||||
SCB_CleanDCache();
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Cleans and Invalidates cortex-m7 L1 data cache.
|
||||
*
|
||||
*/
|
||||
static inline void L1CACHE_CleanInvalidateDCache(void)
|
||||
{
|
||||
SCB_CleanInvalidateDCache();
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Invalidates cortex-m7 L1 data cache by range.
|
||||
*
|
||||
* @param address The start address of the memory to be invalidated.
|
||||
* @param size_byte The memory size.
|
||||
* @note The start address and size_byte should be 32-byte(FSL_FEATURE_L1DCACHE_LINESIZE_BYTE) aligned.
|
||||
* The startAddr here will be forced to align to L1 D-cache line size if
|
||||
* startAddr is not aligned. For the size_byte, application should make sure the
|
||||
* alignment or make sure the right operation order if the size_byte is not aligned.
|
||||
*/
|
||||
static inline void L1CACHE_InvalidateDCacheByRange(uint32_t address, uint32_t size_byte)
|
||||
{
|
||||
SCB_InvalidateDCache_by_Addr((uint32_t *)address, (int32_t)size_byte);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Cleans cortex-m7 L1 data cache by range.
|
||||
*
|
||||
* @param address The start address of the memory to be cleaned.
|
||||
* @param size_byte The memory size.
|
||||
* @note The start address and size_byte should be 32-byte(FSL_FEATURE_L1DCACHE_LINESIZE_BYTE) aligned.
|
||||
* The startAddr here will be forced to align to L1 D-cache line size if
|
||||
* startAddr is not aligned. For the size_byte, application should make sure the
|
||||
* alignment or make sure the right operation order if the size_byte is not aligned.
|
||||
*/
|
||||
static inline void L1CACHE_CleanDCacheByRange(uint32_t address, uint32_t size_byte)
|
||||
{
|
||||
SCB_CleanDCache_by_Addr((uint32_t *)address, (int32_t)size_byte);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Cleans and Invalidates cortex-m7 L1 data cache by range.
|
||||
*
|
||||
* @param address The start address of the memory to be clean and invalidated.
|
||||
* @param size_byte The memory size.
|
||||
* @note The start address and size_byte should be 32-byte(FSL_FEATURE_L1DCACHE_LINESIZE_BYTE) aligned.
|
||||
* The startAddr here will be forced to align to L1 D-cache line size if
|
||||
* startAddr is not aligned. For the size_byte, application should make sure the
|
||||
* alignment or make sure the right operation order if the size_byte is not aligned.
|
||||
*/
|
||||
static inline void L1CACHE_CleanInvalidateDCacheByRange(uint32_t address, uint32_t size_byte)
|
||||
{
|
||||
SCB_CleanInvalidateDCache_by_Addr((uint32_t *)address, (int32_t)size_byte);
|
||||
}
|
||||
/*@}*/
|
||||
|
||||
#if defined(FSL_FEATURE_SOC_L2CACHEC_COUNT) && FSL_FEATURE_SOC_L2CACHEC_COUNT
|
||||
/*!
|
||||
* @name Control for L2 pl310 cache
|
||||
*@{
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @brief Initializes the level 2 cache controller module.
|
||||
*
|
||||
* @param config Pointer to configuration structure. See "l2cache_config_t".
|
||||
*/
|
||||
void L2CACHE_Init(l2cache_config_t *config);
|
||||
|
||||
/*!
|
||||
* @brief Gets an available default settings for the cache controller.
|
||||
*
|
||||
* This function initializes the cache controller configuration structure with default settings.
|
||||
* The default values are:
|
||||
* @code
|
||||
* config->waysNum = kL2CACHE_8ways;
|
||||
* config->waySize = kL2CACHE_32KbSize;
|
||||
* config->repacePolicy = kL2CACHE_Roundrobin;
|
||||
* config->lateConfig = NULL;
|
||||
* config->istrPrefetchEnable = false;
|
||||
* config->dataPrefetchEnable = false;
|
||||
* config->nsLockdownEnable = false;
|
||||
* config->writeAlloc = kL2CACHE_UseAwcache;
|
||||
* @endcode
|
||||
* @param config Pointer to the configuration structure.
|
||||
*/
|
||||
void L2CACHE_GetDefaultConfig(l2cache_config_t *config);
|
||||
|
||||
/*!
|
||||
* @brief Enables the level 2 cache controller.
|
||||
* This function enables the cache controller. Must be written using a secure access.
|
||||
* If write with a Non-secure access will cause a DECERR response.
|
||||
*
|
||||
*/
|
||||
void L2CACHE_Enable(void);
|
||||
|
||||
/*!
|
||||
* @brief Disables the level 2 cache controller.
|
||||
* This function disables the cache controller. Must be written using a secure access.
|
||||
* If write with a Non-secure access will cause a DECERR response.
|
||||
*
|
||||
*/
|
||||
void L2CACHE_Disable(void);
|
||||
|
||||
/*!
|
||||
* @brief Invalidates the Level 2 cache.
|
||||
* This function invalidates all entries in cache.
|
||||
*
|
||||
*/
|
||||
void L2CACHE_Invalidate(void);
|
||||
|
||||
/*!
|
||||
* @brief Invalidates the Level 2 cache lines in the range of two physical addresses.
|
||||
* This function invalidates all cache lines between two physical addresses.
|
||||
*
|
||||
* @param address The start address of the memory to be invalidated.
|
||||
* @param size_byte The memory size.
|
||||
* @note The start address and size_byte should be 32-byte(FSL_FEATURE_L2CACHE_LINESIZE_BYTE) aligned.
|
||||
* The startAddr here will be forced to align to L2 line size if startAddr
|
||||
* is not aligned. For the size_byte, application should make sure the
|
||||
* alignment or make sure the right operation order if the size_byte is not aligned.
|
||||
*/
|
||||
void L2CACHE_InvalidateByRange(uint32_t address, uint32_t size_byte);
|
||||
|
||||
/*!
|
||||
* @brief Cleans the level 2 cache controller.
|
||||
* This function cleans all entries in the level 2 cache controller.
|
||||
*
|
||||
*/
|
||||
void L2CACHE_Clean(void);
|
||||
|
||||
/*!
|
||||
* @brief Cleans the Level 2 cache lines in the range of two physical addresses.
|
||||
* This function cleans all cache lines between two physical addresses.
|
||||
*
|
||||
* @param address The start address of the memory to be cleaned.
|
||||
* @param size_byte The memory size.
|
||||
* @note The start address and size_byte should be 32-byte(FSL_FEATURE_L2CACHE_LINESIZE_BYTE) aligned.
|
||||
* The startAddr here will be forced to align to L2 line size if startAddr
|
||||
* is not aligned. For the size_byte, application should make sure the
|
||||
* alignment or make sure the right operation order if the size_byte is not aligned.
|
||||
*/
|
||||
void L2CACHE_CleanByRange(uint32_t address, uint32_t size_byte);
|
||||
|
||||
/*!
|
||||
* @brief Cleans and invalidates the level 2 cache controller.
|
||||
* This function cleans and invalidates all entries in the level 2 cache controller.
|
||||
*
|
||||
*/
|
||||
void L2CACHE_CleanInvalidate(void);
|
||||
|
||||
/*!
|
||||
* @brief Cleans and invalidates the Level 2 cache lines in the range of two physical addresses.
|
||||
* This function cleans and invalidates all cache lines between two physical addresses.
|
||||
*
|
||||
* @param address The start address of the memory to be cleaned and invalidated.
|
||||
* @param size_byte The memory size.
|
||||
* @note The start address and size_byte should be 32-byte(FSL_FEATURE_L2CACHE_LINESIZE_BYTE) aligned.
|
||||
* The startAddr here will be forced to align to L2 line size if startAddr
|
||||
* is not aligned. For the size_byte, application should make sure the
|
||||
* alignment or make sure the right operation order if the size_byte is not aligned.
|
||||
*/
|
||||
void L2CACHE_CleanInvalidateByRange(uint32_t address, uint32_t size_byte);
|
||||
|
||||
/*!
|
||||
* @brief Enables or disables to lock down the data and instruction by way.
|
||||
* This function locks down the cached instruction/data by way and prevent the adresses from
|
||||
* being allocated and prevent dara from being evicted out of the level 2 cache.
|
||||
* But the normal cache maintenance operations that invalidate, clean or clean
|
||||
* and validate cache contents affect the locked-down cache lines as normal.
|
||||
*
|
||||
* @param masterId The master id, range from 0 ~ 7.
|
||||
* @param mask The ways to be enabled or disabled to lockdown.
|
||||
* each bit in value is related to each way of the cache. for example:
|
||||
* value: bit 0 ------ way 0.
|
||||
* value: bit 1 ------ way 1.
|
||||
* --------------------------
|
||||
* value: bit 15 ------ way 15.
|
||||
* Note: please make sure the value setting is align with your supported ways.
|
||||
* @param enable True enable the lockdown, false to disable the lockdown.
|
||||
*/
|
||||
void L2CACHE_LockdownByWayEnable(uint32_t masterId, uint32_t mask, bool enable);
|
||||
|
||||
/*@}*/
|
||||
#endif /* FSL_FEATURE_SOC_L2CACHEC_COUNT */
|
||||
|
||||
/*!
|
||||
* @name Unified Cache Control for all caches (cortex-m7 L1 cache + l2 pl310)
|
||||
* Mainly used for many drivers for easy cache operation.
|
||||
*@{
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @brief Invalidates all instruction caches by range.
|
||||
*
|
||||
* Both cortex-m7 L1 cache line and L2 PL310 cache line length is 32-byte.
|
||||
*
|
||||
* @param address The physical address.
|
||||
* @param size_byte size of the memory to be invalidated.
|
||||
* @note address and size should be aligned to cache line size
|
||||
* 32-Byte due to the cache operation unit is one cache line. The startAddr here will be forced
|
||||
* to align to the cache line size if startAddr is not aligned. For the size_byte, application should
|
||||
* make sure the alignment or make sure the right operation order if the size_byte is not aligned.
|
||||
*/
|
||||
void ICACHE_InvalidateByRange(uint32_t address, uint32_t size_byte);
|
||||
|
||||
/*!
|
||||
* @brief Invalidates all data caches by range.
|
||||
*
|
||||
* Both cortex-m7 L1 cache line and L2 PL310 cache line length is 32-byte.
|
||||
*
|
||||
* @param address The physical address.
|
||||
* @param size_byte size of the memory to be invalidated.
|
||||
* @note address and size should be aligned to cache line size
|
||||
* 32-Byte due to the cache operation unit is one cache line. The startAddr here will be forced
|
||||
* to align to the cache line size if startAddr is not aligned. For the size_byte, application should
|
||||
* make sure the alignment or make sure the right operation order if the size_byte is not aligned.
|
||||
*/
|
||||
void DCACHE_InvalidateByRange(uint32_t address, uint32_t size_byte);
|
||||
|
||||
/*!
|
||||
* @brief Cleans all data caches by range.
|
||||
*
|
||||
* Both cortex-m7 L1 cache line and L2 PL310 cache line length is 32-byte.
|
||||
*
|
||||
* @param address The physical address.
|
||||
* @param size_byte size of the memory to be cleaned.
|
||||
* @note address and size should be aligned to cache line size
|
||||
* 32-Byte due to the cache operation unit is one cache line. The startAddr here will be forced
|
||||
* to align to the cache line size if startAddr is not aligned. For the size_byte, application should
|
||||
* make sure the alignment or make sure the right operation order if the size_byte is not aligned.
|
||||
*/
|
||||
void DCACHE_CleanByRange(uint32_t address, uint32_t size_byte);
|
||||
|
||||
/*!
|
||||
* @brief Cleans and Invalidates all data caches by range.
|
||||
*
|
||||
* Both cortex-m7 L1 cache line and L2 PL310 cache line length is 32-byte.
|
||||
*
|
||||
* @param address The physical address.
|
||||
* @param size_byte size of the memory to be cleaned and invalidated.
|
||||
* @note address and size should be aligned to cache line size
|
||||
* 32-Byte due to the cache operation unit is one cache line. The startAddr here will be forced
|
||||
* to align to the cache line size if startAddr is not aligned. For the size_byte, application should
|
||||
* make sure the alignment or make sure the right operation order if the size_byte is not aligned.
|
||||
*/
|
||||
void DCACHE_CleanInvalidateByRange(uint32_t address, uint32_t size_byte);
|
||||
|
||||
/*@}*/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
/*! @}*/
|
||||
|
||||
#endif /* _FSL_CACHE_H_*/
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,321 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016-2019 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#ifndef _FSL_CMP_H_
|
||||
#define _FSL_CMP_H_
|
||||
|
||||
#include "fsl_common.h"
|
||||
|
||||
/*!
|
||||
* @addtogroup cmp
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
|
||||
/*! @name Driver version */
|
||||
/*@{*/
|
||||
/*! @brief CMP driver version 2.0.2. */
|
||||
#define FSL_CMP_DRIVER_VERSION (MAKE_VERSION(2, 0, 2))
|
||||
/*@}*/
|
||||
|
||||
/*!
|
||||
* @brief Interrupt enable/disable mask.
|
||||
*/
|
||||
enum _cmp_interrupt_enable
|
||||
{
|
||||
kCMP_OutputRisingInterruptEnable = CMP_SCR_IER_MASK, /*!< Comparator interrupt enable rising. */
|
||||
kCMP_OutputFallingInterruptEnable = CMP_SCR_IEF_MASK, /*!< Comparator interrupt enable falling. */
|
||||
};
|
||||
|
||||
/*!
|
||||
* @brief Status flags' mask.
|
||||
*/
|
||||
enum _cmp_status_flags
|
||||
{
|
||||
kCMP_OutputRisingEventFlag = CMP_SCR_CFR_MASK, /*!< Rising-edge on the comparison output has occurred. */
|
||||
kCMP_OutputFallingEventFlag = CMP_SCR_CFF_MASK, /*!< Falling-edge on the comparison output has occurred. */
|
||||
kCMP_OutputAssertEventFlag = CMP_SCR_COUT_MASK, /*!< Return the current value of the analog comparator output. */
|
||||
};
|
||||
|
||||
/*!
|
||||
* @brief CMP Hysteresis mode.
|
||||
*/
|
||||
typedef enum _cmp_hysteresis_mode
|
||||
{
|
||||
kCMP_HysteresisLevel0 = 0U, /*!< Hysteresis level 0. */
|
||||
kCMP_HysteresisLevel1 = 1U, /*!< Hysteresis level 1. */
|
||||
kCMP_HysteresisLevel2 = 2U, /*!< Hysteresis level 2. */
|
||||
kCMP_HysteresisLevel3 = 3U, /*!< Hysteresis level 3. */
|
||||
} cmp_hysteresis_mode_t;
|
||||
|
||||
/*!
|
||||
* @brief CMP Voltage Reference source.
|
||||
*/
|
||||
typedef enum _cmp_reference_voltage_source
|
||||
{
|
||||
kCMP_VrefSourceVin1 = 0U, /*!< Vin1 is selected as a resistor ladder network supply reference Vin. */
|
||||
kCMP_VrefSourceVin2 = 1U, /*!< Vin2 is selected as a resistor ladder network supply reference Vin. */
|
||||
} cmp_reference_voltage_source_t;
|
||||
|
||||
/*!
|
||||
* @brief Configures the comparator.
|
||||
*/
|
||||
typedef struct _cmp_config
|
||||
{
|
||||
bool enableCmp; /*!< Enable the CMP module. */
|
||||
cmp_hysteresis_mode_t hysteresisMode; /*!< CMP Hysteresis mode. */
|
||||
bool enableHighSpeed; /*!< Enable High-speed (HS) comparison mode. */
|
||||
bool enableInvertOutput; /*!< Enable the inverted comparator output. */
|
||||
bool useUnfilteredOutput; /*!< Set the compare output(COUT) to equal COUTA(true) or COUT(false). */
|
||||
bool enablePinOut; /*!< The comparator output is available on the associated pin. */
|
||||
#if defined(FSL_FEATURE_CMP_HAS_TRIGGER_MODE) && FSL_FEATURE_CMP_HAS_TRIGGER_MODE
|
||||
bool enableTriggerMode; /*!< Enable the trigger mode. */
|
||||
#endif /* FSL_FEATURE_CMP_HAS_TRIGGER_MODE */
|
||||
} cmp_config_t;
|
||||
|
||||
/*!
|
||||
* @brief Configures the filter.
|
||||
*/
|
||||
typedef struct _cmp_filter_config
|
||||
{
|
||||
#if defined(FSL_FEATURE_CMP_HAS_EXTERNAL_SAMPLE_SUPPORT) && FSL_FEATURE_CMP_HAS_EXTERNAL_SAMPLE_SUPPORT
|
||||
bool enableSample; /*!< Using the external SAMPLE as a sampling clock input or using a divided bus clock. */
|
||||
#endif /* FSL_FEATURE_CMP_HAS_EXTERNAL_SAMPLE_SUPPORT */
|
||||
uint8_t filterCount; /*!< Filter Sample Count. Available range is 1-7; 0 disables the filter.*/
|
||||
uint8_t filterPeriod; /*!< Filter Sample Period. The divider to the bus clock. Available range is 0-255. */
|
||||
} cmp_filter_config_t;
|
||||
|
||||
/*!
|
||||
* @brief Configures the internal DAC.
|
||||
*/
|
||||
typedef struct _cmp_dac_config
|
||||
{
|
||||
cmp_reference_voltage_source_t referenceVoltageSource; /*!< Supply voltage reference source. */
|
||||
uint8_t DACValue; /*!< Value for the DAC Output Voltage. Available range is 0-63.*/
|
||||
} cmp_dac_config_t;
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
* API
|
||||
******************************************************************************/
|
||||
|
||||
/*!
|
||||
* @name Initialization
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @brief Initializes the CMP.
|
||||
*
|
||||
* This function initializes the CMP module. The operations included are as follows.
|
||||
* - Enabling the clock for CMP module.
|
||||
* - Configuring the comparator.
|
||||
* - Enabling the CMP module.
|
||||
* Note that for some devices, multiple CMP instances share the same clock gate. In this case, to enable the clock for
|
||||
* any instance enables all CMPs. See the appropriate MCU reference manual for the clock assignment of the CMP.
|
||||
*
|
||||
* @param base CMP peripheral base address.
|
||||
* @param config Pointer to the configuration structure.
|
||||
*/
|
||||
void CMP_Init(CMP_Type *base, const cmp_config_t *config);
|
||||
|
||||
/*!
|
||||
* @brief De-initializes the CMP module.
|
||||
*
|
||||
* This function de-initializes the CMP module. The operations included are as follows.
|
||||
* - Disabling the CMP module.
|
||||
* - Disabling the clock for CMP module.
|
||||
*
|
||||
* This function disables the clock for the CMP.
|
||||
* Note that for some devices, multiple CMP instances share the same clock gate. In this case, before disabling the
|
||||
* clock for the CMP, ensure that all the CMP instances are not used.
|
||||
*
|
||||
* @param base CMP peripheral base address.
|
||||
*/
|
||||
void CMP_Deinit(CMP_Type *base);
|
||||
|
||||
/*!
|
||||
* @brief Enables/disables the CMP module.
|
||||
*
|
||||
* @param base CMP peripheral base address.
|
||||
* @param enable Enables or disables the module.
|
||||
*/
|
||||
static inline void CMP_Enable(CMP_Type *base, bool enable)
|
||||
{
|
||||
if (enable)
|
||||
{
|
||||
base->CR1 |= CMP_CR1_EN_MASK;
|
||||
}
|
||||
else
|
||||
{
|
||||
base->CR1 &= ~(uint8_t)CMP_CR1_EN_MASK;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Initializes the CMP user configuration structure.
|
||||
*
|
||||
* This function initializes the user configuration structure to these default values.
|
||||
* @code
|
||||
* config->enableCmp = true;
|
||||
* config->hysteresisMode = kCMP_HysteresisLevel0;
|
||||
* config->enableHighSpeed = false;
|
||||
* config->enableInvertOutput = false;
|
||||
* config->useUnfilteredOutput = false;
|
||||
* config->enablePinOut = false;
|
||||
* config->enableTriggerMode = false;
|
||||
* @endcode
|
||||
* @param config Pointer to the configuration structure.
|
||||
*/
|
||||
void CMP_GetDefaultConfig(cmp_config_t *config);
|
||||
|
||||
/*!
|
||||
* @brief Sets the input channels for the comparator.
|
||||
*
|
||||
* This function sets the input channels for the comparator.
|
||||
* Note that two input channels cannot be set the same way in the application. When the user selects the same input
|
||||
* from the analog mux to the positive and negative port, the comparator is disabled automatically.
|
||||
*
|
||||
* @param base CMP peripheral base address.
|
||||
* @param positiveChannel Positive side input channel number. Available range is 0-7.
|
||||
* @param negativeChannel Negative side input channel number. Available range is 0-7.
|
||||
*/
|
||||
void CMP_SetInputChannels(CMP_Type *base, uint8_t positiveChannel, uint8_t negativeChannel);
|
||||
|
||||
/* @} */
|
||||
|
||||
/*!
|
||||
* @name Advanced Features
|
||||
* @{
|
||||
*/
|
||||
|
||||
#if defined(FSL_FEATURE_CMP_HAS_DMA) && FSL_FEATURE_CMP_HAS_DMA
|
||||
/*!
|
||||
* @brief Enables/disables the DMA request for rising/falling events.
|
||||
*
|
||||
* This function enables/disables the DMA request for rising/falling events. Either event triggers the generation of
|
||||
* the DMA request from CMP if the DMA feature is enabled. Both events are ignored for generating the DMA request from
|
||||
* the CMP
|
||||
* if the DMA is disabled.
|
||||
*
|
||||
* @param base CMP peripheral base address.
|
||||
* @param enable Enables or disables the feature.
|
||||
*/
|
||||
void CMP_EnableDMA(CMP_Type *base, bool enable);
|
||||
#endif /* FSL_FEATURE_CMP_HAS_DMA */
|
||||
|
||||
#if defined(FSL_FEATURE_CMP_HAS_WINDOW_MODE) && FSL_FEATURE_CMP_HAS_WINDOW_MODE
|
||||
/*!
|
||||
* @brief Enables/disables the window mode.
|
||||
*
|
||||
* @param base CMP peripheral base address.
|
||||
* @param enable Enables or disables the feature.
|
||||
*/
|
||||
static inline void CMP_EnableWindowMode(CMP_Type *base, bool enable)
|
||||
{
|
||||
if (enable)
|
||||
{
|
||||
base->CR1 |= CMP_CR1_WE_MASK;
|
||||
}
|
||||
else
|
||||
{
|
||||
base->CR1 &= (uint8_t)(~CMP_CR1_WE_MASK);
|
||||
}
|
||||
}
|
||||
#endif /* FSL_FEATURE_CMP_HAS_WINDOW_MODE */
|
||||
|
||||
#if defined(FSL_FEATURE_CMP_HAS_PASS_THROUGH_MODE) && FSL_FEATURE_CMP_HAS_PASS_THROUGH_MODE
|
||||
/*!
|
||||
* @brief Enables/disables the pass through mode.
|
||||
*
|
||||
* @param base CMP peripheral base address.
|
||||
* @param enable Enables or disables the feature.
|
||||
*/
|
||||
static inline void CMP_EnablePassThroughMode(CMP_Type *base, bool enable)
|
||||
{
|
||||
if (enable)
|
||||
{
|
||||
base->MUXCR |= CMP_MUXCR_PSTM_MASK;
|
||||
}
|
||||
else
|
||||
{
|
||||
base->MUXCR &= (uint8_t)(~CMP_MUXCR_PSTM_MASK);
|
||||
}
|
||||
}
|
||||
#endif /* FSL_FEATURE_CMP_HAS_PASS_THROUGH_MODE */
|
||||
|
||||
/*!
|
||||
* @brief Configures the filter.
|
||||
*
|
||||
* @param base CMP peripheral base address.
|
||||
* @param config Pointer to the configuration structure.
|
||||
*/
|
||||
void CMP_SetFilterConfig(CMP_Type *base, const cmp_filter_config_t *config);
|
||||
|
||||
/*!
|
||||
* @brief Configures the internal DAC.
|
||||
*
|
||||
* @param base CMP peripheral base address.
|
||||
* @param config Pointer to the configuration structure. "NULL" disables the feature.
|
||||
*/
|
||||
void CMP_SetDACConfig(CMP_Type *base, const cmp_dac_config_t *config);
|
||||
|
||||
/*!
|
||||
* @brief Enables the interrupts.
|
||||
*
|
||||
* @param base CMP peripheral base address.
|
||||
* @param mask Mask value for interrupts. See "_cmp_interrupt_enable".
|
||||
*/
|
||||
void CMP_EnableInterrupts(CMP_Type *base, uint32_t mask);
|
||||
|
||||
/*!
|
||||
* @brief Disables the interrupts.
|
||||
*
|
||||
* @param base CMP peripheral base address.
|
||||
* @param mask Mask value for interrupts. See "_cmp_interrupt_enable".
|
||||
*/
|
||||
void CMP_DisableInterrupts(CMP_Type *base, uint32_t mask);
|
||||
|
||||
/* @} */
|
||||
|
||||
/*!
|
||||
* @name Results
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @brief Gets the status flags.
|
||||
*
|
||||
* @param base CMP peripheral base address.
|
||||
*
|
||||
* @return Mask value for the asserted flags. See "_cmp_status_flags".
|
||||
*/
|
||||
uint32_t CMP_GetStatusFlags(CMP_Type *base);
|
||||
|
||||
/*!
|
||||
* @brief Clears the status flags.
|
||||
*
|
||||
* @param base CMP peripheral base address.
|
||||
* @param mask Mask value for the flags. See "_cmp_status_flags".
|
||||
*/
|
||||
void CMP_ClearStatusFlags(CMP_Type *base, uint32_t mask);
|
||||
|
||||
/* @} */
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
/*!
|
||||
* @}
|
||||
*/
|
||||
#endif /* _FSL_CMP_H_ */
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,496 +0,0 @@
|
||||
/*
|
||||
* Copyright 2017-2020, NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#ifndef __FSL_DCDC_H__
|
||||
#define __FSL_DCDC_H__
|
||||
|
||||
#include "fsl_common.h"
|
||||
|
||||
/*!
|
||||
* @addtogroup dcdc
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
/*! @brief DCDC driver version. */
|
||||
#define FSL_DCDC_DRIVER_VERSION (MAKE_VERSION(2, 1, 0)) /*!< Version 2.1.0. */
|
||||
/*!
|
||||
* @brief DCDC status flags.
|
||||
*/
|
||||
enum _dcdc_status_flags_t
|
||||
{
|
||||
kDCDC_LockedOKStatus = (1U << 0U), /*!< Indicate DCDC status. 1'b1: DCDC already settled 1'b0: DCDC is settling. */
|
||||
};
|
||||
|
||||
/*!
|
||||
* @brief The current bias of low power comparator.
|
||||
*/
|
||||
typedef enum _dcdc_comparator_current_bias
|
||||
{
|
||||
kDCDC_ComparatorCurrentBias50nA = 0U, /*!< The current bias of low power comparator is 50nA. */
|
||||
kDCDC_ComparatorCurrentBias100nA = 1U, /*!< The current bias of low power comparator is 100nA. */
|
||||
kDCDC_ComparatorCurrentBias200nA = 2U, /*!< The current bias of low power comparator is 200nA. */
|
||||
kDCDC_ComparatorCurrentBias400nA = 3U, /*!< The current bias of low power comparator is 400nA. */
|
||||
} dcdc_comparator_current_bias_t;
|
||||
|
||||
/*!
|
||||
* @brief The threshold of over current detection.
|
||||
*/
|
||||
typedef enum _dcdc_over_current_threshold
|
||||
{
|
||||
kDCDC_OverCurrentThresholdAlt0 = 0U, /*!< 1A in the run mode, 0.25A in the power save mode. */
|
||||
kDCDC_OverCurrentThresholdAlt1 = 1U, /*!< 2A in the run mode, 0.25A in the power save mode. */
|
||||
kDCDC_OverCurrentThresholdAlt2 = 2U, /*!< 1A in the run mode, 0.2A in the power save mode. */
|
||||
kDCDC_OverCurrentThresholdAlt3 = 3U, /*!< 2A in the run mode, 0.2A in the power save mode. */
|
||||
} dcdc_over_current_threshold_t;
|
||||
|
||||
/*!
|
||||
* @brief The threshold if peak current detection.
|
||||
*/
|
||||
typedef enum _dcdc_peak_current_threshold
|
||||
{
|
||||
kDCDC_PeakCurrentThresholdAlt0 = 0U, /*!< 150mA peak current threshold. */
|
||||
kDCDC_PeakCurrentThresholdAlt1 = 1U, /*!< 250mA peak current threshold. */
|
||||
kDCDC_PeakCurrentThresholdAlt2 = 2U, /*!< 350mA peak current threshold. */
|
||||
kDCDC_PeakCurrentThresholdAlt3 = 3U, /*!< 450mA peak current threshold. */
|
||||
kDCDC_PeakCurrentThresholdAlt4 = 4U, /*!< 550mA peak current threshold. */
|
||||
kDCDC_PeakCurrentThresholdAlt5 = 5U, /*!< 650mA peak current threshold. */
|
||||
} dcdc_peak_current_threshold_t;
|
||||
|
||||
/*!
|
||||
* @brief The period of counting the charging times in power save mode.
|
||||
*/
|
||||
typedef enum _dcdc_count_charging_time_period
|
||||
{
|
||||
kDCDC_CountChargingTimePeriod8Cycle = 0U, /*!< Eight 32k cycle. */
|
||||
kDCDC_CountChargingTimePeriod16Cycle = 1U, /*!< Sixteen 32k cycle. */
|
||||
} dcdc_count_charging_time_period_t;
|
||||
|
||||
/*!
|
||||
* @brief The threshold of the counting number of charging times
|
||||
*/
|
||||
typedef enum _dcdc_count_charging_time_threshold
|
||||
{
|
||||
kDCDC_CountChargingTimeThreshold32 = 0U, /*!< 0x0: 32. */
|
||||
kDCDC_CountChargingTimeThreshold64 = 1U, /*!< 0x1: 64. */
|
||||
kDCDC_CountChargingTimeThreshold16 = 2U, /*!< 0x2: 16. */
|
||||
kDCDC_CountChargingTimeThreshold8 = 3U, /*!< 0x3: 8. */
|
||||
} dcdc_count_charging_time_threshold_t;
|
||||
|
||||
/*!
|
||||
* @brief Oscillator clock option.
|
||||
*/
|
||||
typedef enum _dcdc_clock_source
|
||||
{
|
||||
kDCDC_ClockAutoSwitch = 0U, /*!< Automatic clock switch from internal oscillator to external clock. */
|
||||
kDCDC_ClockInternalOsc = 1U, /*!< Use internal oscillator. */
|
||||
kDCDC_ClockExternalOsc = 2U, /*!< Use external 24M crystal oscillator. */
|
||||
} dcdc_clock_source_t;
|
||||
|
||||
/*!
|
||||
* @brief Configuration for DCDC detection.
|
||||
*/
|
||||
typedef struct _dcdc_detection_config
|
||||
{
|
||||
bool enableXtalokDetection; /*!< Enable xtalok detection circuit. */
|
||||
bool powerDownOverVoltageDetection; /*!< Power down over-voltage detection comparator. */
|
||||
bool powerDownLowVlotageDetection; /*!< Power down low-voltage detection comparator. */
|
||||
bool powerDownOverCurrentDetection; /*!< Power down over-current detection. */
|
||||
bool powerDownPeakCurrentDetection; /*!< Power down peak-current detection. */
|
||||
bool powerDownZeroCrossDetection; /*!< Power down the zero cross detection function for discontinuous conductor
|
||||
mode. */
|
||||
dcdc_over_current_threshold_t OverCurrentThreshold; /*!< The threshold of over current detection. */
|
||||
dcdc_peak_current_threshold_t PeakCurrentThreshold; /*!< The threshold of peak current detection. */
|
||||
} dcdc_detection_config_t;
|
||||
|
||||
/*!
|
||||
* @brief Configuration for the loop control.
|
||||
*/
|
||||
typedef struct _dcdc_loop_control_config
|
||||
{
|
||||
bool enableCommonHysteresis; /*!< Enable hysteresis in switching converter common mode analog comparators.
|
||||
This feature will improve transient supply ripple and efficiency. */
|
||||
bool enableCommonThresholdDetection; /*!< Increase the threshold detection for common mode analog comparator. */
|
||||
bool enableInvertHysteresisSign; /*!< Invert the sign of the hysteresis in DC-DC analog comparators. */
|
||||
bool enableRCThresholdDetection; /*!< Increase the threshold detection for RC scale circuit. */
|
||||
uint32_t enableRCScaleCircuit; /*!< Available range is 0~7. Enable analog circuit of DC-DC converter to respond
|
||||
faster under transient load conditions. */
|
||||
uint32_t complementFeedForwardStep; /*!< Available range is 0~7. Two's complement feed forward step in duty cycle in
|
||||
the switching DC-DC converter. Each time this field makes a transition from
|
||||
0x0, the loop filter of the DC-DC converter is stepped once by a value
|
||||
proportional to the change. This can be used to force a certain control loop
|
||||
behavior, such as improving response under known heavy load transients. */
|
||||
uint32_t controlParameterMagnitude; /*!< Available range is 0~15. Magnitude of proportional control parameter in the
|
||||
switching DC-DC converter control loop. */
|
||||
uint32_t integralProportionalRatio; /*!< Available range is 0~3.Ratio of integral control parameter to proportional
|
||||
control parameter in the switching DC-DC converter, and can be used to
|
||||
optimize efficiency and loop response. */
|
||||
} dcdc_loop_control_config_t;
|
||||
/*!
|
||||
* @brief Configuration for DCDC low power.
|
||||
*/
|
||||
typedef struct _dcdc_low_power_config
|
||||
{
|
||||
bool enableOverloadDetection; /*!< Enable the overload detection in power save mode, if current is larger than the
|
||||
overloading threshold (typical value is 50 mA), DCDC will switch to the run mode
|
||||
automatically. */
|
||||
bool enableAdjustHystereticValue; /*!< Adjust hysteretic value in low power from 12.5mV to 25mV. */
|
||||
dcdc_count_charging_time_period_t
|
||||
countChargingTimePeriod; /*!< The period of counting the charging times in power save mode. */
|
||||
dcdc_count_charging_time_threshold_t
|
||||
countChargingTimeThreshold; /*!< the threshold of the counting number of charging times during
|
||||
the period that lp_overload_freq_sel sets in power save mode. */
|
||||
} dcdc_low_power_config_t;
|
||||
|
||||
/*!
|
||||
* @brief Configuration for DCDC internal regulator.
|
||||
*/
|
||||
typedef struct _dcdc_internal_regulator_config
|
||||
{
|
||||
bool enableLoadResistor; /*!< control the load resistor of the internal regulator of DCDC, the load resistor is
|
||||
connected as default "true", and need set to "false" to disconnect the load
|
||||
resistor. */
|
||||
uint32_t feedbackPoint; /*!< Available range is 0~3. Select the feedback point of the internal regulator. */
|
||||
} dcdc_internal_regulator_config_t;
|
||||
|
||||
/*!
|
||||
* @brief Configuration for min power setting.
|
||||
*/
|
||||
typedef struct _dcdc_min_power_config
|
||||
{
|
||||
bool enableUseHalfFreqForContinuous; /*!< Set DCDC clock to half frequency for the continuous mode. */
|
||||
} dcdc_min_power_config_t;
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
* API
|
||||
******************************************************************************/
|
||||
/*!
|
||||
* @name Initialization and deinitialization
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @brief Enable the access to DCDC registers.
|
||||
*
|
||||
* @param base DCDC peripheral base address.
|
||||
*/
|
||||
void DCDC_Init(DCDC_Type *base);
|
||||
|
||||
/*!
|
||||
* @brief Disable the access to DCDC registers.
|
||||
*
|
||||
* @param base DCDC peripheral base address.
|
||||
*/
|
||||
void DCDC_Deinit(DCDC_Type *base);
|
||||
|
||||
/* @} */
|
||||
|
||||
/*!
|
||||
* @name Status
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @brief Get DCDC status flags.
|
||||
*
|
||||
* @param base peripheral base address.
|
||||
* @return Mask of asserted status flags. See to "_dcdc_status_flags_t".
|
||||
*/
|
||||
uint32_t DCDC_GetstatusFlags(DCDC_Type *base);
|
||||
|
||||
/* @} */
|
||||
|
||||
/*!
|
||||
* @name Misc control.
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @brief Enable the output range comparator.
|
||||
*
|
||||
* The output range comparator is disabled by default.
|
||||
*
|
||||
* @param base DCDC peripheral base address.
|
||||
* @param enable Enable the feature or not.
|
||||
*/
|
||||
static inline void DCDC_EnableOutputRangeComparator(DCDC_Type *base, bool enable)
|
||||
{
|
||||
if (enable)
|
||||
{
|
||||
base->REG0 &= ~DCDC_REG0_PWD_CMP_OFFSET_MASK;
|
||||
}
|
||||
else
|
||||
{
|
||||
base->REG0 |= DCDC_REG0_PWD_CMP_OFFSET_MASK;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Configure the DCDC clock source.
|
||||
*
|
||||
* @param base DCDC peripheral base address.
|
||||
* @param clockSource Clock source for DCDC. See to "dcdc_clock_source_t".
|
||||
*/
|
||||
void DCDC_SetClockSource(DCDC_Type *base, dcdc_clock_source_t clockSource);
|
||||
|
||||
/*!
|
||||
* @brief Get the default setting for detection configuration.
|
||||
*
|
||||
* The default configuration are set according to responding registers' setting when powered on.
|
||||
* They are:
|
||||
* @code
|
||||
* config->enableXtalokDetection = false;
|
||||
* config->powerDownOverVoltageDetection = true;
|
||||
* config->powerDownLowVlotageDetection = false;
|
||||
* config->powerDownOverCurrentDetection = true;
|
||||
* config->powerDownPeakCurrentDetection = true;
|
||||
* config->powerDownZeroCrossDetection = true;
|
||||
* config->OverCurrentThreshold = kDCDC_OverCurrentThresholdAlt0;
|
||||
* config->PeakCurrentThreshold = kDCDC_PeakCurrentThresholdAlt0;
|
||||
* @endcode
|
||||
*
|
||||
* @param config Pointer to configuration structure. See to "dcdc_detection_config_t"
|
||||
*/
|
||||
void DCDC_GetDefaultDetectionConfig(dcdc_detection_config_t *config);
|
||||
|
||||
/*!
|
||||
* @brief Configure the DCDC detection.
|
||||
*
|
||||
* @param base DCDC peripheral base address.
|
||||
* @param config Pointer to configuration structure. See to "dcdc_detection_config_t"
|
||||
*/
|
||||
void DCDC_SetDetectionConfig(DCDC_Type *base, const dcdc_detection_config_t *config);
|
||||
|
||||
/*!
|
||||
* @brief Get the default setting for low power configuration.
|
||||
*
|
||||
* The default configuration are set according to responding registers' setting when powered on.
|
||||
* They are:
|
||||
* @code
|
||||
* config->enableOverloadDetection = true;
|
||||
* config->enableAdjustHystereticValue = false;
|
||||
* config->countChargingTimePeriod = kDCDC_CountChargingTimePeriod8Cycle;
|
||||
* config->countChargingTimeThreshold = kDCDC_CountChargingTimeThreshold32;
|
||||
* @endcode
|
||||
*
|
||||
* @param config Pointer to configuration structure. See to "dcdc_low_power_config_t"
|
||||
*/
|
||||
void DCDC_GetDefaultLowPowerConfig(dcdc_low_power_config_t *config);
|
||||
|
||||
/*!
|
||||
* @brief Configure the DCDC low power.
|
||||
*
|
||||
* @param base DCDC peripheral base address.
|
||||
* @param config Pointer to configuration structure. See to "dcdc_low_power_config_t".
|
||||
*/
|
||||
void DCDC_SetLowPowerConfig(DCDC_Type *base, const dcdc_low_power_config_t *config);
|
||||
|
||||
/*!
|
||||
* @brief Reset current alert signal. Alert signal is generate by peak current detection.
|
||||
*
|
||||
* @param base DCDC peripheral base address.
|
||||
* @param enable Switcher to reset signal. True means reset signal. False means don't reset signal.
|
||||
*/
|
||||
void DCDC_ResetCurrentAlertSignal(DCDC_Type *base, bool enable);
|
||||
|
||||
/*!
|
||||
* @brief Set the bangap trim value to trim bandgap voltage.
|
||||
*
|
||||
* @param base DCDC peripheral base address.
|
||||
* @param trimValue The bangap trim value. Available range is 0U-31U.
|
||||
*/
|
||||
static inline void DCDC_SetBandgapVoltageTrimValue(DCDC_Type *base, uint32_t trimValue)
|
||||
{
|
||||
base->REG1 &= ~DCDC_REG1_VBG_TRIM_MASK;
|
||||
base->REG1 |= DCDC_REG1_VBG_TRIM(trimValue);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Get the default setting for loop control configuration.
|
||||
*
|
||||
* The default configuration are set according to responding registers' setting when powered on.
|
||||
* They are:
|
||||
* @code
|
||||
* config->enableCommonHysteresis = false;
|
||||
* config->enableCommonThresholdDetection = false;
|
||||
* config->enableInvertHysteresisSign = false;
|
||||
* config->enableRCThresholdDetection = false;
|
||||
* config->enableRCScaleCircuit = 0U;
|
||||
* config->complementFeedForwardStep = 0U;
|
||||
* config->controlParameterMagnitude = 2U;
|
||||
* config->integralProportionalRatio = 2U;
|
||||
* @endcode
|
||||
*
|
||||
* @param config Pointer to configuration structure. See to "dcdc_loop_control_config_t"
|
||||
*/
|
||||
void DCDC_GetDefaultLoopControlConfig(dcdc_loop_control_config_t *config);
|
||||
|
||||
/*!
|
||||
* @brief Configure the DCDC loop control.
|
||||
*
|
||||
* @param base DCDC peripheral base address.
|
||||
* @param config Pointer to configuration structure. See to "dcdc_loop_control_config_t".
|
||||
*/
|
||||
void DCDC_SetLoopControlConfig(DCDC_Type *base, const dcdc_loop_control_config_t *config);
|
||||
|
||||
/*!
|
||||
* @brief Configure for the min power.
|
||||
*
|
||||
* @param base DCDC peripheral base address.
|
||||
* @param config Pointer to configuration structure. See to "dcdc_min_power_config_t".
|
||||
*/
|
||||
void DCDC_SetMinPowerConfig(DCDC_Type *base, const dcdc_min_power_config_t *config);
|
||||
|
||||
/*!
|
||||
* @brief Set the current bias of low power comparator.
|
||||
*
|
||||
* @param base DCDC peripheral base address.
|
||||
* @param biasVaule The current bias of low power comparator. Refer to "dcdc_comparator_current_bias_t".
|
||||
*/
|
||||
static inline void DCDC_SetLPComparatorBiasValue(DCDC_Type *base, dcdc_comparator_current_bias_t biasVaule)
|
||||
{
|
||||
base->REG1 &= ~DCDC_REG1_LP_CMP_ISRC_SEL_MASK;
|
||||
base->REG1 |= DCDC_REG1_LP_CMP_ISRC_SEL(biasVaule);
|
||||
}
|
||||
|
||||
static inline void DCDC_LockTargetVoltage(DCDC_Type *base)
|
||||
{
|
||||
base->REG3 |= DCDC_REG3_DISABLE_STEP_MASK;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Adjust the target voltage of VDD_SOC in run mode and low power mode.
|
||||
* @deprecated Do not use this function. It has been superceded by @ref DCDC_AdjustRunTargetVoltage
|
||||
* and @ref DCDC_AdjustLowPowerTargetVoltage
|
||||
*
|
||||
* This function is to adjust the target voltage of DCDC output. Change them and finally wait until the output is
|
||||
* stabled.
|
||||
* Set the target value of run mode the same as low power mode before entering power save mode, because DCDC will switch
|
||||
* back to run mode if it detects the current loading is larger than about 50 mA(typical value).
|
||||
*
|
||||
* @param base DCDC peripheral base address.
|
||||
* @param VDDRun Target value in run mode. 25 mV each step from 0x00 to 0x1F. 00 is for 0.8V, 0x1F is for 1.575V.
|
||||
* @param VDDStandby Target value in low power mode. 25 mV each step from 0x00 to 0x4. 00 is for 0.9V, 0x4 is for 1.0V.
|
||||
*/
|
||||
void DCDC_AdjustTargetVoltage(DCDC_Type *base, uint32_t VDDRun, uint32_t VDDStandby);
|
||||
|
||||
/*!
|
||||
* @brief Adjust the target voltage of VDD_SOC in run mode.
|
||||
*
|
||||
* This function is to adjust the target voltage of DCDC output. Change them and finally wait until the output is
|
||||
* stabled.
|
||||
* Set the target value of run mode the same as low power mode before entering power save mode, because DCDC will switch
|
||||
* back to run mode if it detects the current loading is larger than about 50 mA(typical value).
|
||||
*
|
||||
* @param base DCDC peripheral base address.
|
||||
* @param VDDRun Target value in run mode. 25 mV each step from 0x00 to 0x1F. 00 is for 0.8V, 0x1F is for 1.575V.
|
||||
*/
|
||||
void DCDC_AdjustRunTargetVoltage(DCDC_Type *base, uint32_t VDDRun);
|
||||
|
||||
/*!
|
||||
* @brief Adjust the target voltage of VDD_SOC in low power mode.
|
||||
*
|
||||
* This function is to adjust the target voltage of DCDC output. Change them and finally wait until the output is
|
||||
* stabled.
|
||||
* Set the target value of run mode the same as low power mode before entering power save mode, because DCDC will switch
|
||||
* back to run mode if it detects the current loading is larger than about 50 mA(typical value).
|
||||
*
|
||||
* @param base DCDC peripheral base address.
|
||||
* @param VDDStandby Target value in low power mode. 25 mV each step from 0x00 to 0x4. 00 is for 0.9V, 0x4 is for 1.0V.
|
||||
*/
|
||||
void DCDC_AdjustLowPowerTargetVoltage(DCDC_Type *base, uint32_t VDDStandby);
|
||||
|
||||
/*!
|
||||
* @brief Configure the DCDC internal regulator.
|
||||
*
|
||||
* @param base DCDC peripheral base address.
|
||||
* @param config Pointer to configuration structure. See to "dcdc_internal_regulator_config_t".
|
||||
*/
|
||||
void DCDC_SetInternalRegulatorConfig(DCDC_Type *base, const dcdc_internal_regulator_config_t *config);
|
||||
|
||||
/*!
|
||||
* @brief Ajust delay to reduce ground noise.
|
||||
*
|
||||
* @param base DCDC peripheral base address.
|
||||
* @param enable Enable the feature or not.
|
||||
*/
|
||||
static inline void DCDC_EnableAdjustDelay(DCDC_Type *base, bool enable)
|
||||
{
|
||||
if (enable)
|
||||
{
|
||||
base->REG3 |= DCDC_REG3_MISC_DELAY_TIMING_MASK;
|
||||
}
|
||||
else
|
||||
{
|
||||
base->REG3 &= ~DCDC_REG3_MISC_DELAY_TIMING_MASK;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Enable/Disable to improve the transition from heavy load to light load. It is valid while zero
|
||||
* cross detection is enabled. If ouput exceeds the threshold, DCDC would return CCM from DCM.
|
||||
*
|
||||
* @param base DCDC peripheral base address.
|
||||
* @param enable Enable the feature or not.
|
||||
*/
|
||||
static inline void DCDC_EnableImproveTransition(DCDC_Type *base, bool enable)
|
||||
{
|
||||
if (enable)
|
||||
{
|
||||
base->REG2 |= DCDC_REG2_DCM_SET_CTRL_MASK;
|
||||
}
|
||||
else
|
||||
{
|
||||
base->REG2 &= ~DCDC_REG2_DCM_SET_CTRL_MASK;
|
||||
}
|
||||
}
|
||||
|
||||
/* @} */
|
||||
|
||||
/*!
|
||||
* @name Application guideline.
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @brief Boot DCDC into DCM(discontinous conduction mode).
|
||||
*
|
||||
* pwd_zcd=0x0;
|
||||
* pwd_cmp_offset=0x0;
|
||||
* dcdc_loopctrl_en_rcscale=0x3 or 0x5;
|
||||
* DCM_set_ctrl=1'b1;
|
||||
*
|
||||
* @param base DCDC peripheral base address.
|
||||
*/
|
||||
void DCDC_BootIntoDCM(DCDC_Type *base);
|
||||
|
||||
/*!
|
||||
* @brief Boot DCDC into CCM(continous conduction mode).
|
||||
*
|
||||
* pwd_zcd=0x1;
|
||||
* pwd_cmp_offset=0x0;
|
||||
* dcdc_loopctrl_en_rcscale=0x3;
|
||||
*
|
||||
* @param base DCDC peripheral base address.
|
||||
*/
|
||||
void DCDC_BootIntoCCM(DCDC_Type *base);
|
||||
|
||||
/* @} */
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* @} */
|
||||
|
||||
#endif /* __FSL_DCDC_H__ */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,41 +0,0 @@
|
||||
/* SPDX-License-Identifier: BSD-2-Clause */
|
||||
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* @ingroup RTEMSBSPsARMimxrt
|
||||
*
|
||||
* @brief Helper file for including registers for SDK drivers.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2020 embedded brains GmbH & Co. KG
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef FSL_DEVICE_REGISTERS_H
|
||||
#define FSL_DEVICE_REGISTERS_H
|
||||
|
||||
#include <chip.h>
|
||||
|
||||
#endif /* FSL_DEVICE_REGISTERS_H */
|
||||
@@ -1,177 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016-2017 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#ifndef _FSL_DMAMUX_H_
|
||||
#define _FSL_DMAMUX_H_
|
||||
|
||||
#include "fsl_common.h"
|
||||
|
||||
/*!
|
||||
* @addtogroup dmamux
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
|
||||
/*! @name Driver version */
|
||||
/*@{*/
|
||||
/*! @brief DMAMUX driver version 2.0.4. */
|
||||
#define FSL_DMAMUX_DRIVER_VERSION (MAKE_VERSION(2, 0, 4))
|
||||
/*@}*/
|
||||
|
||||
/*******************************************************************************
|
||||
* API
|
||||
******************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*!
|
||||
* @name DMAMUX Initialization and de-initialization
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @brief Initializes the DMAMUX peripheral.
|
||||
*
|
||||
* This function ungates the DMAMUX clock.
|
||||
*
|
||||
* @param base DMAMUX peripheral base address.
|
||||
*
|
||||
*/
|
||||
void DMAMUX_Init(DMAMUX_Type *base);
|
||||
|
||||
/*!
|
||||
* @brief Deinitializes the DMAMUX peripheral.
|
||||
*
|
||||
* This function gates the DMAMUX clock.
|
||||
*
|
||||
* @param base DMAMUX peripheral base address.
|
||||
*/
|
||||
void DMAMUX_Deinit(DMAMUX_Type *base);
|
||||
|
||||
/* @} */
|
||||
/*!
|
||||
* @name DMAMUX Channel Operation
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @brief Enables the DMAMUX channel.
|
||||
*
|
||||
* This function enables the DMAMUX channel.
|
||||
*
|
||||
* @param base DMAMUX peripheral base address.
|
||||
* @param channel DMAMUX channel number.
|
||||
*/
|
||||
static inline void DMAMUX_EnableChannel(DMAMUX_Type *base, uint32_t channel)
|
||||
{
|
||||
assert(channel < (uint32_t)FSL_FEATURE_DMAMUX_MODULE_CHANNEL);
|
||||
|
||||
base->CHCFG[channel] |= DMAMUX_CHCFG_ENBL_MASK;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Disables the DMAMUX channel.
|
||||
*
|
||||
* This function disables the DMAMUX channel.
|
||||
*
|
||||
* @note The user must disable the DMAMUX channel before configuring it.
|
||||
* @param base DMAMUX peripheral base address.
|
||||
* @param channel DMAMUX channel number.
|
||||
*/
|
||||
static inline void DMAMUX_DisableChannel(DMAMUX_Type *base, uint32_t channel)
|
||||
{
|
||||
assert(channel < (uint32_t)FSL_FEATURE_DMAMUX_MODULE_CHANNEL);
|
||||
|
||||
base->CHCFG[channel] &= ~(uint8_t)DMAMUX_CHCFG_ENBL_MASK;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Configures the DMAMUX channel source.
|
||||
*
|
||||
* @param base DMAMUX peripheral base address.
|
||||
* @param channel DMAMUX channel number.
|
||||
* @param source Channel source, which is used to trigger the DMA transfer.
|
||||
*/
|
||||
static inline void DMAMUX_SetSource(DMAMUX_Type *base, uint32_t channel, uint32_t source)
|
||||
{
|
||||
assert(channel < (uint32_t)FSL_FEATURE_DMAMUX_MODULE_CHANNEL);
|
||||
|
||||
base->CHCFG[channel] = (uint8_t)((base->CHCFG[channel] & ~DMAMUX_CHCFG_SOURCE_MASK) | DMAMUX_CHCFG_SOURCE(source));
|
||||
}
|
||||
|
||||
#if defined(FSL_FEATURE_DMAMUX_HAS_TRIG) && FSL_FEATURE_DMAMUX_HAS_TRIG > 0U
|
||||
/*!
|
||||
* @brief Enables the DMAMUX period trigger.
|
||||
*
|
||||
* This function enables the DMAMUX period trigger feature.
|
||||
*
|
||||
* @param base DMAMUX peripheral base address.
|
||||
* @param channel DMAMUX channel number.
|
||||
*/
|
||||
static inline void DMAMUX_EnablePeriodTrigger(DMAMUX_Type *base, uint32_t channel)
|
||||
{
|
||||
assert(channel < (uint32_t)FSL_FEATURE_DMAMUX_MODULE_CHANNEL);
|
||||
|
||||
base->CHCFG[channel] |= DMAMUX_CHCFG_TRIG_MASK;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Disables the DMAMUX period trigger.
|
||||
*
|
||||
* This function disables the DMAMUX period trigger.
|
||||
*
|
||||
* @param base DMAMUX peripheral base address.
|
||||
* @param channel DMAMUX channel number.
|
||||
*/
|
||||
static inline void DMAMUX_DisablePeriodTrigger(DMAMUX_Type *base, uint32_t channel)
|
||||
{
|
||||
assert(channel < (uint32_t)FSL_FEATURE_DMAMUX_MODULE_CHANNEL);
|
||||
|
||||
base->CHCFG[channel] &= ~(uint8_t)DMAMUX_CHCFG_TRIG_MASK;
|
||||
}
|
||||
#endif /* FSL_FEATURE_DMAMUX_HAS_TRIG */
|
||||
|
||||
#if (defined(FSL_FEATURE_DMAMUX_HAS_A_ON) && FSL_FEATURE_DMAMUX_HAS_A_ON)
|
||||
/*!
|
||||
* @brief Enables the DMA channel to be always ON.
|
||||
*
|
||||
* This function enables the DMAMUX channel always ON feature.
|
||||
*
|
||||
* @param base DMAMUX peripheral base address.
|
||||
* @param channel DMAMUX channel number.
|
||||
* @param enable Switcher of the always ON feature. "true" means enabled, "false" means disabled.
|
||||
*/
|
||||
static inline void DMAMUX_EnableAlwaysOn(DMAMUX_Type *base, uint32_t channel, bool enable)
|
||||
{
|
||||
assert(channel < (uint32_t)FSL_FEATURE_DMAMUX_MODULE_CHANNEL);
|
||||
|
||||
if (enable)
|
||||
{
|
||||
base->CHCFG[channel] |= DMAMUX_CHCFG_A_ON_MASK;
|
||||
}
|
||||
else
|
||||
{
|
||||
base->CHCFG[channel] &= ~DMAMUX_CHCFG_A_ON_MASK;
|
||||
}
|
||||
}
|
||||
#endif /* FSL_FEATURE_DMAMUX_HAS_A_ON */
|
||||
|
||||
/* @} */
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/* @} */
|
||||
|
||||
#endif /* _FSL_DMAMUX_H_ */
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,458 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016-2020 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#ifndef _FSL_ENC_H_
|
||||
#define _FSL_ENC_H_
|
||||
|
||||
#include "fsl_common.h"
|
||||
|
||||
/*!
|
||||
* @addtogroup enc
|
||||
* @{
|
||||
*/
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
#define FSL_ENC_DRIVER_VERSION (MAKE_VERSION(2, 0, 1))
|
||||
|
||||
/*!
|
||||
* @brief Interrupt enable/disable mask.
|
||||
*/
|
||||
enum _enc_interrupt_enable
|
||||
{
|
||||
kENC_HOMETransitionInterruptEnable = (1U << 0U), /*!< HOME interrupt enable. */
|
||||
kENC_INDEXPulseInterruptEnable = (1U << 1U), /*!< INDEX pulse interrupt enable. */
|
||||
kENC_WatchdogTimeoutInterruptEnable = (1U << 2U), /*!< Watchdog timeout interrupt enable. */
|
||||
kENC_PositionCompareInerruptEnable = (1U << 3U), /*!< Position compare interrupt enable. */
|
||||
kENC_SimultBothPhaseChangeInterruptEnable =
|
||||
(1U << 4U), /*!< Simultaneous PHASEA and PHASEB change interrupt enable. */
|
||||
kENC_PositionRollOverInterruptEnable = (1U << 5U), /*!< Roll-over interrupt enable. */
|
||||
kENC_PositionRollUnderInterruptEnable = (1U << 6U), /*!< Roll-under interrupt enable. */
|
||||
};
|
||||
|
||||
/*!
|
||||
* @brief Status flag mask.
|
||||
*
|
||||
* These flags indicate the counter's events.
|
||||
*/
|
||||
enum _enc_status_flags
|
||||
{
|
||||
kENC_HOMETransitionFlag = (1U << 0U), /*!< HOME signal transition interrupt request. */
|
||||
kENC_INDEXPulseFlag = (1U << 1U), /*!< INDEX Pulse Interrupt Request. */
|
||||
kENC_WatchdogTimeoutFlag = (1U << 2U), /*!< Watchdog timeout interrupt request. */
|
||||
kENC_PositionCompareFlag = (1U << 3U), /*!< Position compare interrupt request. */
|
||||
kENC_SimultBothPhaseChangeFlag = (1U << 4U), /*!< Simultaneous PHASEA and PHASEB change interrupt request. */
|
||||
kENC_PositionRollOverFlag = (1U << 5U), /*!< Roll-over interrupt request. */
|
||||
kENC_PositionRollUnderFlag = (1U << 6U), /*!< Roll-under interrupt request. */
|
||||
kENC_LastCountDirectionFlag = (1U << 7U), /*!< Last count was in the up direction, or the down direction. */
|
||||
};
|
||||
|
||||
/*!
|
||||
* @brief Signal status flag mask.
|
||||
*
|
||||
* These flags indicate the counter's signal.
|
||||
*/
|
||||
enum _enc_signal_status_flags
|
||||
{
|
||||
kENC_RawHOMEStatusFlag = ENC_IMR_HOME_MASK, /*!< Raw HOME input. */
|
||||
kENC_RawINDEXStatusFlag = ENC_IMR_INDEX_MASK, /*!< Raw INDEX input. */
|
||||
kENC_RawPHBStatusFlag = ENC_IMR_PHB_MASK, /*!< Raw PHASEB input. */
|
||||
kENC_RawPHAEXStatusFlag = ENC_IMR_PHA_MASK, /*!< Raw PHASEA input. */
|
||||
kENC_FilteredHOMEStatusFlag = ENC_IMR_FHOM_MASK, /*!< The filtered version of HOME input. */
|
||||
kENC_FilteredINDEXStatusFlag = ENC_IMR_FIND_MASK, /*!< The filtered version of INDEX input. */
|
||||
kENC_FilteredPHBStatusFlag = ENC_IMR_FPHB_MASK, /*!< The filtered version of PHASEB input. */
|
||||
kENC_FilteredPHAStatusFlag = ENC_IMR_FPHA_MASK, /*!< The filtered version of PHASEA input. */
|
||||
};
|
||||
|
||||
/*!
|
||||
* @brief Define HOME signal's trigger mode.
|
||||
*
|
||||
* The ENC would count the trigger from HOME signal line.
|
||||
*/
|
||||
typedef enum _enc_home_trigger_mode
|
||||
{
|
||||
kENC_HOMETriggerDisabled = 0U, /*!< HOME signal's trigger is disabled. */
|
||||
kENC_HOMETriggerOnRisingEdge, /*!< Use positive going edge-to-trigger initialization of position counters. */
|
||||
kENC_HOMETriggerOnFallingEdge, /*!< Use negative going edge-to-trigger initialization of position counters. */
|
||||
} enc_home_trigger_mode_t;
|
||||
|
||||
/*!
|
||||
* @brief Define INDEX signal's trigger mode.
|
||||
*
|
||||
* The ENC would count the trigger from INDEX signal line.
|
||||
*/
|
||||
typedef enum _enc_index_trigger_mode
|
||||
{
|
||||
kENC_INDEXTriggerDisabled = 0U, /*!< INDEX signal's trigger is disabled. */
|
||||
kENC_INDEXTriggerOnRisingEdge, /*!< Use positive going edge-to-trigger initialization of position counters. */
|
||||
kENC_INDEXTriggerOnFallingEdge, /*!< Use negative going edge-to-trigger initialization of position counters. */
|
||||
} enc_index_trigger_mode_t;
|
||||
|
||||
/*!
|
||||
* @brief Define type for decoder work mode.
|
||||
*
|
||||
* The normal work mode uses the standard quadrature decoder with PHASEA and PHASEB. When in signal phase count mode,
|
||||
* a positive transition of the PHASEA input generates a count signal while the PHASEB input and the reverse direction
|
||||
* control the counter direction. If the reverse direction is not enabled, PHASEB = 0 means counting up and PHASEB = 1
|
||||
* means counting down. Otherwise, the direction is reversed.
|
||||
*/
|
||||
typedef enum _enc_decoder_work_mode
|
||||
{
|
||||
kENC_DecoderWorkAsNormalMode = 0U, /*!< Use standard quadrature decoder with PHASEA and PHASEB. */
|
||||
kENC_DecoderWorkAsSignalPhaseCountMode, /*!< PHASEA input generates a count signal while PHASEB input control the
|
||||
direction. */
|
||||
} enc_decoder_work_mode_t;
|
||||
|
||||
/*!
|
||||
* @brief Define type for the condition of POSMATCH pulses.
|
||||
*/
|
||||
typedef enum _enc_position_match_mode
|
||||
{
|
||||
kENC_POSMATCHOnPositionCounterEqualToComapreValue = 0U, /*!< POSMATCH pulses when a match occurs between the
|
||||
position counters (POS) and the compare value (COMP). */
|
||||
kENC_POSMATCHOnReadingAnyPositionCounter, /*!< POSMATCH pulses when any position counter register is read. */
|
||||
} enc_position_match_mode_t;
|
||||
|
||||
/*!
|
||||
* @brief Define type for determining how the revolution counter (REV) is incremented/decremented.
|
||||
*/
|
||||
typedef enum _enc_revolution_count_condition
|
||||
{
|
||||
kENC_RevolutionCountOnINDEXPulse = 0U, /*!< Use INDEX pulse to increment/decrement revolution counter. */
|
||||
kENC_RevolutionCountOnRollOverModulus, /*!< Use modulus counting roll-over/under to increment/decrement revolution
|
||||
counter. */
|
||||
} enc_revolution_count_condition_t;
|
||||
|
||||
/*!
|
||||
* @brief Define type for direction of self test generated signal.
|
||||
*/
|
||||
typedef enum _enc_self_test_direction
|
||||
{
|
||||
kENC_SelfTestDirectionPositive = 0U, /*!< Self test generates the signal in positive direction. */
|
||||
kENC_SelfTestDirectionNegative, /*!< Self test generates the signal in negative direction. */
|
||||
} enc_self_test_direction_t;
|
||||
|
||||
/*!
|
||||
* @brief Define user configuration structure for ENC module.
|
||||
*/
|
||||
typedef struct _enc_config
|
||||
{
|
||||
/* Basic counter. */
|
||||
bool enableReverseDirection; /*!< Enable reverse direction counting. */
|
||||
enc_decoder_work_mode_t decoderWorkMode; /*!< Enable signal phase count mode. */
|
||||
|
||||
/* Signal detection. */
|
||||
enc_home_trigger_mode_t HOMETriggerMode; /*!< Enable HOME to initialize position counters. */
|
||||
enc_index_trigger_mode_t INDEXTriggerMode; /*!< Enable INDEX to initialize position counters. */
|
||||
bool enableTRIGGERClearPositionCounter; /*!< Clear POSD, REV, UPOS and LPOS on rising edge of TRIGGER, or not. */
|
||||
bool enableTRIGGERClearHoldPositionCounter; /*!< Enable update of hold registers on rising edge of TRIGGER, or not.
|
||||
*/
|
||||
|
||||
/* Watchdog. */
|
||||
bool enableWatchdog; /*!< Enable the watchdog to detect if the target is moving or not. */
|
||||
uint16_t watchdogTimeoutValue; /*!< Watchdog timeout count value. It stores the timeout count for the quadrature
|
||||
decoder module watchdog timer. This field is only available when
|
||||
"enableWatchdog" = true. The available value is a 16-bit unsigned number.*/
|
||||
|
||||
/* Filter for PHASEA, PHASEB, INDEX and HOME. */
|
||||
uint16_t filterCount; /*!< Input Filter Sample Count. This value should be chosen to reduce the probability of
|
||||
noisy samples causing an incorrect transition to be recognized. The value represent the
|
||||
number of consecutive samples that must agree prior to the input filter accepting an
|
||||
input transition. A value of 0x0 represents 3 samples. A value of 0x7 represents 10
|
||||
samples. The Available range is 0 - 7.*/
|
||||
uint16_t filterSamplePeriod; /*!< Input Filter Sample Period. This value should be set such that the sampling period
|
||||
is larger than the period of the expected noise. This value represents the
|
||||
sampling period (in IPBus clock cycles) of the decoder input signals.
|
||||
The available range is 0 - 255. */
|
||||
|
||||
/* Position compare. */
|
||||
enc_position_match_mode_t positionMatchMode; /*!< The condition of POSMATCH pulses. */
|
||||
uint32_t positionCompareValue; /*!< Position compare value. The available value is a 32-bit number.*/
|
||||
|
||||
/* Modulus counting. */
|
||||
enc_revolution_count_condition_t revolutionCountCondition; /*!< Revolution Counter Modulus Enable. */
|
||||
bool enableModuloCountMode; /*!< Enable Modulo Counting. */
|
||||
uint32_t positionModulusValue; /*!< Position modulus value. This value would be available only when
|
||||
"enableModuloCountMode" = true. The available value is a 32-bit number. */
|
||||
uint32_t positionInitialValue; /*!< Position initial value. The available value is a 32-bit number. */
|
||||
} enc_config_t;
|
||||
|
||||
/*!
|
||||
* @brief Define configuration structure for self test module.
|
||||
*
|
||||
* The self test module provides a quadrature test signal to the inputs of the quadrature decoder module.
|
||||
* This is a factory test feature. It is also useful to customers' software development and testing.
|
||||
*/
|
||||
typedef struct _enc_self_test_config
|
||||
{
|
||||
enc_self_test_direction_t signalDirection; /*!< Direction of self test generated signal. */
|
||||
uint16_t signalCount; /*!< Hold the number of quadrature advances to generate. The available range is 0 - 255.*/
|
||||
uint16_t signalPeriod; /*!< Hold the period of quadrature phase in IPBus clock cycles.
|
||||
The available range is 0 - 31. */
|
||||
} enc_self_test_config_t;
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
* API
|
||||
******************************************************************************/
|
||||
|
||||
/*!
|
||||
* @name Initialization and De-initialization
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @brief Initialization for the ENC module.
|
||||
*
|
||||
* This function is to make the initialization for the ENC module. It should be called firstly before any operation to
|
||||
* the ENC with the operations like:
|
||||
* - Enable the clock for ENC module.
|
||||
* - Configure the ENC's working attributes.
|
||||
*
|
||||
* @param base ENC peripheral base address.
|
||||
* @param config Pointer to configuration structure. See to "enc_config_t".
|
||||
*/
|
||||
void ENC_Init(ENC_Type *base, const enc_config_t *config);
|
||||
|
||||
/*!
|
||||
* @brief De-initialization for the ENC module.
|
||||
*
|
||||
* This function is to make the de-initialization for the ENC module. It could be called when ENC is no longer used with
|
||||
* the operations like:
|
||||
* - Disable the clock for ENC module.
|
||||
*
|
||||
* @param base ENC peripheral base address.
|
||||
*/
|
||||
void ENC_Deinit(ENC_Type *base);
|
||||
|
||||
/*!
|
||||
* @brief Get an available pre-defined settings for ENC's configuration.
|
||||
*
|
||||
* This function initializes the ENC configuration structure with an available settings, the default value are:
|
||||
* @code
|
||||
* config->enableReverseDirection = false;
|
||||
* config->decoderWorkMode = kENC_DecoderWorkAsNormalMode;
|
||||
* config->HOMETriggerMode = kENC_HOMETriggerDisabled;
|
||||
* config->INDEXTriggerMode = kENC_INDEXTriggerDisabled;
|
||||
* config->enableTRIGGERClearPositionCounter = false;
|
||||
* config->enableTRIGGERClearHoldPositionCounter = false;
|
||||
* config->enableWatchdog = false;
|
||||
* config->watchdogTimeoutValue = 0U;
|
||||
* config->filterCount = 0U;
|
||||
* config->filterSamplePeriod = 0U;
|
||||
* config->positionMatchMode = kENC_POSMATCHOnPositionCounterEqualToComapreValue;
|
||||
* config->positionCompareValue = 0xFFFFFFFFU;
|
||||
* config->revolutionCountCondition = kENC_RevolutionCountOnINDEXPulse;
|
||||
* config->enableModuloCountMode = false;
|
||||
* config->positionModulusValue = 0U;
|
||||
* config->positionInitialValue = 0U;
|
||||
* @endcode
|
||||
* @param config Pointer to a variable of configuration structure. See to "enc_config_t".
|
||||
*/
|
||||
void ENC_GetDefaultConfig(enc_config_t *config);
|
||||
|
||||
/*!
|
||||
* @brief Load the initial position value to position counter.
|
||||
*
|
||||
* This function is to transfer the initial position value (UINIT and LINIT) contents to position counter (UPOS and
|
||||
* LPOS), so that to provide the consistent operation the position counter registers.
|
||||
*
|
||||
* @param base ENC peripheral base address.
|
||||
*/
|
||||
void ENC_DoSoftwareLoadInitialPositionValue(ENC_Type *base);
|
||||
|
||||
/*!
|
||||
* @brief Enable and configure the self test function.
|
||||
*
|
||||
* This function is to enable and configuration the self test function. It controls and sets the frequency of a
|
||||
* quadrature signal generator. It provides a quadrature test signal to the inputs of the quadrature decoder module.
|
||||
* It is a factory test feature; however, it may be useful to customers' software development and testing.
|
||||
*
|
||||
* @param base ENC peripheral base address.
|
||||
* @param config Pointer to configuration structure. See to "enc_self_test_config_t". Pass "NULL" to disable.
|
||||
*/
|
||||
void ENC_SetSelfTestConfig(ENC_Type *base, const enc_self_test_config_t *config);
|
||||
|
||||
/*!
|
||||
* @brief Enable watchdog for ENC module.
|
||||
*
|
||||
* @param base ENC peripheral base address
|
||||
* @param enable Enables or disables the watchdog
|
||||
*/
|
||||
void ENC_EnableWatchdog(ENC_Type *base, bool enable);
|
||||
|
||||
/*!
|
||||
* @brief Set initial position value for ENC module.
|
||||
*
|
||||
* @param base ENC peripheral base address
|
||||
* @param value Positive initial value
|
||||
*/
|
||||
void ENC_SetInitialPositionValue(ENC_Type *base, uint32_t value);
|
||||
|
||||
/* @} */
|
||||
|
||||
/*!
|
||||
* @name Status
|
||||
* @{
|
||||
*/
|
||||
/*!
|
||||
* @brief Get the status flags.
|
||||
*
|
||||
* @param base ENC peripheral base address.
|
||||
*
|
||||
* @return Mask value of status flags. For available mask, see to "_enc_status_flags".
|
||||
*/
|
||||
uint32_t ENC_GetStatusFlags(ENC_Type *base);
|
||||
|
||||
/*!
|
||||
* @brief Clear the status flags.
|
||||
*
|
||||
* @param base ENC peripheral base address.
|
||||
* @param mask Mask value of status flags to be cleared. For available mask, see to "_enc_status_flags".
|
||||
*/
|
||||
void ENC_ClearStatusFlags(ENC_Type *base, uint32_t mask);
|
||||
|
||||
/*!
|
||||
* @brief Get the signals' real-time status.
|
||||
*
|
||||
* @param base ENC peripheral base address.
|
||||
*
|
||||
* @return Mask value of signals' real-time status. For available mask, see to "_enc_signal_status_flags"
|
||||
*/
|
||||
static inline uint16_t ENC_GetSignalStatusFlags(ENC_Type *base)
|
||||
{
|
||||
return base->IMR;
|
||||
}
|
||||
/* @} */
|
||||
|
||||
/*!
|
||||
* @name Interrupts
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @brief Enable the interrupts.
|
||||
*
|
||||
* @param base ENC peripheral base address.
|
||||
* @param mask Mask value of interrupts to be enabled. For available mask, see to "_enc_interrupt_enable".
|
||||
*/
|
||||
void ENC_EnableInterrupts(ENC_Type *base, uint32_t mask);
|
||||
|
||||
/*!
|
||||
* @brief Disable the interrupts.
|
||||
*
|
||||
* @param base ENC peripheral base address.
|
||||
* @param mask Mask value of interrupts to be disabled. For available mask, see to "_enc_interrupt_enable".
|
||||
*/
|
||||
void ENC_DisableInterrupts(ENC_Type *base, uint32_t mask);
|
||||
|
||||
/*!
|
||||
* @brief Get the enabled interrupts' flags.
|
||||
*
|
||||
* @param base ENC peripheral base address.
|
||||
*
|
||||
* @return Mask value of enabled interrupts.
|
||||
*/
|
||||
uint32_t ENC_GetEnabledInterrupts(ENC_Type *base);
|
||||
|
||||
/* @} */
|
||||
|
||||
/*!
|
||||
* @name Value Operation
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @brief Get the current position counter's value.
|
||||
*
|
||||
* @param base ENC peripheral base address.
|
||||
*
|
||||
* @return Current position counter's value.
|
||||
*/
|
||||
uint32_t ENC_GetPositionValue(ENC_Type *base);
|
||||
|
||||
/*!
|
||||
* @brief Get the hold position counter's value.
|
||||
*
|
||||
* When any of the counter registers is read, the contents of each counter register is written to the corresponding hold
|
||||
* register. Taking a snapshot of the counters' values provides a consistent view of a system position and a velocity to
|
||||
* be attained.
|
||||
*
|
||||
* @param base ENC peripheral base address.
|
||||
*
|
||||
* @return Hold position counter's value.
|
||||
*/
|
||||
uint32_t ENC_GetHoldPositionValue(ENC_Type *base);
|
||||
|
||||
/*!
|
||||
* @brief Get the position difference counter's value.
|
||||
*
|
||||
* @param base ENC peripheral base address.
|
||||
*
|
||||
* @return The position difference counter's value.
|
||||
*/
|
||||
static inline uint16_t ENC_GetPositionDifferenceValue(ENC_Type *base)
|
||||
{
|
||||
return base->POSD;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Get the hold position difference counter's value.
|
||||
*
|
||||
* When any of the counter registers is read, the contents of each counter register is written to the corresponding hold
|
||||
* register. Taking a snapshot of the counters' values provides a consistent view of a system position and a velocity to
|
||||
* be attained.
|
||||
*
|
||||
* @param base ENC peripheral base address.
|
||||
*
|
||||
* @return Hold position difference counter's value.
|
||||
*/
|
||||
static inline uint16_t ENC_GetHoldPositionDifferenceValue(ENC_Type *base)
|
||||
{
|
||||
return base->POSDH;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Get the position revolution counter's value.
|
||||
*
|
||||
* @param base ENC peripheral base address.
|
||||
*
|
||||
* @return The position revolution counter's value.
|
||||
*/
|
||||
static inline uint16_t ENC_GetRevolutionValue(ENC_Type *base)
|
||||
{
|
||||
return base->REV;
|
||||
}
|
||||
/*!
|
||||
* @brief Get the hold position revolution counter's value.
|
||||
*
|
||||
* When any of the counter registers is read, the contents of each counter register is written to the corresponding hold
|
||||
* register. Taking a snapshot of the counters' values provides a consistent view of a system position and a velocity to
|
||||
* be attained.
|
||||
*
|
||||
* @param base ENC peripheral base address.
|
||||
*
|
||||
* @return Hold position revolution counter's value.
|
||||
*/
|
||||
static inline uint16_t ENC_GetHoldRevolutionValue(ENC_Type *base)
|
||||
{
|
||||
return base->REVH;
|
||||
}
|
||||
|
||||
/* @} */
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* @} */
|
||||
|
||||
#endif /* _FSL_ENC_H_ */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,218 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016-2017, 2020 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
#ifndef _FSL_EWM_H_
|
||||
#define _FSL_EWM_H_
|
||||
|
||||
#include "fsl_common.h"
|
||||
|
||||
/*!
|
||||
* @addtogroup ewm
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
*******************************************************************************/
|
||||
|
||||
/*! @name Driver version */
|
||||
/*@{*/
|
||||
/*! @brief EWM driver version 2.0.2. */
|
||||
#define FSL_EWM_DRIVER_VERSION (MAKE_VERSION(2, 0, 2))
|
||||
/*@}*/
|
||||
|
||||
/*! @brief Describes EWM clock source. */
|
||||
#if defined(FSL_FEATURE_EWM_HAS_CLOCK_SELECT) && FSL_FEATURE_EWM_HAS_CLOCK_SELECT
|
||||
typedef enum _ewm_lpo_clock_source
|
||||
{
|
||||
kEWM_LpoClockSource0 = 0U, /*!< EWM clock sourced from lpo_clk[0]*/
|
||||
kEWM_LpoClockSource1 = 1U, /*!< EWM clock sourced from lpo_clk[1]*/
|
||||
kEWM_LpoClockSource2 = 2U, /*!< EWM clock sourced from lpo_clk[2]*/
|
||||
kEWM_LpoClockSource3 = 3U, /*!< EWM clock sourced from lpo_clk[3]*/
|
||||
} ewm_lpo_clock_source_t;
|
||||
#endif /* FSL_FEATURE_EWM_HAS_CLOCK_SELECT */
|
||||
|
||||
/*!
|
||||
* @brief Data structure for EWM configuration.
|
||||
*
|
||||
* This structure is used to configure the EWM.
|
||||
*/
|
||||
typedef struct _ewm_config
|
||||
{
|
||||
bool enableEwm; /*!< Enable EWM module */
|
||||
bool enableEwmInput; /*!< Enable EWM_in input */
|
||||
bool setInputAssertLogic; /*!< EWM_in signal assertion state */
|
||||
bool enableInterrupt; /*!< Enable EWM interrupt */
|
||||
#if defined(FSL_FEATURE_EWM_HAS_CLOCK_SELECT) && FSL_FEATURE_EWM_HAS_CLOCK_SELECT
|
||||
ewm_lpo_clock_source_t clockSource; /*!< Clock source select */
|
||||
#endif /* FSL_FEATURE_EWM_HAS_CLOCK_SELECT */
|
||||
#if defined(FSL_FEATURE_EWM_HAS_PRESCALER) && FSL_FEATURE_EWM_HAS_PRESCALER
|
||||
uint8_t prescaler; /*!< Clock prescaler value */
|
||||
#endif /* FSL_FEATURE_EWM_HAS_PRESCALER */
|
||||
uint8_t compareLowValue; /*!< Compare low-register value */
|
||||
uint8_t compareHighValue; /*!< Compare high-register value */
|
||||
} ewm_config_t;
|
||||
|
||||
/*!
|
||||
* @brief EWM interrupt configuration structure with default settings all disabled.
|
||||
*
|
||||
* This structure contains the settings for all of EWM interrupt configurations.
|
||||
*/
|
||||
enum _ewm_interrupt_enable_t
|
||||
{
|
||||
kEWM_InterruptEnable = EWM_CTRL_INTEN_MASK, /*!< Enable the EWM to generate an interrupt*/
|
||||
};
|
||||
|
||||
/*!
|
||||
* @brief EWM status flags.
|
||||
*
|
||||
* This structure contains the constants for the EWM status flags for use in the EWM functions.
|
||||
*/
|
||||
enum _ewm_status_flags_t
|
||||
{
|
||||
kEWM_RunningFlag = EWM_CTRL_EWMEN_MASK, /*!< Running flag, set when EWM is enabled*/
|
||||
};
|
||||
|
||||
/*******************************************************************************
|
||||
* API
|
||||
*******************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*!
|
||||
* @name EWM initialization and de-initialization
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @brief Initializes the EWM peripheral.
|
||||
*
|
||||
* This function is used to initialize the EWM. After calling, the EWM
|
||||
* runs immediately according to the configuration.
|
||||
* Note that, except for the interrupt enable control bit, other control bits and registers are write once after a
|
||||
* CPU reset. Modifying them more than once generates a bus transfer error.
|
||||
*
|
||||
* This is an example.
|
||||
* @code
|
||||
* ewm_config_t config;
|
||||
* EWM_GetDefaultConfig(&config);
|
||||
* config.compareHighValue = 0xAAU;
|
||||
* EWM_Init(ewm_base,&config);
|
||||
* @endcode
|
||||
*
|
||||
* @param base EWM peripheral base address
|
||||
* @param config The configuration of the EWM
|
||||
*/
|
||||
void EWM_Init(EWM_Type *base, const ewm_config_t *config);
|
||||
|
||||
/*!
|
||||
* @brief Deinitializes the EWM peripheral.
|
||||
*
|
||||
* This function is used to shut down the EWM.
|
||||
*
|
||||
* @param base EWM peripheral base address
|
||||
*/
|
||||
void EWM_Deinit(EWM_Type *base);
|
||||
|
||||
/*!
|
||||
* @brief Initializes the EWM configuration structure.
|
||||
*
|
||||
* This function initializes the EWM configuration structure to default values. The default
|
||||
* values are as follows.
|
||||
* @code
|
||||
* ewmConfig->enableEwm = true;
|
||||
* ewmConfig->enableEwmInput = false;
|
||||
* ewmConfig->setInputAssertLogic = false;
|
||||
* ewmConfig->enableInterrupt = false;
|
||||
* ewmConfig->ewm_lpo_clock_source_t = kEWM_LpoClockSource0;
|
||||
* ewmConfig->prescaler = 0;
|
||||
* ewmConfig->compareLowValue = 0;
|
||||
* ewmConfig->compareHighValue = 0xFEU;
|
||||
* @endcode
|
||||
*
|
||||
* @param config Pointer to the EWM configuration structure.
|
||||
* @see ewm_config_t
|
||||
*/
|
||||
void EWM_GetDefaultConfig(ewm_config_t *config);
|
||||
|
||||
/* @} */
|
||||
|
||||
/*!
|
||||
* @name EWM functional Operation
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @brief Enables the EWM interrupt.
|
||||
*
|
||||
* This function enables the EWM interrupt.
|
||||
*
|
||||
* @param base EWM peripheral base address
|
||||
* @param mask The interrupts to enable
|
||||
* The parameter can be combination of the following source if defined
|
||||
* @arg kEWM_InterruptEnable
|
||||
*/
|
||||
static inline void EWM_EnableInterrupts(EWM_Type *base, uint32_t mask)
|
||||
{
|
||||
base->CTRL |= (uint8_t)mask;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Disables the EWM interrupt.
|
||||
*
|
||||
* This function enables the EWM interrupt.
|
||||
*
|
||||
* @param base EWM peripheral base address
|
||||
* @param mask The interrupts to disable
|
||||
* The parameter can be combination of the following source if defined
|
||||
* @arg kEWM_InterruptEnable
|
||||
*/
|
||||
static inline void EWM_DisableInterrupts(EWM_Type *base, uint32_t mask)
|
||||
{
|
||||
base->CTRL &= (uint8_t)(~mask);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Gets all status flags.
|
||||
*
|
||||
* This function gets all status flags.
|
||||
*
|
||||
* This is an example for getting the running flag.
|
||||
* @code
|
||||
* uint32_t status;
|
||||
* status = EWM_GetStatusFlags(ewm_base) & kEWM_RunningFlag;
|
||||
* @endcode
|
||||
* @param base EWM peripheral base address
|
||||
* @return State of the status flag: asserted (true) or not-asserted (false).@see _ewm_status_flags_t
|
||||
* - True: a related status flag has been set.
|
||||
* - False: a related status flag is not set.
|
||||
*/
|
||||
static inline uint32_t EWM_GetStatusFlags(EWM_Type *base)
|
||||
{
|
||||
return ((uint32_t)base->CTRL & EWM_CTRL_EWMEN_MASK);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Services the EWM.
|
||||
*
|
||||
* This function resets the EWM counter to zero.
|
||||
*
|
||||
* @param base EWM peripheral base address
|
||||
*/
|
||||
void EWM_Refresh(EWM_Type *base);
|
||||
|
||||
/*@}*/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*! @}*/
|
||||
|
||||
#endif /* _FSL_EWM_H_ */
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,230 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016-2020 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#ifndef _FSL_FLEXIO_CAMERA_H_
|
||||
#define _FSL_FLEXIO_CAMERA_H_
|
||||
|
||||
#include "fsl_common.h"
|
||||
#include "fsl_flexio.h"
|
||||
/*!
|
||||
* @addtogroup flexio_camera
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
|
||||
/*! @name Driver version */
|
||||
/*@{*/
|
||||
/*! @brief FlexIO Camera driver version 2.1.3. */
|
||||
#define FSL_FLEXIO_CAMERA_DRIVER_VERSION (MAKE_VERSION(2, 1, 3))
|
||||
/*@}*/
|
||||
|
||||
/*! @brief Define the Camera CPI interface is constantly 8-bit width. */
|
||||
#define FLEXIO_CAMERA_PARALLEL_DATA_WIDTH (8U)
|
||||
|
||||
/*! @brief Error codes for the Camera driver. */
|
||||
enum
|
||||
{
|
||||
kStatus_FLEXIO_CAMERA_RxBusy = MAKE_STATUS(kStatusGroup_FLEXIO_CAMERA, 0), /*!< Receiver is busy. */
|
||||
kStatus_FLEXIO_CAMERA_RxIdle = MAKE_STATUS(kStatusGroup_FLEXIO_CAMERA, 1), /*!< Camera receiver is idle. */
|
||||
};
|
||||
|
||||
/*! @brief Define FlexIO Camera status mask. */
|
||||
enum _flexio_camera_status_flags
|
||||
{
|
||||
kFLEXIO_CAMERA_RxDataRegFullFlag = 0x1U, /*!< Receive buffer full flag. */
|
||||
kFLEXIO_CAMERA_RxErrorFlag = 0x2U, /*!< Receive buffer error flag. */
|
||||
};
|
||||
|
||||
/*!
|
||||
* @brief Define structure of configuring the FlexIO Camera device.
|
||||
*/
|
||||
typedef struct _flexio_camera_type
|
||||
{
|
||||
FLEXIO_Type *flexioBase; /*!< FlexIO module base address. */
|
||||
uint32_t datPinStartIdx; /*!< First data pin (D0) index for flexio_camera.
|
||||
Then the successive following FLEXIO_CAMERA_DATA_WIDTH-1 pins
|
||||
are used as D1-D7.*/
|
||||
uint32_t pclkPinIdx; /*!< Pixel clock pin (PCLK) index for flexio_camera. */
|
||||
uint32_t hrefPinIdx; /*!< Horizontal sync pin (HREF) index for flexio_camera. */
|
||||
|
||||
uint32_t shifterStartIdx; /*!< First shifter index used for flexio_camera data FIFO. */
|
||||
uint32_t shifterCount; /*!< The count of shifters that are used as flexio_camera data FIFO. */
|
||||
uint32_t timerIdx; /*!< Timer index used for flexio_camera in FlexIO. */
|
||||
} FLEXIO_CAMERA_Type;
|
||||
|
||||
/*! @brief Define FlexIO Camera user configuration structure. */
|
||||
typedef struct _flexio_camera_config
|
||||
{
|
||||
bool enablecamera; /*!< Enable/disable FlexIO Camera TX & RX. */
|
||||
bool enableInDoze; /*!< Enable/disable FlexIO operation in doze mode*/
|
||||
bool enableInDebug; /*!< Enable/disable FlexIO operation in debug mode*/
|
||||
bool enableFastAccess; /*!< Enable/disable fast access to FlexIO registers,
|
||||
fast access requires the FlexIO clock to be at least
|
||||
twice the frequency of the bus clock. */
|
||||
} flexio_camera_config_t;
|
||||
|
||||
/*! @brief Define FlexIO Camera transfer structure. */
|
||||
typedef struct _flexio_camera_transfer
|
||||
{
|
||||
uint32_t dataAddress; /*!< Transfer buffer*/
|
||||
uint32_t dataNum; /*!< Transfer num*/
|
||||
} flexio_camera_transfer_t;
|
||||
|
||||
/*******************************************************************************
|
||||
* API
|
||||
******************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif /*_cplusplus*/
|
||||
|
||||
/*!
|
||||
* @name Initialization and configuration
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @brief Ungates the FlexIO clock, resets the FlexIO module, and configures the FlexIO Camera.
|
||||
*
|
||||
* @param base Pointer to FLEXIO_CAMERA_Type structure
|
||||
* @param config Pointer to flexio_camera_config_t structure
|
||||
*/
|
||||
void FLEXIO_CAMERA_Init(FLEXIO_CAMERA_Type *base, const flexio_camera_config_t *config);
|
||||
|
||||
/*!
|
||||
* @brief Resets the FLEXIO_CAMERA shifer and timer config.
|
||||
*
|
||||
* @note After calling this API, call FLEXO_CAMERA_Init to use the FlexIO Camera module.
|
||||
*
|
||||
* @param base Pointer to FLEXIO_CAMERA_Type structure
|
||||
*/
|
||||
void FLEXIO_CAMERA_Deinit(FLEXIO_CAMERA_Type *base);
|
||||
|
||||
/*!
|
||||
* @brief Gets the default configuration to configure the FlexIO Camera. The configuration
|
||||
* can be used directly for calling the FLEXIO_CAMERA_Init().
|
||||
* Example:
|
||||
@code
|
||||
flexio_camera_config_t config;
|
||||
FLEXIO_CAMERA_GetDefaultConfig(&userConfig);
|
||||
@endcode
|
||||
* @param config Pointer to the flexio_camera_config_t structure
|
||||
*/
|
||||
void FLEXIO_CAMERA_GetDefaultConfig(flexio_camera_config_t *config);
|
||||
|
||||
/*!
|
||||
* @brief Enables/disables the FlexIO Camera module operation.
|
||||
*
|
||||
* @param base Pointer to the FLEXIO_CAMERA_Type
|
||||
* @param enable True to enable, false does not have any effect.
|
||||
*/
|
||||
static inline void FLEXIO_CAMERA_Enable(FLEXIO_CAMERA_Type *base, bool enable)
|
||||
{
|
||||
if (enable)
|
||||
{
|
||||
base->flexioBase->CTRL |= FLEXIO_CTRL_FLEXEN_MASK;
|
||||
}
|
||||
}
|
||||
|
||||
/*! @} */
|
||||
|
||||
/*!
|
||||
* @name Status
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @brief Gets the FlexIO Camera status flags.
|
||||
*
|
||||
* @param base Pointer to FLEXIO_CAMERA_Type structure
|
||||
* @return FlexIO shifter status flags
|
||||
* @arg FLEXIO_SHIFTSTAT_SSF_MASK
|
||||
* @arg 0
|
||||
*/
|
||||
uint32_t FLEXIO_CAMERA_GetStatusFlags(FLEXIO_CAMERA_Type *base);
|
||||
|
||||
/*!
|
||||
* @brief Clears the receive buffer full flag manually.
|
||||
*
|
||||
* @param base Pointer to the device.
|
||||
* @param mask status flag
|
||||
* The parameter can be any combination of the following values:
|
||||
* @arg kFLEXIO_CAMERA_RxDataRegFullFlag
|
||||
* @arg kFLEXIO_CAMERA_RxErrorFlag
|
||||
*/
|
||||
void FLEXIO_CAMERA_ClearStatusFlags(FLEXIO_CAMERA_Type *base, uint32_t mask);
|
||||
|
||||
/* @} */
|
||||
|
||||
/*!
|
||||
* @name Interrupts
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @brief Switches on the interrupt for receive buffer full event.
|
||||
*
|
||||
* @param base Pointer to the device.
|
||||
*/
|
||||
void FLEXIO_CAMERA_EnableInterrupt(FLEXIO_CAMERA_Type *base);
|
||||
|
||||
/*!
|
||||
* @brief Switches off the interrupt for receive buffer full event.
|
||||
*
|
||||
* @param base Pointer to the device.
|
||||
*
|
||||
*/
|
||||
void FLEXIO_CAMERA_DisableInterrupt(FLEXIO_CAMERA_Type *base);
|
||||
|
||||
/*! @} */
|
||||
|
||||
/*!
|
||||
* @name DMA support
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @brief Enables/disables the FlexIO Camera receive DMA.
|
||||
*
|
||||
* @param base Pointer to FLEXIO_CAMERA_Type structure
|
||||
* @param enable True to enable, false to disable.
|
||||
*
|
||||
* The FlexIO Camera mode can't work without the DMA or eDMA support,
|
||||
* Usually, it needs at least two DMA or eDMA channels, one for transferring data from
|
||||
* Camera, such as 0V7670 to FlexIO buffer, another is for transferring data from FlexIO
|
||||
* buffer to LCD.
|
||||
*
|
||||
*/
|
||||
static inline void FLEXIO_CAMERA_EnableRxDMA(FLEXIO_CAMERA_Type *base, bool enable)
|
||||
{
|
||||
FLEXIO_EnableShifterStatusDMA(base->flexioBase, 1UL << base->shifterStartIdx, enable);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Gets the data from the receive buffer.
|
||||
*
|
||||
* @param base Pointer to the device.
|
||||
* @return data Pointer to the buffer that keeps the data with count of base->shifterCount .
|
||||
*/
|
||||
static inline uint32_t FLEXIO_CAMERA_GetRxBufferAddress(FLEXIO_CAMERA_Type *base)
|
||||
{
|
||||
return FLEXIO_GetShifterBufferAddress(base->flexioBase, kFLEXIO_ShifterBuffer, (uint8_t)base->shifterStartIdx);
|
||||
}
|
||||
|
||||
/*! @} */
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif /*_cplusplus*/
|
||||
|
||||
/*@}*/
|
||||
|
||||
#endif /*_FSL_FLEXIO_CAMERA_H_*/
|
||||
@@ -1,130 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016-2020 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
#ifndef _FSL_FLEXIO_CAMERA_EDMA_H_
|
||||
#define _FSL_FLEXIO_CAMERA_EDMA_H_
|
||||
|
||||
#include "fsl_flexio_camera.h"
|
||||
#include "fsl_edma.h"
|
||||
|
||||
/*!
|
||||
* @addtogroup flexio_edma_camera
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
|
||||
/*! @name Driver version */
|
||||
/*@{*/
|
||||
/*! @brief FlexIO Camera EDMA driver version 2.1.3. */
|
||||
#define FSL_FLEXIO_CAMERA_EDMA_DRIVER_VERSION (MAKE_VERSION(2, 1, 3))
|
||||
/*@}*/
|
||||
|
||||
/*! @brief Forward declaration of the handle typedef. */
|
||||
typedef struct _flexio_camera_edma_handle flexio_camera_edma_handle_t;
|
||||
|
||||
/*! @brief Camera transfer callback function. */
|
||||
typedef void (*flexio_camera_edma_transfer_callback_t)(FLEXIO_CAMERA_Type *base,
|
||||
flexio_camera_edma_handle_t *handle,
|
||||
status_t status,
|
||||
void *userData);
|
||||
|
||||
/*!
|
||||
* @brief Camera eDMA handle
|
||||
*/
|
||||
struct _flexio_camera_edma_handle
|
||||
{
|
||||
flexio_camera_edma_transfer_callback_t callback; /*!< Callback function. */
|
||||
void *userData; /*!< Camera callback function parameter.*/
|
||||
size_t rxSize; /*!< Total bytes to be received. */
|
||||
edma_handle_t *rxEdmaHandle; /*!< The eDMA RX channel used. */
|
||||
uint8_t nbytes; /*!< eDMA minor byte transfer count initially configured. */
|
||||
volatile uint8_t rxState; /*!< RX transfer state */
|
||||
};
|
||||
|
||||
/*******************************************************************************
|
||||
* API
|
||||
******************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* @name eDMA transactional
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @brief Initializes the Camera handle, which is used in transactional functions.
|
||||
*
|
||||
* @param base Pointer to the FLEXIO_CAMERA_Type.
|
||||
* @param handle Pointer to flexio_camera_edma_handle_t structure.
|
||||
* @param callback The callback function.
|
||||
* @param userData The parameter of the callback function.
|
||||
* @param rxEdmaHandle User requested DMA handle for RX DMA transfer.
|
||||
* @retval kStatus_Success Successfully create the handle.
|
||||
* @retval kStatus_OutOfRange The FlexIO Camera eDMA type/handle table out of range.
|
||||
*/
|
||||
status_t FLEXIO_CAMERA_TransferCreateHandleEDMA(FLEXIO_CAMERA_Type *base,
|
||||
flexio_camera_edma_handle_t *handle,
|
||||
flexio_camera_edma_transfer_callback_t callback,
|
||||
void *userData,
|
||||
edma_handle_t *rxEdmaHandle);
|
||||
|
||||
/*!
|
||||
* @brief Receives data using eDMA.
|
||||
*
|
||||
* This function receives data using eDMA. This is a non-blocking function, which returns
|
||||
* right away. When all data is received, the receive callback function is called.
|
||||
*
|
||||
* @param base Pointer to the FLEXIO_CAMERA_Type.
|
||||
* @param handle Pointer to the flexio_camera_edma_handle_t structure.
|
||||
* @param xfer Camera eDMA transfer structure, see #flexio_camera_transfer_t.
|
||||
* @retval kStatus_Success if succeeded, others failed.
|
||||
* @retval kStatus_CAMERA_RxBusy Previous transfer on going.
|
||||
*/
|
||||
status_t FLEXIO_CAMERA_TransferReceiveEDMA(FLEXIO_CAMERA_Type *base,
|
||||
flexio_camera_edma_handle_t *handle,
|
||||
flexio_camera_transfer_t *xfer);
|
||||
|
||||
/*!
|
||||
* @brief Aborts the receive data which used the eDMA.
|
||||
*
|
||||
* This function aborts the receive data which used the eDMA.
|
||||
*
|
||||
* @param base Pointer to the FLEXIO_CAMERA_Type.
|
||||
* @param handle Pointer to the flexio_camera_edma_handle_t structure.
|
||||
*/
|
||||
void FLEXIO_CAMERA_TransferAbortReceiveEDMA(FLEXIO_CAMERA_Type *base, flexio_camera_edma_handle_t *handle);
|
||||
|
||||
/*!
|
||||
* @brief Gets the remaining bytes to be received.
|
||||
*
|
||||
* This function gets the number of bytes still not received.
|
||||
*
|
||||
* @param base Pointer to the FLEXIO_CAMERA_Type.
|
||||
* @param handle Pointer to the flexio_camera_edma_handle_t structure.
|
||||
* @param count Number of bytes sent so far by the non-blocking transaction.
|
||||
* @retval kStatus_Success Succeed get the transfer count.
|
||||
* @retval kStatus_InvalidArgument The count parameter is invalid.
|
||||
*/
|
||||
status_t FLEXIO_CAMERA_TransferGetReceiveCountEDMA(FLEXIO_CAMERA_Type *base,
|
||||
flexio_camera_edma_handle_t *handle,
|
||||
size_t *count);
|
||||
|
||||
/*@}*/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
/*! @}*/
|
||||
|
||||
#endif /* _FSL_CAMERA_EDMA_H_ */
|
||||
@@ -1,486 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016-2020 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
#ifndef _FSL_FLEXIO_I2C_MASTER_H_
|
||||
#define _FSL_FLEXIO_I2C_MASTER_H_
|
||||
|
||||
#include "fsl_common.h"
|
||||
#include "fsl_flexio.h"
|
||||
|
||||
/*!
|
||||
* @addtogroup flexio_i2c_master
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
|
||||
/*! @name Driver version */
|
||||
/*@{*/
|
||||
/*! @brief FlexIO I2C master driver version 2.4.0. */
|
||||
#define FSL_FLEXIO_I2C_MASTER_DRIVER_VERSION (MAKE_VERSION(2, 4, 0))
|
||||
/*@}*/
|
||||
|
||||
/*! @brief Retry times for waiting flag. */
|
||||
#ifndef I2C_RETRY_TIMES
|
||||
#define I2C_RETRY_TIMES 0U /* Define to zero means keep waiting until the flag is assert/deassert. */
|
||||
#endif
|
||||
|
||||
/*! @brief FlexIO I2C transfer status*/
|
||||
enum
|
||||
{
|
||||
kStatus_FLEXIO_I2C_Busy = MAKE_STATUS(kStatusGroup_FLEXIO_I2C, 0), /*!< I2C is busy doing transfer. */
|
||||
kStatus_FLEXIO_I2C_Idle = MAKE_STATUS(kStatusGroup_FLEXIO_I2C, 1), /*!< I2C is busy doing transfer. */
|
||||
kStatus_FLEXIO_I2C_Nak = MAKE_STATUS(kStatusGroup_FLEXIO_I2C, 2), /*!< NAK received during transfer. */
|
||||
kStatus_FLEXIO_I2C_Timeout = MAKE_STATUS(kStatusGroup_FLEXIO_I2C, 3), /*!< Timeout polling status flags. */
|
||||
};
|
||||
|
||||
/*! @brief Define FlexIO I2C master interrupt mask. */
|
||||
enum _flexio_i2c_master_interrupt
|
||||
{
|
||||
kFLEXIO_I2C_TxEmptyInterruptEnable = 0x1U, /*!< Tx buffer empty interrupt enable. */
|
||||
kFLEXIO_I2C_RxFullInterruptEnable = 0x2U, /*!< Rx buffer full interrupt enable. */
|
||||
};
|
||||
|
||||
/*! @brief Define FlexIO I2C master status mask. */
|
||||
enum _flexio_i2c_master_status_flags
|
||||
{
|
||||
kFLEXIO_I2C_TxEmptyFlag = 0x1U, /*!< Tx shifter empty flag. */
|
||||
kFLEXIO_I2C_RxFullFlag = 0x2U, /*!< Rx shifter full/Transfer complete flag. */
|
||||
kFLEXIO_I2C_ReceiveNakFlag = 0x4U, /*!< Receive NAK flag. */
|
||||
};
|
||||
|
||||
/*! @brief Direction of master transfer.*/
|
||||
typedef enum _flexio_i2c_direction
|
||||
{
|
||||
kFLEXIO_I2C_Write = 0x0U, /*!< Master send to slave. */
|
||||
kFLEXIO_I2C_Read = 0x1U, /*!< Master receive from slave. */
|
||||
} flexio_i2c_direction_t;
|
||||
|
||||
/*! @brief Define FlexIO I2C master access structure typedef. */
|
||||
typedef struct _flexio_i2c_type
|
||||
{
|
||||
FLEXIO_Type *flexioBase; /*!< FlexIO base pointer. */
|
||||
uint8_t SDAPinIndex; /*!< Pin select for I2C SDA. */
|
||||
uint8_t SCLPinIndex; /*!< Pin select for I2C SCL. */
|
||||
uint8_t shifterIndex[2]; /*!< Shifter index used in FlexIO I2C. */
|
||||
uint8_t timerIndex[3]; /*!< Timer index used in FlexIO I2C. */
|
||||
uint32_t baudrate; /*!< Master transfer baudrate, used to calculate delay time. */
|
||||
} FLEXIO_I2C_Type;
|
||||
|
||||
/*! @brief Define FlexIO I2C master user configuration structure. */
|
||||
typedef struct _flexio_i2c_master_config
|
||||
{
|
||||
bool enableMaster; /*!< Enables the FlexIO I2C peripheral at initialization time. */
|
||||
bool enableInDoze; /*!< Enable/disable FlexIO operation in doze mode. */
|
||||
bool enableInDebug; /*!< Enable/disable FlexIO operation in debug mode. */
|
||||
bool enableFastAccess; /*!< Enable/disable fast access to FlexIO registers, fast access requires
|
||||
the FlexIO clock to be at least twice the frequency of the bus clock. */
|
||||
uint32_t baudRate_Bps; /*!< Baud rate in Bps. */
|
||||
} flexio_i2c_master_config_t;
|
||||
|
||||
/*! @brief Define FlexIO I2C master transfer structure. */
|
||||
typedef struct _flexio_i2c_master_transfer
|
||||
{
|
||||
uint32_t flags; /*!< Transfer flag which controls the transfer, reserved for FlexIO I2C. */
|
||||
uint8_t slaveAddress; /*!< 7-bit slave address. */
|
||||
flexio_i2c_direction_t direction; /*!< Transfer direction, read or write. */
|
||||
uint32_t subaddress; /*!< Sub address. Transferred MSB first. */
|
||||
uint8_t subaddressSize; /*!< Size of command buffer. */
|
||||
uint8_t volatile *data; /*!< Transfer buffer. */
|
||||
volatile size_t dataSize; /*!< Transfer size. */
|
||||
} flexio_i2c_master_transfer_t;
|
||||
|
||||
/*! @brief FlexIO I2C master handle typedef. */
|
||||
typedef struct _flexio_i2c_master_handle flexio_i2c_master_handle_t;
|
||||
|
||||
/*! @brief FlexIO I2C master transfer callback typedef. */
|
||||
typedef void (*flexio_i2c_master_transfer_callback_t)(FLEXIO_I2C_Type *base,
|
||||
flexio_i2c_master_handle_t *handle,
|
||||
status_t status,
|
||||
void *userData);
|
||||
|
||||
/*! @brief Define FlexIO I2C master handle structure. */
|
||||
struct _flexio_i2c_master_handle
|
||||
{
|
||||
flexio_i2c_master_transfer_t transfer; /*!< FlexIO I2C master transfer copy. */
|
||||
size_t transferSize; /*!< Total bytes to be transferred. */
|
||||
uint8_t state; /*!< Transfer state maintained during transfer. */
|
||||
flexio_i2c_master_transfer_callback_t completionCallback; /*!< Callback function called at transfer event. */
|
||||
/*!< Callback function called at transfer event. */
|
||||
void *userData; /*!< Callback parameter passed to callback function. */
|
||||
bool needRestart; /*!< Whether master needs to send re-start signal. */
|
||||
};
|
||||
|
||||
/*******************************************************************************
|
||||
* API
|
||||
******************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif /*_cplusplus*/
|
||||
|
||||
/*!
|
||||
* @name Initialization and deinitialization
|
||||
* @{
|
||||
*/
|
||||
|
||||
#if defined(FSL_FEATURE_FLEXIO_HAS_PIN_STATUS) && FSL_FEATURE_FLEXIO_HAS_PIN_STATUS
|
||||
/*!
|
||||
* @brief Make sure the bus isn't already pulled down.
|
||||
*
|
||||
* Check the FLEXIO pin status to see whether either of SDA and SCL pin is pulled down.
|
||||
*
|
||||
* @param base Pointer to FLEXIO_I2C_Type structure..
|
||||
* @retval kStatus_Success
|
||||
* @retval kStatus_FLEXIO_I2C_Busy
|
||||
*/
|
||||
status_t FLEXIO_I2C_CheckForBusyBus(FLEXIO_I2C_Type *base);
|
||||
#endif /*FSL_FEATURE_FLEXIO_HAS_PIN_STATUS*/
|
||||
|
||||
/*!
|
||||
* @brief Ungates the FlexIO clock, resets the FlexIO module, and configures the FlexIO I2C
|
||||
* hardware configuration.
|
||||
*
|
||||
* Example
|
||||
@code
|
||||
FLEXIO_I2C_Type base = {
|
||||
.flexioBase = FLEXIO,
|
||||
.SDAPinIndex = 0,
|
||||
.SCLPinIndex = 1,
|
||||
.shifterIndex = {0,1},
|
||||
.timerIndex = {0,1}
|
||||
};
|
||||
flexio_i2c_master_config_t config = {
|
||||
.enableInDoze = false,
|
||||
.enableInDebug = true,
|
||||
.enableFastAccess = false,
|
||||
.baudRate_Bps = 100000
|
||||
};
|
||||
FLEXIO_I2C_MasterInit(base, &config, srcClock_Hz);
|
||||
@endcode
|
||||
*
|
||||
* @param base Pointer to FLEXIO_I2C_Type structure.
|
||||
* @param masterConfig Pointer to flexio_i2c_master_config_t structure.
|
||||
* @param srcClock_Hz FlexIO source clock in Hz.
|
||||
* @retval kStatus_Success Initialization successful
|
||||
* @retval kStatus_InvalidArgument The source clock exceed upper range limitation
|
||||
*/
|
||||
status_t FLEXIO_I2C_MasterInit(FLEXIO_I2C_Type *base, flexio_i2c_master_config_t *masterConfig, uint32_t srcClock_Hz);
|
||||
|
||||
/*!
|
||||
* @brief De-initializes the FlexIO I2C master peripheral. Calling this API Resets the FlexIO I2C master
|
||||
* shifer and timer config, module can't work unless the FLEXIO_I2C_MasterInit is called.
|
||||
*
|
||||
* @param base pointer to FLEXIO_I2C_Type structure.
|
||||
*/
|
||||
void FLEXIO_I2C_MasterDeinit(FLEXIO_I2C_Type *base);
|
||||
|
||||
/*!
|
||||
* @brief Gets the default configuration to configure the FlexIO module. The configuration
|
||||
* can be used directly for calling the FLEXIO_I2C_MasterInit().
|
||||
*
|
||||
* Example:
|
||||
@code
|
||||
flexio_i2c_master_config_t config;
|
||||
FLEXIO_I2C_MasterGetDefaultConfig(&config);
|
||||
@endcode
|
||||
* @param masterConfig Pointer to flexio_i2c_master_config_t structure.
|
||||
*/
|
||||
void FLEXIO_I2C_MasterGetDefaultConfig(flexio_i2c_master_config_t *masterConfig);
|
||||
|
||||
/*!
|
||||
* @brief Enables/disables the FlexIO module operation.
|
||||
*
|
||||
* @param base Pointer to FLEXIO_I2C_Type structure.
|
||||
* @param enable Pass true to enable module, false does not have any effect.
|
||||
*/
|
||||
static inline void FLEXIO_I2C_MasterEnable(FLEXIO_I2C_Type *base, bool enable)
|
||||
{
|
||||
if (enable)
|
||||
{
|
||||
base->flexioBase->CTRL |= FLEXIO_CTRL_FLEXEN_MASK;
|
||||
}
|
||||
}
|
||||
|
||||
/* @} */
|
||||
|
||||
/*!
|
||||
* @name Status
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @brief Gets the FlexIO I2C master status flags.
|
||||
*
|
||||
* @param base Pointer to FLEXIO_I2C_Type structure
|
||||
* @return Status flag, use status flag to AND #_flexio_i2c_master_status_flags can get the related status.
|
||||
*/
|
||||
|
||||
uint32_t FLEXIO_I2C_MasterGetStatusFlags(FLEXIO_I2C_Type *base);
|
||||
|
||||
/*!
|
||||
* @brief Clears the FlexIO I2C master status flags.
|
||||
*
|
||||
* @param base Pointer to FLEXIO_I2C_Type structure.
|
||||
* @param mask Status flag.
|
||||
* The parameter can be any combination of the following values:
|
||||
* @arg kFLEXIO_I2C_RxFullFlag
|
||||
* @arg kFLEXIO_I2C_ReceiveNakFlag
|
||||
*/
|
||||
|
||||
void FLEXIO_I2C_MasterClearStatusFlags(FLEXIO_I2C_Type *base, uint32_t mask);
|
||||
|
||||
/*@}*/
|
||||
|
||||
/*!
|
||||
* @name Interrupts
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @brief Enables the FlexIO i2c master interrupt requests.
|
||||
*
|
||||
* @param base Pointer to FLEXIO_I2C_Type structure.
|
||||
* @param mask Interrupt source.
|
||||
* Currently only one interrupt request source:
|
||||
* @arg kFLEXIO_I2C_TransferCompleteInterruptEnable
|
||||
*/
|
||||
void FLEXIO_I2C_MasterEnableInterrupts(FLEXIO_I2C_Type *base, uint32_t mask);
|
||||
|
||||
/*!
|
||||
* @brief Disables the FlexIO I2C master interrupt requests.
|
||||
*
|
||||
* @param base Pointer to FLEXIO_I2C_Type structure.
|
||||
* @param mask Interrupt source.
|
||||
*/
|
||||
void FLEXIO_I2C_MasterDisableInterrupts(FLEXIO_I2C_Type *base, uint32_t mask);
|
||||
|
||||
/*@}*/
|
||||
|
||||
/*!
|
||||
* @name Bus Operations
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @brief Sets the FlexIO I2C master transfer baudrate.
|
||||
*
|
||||
* @param base Pointer to FLEXIO_I2C_Type structure
|
||||
* @param baudRate_Bps the baud rate value in HZ
|
||||
* @param srcClock_Hz source clock in HZ
|
||||
*/
|
||||
void FLEXIO_I2C_MasterSetBaudRate(FLEXIO_I2C_Type *base, uint32_t baudRate_Bps, uint32_t srcClock_Hz);
|
||||
|
||||
/*!
|
||||
* @brief Sends START + 7-bit address to the bus.
|
||||
*
|
||||
* @note This API should be called when the transfer configuration is ready to send a START signal
|
||||
* and 7-bit address to the bus. This is a non-blocking API, which returns directly after the address
|
||||
* is put into the data register but the address transfer is not finished on the bus. Ensure that
|
||||
* the kFLEXIO_I2C_RxFullFlag status is asserted before calling this API.
|
||||
* @param base Pointer to FLEXIO_I2C_Type structure.
|
||||
* @param address 7-bit address.
|
||||
* @param direction transfer direction.
|
||||
* This parameter is one of the values in flexio_i2c_direction_t:
|
||||
* @arg kFLEXIO_I2C_Write: Transmit
|
||||
* @arg kFLEXIO_I2C_Read: Receive
|
||||
*/
|
||||
|
||||
void FLEXIO_I2C_MasterStart(FLEXIO_I2C_Type *base, uint8_t address, flexio_i2c_direction_t direction);
|
||||
|
||||
/*!
|
||||
* @brief Sends the stop signal on the bus.
|
||||
*
|
||||
* @param base Pointer to FLEXIO_I2C_Type structure.
|
||||
*/
|
||||
void FLEXIO_I2C_MasterStop(FLEXIO_I2C_Type *base);
|
||||
|
||||
/*!
|
||||
* @brief Sends the repeated start signal on the bus.
|
||||
*
|
||||
* @param base Pointer to FLEXIO_I2C_Type structure.
|
||||
*/
|
||||
void FLEXIO_I2C_MasterRepeatedStart(FLEXIO_I2C_Type *base);
|
||||
|
||||
/*!
|
||||
* @brief Sends the stop signal when transfer is still on-going.
|
||||
*
|
||||
* @param base Pointer to FLEXIO_I2C_Type structure.
|
||||
*/
|
||||
void FLEXIO_I2C_MasterAbortStop(FLEXIO_I2C_Type *base);
|
||||
|
||||
/*!
|
||||
* @brief Configures the sent ACK/NAK for the following byte.
|
||||
*
|
||||
* @param base Pointer to FLEXIO_I2C_Type structure.
|
||||
* @param enable True to configure send ACK, false configure to send NAK.
|
||||
*/
|
||||
void FLEXIO_I2C_MasterEnableAck(FLEXIO_I2C_Type *base, bool enable);
|
||||
|
||||
/*!
|
||||
* @brief Sets the number of bytes to be transferred from a start signal to a stop signal.
|
||||
*
|
||||
* @note Call this API before a transfer begins because the timer generates a number of clocks according
|
||||
* to the number of bytes that need to be transferred.
|
||||
*
|
||||
* @param base Pointer to FLEXIO_I2C_Type structure.
|
||||
* @param count Number of bytes need to be transferred from a start signal to a re-start/stop signal
|
||||
* @retval kStatus_Success Successfully configured the count.
|
||||
* @retval kStatus_InvalidArgument Input argument is invalid.
|
||||
*/
|
||||
status_t FLEXIO_I2C_MasterSetTransferCount(FLEXIO_I2C_Type *base, uint16_t count);
|
||||
|
||||
/*!
|
||||
* @brief Writes one byte of data to the I2C bus.
|
||||
*
|
||||
* @note This is a non-blocking API, which returns directly after the data is put into the
|
||||
* data register but the data transfer is not finished on the bus. Ensure that
|
||||
* the TxEmptyFlag is asserted before calling this API.
|
||||
*
|
||||
* @param base Pointer to FLEXIO_I2C_Type structure.
|
||||
* @param data a byte of data.
|
||||
*/
|
||||
static inline void FLEXIO_I2C_MasterWriteByte(FLEXIO_I2C_Type *base, uint32_t data)
|
||||
{
|
||||
base->flexioBase->SHIFTBUFBBS[base->shifterIndex[0]] = data;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Reads one byte of data from the I2C bus.
|
||||
*
|
||||
* @note This is a non-blocking API, which returns directly after the data is read from the
|
||||
* data register. Ensure that the data is ready in the register.
|
||||
*
|
||||
* @param base Pointer to FLEXIO_I2C_Type structure.
|
||||
* @return data byte read.
|
||||
*/
|
||||
static inline uint8_t FLEXIO_I2C_MasterReadByte(FLEXIO_I2C_Type *base)
|
||||
{
|
||||
return (uint8_t)(base->flexioBase->SHIFTBUFBIS[base->shifterIndex[1]]);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Sends a buffer of data in bytes.
|
||||
*
|
||||
* @note This function blocks via polling until all bytes have been sent.
|
||||
*
|
||||
* @param base Pointer to FLEXIO_I2C_Type structure.
|
||||
* @param txBuff The data bytes to send.
|
||||
* @param txSize The number of data bytes to send.
|
||||
* @retval kStatus_Success Successfully write data.
|
||||
* @retval kStatus_FLEXIO_I2C_Nak Receive NAK during writing data.
|
||||
* @retval kStatus_FLEXIO_I2C_Timeout Timeout polling status flags.
|
||||
*/
|
||||
status_t FLEXIO_I2C_MasterWriteBlocking(FLEXIO_I2C_Type *base, const uint8_t *txBuff, uint8_t txSize);
|
||||
|
||||
/*!
|
||||
* @brief Receives a buffer of bytes.
|
||||
*
|
||||
* @note This function blocks via polling until all bytes have been received.
|
||||
*
|
||||
* @param base Pointer to FLEXIO_I2C_Type structure.
|
||||
* @param rxBuff The buffer to store the received bytes.
|
||||
* @param rxSize The number of data bytes to be received.
|
||||
* @retval kStatus_Success Successfully read data.
|
||||
* @retval kStatus_FLEXIO_I2C_Timeout Timeout polling status flags.
|
||||
*/
|
||||
status_t FLEXIO_I2C_MasterReadBlocking(FLEXIO_I2C_Type *base, uint8_t *rxBuff, uint8_t rxSize);
|
||||
|
||||
/*!
|
||||
* @brief Performs a master polling transfer on the I2C bus.
|
||||
*
|
||||
* @note The API does not return until the transfer succeeds or fails due
|
||||
* to receiving NAK.
|
||||
*
|
||||
* @param base pointer to FLEXIO_I2C_Type structure.
|
||||
* @param xfer pointer to flexio_i2c_master_transfer_t structure.
|
||||
* @return status of status_t.
|
||||
*/
|
||||
status_t FLEXIO_I2C_MasterTransferBlocking(FLEXIO_I2C_Type *base, flexio_i2c_master_transfer_t *xfer);
|
||||
/*@}*/
|
||||
|
||||
/*Transactional APIs*/
|
||||
|
||||
/*!
|
||||
* @name Transactional
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @brief Initializes the I2C handle which is used in transactional functions.
|
||||
*
|
||||
* @param base Pointer to FLEXIO_I2C_Type structure.
|
||||
* @param handle Pointer to flexio_i2c_master_handle_t structure to store the transfer state.
|
||||
* @param callback Pointer to user callback function.
|
||||
* @param userData User param passed to the callback function.
|
||||
* @retval kStatus_Success Successfully create the handle.
|
||||
* @retval kStatus_OutOfRange The FlexIO type/handle/isr table out of range.
|
||||
*/
|
||||
status_t FLEXIO_I2C_MasterTransferCreateHandle(FLEXIO_I2C_Type *base,
|
||||
flexio_i2c_master_handle_t *handle,
|
||||
flexio_i2c_master_transfer_callback_t callback,
|
||||
void *userData);
|
||||
|
||||
/*!
|
||||
* @brief Performs a master interrupt non-blocking transfer on the I2C bus.
|
||||
*
|
||||
* @note The API returns immediately after the transfer initiates.
|
||||
* Call FLEXIO_I2C_MasterTransferGetCount to poll the transfer status to check whether
|
||||
* the transfer is finished. If the return status is not kStatus_FLEXIO_I2C_Busy, the transfer
|
||||
* is finished.
|
||||
*
|
||||
* @param base Pointer to FLEXIO_I2C_Type structure
|
||||
* @param handle Pointer to flexio_i2c_master_handle_t structure which stores the transfer state
|
||||
* @param xfer pointer to flexio_i2c_master_transfer_t structure
|
||||
* @retval kStatus_Success Successfully start a transfer.
|
||||
* @retval kStatus_FLEXIO_I2C_Busy FlexIO I2C is not idle, is running another transfer.
|
||||
*/
|
||||
status_t FLEXIO_I2C_MasterTransferNonBlocking(FLEXIO_I2C_Type *base,
|
||||
flexio_i2c_master_handle_t *handle,
|
||||
flexio_i2c_master_transfer_t *xfer);
|
||||
|
||||
/*!
|
||||
* @brief Gets the master transfer status during a interrupt non-blocking transfer.
|
||||
*
|
||||
* @param base Pointer to FLEXIO_I2C_Type structure.
|
||||
* @param handle Pointer to flexio_i2c_master_handle_t structure which stores the transfer state.
|
||||
* @param count Number of bytes transferred so far by the non-blocking transaction.
|
||||
* @retval kStatus_InvalidArgument count is Invalid.
|
||||
* @retval kStatus_NoTransferInProgress There is not a non-blocking transaction currently in progress.
|
||||
* @retval kStatus_Success Successfully return the count.
|
||||
*/
|
||||
status_t FLEXIO_I2C_MasterTransferGetCount(FLEXIO_I2C_Type *base, flexio_i2c_master_handle_t *handle, size_t *count);
|
||||
|
||||
/*!
|
||||
* @brief 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.
|
||||
*
|
||||
* @param base Pointer to FLEXIO_I2C_Type structure
|
||||
* @param handle Pointer to flexio_i2c_master_handle_t structure which stores the transfer state
|
||||
*/
|
||||
void FLEXIO_I2C_MasterTransferAbort(FLEXIO_I2C_Type *base, flexio_i2c_master_handle_t *handle);
|
||||
|
||||
/*!
|
||||
* @brief Master interrupt handler.
|
||||
*
|
||||
* @param i2cType Pointer to FLEXIO_I2C_Type structure
|
||||
* @param i2cHandle Pointer to flexio_i2c_master_transfer_t structure
|
||||
*/
|
||||
void FLEXIO_I2C_MasterTransferHandleIRQ(void *i2cType, void *i2cHandle);
|
||||
|
||||
/*@}*/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif /*_cplusplus*/
|
||||
/*@}*/
|
||||
|
||||
#endif /*_FSL_FLEXIO_I2C_MASTER_H_*/
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,203 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016-2019 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
#ifndef _FSL_FLEXIO_I2S_EDMA_H_
|
||||
#define _FSL_FLEXIO_I2S_EDMA_H_
|
||||
|
||||
#include "fsl_flexio_i2s.h"
|
||||
#include "fsl_edma.h"
|
||||
|
||||
/*!
|
||||
* @addtogroup flexio_edma_i2s
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
|
||||
/*! @name Driver version */
|
||||
/*@{*/
|
||||
/*! @brief FlexIO I2S EDMA driver version 2.1.7. */
|
||||
#define FSL_FLEXIO_I2S_EDMA_DRIVER_VERSION (MAKE_VERSION(2, 1, 7))
|
||||
/*@}*/
|
||||
|
||||
typedef struct _flexio_i2s_edma_handle flexio_i2s_edma_handle_t;
|
||||
|
||||
/*! @brief FlexIO I2S eDMA transfer callback function for finish and error */
|
||||
typedef void (*flexio_i2s_edma_callback_t)(FLEXIO_I2S_Type *base,
|
||||
flexio_i2s_edma_handle_t *handle,
|
||||
status_t status,
|
||||
void *userData);
|
||||
|
||||
/*! @brief FlexIO I2S DMA transfer handle, users should not touch the content of the handle.*/
|
||||
struct _flexio_i2s_edma_handle
|
||||
{
|
||||
edma_handle_t *dmaHandle; /*!< DMA handler for FlexIO I2S send */
|
||||
uint8_t bytesPerFrame; /*!< Bytes in a frame */
|
||||
uint8_t nbytes; /*!< eDMA minor byte transfer count initially configured. */
|
||||
uint32_t state; /*!< Internal state for FlexIO I2S eDMA transfer */
|
||||
flexio_i2s_edma_callback_t callback; /*!< Callback for users while transfer finish or error occurred */
|
||||
void *userData; /*!< User callback parameter */
|
||||
edma_tcd_t tcd[FLEXIO_I2S_XFER_QUEUE_SIZE + 1U]; /*!< TCD pool for eDMA transfer. */
|
||||
flexio_i2s_transfer_t queue[FLEXIO_I2S_XFER_QUEUE_SIZE]; /*!< Transfer queue storing queued transfer. */
|
||||
size_t transferSize[FLEXIO_I2S_XFER_QUEUE_SIZE]; /*!< Data bytes need to transfer */
|
||||
volatile uint8_t queueUser; /*!< Index for user to queue transfer. */
|
||||
volatile uint8_t queueDriver; /*!< Index for driver to get the transfer data and size */
|
||||
};
|
||||
|
||||
/*******************************************************************************
|
||||
* APIs
|
||||
******************************************************************************/
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* @name eDMA Transactional
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @brief Initializes the FlexIO I2S eDMA handle.
|
||||
*
|
||||
* This function initializes the FlexIO I2S master DMA handle which can be used for other FlexIO I2S master
|
||||
* transactional APIs.
|
||||
* Usually, for a specified FlexIO I2S instance, call this API once to get the initialized handle.
|
||||
*
|
||||
* @param base FlexIO I2S peripheral base address.
|
||||
* @param handle FlexIO I2S eDMA handle pointer.
|
||||
* @param callback FlexIO I2S eDMA callback function called while finished a block.
|
||||
* @param userData User parameter for callback.
|
||||
* @param dmaHandle eDMA handle for FlexIO I2S. This handle is a static value allocated by users.
|
||||
*/
|
||||
void FLEXIO_I2S_TransferTxCreateHandleEDMA(FLEXIO_I2S_Type *base,
|
||||
flexio_i2s_edma_handle_t *handle,
|
||||
flexio_i2s_edma_callback_t callback,
|
||||
void *userData,
|
||||
edma_handle_t *dmaHandle);
|
||||
|
||||
/*!
|
||||
* @brief Initializes the FlexIO I2S Rx eDMA handle.
|
||||
*
|
||||
* This function initializes the FlexIO I2S slave DMA handle which can be used for other FlexIO I2S master transactional
|
||||
* APIs.
|
||||
* Usually, for a specified FlexIO I2S instance, call this API once to get the initialized handle.
|
||||
*
|
||||
* @param base FlexIO I2S peripheral base address.
|
||||
* @param handle FlexIO I2S eDMA handle pointer.
|
||||
* @param callback FlexIO I2S eDMA callback function called while finished a block.
|
||||
* @param userData User parameter for callback.
|
||||
* @param dmaHandle eDMA handle for FlexIO I2S. This handle is a static value allocated by users.
|
||||
*/
|
||||
void FLEXIO_I2S_TransferRxCreateHandleEDMA(FLEXIO_I2S_Type *base,
|
||||
flexio_i2s_edma_handle_t *handle,
|
||||
flexio_i2s_edma_callback_t callback,
|
||||
void *userData,
|
||||
edma_handle_t *dmaHandle);
|
||||
|
||||
/*!
|
||||
* @brief Configures the FlexIO I2S Tx audio format.
|
||||
*
|
||||
* Audio format can be changed in run-time of FlexIO I2S. This function configures the sample rate and audio data
|
||||
* format to be transferred. This function also sets the eDMA parameter according to format.
|
||||
*
|
||||
* @param base FlexIO I2S peripheral base address.
|
||||
* @param handle FlexIO I2S eDMA handle pointer
|
||||
* @param format Pointer to FlexIO I2S audio data format structure.
|
||||
* @param srcClock_Hz FlexIO I2S clock source frequency in Hz, it should be 0 while in slave mode.
|
||||
* @retval kStatus_Success Audio format set successfully.
|
||||
* @retval kStatus_InvalidArgument The input arguments is invalid.
|
||||
*/
|
||||
void FLEXIO_I2S_TransferSetFormatEDMA(FLEXIO_I2S_Type *base,
|
||||
flexio_i2s_edma_handle_t *handle,
|
||||
flexio_i2s_format_t *format,
|
||||
uint32_t srcClock_Hz);
|
||||
|
||||
/*!
|
||||
* @brief Performs a non-blocking FlexIO I2S transfer using DMA.
|
||||
*
|
||||
* @note This interface returned immediately after transfer initiates. Users should call
|
||||
* FLEXIO_I2S_GetTransferStatus to poll the transfer status and check whether the FlexIO I2S transfer is finished.
|
||||
*
|
||||
* @param base FlexIO I2S peripheral base address.
|
||||
* @param handle FlexIO I2S DMA handle pointer.
|
||||
* @param xfer Pointer to DMA transfer structure.
|
||||
* @retval kStatus_Success Start a FlexIO I2S eDMA send successfully.
|
||||
* @retval kStatus_InvalidArgument The input arguments is invalid.
|
||||
* @retval kStatus_TxBusy FlexIO I2S is busy sending data.
|
||||
*/
|
||||
status_t FLEXIO_I2S_TransferSendEDMA(FLEXIO_I2S_Type *base,
|
||||
flexio_i2s_edma_handle_t *handle,
|
||||
flexio_i2s_transfer_t *xfer);
|
||||
|
||||
/*!
|
||||
* @brief Performs a non-blocking FlexIO I2S receive using eDMA.
|
||||
*
|
||||
* @note This interface returned immediately after transfer initiates. Users should call
|
||||
* FLEXIO_I2S_GetReceiveRemainingBytes to poll the transfer status and check whether the FlexIO I2S transfer is
|
||||
* finished.
|
||||
*
|
||||
* @param base FlexIO I2S peripheral base address.
|
||||
* @param handle FlexIO I2S DMA handle pointer.
|
||||
* @param xfer Pointer to DMA transfer structure.
|
||||
* @retval kStatus_Success Start a FlexIO I2S eDMA receive successfully.
|
||||
* @retval kStatus_InvalidArgument The input arguments is invalid.
|
||||
* @retval kStatus_RxBusy FlexIO I2S is busy receiving data.
|
||||
*/
|
||||
status_t FLEXIO_I2S_TransferReceiveEDMA(FLEXIO_I2S_Type *base,
|
||||
flexio_i2s_edma_handle_t *handle,
|
||||
flexio_i2s_transfer_t *xfer);
|
||||
|
||||
/*!
|
||||
* @brief Aborts a FlexIO I2S transfer using eDMA.
|
||||
*
|
||||
* @param base FlexIO I2S peripheral base address.
|
||||
* @param handle FlexIO I2S DMA handle pointer.
|
||||
*/
|
||||
void FLEXIO_I2S_TransferAbortSendEDMA(FLEXIO_I2S_Type *base, flexio_i2s_edma_handle_t *handle);
|
||||
|
||||
/*!
|
||||
* @brief Aborts a FlexIO I2S receive using eDMA.
|
||||
*
|
||||
* @param base FlexIO I2S peripheral base address.
|
||||
* @param handle FlexIO I2S DMA handle pointer.
|
||||
*/
|
||||
void FLEXIO_I2S_TransferAbortReceiveEDMA(FLEXIO_I2S_Type *base, flexio_i2s_edma_handle_t *handle);
|
||||
|
||||
/*!
|
||||
* @brief Gets the remaining bytes to be sent.
|
||||
*
|
||||
* @param base FlexIO I2S peripheral base address.
|
||||
* @param handle FlexIO I2S DMA handle pointer.
|
||||
* @param count Bytes sent.
|
||||
* @retval kStatus_Success Succeed get the transfer count.
|
||||
* @retval kStatus_NoTransferInProgress There is not a non-blocking transaction currently in progress.
|
||||
*/
|
||||
status_t FLEXIO_I2S_TransferGetSendCountEDMA(FLEXIO_I2S_Type *base, flexio_i2s_edma_handle_t *handle, size_t *count);
|
||||
|
||||
/*!
|
||||
* @brief Get the remaining bytes to be received.
|
||||
*
|
||||
* @param base FlexIO I2S peripheral base address.
|
||||
* @param handle FlexIO I2S DMA handle pointer.
|
||||
* @param count Bytes received.
|
||||
* @retval kStatus_Success Succeed get the transfer count.
|
||||
* @retval kStatus_NoTransferInProgress There is not a non-blocking transaction currently in progress.
|
||||
*/
|
||||
status_t FLEXIO_I2S_TransferGetReceiveCountEDMA(FLEXIO_I2S_Type *base, flexio_i2s_edma_handle_t *handle, size_t *count);
|
||||
|
||||
/*! @} */
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* @}
|
||||
*/
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,153 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016-2020 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#ifndef _FSL_FLEXIO_MCULCD_EDMA_H_
|
||||
#define _FSL_FLEXIO_MCULCD_EDMA_H_
|
||||
|
||||
#include "fsl_edma.h"
|
||||
#include "fsl_flexio_mculcd.h"
|
||||
|
||||
/*!
|
||||
* @addtogroup flexio_edma_mculcd
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
|
||||
/*@{*/
|
||||
/*! @brief FlexIO MCULCD EDMA driver version. */
|
||||
#define FSL_FLEXIO_MCULCD_EDMA_DRIVER_VERSION (MAKE_VERSION(2, 0, 4))
|
||||
/*@}*/
|
||||
|
||||
/*! @brief typedef for flexio_mculcd_edma_handle_t in advance. */
|
||||
typedef struct _flexio_mculcd_edma_handle flexio_mculcd_edma_handle_t;
|
||||
|
||||
/*! @brief FlexIO MCULCD master callback for transfer complete.
|
||||
*
|
||||
* When transfer finished, the callback function is called and returns the
|
||||
* @p status as kStatus_FLEXIO_MCULCD_Idle.
|
||||
*/
|
||||
typedef void (*flexio_mculcd_edma_transfer_callback_t)(FLEXIO_MCULCD_Type *base,
|
||||
flexio_mculcd_edma_handle_t *handle,
|
||||
status_t status,
|
||||
void *userData);
|
||||
|
||||
/*! @brief FlexIO MCULCD eDMA transfer handle, users should not touch the
|
||||
* content of the handle.*/
|
||||
struct _flexio_mculcd_edma_handle
|
||||
{
|
||||
FLEXIO_MCULCD_Type *base; /*!< Pointer to the FLEXIO_MCULCD_Type. */
|
||||
uint8_t txShifterNum; /*!< Number of shifters used for TX. */
|
||||
uint8_t rxShifterNum; /*!< Number of shifters used for RX. */
|
||||
uint32_t minorLoopBytes; /*!< eDMA transfer minor loop bytes. */
|
||||
edma_modulo_t txEdmaModulo; /*!< Modulo value for the FlexIO shifter buffer access. */
|
||||
edma_modulo_t rxEdmaModulo; /*!< Modulo value for the FlexIO shifter buffer access. */
|
||||
uint32_t dataAddrOrSameValue; /*!< When sending the same value for many times,
|
||||
this is the value to send. When writing or
|
||||
reading array, this is the address of the
|
||||
data array. */
|
||||
size_t dataCount; /*!< Total count to be transferred. */
|
||||
volatile size_t remainingCount; /*!< Remaining count still not transfered. */
|
||||
volatile uint32_t state; /*!< FlexIO MCULCD driver internal state. */
|
||||
edma_handle_t *txDmaHandle; /*!< DMA handle for MCULCD TX */
|
||||
edma_handle_t *rxDmaHandle; /*!< DMA handle for MCULCD RX */
|
||||
flexio_mculcd_edma_transfer_callback_t completionCallback; /*!< Callback for MCULCD DMA transfer */
|
||||
void *userData; /*!< User Data for MCULCD DMA callback */
|
||||
};
|
||||
|
||||
/*******************************************************************************
|
||||
* APIs
|
||||
******************************************************************************/
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* @name eDMA Transactional
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @brief Initializes the FLEXO MCULCD master eDMA handle.
|
||||
*
|
||||
* This function initializes the FLEXO MCULCD master eDMA handle which can be
|
||||
* used for other FLEXO MCULCD transactional APIs. For a specified FLEXO MCULCD
|
||||
* instance, call this API once to get the initialized handle.
|
||||
*
|
||||
* @param base Pointer to FLEXIO_MCULCD_Type structure.
|
||||
* @param handle Pointer to flexio_mculcd_edma_handle_t structure to store the
|
||||
* transfer state.
|
||||
* @param callback MCULCD transfer complete callback, NULL means no callback.
|
||||
* @param userData callback function parameter.
|
||||
* @param txDmaHandle User requested eDMA handle for FlexIO MCULCD eDMA TX,
|
||||
* the DMA request source of this handle should be the first of TX shifters.
|
||||
* @param rxDmaHandle User requested eDMA handle for FlexIO MCULCD eDMA RX,
|
||||
* the DMA request source of this handle should be the last of RX shifters.
|
||||
* @retval kStatus_Success Successfully create the handle.
|
||||
*/
|
||||
status_t FLEXIO_MCULCD_TransferCreateHandleEDMA(FLEXIO_MCULCD_Type *base,
|
||||
flexio_mculcd_edma_handle_t *handle,
|
||||
flexio_mculcd_edma_transfer_callback_t callback,
|
||||
void *userData,
|
||||
edma_handle_t *txDmaHandle,
|
||||
edma_handle_t *rxDmaHandle);
|
||||
|
||||
/*!
|
||||
* @brief Performs a non-blocking FlexIO MCULCD transfer using eDMA.
|
||||
*
|
||||
* This function returns immediately after transfer initiates. To check whether
|
||||
* the transfer is completed, user could:
|
||||
* 1. Use the transfer completed callback;
|
||||
* 2. Polling function FLEXIO_MCULCD_GetTransferCountEDMA
|
||||
*
|
||||
* @param base pointer to FLEXIO_MCULCD_Type structure.
|
||||
* @param handle pointer to flexio_mculcd_edma_handle_t structure to store the
|
||||
* transfer state.
|
||||
* @param xfer Pointer to FlexIO MCULCD transfer structure.
|
||||
* @retval kStatus_Success Successfully start a transfer.
|
||||
* @retval kStatus_InvalidArgument Input argument is invalid.
|
||||
* @retval kStatus_FLEXIO_MCULCD_Busy FlexIO MCULCD is not idle, it is running another
|
||||
* transfer.
|
||||
*/
|
||||
status_t FLEXIO_MCULCD_TransferEDMA(FLEXIO_MCULCD_Type *base,
|
||||
flexio_mculcd_edma_handle_t *handle,
|
||||
flexio_mculcd_transfer_t *xfer);
|
||||
|
||||
/*!
|
||||
* @brief Aborts a FlexIO MCULCD transfer using eDMA.
|
||||
*
|
||||
* @param base pointer to FLEXIO_MCULCD_Type structure.
|
||||
* @param handle FlexIO MCULCD eDMA handle pointer.
|
||||
*/
|
||||
void FLEXIO_MCULCD_TransferAbortEDMA(FLEXIO_MCULCD_Type *base, flexio_mculcd_edma_handle_t *handle);
|
||||
|
||||
/*!
|
||||
* @brief Gets the remaining bytes for FlexIO MCULCD eDMA transfer.
|
||||
*
|
||||
* @param base pointer to FLEXIO_MCULCD_Type structure.
|
||||
* @param handle FlexIO MCULCD eDMA handle pointer.
|
||||
* @param count Number of count transferred so far by the eDMA transaction.
|
||||
* @retval kStatus_Success Get the transferred count Successfully.
|
||||
* @retval kStatus_NoTransferInProgress No transfer in process.
|
||||
*/
|
||||
status_t FLEXIO_MCULCD_TransferGetCountEDMA(FLEXIO_MCULCD_Type *base,
|
||||
flexio_mculcd_edma_handle_t *handle,
|
||||
size_t *count);
|
||||
|
||||
/*! @} */
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* @}
|
||||
*/
|
||||
#endif /* _FSL_FLEXIO_MCULCD_EDMA_H_ */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,207 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016-2020 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
#ifndef _FSL_FLEXIO_SPI_EDMA_H_
|
||||
#define _FSL_FLEXIO_SPI_EDMA_H_
|
||||
|
||||
#include "fsl_flexio_spi.h"
|
||||
#include "fsl_edma.h"
|
||||
|
||||
/*!
|
||||
* @addtogroup flexio_edma_spi
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
|
||||
/*! @name Driver version */
|
||||
/*@{*/
|
||||
/*! @brief FlexIO SPI EDMA driver version 2.2.0. */
|
||||
#define FSL_FLEXIO_SPI_EDMA_DRIVER_VERSION (MAKE_VERSION(2, 2, 0))
|
||||
/*@}*/
|
||||
|
||||
/*! @brief typedef for flexio_spi_master_edma_handle_t in advance. */
|
||||
typedef struct _flexio_spi_master_edma_handle flexio_spi_master_edma_handle_t;
|
||||
|
||||
/*! @brief Slave handle is the same with master handle. */
|
||||
typedef flexio_spi_master_edma_handle_t flexio_spi_slave_edma_handle_t;
|
||||
|
||||
/*! @brief FlexIO SPI master callback for finished transmit */
|
||||
typedef void (*flexio_spi_master_edma_transfer_callback_t)(FLEXIO_SPI_Type *base,
|
||||
flexio_spi_master_edma_handle_t *handle,
|
||||
status_t status,
|
||||
void *userData);
|
||||
|
||||
/*! @brief FlexIO SPI slave callback for finished transmit */
|
||||
typedef void (*flexio_spi_slave_edma_transfer_callback_t)(FLEXIO_SPI_Type *base,
|
||||
flexio_spi_slave_edma_handle_t *handle,
|
||||
status_t status,
|
||||
void *userData);
|
||||
|
||||
/*! @brief FlexIO SPI eDMA transfer handle, users should not touch the content of the handle.*/
|
||||
struct _flexio_spi_master_edma_handle
|
||||
{
|
||||
size_t transferSize; /*!< Total bytes to be transferred. */
|
||||
uint8_t nbytes; /*!< eDMA minor byte transfer count initially configured. */
|
||||
bool txInProgress; /*!< Send transfer in progress */
|
||||
bool rxInProgress; /*!< Receive transfer in progress */
|
||||
edma_handle_t *txHandle; /*!< DMA handler for SPI send */
|
||||
edma_handle_t *rxHandle; /*!< DMA handler for SPI receive */
|
||||
flexio_spi_master_edma_transfer_callback_t callback; /*!< Callback for SPI DMA transfer */
|
||||
void *userData; /*!< User Data for SPI DMA callback */
|
||||
};
|
||||
|
||||
/*******************************************************************************
|
||||
* APIs
|
||||
******************************************************************************/
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* @name eDMA Transactional
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @brief Initializes the FlexIO SPI master eDMA handle.
|
||||
*
|
||||
* This function initializes the FlexIO SPI master eDMA handle which can be used for other FlexIO SPI master
|
||||
* transactional
|
||||
* APIs.
|
||||
* For a specified FlexIO SPI instance, call this API once to get the initialized handle.
|
||||
*
|
||||
* @param base Pointer to FLEXIO_SPI_Type structure.
|
||||
* @param handle Pointer to flexio_spi_master_edma_handle_t structure to store the transfer state.
|
||||
* @param callback SPI callback, NULL means no callback.
|
||||
* @param userData callback function parameter.
|
||||
* @param txHandle User requested eDMA handle for FlexIO SPI RX eDMA transfer.
|
||||
* @param rxHandle User requested eDMA handle for FlexIO SPI TX eDMA transfer.
|
||||
* @retval kStatus_Success Successfully create the handle.
|
||||
* @retval kStatus_OutOfRange The FlexIO SPI eDMA type/handle table out of range.
|
||||
*/
|
||||
status_t FLEXIO_SPI_MasterTransferCreateHandleEDMA(FLEXIO_SPI_Type *base,
|
||||
flexio_spi_master_edma_handle_t *handle,
|
||||
flexio_spi_master_edma_transfer_callback_t callback,
|
||||
void *userData,
|
||||
edma_handle_t *txHandle,
|
||||
edma_handle_t *rxHandle);
|
||||
|
||||
/*!
|
||||
* @brief Performs a non-blocking FlexIO SPI transfer using eDMA.
|
||||
*
|
||||
* @note This interface returns immediately after transfer initiates. Call
|
||||
* FLEXIO_SPI_MasterGetTransferCountEDMA to poll the transfer status and check
|
||||
* whether the FlexIO SPI transfer is finished.
|
||||
*
|
||||
* @param base Pointer to FLEXIO_SPI_Type structure.
|
||||
* @param handle Pointer to flexio_spi_master_edma_handle_t structure to store the transfer state.
|
||||
* @param xfer Pointer to FlexIO SPI transfer structure.
|
||||
* @retval kStatus_Success Successfully start a transfer.
|
||||
* @retval kStatus_InvalidArgument Input argument is invalid.
|
||||
* @retval kStatus_FLEXIO_SPI_Busy FlexIO SPI is not idle, is running another transfer.
|
||||
*/
|
||||
status_t FLEXIO_SPI_MasterTransferEDMA(FLEXIO_SPI_Type *base,
|
||||
flexio_spi_master_edma_handle_t *handle,
|
||||
flexio_spi_transfer_t *xfer);
|
||||
|
||||
/*!
|
||||
* @brief Aborts a FlexIO SPI transfer using eDMA.
|
||||
*
|
||||
* @param base Pointer to FLEXIO_SPI_Type structure.
|
||||
* @param handle FlexIO SPI eDMA handle pointer.
|
||||
*/
|
||||
void FLEXIO_SPI_MasterTransferAbortEDMA(FLEXIO_SPI_Type *base, flexio_spi_master_edma_handle_t *handle);
|
||||
|
||||
/*!
|
||||
* @brief Gets the remaining bytes for FlexIO SPI eDMA transfer.
|
||||
*
|
||||
* @param base Pointer to FLEXIO_SPI_Type structure.
|
||||
* @param handle FlexIO SPI eDMA handle pointer.
|
||||
* @param count Number of bytes transferred so far by the non-blocking transaction.
|
||||
*/
|
||||
status_t FLEXIO_SPI_MasterTransferGetCountEDMA(FLEXIO_SPI_Type *base,
|
||||
flexio_spi_master_edma_handle_t *handle,
|
||||
size_t *count);
|
||||
|
||||
/*!
|
||||
* @brief Initializes the FlexIO SPI slave eDMA handle.
|
||||
*
|
||||
* This function initializes the FlexIO SPI slave eDMA handle.
|
||||
*
|
||||
* @param base Pointer to FLEXIO_SPI_Type structure.
|
||||
* @param handle Pointer to flexio_spi_slave_edma_handle_t structure to store the transfer state.
|
||||
* @param callback SPI callback, NULL means no callback.
|
||||
* @param userData callback function parameter.
|
||||
* @param txHandle User requested eDMA handle for FlexIO SPI TX eDMA transfer.
|
||||
* @param rxHandle User requested eDMA handle for FlexIO SPI RX eDMA transfer.
|
||||
*/
|
||||
static inline void FLEXIO_SPI_SlaveTransferCreateHandleEDMA(FLEXIO_SPI_Type *base,
|
||||
flexio_spi_slave_edma_handle_t *handle,
|
||||
flexio_spi_slave_edma_transfer_callback_t callback,
|
||||
void *userData,
|
||||
edma_handle_t *txHandle,
|
||||
edma_handle_t *rxHandle)
|
||||
{
|
||||
(void)FLEXIO_SPI_MasterTransferCreateHandleEDMA(base, handle, callback, userData, txHandle, rxHandle);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Performs a non-blocking FlexIO SPI transfer using eDMA.
|
||||
*
|
||||
* @note This interface returns immediately after transfer initiates. Call
|
||||
* FLEXIO_SPI_SlaveGetTransferCountEDMA to poll the transfer status and
|
||||
* check whether the FlexIO SPI transfer is finished.
|
||||
*
|
||||
* @param base Pointer to FLEXIO_SPI_Type structure.
|
||||
* @param handle Pointer to flexio_spi_slave_edma_handle_t structure to store the transfer state.
|
||||
* @param xfer Pointer to FlexIO SPI transfer structure.
|
||||
* @retval kStatus_Success Successfully start a transfer.
|
||||
* @retval kStatus_InvalidArgument Input argument is invalid.
|
||||
* @retval kStatus_FLEXIO_SPI_Busy FlexIO SPI is not idle, is running another transfer.
|
||||
*/
|
||||
status_t FLEXIO_SPI_SlaveTransferEDMA(FLEXIO_SPI_Type *base,
|
||||
flexio_spi_slave_edma_handle_t *handle,
|
||||
flexio_spi_transfer_t *xfer);
|
||||
|
||||
/*!
|
||||
* @brief Aborts a FlexIO SPI transfer using eDMA.
|
||||
*
|
||||
* @param base Pointer to FLEXIO_SPI_Type structure.
|
||||
* @param handle Pointer to flexio_spi_slave_edma_handle_t structure to store the transfer state.
|
||||
*/
|
||||
static inline void FLEXIO_SPI_SlaveTransferAbortEDMA(FLEXIO_SPI_Type *base, flexio_spi_slave_edma_handle_t *handle)
|
||||
{
|
||||
FLEXIO_SPI_MasterTransferAbortEDMA(base, handle);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Gets the remaining bytes to be transferred for FlexIO SPI eDMA.
|
||||
*
|
||||
* @param base Pointer to FLEXIO_SPI_Type structure.
|
||||
* @param handle FlexIO SPI eDMA handle pointer.
|
||||
* @param count Number of bytes transferred so far by the non-blocking transaction.
|
||||
*/
|
||||
static inline status_t FLEXIO_SPI_SlaveTransferGetCountEDMA(FLEXIO_SPI_Type *base,
|
||||
flexio_spi_slave_edma_handle_t *handle,
|
||||
size_t *count)
|
||||
{
|
||||
return FLEXIO_SPI_MasterTransferGetCountEDMA(base, handle, count);
|
||||
}
|
||||
|
||||
/*! @} */
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* @}
|
||||
*/
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,178 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016-2020 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
#ifndef _FSL_FLEXIO_UART_EDMA_H_
|
||||
#define _FSL_FLEXIO_UART_EDMA_H_
|
||||
|
||||
#include "fsl_flexio_uart.h"
|
||||
#include "fsl_edma.h"
|
||||
|
||||
/*!
|
||||
* @addtogroup flexio_edma_uart
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
|
||||
/*! @name Driver version */
|
||||
/*@{*/
|
||||
/*! @brief FlexIO UART EDMA driver version 2.2.0. */
|
||||
#define FSL_FLEXIO_UART_EDMA_DRIVER_VERSION (MAKE_VERSION(2, 2, 0))
|
||||
/*@}*/
|
||||
|
||||
/* Forward declaration of the handle typedef. */
|
||||
typedef struct _flexio_uart_edma_handle flexio_uart_edma_handle_t;
|
||||
|
||||
/*! @brief UART transfer callback function. */
|
||||
typedef void (*flexio_uart_edma_transfer_callback_t)(FLEXIO_UART_Type *base,
|
||||
flexio_uart_edma_handle_t *handle,
|
||||
status_t status,
|
||||
void *userData);
|
||||
|
||||
/*!
|
||||
* @brief UART eDMA handle
|
||||
*/
|
||||
struct _flexio_uart_edma_handle
|
||||
{
|
||||
flexio_uart_edma_transfer_callback_t callback; /*!< Callback function. */
|
||||
void *userData; /*!< UART callback function parameter.*/
|
||||
|
||||
size_t txDataSizeAll; /*!< Total bytes to be sent. */
|
||||
size_t rxDataSizeAll; /*!< Total bytes to be received. */
|
||||
|
||||
edma_handle_t *txEdmaHandle; /*!< The eDMA TX channel used. */
|
||||
edma_handle_t *rxEdmaHandle; /*!< The eDMA RX channel used. */
|
||||
|
||||
uint8_t nbytes; /*!< eDMA minor byte transfer count initially configured. */
|
||||
|
||||
volatile uint8_t txState; /*!< TX transfer state. */
|
||||
volatile uint8_t rxState; /*!< RX transfer state */
|
||||
};
|
||||
|
||||
/*******************************************************************************
|
||||
* API
|
||||
******************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* @name eDMA transactional
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @brief Initializes the UART handle which is used in transactional functions.
|
||||
*
|
||||
* @param base Pointer to FLEXIO_UART_Type.
|
||||
* @param handle Pointer to flexio_uart_edma_handle_t structure.
|
||||
* @param callback The callback function.
|
||||
* @param userData The parameter of the callback function.
|
||||
* @param rxEdmaHandle User requested DMA handle for RX DMA transfer.
|
||||
* @param txEdmaHandle User requested DMA handle for TX DMA transfer.
|
||||
* @retval kStatus_Success Successfully create the handle.
|
||||
* @retval kStatus_OutOfRange The FlexIO SPI eDMA type/handle table out of range.
|
||||
*/
|
||||
status_t FLEXIO_UART_TransferCreateHandleEDMA(FLEXIO_UART_Type *base,
|
||||
flexio_uart_edma_handle_t *handle,
|
||||
flexio_uart_edma_transfer_callback_t callback,
|
||||
void *userData,
|
||||
edma_handle_t *txEdmaHandle,
|
||||
edma_handle_t *rxEdmaHandle);
|
||||
|
||||
/*!
|
||||
* @brief Sends data using eDMA.
|
||||
*
|
||||
* This function sends data using eDMA. This is a non-blocking function, which returns
|
||||
* right away. When all data is sent out, the send callback function is called.
|
||||
*
|
||||
* @param base Pointer to FLEXIO_UART_Type
|
||||
* @param handle UART handle pointer.
|
||||
* @param xfer UART eDMA transfer structure, see #flexio_uart_transfer_t.
|
||||
* @retval kStatus_Success if succeed, others failed.
|
||||
* @retval kStatus_FLEXIO_UART_TxBusy Previous transfer on going.
|
||||
*/
|
||||
status_t FLEXIO_UART_TransferSendEDMA(FLEXIO_UART_Type *base,
|
||||
flexio_uart_edma_handle_t *handle,
|
||||
flexio_uart_transfer_t *xfer);
|
||||
|
||||
/*!
|
||||
* @brief Receives data using eDMA.
|
||||
*
|
||||
* This function receives data using eDMA. This is a non-blocking function, which returns
|
||||
* right away. When all data is received, the receive callback function is called.
|
||||
*
|
||||
* @param base Pointer to FLEXIO_UART_Type
|
||||
* @param handle Pointer to flexio_uart_edma_handle_t structure
|
||||
* @param xfer UART eDMA transfer structure, see #flexio_uart_transfer_t.
|
||||
* @retval kStatus_Success if succeed, others failed.
|
||||
* @retval kStatus_UART_RxBusy Previous transfer on going.
|
||||
*/
|
||||
status_t FLEXIO_UART_TransferReceiveEDMA(FLEXIO_UART_Type *base,
|
||||
flexio_uart_edma_handle_t *handle,
|
||||
flexio_uart_transfer_t *xfer);
|
||||
|
||||
/*!
|
||||
* @brief Aborts the sent data which using eDMA.
|
||||
*
|
||||
* This function aborts sent data which using eDMA.
|
||||
*
|
||||
* @param base Pointer to FLEXIO_UART_Type
|
||||
* @param handle Pointer to flexio_uart_edma_handle_t structure
|
||||
*/
|
||||
void FLEXIO_UART_TransferAbortSendEDMA(FLEXIO_UART_Type *base, flexio_uart_edma_handle_t *handle);
|
||||
|
||||
/*!
|
||||
* @brief Aborts the receive data which using eDMA.
|
||||
*
|
||||
* This function aborts the receive data which using eDMA.
|
||||
*
|
||||
* @param base Pointer to FLEXIO_UART_Type
|
||||
* @param handle Pointer to flexio_uart_edma_handle_t structure
|
||||
*/
|
||||
void FLEXIO_UART_TransferAbortReceiveEDMA(FLEXIO_UART_Type *base, flexio_uart_edma_handle_t *handle);
|
||||
|
||||
/*!
|
||||
* @brief Gets the number of bytes sent out.
|
||||
*
|
||||
* This function gets the number of bytes sent out.
|
||||
*
|
||||
* @param base Pointer to FLEXIO_UART_Type
|
||||
* @param handle Pointer to flexio_uart_edma_handle_t structure
|
||||
* @param count Number of bytes sent so far by the non-blocking transaction.
|
||||
* @retval kStatus_NoTransferInProgress transfer has finished or no transfer in progress.
|
||||
* @retval kStatus_Success Successfully return the count.
|
||||
*/
|
||||
status_t FLEXIO_UART_TransferGetSendCountEDMA(FLEXIO_UART_Type *base, flexio_uart_edma_handle_t *handle, size_t *count);
|
||||
|
||||
/*!
|
||||
* @brief Gets the number of bytes received.
|
||||
*
|
||||
* This function gets the number of bytes received.
|
||||
*
|
||||
* @param base Pointer to FLEXIO_UART_Type
|
||||
* @param handle Pointer to flexio_uart_edma_handle_t structure
|
||||
* @param count Number of bytes received so far by the non-blocking transaction.
|
||||
* @retval kStatus_NoTransferInProgress transfer has finished or no transfer in progress.
|
||||
* @retval kStatus_Success Successfully return the count.
|
||||
*/
|
||||
status_t FLEXIO_UART_TransferGetReceiveCountEDMA(FLEXIO_UART_Type *base,
|
||||
flexio_uart_edma_handle_t *handle,
|
||||
size_t *count);
|
||||
|
||||
/*@}*/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
/*! @}*/
|
||||
|
||||
#endif /* _FSL_UART_EDMA_H_ */
|
||||
@@ -1,276 +0,0 @@
|
||||
/*
|
||||
* Copyright 2017-2020 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#ifndef _FSL_FLEXRAM_H_
|
||||
#define _FSL_FLEXRAM_H_
|
||||
|
||||
#include "fsl_common.h"
|
||||
#include "fsl_flexram_allocate.h"
|
||||
|
||||
/*!
|
||||
* @addtogroup flexram
|
||||
* @{
|
||||
*/
|
||||
|
||||
/******************************************************************************
|
||||
* Definitions.
|
||||
*****************************************************************************/
|
||||
|
||||
/*! @name Driver version */
|
||||
/*@{*/
|
||||
/*! @brief Driver version 2.0.7. */
|
||||
#define FSL_FLEXRAM_DRIVER_VERSION (MAKE_VERSION(2U, 0U, 7U))
|
||||
/*@}*/
|
||||
|
||||
/*! @brief Flexram write/read selection. */
|
||||
enum
|
||||
{
|
||||
kFLEXRAM_Read = 0U, /*!< read */
|
||||
kFLEXRAM_Write = 1U, /*!< write */
|
||||
};
|
||||
|
||||
/*! @brief Interrupt status flag mask */
|
||||
enum
|
||||
{
|
||||
kFLEXRAM_OCRAMAccessError = FLEXRAM_INT_STATUS_OCRAM_ERR_STATUS_MASK, /*!< OCRAM accesses unallocated address */
|
||||
kFLEXRAM_DTCMAccessError = FLEXRAM_INT_STATUS_DTCM_ERR_STATUS_MASK, /*!< DTCM accesses unallocated address */
|
||||
kFLEXRAM_ITCMAccessError = FLEXRAM_INT_STATUS_ITCM_ERR_STATUS_MASK, /*!< ITCM accesses unallocated address */
|
||||
|
||||
#if defined(FSL_FEATURE_FLEXRAM_HAS_MAGIC_ADDR) && FSL_FEATURE_FLEXRAM_HAS_MAGIC_ADDR
|
||||
kFLEXRAM_OCRAMMagicAddrMatch = FLEXRAM_INT_STATUS_OCRAM_MAM_STATUS_MASK, /*!< OCRAM magic address match */
|
||||
kFLEXRAM_DTCMMagicAddrMatch = FLEXRAM_INT_STATUS_DTCM_MAM_STATUS_MASK, /*!< DTCM magic address match */
|
||||
kFLEXRAM_ITCMMagicAddrMatch = FLEXRAM_INT_STATUS_ITCM_MAM_STATUS_MASK, /*!< ITCM magic address match */
|
||||
|
||||
kFLEXRAM_InterruptStatusAll = FLEXRAM_INT_STATUS_OCRAM_ERR_STATUS_MASK | FLEXRAM_INT_STATUS_DTCM_ERR_STATUS_MASK |
|
||||
FLEXRAM_INT_STATUS_ITCM_ERR_STATUS_MASK | FLEXRAM_INT_STATUS_OCRAM_MAM_STATUS_MASK |
|
||||
FLEXRAM_INT_STATUS_DTCM_MAM_STATUS_MASK | FLEXRAM_INT_STATUS_ITCM_MAM_STATUS_MASK,
|
||||
/*!< all the interrupt status mask */
|
||||
#else
|
||||
kFLEXRAM_InterruptStatusAll = FLEXRAM_INT_STATUS_OCRAM_ERR_STATUS_MASK | FLEXRAM_INT_STATUS_DTCM_ERR_STATUS_MASK |
|
||||
FLEXRAM_INT_STATUS_ITCM_ERR_STATUS_MASK, /*!< all the interrupt status mask */
|
||||
#endif /* FSL_FEATURE_FLEXRAM_HAS_MAGIC_ADDR */
|
||||
};
|
||||
|
||||
/*! @brief FLEXRAM TCM access mode.
|
||||
* Fast access mode expected to be finished in 1-cycle;
|
||||
* Wait access mode expected to be finished in 2-cycle.
|
||||
* Wait access mode is a feature of the flexram and it should be used when
|
||||
* the CPU clock is too fast to finish TCM access in 1-cycle.
|
||||
* Normally, fast mode is the default mode, the efficiency of the TCM access will better.
|
||||
*/
|
||||
typedef enum _flexram_tcm_access_mode
|
||||
{
|
||||
kFLEXRAM_TCMAccessFastMode = 0U, /*!< fast access mode */
|
||||
kFLEXRAM_TCMAccessWaitMode = 1U, /*!< wait access mode */
|
||||
} flexram_tcm_access_mode_t;
|
||||
|
||||
/*! @brief FLEXRAM TCM support size */
|
||||
enum
|
||||
{
|
||||
kFLEXRAM_TCMSize32KB = 32 * 1024U, /*!< TCM total size be 32KB */
|
||||
kFLEXRAM_TCMSize64KB = 64 * 1024U, /*!< TCM total size be 64KB */
|
||||
kFLEXRAM_TCMSize128KB = 128 * 1024U, /*!< TCM total size be 128KB */
|
||||
kFLEXRAM_TCMSize256KB = 256 * 1024U, /*!< TCM total size be 256KB */
|
||||
kFLEXRAM_TCMSize512KB = 512 * 1024U, /*!< TCM total size be 512KB */
|
||||
};
|
||||
|
||||
/*******************************************************************************
|
||||
* APIs
|
||||
******************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* @name Initialization and de-initialization
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @brief FLEXRAM module initialization function.
|
||||
*
|
||||
* @param base FLEXRAM base address.
|
||||
*/
|
||||
void FLEXRAM_Init(FLEXRAM_Type *base);
|
||||
|
||||
/*!
|
||||
* @brief De-initializes the FLEXRAM.
|
||||
*
|
||||
*/
|
||||
void FLEXRAN_Deinit(FLEXRAM_Type *base);
|
||||
|
||||
/* @} */
|
||||
|
||||
/*!
|
||||
* @name Status
|
||||
* @{
|
||||
*/
|
||||
/*!
|
||||
* @brief FLEXRAM module gets interrupt status.
|
||||
*
|
||||
* @param base FLEXRAM base address.
|
||||
*/
|
||||
static inline uint32_t FLEXRAM_GetInterruptStatus(FLEXRAM_Type *base)
|
||||
{
|
||||
return base->INT_STATUS & (uint32_t)kFLEXRAM_InterruptStatusAll;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief FLEXRAM module clears interrupt status.
|
||||
*
|
||||
* @param base FLEXRAM base address.
|
||||
* @param status Status to be cleared.
|
||||
*/
|
||||
static inline void FLEXRAM_ClearInterruptStatus(FLEXRAM_Type *base, uint32_t status)
|
||||
{
|
||||
base->INT_STATUS |= status;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief FLEXRAM module enables interrupt status.
|
||||
*
|
||||
* @param base FLEXRAM base address.
|
||||
* @param status Status to be enabled.
|
||||
*/
|
||||
static inline void FLEXRAM_EnableInterruptStatus(FLEXRAM_Type *base, uint32_t status)
|
||||
{
|
||||
base->INT_STAT_EN |= status;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief FLEXRAM module disable interrupt status.
|
||||
*
|
||||
* @param base FLEXRAM base address.
|
||||
* @param status Status to be disabled.
|
||||
*/
|
||||
static inline void FLEXRAM_DisableInterruptStatus(FLEXRAM_Type *base, uint32_t status)
|
||||
{
|
||||
base->INT_STAT_EN &= ~status;
|
||||
}
|
||||
|
||||
/* @} */
|
||||
|
||||
/*!
|
||||
* @name Interrupts
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @brief FLEXRAM module enables interrupt.
|
||||
*
|
||||
* @param base FLEXRAM base address.
|
||||
* @param status Status interrupt to be enabled.
|
||||
*/
|
||||
static inline void FLEXRAM_EnableInterruptSignal(FLEXRAM_Type *base, uint32_t status)
|
||||
{
|
||||
base->INT_SIG_EN |= status;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief FLEXRAM module disables interrupt.
|
||||
*
|
||||
* @param base FLEXRAM base address.
|
||||
* @param status Status interrupt to be disabled.
|
||||
*/
|
||||
static inline void FLEXRAM_DisableInterruptSignal(FLEXRAM_Type *base, uint32_t status)
|
||||
{
|
||||
base->INT_SIG_EN &= ~status;
|
||||
}
|
||||
/* @} */
|
||||
|
||||
/*!
|
||||
* @brief FLEXRAM module sets TCM read access mode
|
||||
*
|
||||
* @param base FLEXRAM base address.
|
||||
* @param mode Access mode.
|
||||
*/
|
||||
static inline void FLEXRAM_SetTCMReadAccessMode(FLEXRAM_Type *base, flexram_tcm_access_mode_t mode)
|
||||
{
|
||||
base->TCM_CTRL &= ~FLEXRAM_TCM_CTRL_TCM_RWAIT_EN_MASK;
|
||||
base->TCM_CTRL |= (uint32_t)mode;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief FLEXRAM module set TCM write access mode
|
||||
*
|
||||
* @param base FLEXRAM base address.
|
||||
* @param mode Access mode.
|
||||
*/
|
||||
static inline void FLEXRAM_SetTCMWriteAccessMode(FLEXRAM_Type *base, flexram_tcm_access_mode_t mode)
|
||||
{
|
||||
base->TCM_CTRL &= ~FLEXRAM_TCM_CTRL_TCM_WWAIT_EN_MASK;
|
||||
base->TCM_CTRL |= (uint32_t)mode;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief FLEXRAM module force ram clock on
|
||||
*
|
||||
* @param base FLEXRAM base address.
|
||||
* @param enable Enable or disable clock force on.
|
||||
*/
|
||||
static inline void FLEXRAM_EnableForceRamClockOn(FLEXRAM_Type *base, bool enable)
|
||||
{
|
||||
if (enable)
|
||||
{
|
||||
base->TCM_CTRL |= FLEXRAM_TCM_CTRL_FORCE_CLK_ON_MASK;
|
||||
}
|
||||
else
|
||||
{
|
||||
base->TCM_CTRL &= ~FLEXRAM_TCM_CTRL_FORCE_CLK_ON_MASK;
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(FSL_FEATURE_FLEXRAM_HAS_MAGIC_ADDR) && FSL_FEATURE_FLEXRAM_HAS_MAGIC_ADDR
|
||||
/*!
|
||||
* @brief FLEXRAM OCRAM magic addr configuration.
|
||||
* When read/write access hit magic address, it will generate interrupt.
|
||||
* @param base FLEXRAM base address.
|
||||
* @param magicAddr Magic address, the actual address bits [18:3] is corresponding to the register field [16:1].
|
||||
* @param rwSel Read/write selection. 0 for read access while 1 for write access.
|
||||
*/
|
||||
static inline void FLEXRAM_SetOCRAMMagicAddr(FLEXRAM_Type *base, uint16_t magicAddr, uint32_t rwSel)
|
||||
{
|
||||
base->OCRAM_MAGIC_ADDR = FLEXRAM_OCRAM_MAGIC_ADDR_OCRAM_WR_RD_SEL(rwSel) |
|
||||
FLEXRAM_OCRAM_MAGIC_ADDR_OCRAM_MAGIC_ADDR((uint32_t)magicAddr >> 3);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief FLEXRAM DTCM magic addr configuration.
|
||||
* When read/write access hits magic address, it will generate interrupt.
|
||||
* @param base FLEXRAM base address.
|
||||
* @param magicAddr Magic address, the actual address bits [18:3] is corresponding to the register field [16:1].
|
||||
* @param rwSel Read/write selection. 0 for read access while 1 write access.
|
||||
*/
|
||||
static inline void FLEXRAM_SetDTCMMagicAddr(FLEXRAM_Type *base, uint16_t magicAddr, uint32_t rwSel)
|
||||
{
|
||||
base->DTCM_MAGIC_ADDR = FLEXRAM_DTCM_MAGIC_ADDR_DTCM_WR_RD_SEL(rwSel) |
|
||||
FLEXRAM_DTCM_MAGIC_ADDR_DTCM_MAGIC_ADDR((uint32_t)magicAddr >> 3);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief FLEXRAM ITCM magic addr configuration.
|
||||
* When read/write access hits magic address, it will generate interrupt.
|
||||
* @param base FLEXRAM base address.
|
||||
* @param magicAddr Magic address, the actual address bits [18:3] is corresponding to the register field [16:1].
|
||||
* @param rwSel Read/write selection. 0 for read access while 1 for write access.
|
||||
*/
|
||||
static inline void FLEXRAM_SetITCMMagicAddr(FLEXRAM_Type *base, uint16_t magicAddr, uint32_t rwSel)
|
||||
{
|
||||
base->ITCM_MAGIC_ADDR = FLEXRAM_ITCM_MAGIC_ADDR_ITCM_WR_RD_SEL(rwSel) |
|
||||
FLEXRAM_ITCM_MAGIC_ADDR_ITCM_MAGIC_ADDR((uint32_t)magicAddr >> 3);
|
||||
}
|
||||
#endif /* FSL_FEATURE_FLEXRAM_HAS_MAGIC_ADDR */
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
/*! @}*/
|
||||
|
||||
#endif
|
||||
@@ -1,99 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019-2020 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#ifndef _FSL_FLEXRAM_ALLOCATE_H_
|
||||
#define _FSL_FLEXRAM_ALLOCATE_H_
|
||||
|
||||
#include "fsl_common.h"
|
||||
|
||||
/*!
|
||||
* @addtogroup flexram
|
||||
* @{
|
||||
*/
|
||||
|
||||
/******************************************************************************
|
||||
* Definitions.
|
||||
*****************************************************************************/
|
||||
|
||||
/*! @name Driver version */
|
||||
/*@{*/
|
||||
/*! @brief Driver version 2.0.7. */
|
||||
#define FSL_FLEXRAM_DRIVER_VERSION (MAKE_VERSION(2U, 0U, 7U))
|
||||
/*@}*/
|
||||
|
||||
/*! @brief FLEXRAM bank type */
|
||||
enum
|
||||
{
|
||||
kFLEXRAM_BankNotUsed = 0U, /*!< bank is not used */
|
||||
kFLEXRAM_BankOCRAM = 1U, /*!< bank is OCRAM */
|
||||
kFLEXRAM_BankDTCM = 2U, /*!< bank is DTCM */
|
||||
kFLEXRAM_BankITCM = 3U, /*!< bank is ITCM */
|
||||
};
|
||||
|
||||
/*! @brief FLEXRAM bank allocate source */
|
||||
typedef enum _flexram_bank_allocate_src
|
||||
{
|
||||
kFLEXRAM_BankAllocateThroughHardwareFuse = 0U, /*!< allocate ram through hardware fuse value */
|
||||
kFLEXRAM_BankAllocateThroughBankCfg = 1U, /*!< allocate ram through FLEXRAM_BANK_CFG */
|
||||
} flexram_bank_allocate_src_t;
|
||||
|
||||
/*! @brief FLEXRAM allocate ocram, itcm, dtcm size */
|
||||
typedef struct _flexram_allocate_ram
|
||||
{
|
||||
const uint8_t ocramBankNum; /*!< ocram banknumber which the SOC support */
|
||||
const uint8_t dtcmBankNum; /*!< dtcm bank number to allocate, the number should be power of 2 */
|
||||
const uint8_t itcmBankNum; /*!< itcm bank number to allocate, the number should be power of 2 */
|
||||
} flexram_allocate_ram_t;
|
||||
|
||||
/*******************************************************************************
|
||||
* APIs
|
||||
******************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* @brief FLEXRAM allocate on-chip ram for OCRAM,ITCM,DTCM
|
||||
* This function is independent of FLEXRAM_Init, it can be called directly if ram re-allocate
|
||||
* is needed.
|
||||
* @param config allocate configuration.
|
||||
* @retval kStatus_InvalidArgument the argument is invalid
|
||||
* kStatus_Success allocate success
|
||||
*/
|
||||
status_t FLEXRAM_AllocateRam(flexram_allocate_ram_t *config);
|
||||
|
||||
/*!
|
||||
* @brief FLEXRAM set allocate on-chip ram source
|
||||
* @param src bank config source select value.
|
||||
*/
|
||||
static inline void FLEXRAM_SetAllocateRamSrc(flexram_bank_allocate_src_t src)
|
||||
{
|
||||
IOMUXC_GPR->GPR16 &= ~IOMUXC_GPR_GPR16_FLEXRAM_BANK_CFG_SEL_MASK;
|
||||
IOMUXC_GPR->GPR16 |= IOMUXC_GPR_GPR16_FLEXRAM_BANK_CFG_SEL(src);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief FLEXRAM configure TCM size
|
||||
* This function is used to set the TCM to the target size. If a odd bank number is used,
|
||||
* a new banknumber will be used which is bigger than target value, application can set tcm
|
||||
* size to the biggest bank number always, then boundary access error can be captured by flexram only.
|
||||
* When access to the TCM memory boundary ,hardfault will raised by core.
|
||||
* @param itcmBankNum itcm bank number to allocate
|
||||
* @param dtcmBankNum dtcm bank number to allocate
|
||||
*
|
||||
*/
|
||||
void FLEXRAM_SetTCMSize(uint8_t itcmBankNum, uint8_t dtcmBankNum);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
/*! @}*/
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,130 +0,0 @@
|
||||
/*
|
||||
* Copyright 2017 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#ifndef __FLEXSPI_NOR_BOOT_H__
|
||||
#define __FLEXSPI_NOR_BOOT_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#ifndef __rtems__
|
||||
#include "board.h"
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/*! @name Driver version */
|
||||
/*@{*/
|
||||
/*! @brief XIP_DEVICE driver version 2.0.0. */
|
||||
#define FSL_XIP_DEVICE_DRIVER_VERSION (MAKE_VERSION(2, 0, 0))
|
||||
/*@}*/
|
||||
|
||||
/*************************************
|
||||
* IVT Data
|
||||
*************************************/
|
||||
typedef struct _ivt_ {
|
||||
/** @ref hdr with tag #HAB_TAG_IVT, length and HAB version fields
|
||||
* (see @ref data)
|
||||
*/
|
||||
uint32_t hdr;
|
||||
/** Absolute address of the first instruction to execute from the
|
||||
* image
|
||||
*/
|
||||
uint32_t entry;
|
||||
/** Reserved in this version of HAB: should be NULL. */
|
||||
uint32_t reserved1;
|
||||
/** Absolute address of the image DCD: may be NULL. */
|
||||
uint32_t dcd;
|
||||
/** Absolute address of the Boot Data: may be NULL, but not interpreted
|
||||
* any further by HAB
|
||||
*/
|
||||
uint32_t boot_data;
|
||||
/** Absolute address of the IVT.*/
|
||||
uint32_t self;
|
||||
/** Absolute address of the image CSF.*/
|
||||
uint32_t csf;
|
||||
/** Reserved in this version of HAB: should be zero. */
|
||||
uint32_t reserved2;
|
||||
} ivt;
|
||||
|
||||
#define IVT_MAJOR_VERSION 0x4
|
||||
#define IVT_MAJOR_VERSION_SHIFT 0x4
|
||||
#define IVT_MAJOR_VERSION_MASK 0xF
|
||||
#define IVT_MINOR_VERSION 0x1
|
||||
#define IVT_MINOR_VERSION_SHIFT 0x0
|
||||
#define IVT_MINOR_VERSION_MASK 0xF
|
||||
|
||||
#define IVT_VERSION(major, minor) \
|
||||
((((major) & IVT_MAJOR_VERSION_MASK) << IVT_MAJOR_VERSION_SHIFT) | \
|
||||
(((minor) & IVT_MINOR_VERSION_MASK) << IVT_MINOR_VERSION_SHIFT))
|
||||
|
||||
/* IVT header */
|
||||
#define IVT_TAG_HEADER 0xD1 /**< Image Vector Table */
|
||||
#define IVT_SIZE 0x2000
|
||||
#define IVT_PAR IVT_VERSION(IVT_MAJOR_VERSION, IVT_MINOR_VERSION)
|
||||
#define IVT_HEADER (IVT_TAG_HEADER | (IVT_SIZE << 8) | (IVT_PAR << 24))
|
||||
|
||||
/* Set resume entry */
|
||||
#if defined(__CC_ARM) || defined(__ARMCC_VERSION)
|
||||
extern uint32_t __Vectors[];
|
||||
extern uint32_t Image$$RW_m_config_text$$Base[];
|
||||
#define IMAGE_ENTRY_ADDRESS ((uint32_t)__Vectors)
|
||||
#define FLASH_BASE ((uint32_t)Image$$RW_m_config_text$$Base)
|
||||
#elif defined(__MCUXPRESSO)
|
||||
extern uint32_t __Vectors[];
|
||||
extern uint32_t __boot_hdr_start__[];
|
||||
#define IMAGE_ENTRY_ADDRESS ((uint32_t)__Vectors)
|
||||
#define FLASH_BASE ((uint32_t)__boot_hdr_start__)
|
||||
#elif defined(__ICCARM__)
|
||||
extern uint32_t __VECTOR_TABLE[];
|
||||
extern uint32_t m_boot_hdr_conf_start[];
|
||||
#define IMAGE_ENTRY_ADDRESS ((uint32_t)__VECTOR_TABLE)
|
||||
#define FLASH_BASE ((uint32_t)m_boot_hdr_conf_start)
|
||||
#elif defined(__GNUC__)
|
||||
extern uint32_t __VECTOR_TABLE[];
|
||||
extern uint32_t __FLASH_BASE[];
|
||||
#define IMAGE_ENTRY_ADDRESS ((uint32_t)__VECTOR_TABLE)
|
||||
#define FLASH_BASE ((uint32_t)__FLASH_BASE)
|
||||
#endif
|
||||
|
||||
#ifndef __rtems__
|
||||
#if defined(XIP_BOOT_HEADER_DCD_ENABLE) && (1 == XIP_BOOT_HEADER_DCD_ENABLE)
|
||||
#define DCD_ADDRESS dcd_data
|
||||
#else
|
||||
#define DCD_ADDRESS 0
|
||||
#endif
|
||||
|
||||
#define BOOT_DATA_ADDRESS &boot_data
|
||||
#define CSF_ADDRESS 0
|
||||
#define IVT_RSVD (uint32_t)(0x00000000)
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/*************************************
|
||||
* Boot Data
|
||||
*************************************/
|
||||
typedef struct _boot_data_ {
|
||||
uint32_t start; /* boot start location */
|
||||
uint32_t size; /* size */
|
||||
uint32_t plugin; /* plugin flag - 1 if downloaded application is plugin */
|
||||
uint32_t placeholder; /* placehoder to make even 0x10 size */
|
||||
}BOOT_DATA_T;
|
||||
|
||||
#ifndef __rtems__
|
||||
#if defined(BOARD_FLASH_SIZE)
|
||||
#define FLASH_SIZE BOARD_FLASH_SIZE
|
||||
#else
|
||||
#error "Please define macro BOARD_FLASH_SIZE"
|
||||
#endif
|
||||
#endif /* __rtems__ */
|
||||
#define PLUGIN_FLAG (uint32_t)0
|
||||
|
||||
#ifndef __rtems__
|
||||
/* External Variables */
|
||||
const BOOT_DATA_T boot_data;
|
||||
#if defined(XIP_BOOT_HEADER_DCD_ENABLE) && (1 == XIP_BOOT_HEADER_DCD_ENABLE)
|
||||
extern const uint8_t dcd_data[];
|
||||
#endif
|
||||
#endif /* __rtems__ */
|
||||
|
||||
#endif /* __FLEXSPI_NOR_BOOT_H__ */
|
||||
|
||||
@@ -1,231 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016-2019 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#ifndef _FSL_GPC_H_
|
||||
#define _FSL_GPC_H_
|
||||
|
||||
#include "fsl_common.h"
|
||||
|
||||
/*!
|
||||
* @addtogroup gpc
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
|
||||
/*! @name Driver version */
|
||||
/*@{*/
|
||||
/*! @brief GPC driver version 2.1.1. */
|
||||
#define FSL_GPC_DRIVER_VERSION (MAKE_VERSION(2, 1, 1))
|
||||
/*@}*/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
* API
|
||||
******************************************************************************/
|
||||
|
||||
#if (defined(FSL_FEATURE_GPC_HAS_CNTR_GPCIRQM) && FSL_FEATURE_GPC_HAS_CNTR_GPCIRQM)
|
||||
/*!
|
||||
* @brief Allow all the IRQ/Events within the charge of GPC.
|
||||
*
|
||||
* @param base GPC peripheral base address.
|
||||
*/
|
||||
static inline void GPC_AllowIRQs(GPC_Type *base)
|
||||
{
|
||||
base->CNTR &= ~GPC_CNTR_GPCIRQM_MASK; /* Events would not be masked. */
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Disallow all the IRQ/Events within the charge of GPC.
|
||||
*
|
||||
* @param base GPC peripheral base address.
|
||||
*/
|
||||
static inline void GPC_DisallowIRQs(GPC_Type *base)
|
||||
{
|
||||
base->CNTR |= GPC_CNTR_GPCIRQM_MASK; /* Mask all the events. */
|
||||
}
|
||||
#endif /* FSL_FEATURE_GPC_HAS_CNTR_GPCIRQM */
|
||||
|
||||
/*!
|
||||
* @brief Enable the IRQ.
|
||||
*
|
||||
* @param base GPC peripheral base address.
|
||||
* @param irqId ID number of IRQ to be enabled, available range is 32-159. 0-31 is available in some platforms.
|
||||
*/
|
||||
void GPC_EnableIRQ(GPC_Type *base, uint32_t irqId);
|
||||
|
||||
/*!
|
||||
* @brief Disable the IRQ.
|
||||
*
|
||||
* @param base GPC peripheral base address.
|
||||
* @param irqId ID number of IRQ to be disabled, available range is 32-159. 0-31 is available in some platforms.
|
||||
*/
|
||||
void GPC_DisableIRQ(GPC_Type *base, uint32_t irqId);
|
||||
|
||||
/*!
|
||||
* @brief Get the IRQ/Event flag.
|
||||
*
|
||||
* @param base GPC peripheral base address.
|
||||
* @param irqId ID number of IRQ to be enabled, available range is 32-159. 0-31 is available in some platforms.
|
||||
* @return Indicated IRQ/Event is asserted or not.
|
||||
*/
|
||||
bool GPC_GetIRQStatusFlag(GPC_Type *base, uint32_t irqId);
|
||||
|
||||
#if (defined(FSL_FEATURE_GPC_HAS_CNTR_L2PGE) && FSL_FEATURE_GPC_HAS_CNTR_L2PGE)
|
||||
/*!
|
||||
* @brief L2 Cache Power Gate Enable
|
||||
*
|
||||
* This function configures the L2 cache if it will keep power when in low power mode.
|
||||
* When the L2 cache power is OFF, L2 cache will be power down once when CPU core is power down
|
||||
* and will be hardware invalidated automatically when CPU core is re-power up.
|
||||
* When the L2 cache power is ON, L2 cache will keep power on even if CPU core is power down and
|
||||
* will not be hardware invalidated.
|
||||
* When CPU core is re-power up, the default setting is OFF.
|
||||
*
|
||||
* @param base GPC peripheral base address.
|
||||
* @param enable Enable the request or not.
|
||||
*/
|
||||
static inline void GPC_RequestL2CachePowerDown(GPC_Type *base, bool enable)
|
||||
{
|
||||
if (enable)
|
||||
{
|
||||
base->CNTR |= GPC_CNTR_L2_PGE_MASK; /* OFF. */
|
||||
}
|
||||
else
|
||||
{
|
||||
base->CNTR &= ~GPC_CNTR_L2_PGE_MASK; /* ON. */
|
||||
}
|
||||
}
|
||||
#endif /* FSL_FEATURE_GPC_HAS_CNTR_L2PGE */
|
||||
|
||||
#if (defined(FSL_FEATURE_GPC_HAS_CNTR_PDRAM0PGE) && FSL_FEATURE_GPC_HAS_CNTR_PDRAM0PGE)
|
||||
/*!
|
||||
* @brief FLEXRAM PDRAM0 Power Gate Enable
|
||||
*
|
||||
* This function configures the FLEXRAM PDRAM0 if it will keep power when cpu core is power down.
|
||||
* When the PDRAM0 Power is 1, PDRAM0 will be power down once when CPU core is power down.
|
||||
* When the PDRAM0 Power is 0, PDRAM0 will keep power on even if CPU core is power down.
|
||||
* When CPU core is re-power up, the default setting is 1.
|
||||
*
|
||||
* @param base GPC peripheral base address.
|
||||
* @param enable Enable the request or not.
|
||||
*/
|
||||
static inline void GPC_RequestPdram0PowerDown(GPC_Type *base, bool enable)
|
||||
{
|
||||
if (enable)
|
||||
{
|
||||
base->CNTR |= GPC_CNTR_PDRAM0_PGE_MASK; /* OFF. */
|
||||
}
|
||||
else
|
||||
{
|
||||
base->CNTR &= ~GPC_CNTR_PDRAM0_PGE_MASK; /* ON. */
|
||||
}
|
||||
}
|
||||
#endif /* FSL_FEATURE_GPC_HAS_CNTR_PDRAM0PGE */
|
||||
|
||||
#if (defined(FSL_FEATURE_GPC_HAS_CNTR_VADC) && FSL_FEATURE_GPC_HAS_CNTR_VADC)
|
||||
/*!
|
||||
* @brief VADC power down.
|
||||
*
|
||||
* This function requests the VADC power down.
|
||||
*
|
||||
* @param base GPC peripheral base address.
|
||||
* @param enable Enable the request or not.
|
||||
*/
|
||||
static inline void GPC_RequestVADCPowerDown(GPC_Type *base, bool enable)
|
||||
{
|
||||
if (enable)
|
||||
{
|
||||
base->CNTR &= ~GPC_CNTR_VADC_EXT_PWD_N_MASK; /* VADC power down. */
|
||||
}
|
||||
else
|
||||
{
|
||||
base->CNTR |= GPC_CNTR_VADC_EXT_PWD_N_MASK; /* VADC not power down. */
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Checks if the VADC is power off.
|
||||
*
|
||||
* @param base GPC peripheral base address.
|
||||
* @return Whether the VADC is power off or not.
|
||||
*/
|
||||
static inline bool GPC_GetVADCPowerDownFlag(GPC_Type *base)
|
||||
{
|
||||
return (GPC_CNTR_VADC_ANALOG_OFF_MASK == (GPC_CNTR_VADC_ANALOG_OFF_MASK & base->CNTR));
|
||||
}
|
||||
#endif /* FSL_FEATURE_GPC_HAS_CNTR_VADC */
|
||||
|
||||
#if (defined(FSL_FEATURE_GPC_HAS_CNTR_DVFS0CR) && FSL_FEATURE_GPC_HAS_CNTR_DVFS0CR)
|
||||
/*!
|
||||
* @brief Checks if the DVFS0 is requesting for frequency/voltage update.
|
||||
*
|
||||
* @param base GPC peripheral base address.
|
||||
* @return Whether the DVFS0 is requesting for frequency/voltage update.
|
||||
*/
|
||||
static inline bool GPC_HasDVFS0ChangeRequest(GPC_Type *base)
|
||||
{
|
||||
return (GPC_CNTR_DVFS0CR_MASK == (GPC_CNTR_DVFS0CR_MASK & base->CNTR));
|
||||
}
|
||||
#endif /* FSL_FEATURE_GPC_HAS_CNTR_DVFS0CR */
|
||||
|
||||
#if (defined(FSL_FEATURE_GPC_HAS_CNTR_DISPLAY) && FSL_FEATURE_GPC_HAS_CNTR_DISPLAY)
|
||||
/*!
|
||||
* @brief Requests the display power switch sequence.
|
||||
*
|
||||
* @param base GPC peripheral base address.
|
||||
* @param enable Enable the power on sequence, or the power down sequence.
|
||||
*/
|
||||
static inline void GPC_RequestDisplayPowerOn(GPC_Type *base, bool enable)
|
||||
{
|
||||
if (enable)
|
||||
{
|
||||
base->CNTR |= GPC_CNTR_DISPLAY_PUP_REQ_MASK; /* Power on sequence. */
|
||||
}
|
||||
else
|
||||
{
|
||||
base->CNTR |= GPC_CNTR_DISPLAY_PDN_REQ_MASK; /* Power down sequence. */
|
||||
}
|
||||
}
|
||||
#endif /* FSL_FEATURE_GPC_HAS_CNTR_DISPLAY */
|
||||
|
||||
/*!
|
||||
* @brief Requests the MEGA power switch sequence.
|
||||
*
|
||||
* @param base GPC peripheral base address.
|
||||
* @param enable Enable the power on sequence, or the power down sequence.
|
||||
*/
|
||||
static inline void GPC_RequestMEGAPowerOn(GPC_Type *base, bool enable)
|
||||
{
|
||||
if (enable)
|
||||
{
|
||||
base->CNTR |= GPC_CNTR_MEGA_PUP_REQ_MASK; /* Power on sequence. */
|
||||
}
|
||||
else
|
||||
{
|
||||
base->CNTR |= GPC_CNTR_MEGA_PDN_REQ_MASK; /* Power down sequence. */
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* @}
|
||||
*/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
/*!
|
||||
* @}
|
||||
*/
|
||||
#endif /* _FSL_GPC_H_ */
|
||||
@@ -1,342 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016-2020 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#ifndef _FSL_GPIO_H_
|
||||
#define _FSL_GPIO_H_
|
||||
|
||||
#include "fsl_common.h"
|
||||
|
||||
/*!
|
||||
* @addtogroup gpio_driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
|
||||
/*! @name Driver version */
|
||||
/*@{*/
|
||||
/*! @brief GPIO driver version 2.0.3. */
|
||||
#define FSL_GPIO_DRIVER_VERSION (MAKE_VERSION(2, 0, 3))
|
||||
/*@}*/
|
||||
|
||||
/*! @brief GPIO direction definition. */
|
||||
typedef enum _gpio_pin_direction
|
||||
{
|
||||
kGPIO_DigitalInput = 0U, /*!< Set current pin as digital input.*/
|
||||
kGPIO_DigitalOutput = 1U, /*!< Set current pin as digital output.*/
|
||||
} gpio_pin_direction_t;
|
||||
|
||||
/*! @brief GPIO interrupt mode definition. */
|
||||
typedef enum _gpio_interrupt_mode
|
||||
{
|
||||
kGPIO_NoIntmode = 0U, /*!< Set current pin general IO functionality.*/
|
||||
kGPIO_IntLowLevel = 1U, /*!< Set current pin interrupt is low-level sensitive.*/
|
||||
kGPIO_IntHighLevel = 2U, /*!< Set current pin interrupt is high-level sensitive.*/
|
||||
kGPIO_IntRisingEdge = 3U, /*!< Set current pin interrupt is rising-edge sensitive.*/
|
||||
kGPIO_IntFallingEdge = 4U, /*!< Set current pin interrupt is falling-edge sensitive.*/
|
||||
kGPIO_IntRisingOrFallingEdge = 5U, /*!< Enable the edge select bit to override the ICR register's configuration.*/
|
||||
} gpio_interrupt_mode_t;
|
||||
|
||||
/*! @brief GPIO Init structure definition. */
|
||||
typedef struct _gpio_pin_config
|
||||
{
|
||||
gpio_pin_direction_t direction; /*!< Specifies the pin direction. */
|
||||
uint8_t outputLogic; /*!< Set a default output logic, which has no use in input */
|
||||
gpio_interrupt_mode_t
|
||||
interruptMode; /*!< Specifies the pin interrupt mode, a value of @ref gpio_interrupt_mode_t. */
|
||||
} gpio_pin_config_t;
|
||||
|
||||
/*******************************************************************************
|
||||
* API
|
||||
******************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* @name GPIO Initialization and Configuration functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @brief Initializes the GPIO peripheral according to the specified
|
||||
* parameters in the initConfig.
|
||||
*
|
||||
* @param base GPIO base pointer.
|
||||
* @param pin Specifies the pin number
|
||||
* @param Config pointer to a @ref gpio_pin_config_t structure that
|
||||
* contains the configuration information.
|
||||
*/
|
||||
void GPIO_PinInit(GPIO_Type *base, uint32_t pin, const gpio_pin_config_t *Config);
|
||||
/*@}*/
|
||||
|
||||
/*!
|
||||
* @name GPIO Reads and Write Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @brief Sets the output level of the individual GPIO pin to logic 1 or 0.
|
||||
*
|
||||
* @param base GPIO base pointer.
|
||||
* @param pin GPIO port pin number.
|
||||
* @param output GPIOpin output logic level.
|
||||
* - 0: corresponding pin output low-logic level.
|
||||
* - 1: corresponding pin output high-logic level.
|
||||
*/
|
||||
void GPIO_PinWrite(GPIO_Type *base, uint32_t pin, uint8_t output);
|
||||
|
||||
/*!
|
||||
* @brief Sets the output level of the individual GPIO pin to logic 1 or 0.
|
||||
* @deprecated Do not use this function. It has been superceded by @ref GPIO_PinWrite.
|
||||
*/
|
||||
static inline void GPIO_WritePinOutput(GPIO_Type *base, uint32_t pin, uint8_t output)
|
||||
{
|
||||
GPIO_PinWrite(base, pin, output);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Sets the output level of the multiple GPIO pins to the logic 1.
|
||||
*
|
||||
* @param base GPIO peripheral base pointer (GPIO1, GPIO2, GPIO3, and so on.)
|
||||
* @param mask GPIO pin number macro
|
||||
*/
|
||||
static inline void GPIO_PortSet(GPIO_Type *base, uint32_t mask)
|
||||
{
|
||||
#if (defined(FSL_FEATURE_IGPIO_HAS_DR_SET) && (FSL_FEATURE_IGPIO_HAS_DR_SET == 1))
|
||||
base->DR_SET = mask;
|
||||
#else
|
||||
base->DR |= mask;
|
||||
#endif /* FSL_FEATURE_IGPIO_HAS_DR_SET */
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Sets the output level of the multiple GPIO pins to the logic 1.
|
||||
* @deprecated Do not use this function. It has been superceded by @ref GPIO_PortSet.
|
||||
*/
|
||||
static inline void GPIO_SetPinsOutput(GPIO_Type *base, uint32_t mask)
|
||||
{
|
||||
GPIO_PortSet(base, mask);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Sets the output level of the multiple GPIO pins to the logic 0.
|
||||
*
|
||||
* @param base GPIO peripheral base pointer (GPIO1, GPIO2, GPIO3, and so on.)
|
||||
* @param mask GPIO pin number macro
|
||||
*/
|
||||
static inline void GPIO_PortClear(GPIO_Type *base, uint32_t mask)
|
||||
{
|
||||
#if (defined(FSL_FEATURE_IGPIO_HAS_DR_CLEAR) && (FSL_FEATURE_IGPIO_HAS_DR_CLEAR == 1))
|
||||
base->DR_CLEAR = mask;
|
||||
#else
|
||||
base->DR &= ~mask;
|
||||
#endif /* FSL_FEATURE_IGPIO_HAS_DR_CLEAR */
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Sets the output level of the multiple GPIO pins to the logic 0.
|
||||
* @deprecated Do not use this function. It has been superceded by @ref GPIO_PortClear.
|
||||
*/
|
||||
static inline void GPIO_ClearPinsOutput(GPIO_Type *base, uint32_t mask)
|
||||
{
|
||||
GPIO_PortClear(base, mask);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Reverses the current output logic of the multiple GPIO pins.
|
||||
*
|
||||
* @param base GPIO peripheral base pointer (GPIO1, GPIO2, GPIO3, and so on.)
|
||||
* @param mask GPIO pin number macro
|
||||
*/
|
||||
static inline void GPIO_PortToggle(GPIO_Type *base, uint32_t mask)
|
||||
{
|
||||
#if (defined(FSL_FEATURE_IGPIO_HAS_DR_TOGGLE) && (FSL_FEATURE_IGPIO_HAS_DR_TOGGLE == 1))
|
||||
base->DR_TOGGLE = mask;
|
||||
#endif /* FSL_FEATURE_IGPIO_HAS_DR_TOGGLE */
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Reads the current input value of the GPIO port.
|
||||
*
|
||||
* @param base GPIO base pointer.
|
||||
* @param pin GPIO port pin number.
|
||||
* @retval GPIO port input value.
|
||||
*/
|
||||
static inline uint32_t GPIO_PinRead(GPIO_Type *base, uint32_t pin)
|
||||
{
|
||||
assert(pin < 32U);
|
||||
|
||||
return (((base->DR) >> pin) & 0x1U);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Reads the current input value of the GPIO port.
|
||||
* @deprecated Do not use this function. It has been superceded by @ref GPIO_PinRead.
|
||||
*/
|
||||
static inline uint32_t GPIO_ReadPinInput(GPIO_Type *base, uint32_t pin)
|
||||
{
|
||||
return GPIO_PinRead(base, pin);
|
||||
}
|
||||
/*@}*/
|
||||
|
||||
/*!
|
||||
* @name GPIO Reads Pad Status Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @brief Reads the current GPIO pin pad status.
|
||||
*
|
||||
* @param base GPIO base pointer.
|
||||
* @param pin GPIO port pin number.
|
||||
* @retval GPIO pin pad status value.
|
||||
*/
|
||||
static inline uint8_t GPIO_PinReadPadStatus(GPIO_Type *base, uint32_t pin)
|
||||
{
|
||||
assert(pin < 32U);
|
||||
|
||||
return (uint8_t)(((base->PSR) >> pin) & 0x1U);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Reads the current GPIO pin pad status.
|
||||
* @deprecated Do not use this function. It has been superceded by @ref GPIO_PinReadPadStatus.
|
||||
*/
|
||||
static inline uint8_t GPIO_ReadPadStatus(GPIO_Type *base, uint32_t pin)
|
||||
{
|
||||
return GPIO_PinReadPadStatus(base, pin);
|
||||
}
|
||||
|
||||
/*@}*/
|
||||
|
||||
/*!
|
||||
* @name Interrupts and flags management functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @brief Sets the current pin interrupt mode.
|
||||
*
|
||||
* @param base GPIO base pointer.
|
||||
* @param pin GPIO port pin number.
|
||||
* @param pinInterruptMode pointer to a @ref gpio_interrupt_mode_t structure
|
||||
* that contains the interrupt mode information.
|
||||
*/
|
||||
void GPIO_PinSetInterruptConfig(GPIO_Type *base, uint32_t pin, gpio_interrupt_mode_t pinInterruptMode);
|
||||
|
||||
/*!
|
||||
* @brief Sets the current pin interrupt mode.
|
||||
* @deprecated Do not use this function. It has been superceded by @ref GPIO_PinSetInterruptConfig.
|
||||
*/
|
||||
static inline void GPIO_SetPinInterruptConfig(GPIO_Type *base, uint32_t pin, gpio_interrupt_mode_t pinInterruptMode)
|
||||
{
|
||||
GPIO_PinSetInterruptConfig(base, pin, pinInterruptMode);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Enables the specific pin interrupt.
|
||||
*
|
||||
* @param base GPIO base pointer.
|
||||
* @param mask GPIO pin number macro.
|
||||
*/
|
||||
static inline void GPIO_PortEnableInterrupts(GPIO_Type *base, uint32_t mask)
|
||||
{
|
||||
base->IMR |= mask;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Enables the specific pin interrupt.
|
||||
*
|
||||
* @param base GPIO base pointer.
|
||||
* @param mask GPIO pin number macro.
|
||||
*/
|
||||
static inline void GPIO_EnableInterrupts(GPIO_Type *base, uint32_t mask)
|
||||
{
|
||||
GPIO_PortEnableInterrupts(base, mask);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Disables the specific pin interrupt.
|
||||
*
|
||||
* @param base GPIO base pointer.
|
||||
* @param mask GPIO pin number macro.
|
||||
*/
|
||||
static inline void GPIO_PortDisableInterrupts(GPIO_Type *base, uint32_t mask)
|
||||
{
|
||||
base->IMR &= ~mask;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Disables the specific pin interrupt.
|
||||
* @deprecated Do not use this function. It has been superceded by @ref GPIO_PortDisableInterrupts.
|
||||
*/
|
||||
static inline void GPIO_DisableInterrupts(GPIO_Type *base, uint32_t mask)
|
||||
{
|
||||
GPIO_PortDisableInterrupts(base, mask);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Reads individual pin interrupt status.
|
||||
*
|
||||
* @param base GPIO base pointer.
|
||||
* @retval current pin interrupt status flag.
|
||||
*/
|
||||
static inline uint32_t GPIO_PortGetInterruptFlags(GPIO_Type *base)
|
||||
{
|
||||
return base->ISR;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Reads individual pin interrupt status.
|
||||
*
|
||||
* @param base GPIO base pointer.
|
||||
* @retval current pin interrupt status flag.
|
||||
*/
|
||||
static inline uint32_t GPIO_GetPinsInterruptFlags(GPIO_Type *base)
|
||||
{
|
||||
return GPIO_PortGetInterruptFlags(base);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Clears pin interrupt flag. Status flags are cleared by
|
||||
* writing a 1 to the corresponding bit position.
|
||||
*
|
||||
* @param base GPIO base pointer.
|
||||
* @param mask GPIO pin number macro.
|
||||
*/
|
||||
static inline void GPIO_PortClearInterruptFlags(GPIO_Type *base, uint32_t mask)
|
||||
{
|
||||
base->ISR = mask;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Clears pin interrupt flag. Status flags are cleared by
|
||||
* writing a 1 to the corresponding bit position.
|
||||
*
|
||||
* @param base GPIO base pointer.
|
||||
* @param mask GPIO pin number macro.
|
||||
*/
|
||||
static inline void GPIO_ClearPinsInterruptFlags(GPIO_Type *base, uint32_t mask)
|
||||
{
|
||||
GPIO_PortClearInterruptFlags(base, mask);
|
||||
}
|
||||
/*@}*/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* _FSL_GPIO_H_*/
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,180 +0,0 @@
|
||||
/*
|
||||
* Copyright 2017, 2019 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
#ifndef _FSL_KPP_H_
|
||||
#define _FSL_KPP_H_
|
||||
|
||||
#include "fsl_common.h"
|
||||
|
||||
/*!
|
||||
* @addtogroup kpp
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
|
||||
/*! @name Driver version */
|
||||
/*@{*/
|
||||
/*! @brief KPP driver version 2.0.0. */
|
||||
#define FSL_KPP_DRIVER_VERSION (MAKE_VERSION(2, 0, 0))
|
||||
/*@}*/
|
||||
|
||||
#define KPP_KEYPAD_COLUMNNUM_MAX (8U)
|
||||
#define KPP_KEYPAD_ROWNUM_MAX (8U)
|
||||
|
||||
/*! @brief List of interrupts supported by the peripheral. This
|
||||
* enumeration uses one-bot encoding to allow a logical OR of multiple
|
||||
* members. Members usually map to interrupt enable bits in one or more
|
||||
* peripheral registers.
|
||||
*/
|
||||
typedef enum _kpp_interrupt_enable
|
||||
{
|
||||
kKPP_keyDepressInterrupt = KPP_KPSR_KDIE_MASK, /*!< Keypad depress interrupt source */
|
||||
kKPP_keyReleaseInterrupt = KPP_KPSR_KRIE_MASK /*!< Keypad release interrupt source */
|
||||
} kpp_interrupt_enable_t;
|
||||
|
||||
/*! @brief Lists of KPP synchronize chain operation. */
|
||||
typedef enum _kpp_sync_operation
|
||||
{
|
||||
kKPP_ClearKeyDepressSyncChain = KPP_KPSR_KDSC_MASK, /*!< Keypad depress interrupt status. */
|
||||
kKPP_SetKeyReleasesSyncChain = KPP_KPSR_KRSS_MASK, /*!< Keypad release interrupt status. */
|
||||
} kpp_sync_operation_t;
|
||||
|
||||
/*! @brief Lists of KPP status. */
|
||||
typedef struct _kpp_config
|
||||
{
|
||||
uint8_t activeRow; /*!< The row number: bit 7 ~ 0 represents the row 7 ~ 0. */
|
||||
uint8_t activeColumn; /*!< The column number: bit 7 ~ 0 represents the column 7 ~ 0. */
|
||||
uint16_t interrupt; /*!< KPP interrupt source. A logical OR of "kpp_interrupt_enable_t". */
|
||||
} kpp_config_t;
|
||||
|
||||
/*******************************************************************************
|
||||
* API
|
||||
******************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* @name Initialization and De-initialization
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @brief KPP initialize.
|
||||
* This function ungates the KPP clock and initializes KPP.
|
||||
* This function must be called before calling any other KPP driver functions.
|
||||
*
|
||||
* @param base KPP peripheral base address.
|
||||
* @param configure The KPP configuration structure pointer.
|
||||
*/
|
||||
void KPP_Init(KPP_Type *base, kpp_config_t *configure);
|
||||
|
||||
/*!
|
||||
* @brief Deinitializes the KPP module and gates the clock.
|
||||
* This function gates the KPP clock. As a result, the KPP
|
||||
* module doesn't work after calling this function.
|
||||
*
|
||||
* @param base KPP peripheral base address.
|
||||
*/
|
||||
void KPP_Deinit(KPP_Type *base);
|
||||
|
||||
/* @} */
|
||||
|
||||
/*!
|
||||
* @name KPP Basic Operation
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @brief Enable the interrupt.
|
||||
*
|
||||
* @param base KPP peripheral base address.
|
||||
* @param mask KPP interrupts to enable. This is a logical OR of the
|
||||
* enumeration :: kpp_interrupt_enable_t.
|
||||
*/
|
||||
static inline void KPP_EnableInterrupts(KPP_Type *base, uint16_t mask)
|
||||
{
|
||||
uint16_t data = (uint16_t)(base->KPSR & ~(KPP_KPSR_KPKR_MASK | KPP_KPSR_KPKD_MASK));
|
||||
base->KPSR = data | mask;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Disable the interrupt.
|
||||
*
|
||||
* @param base KPP peripheral base address.
|
||||
* @param mask KPP interrupts to disable. This is a logical OR of the
|
||||
* enumeration :: kpp_interrupt_enable_t.
|
||||
*/
|
||||
static inline void KPP_DisableInterrupts(KPP_Type *base, uint16_t mask)
|
||||
{
|
||||
base->KPSR &= ~(mask | KPP_KPSR_KPKR_MASK | KPP_KPSR_KPKD_MASK);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Gets the KPP interrupt event status.
|
||||
*
|
||||
* @param base KPP peripheral base address.
|
||||
* @return The status of the KPP. Application can use the enum type in the "kpp_interrupt_enable_t"
|
||||
* to get the right status of the related event.
|
||||
*/
|
||||
static inline uint16_t KPP_GetStatusFlag(KPP_Type *base)
|
||||
{
|
||||
return (base->KPSR & (KPP_KPSR_KPKR_MASK | KPP_KPSR_KPKD_MASK)) << KPP_KPSR_KDIE_SHIFT;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Clears KPP status flag.
|
||||
*
|
||||
* @param base KPP peripheral base address.
|
||||
* @param mask KPP mask to be cleared. This is a logical OR of the
|
||||
* enumeration :: kpp_interrupt_enable_t.
|
||||
*/
|
||||
static inline void KPP_ClearStatusFlag(KPP_Type *base, uint16_t mask)
|
||||
{
|
||||
base->KPSR |= (uint16_t)((mask) >> KPP_KPSR_KDIE_SHIFT);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Set KPP synchronization chain.
|
||||
*
|
||||
* @param base KPP peripheral base address.
|
||||
* @param mask KPP mask to be cleared. This is a logical OR of the
|
||||
* enumeration :: kpp_sync_operation_t.
|
||||
*/
|
||||
static inline void KPP_SetSynchronizeChain(KPP_Type *base, uint16_t mask)
|
||||
{
|
||||
uint16_t data = base->KPSR & (KPP_KPSR_KRSS_MASK | KPP_KPSR_KDSC_MASK | KPP_KPSR_KRIE_MASK | KPP_KPSR_KDIE_MASK);
|
||||
base->KPSR = data | mask;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Keypad press scanning.
|
||||
*
|
||||
* This function will scanning all columns and rows. so
|
||||
* all scanning data will be stored in the data pointer.
|
||||
*
|
||||
* @param base KPP peripheral base address.
|
||||
* @param data KPP key press scanning data. The data buffer should be prepared with
|
||||
* length at least equal to KPP_KEYPAD_COLUMNNUM_MAX * KPP_KEYPAD_ROWNUM_MAX.
|
||||
* the data pointer is recommended to be a array like uint8_t data[KPP_KEYPAD_COLUMNNUM_MAX].
|
||||
* for example the data[2] = 4, that means in column 1 row 2 has a key press event.
|
||||
* @param clockSrc_Hz Source clock.
|
||||
*/
|
||||
void KPP_keyPressScanning(KPP_Type *base, uint8_t *data, uint32_t clockSrc_Hz);
|
||||
|
||||
/* @} */
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
/*! @}*/
|
||||
|
||||
#endif /* _FSL_KPP_H_*/
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,157 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016-2020 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
#ifndef _FSL_LPI2C_EDMA_H_
|
||||
#define _FSL_LPI2C_EDMA_H_
|
||||
|
||||
#include "fsl_lpi2c.h"
|
||||
#include "fsl_edma.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
|
||||
/*! @name Driver version */
|
||||
/*@{*/
|
||||
/*! @brief LPI2C EDMA driver version 2.1.11. */
|
||||
#define FSL_LPI2C_EDMA_DRIVER_VERSION (MAKE_VERSION(2, 1, 11))
|
||||
/*@}*/
|
||||
|
||||
/*!
|
||||
* @addtogroup lpi2c_master_edma_driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Forward declaration of the transfer descriptor and handle typedefs. */
|
||||
typedef struct _lpi2c_master_edma_handle lpi2c_master_edma_handle_t;
|
||||
|
||||
/*!
|
||||
* @brief Master DMA completion callback function pointer type.
|
||||
*
|
||||
* This callback is used only for the non-blocking master transfer API. Specify the callback you wish to use
|
||||
* in the call to LPI2C_MasterCreateEDMAHandle().
|
||||
*
|
||||
* @param base The LPI2C peripheral base address.
|
||||
* @param handle Handle associated with the completed transfer.
|
||||
* @param completionStatus Either kStatus_Success or an error code describing how the transfer completed.
|
||||
* @param userData Arbitrary pointer-sized value passed from the application.
|
||||
*/
|
||||
typedef void (*lpi2c_master_edma_transfer_callback_t)(LPI2C_Type *base,
|
||||
lpi2c_master_edma_handle_t *handle,
|
||||
status_t completionStatus,
|
||||
void *userData);
|
||||
|
||||
/*!
|
||||
* @brief Driver handle for master DMA APIs.
|
||||
* @note The contents of this structure are private and subject to change.
|
||||
*/
|
||||
struct _lpi2c_master_edma_handle
|
||||
{
|
||||
LPI2C_Type *base; /*!< LPI2C base pointer. */
|
||||
bool isBusy; /*!< Transfer state machine current state. */
|
||||
uint8_t nbytes; /*!< eDMA minor byte transfer count initially configured. */
|
||||
uint16_t commandBuffer[7]; /*!< LPI2C command sequence. */
|
||||
lpi2c_master_transfer_t transfer; /*!< Copy of the current transfer info. */
|
||||
lpi2c_master_edma_transfer_callback_t completionCallback; /*!< Callback function pointer. */
|
||||
void *userData; /*!< Application data passed to callback. */
|
||||
edma_handle_t *rx; /*!< Handle for receive DMA channel. */
|
||||
edma_handle_t *tx; /*!< Handle for transmit DMA channel. */
|
||||
edma_tcd_t tcds[3]; /*!< Software TCD. Three are allocated to provide enough room to align to 32-bytes. */
|
||||
};
|
||||
|
||||
/*! @} */
|
||||
|
||||
/*******************************************************************************
|
||||
* API
|
||||
******************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* @addtogroup lpi2c_master_edma_driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*! @name Master DMA */
|
||||
/*@{*/
|
||||
|
||||
/*!
|
||||
* @brief Create a new handle for the LPI2C master DMA APIs.
|
||||
*
|
||||
* The creation of a handle is for use with the DMA APIs. Once a handle
|
||||
* is created, there is not a corresponding destroy handle. If the user wants to
|
||||
* terminate a transfer, the LPI2C_MasterTransferAbortEDMA() API shall be called.
|
||||
*
|
||||
* For devices where the LPI2C send and receive DMA requests are OR'd together, the @a txDmaHandle
|
||||
* parameter is ignored and may be set to NULL.
|
||||
*
|
||||
* @param base The LPI2C peripheral base address.
|
||||
* @param[out] handle Pointer to the LPI2C master driver handle.
|
||||
* @param rxDmaHandle Handle for the eDMA receive channel. Created by the user prior to calling this function.
|
||||
* @param txDmaHandle Handle for the eDMA transmit channel. Created by the user prior to calling this function.
|
||||
* @param callback User provided pointer to the asynchronous callback function.
|
||||
* @param userData User provided pointer to the application callback data.
|
||||
*/
|
||||
void LPI2C_MasterCreateEDMAHandle(LPI2C_Type *base,
|
||||
lpi2c_master_edma_handle_t *handle,
|
||||
edma_handle_t *rxDmaHandle,
|
||||
edma_handle_t *txDmaHandle,
|
||||
lpi2c_master_edma_transfer_callback_t callback,
|
||||
void *userData);
|
||||
|
||||
/*!
|
||||
* @brief Performs a non-blocking DMA-based transaction on the I2C bus.
|
||||
*
|
||||
* The callback specified when the @a handle was created is invoked when the transaction has
|
||||
* completed.
|
||||
*
|
||||
* @param base The LPI2C peripheral base address.
|
||||
* @param handle Pointer to the LPI2C master driver handle.
|
||||
* @param transfer The pointer to the transfer descriptor.
|
||||
* @retval kStatus_Success The transaction was started successfully.
|
||||
* @retval #kStatus_LPI2C_Busy Either another master is currently utilizing the bus, or another DMA
|
||||
* transaction is already in progress.
|
||||
*/
|
||||
status_t LPI2C_MasterTransferEDMA(LPI2C_Type *base,
|
||||
lpi2c_master_edma_handle_t *handle,
|
||||
lpi2c_master_transfer_t *transfer);
|
||||
|
||||
/*!
|
||||
* @brief Returns number of bytes transferred so far.
|
||||
*
|
||||
* @param base The LPI2C peripheral base address.
|
||||
* @param handle Pointer to the LPI2C master driver handle.
|
||||
* @param[out] count Number of bytes transferred so far by the non-blocking transaction.
|
||||
* @retval kStatus_Success
|
||||
* @retval kStatus_NoTransferInProgress There is not a DMA transaction currently in progress.
|
||||
*/
|
||||
status_t LPI2C_MasterTransferGetCountEDMA(LPI2C_Type *base, lpi2c_master_edma_handle_t *handle, size_t *count);
|
||||
|
||||
/*!
|
||||
* @brief Terminates a non-blocking LPI2C master transmission early.
|
||||
*
|
||||
* @note It is not safe to call this function from an IRQ handler that has a higher priority than the
|
||||
* eDMA peripheral's IRQ priority.
|
||||
*
|
||||
* @param base The LPI2C peripheral base address.
|
||||
* @param handle Pointer to the LPI2C master driver handle.
|
||||
* @retval kStatus_Success A transaction was successfully aborted.
|
||||
* @retval #kStatus_LPI2C_Idle There is not a DMA transaction currently in progress.
|
||||
*/
|
||||
status_t LPI2C_MasterTransferAbortEDMA(LPI2C_Type *base, lpi2c_master_edma_handle_t *handle);
|
||||
|
||||
/*@}*/
|
||||
|
||||
/*! @} */
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _FSL_LPI2C_EDMA_H_ */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,301 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016-2019 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
#ifndef _FSL_LPSPI_EDMA_H_
|
||||
#define _FSL_LPSPI_EDMA_H_
|
||||
|
||||
#include "fsl_lpspi.h"
|
||||
#include "fsl_edma.h"
|
||||
|
||||
/*!
|
||||
* @addtogroup lpspi_edma_driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/***********************************************************************************************************************
|
||||
* Definitions
|
||||
**********************************************************************************************************************/
|
||||
/*! @name Driver version */
|
||||
/*@{*/
|
||||
/*! @brief LPSPI EDMA driver version 2.0.5. */
|
||||
#define FSL_LPSPI_EDMA_DRIVER_VERSION (MAKE_VERSION(2, 0, 5))
|
||||
/*@}*/
|
||||
|
||||
/*!
|
||||
* @brief Forward declaration of the _lpspi_master_edma_handle typedefs.
|
||||
*/
|
||||
typedef struct _lpspi_master_edma_handle lpspi_master_edma_handle_t;
|
||||
|
||||
/*!
|
||||
* @brief Forward declaration of the _lpspi_slave_edma_handle typedefs.
|
||||
*/
|
||||
typedef struct _lpspi_slave_edma_handle lpspi_slave_edma_handle_t;
|
||||
|
||||
/*!
|
||||
* @brief Completion callback function pointer type.
|
||||
*
|
||||
* @param base LPSPI peripheral base address.
|
||||
* @param handle Pointer to the handle for the LPSPI master.
|
||||
* @param status Success or error code describing whether the transfer completed.
|
||||
* @param userData Arbitrary pointer-dataSized value passed from the application.
|
||||
*/
|
||||
typedef void (*lpspi_master_edma_transfer_callback_t)(LPSPI_Type *base,
|
||||
lpspi_master_edma_handle_t *handle,
|
||||
status_t status,
|
||||
void *userData);
|
||||
/*!
|
||||
* @brief Completion callback function pointer type.
|
||||
*
|
||||
* @param base LPSPI peripheral base address.
|
||||
* @param handle Pointer to the handle for the LPSPI slave.
|
||||
* @param status Success or error code describing whether the transfer completed.
|
||||
* @param userData Arbitrary pointer-dataSized value passed from the application.
|
||||
*/
|
||||
typedef void (*lpspi_slave_edma_transfer_callback_t)(LPSPI_Type *base,
|
||||
lpspi_slave_edma_handle_t *handle,
|
||||
status_t status,
|
||||
void *userData);
|
||||
|
||||
/*! @brief LPSPI master eDMA transfer handle structure used for transactional API. */
|
||||
struct _lpspi_master_edma_handle
|
||||
{
|
||||
volatile bool isPcsContinuous; /*!< Is PCS continuous in transfer. */
|
||||
|
||||
volatile bool isByteSwap; /*!< A flag that whether should byte swap. */
|
||||
|
||||
volatile uint8_t fifoSize; /*!< FIFO dataSize. */
|
||||
|
||||
volatile uint8_t rxWatermark; /*!< Rx watermark. */
|
||||
|
||||
volatile uint8_t bytesEachWrite; /*!< Bytes for each write TDR. */
|
||||
volatile uint8_t bytesEachRead; /*!< Bytes for each read RDR. */
|
||||
|
||||
volatile uint8_t bytesLastRead; /*!< Bytes for last read RDR. */
|
||||
volatile bool isThereExtraRxBytes; /*!< Is there extra RX byte. */
|
||||
|
||||
uint8_t *volatile txData; /*!< Send buffer. */
|
||||
uint8_t *volatile rxData; /*!< Receive buffer. */
|
||||
volatile size_t txRemainingByteCount; /*!< Number of bytes remaining to send.*/
|
||||
volatile size_t rxRemainingByteCount; /*!< Number of bytes remaining to receive.*/
|
||||
|
||||
volatile uint32_t writeRegRemainingTimes; /*!< Write TDR register remaining times. */
|
||||
volatile uint32_t readRegRemainingTimes; /*!< Read RDR register remaining times. */
|
||||
|
||||
uint32_t totalByteCount; /*!< Number of transfer bytes*/
|
||||
|
||||
uint32_t txBuffIfNull; /*!< Used if there is not txData for DMA purpose.*/
|
||||
uint32_t rxBuffIfNull; /*!< Used if there is not rxData for DMA purpose.*/
|
||||
|
||||
uint32_t transmitCommand; /*!< Used to write TCR for DMA purpose.*/
|
||||
|
||||
volatile uint8_t state; /*!< LPSPI transfer state , _lpspi_transfer_state.*/
|
||||
|
||||
uint8_t nbytes; /*!< eDMA minor byte transfer count initially configured. */
|
||||
|
||||
lpspi_master_edma_transfer_callback_t callback; /*!< Completion callback. */
|
||||
void *userData; /*!< Callback user data. */
|
||||
|
||||
edma_handle_t *edmaRxRegToRxDataHandle; /*!<edma_handle_t handle point used for RxReg to RxData buff*/
|
||||
edma_handle_t *edmaTxDataToTxRegHandle; /*!<edma_handle_t handle point used for TxData to TxReg buff*/
|
||||
|
||||
edma_tcd_t lpspiSoftwareTCD[3]; /*!<SoftwareTCD, internal used*/
|
||||
};
|
||||
|
||||
/*! @brief LPSPI slave eDMA transfer handle structure used for transactional API.*/
|
||||
struct _lpspi_slave_edma_handle
|
||||
{
|
||||
volatile bool isByteSwap; /*!< A flag that whether should byte swap. */
|
||||
|
||||
volatile uint8_t fifoSize; /*!< FIFO dataSize. */
|
||||
|
||||
volatile uint8_t rxWatermark; /*!< Rx watermark. */
|
||||
|
||||
volatile uint8_t bytesEachWrite; /*!< Bytes for each write TDR. */
|
||||
volatile uint8_t bytesEachRead; /*!< Bytes for each read RDR. */
|
||||
|
||||
volatile uint8_t bytesLastRead; /*!< Bytes for last read RDR. */
|
||||
volatile bool isThereExtraRxBytes; /*!< Is there extra RX byte. */
|
||||
|
||||
uint8_t nbytes; /*!< eDMA minor byte transfer count initially configured. */
|
||||
|
||||
uint8_t *volatile txData; /*!< Send buffer. */
|
||||
uint8_t *volatile rxData; /*!< Receive buffer. */
|
||||
volatile size_t txRemainingByteCount; /*!< Number of bytes remaining to send.*/
|
||||
volatile size_t rxRemainingByteCount; /*!< Number of bytes remaining to receive.*/
|
||||
|
||||
volatile uint32_t writeRegRemainingTimes; /*!< Write TDR register remaining times. */
|
||||
volatile uint32_t readRegRemainingTimes; /*!< Read RDR register remaining times. */
|
||||
|
||||
uint32_t totalByteCount; /*!< Number of transfer bytes*/
|
||||
|
||||
uint32_t txBuffIfNull; /*!< Used if there is not txData for DMA purpose.*/
|
||||
uint32_t rxBuffIfNull; /*!< Used if there is not rxData for DMA purpose.*/
|
||||
|
||||
volatile uint8_t state; /*!< LPSPI transfer state.*/
|
||||
|
||||
uint32_t errorCount; /*!< Error count for slave transfer.*/
|
||||
|
||||
lpspi_slave_edma_transfer_callback_t callback; /*!< Completion callback. */
|
||||
void *userData; /*!< Callback user data. */
|
||||
|
||||
edma_handle_t *edmaRxRegToRxDataHandle; /*!<edma_handle_t handle point used for RxReg to RxData buff*/
|
||||
edma_handle_t *edmaTxDataToTxRegHandle; /*!<edma_handle_t handle point used for TxData to TxReg*/
|
||||
|
||||
edma_tcd_t lpspiSoftwareTCD[2]; /*!<SoftwareTCD, internal used*/
|
||||
};
|
||||
|
||||
/***********************************************************************************************************************
|
||||
* API
|
||||
**********************************************************************************************************************/
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif /*_cplusplus*/
|
||||
|
||||
/*Transactional APIs*/
|
||||
|
||||
/*!
|
||||
* @brief Initializes the LPSPI master eDMA handle.
|
||||
*
|
||||
* This function initializes the LPSPI eDMA handle which can be used for other LPSPI transactional APIs. Usually, for a
|
||||
* specified LPSPI instance, call this API once to get the initialized handle.
|
||||
*
|
||||
* Note that the LPSPI eDMA has a separated (Rx and Rx as two sources) or shared (Rx and Tx are the same source) DMA
|
||||
* request source.
|
||||
* (1) For a separated DMA request source, enable and set the Rx DMAMUX source for edmaRxRegToRxDataHandle and
|
||||
* Tx DMAMUX source for edmaIntermediaryToTxRegHandle.
|
||||
* (2) For a shared DMA request source, enable and set the Rx/Rx DMAMUX source for edmaRxRegToRxDataHandle.
|
||||
*
|
||||
* @param base LPSPI peripheral base address.
|
||||
* @param handle LPSPI handle pointer to lpspi_master_edma_handle_t.
|
||||
* @param callback LPSPI callback.
|
||||
* @param userData callback function parameter.
|
||||
* @param edmaRxRegToRxDataHandle edmaRxRegToRxDataHandle pointer to edma_handle_t.
|
||||
* @param edmaTxDataToTxRegHandle edmaTxDataToTxRegHandle pointer to edma_handle_t.
|
||||
*/
|
||||
void LPSPI_MasterTransferCreateHandleEDMA(LPSPI_Type *base,
|
||||
lpspi_master_edma_handle_t *handle,
|
||||
lpspi_master_edma_transfer_callback_t callback,
|
||||
void *userData,
|
||||
edma_handle_t *edmaRxRegToRxDataHandle,
|
||||
edma_handle_t *edmaTxDataToTxRegHandle);
|
||||
|
||||
/*!
|
||||
* @brief LPSPI master transfer data using eDMA.
|
||||
*
|
||||
* This function transfers data using eDMA. This is a non-blocking function, which returns right away. When all data
|
||||
* is transferred, the callback function is called.
|
||||
*
|
||||
* Note:
|
||||
* The transfer data size should be an integer multiple of bytesPerFrame if bytesPerFrame is less than or equal to 4.
|
||||
* For bytesPerFrame greater than 4:
|
||||
* The transfer data size should be equal to bytesPerFrame if the bytesPerFrame is not an integer multiple of 4.
|
||||
* Otherwise, the transfer data size can be an integer multiple of bytesPerFrame.
|
||||
*
|
||||
* @param base LPSPI peripheral base address.
|
||||
* @param handle pointer to lpspi_master_edma_handle_t structure which stores the transfer state.
|
||||
* @param transfer pointer to lpspi_transfer_t structure.
|
||||
* @return status of status_t.
|
||||
*/
|
||||
status_t LPSPI_MasterTransferEDMA(LPSPI_Type *base, lpspi_master_edma_handle_t *handle, lpspi_transfer_t *transfer);
|
||||
|
||||
/*!
|
||||
* @brief LPSPI master aborts a transfer which is using eDMA.
|
||||
*
|
||||
* This function aborts a transfer which is using eDMA.
|
||||
*
|
||||
* @param base LPSPI peripheral base address.
|
||||
* @param handle pointer to lpspi_master_edma_handle_t structure which stores the transfer state.
|
||||
*/
|
||||
void LPSPI_MasterTransferAbortEDMA(LPSPI_Type *base, lpspi_master_edma_handle_t *handle);
|
||||
|
||||
/*!
|
||||
* @brief Gets the master eDMA transfer remaining bytes.
|
||||
*
|
||||
* This function gets the master eDMA transfer remaining bytes.
|
||||
*
|
||||
* @param base LPSPI peripheral base address.
|
||||
* @param handle pointer to lpspi_master_edma_handle_t structure which stores the transfer state.
|
||||
* @param count Number of bytes transferred so far by the EDMA transaction.
|
||||
* @return status of status_t.
|
||||
*/
|
||||
status_t LPSPI_MasterTransferGetCountEDMA(LPSPI_Type *base, lpspi_master_edma_handle_t *handle, size_t *count);
|
||||
|
||||
/*!
|
||||
* @brief Initializes the LPSPI slave eDMA handle.
|
||||
*
|
||||
* This function initializes the LPSPI eDMA handle which can be used for other LPSPI transactional APIs. Usually, for a
|
||||
* specified LPSPI instance, call this API once to get the initialized handle.
|
||||
*
|
||||
* Note that LPSPI eDMA has a separated (Rx and Tx as two sources) or shared (Rx and Tx as the same source) DMA request
|
||||
* source.
|
||||
*
|
||||
* (1) For a separated DMA request source, enable and set the Rx DMAMUX source for edmaRxRegToRxDataHandle and
|
||||
* Tx DMAMUX source for edmaTxDataToTxRegHandle.
|
||||
* (2) For a shared DMA request source, enable and set the Rx/Rx DMAMUX source for edmaRxRegToRxDataHandle .
|
||||
*
|
||||
* @param base LPSPI peripheral base address.
|
||||
* @param handle LPSPI handle pointer to lpspi_slave_edma_handle_t.
|
||||
* @param callback LPSPI callback.
|
||||
* @param userData callback function parameter.
|
||||
* @param edmaRxRegToRxDataHandle edmaRxRegToRxDataHandle pointer to edma_handle_t.
|
||||
* @param edmaTxDataToTxRegHandle edmaTxDataToTxRegHandle pointer to edma_handle_t.
|
||||
*/
|
||||
void LPSPI_SlaveTransferCreateHandleEDMA(LPSPI_Type *base,
|
||||
lpspi_slave_edma_handle_t *handle,
|
||||
lpspi_slave_edma_transfer_callback_t callback,
|
||||
void *userData,
|
||||
edma_handle_t *edmaRxRegToRxDataHandle,
|
||||
edma_handle_t *edmaTxDataToTxRegHandle);
|
||||
|
||||
/*!
|
||||
* @brief LPSPI slave transfers data using eDMA.
|
||||
*
|
||||
* This function transfers data using eDMA. This is a non-blocking function, which return right away. When all data
|
||||
* is transferred, the callback function is called.
|
||||
*
|
||||
* Note:
|
||||
* The transfer data size should be an integer multiple of bytesPerFrame if bytesPerFrame is less than or equal to 4.
|
||||
* For bytesPerFrame greater than 4:
|
||||
* The transfer data size should be equal to bytesPerFrame if the bytesPerFrame is not an integer multiple of 4.
|
||||
* Otherwise, the transfer data size can be an integer multiple of bytesPerFrame.
|
||||
*
|
||||
* @param base LPSPI peripheral base address.
|
||||
* @param handle pointer to lpspi_slave_edma_handle_t structure which stores the transfer state.
|
||||
* @param transfer pointer to lpspi_transfer_t structure.
|
||||
* @return status of status_t.
|
||||
*/
|
||||
status_t LPSPI_SlaveTransferEDMA(LPSPI_Type *base, lpspi_slave_edma_handle_t *handle, lpspi_transfer_t *transfer);
|
||||
|
||||
/*!
|
||||
* @brief LPSPI slave aborts a transfer which is using eDMA.
|
||||
*
|
||||
* This function aborts a transfer which is using eDMA.
|
||||
*
|
||||
* @param base LPSPI peripheral base address.
|
||||
* @param handle pointer to lpspi_slave_edma_handle_t structure which stores the transfer state.
|
||||
*/
|
||||
void LPSPI_SlaveTransferAbortEDMA(LPSPI_Type *base, lpspi_slave_edma_handle_t *handle);
|
||||
|
||||
/*!
|
||||
* @brief Gets the slave eDMA transfer remaining bytes.
|
||||
*
|
||||
* This function gets the slave eDMA transfer remaining bytes.
|
||||
*
|
||||
* @param base LPSPI peripheral base address.
|
||||
* @param handle pointer to lpspi_slave_edma_handle_t structure which stores the transfer state.
|
||||
* @param count Number of bytes transferred so far by the eDMA transaction.
|
||||
* @return status of status_t.
|
||||
*/
|
||||
status_t LPSPI_SlaveTransferGetCountEDMA(LPSPI_Type *base, lpspi_slave_edma_handle_t *handle, size_t *count);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
/*! @}*/
|
||||
|
||||
#endif /*_FSL_LPSPI_EDMA_H_*/
|
||||
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user