Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/thirdpin/libopencm3.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Palsson <karlp@tweak.net.au>2018-08-27 18:04:57 +0300
committerKarl Palsson <karlp@tweak.net.au>2018-08-27 18:11:32 +0300
commit8cf3a20bff1632d8a265cf5654b400aaf5a5b3e2 (patch)
treec36bcd81bdd2c8ce7ba2acd34e93974f0e21e826
parent22754f091941aa5adc0765b50c02d849083d1cd5 (diff)
tests: usb gadget0: add ti lm4f120xl board
This has failing tests, and doesn't implement (yet) the delay routines, so it won't even compile without disabling that functionality in the core gadget0 code. However, it passes most tests, and it demonstrates that the changes made to the setup handling earlier haven't broken USB on this platform.
-rw-r--r--tests/gadget-zero/Makefile.tilm4f120xl42
-rw-r--r--tests/gadget-zero/main-tilm4f120xl.c60
2 files changed, 102 insertions, 0 deletions
diff --git a/tests/gadget-zero/Makefile.tilm4f120xl b/tests/gadget-zero/Makefile.tilm4f120xl
new file mode 100644
index 00000000..d458b338
--- /dev/null
+++ b/tests/gadget-zero/Makefile.tilm4f120xl
@@ -0,0 +1,42 @@
+##
+## This file is part of the libopencm3 project.
+##
+## This library is free software: you can redistribute it and/or modify
+## it under the terms of the GNU Lesser General Public License as published by
+## the Free Software Foundation, either version 3 of the License, or
+## (at your option) any later version.
+##
+## This library 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 Lesser General Public License for more details.
+##
+## You should have received a copy of the GNU Lesser General Public License
+## along with this library. If not, see <http://www.gnu.org/licenses/>.
+##
+
+BOARD = tilm4f120xl
+PROJECT = usb-gadget0-$(BOARD)
+BUILD_DIR = bin-$(BOARD)
+
+SHARED_DIR = ../shared
+
+CFILES = main-$(BOARD).c
+CFILES += usb-gadget0.c trace.c trace_stdio.c
+#CFILES += delay.c
+
+VPATH += $(SHARED_DIR)
+
+INCLUDES += $(patsubst %,-I%, . $(SHARED_DIR))
+
+OPENCM3_DIR=../..
+
+### This section can go to an arch shared rules eventually...
+DEVICE=lm4f120xl
+OOCD_FILE = openocd.$(BOARD).cfg
+
+include $(OPENCM3_DIR)/mk/genlink-config.mk
+#include $(OPENCM3_DIR)/mk/gcc-config.mk
+include $(OPENCM3_DIR)/mk/genlink-rules.mk
+include ../rules.mk
+#include $(OPENCM3_DIR)/mk/gcc-rules.mk
diff --git a/tests/gadget-zero/main-tilm4f120xl.c b/tests/gadget-zero/main-tilm4f120xl.c
new file mode 100644
index 00000000..67abb6ae
--- /dev/null
+++ b/tests/gadget-zero/main-tilm4f120xl.c
@@ -0,0 +1,60 @@
+/*
+ * This file is part of the libopencm3 project.
+ *
+ * Copyright (C) 2018 Karl Palsson <karlp@tweak.net.au>
+ *
+ * This library is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This library 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <libopencm3/cm3/nvic.h>
+#include <libopencm3/lm4f/gpio.h>
+#include <libopencm3/lm4f/rcc.h>
+#include <libopencm3/lm4f/systemcontrol.h>
+
+#include <stdio.h>
+#include "usb-gadget0.h"
+
+#define ER_DEBUG
+#ifdef ER_DEBUG
+#define ER_DPRINTF(fmt, ...) \
+ do { printf(fmt, ## __VA_ARGS__); } while (0)
+#else
+#define ER_DPRINTF(fmt, ...) \
+ do { } while (0)
+#endif
+
+int main(void)
+{
+ gpio_enable_ahb_aperture();
+#define PLL_DIV_80MHZ 5
+ rcc_sysclk_config(OSCSRC_MOSC, XTAL_16M, PLL_DIV_80MHZ);
+ periph_clock_enable(RCC_GPIOD);
+ gpio_mode_setup(GPIOD, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO4 | GPIO5);
+
+ /* blue LED on board */
+ periph_clock_enable(RCC_GPIOF);
+ gpio_mode_setup(GPIOF, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO2);
+ gpio_set_output_config(GPIOF, GPIO_OTYPE_PP, GPIO_DRIVE_2MA, GPIO2);
+
+ usbd_device *usbd_dev = gadget0_init(&lm4f_usb_driver, "tilm4f120xl");
+
+ ER_DPRINTF("bootup complete\n");
+ while (1) {
+ gpio_set(GPIOF, GPIO2);
+ gadget0_run(usbd_dev);
+ gpio_clear(GPIOF, GPIO2);
+ }
+
+}
+