Kévin Redon | 9a12d68 | 2018-07-08 13:21:16 +0200 | [diff] [blame] | 1 | /* 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 Welte | 2d3371e | 2015-11-30 11:59:03 +0100 | [diff] [blame] | 17 | #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 Welte | 83207e0 | 2017-02-03 22:16:47 +0100 | [diff] [blame] | 43 | #include "syscalls.h" |
Harald Welte | 2d3371e | 2015-11-30 11:59:03 +0100 | [diff] [blame] | 44 | |
Harald Welte | 2d3371e | 2015-11-30 11:59:03 +0100 | [diff] [blame] | 45 | #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 Welte | 2d3371e | 2015-11-30 11:59:03 +0100 | [diff] [blame] | 56 | #define BOARD_MCK 48000000 |
| 57 | |
Kévin Redon | ca9e4bf | 2018-06-27 16:26:21 +0200 | [diff] [blame] | 58 | #define PIO_LED_RED PIO_PA17 |
| 59 | #define PIO_LED_GREEN PIO_PA18 |
Harald Welte | 2d3371e | 2015-11-30 11:59:03 +0100 | [diff] [blame] | 60 | |
Harald Welte | abba8a8 | 2017-03-06 16:58:00 +0100 | [diff] [blame] | 61 | #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 Welte | 2d3371e | 2015-11-30 11:59:03 +0100 | [diff] [blame] | 63 | #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 Welte | 67415e3 | 2016-09-01 20:57:56 +0200 | [diff] [blame] | 83 | #define CONSOLE_BAUDRATE 115200 |
Kévin Redon | eac1bec | 2018-06-25 15:55:33 +0200 | [diff] [blame] | 84 | /** UART peripheral used by the console (UART0). */ |
| 85 | #define CONSOLE_UART UART0 |
| 86 | /** UART peripheral ID used by the console (UART0). */ |
Harald Welte | 2d3371e | 2015-11-30 11:59:03 +0100 | [diff] [blame] | 87 | #define CONSOLE_ID ID_UART0 |
Kévin Redon | eac1bec | 2018-06-25 15:55:33 +0200 | [diff] [blame] | 88 | /** 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 Welte | 2d3371e | 2015-11-30 11:59:03 +0100 | [diff] [blame] | 92 | /** 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 Redon | 4091d78 | 2018-06-11 13:43:27 +0200 | [diff] [blame] | 100 | /* USART peripherals for a phone and SIM card setup */ |
| 101 | /* USART peripheral connected to the SIM card */ |
Harald Welte | 2d3371e | 2015-11-30 11:59:03 +0100 | [diff] [blame] | 102 | #define USART_SIM USART0 |
Kévin Redon | 4091d78 | 2018-06-11 13:43:27 +0200 | [diff] [blame] | 103 | /* ID of USART peripheral connected to the SIM card */ |
Harald Welte | 2d3371e | 2015-11-30 11:59:03 +0100 | [diff] [blame] | 104 | #define ID_USART_SIM ID_USART0 |
Kévin Redon | 4091d78 | 2018-06-11 13:43:27 +0200 | [diff] [blame] | 105 | /* 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 Welte | 2d3371e | 2015-11-30 11:59:03 +0100 | [diff] [blame] | 113 | |
| 114 | #define SIM_PWEN PIO_PA5 |
| 115 | #define VCC_FWD PIO_PA26 |
| 116 | |
Harald Welte | 2d3371e | 2015-11-30 11:59:03 +0100 | [diff] [blame] | 117 | // Board has UDP controller |
| 118 | #define BOARD_USB_UDP |
Harald Welte | 2d3371e | 2015-11-30 11:59:03 +0100 | [diff] [blame] | 119 | |
Harald Welte | 7ed6f3b | 2017-02-26 17:00:43 +0100 | [diff] [blame] | 120 | #define BOARD_USB_DFU |
| 121 | #define BOARD_DFU_BOOT_SIZE (16 * 1024) |
Harald Welte | 32852bc | 2017-02-28 00:21:45 +0100 | [diff] [blame] | 122 | #define BOARD_DFU_RAM_SIZE (2 * 1024) |
Harald Welte | 7ed6f3b | 2017-02-26 17:00:43 +0100 | [diff] [blame] | 123 | #define BOARD_DFU_PAGE_SIZE 512 |
| 124 | #define BOARD_DFU_NUM_IF 2 |
Harald Welte | aa3b867 | 2017-02-10 19:21:10 +0100 | [diff] [blame] | 125 | |
| 126 | extern void board_exec_dbg_cmd(int ch); |
| 127 | extern void board_main_top(void); |
Harald Welte | 27f5fc6 | 2017-11-28 22:15:56 +0100 | [diff] [blame] | 128 | extern int board_override_enter_dfu(void); |
Harald Welte | 2d3371e | 2015-11-30 11:59:03 +0100 | [diff] [blame] | 129 | #endif |