MAX32665 Peripheral Driver API
Peripheral Driver API for the MAX32665
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Modules Pages
System Configuration (MXC_SYS)

Macros

#define MXC_CRITICAL(code)
 

Enumerations

enum  mxc_sys_reset_t
 
enum  mxc_sys_periph_clock_t
 

Functions

static void MXC_SYS_Crit_Enter (void)
 
static void MXC_SYS_Crit_Exit (void)
 
static int MXC_SYS_In_Crit_Section (void)
 
int MXC_SYS_GetUSN (uint8_t *usn, uint8_t *checksum)
 
int MXC_SYS_IsClockEnabled (mxc_sys_periph_clock_t clock)
 
void MXC_SYS_ClockDisable (mxc_sys_periph_clock_t clock)
 
void MXC_SYS_ClockEnable (mxc_sys_periph_clock_t clock)
 
void MXC_SYS_RTCClockEnable (void)
 
int MXC_SYS_RTCClockDisable (void)
 
int MXC_SYS_ClockSourceEnable (mxc_sys_system_clock_t clock)
 
int MXC_SYS_ClockSourceDisable (mxc_sys_system_clock_t clock)
 
int MXC_SYS_Clock_Select (mxc_sys_system_clock_t clock)
 
void MXC_SYS_Clock_Div (mxc_sys_system_div_t div)
 
int MXC_SYS_Clock_Timeout (uint32_t ready)
 
void MXC_SYS_Reset_Periph (mxc_sys_reset_t reset)
 
uint8_t MXC_SYS_GetRev (void)
 
int MXC_SYS_LockDAP_Permanent (void)
 

Detailed Description

API for system configuration including clock source selection and entering critical sections of code.

Macro Definition Documentation

◆ MXC_CRITICAL

#define MXC_CRITICAL (   code)
Value:
{\
MXC_SYS_Crit_Enter();\
code;\
MXC_SYS_Crit_Exit();\
}

Macro for wrapping a section of code to make it critical (interrupts disabled). Note: this macro does not support nesting.

Ex:

printf("Hello critical section!\n");
)
#define MXC_CRITICAL(code)
Macro for wrapping a section of code to make it critical (interrupts disabled). Note: this macro does...
Definition: mxc_sys.h:302

This macro places a call to MXC_SYS_Crit_Enter before the code, and a call to MXC_SYS_Crit_Exit after.

Parameters
codeThe code section to wrap.

Enumeration Type Documentation

◆ mxc_sys_periph_clock_t

System clock disable enumeration. Used in SYS_ClockDisable and SYS_ClockEnable functions.

Enumerator
MXC_SYS_PERIPH_CLOCK_GPIO0 

Disable MXC_F_GCR_PERCKCN0_GPIO0D clock

MXC_SYS_PERIPH_CLOCK_GPIO1 

Disable MXC_F_GCR_PERCKCN0_GPIO1D clock

MXC_SYS_PERIPH_CLOCK_USB 

Disable MXC_F_GCR_PERCKCN0_USBD clock

MXC_SYS_PERIPH_CLOCK_DMA 

Disable MXC_F_GCR_PERCKCN0_DMAD clock

MXC_SYS_PERIPH_CLOCK_SPI1 

Disable MXC_F_GCR_PERCKCN0_SPI1D clock

MXC_SYS_PERIPH_CLOCK_SPI2 

Disable MXC_F_GCR_PERCKCN0_SPI2D clock

MXC_SYS_PERIPH_CLOCK_UART0 

Disable MXC_F_GCR_PERCKCN0_UART0D clock

MXC_SYS_PERIPH_CLOCK_UART1 

Disable MXC_F_GCR_PERCKCN0_UART1D clock

MXC_SYS_PERIPH_CLOCK_I2C0 

Disable MXC_F_GCR_PERCKCN0_I2C0D clock

MXC_SYS_PERIPH_CLOCK_TPU 

Disable MXC_F_GCR_PERCKCN0_CRYPTOD clock

MXC_SYS_PERIPH_CLOCK_T0 

