blob: 06d3d6a417d2b66627a3b5e33ff2719b783b8f59 [file] [log] [blame]
Kévin Redon9a12d682018-07-08 13:21:16 +02001/* SIMtrace 2 common board pin definitions
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
16 */
Harald Welte2d3371e2015-11-30 11:59:03 +010017#ifndef _BOARD_
18#define _BOARD_
19
20/** Headers */
21#include "chip.h"
22/* We need this for a nop instruction in USB_HAL.c */
23#define __CC_ARM
24
25/** Board */
26#include "board_lowlevel.h"
27#include "uart_console.h"
28#include "iso7816_4.h"
29#include "led.h"
30#include "cciddriver.h"
31#include "usart.h"
32#include "USBD.h"
33
34#include "USBD_Config.h"
35#include "USBDDriver.h"
36
37/** Highlevel */
38#include "trace.h"
39#include "stdio.h"
40#include "stdlib.h"
41#include "string.h"
42#include "inttypes.h"
Harald Welte83207e02017-02-03 22:16:47 +010043#include "syscalls.h"
Harald Welte2d3371e2015-11-30 11:59:03 +010044
Harald Welte2d3371e2015-11-30 11:59:03 +010045#define MIN(a, b) ((a < b) ? a : b)
46
47#ifdef __GNUC__
48#undef __GNUC__
49#endif
50
51/** Family definition (already defined) */
52#define sam3s
53/** Core definition */
54#define cortexm3
55
Harald Welte2d3371e2015-11-30 11:59:03 +010056#define BOARD_MCK 48000000
57
Kévin Redonca9e4bf2018-06-27 16:26:21 +020058#define PIO_LED_RED PIO_PA17
59#define PIO_LED_GREEN PIO_PA18
Harald Welte2d3371e2015-11-30 11:59:03 +010060
Harald Welteabba8a82017-03-06 16:58:00 +010061#define PIN_LED_RED {PIO_LED_RED, PIOA, ID_PIOA, PIO_OUTPUT_1, PIO_DEFAULT}
62#define PIN_LED_GREEN {PIO_LED_GREEN, PIOA, ID_PIOA, PIO_OUTPUT_1, PIO_DEFAULT}
Harald Welte2d3371e2015-11-30 11:59:03 +010063#define PINS_LEDS PIN_LED_RED, PIN_LED_GREEN
64
65#define LED_NUM_RED 0
66#define LED_NUM_GREEN 1
67
68/** USART0 pin RX */
69#define PIN_USART0_RXD {PIO_PA9A_URXD0, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT}
70/** USART0 pin TX */
71#define PIN_USART0_TXD {PIO_PA10A_UTXD0, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT}
72
73#define BOARD_PIN_USART_RXD PIN_USART0_RXD
74#define BOARD_PIN_USART_TXD PIN_USART0_TXD
75
76#define BOARD_ID_USART ID_USART0
77#define BOARD_USART_BASE USART0
78
79#define PINS_UART { PIO_PA9A_URXD0|PIO_PA10A_UTXD0, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT}
80
81/** UART0 */
82/** Console baudrate always using 115200. */
Harald Welte67415e32016-09-01 20:57:56 +020083#define CONSOLE_BAUDRATE 115200
Kévin Redoneac1bec2018-06-25 15:55:33 +020084/** UART peripheral used by the console (UART0). */
85#define CONSOLE_UART UART0
86/** UART peripheral ID used by the console (UART0). */
Harald Welte2d3371e2015-11-30 11:59:03 +010087#define CONSOLE_ID ID_UART0
Kévin Redoneac1bec2018-06-25 15:55:33 +020088/** UART ISR used by the console (UART0). */
89#define CONSOLE_ISR UART0_IrqHandler
90/** UART IRQ used by the console (UART0). */
91#define CONSOLE_IRQ UART0_IRQn
Harald Welte2d3371e2015-11-30 11:59:03 +010092/** Pins description corresponding to Rxd,Txd, (UART pins) */
93#define CONSOLE_PINS {PINS_UART}
94
95/// Smartcard detection pin
96// FIXME: add connect pin as iso pin...should it be periph b or interrupt oder input?
97#define BOARD_ISO7816_BASE_USART USART0
98#define BOARD_ISO7816_ID_USART ID_USART0
99
Kévin Redon4091d782018-06-11 13:43:27 +0200100/* USART peripherals for a phone and SIM card setup */
101/* USART peripheral connected to the SIM card */
Harald Welte2d3371e2015-11-30 11:59:03 +0100102#define USART_SIM USART0
Kévin Redon4091d782018-06-11 13:43:27 +0200103/* ID of USART peripheral connected to the SIM card */
Harald Welte2d3371e2015-11-30 11:59:03 +0100104#define ID_USART_SIM ID_USART0
Kévin Redon4091d782018-06-11 13:43:27 +0200105/* Interrupt request ID of USART peripheral connected to the SIM card */
106#define IRQ_USART_SIM USART0_IRQn
107/* USART peripheral connected to the phone */
108#define USART_PHONE USART1
109/* ID of USART peripheral connected to the phone */
110#define ID_USART_PHONE ID_USART1
111/* Interrupt request ID of USART peripheral connected to the phone */
112#define IRQ_USART_PHONE USART1_IRQn
Harald Welte2d3371e2015-11-30 11:59:03 +0100113
114#define SIM_PWEN PIO_PA5
115#define VCC_FWD PIO_PA26
116
Kévin Redonf5869d42018-06-17 22:31:21 +0200117/** Pin configuration to control USB pull-up on D+
118 * @details the USB pull-up on D+ is enable by default on the board but can be disabled by setting PA16 high
119 */
120#define PIN_USB_PULLUP {PIO_PA16, PIOA, ID_PIOA, PIO_OUTPUT_0, PIO_DEFAULT}
Harald Welte2d3371e2015-11-30 11:59:03 +0100121
122// Board has UDP controller
123#define BOARD_USB_UDP
124// D+ has external pull-up
125#define BOARD_USB_PULLUP_EXTERNAL
126
Harald Welte7ed6f3b2017-02-26 17:00:43 +0100127#define BOARD_USB_DFU
128#define BOARD_DFU_BOOT_SIZE (16 * 1024)
Harald Welte32852bc2017-02-28 00:21:45 +0100129#define BOARD_DFU_RAM_SIZE (2 * 1024)
Harald Welte7ed6f3b2017-02-26 17:00:43 +0100130#define BOARD_DFU_PAGE_SIZE 512
131#define BOARD_DFU_NUM_IF 2
Harald Welteaa3b8672017-02-10 19:21:10 +0100132
133extern void board_exec_dbg_cmd(int ch);
134extern void board_main_top(void);
Harald Welte27f5fc62017-11-28 22:15:56 +0100135extern int board_override_enter_dfu(void);
Harald Welte2d3371e2015-11-30 11:59:03 +0100136#endif