blob: 115515819562846bcb9a8b363212d225c3658363 [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
Kévin Redonca9e4bf2018-06-27 16:26:21 +020056#define PIO_LED_RED PIO_PA17
57#define PIO_LED_GREEN PIO_PA18
Harald Welte2d3371e2015-11-30 11:59:03 +010058
Harald Welteabba8a82017-03-06 16:58:00 +010059#define PIN_LED_RED {PIO_LED_RED, PIOA, ID_PIOA, PIO_OUTPUT_1, PIO_DEFAULT}
60#define PIN_LED_GREEN {PIO_LED_GREEN, PIOA, ID_PIOA, PIO_OUTPUT_1, PIO_DEFAULT}
Harald Welte2d3371e2015-11-30 11:59:03 +010061#define PINS_LEDS PIN_LED_RED, PIN_LED_GREEN
62
63#define LED_NUM_RED 0
64#define LED_NUM_GREEN 1
65
66/** USART0 pin RX */
67#define PIN_USART0_RXD {PIO_PA9A_URXD0, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT}
68/** USART0 pin TX */
69#define PIN_USART0_TXD {PIO_PA10A_UTXD0, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT}
70
71#define BOARD_PIN_USART_RXD PIN_USART0_RXD
72#define BOARD_PIN_USART_TXD PIN_USART0_TXD
73
74#define BOARD_ID_USART ID_USART0
75#define BOARD_USART_BASE USART0
76
77#define PINS_UART { PIO_PA9A_URXD0|PIO_PA10A_UTXD0, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT}
78
79/** UART0 */
Kévin Redon80d94762018-08-28 19:19:03 +020080/** Console baud rate in bps */
81#define CONSOLE_BAUDRATE 921600
Kévin Redoneac1bec2018-06-25 15:55:33 +020082/** UART peripheral used by the console (UART0). */
83#define CONSOLE_UART UART0
84/** UART peripheral ID used by the console (UART0). */
Harald Welte2d3371e2015-11-30 11:59:03 +010085#define CONSOLE_ID ID_UART0
Kévin Redoneac1bec2018-06-25 15:55:33 +020086/** UART ISR used by the console (UART0). */
87#define CONSOLE_ISR UART0_IrqHandler
88/** UART IRQ used by the console (UART0). */
89#define CONSOLE_IRQ UART0_IRQn
Harald Welte2d3371e2015-11-30 11:59:03 +010090/** Pins description corresponding to Rxd,Txd, (UART pins) */
91#define CONSOLE_PINS {PINS_UART}
92
93/// Smartcard detection pin
94// FIXME: add connect pin as iso pin...should it be periph b or interrupt oder input?
95#define BOARD_ISO7816_BASE_USART USART0
96#define BOARD_ISO7816_ID_USART ID_USART0
97
Kévin Redon4091d782018-06-11 13:43:27 +020098/* USART peripherals for a phone and SIM card setup */
99/* USART peripheral connected to the SIM card */
Harald Welte2d3371e2015-11-30 11:59:03 +0100100#define USART_SIM USART0
Kévin Redon4091d782018-06-11 13:43:27 +0200101/* ID of USART peripheral connected to the SIM card */
Harald Welte2d3371e2015-11-30 11:59:03 +0100102#define ID_USART_SIM ID_USART0
Kévin Redon4091d782018-06-11 13:43:27 +0200103/* Interrupt request ID of USART peripheral connected to the SIM card */
104#define IRQ_USART_SIM USART0_IRQn
105/* USART peripheral connected to the phone */
106#define USART_PHONE USART1
107/* ID of USART peripheral connected to the phone */
108#define ID_USART_PHONE ID_USART1
109/* Interrupt request ID of USART peripheral connected to the phone */
110#define IRQ_USART_PHONE USART1_IRQn
Harald Welte2d3371e2015-11-30 11:59:03 +0100111
112#define SIM_PWEN PIO_PA5
113#define VCC_FWD PIO_PA26
114
Harald Welte2d3371e2015-11-30 11:59:03 +0100115// Board has UDP controller
116#define BOARD_USB_UDP
Harald Welte2d3371e2015-11-30 11:59:03 +0100117
Harald Welte7ed6f3b2017-02-26 17:00:43 +0100118#define BOARD_USB_DFU
119#define BOARD_DFU_BOOT_SIZE (16 * 1024)
Harald Welte32852bc2017-02-28 00:21:45 +0100120#define BOARD_DFU_RAM_SIZE (2 * 1024)
Harald Welte7ed6f3b2017-02-26 17:00:43 +0100121#define BOARD_DFU_PAGE_SIZE 512
122#define BOARD_DFU_NUM_IF 2
Harald Welteaa3b8672017-02-10 19:21:10 +0100123
124extern void board_exec_dbg_cmd(int ch);
125extern void board_main_top(void);
Harald Welte27f5fc62017-11-28 22:15:56 +0100126extern int board_override_enter_dfu(void);
Harald Welte2d3371e2015-11-30 11:59:03 +0100127#endif