Disable MXC_F_GCR_PERCKCN0_T0D clock

MXC_SYS_PERIPH_CLOCK_T1 

Disable MXC_F_GCR_PERCKCN0_T1D clock

MXC_SYS_PERIPH_CLOCK_T2 

Disable MXC_F_GCR_PERCKCN0_T2D clock

MXC_SYS_PERIPH_CLOCK_T3 

Disable MXC_F_GCR_PERCKCN0_T3D clock

MXC_SYS_PERIPH_CLOCK_T4 

Disable MXC_F_GCR_PERCKCN0_T4D clock

MXC_SYS_PERIPH_CLOCK_T5 

Disable MXC_F_GCR_PERCKCN0_T5D clock

MXC_SYS_PERIPH_CLOCK_ADC 

Disable MXC_F_GCR_PERCKCN0_ADCD clock

MXC_SYS_PERIPH_CLOCK_I2C1 

Disable MXC_F_GCR_PERCKCN0_I2C1D clock

MXC_SYS_PERIPH_CLOCK_PT 

Disable MXC_F_GCR_PERCKCN0_PTD clock

MXC_SYS_PERIPH_CLOCK_SPIXIP 

Disable MXC_F_GCR_PERCKCN0_SPIXIPD clock

MXC_SYS_PERIPH_CLOCK_SPIXFC 

Disable MXC_F_GCR_PERCKCN0_SPIMD clock

MXC_SYS_PERIPH_CLOCK_UART2 

Disable MXC_F_GCR_PERCKCN1_UART2D clock

MXC_SYS_PERIPH_CLOCK_TRNG 

Disable MXC_F_GCR_PERCKCN1_TRNGD clock

MXC_SYS_PERIPH_CLOCK_SCACHE 

Disable MXC_F_GCR_PERCKCN1_SCACHED clock

MXC_SYS_PERIPH_CLOCK_SDMA 

Disable MXC_F_GCR_PERCKCN1_SDMAD clock

MXC_SYS_PERIPH_CLOCK_SMPHR 

Disable MXC_F_GCR_PERCKCN1_SMPHRD clock

MXC_SYS_PERIPH_CLOCK_SDHC 

Disable MXC_F_GCR_PERCKCN1_SDHCD clock

MXC_SYS_PERIPH_CLOCK_ICACHEXIP 

Disable MXC_F_GCR_PERCKCN1_ICACHEXIPD clock

MXC_SYS_PERIPH_CLOCK_OWIRE 

Disable MXC_F_GCR_PERCKCN1_OWIRED clock

MXC_SYS_PERIPH_CLOCK_SPI0 

Disable QSPI Clock (API Calls QSPI SPI0)

MXC_SYS_PERIPH_CLOCK_SPIXIPD 

Disable MXC_F_GCR_PERCKCN1_SPIXIPDD clock

MXC_SYS_PERIPH_CLOCK_DMA1 

Disable MXC_F_GCR_PERCKCN1_DMA1D clock

MXC_SYS_PERIPH_CLOCK_AUDIO 

Disable MXC_F_GCR_PERCKCN1_AUDIOD clock

MXC_SYS_PERIPH_CLOCK_I2C2 

Disable MXC_F_GCR_PERCKCN1_I2C2D clock

MXC_SYS_PERIPH_CLOCK_HTMR0 

Disable MXC_F_GCR_PERCKCN1_HTMR0D clock

MXC_SYS_PERIPH_CLOCK_HTMR1 

Disable MXC_F_GCR_PERCKCN1_HTMR1D clock

MXC_SYS_PERIPH_CLOCK_WDT0 

Disable MXC_F_GCR_PERCKCN1_WTD0D clock

MXC_SYS_PERIPH_CLOCK_WDT1 

Disable MXC_F_GCR_PERCKCN1_WTD1D clock

MXC_SYS_PERIPH_CLOCK_WDT2 

Disable MXC_F_GCR_PERCKCN1_WTD2D clock

MXC_SYS_PERIPH_CLOCK_CPU1 

