/* * Code generated from Atmel Start. * * This file will be overwritten when reconfiguring your Atmel Start project. * Please copy examples or other code you want to keep to a separate file * to avoid losing it when reconfiguring. */ #include "driver_init.h" #include #include #include struct usart_sync_descriptor USART_0; struct i2c_m_sync_desc I2C_0; void USART_0_PORT_init(void) { gpio_set_pin_function(PB25, PINMUX_PB25D_SERCOM2_PAD0); gpio_set_pin_function(PB24, PINMUX_PB24D_SERCOM2_PAD1); } void USART_0_CLOCK_init(void) { hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM2_GCLK_ID_CORE, CONF_GCLK_SERCOM2_CORE_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos)); hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM2_GCLK_ID_SLOW, CONF_GCLK_SERCOM2_SLOW_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos)); hri_mclk_set_APBBMASK_SERCOM2_bit(MCLK); } void USART_0_init(void) { USART_0_CLOCK_init(); usart_sync_init(&USART_0, SERCOM2, (void *)NULL); USART_0_PORT_init(); } void I2C_0_PORT_init(void) { gpio_set_pin_pull_mode(PA22, // Pull configuration // pad_pull_config // Off // Pull-up // Pull-down GPIO_PULL_OFF); gpio_set_pin_function(PA22, PINMUX_PA22C_SERCOM3_PAD0); gpio_set_pin_pull_mode(PA23, // Pull configuration // pad_pull_config // Off // Pull-up // Pull-down GPIO_PULL_OFF); gpio_set_pin_function(PA23, PINMUX_PA23C_SERCOM3_PAD1); } void I2C_0_CLOCK_init(void) { hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM3_GCLK_ID_CORE, CONF_GCLK_SERCOM3_CORE_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos)); hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM3_GCLK_ID_SLOW, CONF_GCLK_SERCOM3_SLOW_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos)); hri_mclk_set_APBBMASK_SERCOM3_bit(MCLK); } void I2C_0_init(void) { I2C_0_CLOCK_init(); i2c_m_sync_init(&I2C_0, SERCOM3); I2C_0_PORT_init(); } void system_init(void) { init_mcu(); USART_0_init(); I2C_0_init(); }