Kévin Redon | 9a12d68 | 2018-07-08 13:21:16 +0200 | [diff] [blame] | 1 | /* 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 Welte | ba2ad56 | 2017-11-28 19:49:41 +0100 | [diff] [blame] | 20 | #include "board.h" |
| 21 | #include "simtrace.h" |
| 22 | #include "utils.h" |
| 23 | #include "sim_switch.h" |
Harald Welte | 9d90d28 | 2018-06-29 22:25:42 +0200 | [diff] [blame] | 24 | #include <osmocom/core/timer.h> |
Harald Welte | ba2ad56 | 2017-11-28 19:49:41 +0100 | [diff] [blame] | 25 | #include "usb_buf.h" |
| 26 | |
| 27 | void board_exec_dbg_cmd(int ch) |
| 28 | { |
Harald Welte | 7b250bf | 2017-11-28 22:10:49 +0100 | [diff] [blame] | 29 | 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 Welte | ba2ad56 | 2017-11-28 19:49:41 +0100 | [diff] [blame] | 43 | } |
| 44 | |
| 45 | void board_main_top(void) |
| 46 | { |
Harald Welte | 7b250bf | 2017-11-28 22:10:49 +0100 | [diff] [blame] | 47 | #ifndef APPLICATION_dfu |
| 48 | usb_buf_init(); |
| 49 | |
| 50 | /* Initialize checking for card insert/remove events */ |
| 51 | //card_present_init(); |
| 52 | #endif |
Harald Welte | ba2ad56 | 2017-11-28 19:49:41 +0100 | [diff] [blame] | 53 | } |
Harald Welte | c1e2254 | 2017-11-28 22:29:53 +0100 | [diff] [blame] | 54 | |
| 55 | int 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 Redon | 8210ec3 | 2018-06-27 16:25:35 +0200 | [diff] [blame] | 63 | /* do not print to early since the console is not initialized yet */ |
| 64 | //printf("BOOTLOADER switch pressed -> Force DFU\n\r"); |
Harald Welte | c1e2254 | 2017-11-28 22:29:53 +0100 | [diff] [blame] | 65 | return 1; |
| 66 | } else |
| 67 | return 0; |
| 68 | } |