4 * \brief SAM4S-EK board init.
\r
6 * Copyright (c) 2011 - 2012 Atmel Corporation. All rights reserved.
\r
10 * Redistribution and use in source and binary forms, with or without
\r
11 * modification, are permitted provided that the following conditions are met:
\r
13 * 1. Redistributions of source code must retain the above copyright notice,
\r
14 * this list of conditions and the following disclaimer.
\r
16 * 2. Redistributions in binary form must reproduce the above copyright notice,
\r
17 * this list of conditions and the following disclaimer in the documentation
\r
18 * and/or other materials provided with the distribution.
\r
20 * 3. The name of Atmel may not be used to endorse or promote products derived
\r
21 * from this software without specific prior written permission.
\r
23 * 4. This software may only be redistributed and used in connection with an
\r
24 * Atmel microcontroller product.
\r
26 * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
\r
27 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
\r
28 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
\r
29 * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
\r
30 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
\r
31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
\r
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
\r
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
\r
34 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
\r
35 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
\r
36 * POSSIBILITY OF SUCH DAMAGE.
\r
42 #include "compiler.h"
\r
44 #include "conf_board.h"
\r
47 void board_init(void)
\r
49 #ifndef CONF_BOARD_KEEP_WATCHDOG_AT_INIT
\r
50 /* Disable the watchdog */
\r
51 WDT->WDT_MR = WDT_MR_WDDIS;
\r
54 /* Configure LED pins */
\r
55 gpio_configure_pin(LED0_GPIO, LED0_FLAGS);
\r
56 gpio_configure_pin(LED1_GPIO, LED1_FLAGS);
\r
58 /* Configure Push Button pins */
\r
59 gpio_configure_pin(GPIO_PUSH_BUTTON_1, GPIO_PUSH_BUTTON_1_FLAGS);
\r
60 gpio_configure_pin(GPIO_PUSH_BUTTON_2, GPIO_PUSH_BUTTON_2_FLAGS);
\r
62 #ifdef CONF_BOARD_UART_CONSOLE
\r
63 /* Configure UART pins */
\r
64 gpio_configure_group(PINS_UART_PIO, PINS_UART, PINS_UART_FLAGS);
\r
67 /* Configure ADC example pins */
\r
68 #ifdef CONF_BOARD_ADC
\r
69 /* TC TIOA configuration */
\r
70 gpio_configure_pin(PIN_TC0_TIOA0,PIN_TC0_TIOA0_FLAGS);
\r
72 /* ADC Trigger configuration */
\r
73 gpio_configure_pin(PINS_ADC_TRIG, PINS_ADC_TRIG_FLAG);
\r
75 /* PWMH0 configuration */
\r
76 gpio_configure_pin(PIN_PWMC_PWMH0_TRIG, PIN_PWMC_PWMH0_TRIG_FLAG);
\r
79 #ifdef CONF_BOARD_PWM_LED0
\r
80 /* Configure PWM LED0 pin */
\r
81 gpio_configure_pin(PIN_PWM_LED0_GPIO, PIN_PWM_LED0_FLAGS);
\r
84 #ifdef CONF_BOARD_PWM_LED1
\r
85 /* Configure PWM LED1 pin */
\r
86 gpio_configure_pin(PIN_PWM_LED1_GPIO, PIN_PWM_LED1_FLAGS);
\r
89 #ifdef CONF_BOARD_PWM_LED2
\r
90 /* Configure PWM LED2 pin */
\r
91 gpio_configure_pin(PIN_PWM_LED2_GPIO, PIN_PWM_LED2_FLAGS);
\r
94 /* Configure SPI pins */
\r
95 #ifdef CONF_BOARD_SPI
\r
96 gpio_configure_pin(SPI_MISO_GPIO, SPI_MISO_FLAGS);
\r
97 gpio_configure_pin(SPI_MOSI_GPIO, SPI_MOSI_FLAGS);
\r
98 gpio_configure_pin(SPI_SPCK_GPIO, SPI_SPCK_FLAGS);
\r
101 * For NPCS 1, 2, and 3, different PINs can be used to access the same NPCS line.
\r
102 * Depending on the application requirements, the default PIN may not be available.
\r
103 * Hence a different PIN should be selected using the CONF_BOARD_SPI_NPCS_GPIO and
\r
104 * CONF_BOARD_SPI_NPCS_FLAGS macros.
\r
107 #ifdef CONF_BOARD_SPI_NPCS0
\r
108 gpio_configure_pin(SPI_NPCS0_GPIO, SPI_NPCS0_FLAGS);
\r
111 #ifdef CONF_BOARD_SPI_NPCS1
\r
112 #if defined(CONF_BOARD_SPI_NPCS1_GPIO) && defined(CONF_BOARD_SPI_NPCS1_FLAGS)
\r
113 gpio_configure_pin(CONF_BOARD_SPI_NPCS1_GPIO, CONF_BOARD_SPI_NPCS1_FLAGS);
\r
115 gpio_configure_pin(SPI_NPCS1_PA31_GPIO, SPI_NPCS1_PA31_FLAGS);
\r
119 #ifdef CONF_BOARD_SPI_NPCS2
\r
120 #if defined(CONF_BOARD_SPI_NPCS2_GPIO) && defined(CONF_BOARD_SPI_NPCS2_FLAGS)
\r
121 gpio_configure_pin(CONF_BOARD_SPI_NPCS2_GPIO, CONF_BOARD_SPI_NPCS2_FLAGS);
\r
123 gpio_configure_pin(SPI_NPCS2_PA30_GPIO, SPI_NPCS2_PA30_FLAGS);
\r
127 #ifdef CONF_BOARD_SPI_NPCS3
\r
128 #if defined(CONF_BOARD_SPI_NPCS3_GPIO) && defined(CONF_BOARD_SPI_NPCS3_FLAGS)
\r
129 gpio_configure_pin(CONF_BOARD_SPI_NPCS3_GPIO, CONF_BOARD_SPI_NPCS3_FLAGS);
\r
131 gpio_configure_pin(SPI_NPCS3_PA22_GPIO, SPI_NPCS3_PA22_FLAGS);
\r
136 #ifdef CONF_BOARD_USART_RXD
\r
137 /* Configure USART RXD pin */
\r
138 gpio_configure_pin(PIN_USART1_RXD_IDX, PIN_USART1_RXD_FLAGS);
\r
141 #ifdef CONF_BOARD_USART_TXD
\r
142 /* Configure USART TXD pin */
\r
143 gpio_configure_pin(PIN_USART1_TXD_IDX, PIN_USART1_TXD_FLAGS);
\r
146 #ifdef CONF_BOARD_USART_CTS
\r
147 /* Configure USART CTS pin */
\r
148 gpio_configure_pin(PIN_USART1_CTS_IDX, PIN_USART1_CTS_FLAGS);
\r
151 #ifdef CONF_BOARD_USART_RTS
\r
152 /* Configure USART RTS pin */
\r
153 gpio_configure_pin(PIN_USART1_RTS_IDX, PIN_USART1_RTS_FLAGS);
\r
156 #ifdef CONF_BOARD_USART_SCK
\r
157 /* Configure USART synchronous communication SCK pin */
\r
158 gpio_configure_pin(PIN_USART1_SCK_IDX, PIN_USART1_SCK_FLAGS);
\r
161 #ifdef CONF_BOARD_ADM3312_EN
\r
162 /* Configure ADM33312 enable pin */
\r
163 gpio_configure_pin(PIN_USART1_EN_IDX, PIN_USART1_EN_FLAGS);
\r
164 gpio_set_pin_low(PIN_USART1_EN_IDX);
\r
167 #ifdef CONF_BOARD_TFDU4300_SD
\r
168 /* Configure IrDA transceiver shutdown pin */
\r
169 gpio_configure_pin(PIN_IRDA_SD_IDX, PIN_IRDA_SD_FLAGS);
\r
170 gpio_set_pin_low(PIN_IRDA_SD_IDX);
\r
173 #ifdef CONF_BOARD_ADM3485_RE
\r
174 /* Configure RS485 transceiver RE pin */
\r
175 gpio_configure_pin(PIN_RE_IDX, PIN_RE_FLAGS);
\r
176 gpio_set_pin_low(PIN_RE_IDX);
\r
179 #ifdef CONF_BOARD_ILI9325
\r
180 /* Configure LCD EBI pins */
\r
181 gpio_configure_pin(PIN_EBI_DATA_BUS_D0, PIN_EBI_DATA_BUS_FLAGS);
\r
182 gpio_configure_pin(PIN_EBI_DATA_BUS_D1, PIN_EBI_DATA_BUS_FLAGS);
\r
183 gpio_configure_pin(PIN_EBI_DATA_BUS_D2, PIN_EBI_DATA_BUS_FLAGS);
\r
184 gpio_configure_pin(PIN_EBI_DATA_BUS_D3, PIN_EBI_DATA_BUS_FLAGS);
\r
185 gpio_configure_pin(PIN_EBI_DATA_BUS_D4, PIN_EBI_DATA_BUS_FLAGS);
\r
186 gpio_configure_pin(PIN_EBI_DATA_BUS_D5, PIN_EBI_DATA_BUS_FLAGS);
\r
187 gpio_configure_pin(PIN_EBI_DATA_BUS_D6, PIN_EBI_DATA_BUS_FLAGS);
\r
188 gpio_configure_pin(PIN_EBI_DATA_BUS_D7, PIN_EBI_DATA_BUS_FLAGS);
\r
189 gpio_configure_pin(PIN_EBI_NRD, PIN_EBI_NRD_FLAGS);
\r
190 gpio_configure_pin(PIN_EBI_NWE, PIN_EBI_NWE_FLAGS);
\r
191 gpio_configure_pin(PIN_EBI_NCS1, PIN_EBI_NCS1_FLAGS);
\r
192 gpio_configure_pin(PIN_EBI_LCD_RS, PIN_EBI_LCD_RS_FLAGS);
\r
195 #ifdef CONF_BOARD_AAT3155
\r
196 /* Configure Backlight control pin */
\r
197 gpio_configure_pin(BOARD_BACKLIGHT, BOARD_BACKLIGHT_FLAG);
\r
200 #ifdef CONF_BOARD_ADS7843
\r
201 /* Configure Touchscreen SPI pins */
\r
202 gpio_configure_pin(PIN_TSC_IRQ_IDX,PIN_TSC_IRQ_FLAG);
\r
203 gpio_configure_pin(SPI_MISO_GPIO, SPI_MISO_FLAGS);
\r
204 gpio_configure_pin(SPI_MOSI_GPIO, SPI_MOSI_FLAGS);
\r
205 gpio_configure_pin(SPI_SPCK_GPIO, SPI_SPCK_FLAGS);
\r
206 gpio_configure_pin(SPI_NPCS0_GPIO, SPI_NPCS0_FLAGS);
\r
207 gpio_configure_pin(PIN_TSC_BUSY_IDX, PIN_TSC_BUSY_FLAG);
\r