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.
157 lines
4.9 KiB
C
157 lines
4.9 KiB
C
/*
|
|
* 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>
|
|
#include <hpl_gclk_base.h>
|
|
#include <hpl_pm_base.h>
|
|
|
|
struct usart_sync_descriptor USART_0;
|
|
|
|
void USART_0_PORT_init(void)
|
|
{
|
|
|
|
gpio_set_pin_function(PA22, PINMUX_PA22C_SERCOM3_PAD0);
|
|
|
|
gpio_set_pin_function(PA23, PINMUX_PA23C_SERCOM3_PAD1);
|
|
}
|
|
|
|
void USART_0_CLOCK_init(void)
|
|
{
|
|
_pm_enable_bus_clock(PM_BUS_APBC, SERCOM3);
|
|
_gclk_enable_channel(SERCOM3_GCLK_ID_CORE, CONF_GCLK_SERCOM3_CORE_SRC);
|
|
}
|
|
|
|
void USART_0_init(void)
|
|
{
|
|
USART_0_CLOCK_init();
|
|
usart_sync_init(&USART_0, SERCOM3, (void *)NULL);
|
|
USART_0_PORT_init();
|
|
}
|
|
|
|
void delay_driver_init(void)
|
|
{
|
|
delay_init(SysTick);
|
|
}
|
|
|
|
void USB_DEVICE_INSTANCE_PORT_init(void)
|
|
{
|
|
|
|
gpio_set_pin_direction(PA24,
|
|
// <y> Pin direction
|
|
// <id> pad_direction
|
|
// <GPIO_DIRECTION_OFF"> Off
|
|
// <GPIO_DIRECTION_IN"> In
|
|
// <GPIO_DIRECTION_OUT"> Out
|
|
GPIO_DIRECTION_OUT);
|
|
|
|
gpio_set_pin_level(PA24,
|
|
// <y> Initial level
|
|
// <id> pad_initial_level
|
|
// <false"> Low
|
|
// <true"> High
|
|
false);
|
|
|
|
gpio_set_pin_pull_mode(PA24,
|
|
// <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(PA24,
|
|
// <y> Pin function
|
|
// <id> pad_function
|
|
// <i> Auto : use driver pinmux if signal is imported by driver, else turn off function
|
|
// <PINMUX_PA24G_USB_DM"> Auto
|
|
// <GPIO_PIN_FUNCTION_OFF"> Off
|
|
// <GPIO_PIN_FUNCTION_A"> A
|
|
// <GPIO_PIN_FUNCTION_B"> B
|
|
// <GPIO_PIN_FUNCTION_C"> C
|
|
// <GPIO_PIN_FUNCTION_D"> D
|
|
// <GPIO_PIN_FUNCTION_E"> E
|
|
// <GPIO_PIN_FUNCTION_F"> F
|
|
// <GPIO_PIN_FUNCTION_G"> G
|
|
// <GPIO_PIN_FUNCTION_H"> H
|
|
PINMUX_PA24G_USB_DM);
|
|
|
|
gpio_set_pin_direction(PA25,
|
|
// <y> Pin direction
|
|
// <id> pad_direction
|
|
// <GPIO_DIRECTION_OFF"> Off
|
|
// <GPIO_DIRECTION_IN"> In
|
|
// <GPIO_DIRECTION_OUT"> Out
|
|
GPIO_DIRECTION_OUT);
|
|
|
|
gpio_set_pin_level(PA25,
|
|
// <y> Initial level
|
|
// <id> pad_initial_level
|
|
// <false"> Low
|
|
// <true"> High
|
|
false);
|
|
|
|
gpio_set_pin_pull_mode(PA25,
|
|
// <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(PA25,
|
|
// <y> Pin function
|
|
// <id> pad_function
|
|
// <i> Auto : use driver pinmux if signal is imported by driver, else turn off function
|
|
// <PINMUX_PA25G_USB_DP"> Auto
|
|
// <GPIO_PIN_FUNCTION_OFF"> Off
|
|
// <GPIO_PIN_FUNCTION_A"> A
|
|
// <GPIO_PIN_FUNCTION_B"> B
|
|
// <GPIO_PIN_FUNCTION_C"> C
|
|
// <GPIO_PIN_FUNCTION_D"> D
|
|
// <GPIO_PIN_FUNCTION_E"> E
|
|
// <GPIO_PIN_FUNCTION_F"> F
|
|
// <GPIO_PIN_FUNCTION_G"> G
|
|
// <GPIO_PIN_FUNCTION_H"> H
|
|
PINMUX_PA25G_USB_DP);
|
|
}
|
|
|
|
/* The USB module requires a GCLK_USB of 48 MHz ~ 0.25% clock
|
|
* for low speed and full speed operation. */
|
|
#if (CONF_GCLK_USB_FREQUENCY > (48000000 + 48000000 / 400)) || (CONF_GCLK_USB_FREQUENCY < (48000000 - 48000000 / 400))
|
|
#warning USB clock should be 48MHz ~ 0.25% clock, check your configuration!
|
|
#endif
|
|
|
|
void USB_DEVICE_INSTANCE_CLOCK_init(void)
|
|
{
|
|
|
|
_pm_enable_bus_clock(PM_BUS_APBB, USB);
|
|
_pm_enable_bus_clock(PM_BUS_AHB, USB);
|
|
_gclk_enable_channel(USB_GCLK_ID, CONF_GCLK_USB_SRC);
|
|
}
|
|
|
|
void USB_DEVICE_INSTANCE_init(void)
|
|
{
|
|
USB_DEVICE_INSTANCE_CLOCK_init();
|
|
usb_d_init();
|
|
USB_DEVICE_INSTANCE_PORT_init();
|
|
}
|
|
|
|
void system_init(void)
|
|
{
|
|
init_mcu();
|
|
|
|
USART_0_init();
|
|
|
|
delay_driver_init();
|
|
|
|
USB_DEVICE_INSTANCE_init();
|
|
}
|