blob: fec8a05de88c182e9be9e1d08450e9a5a441764b [file] [log] [blame]
Harald Welte2d3371e2015-11-30 11:59:03 +01001#ifndef _BOARD_
2#define _BOARD_
3
4/** Headers */
5#include "chip.h"
6/* We need this for a nop instruction in USB_HAL.c */
7#define __CC_ARM
8
9/** Board */
10#include "board_lowlevel.h"
11#include "uart_console.h"
12#include "iso7816_4.h"
13#include "led.h"
14#include "cciddriver.h"
15#include "usart.h"
16#include "USBD.h"
17
18#include "USBD_Config.h"
19#include "USBDDriver.h"
20
21/** Highlevel */
22#include "trace.h"
23#include "stdio.h"
24#include "stdlib.h"
25#include "string.h"
26#include "inttypes.h"
27
Harald Welte2d3371e2015-11-30 11:59:03 +010028#define MIN(a, b) ((a < b) ? a : b)
29
30#ifdef __GNUC__
31#undef __GNUC__
32#endif
33
34/** Family definition (already defined) */
35#define sam3s
36/** Core definition */
37#define cortexm3
38
Harald Welte2d3371e2015-11-30 11:59:03 +010039#define BOARD_MCK 48000000
40
41#define LED_RED PIO_PA17
42#define LED_GREEN PIO_PA18
43
44#define PIN_LED_RED {LED_RED, PIOA, ID_PIOA, PIO_OUTPUT_1, PIO_DEFAULT}
45#define PIN_LED_GREEN {LED_GREEN, PIOA, ID_PIOA, PIO_OUTPUT_1, PIO_DEFAULT}
46#define PINS_LEDS PIN_LED_RED, PIN_LED_GREEN
47
48#define LED_NUM_RED 0
49#define LED_NUM_GREEN 1
50
51/** USART0 pin RX */
52#define PIN_USART0_RXD {PIO_PA9A_URXD0, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT}
53/** USART0 pin TX */
54#define PIN_USART0_TXD {PIO_PA10A_UTXD0, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT}
55
56#define BOARD_PIN_USART_RXD PIN_USART0_RXD
57#define BOARD_PIN_USART_TXD PIN_USART0_TXD
58
59#define BOARD_ID_USART ID_USART0
60#define BOARD_USART_BASE USART0
61
62#define PINS_UART { PIO_PA9A_URXD0|PIO_PA10A_UTXD0, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT}
63
64/** UART0 */
65/** Console baudrate always using 115200. */
Harald Welte67415e32016-09-01 20:57:56 +020066#define CONSOLE_BAUDRATE 115200
Harald Welte2d3371e2015-11-30 11:59:03 +010067/** Usart Hw interface used by the console (UART0). */
68#define CONSOLE_USART UART0
69/** Usart Hw ID used by the console (UART0). */
70#define CONSOLE_ID ID_UART0
71/** Pins description corresponding to Rxd,Txd, (UART pins) */
72#define CONSOLE_PINS {PINS_UART}
73
74/// Smartcard detection pin
75// FIXME: add connect pin as iso pin...should it be periph b or interrupt oder input?
76#define BOARD_ISO7816_BASE_USART USART0
77#define BOARD_ISO7816_ID_USART ID_USART0
78
79#define USART_SIM USART0
80#define ID_USART_SIM ID_USART0
81#define USART_PHONE USART1
82#define ID_USART_PHONE ID_USART1
83
84#define SIM_PWEN PIO_PA5
85#define VCC_FWD PIO_PA26
86
87
88//** USB **/
89// USB pull-up control pin definition (PA16).
90// Default: 1 (USB Pullup deactivated)
91#define PIN_USB_PULLUP {1 << 16, PIOA, ID_PIOA, PIO_OUTPUT_1, PIO_DEFAULT}
92
93// Board has UDP controller
94#define BOARD_USB_UDP
95// D+ has external pull-up
96#define BOARD_USB_PULLUP_EXTERNAL
97
98#define BOARD_USB_NUMENDPOINTS 8
99
100// FIXME: in all other cases return 0?
101#define BOARD_USB_ENDPOINTS_MAXPACKETSIZE(i) (((i == 4) || (i == 5))? 512 : 64)
102#define BOARD_USB_ENDPOINTS_BANKS(i) (((i == 0) || (i == 3)) ? 1 : 2)
103
104/// USB attributes configuration descriptor (bus or self powered, remote wakeup)
105//#define BOARD_USB_BMATTRIBUTES USBConfigurationDescriptor_SELFPOWERED_NORWAKEUP
106#define BOARD_USB_BMATTRIBUTES USBConfigurationDescriptor_BUSPOWERED_NORWAKEUP
107//#define BOARD_USB_BMATTRIBUTES USBConfigurationDescriptor_SELFPOWERED_RWAKEUP
108
109#endif