Disable MXC_F_GCR_PERCKCN1_CPU1D clock

◆ mxc_sys_reset_t

System reset0 and reset1 enumeration. Used in SYS_PeriphReset0 function.

Enumerator
MXC_SYS_RESET_DMA0 

Reset DMA

MXC_SYS_RESET_WDT0 

Reset WDT

MXC_SYS_RESET_GPIO0 

Reset GPIO0

MXC_SYS_RESET_GPIO1 

Reset GPIO1

MXC_SYS_RESET_TIMER0 

Reset TIMER0

MXC_SYS_RESET_TIMER1 

Reset TIMER1

MXC_SYS_RESET_TIMER2 

Reset TIMER2

MXC_SYS_RESET_TIMER3 

Reset TIMER3

MXC_SYS_RESET_TIMER4 

Reset TIMER4

MXC_SYS_RESET_TIMER5 

Reset TIMER5

MXC_SYS_RESET_UART0 

Reset UART0

MXC_SYS_RESET_UART1 

Reset UART1

MXC_SYS_RESET_SPI1 

Reset SPI0

MXC_SYS_RESET_SPI2 

Reset SPI1

MXC_SYS_RESET_I2C0 

Reset I2C0

MXC_SYS_RESET_RTC 

Reset RTC

MXC_SYS_RESET_CRYPTO 

Reset CRYPTO

MXC_SYS_RESET_SMPHR 

Reset SMPHR

MXC_SYS_RESET_USB 

Reset USB

MXC_SYS_RESET_ADC 

Reset ADC

MXC_SYS_RESET_DMA1 

Reset DMA1

MXC_SYS_RESET_UART2 

Reset UART2

MXC_SYS_RESET_SRST 

Soft reset

MXC_SYS_RESET_PRST 

Peripheral reset

MXC_SYS_RESET_SYSTEM 

System reset

MXC_SYS_RESET_I2C1 

Reset I2C1

MXC_SYS_RESET_PT 

Reset PT

MXC_SYS_RESET_SPIXIP 

Reset SPIXIP

MXC_SYS_RESET_XSPIM 

Reset XSPIM

MXC_SYS_RESET_SDHC 

Reset SDHC

MXC_SYS_RESET_OWIRE 

Reset OWIRE

MXC_SYS_RESET_WDT1 

Reset WDT1

MXC_SYS_RESET_SPI0 

Reset SPI2

MXC_SYS_RESET_SPIXMEM 

Reset SPIXMEM

MXC_SYS_RESET_SEMA 

Reset SEMA

MXC_SYS_RESET_WDT2 

Reset WDT1

MXC_SYS_RESET_BTLE 

Reset BTLE

MXC_SYS_RESET_AUDIO 

Reset BTLE

MXC_SYS_RESET_RPU 

Reset BTLE

MXC_SYS_RESET_I2C2 

Reset BTLE

MXC_SYS_RESET_HTMR0 

Reset HTMR0

MXC_SYS_RESET_HTMR1 

Reset HTMR1

MXC_SYS_RESET_DVS 

Reset DVS

MXC_SYS_RESET_SIMO 

Reset SIMO

Function Documentation

◆ MXC_SYS_Clock_Div()

void MXC_SYS_Clock_Div ( mxc_sys_system_div_t  div)

Select the system clock divider.

Parameters
clockEnumeration for desired system clock divider.

◆ MXC_SYS_Clock_Select()

int MXC_SYS_Clock_Select ( mxc_sys_system_clock_t  clock)

Select the system clock.

Parameters
clockEnumeration for desired clock.
tmrOptional tmr pointer for timeout. NULL if undesired.
Returns
E_NO_ERROR if everything is successful.

◆ MXC_SYS_Clock_Timeout()

int MXC_SYS_Clock_Timeout ( uint32_t  ready)

Wait for a clock to enable with timeout.

Parameters
readyThe clock to wait for
Returns
E_NO_ERROR if ready, E_TIME_OUT if timeout

◆ MXC_SYS_ClockDisable()

