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 . +## + +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 + * + * 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 . + */ + +#include +#include +#include +#include + +#include +#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); + } + +} +