define LED and DFU board specific pins and remove unused definitions

This commit is contained in:
King Kévin 2019-11-18 11:17:55 +01:00
parent bea3ff1f53
commit e70edfb77e
6 changed files with 14 additions and 30 deletions

View File

@ -15,7 +15,7 @@ FIRMWARES = [BOOTLOADER, APPLICATION]
# which development board is used
# supported are: SYSTEM_BOARD, MAPLE_MINI, BLUE_PILL, BLACK_PILL, CORE_BOARD, STLINKV2, BLASTER, BUSVOODOO
BOARD = ENV["BOARD"] || "CORE_BOARD"
BOARD = ENV["BOARD"] || "USB_CABLE_TESTER"
# libopencm3 definitions
LIBOPENCM3_DIR = "libopencm3"
@ -184,7 +184,7 @@ end
# SWD/JTAG adapter used
# supported are : STLINKV2 (ST-Link V2), BMP (Black Magic Probe)
SWD_ADAPTER = ENV["SWD_ADAPTER"] || "BMP"
SWD_ADAPTER = ENV["SWD_ADAPTER"] || "STLINKV2"
# openOCD path to control the adapter
OOCD = ENV["OOCD"] || "openocd"
# openOCD adapted name

View File

@ -41,9 +41,6 @@
/* own libraries */
#include "global.h" // board definitions
#include "print.h" // printing utilities
#if !defined(STLINKV2)
#include "uart.h" // USART utilities
#endif
#include "usb_cdcacm.h" // USB CDC ACM utilities
#include "terminal.h" // handle the terminal interface
#include "menu.h" // menu utilities
@ -54,11 +51,7 @@
/** set to 0 if the RTC is reset when the board is powered on, only indicates the uptime
* set to 1 if VBAT can keep the RTC running when the board is unpowered, indicating the date and time
*/
#if defined(CORE_BOARD)
#define RTC_DATE_TIME 1
#else
#define RTC_DATE_TIME 0
#endif
/** number of RTC ticks per second
* @note use integer divider of oscillator to keep second precision
@ -80,16 +73,10 @@ size_t putc(char c)
static char last_c = 0; // to remember on which character we last sent
if ('\n' == c) { // send carriage return (CR) + line feed (LF) newline for each LF
if ('\r' != last_c) { // CR has not already been sent
#if !defined(STLINKV2)
uart_putchar_nonblocking('\r'); // send CR over USART
#endif
usb_cdcacm_putchar('\r'); // send CR over USB
length++; // remember we printed 1 character
}
}
#if !defined(STLINKV2)
uart_putchar_nonblocking(c); // send byte over USART
#endif
usb_cdcacm_putchar(c); // send byte over USB
length++; // remember we printed 1 character
last_c = c; // remember last character
@ -337,11 +324,8 @@ void main(void)
#endif
board_setup(); // setup board
#if !defined(STLINKV2)
uart_setup(); // setup USART (for printing)
#endif
usb_cdcacm_setup(); // setup USB CDC ACM (for printing)
puts("\nwelcome to the CuVoodoo STM32F1 example application\n"); // print welcome message
printf("\nwelcome to the CuVoodoo USB cable tester\n"); // print welcome message
#if DEBUG
// show reset cause
@ -382,7 +366,6 @@ void main(void)
#endif
// setup RTC
puts("setup internal RTC: ");
#if defined(BLUE_PILL) || defined(STLINKV2) || defined(BLASTER) // for boards without a Low Speed External oscillator
// note: the blue pill LSE oscillator is affected when toggling the onboard LED, thus prefer the HSE
rtc_auto_awake(RCC_HSE, 8000000 / 128 / RTC_TICKS_SECOND - 1); // use High Speed External oscillator (8 MHz / 128) as RTC clock (VBAT can't be used to keep the RTC running)
@ -392,7 +375,6 @@ void main(void)
rtc_interrupt_enable(RTC_SEC); // enable RTC interrupt on "seconds"
nvic_enable_irq(NVIC_RTC_IRQ); // allow the RTC to interrupt
time_start = rtc_get_counter_val(); // get start time from internal RTC
puts("OK\n");
// setup terminal
terminal_prefix = ""; // set default prefix
@ -401,7 +383,6 @@ void main(void)
// start main loop
bool action = false; // if an action has been performed don't go to sleep
button_flag = false; // reset button flag
while (true) { // infinite loop
iwdg_reset(); // kick the dog
if (user_input_available) { // user input is available
@ -410,13 +391,6 @@ void main(void)
char c = user_input_get(); // store receive character
terminal_send(c); // send received character to terminal
}
if (button_flag) { // user pressed button
action = true; // action has been performed
puts("button pressed\n");
led_toggle(); // toggle LED
sleep_ms(100); // wait a bit to remove noise and double trigger
button_flag = false; // reset flag
}
if (rtc_internal_tick_flag) { // the internal RTC ticked
rtc_internal_tick_flag = false; // reset flag
action = true; // action has been performed

View File

@ -75,6 +75,7 @@ void main(void)
dfu_force = true; // DFU mode forced
}
#endif // defined(DFU_FORCE_PIN)
gpio_primary_remap(AFIO_MAPR_SWJ_CFG_FULL_SWJ, 0); // re-enable full SWJ
}
// start application if valid

View File

@ -32,7 +32,6 @@
#include "global.h" // common methods
volatile bool button_flag = false;
volatile bool user_input_available = false;
static volatile uint8_t user_input_buffer[64] = {0}; /**< ring buffer for received data */

View File

@ -679,6 +679,10 @@
#define DFU_FORCE_PIN PC4 /**< GPIO pin (pin PC4) */
#define DFU_FORCE_VALUE 1 /**< pin floating, set high when shorted with nearby VCC */
#endif
#elif defined(USB_CABLE_TESTER)
/* since there is no pin left, we re-use SWDIO */
#define DFU_FORCE_PIN PA13 /**< SWDIO pin (needs to be remapped to become PA13) */
#define DFU_FORCE_VALUE 0 /**< must be low to force DFU mode (note: SWDIO is also pulled up after reset) */
#else
/* use the JNTRST pin as GPIO (SWJ will still be working, minus NTRST) */
#define DFU_FORCE_PIN PB4 /**< JNTRST pin (needs to be remapped to become PB4) */
@ -698,6 +702,7 @@ extern char __application_end;
* @note this symbol will be provided by the linker script
*/
extern char __flash_end;
/** flag set when board user button has been pressed/released */
extern volatile bool button_flag;
/** symbol for the DFU magic word

View File

@ -357,6 +357,11 @@ void usb_dfu_setup(void)
rcc_periph_clock_enable(RCC_GPIOB);
gpio_set_mode(GPIOB, GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO6);
gpio_set(GPIOB, GPIO6);
#elif defined(USB_CABLE_TESTER)
// enable USB D+ pull-up using pMOS
rcc_periph_clock_enable(RCC_GPIOD);
gpio_set_mode(GPIOD, GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_OPENDRAIN, GPIO13);
gpio_clear(GPIOD, GPIO13);
#endif
rcc_periph_clock_enable(RCC_GPIOA); // enable clock for GPIO used for USB
rcc_periph_clock_enable(RCC_USB); // enable clock for USB domain