void MXC_SYS_ClockDisable ( mxc_sys_periph_clock_t  clock)

Disables the selected peripheral clock.

Parameters
clockEnumeration for desired clock.

◆ MXC_SYS_ClockEnable()

void MXC_SYS_ClockEnable ( mxc_sys_periph_clock_t  clock)

Enables the selected peripheral clock.

Parameters
clockEnumeration for desired clock.

◆ MXC_SYS_ClockSourceDisable()

int MXC_SYS_ClockSourceDisable ( mxc_sys_system_clock_t  clock)

Disable System Clock Source.

Parameters
clockThe clock to disable
Returns
E_NO_ERROR if everything is successful

◆ MXC_SYS_ClockSourceEnable()

int MXC_SYS_ClockSourceEnable ( mxc_sys_system_clock_t  clock)

Enable System Clock Source without switching to it.

Parameters
clockThe clock to enable
Returns
E_NO_ERROR if everything is successful

◆ MXC_SYS_Crit_Enter()

static void MXC_SYS_Crit_Enter ( void  )
inlinestatic

Enter a critical section of code that cannot be interrupted. Call MXC_SYS_Crit_Exit to exit the critical section.

Ex:

printf("Hello critical section!\n");
static void MXC_SYS_Crit_Exit(void)
Exit a critical section of code from MXC_SYS_Crit_Enter.
Definition: mxc_sys.h:263
static void MXC_SYS_Crit_Enter(void)
Enter a critical section of code that cannot be interrupted. Call MXC_SYS_Crit_Exit to exit the criti...
Definition: mxc_sys.h:251

The MXC_CRITICAL macro is also provided as a convencience macro for wrapping a code section in this way.

Returns
None

◆ MXC_SYS_Crit_Exit()

static void MXC_SYS_Crit_Exit ( void  )
inlinestatic

Exit a critical section of code from MXC_SYS_Crit_Enter.

Returns
None

◆ MXC_SYS_GetRev()

uint8_t MXC_SYS_GetRev ( void  )

Get the revision of the chip.

Returns
the chip revision

◆ MXC_SYS_GetUSN()

int MXC_SYS_GetUSN ( uint8_t *  usn,
uint8_t *  checksum 
)

Reads the device USN and verifies the checksum.

Parameters
usnPointer to store the USN. Array must be at least MXC_SYS_USN_LEN bytes long.
checksumOptional pointer to store the AES checksum. If not NULL, checksum is verified with AES engine.
Returns
E_NO_ERROR if everything is successful.

◆ MXC_SYS_In_Crit_Section()

static int MXC_SYS_In_Crit_Section ( void  )
inlinestatic

Polls whether code is currently executing from a critical section.

Returns
1 if code is currently in a critical section (interrupts are disabled). 0 if code is not in a critical section.

◆ MXC_SYS_IsClockEnabled()

int MXC_SYS_IsClockEnabled ( mxc_sys_periph_clock_t  clock)

Determines if the selected peripheral clock is enabled.

Parameters
clockEnumeration for desired clock.
Returns
0 is the clock is disabled, non 0 if the clock is enabled.

◆ MXC_SYS_LockDAP_Permanent()

int MXC_SYS_LockDAP_Permanent ( void  )

This function PERMANENTLY locks the Debug Access Port.

Warning
After executing this function you will never be able to reprogram the target micro.

◆ MXC_SYS_Reset_Periph()

void MXC_SYS_Reset_Periph ( mxc_sys_reset_t  reset)

Reset the peripherals and/or CPU in the RST0 or RST1 register.

Parameters
Enumerationfor what to reset. Can reset multiple items at once.

◆ MXC_SYS_RTCClockDisable()

int MXC_SYS_RTCClockDisable ( void  )

Disables the 32kHz oscillator.

Returns
E_NO_ERROR if everything is successful

◆ MXC_SYS_RTCClockEnable()

void MXC_SYS_RTCClockEnable ( void  )

Enables the 32kHz oscillator.

Parameters
mxc_sys_cfgNot used, may be NULL.