MAX32690 Peripheral Driver API
Peripheral Driver API for the MAX32690
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
 
enum  mxc_sys_system_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_SetClockDiv (mxc_sys_system_clock_div_t div)
 
mxc_sys_system_clock_div_t MXC_SYS_GetClockDiv (void)
 
int MXC_SYS_ClockCalibrate (mxc_sys_system_clock_t clock)
 
int MXC_SYS_Clock_Timeout (uint32_t ready)
 
void MXC_SYS_Reset_Periph (mxc_sys_reset_t reset)
 
void MXC_SYS_RISCVRun (void)
 
void MXC_SYS_RISCVShutdown (void)
 
uint32_t MXC_SYS_RiscVClockRate (void)
 
int MXC_SYS_LockDAP_Permanent (void)
 
int MXC_SYS_SetBypass (mxc_sys_system_clock_t clock, bool bypass)
 

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:318

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 MXC_SYS_ClockDisable and MXC_SYS_ClockEnable functions.

Enumerator
MXC_SYS_PERIPH_CLOCK_GPIO0 

Disable MXC_F_GCR_PCLKDIS0_GPIO0 clock

MXC_SYS_PERIPH_CLOCK_GPIO1 

Disable MXC_F_GCR_PCLKDIS0_GPIO1 clock

MXC_SYS_PERIPH_CLOCK_GPIO2 

Disable MXC_F_GCR_PCLKDIS0_GPIO2 clock

MXC_SYS_PERIPH_CLOCK_USB 

Disable MXC_F_GCR_PCLKDIS0_USB clock

MXC_SYS_PERIPH_CLOCK_DMA 

Disable MXC_F_GCR_PCLKDIS0_DMA clock

MXC_SYS_PERIPH_CLOCK_SPI0 

Disable MXC_F_GCR_PCLKDIS0_SPI0 clock

MXC_SYS_PERIPH_CLOCK_SPI1 

Disable MXC_F_GCR_PCLKDIS0_SPI1 clock

MXC_SYS_PERIPH_CLOCK_SPI2 

Disable MXC_F_GCR_PCLKDIS0_SPI2 clock

MXC_SYS_PERIPH_CLOCK_UART0 

Disable MXC_F_GCR_PCLKDIS0_UART0 clock

MXC_SYS_PERIPH_CLOCK_UART1 

Disable MXC_F_GCR_PCLKDIS0_UART1 clock

MXC_SYS_PERIPH_CLOCK_I2C0 

Disable MXC_F_GCR_PCLKDIS0_I2C0 clock

MXC_SYS_PERIPH_CLOCK_CRYPTO 

Disable MXC_F_GCR_PCLKDIS0_CRYPTO clock

MXC_SYS_PERIPH_CLOCK_TMR0 

Disable MXC_F_GCR_PCLKDIS0_TMR0 clock

MXC_SYS_PERIPH_CLOCK_TMR1 

Disable MXC_F_GCR_PCLKDIS0_TMR1 clock

MXC_SYS_PERIPH_CLOCK_TMR2 

Disable MXC_F_GCR_PCLKDIS0_TMR2 clock

MXC_SYS_PERIPH_CLOCK_TMR3 

Disable MXC_F_GCR_PCLKDIS0_T3 clock

MXC_SYS_PERIPH_CLOCK_ADC 

Disable MXC_F_GCR_PCLKDIS0_ADC clock

MXC_SYS_PERIPH_CLOCK_I2C1 

Disable MXC_F_GCR_PCLKDIS0_I2C1 clock

MXC_SYS_PERIPH_CLOCK_PT 

Disable MXC_F_GCR_PCLKDIS0_PT clock

MXC_SYS_PERIPH_CLOCK_SPIXIP 

Disable MXC_F_GCR_PCLKDIS0_SPIXIP clock

MXC_SYS_PERIPH_CLOCK_SPIXIPC 

Disable MXC_F_GCR_PCLKDIS0_SPIXIPC clock

MXC_SYS_PERIPH_CLOCK_BTLE 

Disable MXC_F_GCR_PCLKDIS1_BTLE clock

MXC_SYS_PERIPH_CLOCK_UART2 

Disable MXC_F_GCR_PCLKDIS1_UART2 clock

MXC_SYS_PERIPH_CLOCK_TRNG 

