FreeRTOS-Kernel/FreeRTOS/Demo/AVR_ATMega4809_IAR/clk_config.h
m17336 d4bf09480a
Update previous AVR ATmega0 and AVR Dx projecs + addition of equivalent projects in MPLAB.X and IAR (#180)
* Updated indentation in AVR_ATMega4809_Atmel_Studio and AVR_Dx_Atmel_Studio projects, plus small fixes in their readme files.

* Added AVR_ATMega4809_IAR, AVR_ATMega4809_MPLAB.X, AVR_Dx_IAR and AVR_Dx_MPLAB.X demo projects.

* Removed build artefacts and added .gitignore files in AVR_ATMega4809_MPLAB.X and AVR_Dx_MPLAB.X projects.

Co-authored-by: Yuhui Zheng <10982575+yuhui-zheng@users.noreply.github.com>
2020-08-06 12:37:08 -07:00

38 lines
No EOL
1.3 KiB
C

#ifndef CLK_CONFIG_H_
#define CLK_CONFIG_H_
#include "FreeRTOSConfig.h"
#include "protected_io/ccp.h"
#if ( configCPU_CLOCK_HZ == 20000000 )
#define CLK_init() ccp_write_io((void *)&(CLKCTRL.MCLKCTRLA), CLKCTRL_CLKSEL_OSC20M_gc);
#elif ( configCPU_CLOCK_HZ == 10000000 )
#define CLK_init() { \
ccp_write_io((void *)&(CLKCTRL.MCLKCTRLA), CLKCTRL_CLKSEL_OSC20M_gc); \
ccp_write_io((void *)&(CLKCTRL.MCLKCTRLB), CLKCTRL_PDIV_2X_gc | CLKCTRL_PEN_bm); \
}
#elif ( configCPU_CLOCK_HZ == 5000000 )
#define CLK_init() { \
ccp_write_io((void *)&(CLKCTRL.MCLKCTRLA), CLKCTRL_CLKSEL_OSC20M_gc); \
ccp_write_io((void *)&(CLKCTRL.MCLKCTRLB), CLKCTRL_PDIV_4X_gc | CLKCTRL_PEN_bm); \
}
#elif ( configCPU_CLOCK_HZ == 2000000 )
#define CLK_init() { \
ccp_write_io((void *)&(CLKCTRL.MCLKCTRLA), CLKCTRL_CLKSEL_OSC20M_gc); \
ccp_write_io((void *)&(CLKCTRL.MCLKCTRLB), CLKCTRL_PDIV_10X_gc | CLKCTRL_PEN_bm); \
}
#else
#error The selected clock frequency is not supported. Choose a value from the NOTE in FreeRTOSConfig.h.
#endif
#endif /* CLK_CONFIG_H_ */