blob: cb72d4084172ea44688de775789a7d01b2578ee0 [file] [log] [blame]
Kévin Redon9a12d682018-07-08 13:21:16 +02001/* SIMtrace 2 common board pin definitions
2 *
Kévin Redonad0958e2018-09-06 22:49:56 +02003 * (C) 2015-2017 by Harald Welte <hwelte@hmw-consulting.de>
4 * (C) 2018, sysmocom -s.f.m.c. GmbH, Author: Kevin Redon <kredon@sysmocom.de>
5 *
Kévin Redon9a12d682018-07-08 13:21:16 +02006 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
19 */
Harald Welte2d3371e2015-11-30 11:59:03 +010020#ifndef _BOARD_
21#define _BOARD_
22
23/** Headers */
24#include "chip.h"
25/* We need this for a nop instruction in USB_HAL.c */
26#define __CC_ARM
27
28/** Board */
29#include "board_lowlevel.h"
30#include "uart_console.h"
31#include "iso7816_4.h"
32#include "led.h"
33#include "cciddriver.h"
34#include "usart.h"
35#include "USBD.h"
36
37#include "USBD_Config.h"
38#include "USBDDriver.h"
39
40/** Highlevel */
41#include "trace.h"
42#include "stdio.h"
43#include "stdlib.h"
44#include "string.h"
45#include "inttypes.h"
Harald Welte83207e02017-02-03 22:16:47 +010046#include "syscalls.h"
Harald Welte2d3371e2015-11-30 11:59:03 +010047
Harald Welte2d3371e2015-11-30 11:59:03 +010048#define MIN(a, b) ((a < b) ? a : b)
49
50#ifdef __GNUC__
51#undef __GNUC__
52#endif
53
54/** Family definition (already defined) */
55#define sam3s
56/** Core definition */
57#define cortexm3
58
Kévin Redonca9e4bf2018-06-27 16:26:21 +020059#define PIO_LED_RED PIO_PA17
60#define PIO_LED_GREEN PIO_PA18
Harald Welte2d3371e2015-11-30 11:59:03 +010061
Harald Welteabba8a82017-03-06 16:58:00 +010062#define PIN_LED_RED {PIO_LED_RED, PIOA, ID_PIOA, PIO_OUTPUT_1, PIO_DEFAULT}
63#define PIN_LED_GREEN {PIO_LED_GREEN, PIOA, ID_PIOA, PIO_OUTPUT_1, PIO_DEFAULT}
Harald Welte2d3371e2015-11-30 11:59:03 +010064#define PINS_LEDS PIN_LED_RED, PIN_LED_GREEN
65
66#define LED_NUM_RED 0
67#define LED_NUM_GREEN 1
68
69/** USART0 pin RX */
70#define PIN_USART0_RXD {PIO_PA9A_URXD0, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT}
71/** USART0 pin TX */
72#define PIN_USART0_TXD {PIO_PA10A_UTXD0, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT}
73
74#define BOARD_PIN_USART_RXD PIN_USART0_RXD
75#define BOARD_PIN_USART_TXD PIN_USART0_TXD
76
77#define BOARD_ID_USART ID_USART0
78#define BOARD_USART_BASE USART0
79
80#define PINS_UART { PIO_PA9A_URXD0|PIO_PA10A_UTXD0, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT}
81
82/** UART0 */
Kévin Redon80d94762018-08-28 19:19:03 +020083/** Console baud rate in bps */
84#define CONSOLE_BAUDRATE 921600
Kévin Redoneac1bec2018-06-25 15:55:33 +020085/** UART peripheral used by the console (UART0). */
86#define CONSOLE_UART UART0
87/** UART peripheral ID used by the console (UART0). */
Harald Welte2d3371e2015-11-30 11:59:03 +010088#define CONSOLE_ID ID_UART0
Kévin Redoneac1bec2018-06-25 15:55:33 +020089/** UART ISR used by the console (UART0). */
90#define CONSOLE_ISR UART0_IrqHandler
91/** UART IRQ used by the console (UART0). */
92#define CONSOLE_IRQ UART0_IRQn
Harald Welte2d3371e2015-11-30 11:59:03 +010093/** Pins description corresponding to Rxd,Txd, (UART pins) */
94#define CONSOLE_PINS {PINS_UART}
95
96/// Smartcard detection pin
97// FIXME: add connect pin as iso pin...should it be periph b or interrupt oder input?
98#define BOARD_ISO7816_BASE_USART USART0
99#define BOARD_ISO7816_ID_USART ID_USART0
100
Kévin Redon4091d782018-06-11 13:43:27 +0200101/* USART peripherals for a phone and SIM card setup */
102/* USART peripheral connected to the SIM card */
Harald Welte2d3371e2015-11-30 11:59:03 +0100103#define USART_SIM USART0
Kévin Redon4091d782018-06-11 13:43:27 +0200104/* ID of USART peripheral connected to the SIM card */
Harald Welte2d3371e2015-11-30 11:59:03 +0100105#define ID_USART_SIM ID_USART0
Kévin Redon4091d782018-06-11 13:43:27 +0200106/* Interrupt request ID of USART peripheral connected to the SIM card */
107#define IRQ_USART_SIM USART0_IRQn
108/* USART peripheral connected to the phone */
109#define USART_PHONE USART1
110/* ID of USART peripheral connected to the phone */
111#define ID_USART_PHONE ID_USART1
112/* Interrupt request ID of USART peripheral connected to the phone */
113#define IRQ_USART_PHONE USART1_IRQn
Harald Welte2d3371e2015-11-30 11:59:03 +0100114
115#define SIM_PWEN PIO_PA5
116#define VCC_FWD PIO_PA26
117
Harald Welte2d3371e2015-11-30 11:59:03 +0100118// Board has UDP controller
119#define BOARD_USB_UDP
Harald Welte2d3371e2015-11-30 11:59:03 +0100120
Harald Welte7ed6f3b2017-02-26 17:00:43 +0100121#define BOARD_USB_DFU
122#define BOARD_DFU_BOOT_SIZE (16 * 1024)
Harald Welte32852bc2017-02-28 00:21:45 +0100123#define BOARD_DFU_RAM_SIZE (2 * 1024)
Harald Welte7ed6f3b2017-02-26 17:00:43 +0100124#define BOARD_DFU_PAGE_SIZE 512
125#define BOARD_DFU_NUM_IF 2
Harald Welteaa3b8672017-02-10 19:21:10 +0100126
127extern void board_exec_dbg_cmd(int ch);
128extern void board_main_top(void);
Harald Welte27f5fc62017-11-28 22:15:56 +0100129extern int board_override_enter_dfu(void);
Harald Welte2d3371e2015-11-30 11:59:03 +0100130#endif