MAX32670 Peripheral Driver API
Peripheral Driver API for the MAX32670
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_Clock_Timeout (uint32_t ready)
 
void MXC_SYS_Reset_Periph (mxc_sys_reset_t reset)
 
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:238

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

Enumerator
MXC_SYS_PERIPH_CLOCK_GPIO0 

GPIO0 clock

MXC_SYS_PERIPH_CLOCK_GPIO1 

GPIO1 clock

MXC_SYS_PERIPH_CLOCK_DMA 

DMA clock

MXC_SYS_PERIPH_CLOCK_SPI0 

SPI0 clock

MXC_SYS_PERIPH_CLOCK_SPI1 

SPI1 clock

MXC_SYS_PERIPH_CLOCK_SPI2 

SPI2 clock

MXC_SYS_PERIPH_CLOCK_UART0 

UART0 clock

MXC_SYS_PERIPH_CLOCK_UART1 

UART1 clock

MXC_SYS_PERIPH_CLOCK_I2C0 

I2C0 clock

MXC_SYS_PERIPH_CLOCK_TMR0 

TMR0 clock

MXC_SYS_PERIPH_CLOCK_TMR1 

TMR1 clock

MXC_SYS_PERIPH_CLOCK_TMR2 

TMR2 clock

MXC_SYS_PERIPH_CLOCK_TMR3 

TMR3 clock

MXC_SYS_PERIPH_CLOCK_I2C1 

I2C1 clock

MXC_SYS_PERIPH_CLOCK_UART2 

UART2 clock

MXC_SYS_PERIPH_CLOCK_TRNG 

TRNG clock

MXC_SYS_PERIPH_CLOCK_WDT0 

WDT0 clock

MXC_SYS_PERIPH_CLOCK_WDT1 

WDT1 clock

MXC_SYS_PERIPH_CLOCK_ICACHE 

ICACHE clock

MXC_SYS_PERIPH_CLOCK_CRC 

CRC clock

MXC_SYS_PERIPH_CLOCK_AES 

AES clock

MXC_SYS_PERIPH_CLOCK_I2C2 

I2C2 clock

MXC_SYS_PERIPH_CLOCK_I2S 

I2S clock

MXC_SYS_PERIPH_CLOCK_TMR4 

TMR4 clock

MXC_SYS_PERIPH_CLOCK_TMR5 

TMR5 clock

MXC_SYS_PERIPH_CLOCK_UART3 

UART3 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_TMR0 

Reset TIMER0

MXC_SYS_RESET0_TMR1 

Reset TIMER1

MXC_SYS_RESET0_TMR2 

Reset TIMER2

MXC_SYS_RESET0_TMR3 

Reset TIMER3

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_TRNG 

Reset TRNG

MXC_SYS_RESET0_UART2 

Reset UART2

MXC_SYS_RESET0_SRST 

Soft reset

MXC_SYS_RESET0_PRST 

Peripheral reset

MXC_SYS_RESET0_SYS 

System reset

MXC_SYS_RESET1_I2C1 

Reset I2C1

MXC_SYS_RESET1_WDT1 

Reset WDT1

MXC_SYS_RESET1_AES 

Reset AES

MXC_SYS_RESET1_CRC 

Reset CRC

MXC_SYS_RESET1_I2C2 

Reset I2C2

MXC_SYS_RESET1_I2S 

Reset I2S

MXC_SYS_RESET_TMR4 

Reset TMR4

MXC_SYS_RESET_TMR5 

Reset TMR5

MXC_SYS_RESET_UART3 

Reset UART3

MXC_SYS_RESET_RTC 

Reset RTC

◆ 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_IBRO 

Select the Internal Baud Rate Oscillator (IBRO)

MXC_SYS_CLOCK_ERFO 

Select the External RF Crystal Oscillator

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_max32670.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_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:199
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:187

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
resetThe peripheral to reset

◆ MXC_SYS_RTCClockDisable()

int MXC_SYS_RTCClockDisable ( void  )

Disables the External RTC Clock Input.

Returns
E_NO_ERROR if everything is successful

◆ MXC_SYS_RTCClockEnable()

void MXC_SYS_RTCClockEnable ( void  )

Enables the External RTC Clock Input.

Returns
None

◆ 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.