blob: 9d323cf0168e4580e21fea63aa4e419adf4a012c [file] [log] [blame]
Kévin Redon9a12d682018-07-08 13:21:16 +02001/* SIMtrace with SAM3S specific application code
2 *
3 * (C) 2017 by Harald Welte <laforge@gnumonks.org>
4 * (C) 2018 by sysmocom -s.f.m.c. GmbH, Author: Kevin Redon <kredon@sysmocom.de>
5 *
6 * 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 Welteba2ad562017-11-28 19:49:41 +010020#include "board.h"
21#include "simtrace.h"
22#include "utils.h"
23#include "sim_switch.h"
Harald Welte9d90d282018-06-29 22:25:42 +020024#include <osmocom/core/timer.h>
Harald Welteba2ad562017-11-28 19:49:41 +010025#include "usb_buf.h"
26
27void board_exec_dbg_cmd(int ch)
28{
Harald Welte7b250bf2017-11-28 22:10:49 +010029 switch (ch) {
30 case '?':
31 printf("\t?\thelp\n\r");
32 printf("\tR\treset SAM3\n\r");
33 break;
34 case 'R':
35 printf("Asking NVIC to reset us\n\r");
36 USBD_Disconnect();
37 NVIC_SystemReset();
38 break;
39 default:
40 printf("Unknown command '%c'\n\r", ch);
41 break;
42 }
Harald Welteba2ad562017-11-28 19:49:41 +010043}
44
45void board_main_top(void)
46{
Harald Welte7b250bf2017-11-28 22:10:49 +010047#ifndef APPLICATION_dfu
48 usb_buf_init();
49
50 /* Initialize checking for card insert/remove events */
51 //card_present_init();
52#endif
Harald Welteba2ad562017-11-28 19:49:41 +010053}
Harald Weltec1e22542017-11-28 22:29:53 +010054
55int board_override_enter_dfu(void)
56{
57 const Pin bl_sw_pin = PIN_BOOTLOADER_SW;
58
59 PIO_Configure(&bl_sw_pin, 1);
60
61 /* Enter DFU bootloader in case the respective button is pressed */
62 if (PIO_Get(&bl_sw_pin) == 0) {
Kévin Redon8210ec32018-06-27 16:25:35 +020063 /* do not print to early since the console is not initialized yet */
64 //printf("BOOTLOADER switch pressed -> Force DFU\n\r");
Harald Weltec1e22542017-11-28 22:29:53 +010065 return 1;
66 } else
67 return 0;
68}