Disable MXC_F_GCR_PCLKDIS1_TRNG clock

MXC_SYS_PERIPH_CLOCK_PUF 

Disable MXC_F_GCR_PCLKDIS1_PUF clock

MXC_SYS_PERIPH_CLOCK_SMPHR 

Disable MXC_F_GCR_PCLKDIS1_SMPHR clock

MXC_SYS_PERIPH_CLOCK_HPB 

Disable MXC_F_GCR_PCLKDIS1_HPB clock

MXC_SYS_PERIPH_CLOCK_SYSCACHE 

Disable MXC_F_GCR_PCLKDIS1_SYSCACHE clock

MXC_SYS_PERIPH_CLOCK_CAN0 

Disable MXC_F_GCR_PCLKDIS1_CAN0 clock

MXC_SYS_PERIPH_CLOCK_OWIRE 

Disable MXC_F_GCR_PCLKDIS1_OWM clock

MXC_SYS_PERIPH_CLOCK_SPI3 

Disable MXC_F_GCR_PCLKDIS1_SPI3 clock

MXC_SYS_PERIPH_CLOCK_SPI4 

Disable MXC_F_GCR_PCLKDIS1_SPI4 clock

MXC_SYS_PERIPH_CLOCK_CAN1 

Disable MXC_F_GCR_PCLKDIS1_CAN1 clock

MXC_SYS_PERIPH_CLOCK_I2S 

Disable MXC_F_GCR_PCLKDIS1_I2S clock

MXC_SYS_PERIPH_CLOCK_I2C2 

Disable MXC_F_GCR_PCLKDIS1_I2C2 clock

MXC_SYS_PERIPH_CLOCK_WDT0 

Disable MXC_F_GCR_PCLKDIS1_WDT0 clock

MXC_SYS_PERIPH_CLOCK_CPU1 

Disable MXC_F_GCR_PCLKDIS1_CPU1 clock

MXC_SYS_PERIPH_CLOCK_GPIO3 

Disable MXC_F_LPGCR_PCLKDIS_GPIO3 clock

MXC_SYS_PERIPH_CLOCK_WDT1 

Disable MXC_F_LPGCR_PCLKDIS_WDT2 clock

MXC_SYS_PERIPH_CLOCK_TMR4 

Disable MXC_F_LPGCR_PCLKDIS_TMR4 clock

MXC_SYS_PERIPH_CLOCK_TMR5 

Disable MXC_F_LPGCR_PCLKDIS_TMR5 clock

MXC_SYS_PERIPH_CLOCK_UART3 

Disable MXC_F_LPGCR_PCLKDIS_UART3 clock

MXC_SYS_PERIPH_CLOCK_LPCOMP 

Disable MXC_F_LPGCR_PCLKDIS_LPCOMP clock

◆ mxc_sys_reset_t

System reset0 and reset1 enumeration. Used in MXC_SYS_PeriphReset0 function.

Enumerator
MXC_SYS_RESET0_DMA 

Reset DMA

MXC_SYS_RESET0_WDT0 

Reset WDT

MXC_SYS_RESET0_GPIO0 

Reset GPIO0

MXC_SYS_RESET0_GPIO1 

Reset GPIO1

MXC_SYS_RESET0_GPIO2 

Reset GPIO2

MXC_SYS_RESET0_TMR0 

Reset TMR0

MXC_SYS_RESET0_TMR1 

Reset TMR1

MXC_SYS_RESET0_TMR2 

Reset TMR2

MXC_SYS_RESET0_TMR3 

Reset TMR3

MXC_SYS_RESET0_UART0 

Reset UART0

MXC_SYS_RESET0_UART1 

Reset UART1

MXC_SYS_RESET0_SPI0 

Reset SPI0

MXC_SYS_RESET0_SPI1 

Reset SPI1

MXC_SYS_RESET0_SPI2 

Reset SPI2

MXC_SYS_RESET0_I2C0 

Reset I2C0

MXC_SYS_RESET0_RTC 

Reset RTC

MXC_SYS_RESET0_CRYPTO 

Reset CRYPTO

MXC_SYS_RESET0_CAN0 

Reset CAN0

MXC_SYS_RESET0_CAN1 

Reset CAN1

MXC_SYS_RESET0_HPB 

Reset HPB

