Browse Source

tests: gadget0: efm32hg: add gadget0 test for efm32hg

pull/887/head
Sebastian Holzapfel 7 years ago
committed by Karl Palsson
parent
commit
d79674db09
  1. 44
      tests/gadget-zero/Makefile.efm32hg309-generic
  2. 45
      tests/gadget-zero/delay_efm32.c
  3. 57
      tests/gadget-zero/main-efm32hg309-generic.c
  4. 14
      tests/gadget-zero/openocd.efm32hg309-generic.cfg

44
tests/gadget-zero/Makefile.efm32hg309-generic

@ -0,0 +1,44 @@
##
## 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 = efm32hg309-generic
PROJECT = usb-gadget0-$(BOARD)
BUILD_DIR = bin-$(BOARD)
SHARED_DIR = ../shared
CFILES = main-$(BOARD).c
CFILES += usb-gadget0.c
CFILES += delay_efm32.c
VPATH += $(SHARED_DIR)
INCLUDES += $(patsubst %,-I%, . $(SHARED_DIR))
OPENCM3_DIR=../..
### This section can go to an arch shared rules eventually...
LDSCRIPT = ../../lib/efm32/hg/efm32hg309f64.ld
OPENCM3_LIB = opencm3_efm32hg
OPENCM3_DEFS = -DEFM32HG
FP_FLAGS ?= -mfloat-abi=soft
ARCH_FLAGS = -mthumb -mcpu=cortex-m0plus $(FP_FLAGS)
#OOCD_INTERFACE = stlink-v2-1
#OOCD_TARGET = efm32
OOCD_FILE = openocd.efm32hg309-generic.cfg
include ../rules.mk

45
tests/gadget-zero/delay_efm32.c

@ -0,0 +1,45 @@
/*
* This file is part of the libopencm3 project.
*
* Copyright (C) 2018 Seb Holzapfel <schnommus@gmail.com>
*
* 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 <stdint.h>
#include <libopencm3/efm32/cmu.h>
#include <libopencm3/efm32/timer.h>
#include "delay.h"
extern const uint32_t ahb_frequency;
void delay_setup(void)
{
cmu_periph_clock_enable(CMU_TIMER2);
/* efm32hg doesn't support a nice 1us prescaler */
timer_start(TIMER2);
}
void delay_us(uint16_t us)
{
volatile uint16_t time_now = 0;
/* Convert microseconds into timer ticks */
uint16_t delay_ahb_cycles = us * (ahb_frequency / 1000000);
TIMER2_CNT = 0;
while (time_now < delay_ahb_cycles) {
time_now = TIMER2_CNT;
}
}

57
tests/gadget-zero/main-efm32hg309-generic.c

@ -0,0 +1,57 @@
/*
* This file is part of the libopencm3 project.
*
* Copyright (C) 2015 Karl Palsson <karlp@tweak.net.au>
* Copyright (C) 2018 Seb Holzapfel <schnommus@gmail.com>
*
* 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/common.h>
#include <libopencm3/cm3/vector.h>
#include <libopencm3/cm3/scb.h>
#include <libopencm3/cm3/nvic.h>
#include <stdio.h>
#include "usb-gadget0.h"
/* no trace on cm0 #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
const uint32_t ahb_frequency = 14000000;
#include "trace.h"
void trace_send_blocking8(int stimulus_port, char c)
{
(void)stimulus_port;
(void)c;
}
int main(void)
{
usbd_device *usbd_dev = gadget0_init(&efm32hg_usb_driver,
"efm32hg309-generic");
ER_DPRINTF("bootup complete\n");
while (1) {
gadget0_run(usbd_dev);
}
}

14
tests/gadget-zero/openocd.efm32hg309-generic.cfg

@ -0,0 +1,14 @@
# Generic efm32hg309 on Tomu board, using stm32l053-disco as debugger
source [find interface/stlink-v2-1.cfg]
transport select hla_swd
adapter_khz 1000
set CHIPNAME efm32hg309
set CPUTAPID 0x0bc11477
source [find target/efm32.cfg]
source openocd.common.cfg
optional_local "openocd.efm32hg309-generic.local.cfg"
init
targets
reset halt
Loading…
Cancel
Save