Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(PeriphDrivers): Allow Skipping Clock and GPIO Initialization on Additional Peripherals #809

Merged
merged 1 commit into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Libraries/PeriphDrivers/Include/MAX32570/owm.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ typedef struct {
/**
* @brief Initialize and enable OWM module.
* @param cfg Pointer to OWM configuration.
* @param map MAP_A, MAP_B or MAP_C onewire pins select
* @param map MAP_A, MAP_B or MAP_C onewire pins select. Has no effect
* incase of MSDK_NO_GPIO_CLK_INIT has been defined.
*
* @return #E_NO_ERROR if everything is successful
* @return #E_NULL_PTR if parameter is a null pointer
Expand Down
3 changes: 2 additions & 1 deletion Libraries/PeriphDrivers/Include/MAX32660/uart.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ struct _mxc_uart_req_t {
* @param uart Pointer to UART registers (selects the UART block used.)
* @param baud The requested clock frequency. The actual clock frequency
* will be returned by the function if successful.
* @param map Selects which pin map to use.
* @param map Selects which pin map to use. Has no effect incase of
* MSDK_NO_GPIO_CLK_INIT has been defined.
*
* @return If successful, the actual clock frequency is returned. Otherwise, see
* \ref MXC_Error_Codes for a list of return codes.
Expand Down
3 changes: 2 additions & 1 deletion Libraries/PeriphDrivers/Include/MAX32665/owm.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ typedef struct {
/**
* @brief Initialize and enable OWM module.
* @param cfg Pointer to OWM configuration.
* @param map MAP_A, MAP_B or MAP_C onewire pins select
* @param map MAP_A, MAP_B or MAP_C onewire pins select. Has no effect
* incase of MSDK_NO_GPIO_CLK_INIT has been defined.
*
* @return #E_NO_ERROR if everything is successful
* @return #E_NULL_PTR if parameter is a null pointer
Expand Down
Empty file.
2 changes: 2 additions & 0 deletions Libraries/PeriphDrivers/Source/ADC/adc_me10.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,10 @@
// ********************************************************************************
int MXC_ADC_Init(void)
{
#ifndef MSDK_NO_GPIO_CLK_INIT
MXC_SYS_Reset_Periph(MXC_SYS_RESET_ADC);
MXC_SYS_ClockEnable(MXC_SYS_PERIPH_CLOCK_ADC);
#endif

return MXC_ADC_RevA_Init((mxc_adc_reva_regs_t *)MXC_ADC);
}
Expand Down
2 changes: 2 additions & 0 deletions Libraries/PeriphDrivers/Source/ADC/adc_me12.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,10 @@ static void initGPIOForTrigSrc(mxc_adc_trig_sel_t hwTrig)

int MXC_ADC_Init(mxc_adc_req_t *req)
{
#ifndef MSDK_NO_GPIO_CLK_INIT
MXC_SYS_Reset_Periph(MXC_SYS_RESET0_ADC);
MXC_SYS_ClockEnable(MXC_SYS_PERIPH_CLOCK_ADC);
#endif

MXC_ADC_ReferenceSelect(req->ref);

Expand Down
2 changes: 2 additions & 0 deletions Libraries/PeriphDrivers/Source/ADC/adc_me13.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@

int MXC_ADC_Init(void)
{
#ifndef MSDK_NO_GPIO_CLK_INIT
MXC_SYS_Reset_Periph(MXC_SYS_RESET0_ADC);

MXC_SYS_ClockEnable(MXC_SYS_PERIPH_CLOCK_ADC);
#endif

//turn on charge pump enable (chip specific)
MXC_ADC->ctrl |= MXC_F_ADC_CTRL_CHGPUMP_PWR;
Expand Down
2 changes: 2 additions & 0 deletions Libraries/PeriphDrivers/Source/ADC/adc_me14.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,15 @@

int MXC_ADC_Init(void)
{
#ifndef MSDK_NO_GPIO_CLK_INIT
MXC_GCR->rstr0 |= MXC_F_GCR_RSTR0_ADC;

// Reset ADC block
while (MXC_GCR->rstr0 & MXC_F_GCR_RSTR0_ADC) {}

// Enable ADC peripheral clock
MXC_GCR->perckcn0 &= ~MXC_F_GCR_PERCKCN0_ADCD;
#endif

return MXC_ADC_RevA_Init((mxc_adc_reva_regs_t *)MXC_ADC);
}
Expand Down
2 changes: 2 additions & 0 deletions Libraries/PeriphDrivers/Source/ADC/adc_me17.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,11 @@ static void initGPIOForChannel(mxc_adc_chsel_t channel)

int MXC_ADC_Init(void)
{
#ifndef MSDK_NO_GPIO_CLK_INIT
MXC_SYS_Reset_Periph(MXC_SYS_RESET0_ADC);

MXC_SYS_ClockEnable(MXC_SYS_PERIPH_CLOCK_ADC);
#endif

return MXC_ADC_RevA_Init((mxc_adc_reva_regs_t *)MXC_ADC);
}
Expand Down
2 changes: 2 additions & 0 deletions Libraries/PeriphDrivers/Source/ADC/adc_me18.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,13 @@ static void initGPIOForTrigSrc(mxc_adc_trig_sel_t hwTrig)

int MXC_ADC_Init(mxc_adc_req_t *req)
{
#ifndef MSDK_NO_GPIO_CLK_INIT
MXC_SYS_Reset_Periph(MXC_SYS_RESET0_ADC);
MXC_SYS_ClockEnable(MXC_SYS_PERIPH_CLOCK_ADC);

/* This is required for temperature sensor only */
MXC_SYS_ClockSourceEnable(MXC_SYS_CLOCK_IBRO);
#endif

MXC_ADC_ReferenceSelect(req->ref);

Expand Down
2 changes: 2 additions & 0 deletions Libraries/PeriphDrivers/Source/ADC/adc_me21.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ static void initGPIOforHWTrig(mxc_adc_trig_sel_t hwTrig)

int MXC_ADC_Init(mxc_adc_req_t *req)
{
#ifndef MSDK_NO_GPIO_CLK_INIT
/* ADC in reset state */
switch (req->clock) {
case MXC_ADC_CLK_HCLK:
Expand All @@ -189,6 +190,7 @@ int MXC_ADC_Init(mxc_adc_req_t *req)

/* This is required for temperature sensor only */
MXC_SYS_ClockSourceEnable(MXC_SYS_CLOCK_IBRO);
#endif

MXC_ADC_ReferenceSelect(req->ref);

Expand Down
2 changes: 2 additions & 0 deletions Libraries/PeriphDrivers/Source/ADC/adc_me55.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@

int MXC_ADC_Init(void)
{
#ifndef MSDK_NO_GPIO_CLK_INIT
MXC_SYS_Reset_Periph(MXC_SYS_RESET0_ADC);

MXC_SYS_ClockEnable(MXC_SYS_PERIPH_CLOCK_ADC);
#endif

//turn on charge pump enable (chip specific)
MXC_ADC->ctrl |= MXC_F_ADC_CTRL_CHGPUMP_PWR;
Expand Down
2 changes: 2 additions & 0 deletions Libraries/PeriphDrivers/Source/AES/aes_ai87.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,10 @@

int MXC_AES_Init(void)
{
#ifndef MSDK_NO_GPIO_CLK_INIT
MXC_SYS_ClockEnable(MXC_SYS_PERIPH_CLOCK_AES);
MXC_SYS_ClockEnable(MXC_SYS_PERIPH_CLOCK_TRNG);
#endif

MXC_AES->ctrl = 0x00;
// Start with a randomly generated key.
Expand Down
2 changes: 2 additions & 0 deletions Libraries/PeriphDrivers/Source/AES/aes_me12.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,10 @@

int MXC_AES_Init(void)
{
#ifndef MSDK_NO_GPIO_CLK_INIT
MXC_SYS_ClockEnable(MXC_SYS_PERIPH_CLOCK_AES);
MXC_SYS_ClockEnable(MXC_SYS_PERIPH_CLOCK_TRNG);
#endif

return MXC_AES_RevB_Init((mxc_aes_revb_regs_t *)MXC_AES);
}
Expand Down
2 changes: 2 additions & 0 deletions Libraries/PeriphDrivers/Source/AES/aes_me15.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,10 @@ static void reverse_key(const void *key, uint8_t *keyr, int len)

int MXC_AES_Init(void)
{
#ifndef MSDK_NO_GPIO_CLK_INIT
MXC_SYS_ClockEnable(MXC_SYS_PERIPH_CLOCK_AES);
MXC_SYS_ClockEnable(MXC_SYS_PERIPH_CLOCK_TRNG);
#endif

MXC_AES->ctrl = 0x00;
// Start with a randomly generated key.
Expand Down
2 changes: 2 additions & 0 deletions Libraries/PeriphDrivers/Source/AES/aes_me17.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,10 @@

int MXC_AES_Init(void)
{
#ifndef MSDK_NO_GPIO_CLK_INIT
MXC_SYS_ClockEnable(MXC_SYS_PERIPH_CLOCK_AES);
MXC_SYS_ClockEnable(MXC_SYS_PERIPH_CLOCK_TRNG);
#endif

return MXC_AES_RevB_Init((mxc_aes_revb_regs_t *)MXC_AES);
}
Expand Down
2 changes: 2 additions & 0 deletions Libraries/PeriphDrivers/Source/AES/aes_me18.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,10 @@

int MXC_AES_Init(void)
{
#ifndef MSDK_NO_GPIO_CLK_INIT
MXC_SYS_ClockEnable(MXC_SYS_PERIPH_CLOCK_AES);
MXC_SYS_ClockEnable(MXC_SYS_PERIPH_CLOCK_TRNG);
#endif

return MXC_AES_RevB_Init((mxc_aes_revb_regs_t *)MXC_AES);
}
Expand Down
2 changes: 2 additions & 0 deletions Libraries/PeriphDrivers/Source/AES/aes_me21.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,10 @@

int MXC_AES_Init(void)
{
#ifndef MSDK_NO_GPIO_CLK_INIT
MXC_SYS_ClockEnable(MXC_SYS_PERIPH_CLOCK_AES);
MXC_SYS_ClockEnable(MXC_SYS_PERIPH_CLOCK_TRNG);
#endif

MXC_AES_RevB_Init((mxc_aes_revb_regs_t *)MXC_AES);

Expand Down
2 changes: 2 additions & 0 deletions Libraries/PeriphDrivers/Source/CRC/crc_ai87.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@

int MXC_CRC_Init(void)
{
#ifndef MSDK_NO_GPIO_CLK_INIT
MXC_SYS_ClockEnable(MXC_SYS_PERIPH_CLOCK_CRC);
#endif

MXC_CRC_RevA_Init((mxc_crc_reva_regs_t *)MXC_CRC);

Expand Down
2 changes: 2 additions & 0 deletions Libraries/PeriphDrivers/Source/CRC/crc_me15.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@

int MXC_CRC_Init(void)
{
#ifndef MSDK_NO_GPIO_CLK_INIT
MXC_SYS_ClockEnable(MXC_SYS_PERIPH_CLOCK_CRC);
#endif

MXC_CRC_RevA_Init((mxc_crc_reva_regs_t *)MXC_CRC);

Expand Down
2 changes: 2 additions & 0 deletions Libraries/PeriphDrivers/Source/CRC/crc_me16.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@

int MXC_CRC_Init(void)
{
#ifndef MSDK_NO_GPIO_CLK_INIT
MXC_SYS_ClockEnable(MXC_SYS_PERIPH_CLOCK_CRC);
#endif

MXC_CRC_RevA_Init();

Expand Down
2 changes: 2 additions & 0 deletions Libraries/PeriphDrivers/Source/CRC/crc_me17.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@

int MXC_CRC_Init(void)
{
#ifndef MSDK_NO_GPIO_CLK_INIT
MXC_SYS_ClockEnable(MXC_SYS_PERIPH_CLOCK_CRC);
#endif

MXC_CRC_RevA_Init((mxc_crc_reva_regs_t *)MXC_CRC);

Expand Down
2 changes: 2 additions & 0 deletions Libraries/PeriphDrivers/Source/HTMR/htmr_me13.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ int MXC_HTMR_Init(mxc_htmr_regs_t *htmr, uint32_t longInterval, uint8_t shortInt
return E_NULL_PTR;
}

#ifndef MSDK_NO_GPIO_CLK_INIT
if (MXC_SYS_ClockSourceEnable(MXC_SYS_CLOCK_IBRO) != E_NO_ERROR) {
return E_TIME_OUT;
}
Expand All @@ -61,6 +62,7 @@ int MXC_HTMR_Init(mxc_htmr_regs_t *htmr, uint32_t longInterval, uint8_t shortInt
} else {
return E_BAD_PARAM;
}
#endif

return MXC_HTMR_RevA_Init((mxc_htmr_reva_regs_t *)htmr, longInterval, shortInterval);
}
Expand Down
2 changes: 2 additions & 0 deletions Libraries/PeriphDrivers/Source/HTMR/htmr_me14.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ int MXC_HTMR_Init(mxc_htmr_regs_t *htmr, uint32_t longInterval, uint8_t shortInt
return E_NULL_PTR;
}

#ifndef MSDK_NO_GPIO_CLK_INIT
if (MXC_SYS_ClockSourceEnable(MXC_SYS_CLOCK_HIRC8) != E_NO_ERROR) {
return E_TIME_OUT;
}
Expand All @@ -79,6 +80,7 @@ int MXC_HTMR_Init(mxc_htmr_regs_t *htmr, uint32_t longInterval, uint8_t shortInt
} else {
return E_BAD_PARAM;
}
#endif

return MXC_HTMR_RevA_Init((mxc_htmr_reva_regs_t *)htmr, longInterval, shortInterval);
}
Expand Down
2 changes: 2 additions & 0 deletions Libraries/PeriphDrivers/Source/HTMR/htmr_me55.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ int MXC_HTMR_Init(mxc_htmr_regs_t *htmr, uint32_t longInterval, uint8_t shortInt
return E_NULL_PTR;
}

#ifndef MSDK_NO_GPIO_CLK_INIT
if (MXC_SYS_ClockSourceEnable(MXC_SYS_CLOCK_IBRO) != E_NO_ERROR) {
return E_TIME_OUT;
}
Expand All @@ -61,6 +62,7 @@ int MXC_HTMR_Init(mxc_htmr_regs_t *htmr, uint32_t longInterval, uint8_t shortInt
} else {
return E_BAD_PARAM;
}
#endif

return MXC_HTMR_RevA_Init((mxc_htmr_reva_regs_t *)htmr, longInterval, shortInterval);
}
Expand Down
2 changes: 2 additions & 0 deletions Libraries/PeriphDrivers/Source/OWM/owm_ai87.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ int MXC_OWM_Init(const mxc_owm_cfg_t *cfg)
return E_NULL_PTR;
}

#ifndef MSDK_NO_GPIO_CLK_INIT
// Set system level configurations
mxc_gpio_regs_t *gpio = gpio_cfg_owm.port;

Expand All @@ -78,6 +79,7 @@ int MXC_OWM_Init(const mxc_owm_cfg_t *cfg)
if ((err = MXC_GPIO_Config(&gpio_cfg_owm)) != E_NO_ERROR) {
return err;
}
#endif

// Configure clk divisor to get 1MHz OWM clk
mxc_owm_clk = PeripheralClock;
Expand Down
2 changes: 2 additions & 0 deletions Libraries/PeriphDrivers/Source/OWM/owm_me10.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,11 @@ int MXC_OWM_Init(const mxc_owm_cfg_t *cfg)
return E_NULL_PTR;
}

#ifndef MSDK_NO_GPIO_CLK_INIT
// Set system level configurations
MXC_SYS_ClockEnable(MXC_SYS_PERIPH_CLOCK_OWIRE);
MXC_GPIO_Config(&gpio_cfg_owm);
#endif

// Configure clk divisor to get 1MHz OWM clk
mxc_owm_clk = PeripheralClock;
Expand Down
4 changes: 4 additions & 0 deletions Libraries/PeriphDrivers/Source/OWM/owm_me13.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ int MXC_OWM_Init(const mxc_owm_cfg_t *cfg, sys_map_t map)
return E_NULL_PTR;
}

#ifndef MSDK_NO_GPIO_CLK_INIT
// Set system level configurations
MXC_SYS_ClockEnable(MXC_SYS_PERIPH_CLOCK_OWIRE);

Expand All @@ -73,6 +74,9 @@ int MXC_OWM_Init(const mxc_owm_cfg_t *cfg, sys_map_t map)
if ((err = MXC_GPIO_Config(gpio)) != E_NO_ERROR) {
return err;
}
#else
(void)map;
#endif

// Configure clk divisor to get 1MHz OWM clk
mxc_owm_clk = PeripheralClock;
Expand Down
4 changes: 4 additions & 0 deletions Libraries/PeriphDrivers/Source/OWM/owm_me14.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ int MXC_OWM_Init(const mxc_owm_cfg_t *cfg, sys_map_t map)
return E_NULL_PTR;
}

#ifndef MSDK_NO_GPIO_CLK_INIT
// Set system level configurations
MXC_SYS_ClockEnable(MXC_SYS_PERIPH_CLOCK_OWIRE);

Expand All @@ -91,6 +92,9 @@ int MXC_OWM_Init(const mxc_owm_cfg_t *cfg, sys_map_t map)
if ((err = MXC_GPIO_Config(gpio)) != E_NO_ERROR) {
return err;
}
#else
(void)map;
#endif

// Configure clk divisor to get 1MHz OWM clk
mxc_owm_clk = PeripheralClock;
Expand Down
2 changes: 2 additions & 0 deletions Libraries/PeriphDrivers/Source/OWM/owm_me17.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,13 @@ int MXC_OWM_Init(const mxc_owm_cfg_t *cfg)
return E_NULL_PTR;
}

#ifndef MSDK_NO_GPIO_CLK_INIT
MXC_SYS_ClockEnable(MXC_SYS_PERIPH_CLOCK_OWIRE);

if ((err = MXC_GPIO_Config(&gpio_cfg_owm)) != E_NO_ERROR) {
return err;
}
#endif

// Configure clk divisor to get 1MHz OWM clk
mxc_owm_clk = PeripheralClock;
Expand Down
2 changes: 2 additions & 0 deletions Libraries/PeriphDrivers/Source/OWM/owm_me18.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,13 @@ int MXC_OWM_Init(const mxc_owm_cfg_t *cfg)
return E_NULL_PTR;
}

#ifndef MSDK_NO_GPIO_CLK_INIT
MXC_SYS_ClockEnable(MXC_SYS_PERIPH_CLOCK_OWIRE);

if ((err = MXC_GPIO_Config(&gpio_cfg_owm)) != E_NO_ERROR) {
return err;
}
#endif

// Configure clk divisor to get 1MHz OWM clk
mxc_owm_clk = PeripheralClock;
Expand Down
2 changes: 2 additions & 0 deletions Libraries/PeriphDrivers/Source/SPIMSS/i2s_me10.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,10 @@ mxc_i2s_direction_t dir;
/* ************************************************************************* */
int MXC_I2S_Init(const mxc_i2s_config_t *cfg, void (*dma_ctz_cb)(int, int))
{
#ifndef MSDK_NO_GPIO_CLK_INIT
MXC_SYS_ClockEnable(MXC_SYS_PERIPH_CLOCK_I2S);
MXC_GPIO_Config(&gpio_cfg_i2s);
#endif

return MXC_I2S_RevA_Init((mxc_spimss_reva_regs_t *)MXC_SPIMSS, cfg, dma_ctz_cb);
}
Expand Down
Loading