Skip to content

Commit

Permalink
Add MSDK_NO_GPIO_CLK_INIT to disable clock&gpio init
Browse files Browse the repository at this point in the history
Added for below peripherals
- ADC
- OWM
- UART
- AES/CRC/TRNG
- HTMR
- WUT
- SPIXF/ SPIMSS

Signed-off-by: Sadik Ozer <[email protected]>
  • Loading branch information
ozersa committed Nov 27, 2023
1 parent 803b93a commit 679ccf0
Show file tree
Hide file tree
Showing 54 changed files with 112 additions and 0 deletions.
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,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_me18.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/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
2 changes: 2 additions & 0 deletions Libraries/PeriphDrivers/Source/SPIMSS/i2s_me11.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ int dma_channel = -1;

int MXC_I2S_Init(const mxc_i2s_config_t *config, void (*dma_ctz_cb)(int, int))
{
#ifndef MSDK_NO_GPIO_CLK_INIT
if (config->map == I2S_MAP_A) {
MXC_GPIO_Config(&gpio_cfg_spi1a); // SPIMSS: I2S and SPI share pins
} else if (config->map == I2S_MAP_B) {
Expand All @@ -83,6 +84,7 @@ int MXC_I2S_Init(const mxc_i2s_config_t *config, void (*dma_ctz_cb)(int, int))
}

MXC_SYS_ClockEnable(MXC_SYS_PERIPH_CLOCK_SPI1); // SPI1 clock used for SPIMSS
#endif

return MXC_I2S_RevA_Init((mxc_spimss_reva_regs_t *)MXC_SPIMSS, config, dma_ctz_cb);
}
Expand Down
2 changes: 2 additions & 0 deletions Libraries/PeriphDrivers/Source/SPIXF/spixf_me10.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,12 @@
/* ************************************************************************** */
int MXC_SPIXF_Init(uint32_t cmdval, uint32_t frequency)
{
#ifndef MSDK_NO_GPIO_CLK_INIT
MXC_SYS_ClockEnable(MXC_SYS_PERIPH_CLOCK_SPIXIPF);
MXC_SYS_ClockEnable(MXC_SYS_PERIPH_CLOCK_SPIXIPM);
MXC_SYS_ClockEnable(MXC_SYS_PERIPH_CLOCK_ICACHEXIP);
MXC_GPIO_Config(&gpio_cfg_spixfc);
#endif

MXC_SPIXF_RevA_Init((mxc_spixfc_reva_regs_t *)MXC_SPIXFC, (mxc_spixfm_reva_regs_t *)MXC_SPIXF,
cmdval, frequency);
Expand Down
Loading

0 comments on commit 679ccf0

Please sign in to comment.