MXC_SYS_RESET0_SMPHR 

Reset SMPHR

MXC_SYS_RESET0_USB 

Reset USB

MXC_SYS_RESET0_TRNG 

Reset TRNG

MXC_SYS_RESET0_ADC 

Reset ADC

MXC_SYS_RESET0_UART2 

Reset UART2

MXC_SYS_RESET0_SOFT 

Soft reset

MXC_SYS_RESET0_PERIPH 

Peripheral reset

MXC_SYS_RESET0_SYS 

System reset

MXC_SYS_RESET1_I2C1 

Reset I2C1

MXC_SYS_RESET1_PT 

Reset PT

MXC_SYS_RESET1_SPIXIP 

Reset SPIXIP

MXC_SYS_RESET1_SPIXIPM 

Reset SPIXIPM

MXC_SYS_RESET1_OWM 

Reset OWM

MXC_SYS_RESET1_SPI3 

Reset SPI3

MXC_SYS_RESET1_SPI4 

Reset SPI4

MXC_SYS_RESET1_SMPHR 

Reset SMPHR

MXC_SYS_RESET1_BTLE 

Reset BTLE

MXC_SYS_RESET1_I2C2 

Reset I2C2

MXC_SYS_RESET1_I2S 

Reset I2S

MXC_SYS_RESET1_PUF 

Reset PUF

MXC_SYS_RESET1_CPU1 

Reset CPU1

MXC_SYS_RESET_GPIO3 

Reset GPIO3

MXC_SYS_RESET_WDT1 

Reset WDT1

MXC_SYS_RESET_TMR4 

Reset TMR4

MXC_SYS_RESET_TMR5 

Reset TMR5

MXC_SYS_RESET_UART3 

Reset UART3

MXC_SYS_RESET_LPCOMP 

Reset LPCOMP

◆ mxc_sys_system_clock_t

Enumeration to select System Clock source.

Enumerator
MXC_SYS_CLOCK_IPO 

Select the Internal Primary Oscillator (IPO)

MXC_SYS_CLOCK_ERFO 

Select the External RF Crystal Oscillator

MXC_SYS_CLOCK_IBRO 

Select the Internal Baud Rate Oscillator (IBRO)

MXC_SYS_CLOCK_ISO 

Select the Internal Secondary Oscillator (ISO)

MXC_SYS_CLOCK_INRO 

Select the Internal Nanoring Oscillator (INRO)

MXC_SYS_CLOCK_ERTCO 

Select the External RTC Crystal Oscillator

MXC_SYS_CLOCK_EXTCLK 

Use the external system clock input

Function Documentation

◆ MXC_SYS_Clock_Select()

int MXC_SYS_Clock_Select ( mxc_sys_system_clock_t  clock)

Select the system clock.

Parameters
clockEnumeration for desired clock. Note: If using the external clock input be sure to define EXTCLK_FREQ correctly. The default EXTCLK_FREQ value is defined in the system_max78002.h file and can be overridden at compile time.
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_ClockCalibrate()

int MXC_SYS_ClockCalibrate ( mxc_sys_system_clock_t  clock)

Calibrate the specified system clock.

Parameters
clockClock source to calibrate. Note usually only the IPO supports calibration.
Check the microcontroller's UG for more details.
Returns
E_NO_ERROR if everything is successful.

◆ 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:279
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:267

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_GetClockDiv()

mxc_sys_system_clock_div_t MXC_SYS_GetClockDiv ( void  )

Get the system clock divider.

Returns
System clock divider.

◆ 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 rstr0 or rstr1 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.

◆ MXC_SYS_SetBypass()

int MXC_SYS_SetBypass ( mxc_sys_system_clock_t  clock,
bool  bypass 
)

Bypass the crystal oscillator driver circuit for the specified clock. Some clock sources support this option, allowing an external square wave input signal to be fed directly to the clock's input pin. Refer to the microcontroller's User Guide for more details.

Parameters
clockThe clock source target
bypassBypass the oscillator circuit or not. Set to true to bypass, false to disable the bypass
Returns
Error Codes

◆ MXC_SYS_SetClockDiv()

void MXC_SYS_SetClockDiv ( mxc_sys_system_clock_div_t  div)

Set the system clock divider.

Parameters
divEnumeration for desired clock divider.