tests: gadget0: Add blackpill-f411ce support
This commit is contained in:
committed by
Piotr Esden-Tempski
parent
2c59c66945
commit
7742f1cfd6
40
tests/gadget-zero/Makefile.stm32f411-generic
Normal file
40
tests/gadget-zero/Makefile.stm32f411-generic
Normal file
@@ -0,0 +1,40 @@
|
||||
##
|
||||
## 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 = stm32f411-generic
|
||||
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=stm32f411ce
|
||||
OOCD_FILE = openocd.$(BOARD).cfg
|
||||
|
||||
include $(OPENCM3_DIR)/mk/genlink-config.mk
|
||||
include $(OPENCM3_DIR)/mk/genlink-rules.mk
|
||||
include ../rules.mk
|
||||
64
tests/gadget-zero/main-stm32f411-generic.c
Normal file
64
tests/gadget-zero/main-stm32f411-generic.c
Normal file
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* This file is part of the libopencm3 project.
|
||||
*
|
||||
* Copyright (C) 2015 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/stm32/gpio.h>
|
||||
#include <libopencm3/stm32/rcc.h>
|
||||
#include <libopencm3/usb/dwc/otg_fs.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)
|
||||
{
|
||||
rcc_clock_setup_pll(&rcc_hse_25mhz_3v3[RCC_CLOCK_3V3_96MHZ]);
|
||||
rcc_periph_clock_enable(RCC_GPIOA);
|
||||
rcc_periph_clock_enable(RCC_OTGFS);
|
||||
|
||||
gpio_mode_setup(GPIOA, GPIO_MODE_AF, GPIO_PUPD_NONE, GPIO11 | GPIO12);
|
||||
gpio_set_af(GPIOA, GPIO_AF10, GPIO11 | GPIO12);
|
||||
|
||||
/* LED to indicate boot process */
|
||||
rcc_periph_clock_enable(RCC_GPIOC);
|
||||
gpio_mode_setup(GPIOC, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO13);
|
||||
gpio_set(GPIOC, GPIO13);
|
||||
|
||||
/* https://github.com/libopencm3/libopencm3/pull/1256#issuecomment-779424001 */
|
||||
OTG_FS_GCCFG |= OTG_GCCFG_NOVBUSSENS | OTG_GCCFG_PWRDWN;
|
||||
OTG_FS_GCCFG &= ~(OTG_GCCFG_VBUSBSEN | OTG_GCCFG_VBUSASEN);
|
||||
|
||||
usbd_device *usbd_dev = gadget0_init(&otgfs_usb_driver, "stm32f411-generic");
|
||||
|
||||
ER_DPRINTF("bootup complete\n");
|
||||
gpio_clear(GPIOC, GPIO13);
|
||||
while (1) {
|
||||
gadget0_run(usbd_dev);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user