You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
88 lines
2.2 KiB
C
88 lines
2.2 KiB
C
3 years ago
|
/*
|
||
|
* 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 <peripheral_clk_config.h>
|
||
|
#include <utils.h>
|
||
|
#include <hal_init.h>
|
||
|
|
||
|
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,
|
||
|
// <y> Pull configuration
|
||
|
// <id> pad_pull_config
|
||
|
// <GPIO_PULL_OFF"> Off
|
||
|
// <GPIO_PULL_UP"> Pull-up
|
||
|
// <GPIO_PULL_DOWN"> Pull-down
|
||
|
GPIO_PULL_OFF);
|
||
|
|
||
|
gpio_set_pin_function(PA22, PINMUX_PA22C_SERCOM3_PAD0);
|
||
|
|
||
|
gpio_set_pin_pull_mode(PA23,
|
||
|
// <y> Pull configuration
|
||
|
// <id> pad_pull_config
|
||
|
// <GPIO_PULL_OFF"> Off
|
||
|
// <GPIO_PULL_UP"> Pull-up
|
||
|
// <GPIO_PULL_DOWN"> 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();
|
||
|
}
|