![]() |
MCUXpresso SDK API Reference Manual
Rev 2.16.000
NXP Semiconductors
|
Macros | |
#define | FSL_DRIVER_TRANSFER_DOUBLE_WEAK_IRQ 1 |
Macro to use the default weak IRQ handler in drivers. More... | |
#define | MAKE_STATUS(group, code) ((((group)*100L) + (code))) |
Construct a status code value from a group and code number. More... | |
#define | MAKE_VERSION(major, minor, bugfix) (((major)*65536L) + ((minor)*256L) + (bugfix)) |
Construct the version number for drivers. More... | |
#define | ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) |
Computes the number of elements in an array. More... | |
#define | UINT64_H(X) ((uint32_t)((((uint64_t) (X)) >> 32U) & 0x0FFFFFFFFULL)) |
Macro to get upper 32 bits of a 64-bit value. | |
#define | UINT64_L(X) ((uint32_t)(((uint64_t) (X)) & 0x0FFFFFFFFULL)) |
Macro to get lower 32 bits of a 64-bit value. | |
#define | SUPPRESS_FALL_THROUGH_WARNING() |
For switch case code block, if case section ends without "break;" statement, there wil be fallthrough warning with compiler flag -Wextra or -Wimplicit-fallthrough=n when using armgcc. More... | |
#define | SDK_DSC_DEFAULT_INT_PRIO 1U |
Default DSC interrupt priority number. More... | |
#define | SetIRQBasePriority(x) __EI##x() |
Set base core IRQ priority, that core will response the interrupt request with priority >= base IRQ priority. | |
#define | PeriphReadReg(reg) (reg) |
Read register value. More... | |
#define | PeriphWriteReg(reg, data) (reg) = (data) |
Write data to register. More... | |
#define | PeriphSetBits(reg, bitMask) (reg) |= (bitMask) |
Set specified bits in register. More... | |
#define | PeriphClearBits(reg, bitMask) (reg) &= (~(bitMask)) |
Clear specified bits in register. More... | |
#define | PeriphInvertBits(reg, bitMask) (reg) ^= (bitMask) |
Invert specified bits in register. More... | |
#define | PeriphGetBits(reg, bitMask) ((reg) & (bitMask)) |
Get specified bits in register. More... | |
#define | PeriphWriteBitGroup(reg, bitMask, bitValue) (reg) = ((reg) & ~(bitMask)) | ((bitValue) & (bitMask)) |
Write group of bits to register. More... | |
#define | PeriphSafeClearFlags(reg, allFlagsMask, flagMask) (reg) = ((reg) & (~(allFlagsMask))) | ((flagMask) & (allFlagsMask)) |
Clear (acknowledge) flags which are active-high and are cleared-by-write-one. More... | |
#define | PeriphSafeClearBits(reg, allFlagsMask, bitMask) (reg) = ((reg) & (~((allFlagsMask) | (bitMask)))) |
Clear selected bits without modifying (acknowledge) bit flags which are active-high and are cleared-by-write-one. More... | |
#define | PeriphSafeSetBits(reg, allFlagsMask, bitMask) (reg) = ((reg) & (~(allFlagsMask))) | ((bitMask) & (~(allFlagsMask))) |
Set selected bits without modifying (acknowledge) bit flags which are active-high and are cleared-by-write-one. More... | |
#define | PeriphSafeWriteBitGroup(reg, allFlagsMask, bitMask, bitValue) (reg) = ((reg) & (~((allFlagsMask) | (bitMask)))) | ((bitValue) & (bitMask) & (~(allFlagsMask))) |
Write group of bits without modifying (acknowledge) bit flags which are active-high and are cleared-by-write-one. More... | |
#define | SDK_GET_REGISTER_BYTE_ADDR(ipType, ipBase, regName) ((2UL * ((uint32_t)(ipBase))) + ((uint32_t)(uint8_t *)&(((ipType *)0)->regName))) |
Get IP register byte address with uint32_t type. More... | |
Typedefs | |
typedef int32_t | status_t |
Type used for all status and error return values. More... | |
Functions | |
void | SDK_DelayAtLeastUs (uint32_t delayTime_us, uint32_t coreClock_Hz) |
Delay at least for some time. More... | |
static uint32_t | DisableGlobalIRQ (void) |
Disable the global IRQ. | |
static void | EnableGlobalIRQ (uint32_t irqSts) |
Enable the global IRQ. | |
static bool | isIRQAllowed (void) |
Check if currently core is able to response IRQ. | |
void | SDK_DelayCoreCycles (uint32_t u32Num) |
Delay core cycles. More... | |
uint32_t | SDK_CovertUsToCount (uint32_t u32Us, uint32_t u32Hz) |
Covert us to count with fixed-point calculation. More... | |
uint32_t | SDK_CovertCountToUs (uint32_t u32Count, uint32_t u32Hz) |
Covert count to us with fixed-point calculation. More... | |
uint32_t | SDK_CovertMsToCount (uint32_t u32Ms, uint32_t u32Hz) |
Covert ms to count with fixed-point calculation. More... | |
uint32_t | SDK_CovertCountToMs (uint32_t u32Count, uint32_t u32Hz) |
Covert count to ms with fixed-point calculation. More... | |
void | SDK_DelayAtLeastMs (uint32_t delayTime_ms, uint32_t coreClock_Hz) |
Delay at least for some time in millisecond unit. More... | |
Driver version | |
#define | FSL_COMMON_DRIVER_VERSION (MAKE_VERSION(2, 4, 1)) |
common driver version. More... | |
Debug console type definition. | |
#define | DEBUG_CONSOLE_DEVICE_TYPE_NONE 0U |
No debug console. More... | |
#define | DEBUG_CONSOLE_DEVICE_TYPE_UART 1U |
Debug console based on UART. More... | |
#define | DEBUG_CONSOLE_DEVICE_TYPE_LPUART 2U |
Debug console based on LPUART. More... | |
#define | DEBUG_CONSOLE_DEVICE_TYPE_LPSCI 3U |
Debug console based on LPSCI. More... | |
#define | DEBUG_CONSOLE_DEVICE_TYPE_USBCDC 4U |
Debug console based on USBCDC. More... | |
#define | DEBUG_CONSOLE_DEVICE_TYPE_FLEXCOMM 5U |
Debug console based on FLEXCOMM. More... | |
#define | DEBUG_CONSOLE_DEVICE_TYPE_IUART 6U |
Debug console based on i.MX UART. More... | |
#define | DEBUG_CONSOLE_DEVICE_TYPE_VUSART 7U |
Debug console based on LPC_VUSART. More... | |
#define | DEBUG_CONSOLE_DEVICE_TYPE_MINI_USART 8U |
Debug console based on LPC_USART. More... | |
#define | DEBUG_CONSOLE_DEVICE_TYPE_SWO 9U |
Debug console based on SWO. More... | |
#define | DEBUG_CONSOLE_DEVICE_TYPE_QSCI 10U |
Debug console based on QSCI. More... | |
Min/max macros | |
#define | MIN(a, b) (((a) < (b)) ? (a) : (b)) |
Computes the minimum of a and b. More... | |
#define | MAX(a, b) (((a) > (b)) ? (a) : (b)) |
Computes the maximum of a and b. More... | |
UINT16_MAX/UINT32_MAX value | |
#define | UINT16_MAX ((uint16_t)-1) |
Max value of uint16_t type. More... | |
#define | UINT32_MAX ((uint32_t)-1) |
Max value of uint32_t type. More... | |
Timer utilities | |
#define | USEC_TO_COUNT(us, clockFreqInHz) SDK_CovertUsToCount(us, clockFreqInHz) |
Macro to convert a microsecond period to raw count value. | |
#define | COUNT_TO_USEC(count, clockFreqInHz) SDK_CovertCountToUs(count, clockFreqInHz) |
Macro to convert a raw count value to microsecond. | |
#define | MSEC_TO_COUNT(ms, clockFreqInHz) SDK_CovertMsToCount(ms, clockFreqInHz) |
Macro to convert a millisecond period to raw count value. | |
#define | COUNT_TO_MSEC(count, clockFreqInHz) SDK_CovertCountToMs(count, clockFreqInHz) |
Macro to convert a raw count value to millisecond. | |
Alignment variable definition macros | |
#define | SDK_ALIGN(var, alignbytes) var __attribute__((aligned(alignbytes))) |
Macro to define a variable with alignbytes alignment. | |
#define | AT_NONCACHEABLE_SECTION(var) var |
#define | AT_NONCACHEABLE_SECTION_ALIGN(var, alignbytes) var __attribute__((aligned(alignbytes))) |
#define | AT_NONCACHEABLE_SECTION_INIT(var) var |
#define | AT_NONCACHEABLE_SECTION_ALIGN_INIT(var, alignbytes) var __attribute__((aligned(alignbytes))) |
Interrupt | |
DSC interrupt controller uses the same bit-filed to control interrupt enable status and priority, to provide compatible APIs, SDK uses a interrupt priority table, thus application could control the interrupt enable/disable, and interrupt priority independently. Also, the API EnableIRQWithPriority could be used to enable the interrupt and set the priority at the same time. API implementation:
The interrupt functions configure INTC module, application could call the INTC driver directly for the same purpose. | |
status_t | EnableIRQWithPriority (IRQn_Type irq, uint8_t priNum) |
Enable the IRQ, and also set the interrupt priority. More... | |
status_t | DisableIRQ (IRQn_Type irq) |
Disable specific interrupt. More... | |
status_t | EnableIRQ (IRQn_Type irq) |
Enable specific interrupt. More... | |
status_t | IRQ_SetPriority (IRQn_Type irq, uint8_t priNum) |
Set the IRQ priority. More... | |
#define FSL_DRIVER_TRANSFER_DOUBLE_WEAK_IRQ 1 |
#define MAKE_STATUS | ( | group, | |
code | |||
) | ((((group)*100L) + (code))) |
#define MAKE_VERSION | ( | major, | |
minor, | |||
bugfix | |||
) | (((major)*65536L) + ((minor)*256L) + (bugfix)) |
The driver version is a 32-bit number, for both 32-bit platforms(such as Cortex M) and 16-bit platforms(such as DSC).
| Unused || Major Version || Minor Version || Bug Fix | 31 25 24 17 16 9 8 0
#define FSL_COMMON_DRIVER_VERSION (MAKE_VERSION(2, 4, 1)) |
#define DEBUG_CONSOLE_DEVICE_TYPE_NONE 0U |
#define DEBUG_CONSOLE_DEVICE_TYPE_UART 1U |
#define DEBUG_CONSOLE_DEVICE_TYPE_LPUART 2U |
#define DEBUG_CONSOLE_DEVICE_TYPE_LPSCI 3U |
#define DEBUG_CONSOLE_DEVICE_TYPE_USBCDC 4U |
#define DEBUG_CONSOLE_DEVICE_TYPE_FLEXCOMM 5U |
#define DEBUG_CONSOLE_DEVICE_TYPE_IUART 6U |
#define DEBUG_CONSOLE_DEVICE_TYPE_VUSART 7U |
#define DEBUG_CONSOLE_DEVICE_TYPE_MINI_USART 8U |
#define DEBUG_CONSOLE_DEVICE_TYPE_SWO 9U |
#define DEBUG_CONSOLE_DEVICE_TYPE_QSCI 10U |
#define MIN | ( | a, | |
b | |||
) | (((a) < (b)) ? (a) : (b)) |
#define MAX | ( | a, | |
b | |||
) | (((a) > (b)) ? (a) : (b)) |
#define ARRAY_SIZE | ( | x | ) | (sizeof(x) / sizeof((x)[0])) |
#define UINT16_MAX ((uint16_t)-1) |
#define UINT32_MAX ((uint32_t)-1) |
#define SUPPRESS_FALL_THROUGH_WARNING | ( | ) |
To suppress this warning, "SUPPRESS_FALL_THROUGH_WARNING();" need to be added at the end of each case section which misses "break;"statement.
#define SDK_DSC_DEFAULT_INT_PRIO 1U |
#define PeriphReadReg | ( | reg | ) | (reg) |
Example: val = PeriphReadReg(OCCS->OSCTL2);
reg | Register name. |
#define PeriphWriteReg | ( | reg, | |
data | |||
) | (reg) = (data) |
Example: PeriphWriteReg(OCCS->OSCTL2, 0x278U);
reg | Register name. |
data | Data wrote to register. |
#define PeriphSetBits | ( | reg, | |
bitMask | |||
) | (reg) |= (bitMask) |
Example: PeriphSetBits(OCCS->OSCTL2, 0x12U);
reg | Register name. |
bitMask | Bits mask, set bits will be set in the register. |
#define PeriphClearBits | ( | reg, | |
bitMask | |||
) | (reg) &= (~(bitMask)) |
Example: PeriphClearBits(OCCS->OSCTL2, 0x12U);
reg | Register name. |
bitMask | Bits mask, set bits will be cleared in the register. |
#define PeriphInvertBits | ( | reg, | |
bitMask | |||
) | (reg) ^= (bitMask) |
Example: PeriphInvertBits(OCCS->OSCTL2, 0x12U);
reg | Register name. |
bitMask | Bits mask, set bits will be inverted in the register. |
#define PeriphGetBits | ( | reg, | |
bitMask | |||
) | ((reg) & (bitMask)) |
Example: val = PeriphGetBits(OCCS->OSCTL2, 0x23U);
reg | Register name. |
bitMask | Bits mask, specify the getting bits. |
#define PeriphWriteBitGroup | ( | reg, | |
bitMask, | |||
bitValue | |||
) | (reg) = ((reg) & ~(bitMask)) | ((bitValue) & (bitMask)) |
Example: PeriphWriteBitGroup(OCCS->DIVBY, OCCS_DIVBY_COD_MASK, OCCS_DIVBY_COD(23U)); PeriphWriteBitGroup(OCCS->DIVBY, OCCS_DIVBY_COD_MASK | OCCS_DIVBY_PLLDB_MASK, \ OCCS_DIVBY_COD(23U) | OCCS_DIVBY_PLLDB(49U));
reg | Register name. |
bitMask | Bits mask, mask of the group of bits. |
bitValue | This value will be written into the bit group specified by parameter bitMask. |
#define PeriphSafeClearFlags | ( | reg, | |
allFlagsMask, | |||
flagMask | |||
) | (reg) = ((reg) & (~(allFlagsMask))) | ((flagMask) & (allFlagsMask)) |
This macro is useful when a register is comprised by normal read-write bits and cleared-by-write-one bits. Example: PeriphSafeClearFlags(PWMA->FAULT[0].FSTS, PWM_FSTS_FFLAG_MASK, PWM_FSTS_FFLAG(2));
reg | Register name. |
allFlagsMask | Mask for all flags which are active-high and are cleared-by-write-one. |
flagMask | The selected flags(cleared-by-write-one) which are supposed to be cleared. |
#define PeriphSafeClearBits | ( | reg, | |
allFlagsMask, | |||
bitMask | |||
) | (reg) = ((reg) & (~((allFlagsMask) | (bitMask)))) |
This macro is useful when a register is comprised by normal read-write bits and cleared-by-write-one bits. Example: PeriphSafeClearBits(PWMA->FAULT[0].FSTS, PWM_FSTS_FFLAG_MASK, PWM_FSTS_FHALF(2));
reg | Register name. |
allFlagsMask | Mask for all flags which are active-high and are cleared-by-write-one. |
bitMask | The selected bits which are supposed to be cleared. |
#define PeriphSafeSetBits | ( | reg, | |
allFlagsMask, | |||
bitMask | |||
) | (reg) = ((reg) & (~(allFlagsMask))) | ((bitMask) & (~(allFlagsMask))) |
This macro is useful when a register is comprised by normal read-write bits and cleared-by-write-one bits. Example: PeriphSafeSetBits(PWMA->FAULT[0].FSTS, PWM_FSTS_FFLAG_MASK, PWM_FSTS_FHALF(2));
reg | Register name. |
allFlagsMask | Mask for all flags which are active-high and are cleared-by-write-one. |
bitMask | The selected bits which are supposed to be set. |
#define PeriphSafeWriteBitGroup | ( | reg, | |
allFlagsMask, | |||
bitMask, | |||
bitValue | |||
) | (reg) = ((reg) & (~((allFlagsMask) | (bitMask)))) | ((bitValue) & (bitMask) & (~(allFlagsMask))) |
This macro is useful when a register is comprised by normal read-write bits and cleared-by-write-one bits. Example: PeriphSafeWriteBitGroup(PWMA->FAULT[0].FSTS, PWM_FSTS_FFLAG_MASK, PWM_FSTS_FHALF_MASK, PWM_FSTS_FHALF(3U)); PeriphSafeWriteBitGroup(PWMA->FAULT[0].FSTS, PWM_FSTS_FFLAG_MASK, PWM_FSTS_FHALF_MASK | PWM_FSTS_FFULL_MASK, \ PWM_FSTS_FHALF(3U) | PWM_FSTS_FFULL(2U));
reg | Register name. |
allFlagsMask | Mask for all flags which are active-high and are cleared-by-write-one. |
bitMask | Bits mask, mask of the group of bits. |
bitValue | This value will be written into the bit group specified by parameter bitMask. |
#define SDK_GET_REGISTER_BYTE_ADDR | ( | ipType, | |
ipBase, | |||
regName | |||
) | ((2UL * ((uint32_t)(ipBase))) + ((uint32_t)(uint8_t *)&(((ipType *)0)->regName))) |
This macro is useful when a register byte address is required, especially in SDM mode. Example: SDK_GET_REGISTER_BYTE_ADDR(ADC_Type, ADC, RSLT[0]);
ipType | IP register mapping struct type. |
ipBase | IP instance base pointer, WORD address. |
regName | Member register name of IP register mapping struct. |
typedef int32_t status_t |
enum _status_groups |
anonymous enum |
void SDK_DelayAtLeastUs | ( | uint32_t | delayTime_us, |
uint32_t | coreClock_Hz | ||
) |
Please note that, this API uses while loop for delay, different run-time environments make the time not precise, if precise delay count was needed, please implement a new delay function with hardware timer.
delayTime_us | Delay time in unit of microsecond. |
coreClock_Hz | Core clock frequency with Hz. |
status_t EnableIRQWithPriority | ( | IRQn_Type | irq, |
uint8_t | priNum | ||
) |
priNum
is range in 1~3, and its value is NOT directly map to interrupt priority.User should check chip's RM to get its corresponding interrupt priority.
When priNum
set as 0, then SDK_DSC_DEFAULT_INT_PRIO is set instead. When priNum
set as number larger than 3, then only the 2 LSB take effect, for example, setting priNum
to 5 is the same with setting it to 1.
This function configures INTC module, application could call the INTC driver directly for the same purpose.
irq | The IRQ to enable. |
priNum | Priority number set to interrupt controller register. Larger number means higher priority. The allowed range is 1~3, and its value is NOT directly map to interrupt priority. In other words, the same priority number means different interrupt priority levels for different IRQ, please check reference manual for the relationship. When pass in 0, then SDK_DSC_DEFAULT_INT_PRIO is set to priority register. |
status_t DisableIRQ | ( | IRQn_Type | irq | ) |
This function configures INTC module, application could call the INTC driver directly for the same purpose.
irq | The IRQ to disable. |
status_t EnableIRQ | ( | IRQn_Type | irq | ) |
The recommended workflow is calling IRQ_SetPriority first, then call EnableIRQ. If IRQ_SetPriority is not called first, then the interrupt is enabled with default priority value SDK_DSC_DEFAULT_INT_PRIO.
Another recommended workflow is calling EnableIRQWithPriority directly, it is the same with calling IRQ_SetPriority + EnableIRQ.
This function configures INTC module, application could call the INTC driver directly for the same purpose.
irq | The IRQ to enable. |
status_t IRQ_SetPriority | ( | IRQn_Type | irq, |
uint8_t | priNum | ||
) |
priNum
is range in 1~3, and its value is NOT directly map to interrupt priority.User should check chip's RM to get its corresponding interrupt priority
When priNum
set as 0, then SDK_DSC_DEFAULT_INT_PRIO is set instead. When priNum
set as number larger than 3, then only the 2 LSB take effect, for example, setting priNum
to 5 is the same with setting it to 1.
This function configures INTC module, application could call the INTC driver directly for the same purpose.
irq | The IRQ to set. |
priNum | Priority number set to interrupt controller register. Larger number means higher priority, 0 means disable the interrupt. The allowed range is 0~3, and its value is NOT directly map to interrupt priority. In other words, the same priority number means different interrupt priority levels for different IRQ, please check reference manual for the relationship. |
void SDK_DelayCoreCycles | ( | uint32_t | u32Num | ) |
Please note that, this API uses software loop for delay, the actual delayed time depends on core clock frequency, where the function is located (ram or flash), flash clock, possible interrupt.
u32Num | Number of core clock cycle which needs to be delayed. |
uint32_t SDK_CovertUsToCount | ( | uint32_t | u32Us, |
uint32_t | u32Hz | ||
) |
u32Us | Time in us |
u32Hz | Clock frequency in Hz |
uint32_t SDK_CovertCountToUs | ( | uint32_t | u32Count, |
uint32_t | u32Hz | ||
) |
u32Count | Count value |
u32Hz | Clock frequency in Hz |
uint32_t SDK_CovertMsToCount | ( | uint32_t | u32Ms, |
uint32_t | u32Hz | ||
) |
u32Ms | Time in us |
u32Hz | Clock frequency in Hz |
uint32_t SDK_CovertCountToMs | ( | uint32_t | u32Count, |
uint32_t | u32Hz | ||
) |
u32Count | Count value |
u32Hz | Clock frequency in Hz |
void SDK_DelayAtLeastMs | ( | uint32_t | delayTime_ms, |
uint32_t | coreClock_Hz | ||
) |
Please note that, this API uses while loop for delay, different run-time environments make the time not precise, if precise delay count was needed, please implement a new delay function with hardware timer.
delayTime_ms | Delay time in unit of millisecond. |
coreClock_Hz | Core clock frequency with Hz. |