atmel-asf-projects/sam/boards/osmocom_e1_usb/init.c

99 lines
3.2 KiB
C

/**
* \file
*
* \brief SAM4S Xplained Pro board initialization
*
* Copyright (C) 2012-2015 Atmel Corporation. All rights reserved.
*
* \asf_license_start
*
* \page License
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. The name of Atmel may not be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* 4. This software may only be redistributed and used in connection with an
* Atmel microcontroller product.
*
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* \asf_license_stop
*/
/*
* Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a>
*/
#include <board.h>
#include <gpio.h>
#include <ioport.h>
#include <wdt.h>
/**
* \addtogroup sam4s_xplained_pro_group
* @{
*/
void board_init(void)
{
#ifndef CONF_BOARD_KEEP_WATCHDOG_AT_INIT
wdt_disable(WDT);
#endif
/* GPIO has been deprecated, the old code just keeps it for compatibility.
* In new designs IOPORT is used instead.
* Here IOPORT must be initialized for others to use before setting up IO.
*/
ioport_init();
/* Initialize LED, turned off */
ioport_set_pin_level(LED_0_PIN, !LED_0_ACTIVE);
ioport_set_pin_dir(LED_0_PIN, IOPORT_DIR_OUTPUT);
ioport_set_pin_level(LED_1_PIN, !LED_1_ACTIVE);
ioport_set_pin_dir(LED_1_PIN, IOPORT_DIR_OUTPUT);
ioport_set_pin_level(LED_2_PIN, !LED_2_ACTIVE);
ioport_set_pin_dir(LED_2_PIN, IOPORT_DIR_OUTPUT);
#ifdef CONF_BOARD_UART_CONSOLE
/* Configure UART pins */
gpio_configure_group(PINS_UART0_PIO, PINS_UART0, PINS_UART0_FLAGS);
#endif
#ifdef CONF_BOARD_TWI0
gpio_configure_pin(TWI0_DATA_GPIO, TWI0_DATA_FLAGS);
gpio_configure_pin(TWI0_CLK_GPIO, TWI0_CLK_FLAGS);
#endif
/* Configure SPI pins */
#ifdef CONF_BOARD_SPI
gpio_configure_pin(SPI_MISO_GPIO, SPI_MISO_FLAGS);
gpio_configure_pin(SPI_MOSI_GPIO, SPI_MOSI_FLAGS);
gpio_configure_pin(SPI_SPCK_GPIO, SPI_SPCK_FLAGS);
gpio_configure_pin(SPI_NPCS0_GPIO, SPI_NPCS0_FLAGS);
gpio_configure_pin(SPI_NPCS1_PA31_GPIO, SPI_NPCS1_PA31_FLAGS);
gpio_configure_pin(SPI_NPCS2_PA30_GPIO, SPI_NPCS2_PA30_FLAGS);
#endif
}
/** @} */