981 lines
28 KiB
C
981 lines
28 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>
|
|
|
|
/*! The buffer size for USART */
|
|
#define SIM0_BUFFER_SIZE 512
|
|
|
|
/*! The buffer size for USART */
|
|
#define SIM1_BUFFER_SIZE 512
|
|
|
|
/*! The buffer size for USART */
|
|
#define SIM2_BUFFER_SIZE 512
|
|
|
|
/*! The buffer size for USART */
|
|
#define SIM3_BUFFER_SIZE 512
|
|
|
|
/*! The buffer size for USART */
|
|
#define SIM4_BUFFER_SIZE 512
|
|
|
|
/*! The buffer size for USART */
|
|
#define SIM5_BUFFER_SIZE 512
|
|
|
|
/*! The buffer size for USART */
|
|
#define SIM6_BUFFER_SIZE 512
|
|
|
|
/*! The buffer size for USART */
|
|
#ifdef ENABLE_DBG_UART7
|
|
#define UART_DEBUG_BUFFER_SIZE 4096
|
|
#else
|
|
#define SIM7_BUFFER_SIZE 512
|
|
#endif
|
|
|
|
struct usart_async_descriptor SIM0;
|
|
struct usart_async_descriptor SIM1;
|
|
struct usart_async_descriptor SIM2;
|
|
struct usart_async_descriptor SIM3;
|
|
struct usart_async_descriptor SIM4;
|
|
struct usart_async_descriptor SIM5;
|
|
struct usart_async_descriptor SIM6;
|
|
#ifndef ENABLE_DBG_UART7
|
|
struct usart_async_descriptor SIM7;
|
|
#endif
|
|
|
|
static uint8_t SIM0_buffer[SIM0_BUFFER_SIZE];
|
|
static uint8_t SIM1_buffer[SIM1_BUFFER_SIZE];
|
|
static uint8_t SIM2_buffer[SIM2_BUFFER_SIZE];
|
|
static uint8_t SIM3_buffer[SIM3_BUFFER_SIZE];
|
|
static uint8_t SIM4_buffer[SIM4_BUFFER_SIZE];
|
|
static uint8_t SIM5_buffer[SIM5_BUFFER_SIZE];
|
|
static uint8_t SIM6_buffer[SIM6_BUFFER_SIZE];
|
|
#ifndef ENABLE_DBG_UART7
|
|
static uint8_t SIM7_buffer[SIM7_BUFFER_SIZE];
|
|
#else
|
|
struct usart_async_rings_descriptor UART_debug;
|
|
static uint8_t UART_DEBUG_buffer_rx[UART_DEBUG_BUFFER_SIZE];
|
|
static uint8_t UART_DEBUG_buffer_tx[UART_DEBUG_BUFFER_SIZE];
|
|
#endif
|
|
struct calendar_descriptor CALENDAR_0;
|
|
|
|
void CALENDAR_0_CLOCK_init(void)
|
|
{
|
|
hri_mclk_set_APBAMASK_RTC_bit(MCLK);
|
|
}
|
|
|
|
void CALENDAR_0_init(void)
|
|
{
|
|
CALENDAR_0_CLOCK_init();
|
|
calendar_init(&CALENDAR_0, RTC);
|
|
}
|
|
|
|
/**
|
|
* \brief USART Clock initialization function
|
|
*
|
|
* Enables register interface and peripheral clock
|
|
*/
|
|
void SIM0_CLOCK_init()
|
|
{
|
|
|
|
hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM0_GCLK_ID_CORE, CONF_GCLK_SERCOM0_CORE_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
|
|
hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM0_GCLK_ID_SLOW, CONF_GCLK_SERCOM0_SLOW_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
|
|
|
|
hri_mclk_set_APBAMASK_SERCOM0_bit(MCLK);
|
|
}
|
|
|
|
/**
|
|
* \brief USART pinmux initialization function
|
|
*
|
|
* Set each required pin to USART functionality
|
|
*/
|
|
void SIM0_PORT_init()
|
|
{
|
|
|
|
gpio_set_pin_function(SIM0_IO, PINMUX_PA04D_SERCOM0_PAD0);
|
|
}
|
|
|
|
/**
|
|
* \brief USART initialization function
|
|
*
|
|
* Enables USART peripheral, clocks and initializes USART driver
|
|
*/
|
|
void SIM0_init(void)
|
|
{
|
|
SIM0_CLOCK_init();
|
|
usart_async_init(&SIM0, SERCOM0, SIM0_buffer, SIM0_BUFFER_SIZE, (void *)NULL);
|
|
SIM0_PORT_init();
|
|
}
|
|
|
|
/**
|
|
* \brief USART Clock initialization function
|
|
*
|
|
* Enables register interface and peripheral clock
|
|
*/
|
|
void SIM1_CLOCK_init()
|
|
{
|
|
|
|
hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM1_GCLK_ID_CORE, CONF_GCLK_SERCOM1_CORE_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
|
|
hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM1_GCLK_ID_SLOW, CONF_GCLK_SERCOM1_SLOW_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
|
|
|
|
hri_mclk_set_APBAMASK_SERCOM1_bit(MCLK);
|
|
}
|
|
|
|
/**
|
|
* \brief USART pinmux initialization function
|
|
*
|
|
* Set each required pin to USART functionality
|
|
*/
|
|
void SIM1_PORT_init()
|
|
{
|
|
|
|
gpio_set_pin_function(SIM1_IO, PINMUX_PA16C_SERCOM1_PAD0);
|
|
}
|
|
|
|
/**
|
|
* \brief USART initialization function
|
|
*
|
|
* Enables USART peripheral, clocks and initializes USART driver
|
|
*/
|
|
void SIM1_init(void)
|
|
{
|
|
SIM1_CLOCK_init();
|
|
usart_async_init(&SIM1, SERCOM1, SIM1_buffer, SIM1_BUFFER_SIZE, (void *)NULL);
|
|
SIM1_PORT_init();
|
|
}
|
|
|
|
/**
|
|
* \brief USART Clock initialization function
|
|
*
|
|
* Enables register interface and peripheral clock
|
|
*/
|
|
void SIM2_CLOCK_init()
|
|
{
|
|
|
|
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);
|
|
}
|
|
|
|
/**
|
|
* \brief USART pinmux initialization function
|
|
*
|
|
* Set each required pin to USART functionality
|
|
*/
|
|
void SIM2_PORT_init()
|
|
{
|
|
|
|
gpio_set_pin_function(SIM2_IO, PINMUX_PA09D_SERCOM2_PAD0);
|
|
}
|
|
|
|
/**
|
|
* \brief USART initialization function
|
|
*
|
|
* Enables USART peripheral, clocks and initializes USART driver
|
|
*/
|
|
void SIM2_init(void)
|
|
{
|
|
SIM2_CLOCK_init();
|
|
usart_async_init(&SIM2, SERCOM2, SIM2_buffer, SIM2_BUFFER_SIZE, (void *)NULL);
|
|
SIM2_PORT_init();
|
|
}
|
|
|
|
/**
|
|
* \brief USART Clock initialization function
|
|
*
|
|
* Enables register interface and peripheral clock
|
|
*/
|
|
void SIM3_CLOCK_init()
|
|
{
|
|
|
|
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);
|
|
}
|
|
|
|
/**
|
|
* \brief USART pinmux initialization function
|
|
*
|
|
* Set each required pin to USART functionality
|
|
*/
|
|
void SIM3_PORT_init()
|
|
{
|
|
|
|
gpio_set_pin_function(SIM3_IO, PINMUX_PB20C_SERCOM3_PAD0);
|
|
}
|
|
|
|
/**
|
|
* \brief USART initialization function
|
|
*
|
|
* Enables USART peripheral, clocks and initializes USART driver
|
|
*/
|
|
void SIM3_init(void)
|
|
{
|
|
SIM3_CLOCK_init();
|
|
usart_async_init(&SIM3, SERCOM3, SIM3_buffer, SIM3_BUFFER_SIZE, (void *)NULL);
|
|
SIM3_PORT_init();
|
|
}
|
|
|
|
/**
|
|
* \brief USART Clock initialization function
|
|
*
|
|
* Enables register interface and peripheral clock
|
|
*/
|
|
void SIM4_CLOCK_init()
|
|
{
|
|
|
|
hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM4_GCLK_ID_CORE, CONF_GCLK_SERCOM4_CORE_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
|
|
hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM4_GCLK_ID_SLOW, CONF_GCLK_SERCOM4_SLOW_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
|
|
|
|
hri_mclk_set_APBDMASK_SERCOM4_bit(MCLK);
|
|
}
|
|
|
|
/**
|
|
* \brief USART pinmux initialization function
|
|
*
|
|
* Set each required pin to USART functionality
|
|
*/
|
|
void SIM4_PORT_init()
|
|
{
|
|
|
|
gpio_set_pin_function(SIM4_IO, PINMUX_PB08D_SERCOM4_PAD0);
|
|
}
|
|
|
|
/**
|
|
* \brief USART initialization function
|
|
*
|
|
* Enables USART peripheral, clocks and initializes USART driver
|
|
*/
|
|
void SIM4_init(void)
|
|
{
|
|
SIM4_CLOCK_init();
|
|
usart_async_init(&SIM4, SERCOM4, SIM4_buffer, SIM4_BUFFER_SIZE, (void *)NULL);
|
|
SIM4_PORT_init();
|
|
}
|
|
|
|
/**
|
|
* \brief USART Clock initialization function
|
|
*
|
|
* Enables register interface and peripheral clock
|
|
*/
|
|
void SIM5_CLOCK_init()
|
|
{
|
|
|
|
hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM5_GCLK_ID_CORE, CONF_GCLK_SERCOM5_CORE_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
|
|
hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM5_GCLK_ID_SLOW, CONF_GCLK_SERCOM5_SLOW_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
|
|
|
|
hri_mclk_set_APBDMASK_SERCOM5_bit(MCLK);
|
|
}
|
|
|
|
/**
|
|
* \brief USART pinmux initialization function
|
|
*
|
|
* Set each required pin to USART functionality
|
|
*/
|
|
void SIM5_PORT_init()
|
|
{
|
|
|
|
gpio_set_pin_function(SIM5_IO, PINMUX_PB16C_SERCOM5_PAD0);
|
|
}
|
|
|
|
/**
|
|
* \brief USART initialization function
|
|
*
|
|
* Enables USART peripheral, clocks and initializes USART driver
|
|
*/
|
|
void SIM5_init(void)
|
|
{
|
|
SIM5_CLOCK_init();
|
|
usart_async_init(&SIM5, SERCOM5, SIM5_buffer, SIM5_BUFFER_SIZE, (void *)NULL);
|
|
SIM5_PORT_init();
|
|
}
|
|
|
|
/**
|
|
* \brief USART Clock initialization function
|
|
*
|
|
* Enables register interface and peripheral clock
|
|
*/
|
|
void SIM6_CLOCK_init()
|
|
{
|
|
|
|
hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM6_GCLK_ID_CORE, CONF_GCLK_SERCOM6_CORE_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
|
|
hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM6_GCLK_ID_SLOW, CONF_GCLK_SERCOM6_SLOW_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
|
|
|
|
hri_mclk_set_APBDMASK_SERCOM6_bit(MCLK);
|
|
}
|
|
|
|
/**
|
|
* \brief USART pinmux initialization function
|
|
*
|
|
* Set each required pin to USART functionality
|
|
*/
|
|
void SIM6_PORT_init()
|
|
{
|
|
|
|
gpio_set_pin_function(SIM6_IO, PINMUX_PC16C_SERCOM6_PAD0);
|
|
}
|
|
|
|
/**
|
|
* \brief USART initialization function
|
|
*
|
|
* Enables USART peripheral, clocks and initializes USART driver
|
|
*/
|
|
void SIM6_init(void)
|
|
{
|
|
SIM6_CLOCK_init();
|
|
usart_async_init(&SIM6, SERCOM6, SIM6_buffer, SIM6_BUFFER_SIZE, (void *)NULL);
|
|
SIM6_PORT_init();
|
|
}
|
|
|
|
#ifdef ENABLE_DBG_UART7
|
|
/**
|
|
* \brief USART Clock initialization function
|
|
*
|
|
* Enables register interface and peripheral clock
|
|
*/
|
|
void UART_debug_CLOCK_init()
|
|
{
|
|
|
|
hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM7_GCLK_ID_CORE, CONF_GCLK_SERCOM7_CORE_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
|
|
hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM7_GCLK_ID_SLOW, CONF_GCLK_SERCOM7_SLOW_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
|
|
|
|
hri_mclk_set_APBDMASK_SERCOM7_bit(MCLK);
|
|
}
|
|
|
|
/**
|
|
* \brief USART pinmux initialization function
|
|
*
|
|
* Set each required pin to USART functionality
|
|
*/
|
|
void UART_debug_PORT_init()
|
|
{
|
|
|
|
gpio_set_pin_function(UART_TX, PINMUX_PB30C_SERCOM7_PAD0);
|
|
|
|
gpio_set_pin_function(UART_RX, PINMUX_PB31C_SERCOM7_PAD1);
|
|
}
|
|
|
|
/**
|
|
* \brief USART initialization function
|
|
*
|
|
* Enables USART peripheral, clocks and initializes USART driver
|
|
*/
|
|
void UART_debug_init(void)
|
|
{
|
|
UART_debug_CLOCK_init();
|
|
usart_async_rings_init(&UART_debug, SERCOM7, UART_DEBUG_buffer_rx, UART_DEBUG_BUFFER_SIZE, UART_DEBUG_buffer_tx, UART_DEBUG_BUFFER_SIZE, (void *)NULL);
|
|
UART_debug_PORT_init();
|
|
}
|
|
#else
|
|
/**
|
|
* \brief USART Clock initialization function
|
|
*
|
|
* Enables register interface and peripheral clock
|
|
*/
|
|
void SIM7_CLOCK_init()
|
|
{
|
|
|
|
hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM7_GCLK_ID_CORE, CONF_GCLK_SERCOM7_CORE_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
|
|
hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM7_GCLK_ID_SLOW, CONF_GCLK_SERCOM7_SLOW_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
|
|
|
|
hri_mclk_set_APBDMASK_SERCOM7_bit(MCLK);
|
|
}
|
|
|
|
/**
|
|
* \brief USART pinmux initialization function
|
|
*
|
|
* Set each required pin to USART functionality
|
|
*/
|
|
void SIM7_PORT_init()
|
|
{
|
|
|
|
gpio_set_pin_function(SIM7_IO, PINMUX_PB21D_SERCOM7_PAD0);
|
|
}
|
|
|
|
/**
|
|
* \brief USART initialization function
|
|
*
|
|
* Enables USART peripheral, clocks and initializes USART driver
|
|
*/
|
|
void SIM7_init(void)
|
|
{
|
|
SIM7_CLOCK_init();
|
|
usart_async_init(&SIM7, SERCOM7, SIM7_buffer, SIM7_BUFFER_SIZE, (void *)NULL);
|
|
SIM7_PORT_init();
|
|
}
|
|
#endif
|
|
void USB_DEVICE_INSTANCE_PORT_init(void)
|
|
{
|
|
|
|
gpio_set_pin_direction(USBUP_D_N,
|
|
// <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(USBUP_D_N,
|
|
// <y> Initial level
|
|
// <id> pad_initial_level
|
|
// <false"> Low
|
|
// <true"> High
|
|
false);
|
|
|
|
gpio_set_pin_pull_mode(USBUP_D_N,
|
|
// <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(USBUP_D_N,
|
|
// <y> Pin function
|
|
// <id> pad_function
|
|
// <i> Auto : use driver pinmux if signal is imported by driver, else turn off function
|
|
// <PINMUX_PA24H_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
|
|
// <GPIO_PIN_FUNCTION_I"> I
|
|
// <GPIO_PIN_FUNCTION_J"> J
|
|
// <GPIO_PIN_FUNCTION_K"> K
|
|
// <GPIO_PIN_FUNCTION_L"> L
|
|
// <GPIO_PIN_FUNCTION_M"> M
|
|
// <GPIO_PIN_FUNCTION_N"> N
|
|
PINMUX_PA24H_USB_DM);
|
|
|
|
gpio_set_pin_direction(USBUP_D_P,
|
|
// <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(USBUP_D_P,
|
|
// <y> Initial level
|
|
// <id> pad_initial_level
|
|
// <false"> Low
|
|
// <true"> High
|
|
false);
|
|
|
|
gpio_set_pin_pull_mode(USBUP_D_P,
|
|
// <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(USBUP_D_P,
|
|
// <y> Pin function
|
|
// <id> pad_function
|
|
// <i> Auto : use driver pinmux if signal is imported by driver, else turn off function
|
|
// <PINMUX_PA25H_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
|
|
// <GPIO_PIN_FUNCTION_I"> I
|
|
// <GPIO_PIN_FUNCTION_J"> J
|
|
// <GPIO_PIN_FUNCTION_K"> K
|
|
// <GPIO_PIN_FUNCTION_L"> L
|
|
// <GPIO_PIN_FUNCTION_M"> M
|
|
// <GPIO_PIN_FUNCTION_N"> N
|
|
PINMUX_PA25H_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)
|
|
{
|
|
|
|
hri_gclk_write_PCHCTRL_reg(GCLK, USB_GCLK_ID, CONF_GCLK_USB_SRC | GCLK_PCHCTRL_CHEN);
|
|
hri_mclk_set_AHBMASK_USB_bit(MCLK);
|
|
hri_mclk_set_APBBMASK_USB_bit(MCLK);
|
|
}
|
|
|
|
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();
|
|
|
|
// GPIO on PA02
|
|
|
|
// Set pin direction to input
|
|
gpio_set_pin_direction(SIM4_INT, GPIO_DIRECTION_IN);
|
|
|
|
gpio_set_pin_pull_mode(SIM4_INT,
|
|
// <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(SIM4_INT, GPIO_PIN_FUNCTION_OFF);
|
|
|
|
// GPIO on PA03
|
|
|
|
// Set pin direction to input
|
|
gpio_set_pin_direction(SIM5_INT, GPIO_DIRECTION_IN);
|
|
|
|
gpio_set_pin_pull_mode(SIM5_INT,
|
|
// <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(SIM5_INT, GPIO_PIN_FUNCTION_OFF);
|
|
|
|
// GPIO on PA10
|
|
|
|
gpio_set_pin_direction(RMII_CLOCK,
|
|
// <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(RMII_CLOCK,
|
|
// <y> Initial level
|
|
// <id> pad_initial_level
|
|
// <false"> Low
|
|
// <true"> High
|
|
false);
|
|
|
|
gpio_set_pin_pull_mode(RMII_CLOCK,
|
|
// <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(RMII_CLOCK,
|
|
// <y> Pin function
|
|
// <id> pad_function
|
|
// <i> Auto : use driver pinmux if signal is imported by driver, else turn off function
|
|
// <GPIO_PIN_FUNCTION_OFF"> 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
|
|
// <GPIO_PIN_FUNCTION_I"> I
|
|
// <GPIO_PIN_FUNCTION_J"> J
|
|
// <GPIO_PIN_FUNCTION_K"> K
|
|
// <GPIO_PIN_FUNCTION_L"> L
|
|
// <GPIO_PIN_FUNCTION_M"> M
|
|
// <GPIO_PIN_FUNCTION_N"> N
|
|
GPIO_PIN_FUNCTION_M);
|
|
|
|
// GPIO on PA11
|
|
|
|
gpio_set_pin_direction(SIMCLK_20MHZ,
|
|
// <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(SIMCLK_20MHZ,
|
|
// <y> Initial level
|
|
// <id> pad_initial_level
|
|
// <false"> Low
|
|
// <true"> High
|
|
false);
|
|
|
|
gpio_set_pin_pull_mode(SIMCLK_20MHZ,
|
|
// <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(SIMCLK_20MHZ,
|
|
// <y> Pin function
|
|
// <id> pad_function
|
|
// <i> Auto : use driver pinmux if signal is imported by driver, else turn off function
|
|
// <GPIO_PIN_FUNCTION_OFF"> 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
|
|
// <GPIO_PIN_FUNCTION_I"> I
|
|
// <GPIO_PIN_FUNCTION_J"> J
|
|
// <GPIO_PIN_FUNCTION_K"> K
|
|
// <GPIO_PIN_FUNCTION_L"> L
|
|
// <GPIO_PIN_FUNCTION_M"> M
|
|
// <GPIO_PIN_FUNCTION_N"> N
|
|
GPIO_PIN_FUNCTION_M);
|
|
|
|
// GPIO on PA20
|
|
|
|
// Set pin direction to input
|
|
gpio_set_pin_direction(VB0, GPIO_DIRECTION_IN);
|
|
|
|
gpio_set_pin_pull_mode(VB0,
|
|
// <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(VB0, GPIO_PIN_FUNCTION_OFF);
|
|
|
|
// GPIO on PA21
|
|
|
|
// Set pin direction to input
|
|
gpio_set_pin_direction(VB1, GPIO_DIRECTION_IN);
|
|
|
|
gpio_set_pin_pull_mode(VB1,
|
|
// <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(VB1, GPIO_PIN_FUNCTION_OFF);
|
|
|
|
// GPIO on PA22
|
|
|
|
// Set pin direction to input
|
|
gpio_set_pin_direction(VB2, GPIO_DIRECTION_IN);
|
|
|
|
gpio_set_pin_pull_mode(VB2,
|
|
// <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(VB2, GPIO_PIN_FUNCTION_OFF);
|
|
|
|
// GPIO on PA23
|
|
|
|
// Set pin direction to input
|
|
gpio_set_pin_direction(VB3, GPIO_DIRECTION_IN);
|
|
|
|
gpio_set_pin_pull_mode(VB3,
|
|
// <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(VB3, GPIO_PIN_FUNCTION_OFF);
|
|
|
|
// GPIO on PB02
|
|
|
|
gpio_set_pin_level(SCL2,
|
|
// <y> Initial level
|
|
// <id> pad_initial_level
|
|
// <false"> Low
|
|
// <true"> High
|
|
false);
|
|
|
|
// Set pin direction to output
|
|
gpio_set_pin_direction(SCL2, GPIO_DIRECTION_OUT);
|
|
|
|
gpio_set_pin_function(SCL2, GPIO_PIN_FUNCTION_OFF);
|
|
|
|
// GPIO on PB03
|
|
|
|
gpio_set_pin_level(SDA2,
|
|
// <y> Initial level
|
|
// <id> pad_initial_level
|
|
// <false"> Low
|
|
// <true"> High
|
|
false);
|
|
|
|
// Set pin direction to output
|
|
gpio_set_pin_direction(SDA2, GPIO_DIRECTION_OUT);
|
|
|
|
gpio_set_pin_function(SDA2, GPIO_PIN_FUNCTION_OFF);
|
|
|
|
// GPIO on PB04
|
|
|
|
// Set pin direction to input
|
|
gpio_set_pin_direction(SIM6_INT, GPIO_DIRECTION_IN);
|
|
|
|
gpio_set_pin_pull_mode(SIM6_INT,
|
|
// <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(SIM6_INT, GPIO_PIN_FUNCTION_OFF);
|
|
|
|
// GPIO on PB05
|
|
|
|
// Set pin direction to input
|
|
gpio_set_pin_direction(SIM7_INT, GPIO_DIRECTION_IN);
|
|
|
|
gpio_set_pin_pull_mode(SIM7_INT,
|
|
// <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(SIM7_INT, GPIO_PIN_FUNCTION_OFF);
|
|
|
|
// GPIO on PB06
|
|
|
|
gpio_set_pin_level(SCL3,
|
|
// <y> Initial level
|
|
// <id> pad_initial_level
|
|
// <false"> Low
|
|
// <true"> High
|
|
false);
|
|
|
|
// Set pin direction to output
|
|
gpio_set_pin_direction(SCL3, GPIO_DIRECTION_OUT);
|
|
|
|
gpio_set_pin_function(SCL3, GPIO_PIN_FUNCTION_OFF);
|
|
|
|
// GPIO on PB07
|
|
|
|
gpio_set_pin_level(SDA3,
|
|
// <y> Initial level
|
|
// <id> pad_initial_level
|
|
// <false"> Low
|
|
// <true"> High
|
|
false);
|
|
|
|
// Set pin direction to output
|
|
gpio_set_pin_direction(SDA3, GPIO_DIRECTION_OUT);
|
|
|
|
gpio_set_pin_function(SDA3, GPIO_PIN_FUNCTION_OFF);
|
|
|
|
// GPIO on PB14
|
|
|
|
gpio_set_pin_level(SCL1,
|
|
// <y> Initial level
|
|
// <id> pad_initial_level
|
|
// <false"> Low
|
|
// <true"> High
|
|
false);
|
|
|
|
// Set pin direction to output
|
|
gpio_set_pin_direction(SCL1, GPIO_DIRECTION_OUT);
|
|
|
|
gpio_set_pin_function(SCL1, GPIO_PIN_FUNCTION_OFF);
|
|
|
|
// GPIO on PB15
|
|
|
|
gpio_set_pin_level(SDA1,
|
|
// <y> Initial level
|
|
// <id> pad_initial_level
|
|
// <false"> Low
|
|
// <true"> High
|
|
false);
|
|
|
|
// Set pin direction to output
|
|
gpio_set_pin_direction(SDA1, GPIO_DIRECTION_OUT);
|
|
|
|
gpio_set_pin_function(SDA1, GPIO_PIN_FUNCTION_OFF);
|
|
|
|
// GPIO on PC00
|
|
|
|
// Set pin direction to input
|
|
gpio_set_pin_direction(SIM0_INT, GPIO_DIRECTION_IN);
|
|
|
|
gpio_set_pin_pull_mode(SIM0_INT,
|
|
// <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(SIM0_INT, GPIO_PIN_FUNCTION_OFF);
|
|
|
|
// GPIO on PC01
|
|
|
|
// Set pin direction to input
|
|
gpio_set_pin_direction(SIM1_INT, GPIO_DIRECTION_IN);
|
|
|
|
gpio_set_pin_pull_mode(SIM1_INT,
|
|
// <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(SIM1_INT, GPIO_PIN_FUNCTION_OFF);
|
|
|
|
// GPIO on PC02
|
|
|
|
// Set pin direction to input
|
|
gpio_set_pin_direction(SIM2_INT, GPIO_DIRECTION_IN);
|
|
|
|
gpio_set_pin_pull_mode(SIM2_INT,
|
|
// <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(SIM2_INT, GPIO_PIN_FUNCTION_OFF);
|
|
|
|
// GPIO on PC03
|
|
|
|
// Set pin direction to input
|
|
gpio_set_pin_direction(SIM3_INT, GPIO_DIRECTION_IN);
|
|
|
|
gpio_set_pin_pull_mode(SIM3_INT,
|
|
// <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(SIM3_INT, GPIO_PIN_FUNCTION_OFF);
|
|
|
|
// GPIO on PC14
|
|
|
|
// Set pin direction to input
|
|
gpio_set_pin_direction(SWITCH, GPIO_DIRECTION_IN);
|
|
|
|
gpio_set_pin_pull_mode(SWITCH,
|
|
// <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(SWITCH, GPIO_PIN_FUNCTION_OFF);
|
|
|
|
// GPIO on PC15
|
|
|
|
// Set pin direction to input
|
|
gpio_set_pin_direction(MUX_STAT, GPIO_DIRECTION_IN);
|
|
|
|
gpio_set_pin_pull_mode(MUX_STAT,
|
|
// <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(MUX_STAT, GPIO_PIN_FUNCTION_OFF);
|
|
|
|
// GPIO on PC26
|
|
|
|
gpio_set_pin_level(USER_LED,
|
|
// <y> Initial level
|
|
// <id> pad_initial_level
|
|
// <false"> Low
|
|
// <true"> High
|
|
false);
|
|
|
|
// Set pin direction to output
|
|
gpio_set_pin_direction(USER_LED, GPIO_DIRECTION_OUT);
|
|
|
|
gpio_set_pin_function(USER_LED, GPIO_PIN_FUNCTION_OFF);
|
|
|
|
// GPIO on PC27
|
|
|
|
gpio_set_pin_level(SCL4,
|
|
// <y> Initial level
|
|
// <id> pad_initial_level
|
|
// <false"> Low
|
|
// <true"> High
|
|
false);
|
|
|
|
// Set pin direction to output
|
|
gpio_set_pin_direction(SCL4, GPIO_DIRECTION_OUT);
|
|
|
|
gpio_set_pin_function(SCL4, GPIO_PIN_FUNCTION_OFF);
|
|
|
|
// GPIO on PC28
|
|
|
|
gpio_set_pin_level(SDA4,
|
|
// <y> Initial level
|
|
// <id> pad_initial_level
|
|
// <false"> Low
|
|
// <true"> High
|
|
false);
|
|
|
|
// Set pin direction to output
|
|
gpio_set_pin_direction(SDA4, GPIO_DIRECTION_OUT);
|
|
|
|
gpio_set_pin_function(SDA4, GPIO_PIN_FUNCTION_OFF);
|
|
|
|
CALENDAR_0_init();
|
|
SIM0_init();
|
|
SIM1_init();
|
|
SIM2_init();
|
|
SIM3_init();
|
|
SIM4_init();
|
|
SIM5_init();
|
|
SIM6_init();
|
|
#ifndef ENABLE_DBG_UART7
|
|
SIM7_init();
|
|
#else
|
|
UART_debug_init();
|
|
#endif
|
|
|
|
USB_DEVICE_INSTANCE_init();
|
|
}
|