aboutsummaryrefslogtreecommitdiff
path: root/src/platforms/launchpad-icdi/platform.c
diff options
context:
space:
mode:
authorGareth McMullin2015-03-02 10:16:33 -0800
committerGareth McMullin2015-03-02 10:16:33 -0800
commitb07ffffcee53e18051b324eb59a2794044ce6f95 (patch)
treed52ba33369d50f9011f286ad5ee9f0e895841e3e /src/platforms/launchpad-icdi/platform.c
parent4d4813de87721528fc9a06174dd1da5c245ae2f3 (diff)
Factor out common cdcacm.c from stm32 and tm4c.
Cleaned up interface to enter bootloader and read serial number.
Diffstat (limited to 'src/platforms/launchpad-icdi/platform.c')
-rw-r--r--src/platforms/launchpad-icdi/platform.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/platforms/launchpad-icdi/platform.c b/src/platforms/launchpad-icdi/platform.c
index 0e3fb85..e689f0c 100644
--- a/src/platforms/launchpad-icdi/platform.c
+++ b/src/platforms/launchpad-icdi/platform.c
@@ -1,3 +1,19 @@
+/*
+ * This file is part of the Black Magic Debug project.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
#include "general.h"
#include "gdb_if.h"
#include "cdcacm.h"
@@ -7,6 +23,7 @@
#include <libopencm3/lm4f/nvic.h>
#include <libopencm3/lm4f/uart.h>
#include <libopencm3/cm3/systick.h>
+#include <libopencm3/lm4f/usb.h>
#define SYSTICKHZ 100
#define SYSTICKMS (1000 / SYSTICKHZ)
@@ -58,6 +75,13 @@ platform_init(void)
nvic_enable_irq(NVIC_SYSTICK_IRQ);
nvic_enable_irq(NVIC_UART0_IRQ);
+ periph_clock_enable(RCC_GPIOD);
+ __asm__("nop"); __asm__("nop"); __asm__("nop");
+ gpio_mode_setup(GPIOD_BASE, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO4|GPIO5);
+ usb_enable_interrupts(USB_INT_RESET | USB_INT_DISCON |
+ USB_INT_RESUME | USB_INT_SUSPEND,
+ 0xff, 0xff);
+
usbuart_init();
cdcacm_init();
}
@@ -73,3 +97,25 @@ const char *platform_target_voltage(void)
return "not supported";
}
+char *serialno_read(char *s)
+{
+ /* FIXME: Store a unique serial number somewhere and retreive here */
+ uint32_t unique_id = 1;
+ int i;
+
+ /* Fetch serial number from chip's unique ID */
+ for(i = 0; i < 8; i++) {
+ s[7-i] = ((unique_id >> (4*i)) & 0xF) + '0';
+ }
+ for(i = 0; i < 8; i++)
+ if(s[i] > '9')
+ s[i] += 'A' - '9' - 1;
+ s[8] = 0;
+
+ return s;
+}
+
+void platform_request_boot(void)
+{
+}
+