1 /**
2 * \file
3 *
4 * \brief SAM D20 Xplained Pro board initialization
5 *
6 * Copyright (c) 2014-2015 Atmel Corporation. All rights reserved.
7 *
8 * \asf_license_start
9 *
10 * \page License
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions are met:
14 *
15 * 1. Redistributions of source code must retain the above copyright notice,
16 * this list of conditions and the following disclaimer.
17 *
18 * 2. Redistributions in binary form must reproduce the above copyright notice,
19 * this list of conditions and the following disclaimer in the documentation
20 * and/or other materials provided with the distribution.
21 *
22 * 3. The name of Atmel may not be used to endorse or promote products derived
23 * from this software without specific prior written permission.
24 *
25 * 4. This software may only be redistributed and used in connection with an
26 * Atmel microcontroller product.
27 *
28 * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
29 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
30 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
31 * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
32 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
34 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
36 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
37 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38 * POSSIBILITY OF SUCH DAMAGE.
39 *
40 * \asf_license_stop
41 *
42 */
43 /*
44 * Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a>
45 */
46
47 #include <compiler.h>
48 #include <board.h>
49 #include <conf_board.h>
50 #include <port.h>
51
52 #if defined(__GNUC__)
53 void board_init(void) WEAK __attribute__((alias("system_board_init")));
54 #elif defined(__ICCARM__)
55 void board_init(void);
56 # pragma weak board_init=system_board_init
57 #endif
58
system_board_init(void)59 void system_board_init(void)
60 {
61 struct port_config pin_conf;
62 port_get_config_defaults(&pin_conf);
63
64 /* Configure LEDs as outputs, turn them off */
65 pin_conf.direction = PORT_PIN_DIR_OUTPUT;
66 port_pin_set_config(LED_0_PIN, &pin_conf);
67 port_pin_set_output_level(LED_0_PIN, LED_0_INACTIVE);
68
69 /* Set buttons as inputs */
70 pin_conf.direction = PORT_PIN_DIR_INPUT;
71 pin_conf.input_pull = PORT_PIN_PULL_UP;
72 port_pin_set_config(BUTTON_0_PIN, &pin_conf);
73 #ifdef CONF_BOARD_AT86RFX
74 port_get_config_defaults(&pin_conf);
75 pin_conf.direction = PORT_PIN_DIR_OUTPUT;
76 port_pin_set_config(AT86RFX_SPI_SCK, &pin_conf);
77 port_pin_set_config(AT86RFX_SPI_MOSI, &pin_conf);
78 port_pin_set_config(AT86RFX_SPI_CS, &pin_conf);
79 port_pin_set_config(AT86RFX_RST_PIN, &pin_conf);
80 port_pin_set_config(AT86RFX_SLP_PIN, &pin_conf);
81 port_pin_set_output_level(AT86RFX_SPI_SCK, true);
82 port_pin_set_output_level(AT86RFX_SPI_MOSI, true);
83 port_pin_set_output_level(AT86RFX_SPI_CS, true);
84 port_pin_set_output_level(AT86RFX_RST_PIN, true);
85 port_pin_set_output_level(AT86RFX_SLP_PIN, true);
86 #ifdef EXT_RF_FRONT_END_CTRL
87 port_pin_set_config(AT86RFX_CPS, &pin_conf);
88 port_pin_set_output_level(AT86RFX_CPS, HIGH);
89 port_pin_set_config(AT86RFX_CSD, &pin_conf);
90 port_pin_set_output_level(AT86RFX_CSD, HIGH);
91 #endif
92
93 pin_conf.direction = PORT_PIN_DIR_INPUT;
94 port_pin_set_config(AT86RFX_SPI_MISO, &pin_conf);
95
96 #endif
97 }
98