Whitespace cleanup.
This commit is contained in:
parent
60626e5bbe
commit
a5549d630c
|
@ -970,7 +970,7 @@ static int cortexm_hostio_request(target *t)
|
|||
case SYS_OPEN:{ /* open */
|
||||
/* Translate stupid fopen modes to open flags.
|
||||
* See DUI0471C, Table 8-3 */
|
||||
const uint32_t flags[] = {
|
||||
const uint32_t flags[] = {
|
||||
FILEIO_O_RDONLY, /* r, rb */
|
||||
FILEIO_O_RDWR, /* r+, r+b */
|
||||
FILEIO_O_WRONLY | FILEIO_O_CREAT | FILEIO_O_TRUNC,/*w*/
|
||||
|
|
|
@ -217,7 +217,7 @@ gdb_main(void)
|
|||
break;
|
||||
|
||||
case 0x04:
|
||||
case 'D': /* GDB 'detach' command. */
|
||||
case 'D': /* GDB 'detach' command. */
|
||||
if(cur_target)
|
||||
target_detach(cur_target);
|
||||
last_target = cur_target;
|
||||
|
|
|
@ -38,10 +38,10 @@
|
|||
#define INLINE_GPIO
|
||||
#define CDCACM_PACKET_SIZE 64
|
||||
#define PLATFORM_HAS_TRACESWO
|
||||
#define BOARD_IDENT "Black Magic Probe (F4Discovery), (Firmware 1.5" VERSION_SUFFIX ", build " BUILDDATE ")"
|
||||
#define BOARD_IDENT_DFU "Black Magic (Upgrade) for F4Discovery, (Firmware 1.5" VERSION_SUFFIX ", build " BUILDDATE ")"
|
||||
#define DFU_IDENT "Black Magic Firmware Upgrade (F4Discovery"
|
||||
#define DFU_IFACE_STRING "@Internal Flash /0x08000000/1*016Ka,3*016Kg,1*064Kg,7*128Kg"
|
||||
#define BOARD_IDENT "Black Magic Probe (F4Discovery), (Firmware 1.5" VERSION_SUFFIX ", build " BUILDDATE ")"
|
||||
#define BOARD_IDENT_DFU "Black Magic (Upgrade) for F4Discovery, (Firmware 1.5" VERSION_SUFFIX ", build " BUILDDATE ")"
|
||||
#define DFU_IDENT "Black Magic Firmware Upgrade (F4Discovery"
|
||||
#define DFU_IFACE_STRING "@Internal Flash /0x08000000/1*016Ka,3*016Kg,1*064Kg,7*128Kg"
|
||||
|
||||
extern usbd_device *usbdev;
|
||||
#define CDCACM_GDB_ENDPOINT 1
|
||||
|
@ -97,13 +97,16 @@ extern usbd_device *usbdev;
|
|||
#define LED_ERROR GPIO14
|
||||
#define LED_BOOTLOADER GPIO15
|
||||
|
||||
#define TMS_SET_MODE() gpio_mode_setup(TMS_PORT, GPIO_MODE_OUTPUT, \
|
||||
GPIO_PUPD_NONE, TMS_PIN);
|
||||
#define SWDIO_MODE_FLOAT() gpio_mode_setup(SWDIO_PORT, GPIO_MODE_INPUT, \
|
||||
GPIO_PUPD_NONE, SWDIO_PIN);
|
||||
#define TMS_SET_MODE() \
|
||||
gpio_mode_setup(TMS_PORT, GPIO_MODE_OUTPUT, \
|
||||
GPIO_PUPD_NONE, TMS_PIN);
|
||||
#define SWDIO_MODE_FLOAT() \
|
||||
gpio_mode_setup(SWDIO_PORT, GPIO_MODE_INPUT, \
|
||||
GPIO_PUPD_NONE, SWDIO_PIN);
|
||||
|
||||
#define SWDIO_MODE_DRIVE() gpio_mode_setup(SWDIO_PORT, GPIO_MODE_OUTPUT, \
|
||||
GPIO_PUPD_NONE, SWDIO_PIN);
|
||||
#define SWDIO_MODE_DRIVE() \
|
||||
gpio_mode_setup(SWDIO_PORT, GPIO_MODE_OUTPUT, \
|
||||
GPIO_PUPD_NONE, SWDIO_PIN);
|
||||
|
||||
|
||||
#define USB_DRIVER stm32f107_usb_driver
|
||||
|
@ -132,13 +135,13 @@ extern usbd_device *usbdev;
|
|||
#define USBUSART_TIM_IRQ NVIC_TIM4_IRQ
|
||||
#define USBUSART_TIM_ISR tim4_isr
|
||||
|
||||
#define UART_PIN_SETUP() do { \
|
||||
gpio_mode_setup(USBUSART_TX_PORT, GPIO_MODE_AF, GPIO_PUPD_NONE, \
|
||||
USBUSART_TX_PIN); \
|
||||
gpio_mode_setup(USBUSART_RX_PORT, GPIO_MODE_AF, GPIO_PUPD_NONE, \
|
||||
USBUSART_RX_PIN); \
|
||||
gpio_set_af(USBUSART_TX_PORT, GPIO_AF7, USBUSART_TX_PIN); \
|
||||
gpio_set_af(USBUSART_RX_PORT, GPIO_AF7, USBUSART_RX_PIN); \
|
||||
#define UART_PIN_SETUP() do { \
|
||||
gpio_mode_setup(USBUSART_TX_PORT, GPIO_MODE_AF, GPIO_PUPD_NONE, \
|
||||
USBUSART_TX_PIN); \
|
||||
gpio_mode_setup(USBUSART_RX_PORT, GPIO_MODE_AF, GPIO_PUPD_NONE, \
|
||||
USBUSART_RX_PIN); \
|
||||
gpio_set_af(USBUSART_TX_PORT, GPIO_AF7, USBUSART_TX_PIN); \
|
||||
gpio_set_af(USBUSART_RX_PORT, GPIO_AF7, USBUSART_RX_PIN); \
|
||||
} while(0)
|
||||
|
||||
#define TRACE_TIM TIM3
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
void dfu_detach(void)
|
||||
{
|
||||
/* USB device must detach, we just reset... */
|
||||
/* USB device must detach, we just reset... */
|
||||
scb_reset_system();
|
||||
}
|
||||
|
||||
|
@ -40,8 +40,8 @@ int main(void)
|
|||
|
||||
dfu_protect_enable();
|
||||
|
||||
/* Set up clock*/
|
||||
rcc_clock_setup_hse_3v3(&hse_8mhz_3v3[CLOCK_3V3_168MHZ]);
|
||||
/* Set up clock*/
|
||||
rcc_clock_setup_hse_3v3(&hse_8mhz_3v3[CLOCK_3V3_168MHZ]);
|
||||
systick_set_clocksource(STK_CSR_CLKSOURCE_AHB_DIV8);
|
||||
systick_set_reload(2100000);
|
||||
|
||||
|
|
|
@ -60,16 +60,17 @@ int swdptap_init(void)
|
|||
|
||||
void swdptap_reset(void)
|
||||
{
|
||||
swdptap_turnaround(0);
|
||||
/* 50 clocks with TMS high */
|
||||
for(int i = 0; i < 50; i++) swdptap_bit_out(1);
|
||||
swdptap_turnaround(0);
|
||||
/* 50 clocks with TMS high */
|
||||
for(int i = 0; i < 50; i++)
|
||||
swdptap_bit_out(1);
|
||||
}
|
||||
|
||||
static void swdptap_turnaround(uint8_t dir)
|
||||
{
|
||||
static uint8_t olddir = 0;
|
||||
|
||||
//DEBUG("%s", dir ? "\n-> ":"\n<- ");
|
||||
/*DEBUG("%s", dir ? "\n-> ":"\n<- ");*/
|
||||
platform_buffer_flush();
|
||||
|
||||
if(dir == olddir) return;
|
||||
|
|
|
@ -110,14 +110,13 @@ int platform_init(void)
|
|||
: GPIO_CNF_OUTPUT_OPENDRAIN),
|
||||
SRST_PIN);
|
||||
|
||||
/* Enable internal pull-up on PWR_BR so that we don't drive
|
||||
TPWR locally or inadvertently supply power to the target. */
|
||||
if (platform_hwversion () > 0) {
|
||||
gpio_set (PWR_BR_PORT, PWR_BR_PIN);
|
||||
gpio_set_mode(PWR_BR_PORT, GPIO_MODE_INPUT,
|
||||
GPIO_CNF_INPUT_PULL_UPDOWN,
|
||||
PWR_BR_PIN);
|
||||
}
|
||||
/* Enable internal pull-up on PWR_BR so that we don't drive
|
||||
TPWR locally or inadvertently supply power to the target. */
|
||||
if (platform_hwversion () > 0) {
|
||||
gpio_set (PWR_BR_PORT, PWR_BR_PIN);
|
||||
gpio_set_mode(PWR_BR_PORT, GPIO_MODE_INPUT,
|
||||
GPIO_CNF_INPUT_PULL_UPDOWN, PWR_BR_PIN);
|
||||
}
|
||||
|
||||
/* Setup heartbeat timer */
|
||||
systick_set_clocksource(STK_CSR_CLKSOURCE_AHB_DIV8);
|
||||
|
@ -134,15 +133,16 @@ int platform_init(void)
|
|||
gpio_set_mode(GPIOB, GPIO_MODE_INPUT,
|
||||
GPIO_CNF_INPUT_PULL_UPDOWN, GPIO0);
|
||||
}
|
||||
|
||||
SCB_VTOR = 0x2000; // Relocate interrupt vector table here
|
||||
/* Relocate interrupt vector table here */
|
||||
SCB_VTOR = 0x2000;
|
||||
|
||||
cdcacm_init();
|
||||
usbuart_init();
|
||||
|
||||
// Set recovery point
|
||||
/* Set recovery point */
|
||||
if (setjmp(fatal_error_jmpbuf)) {
|
||||
return 0; // Do nothing on failure
|
||||
/* Do nothing on failure */
|
||||
return 0;
|
||||
}
|
||||
|
||||
jtag_scan(NULL);
|
||||
|
@ -162,7 +162,7 @@ bool platform_target_get_power(void) {
|
|||
if (platform_hwversion() > 0) {
|
||||
return gpio_get(PWR_BR_PORT, PWR_BR_PIN);
|
||||
}
|
||||
return 1; // 1 = Unpowered
|
||||
return 1; /* 1 = Unpowered */
|
||||
}
|
||||
void platform_target_set_power(bool power)
|
||||
{
|
||||
|
|
|
@ -41,11 +41,11 @@
|
|||
#define PLATFORM_HAS_TRACESWO
|
||||
#define PLATFORM_HAS_POWER_SWITCH
|
||||
#define BOARD_IDENT "Black Magic Probe"
|
||||
#define BOARD_IDENT_DFU "Black Magic Probe (Upgrade)"
|
||||
#define BOARD_IDENT_UPD "Black Magic Probe (DFU Upgrade)"
|
||||
#define BOARD_IDENT_DFU "Black Magic Probe (Upgrade)"
|
||||
#define BOARD_IDENT_UPD "Black Magic Probe (DFU Upgrade)"
|
||||
#define DFU_IDENT "Black Magic Firmware Upgrade"
|
||||
#define DFU_IFACE_STRING "@Internal Flash /0x08000000/8*001Ka,120*001Kg"
|
||||
#define UPD_IFACE_STRING "@Internal Flash /0x08000000/8*001Kg"
|
||||
#define DFU_IFACE_STRING "@Internal Flash /0x08000000/8*001Ka,120*001Kg"
|
||||
#define UPD_IFACE_STRING "@Internal Flash /0x08000000/8*001Kg"
|
||||
|
||||
extern usbd_device *usbdev;
|
||||
#define CDCACM_GDB_ENDPOINT 1
|
||||
|
@ -109,35 +109,35 @@ extern usbd_device *usbdev;
|
|||
#define LED_IDLE_RUN GPIO10
|
||||
#define LED_ERROR GPIO11
|
||||
|
||||
#define TMS_SET_MODE() \
|
||||
gpio_set_mode(TMS_PORT, GPIO_MODE_OUTPUT_50_MHZ, \
|
||||
GPIO_CNF_OUTPUT_PUSHPULL, TMS_PIN);
|
||||
#define SWDIO_MODE_FLOAT() \
|
||||
gpio_set_mode(SWDIO_PORT, GPIO_MODE_INPUT, \
|
||||
GPIO_CNF_INPUT_FLOAT, SWDIO_PIN);
|
||||
#define SWDIO_MODE_DRIVE() \
|
||||
gpio_set_mode(SWDIO_PORT, GPIO_MODE_OUTPUT_50_MHZ, \
|
||||
GPIO_CNF_OUTPUT_PUSHPULL, SWDIO_PIN);
|
||||
#define TMS_SET_MODE() \
|
||||
gpio_set_mode(TMS_PORT, GPIO_MODE_OUTPUT_50_MHZ, \
|
||||
GPIO_CNF_OUTPUT_PUSHPULL, TMS_PIN);
|
||||
#define SWDIO_MODE_FLOAT() \
|
||||
gpio_set_mode(SWDIO_PORT, GPIO_MODE_INPUT, \
|
||||
GPIO_CNF_INPUT_FLOAT, SWDIO_PIN);
|
||||
#define SWDIO_MODE_DRIVE() \
|
||||
gpio_set_mode(SWDIO_PORT, GPIO_MODE_OUTPUT_50_MHZ, \
|
||||
GPIO_CNF_OUTPUT_PUSHPULL, SWDIO_PIN);
|
||||
|
||||
#define UART_PIN_SETUP() \
|
||||
gpio_set_mode(USBUSART_PORT, GPIO_MODE_OUTPUT_2_MHZ, \
|
||||
GPIO_CNF_OUTPUT_ALTFN_PUSHPULL, USBUSART_TX_PIN);
|
||||
#define UART_PIN_SETUP() \
|
||||
gpio_set_mode(USBUSART_PORT, GPIO_MODE_OUTPUT_2_MHZ, \
|
||||
GPIO_CNF_OUTPUT_ALTFN_PUSHPULL, USBUSART_TX_PIN);
|
||||
|
||||
#define SRST_SET_VAL(x) \
|
||||
platform_srst_set_val(x)
|
||||
#define SRST_SET_VAL(x) \
|
||||
platform_srst_set_val(x)
|
||||
|
||||
#define USB_DRIVER stm32f103_usb_driver
|
||||
#define USB_IRQ NVIC_USB_LP_CAN_RX0_IRQ
|
||||
#define USB_ISR usb_lp_can_rx0_isr
|
||||
#define USB_DRIVER stm32f103_usb_driver
|
||||
#define USB_IRQ NVIC_USB_LP_CAN_RX0_IRQ
|
||||
#define USB_ISR usb_lp_can_rx0_isr
|
||||
/* Interrupt priorities. Low numbers are high priority.
|
||||
* For now USART1 preempts USB which may spin while buffer is drained.
|
||||
* TIM3 is used for traceswo capture and must be highest priority.
|
||||
*/
|
||||
#define IRQ_PRI_USB (2 << 4)
|
||||
#define IRQ_PRI_USBUSART (1 << 4)
|
||||
#define IRQ_PRI_USBUSART_TIM (3 << 4)
|
||||
#define IRQ_PRI_USB_VBUS (14 << 4)
|
||||
#define IRQ_PRI_TRACE (0 << 4)
|
||||
#define IRQ_PRI_USB (2 << 4)
|
||||
#define IRQ_PRI_USBUSART (1 << 4)
|
||||
#define IRQ_PRI_USBUSART_TIM (3 << 4)
|
||||
#define IRQ_PRI_USB_VBUS (14 << 4)
|
||||
#define IRQ_PRI_TRACE (0 << 4)
|
||||
|
||||
#define USBUSART USART1
|
||||
#define USBUSART_CR1 USART1_CR1
|
||||
|
|
|
@ -29,7 +29,7 @@ uint32_t app_address = 0x08002000;
|
|||
|
||||
void dfu_detach(void)
|
||||
{
|
||||
/* USB device must detach, we just reset... */
|
||||
/* USB device must detach, we just reset... */
|
||||
scb_reset_system();
|
||||
}
|
||||
|
||||
|
|
|
@ -81,17 +81,17 @@ int main(void)
|
|||
|
||||
rcc_clock_setup_in_hse_8mhz_out_72mhz();
|
||||
|
||||
stlink_set_rev();
|
||||
stlink_set_rev();
|
||||
|
||||
systick_set_clocksource(STK_CSR_CLKSOURCE_AHB_DIV8);
|
||||
systick_set_reload(900000);
|
||||
|
||||
dfu_protect(UPD_MODE);
|
||||
dfu_protect(UPD_MODE);
|
||||
|
||||
/* Handle USB disconnect/connect */
|
||||
/* Handle USB disconnect/connect */
|
||||
/* Just in case: Disconnect USB cable by resetting USB Device
|
||||
* and pulling USB_DP low
|
||||
* Device will reconnect automatically as Pull-Up is hard wired*/
|
||||
* and pulling USB_DP low
|
||||
* Device will reconnect automatically as Pull-Up is hard wired*/
|
||||
rcc_periph_reset_pulse(RST_USB);
|
||||
rcc_periph_clock_enable(RCC_USB);
|
||||
rcc_periph_clock_enable(RCC_GPIOA);
|
||||
|
|
|
@ -49,22 +49,21 @@ uint16_t led_idle_run;
|
|||
int platform_hwversion(void)
|
||||
{
|
||||
static int hwversion = -1;
|
||||
int i;
|
||||
int i;
|
||||
if (hwversion == -1) {
|
||||
gpio_set_mode(GPIOC, GPIO_MODE_INPUT,
|
||||
GPIO_CNF_INPUT_PULL_UPDOWN,
|
||||
GPIO14 | GPIO13);
|
||||
GPIO_CNF_INPUT_PULL_UPDOWN, GPIO14 | GPIO13);
|
||||
gpio_set(GPIOC, GPIO14 | GPIO13);
|
||||
for (i = 0; i<10; i++)
|
||||
hwversion = ~(gpio_get(GPIOC, GPIO14 | GPIO13) >> 13) & 3;
|
||||
switch (hwversion)
|
||||
{
|
||||
case 0:
|
||||
led_idle_run = GPIO8;
|
||||
break;
|
||||
default:
|
||||
led_idle_run = GPIO9;
|
||||
}
|
||||
for (i = 0; i<10; i++)
|
||||
hwversion = ~(gpio_get(GPIOC, GPIO14 | GPIO13) >> 13) & 3;
|
||||
switch (hwversion)
|
||||
{
|
||||
case 0:
|
||||
led_idle_run = GPIO8;
|
||||
break;
|
||||
default:
|
||||
led_idle_run = GPIO9;
|
||||
}
|
||||
}
|
||||
return hwversion;
|
||||
}
|
||||
|
@ -82,30 +81,30 @@ int platform_init(void)
|
|||
rcc_periph_clock_enable(RCC_CRC);
|
||||
|
||||
/* On Rev 1 unconditionally activate MCO on PORTA8 with HSE
|
||||
* platform_hwversion() also needed to initialize led_idle_run!
|
||||
*/
|
||||
if (platform_hwversion() == 1)
|
||||
{
|
||||
RCC_CFGR &= ~( 0xf<< 24);
|
||||
RCC_CFGR |= (RCC_CFGR_MCO_HSECLK << 24);
|
||||
gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_50_MHZ,
|
||||
GPIO_CNF_OUTPUT_ALTFN_PUSHPULL, GPIO8);
|
||||
}
|
||||
* platform_hwversion() also needed to initialize led_idle_run!
|
||||
*/
|
||||
if (platform_hwversion() == 1)
|
||||
{
|
||||
RCC_CFGR &= ~(0xf << 24);
|
||||
RCC_CFGR |= (RCC_CFGR_MCO_HSECLK << 24);
|
||||
gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_50_MHZ,
|
||||
GPIO_CNF_OUTPUT_ALTFN_PUSHPULL, GPIO8);
|
||||
}
|
||||
/* Setup GPIO ports */
|
||||
gpio_set_mode(TMS_PORT, GPIO_MODE_OUTPUT_50_MHZ,
|
||||
GPIO_CNF_OUTPUT_PUSHPULL, TMS_PIN);
|
||||
GPIO_CNF_OUTPUT_PUSHPULL, TMS_PIN);
|
||||
gpio_set_mode(TCK_PORT, GPIO_MODE_OUTPUT_50_MHZ,
|
||||
GPIO_CNF_OUTPUT_PUSHPULL, TCK_PIN);
|
||||
GPIO_CNF_OUTPUT_PUSHPULL, TCK_PIN);
|
||||
gpio_set_mode(TDI_PORT, GPIO_MODE_OUTPUT_50_MHZ,
|
||||
GPIO_CNF_OUTPUT_PUSHPULL, TDI_PIN);
|
||||
GPIO_CNF_OUTPUT_PUSHPULL, TDI_PIN);
|
||||
uint16_t srst_pin = platform_hwversion() == 0 ?
|
||||
SRST_PIN_V1 : SRST_PIN_V2;
|
||||
SRST_PIN_V1 : SRST_PIN_V2;
|
||||
gpio_set(SRST_PORT, srst_pin);
|
||||
gpio_set_mode(SRST_PORT, GPIO_MODE_OUTPUT_50_MHZ,
|
||||
GPIO_CNF_OUTPUT_OPENDRAIN, srst_pin);
|
||||
GPIO_CNF_OUTPUT_OPENDRAIN, srst_pin);
|
||||
|
||||
gpio_set_mode(LED_PORT, GPIO_MODE_OUTPUT_2_MHZ,
|
||||
GPIO_CNF_OUTPUT_PUSHPULL, led_idle_run);
|
||||
GPIO_CNF_OUTPUT_PUSHPULL, led_idle_run);
|
||||
|
||||
/* Setup heartbeat timer */
|
||||
systick_set_clocksource(STK_CSR_CLKSOURCE_AHB_DIV8);
|
||||
|
@ -117,13 +116,14 @@ int platform_init(void)
|
|||
|
||||
usbuart_init();
|
||||
|
||||
SCB_VTOR = 0x2000; // Relocate interrupt vector table here
|
||||
SCB_VTOR = 0x2000; /* Relocate interrupt vector table here */
|
||||
|
||||
cdcacm_init();
|
||||
|
||||
// Set recovery point
|
||||
/* Set recovery point */
|
||||
if (setjmp(fatal_error_jmpbuf)) {
|
||||
return 0; // Do nothing on failure
|
||||
/* Do nothing on failure */
|
||||
return 0;
|
||||
}
|
||||
|
||||
jtag_scan(NULL);
|
||||
|
@ -134,7 +134,7 @@ int platform_init(void)
|
|||
void platform_delay(uint32_t delay)
|
||||
{
|
||||
timeout_counter = delay;
|
||||
while(timeout_counter);
|
||||
while (timeout_counter);
|
||||
}
|
||||
|
||||
void platform_srst_set_val(bool assert)
|
||||
|
@ -177,7 +177,7 @@ void disconnect_usb(void)
|
|||
rcc_periph_clock_enable(RCC_GPIOA);
|
||||
gpio_clear(GPIOA, GPIO12);
|
||||
gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_2_MHZ,
|
||||
GPIO_CNF_OUTPUT_OPENDRAIN, GPIO12);
|
||||
GPIO_CNF_OUTPUT_OPENDRAIN, GPIO12);
|
||||
}
|
||||
|
||||
void assert_boot_pin(void)
|
||||
|
@ -192,4 +192,8 @@ void assert_boot_pin(void)
|
|||
crl |= 0x80;
|
||||
GPIOA_CRL = crl;
|
||||
}
|
||||
void setup_vbus_irq(void){};
|
||||
|
||||
void setup_vbus_irq(void)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -38,12 +38,12 @@
|
|||
|
||||
#define INLINE_GPIO
|
||||
#define CDCACM_PACKET_SIZE 64
|
||||
#define BOARD_IDENT "Black Magic Probe (STLINK), (Firmware 1.5" VERSION_SUFFIX ", build " BUILDDATE ")"
|
||||
#define BOARD_IDENT_DFU "Black Magic (Upgrade) for STLink/Discovery, (Firmware 1.5" VERSION_SUFFIX ", build " BUILDDATE ")"
|
||||
#define BOARD_IDENT_UPD "Black Magic (DFU Upgrade) for STLink/Discovery, (Firmware 1.5" VERSION_SUFFIX ", build " BUILDDATE ")"
|
||||
#define DFU_IDENT "Black Magic Firmware Upgrade (STLINK)"
|
||||
#define DFU_IFACE_STRING "@Internal Flash /0x08000000/8*001Ka,56*001Kg"
|
||||
#define UPD_IFACE_STRING "@Internal Flash /0x08000000/8*001Kg"
|
||||
#define BOARD_IDENT "Black Magic Probe (STLINK), (Firmware 1.5" VERSION_SUFFIX ", build " BUILDDATE ")"
|
||||
#define BOARD_IDENT_DFU "Black Magic (Upgrade) for STLink/Discovery, (Firmware 1.5" VERSION_SUFFIX ", build " BUILDDATE ")"
|
||||
#define BOARD_IDENT_UPD "Black Magic (DFU Upgrade) for STLink/Discovery, (Firmware 1.5" VERSION_SUFFIX ", build " BUILDDATE ")"
|
||||
#define DFU_IDENT "Black Magic Firmware Upgrade (STLINK)"
|
||||
#define DFU_IFACE_STRING "@Internal Flash /0x08000000/8*001Ka,56*001Kg"
|
||||
#define UPD_IFACE_STRING "@Internal Flash /0x08000000/8*001Kg"
|
||||
|
||||
extern usbd_device *usbdev;
|
||||
#define CDCACM_GDB_ENDPOINT 1
|
||||
|
@ -94,26 +94,26 @@ extern usbd_device *usbdev;
|
|||
#define LED_PORT_UART GPIOC
|
||||
#define LED_UART GPIO14
|
||||
|
||||
#define TMS_SET_MODE() \
|
||||
gpio_set_mode(TMS_PORT, GPIO_MODE_OUTPUT_50_MHZ, \
|
||||
GPIO_CNF_OUTPUT_PUSHPULL, TMS_PIN);
|
||||
#define SWDIO_MODE_FLOAT() \
|
||||
gpio_set_mode(SWDIO_PORT, GPIO_MODE_INPUT, \
|
||||
GPIO_CNF_INPUT_FLOAT, SWDIO_PIN);
|
||||
#define SWDIO_MODE_DRIVE() \
|
||||
gpio_set_mode(SWDIO_PORT, GPIO_MODE_OUTPUT_50_MHZ, \
|
||||
GPIO_CNF_OUTPUT_PUSHPULL, SWDIO_PIN);
|
||||
#define TMS_SET_MODE() \
|
||||
gpio_set_mode(TMS_PORT, GPIO_MODE_OUTPUT_50_MHZ, \
|
||||
GPIO_CNF_OUTPUT_PUSHPULL, TMS_PIN);
|
||||
#define SWDIO_MODE_FLOAT() \
|
||||
gpio_set_mode(SWDIO_PORT, GPIO_MODE_INPUT, \
|
||||
GPIO_CNF_INPUT_FLOAT, SWDIO_PIN);
|
||||
#define SWDIO_MODE_DRIVE() \
|
||||
gpio_set_mode(SWDIO_PORT, GPIO_MODE_OUTPUT_50_MHZ, \
|
||||
GPIO_CNF_OUTPUT_PUSHPULL, SWDIO_PIN);
|
||||
|
||||
#define UART_PIN_SETUP() \
|
||||
gpio_set_mode(USBUSART_PORT, GPIO_MODE_OUTPUT_2_MHZ, \
|
||||
GPIO_CNF_OUTPUT_ALTFN_PUSHPULL, USBUSART_TX_PIN);
|
||||
#define UART_PIN_SETUP() \
|
||||
gpio_set_mode(USBUSART_PORT, GPIO_MODE_OUTPUT_2_MHZ, \
|
||||
GPIO_CNF_OUTPUT_ALTFN_PUSHPULL, USBUSART_TX_PIN);
|
||||
|
||||
#define SRST_SET_VAL(x) \
|
||||
platform_srst_set_val(x)
|
||||
#define SRST_SET_VAL(x) \
|
||||
platform_srst_set_val(x)
|
||||
|
||||
#define USB_DRIVER stm32f103_usb_driver
|
||||
#define USB_IRQ NVIC_USB_LP_CAN_RX0_IRQ
|
||||
#define USB_ISR usb_lp_can_rx0_isr
|
||||
#define USB_IRQ NVIC_USB_LP_CAN_RX0_IRQ
|
||||
#define USB_ISR usb_lp_can_rx0_isr
|
||||
/* Interrupt priorities. Low numbers are high priority.
|
||||
* For now USART2 preempts USB which may spin while buffer is drained.
|
||||
* TIM3 is used for traceswo capture and must be highest priority.
|
||||
|
@ -209,3 +209,4 @@ static inline uint16_t _gpio_get(uint32_t gpioport, uint16_t gpios)
|
|||
|
||||
void disconnect_usb(void);
|
||||
void assert_boot_pin(void);
|
||||
|
||||
|
|
|
@ -106,10 +106,10 @@ int main(void)
|
|||
systick_set_clocksource(STK_CSR_CLKSOURCE_AHB_DIV8);
|
||||
systick_set_reload(900000);
|
||||
|
||||
/* Handle USB disconnect/connect */
|
||||
/* Handle USB disconnect/connect */
|
||||
/* Just in case: Disconnect USB cable by resetting USB Device
|
||||
* and pulling USB_DP low
|
||||
* Device will reconnect automatically as Pull-Up is hard wired*/
|
||||
* and pulling USB_DP low
|
||||
* Device will reconnect automatically as Pull-Up is hard wired*/
|
||||
rcc_periph_reset_pulse(RST_USB);
|
||||
rcc_periph_clock_enable(RCC_USB);
|
||||
rcc_periph_clock_enable(RCC_GPIOA);
|
||||
|
|
|
@ -51,20 +51,20 @@ static int cdcacm_gdb_dtr = 1;
|
|||
|
||||
|
||||
static const struct usb_device_descriptor dev = {
|
||||
.bLength = USB_DT_DEVICE_SIZE,
|
||||
.bDescriptorType = USB_DT_DEVICE,
|
||||
.bcdUSB = 0x0200,
|
||||
.bDeviceClass = 0xEF, /* Miscellaneous Device */
|
||||
.bDeviceSubClass = 2, /* Common Class */
|
||||
.bDeviceProtocol = 1, /* Interface Association */
|
||||
.bMaxPacketSize0 = 64,
|
||||
.idVendor = 0x1D50,
|
||||
.idProduct = 0x6018,
|
||||
.bcdDevice = 0x0100,
|
||||
.iManufacturer = 1,
|
||||
.iProduct = 2,
|
||||
.iSerialNumber = 3,
|
||||
.bNumConfigurations = 1,
|
||||
.bLength = USB_DT_DEVICE_SIZE,
|
||||
.bDescriptorType = USB_DT_DEVICE,
|
||||
.bcdUSB = 0x0200,
|
||||
.bDeviceClass = 0xEF, /* Miscellaneous Device */
|
||||
.bDeviceSubClass = 2, /* Common Class */
|
||||
.bDeviceProtocol = 1, /* Interface Association */
|
||||
.bMaxPacketSize0 = 64,
|
||||
.idVendor = 0x1D50,
|
||||
.idProduct = 0x6018,
|
||||
.bcdDevice = 0x0100,
|
||||
.iManufacturer = 1,
|
||||
.iProduct = 2,
|
||||
.iSerialNumber = 3,
|
||||
.bNumConfigurations = 1,
|
||||
};
|
||||
|
||||
/* This notification endpoint isn't implemented. According to CDC spec its
|
||||
|
@ -412,7 +412,7 @@ static void dfu_detach_complete(usbd_device *dev, struct usb_setup_data *req)
|
|||
disconnect_usb();
|
||||
|
||||
/* Assert boot-request pin */
|
||||
assert_boot_pin();
|
||||
assert_boot_pin();
|
||||
|
||||
/* Reset core to enter bootloader */
|
||||
scb_reset_core();
|
||||
|
@ -555,22 +555,22 @@ void USB_ISR(void)
|
|||
static char *get_dev_unique_id(char *s)
|
||||
{
|
||||
#if defined(STM32F4)
|
||||
volatile uint32_t *unique_id_p = (volatile uint32_t *)0x1FFF7A10;
|
||||
volatile uint32_t *unique_id_p = (volatile uint32_t *)0x1FFF7A10;
|
||||
#else
|
||||
volatile uint32_t *unique_id_p = (volatile uint32_t *)0x1FFFF7E8;
|
||||
volatile uint32_t *unique_id_p = (volatile uint32_t *)0x1FFFF7E8;
|
||||
#endif
|
||||
uint32_t unique_id = *unique_id_p +
|
||||
*(unique_id_p + 1) +
|
||||
*(unique_id_p + 2);
|
||||
int i;
|
||||
int i;
|
||||
|
||||
/* Fetch serial number from chip's unique ID */
|
||||
for(i = 0; i < 8; i++) {
|
||||
s[7-i] = ((unique_id >> (4*i)) & 0xF) + '0';
|
||||
}
|
||||
for(i = 0; i < 8; i++)
|
||||
if(s[i] > '9')
|
||||
s[i] += 'A' - '9' - 1;
|
||||
/* Fetch serial number from chip's unique ID */
|
||||
for(i = 0; i < 8; i++) {
|
||||
s[7-i] = ((unique_id >> (4*i)) & 0xF) + '0';
|
||||
}
|
||||
for(i = 0; i < 8; i++)
|
||||
if(s[i] > '9')
|
||||
s[i] += 'A' - '9' - 1;
|
||||
s[8] = 0;
|
||||
|
||||
return s;
|
||||
|
|
|
@ -28,13 +28,17 @@
|
|||
|
||||
#include "usbdfu.h"
|
||||
|
||||
static uint32_t sector_addr[] = {0x8000000, 0x8004000, 0x8008000, 0x800c000,
|
||||
0x8010000, 0x8020000, 0x8040000, 0x8060000,
|
||||
0x8080000, 0x80a0000, 0x80c0000, 0x80e0000,
|
||||
0x8100000, 0};
|
||||
static uint16_t sector_erase_time[12]= {500, 500, 500, 500,
|
||||
1100,
|
||||
2600, 2600, 2600, 2600, 2600, 2600, 2600};
|
||||
static uint32_t sector_addr[] = {
|
||||
0x8000000, 0x8004000, 0x8008000, 0x800c000,
|
||||
0x8010000, 0x8020000, 0x8040000, 0x8060000,
|
||||
0x8080000, 0x80a0000, 0x80c0000, 0x80e0000,
|
||||
0x8100000, 0
|
||||
};
|
||||
static uint16_t sector_erase_time[12]= {
|
||||
500, 500, 500, 500,
|
||||
1100, 2600, 2600, 2600,
|
||||
2600, 2600, 2600, 2600
|
||||
};
|
||||
static uint8_t sector_num = 0xff;
|
||||
|
||||
/* Find the sector number for a given address*/
|
||||
|
@ -45,7 +49,7 @@ static void get_sector_num(uint32_t addr)
|
|||
if (addr < sector_addr[i+1])
|
||||
break;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
if (!sector_addr[i])
|
||||
return;
|
||||
sector_num = i;
|
||||
|
@ -61,9 +65,8 @@ void dfu_check_and_do_sector_erase(uint32_t addr)
|
|||
void dfu_flash_program_buffer(uint32_t baseaddr, void *buf, int len)
|
||||
{
|
||||
for(int i = 0; i < len; i += 4)
|
||||
flash_program_word(baseaddr + i,
|
||||
*(uint32_t*)(buf+i),
|
||||
FLASH_PROGRAM_X32);
|
||||
flash_program_word(baseaddr + i, *(uint32_t*)(buf+i),
|
||||
FLASH_PROGRAM_X32);
|
||||
}
|
||||
|
||||
uint32_t dfu_poll_timeout(uint8_t cmd, uint32_t addr, uint16_t blocknum)
|
||||
|
@ -100,7 +103,7 @@ void dfu_jump_app_if_valid(void)
|
|||
SCB_VTOR = APP_ADDRESS & 0x1FFFFF; /* Max 2 MByte Flash*/
|
||||
/* Initialise master stack pointer */
|
||||
asm volatile ("msr msp, %0"::"g"
|
||||
(*(volatile uint32_t*)APP_ADDRESS));
|
||||
(*(volatile uint32_t*)APP_ADDRESS));
|
||||
/* Jump to application */
|
||||
(*(void(**)())(APP_ADDRESS + 4))();
|
||||
}
|
||||
|
|
|
@ -50,20 +50,20 @@ static struct {
|
|||
} prog;
|
||||
|
||||
const struct usb_device_descriptor dev = {
|
||||
.bLength = USB_DT_DEVICE_SIZE,
|
||||
.bDescriptorType = USB_DT_DEVICE,
|
||||
.bcdUSB = 0x0200,
|
||||
.bDeviceClass = 0,
|
||||
.bDeviceSubClass = 0,
|
||||
.bDeviceProtocol = 0,
|
||||
.bMaxPacketSize0 = 64,
|
||||
.idVendor = 0x1D50,
|
||||
.idProduct = 0x6017,
|
||||
.bcdDevice = 0x0100,
|
||||
.iManufacturer = 1,
|
||||
.iProduct = 2,
|
||||
.iSerialNumber = 3,
|
||||
.bNumConfigurations = 1,
|
||||
.bLength = USB_DT_DEVICE_SIZE,
|
||||
.bDescriptorType = USB_DT_DEVICE,
|
||||
.bcdUSB = 0x0200,
|
||||
.bDeviceClass = 0,
|
||||
.bDeviceSubClass = 0,
|
||||
.bDeviceProtocol = 0,
|
||||
.bMaxPacketSize0 = 64,
|
||||
.idVendor = 0x1D50,
|
||||
.idProduct = 0x6017,
|
||||
.bcdDevice = 0x0100,
|
||||
.iManufacturer = 1,
|
||||
.iProduct = 2,
|
||||
.iSerialNumber = 3,
|
||||
.bNumConfigurations = 1,
|
||||
};
|
||||
|
||||
const struct usb_dfu_descriptor dfu_function = {
|
||||
|
@ -166,8 +166,7 @@ usbdfu_getstatus_complete(usbd_device *dev, struct usb_setup_data *req)
|
|||
flash_unlock();
|
||||
if(prog.blocknum == 0) {
|
||||
uint32_t addr = get_le32(prog.buf + 1);
|
||||
if (addr < app_address ||
|
||||
(addr >= max_address)) {
|
||||
if ((addr < app_address) || (addr >= max_address)) {
|
||||
flash_lock();
|
||||
usbd_ep_stall_set(dev, 0, 1);
|
||||
return;
|
||||
|
@ -282,34 +281,34 @@ void dfu_main(void)
|
|||
static char *get_dev_unique_id(char *s)
|
||||
{
|
||||
#if defined(STM32F4) || defined(STM32F2)
|
||||
#define UNIQUE_SERIAL_R 0x1FFF7A10
|
||||
#define FLASH_SIZE_R 0x1fff7A22
|
||||
# define UNIQUE_SERIAL_R 0x1FFF7A10
|
||||
# define FLASH_SIZE_R 0x1fff7A22
|
||||
#elif defined(STM32F3)
|
||||
#define UNIQUE_SERIAL_R 0x1FFFF7AC
|
||||
#define FLASH_SIZE_R 0x1fff77cc
|
||||
# define UNIQUE_SERIAL_R 0x1FFFF7AC
|
||||
# define FLASH_SIZE_R 0x1fff77cc
|
||||
#elif defined(STM32L1)
|
||||
#define UNIQUE_SERIAL_R 0x1ff80050
|
||||
#define FLASH_SIZE_R 0x1FF8004C
|
||||
# define UNIQUE_SERIAL_R 0x1ff80050
|
||||
# define FLASH_SIZE_R 0x1FF8004C
|
||||
#else
|
||||
#define UNIQUE_SERIAL_R 0x1FFFF7E8;
|
||||
#define FLASH_SIZE_R 0x1ffff7e0
|
||||
# define UNIQUE_SERIAL_R 0x1FFFF7E8;
|
||||
# define FLASH_SIZE_R 0x1ffff7e0
|
||||
#endif
|
||||
volatile uint32_t *unique_id_p = (volatile uint32_t *)UNIQUE_SERIAL_R;
|
||||
volatile uint32_t *unique_id_p = (volatile uint32_t *)UNIQUE_SERIAL_R;
|
||||
uint32_t unique_id = *unique_id_p +
|
||||
*(unique_id_p + 1) +
|
||||
*(unique_id_p + 2);
|
||||
int i;
|
||||
int i;
|
||||
|
||||
/* Calculated the upper flash limit from the exported data
|
||||
in theparameter block*/
|
||||
max_address = (*(uint32_t *) FLASH_SIZE_R) <<10;
|
||||
/* Fetch serial number from chip's unique ID */
|
||||
for(i = 0; i < 8; i++) {
|
||||
s[7-i] = ((unique_id >> (4*i)) & 0xF) + '0';
|
||||
}
|
||||
for(i = 0; i < 8; i++)
|
||||
if(s[i] > '9')
|
||||
s[i] += 'A' - '9' - 1;
|
||||
/* Calculated the upper flash limit from the exported data
|
||||
in theparameter block*/
|
||||
max_address = (*(uint32_t *) FLASH_SIZE_R) <<10;
|
||||
/* Fetch serial number from chip's unique ID */
|
||||
for(i = 0; i < 8; i++) {
|
||||
s[7-i] = ((unique_id >> (4*i)) & 0xF) + '0';
|
||||
}
|
||||
for(i = 0; i < 8; i++)
|
||||
if(s[i] > '9')
|
||||
s[i] += 'A' - '9' - 1;
|
||||
s[8] = 0;
|
||||
|
||||
return s;
|
||||
|
|
|
@ -67,8 +67,8 @@ void gdb_usb_out_cb(usbd_device *dev, uint8_t ep)
|
|||
{
|
||||
(void)ep;
|
||||
usbd_ep_nak_set(dev, CDCACM_GDB_ENDPOINT, 1);
|
||||
count_new = usbd_ep_read_packet(dev, CDCACM_GDB_ENDPOINT,
|
||||
double_buffer_out, CDCACM_PACKET_SIZE);
|
||||
count_new = usbd_ep_read_packet(dev, CDCACM_GDB_ENDPOINT,
|
||||
double_buffer_out, CDCACM_PACKET_SIZE);
|
||||
if(!count_new) {
|
||||
usbd_ep_nak_set(dev, CDCACM_GDB_ENDPOINT, 0);
|
||||
}
|
||||
|
@ -77,19 +77,19 @@ void gdb_usb_out_cb(usbd_device *dev, uint8_t ep)
|
|||
unsigned char gdb_if_getchar(void)
|
||||
{
|
||||
|
||||
while(!(out_ptr < count_out)) {
|
||||
while (!(out_ptr < count_out)) {
|
||||
/* Detach if port closed */
|
||||
if(!cdcacm_get_dtr())
|
||||
if (!cdcacm_get_dtr())
|
||||
return 0x04;
|
||||
|
||||
while(cdcacm_get_config() != 1);
|
||||
if (count_new) {
|
||||
memcpy(buffer_out, double_buffer_out,count_new);
|
||||
count_out = count_new;
|
||||
count_new = 0;
|
||||
out_ptr = 0;
|
||||
usbd_ep_nak_set(usbdev, CDCACM_GDB_ENDPOINT, 0);
|
||||
}
|
||||
while (cdcacm_get_config() != 1);
|
||||
if (count_new) {
|
||||
memcpy(buffer_out, double_buffer_out,count_new);
|
||||
count_out = count_new;
|
||||
count_new = 0;
|
||||
out_ptr = 0;
|
||||
usbd_ep_nak_set(usbdev, CDCACM_GDB_ENDPOINT, 0);
|
||||
}
|
||||
}
|
||||
|
||||
return buffer_out[out_ptr++];
|
||||
|
@ -99,19 +99,19 @@ unsigned char gdb_if_getchar_to(int timeout)
|
|||
{
|
||||
timeout_counter = timeout/100;
|
||||
|
||||
if(!(out_ptr < count_out)) do {
|
||||
if (!(out_ptr < count_out)) do {
|
||||
/* Detach if port closed */
|
||||
if(!cdcacm_get_dtr())
|
||||
if (!cdcacm_get_dtr())
|
||||
return 0x04;
|
||||
|
||||
while(cdcacm_get_config() != 1);
|
||||
if (count_new) {
|
||||
memcpy(buffer_out, double_buffer_out,count_new);
|
||||
count_out = count_new;
|
||||
count_new = 0;
|
||||
out_ptr = 0;
|
||||
usbd_ep_nak_set(usbdev, CDCACM_GDB_ENDPOINT, 0);
|
||||
}
|
||||
while (cdcacm_get_config() != 1);
|
||||
if (count_new) {
|
||||
memcpy(buffer_out, double_buffer_out,count_new);
|
||||
count_out = count_new;
|
||||
count_new = 0;
|
||||
out_ptr = 0;
|
||||
usbd_ep_nak_set(usbdev, CDCACM_GDB_ENDPOINT, 0);
|
||||
}
|
||||
} while(timeout_counter && !(out_ptr < count_out));
|
||||
|
||||
if(out_ptr < count_out)
|
||||
|
|
|
@ -54,10 +54,10 @@ int platform_init(void)
|
|||
rcc_periph_clock_enable(RCC_CRC);
|
||||
|
||||
/* Unmap JTAG Pins so we can reuse as GPIO */
|
||||
data = AFIO_MAPR;
|
||||
data &= ~AFIO_MAPR_SWJ_MASK;
|
||||
data |= AFIO_MAPR_SWJ_CFG_JTAG_OFF_SW_OFF;
|
||||
AFIO_MAPR = data;
|
||||
data = AFIO_MAPR;
|
||||
data &= ~AFIO_MAPR_SWJ_MASK;
|
||||
data |= AFIO_MAPR_SWJ_CFG_JTAG_OFF_SW_OFF;
|
||||
AFIO_MAPR = data;
|
||||
/* Setup JTAG GPIO ports */
|
||||
gpio_set_mode(TMS_PORT, GPIO_MODE_OUTPUT_10_MHZ,
|
||||
GPIO_CNF_OUTPUT_PUSHPULL, TMS_PIN);
|
||||
|
@ -69,21 +69,21 @@ int platform_init(void)
|
|||
gpio_set_mode(TDO_PORT, GPIO_MODE_INPUT,
|
||||
GPIO_CNF_INPUT_FLOAT, TDO_PIN);
|
||||
|
||||
gpio_set(NRST_PORT,NRST_PIN);
|
||||
gpio_set(NRST_PORT,NRST_PIN);
|
||||
gpio_set_mode(NRST_PORT, GPIO_MODE_INPUT,
|
||||
GPIO_CNF_INPUT_PULL_UPDOWN, NRST_PIN);
|
||||
|
||||
gpio_set_mode(LED_PORT, GPIO_MODE_OUTPUT_2_MHZ,
|
||||
GPIO_CNF_OUTPUT_PUSHPULL, led_idle_run);
|
||||
|
||||
/* Remap TIM2 TIM2_REMAP[1]
|
||||
* TIM2_CH1_ETR -> PA15 (TDI, set as output above)
|
||||
* TIM2_CH2 -> PB3 (TDO)
|
||||
*/
|
||||
data = AFIO_MAPR;
|
||||
data &= ~AFIO_MAPR_TIM2_REMAP_FULL_REMAP;
|
||||
data |= AFIO_MAPR_TIM2_REMAP_PARTIAL_REMAP1;
|
||||
AFIO_MAPR = data;
|
||||
/* Remap TIM2 TIM2_REMAP[1]
|
||||
* TIM2_CH1_ETR -> PA15 (TDI, set as output above)
|
||||
* TIM2_CH2 -> PB3 (TDO)
|
||||
*/
|
||||
data = AFIO_MAPR;
|
||||
data &= ~AFIO_MAPR_TIM2_REMAP_FULL_REMAP;
|
||||
data |= AFIO_MAPR_TIM2_REMAP_PARTIAL_REMAP1;
|
||||
AFIO_MAPR = data;
|
||||
|
||||
/* Setup heartbeat timer */
|
||||
systick_set_clocksource(STK_CSR_CLKSOURCE_AHB_DIV8);
|
||||
|
|
|
@ -38,12 +38,12 @@
|
|||
|
||||
#define INLINE_GPIO
|
||||
#define CDCACM_PACKET_SIZE 64
|
||||
#define BOARD_IDENT "Black Magic Probe (SWLINK), (Firmware 1.5" VERSION_SUFFIX ", build " BUILDDATE ")"
|
||||
#define BOARD_IDENT_DFU "Black Magic (Upgrade), STM8S Discovery, (Firmware 1.5" VERSION_SUFFIX ", build " BUILDDATE ")"
|
||||
#define BOARD_IDENT_UPD "Black Magic (DFU Upgrade), STM8S Discovery, (Firmware 1.5" VERSION_SUFFIX ", build " BUILDDATE ")"
|
||||
#define DFU_IDENT "Black Magic Firmware Upgrade (SWLINK)"
|
||||
#define DFU_IFACE_STRING "@Internal Flash /0x08000000/8*001Ka,56*001Kg"
|
||||
#define UPD_IFACE_STRING "@Internal Flash /0x08000000/8*001Kg"
|
||||
#define BOARD_IDENT "Black Magic Probe (SWLINK), (Firmware 1.5" VERSION_SUFFIX ", build " BUILDDATE ")"
|
||||
#define BOARD_IDENT_DFU "Black Magic (Upgrade), STM8S Discovery, (Firmware 1.5" VERSION_SUFFIX ", build " BUILDDATE ")"
|
||||
#define BOARD_IDENT_UPD "Black Magic (DFU Upgrade), STM8S Discovery, (Firmware 1.5" VERSION_SUFFIX ", build " BUILDDATE ")"
|
||||
#define DFU_IDENT "Black Magic Firmware Upgrade (SWLINK)"
|
||||
#define DFU_IFACE_STRING "@Internal Flash /0x08000000/8*001Ka,56*001Kg"
|
||||
#define UPD_IFACE_STRING "@Internal Flash /0x08000000/8*001Kg"
|
||||
|
||||
extern usbd_device *usbdev;
|
||||
#define CDCACM_GDB_ENDPOINT 1
|
||||
|
@ -86,26 +86,25 @@ extern usbd_device *usbdev;
|
|||
#define LED_PORT_UART GPIOC
|
||||
#define LED_UART GPIO14
|
||||
|
||||
#define TMS_SET_MODE() \
|
||||
gpio_set_mode(TMS_PORT, GPIO_MODE_OUTPUT_50_MHZ, \
|
||||
GPIO_CNF_OUTPUT_PUSHPULL, TMS_PIN);
|
||||
#define SWDIO_MODE_FLOAT() \
|
||||
gpio_set_mode(SWDIO_PORT, GPIO_MODE_INPUT, \
|
||||
GPIO_CNF_INPUT_FLOAT, SWDIO_PIN);
|
||||
#define SWDIO_MODE_DRIVE() \
|
||||
gpio_set_mode(SWDIO_PORT, GPIO_MODE_OUTPUT_50_MHZ, \
|
||||
GPIO_CNF_OUTPUT_PUSHPULL, SWDIO_PIN);
|
||||
#define TMS_SET_MODE() \
|
||||
gpio_set_mode(TMS_PORT, GPIO_MODE_OUTPUT_50_MHZ, \
|
||||
GPIO_CNF_OUTPUT_PUSHPULL, TMS_PIN);
|
||||
#define SWDIO_MODE_FLOAT() \
|
||||
gpio_set_mode(SWDIO_PORT, GPIO_MODE_INPUT, \
|
||||
GPIO_CNF_INPUT_FLOAT, SWDIO_PIN);
|
||||
#define SWDIO_MODE_DRIVE() \
|
||||
gpio_set_mode(SWDIO_PORT, GPIO_MODE_OUTPUT_50_MHZ, \
|
||||
GPIO_CNF_OUTPUT_PUSHPULL, SWDIO_PIN);
|
||||
|
||||
#define UART_PIN_SETUP() do \
|
||||
{ \
|
||||
AFIO_MAPR |= AFIO_MAPR_USART1_REMAP; \
|
||||
gpio_set_mode(USBUSART_PORT, GPIO_MODE_OUTPUT_2_MHZ, \
|
||||
GPIO_CNF_OUTPUT_ALTFN_PUSHPULL, USBUSART_TX_PIN); \
|
||||
} while (0)
|
||||
#define UART_PIN_SETUP() do { \
|
||||
AFIO_MAPR |= AFIO_MAPR_USART1_REMAP; \
|
||||
gpio_set_mode(USBUSART_PORT, GPIO_MODE_OUTPUT_2_MHZ, \
|
||||
GPIO_CNF_OUTPUT_ALTFN_PUSHPULL, USBUSART_TX_PIN); \
|
||||
} while (0)
|
||||
|
||||
#define USB_DRIVER stm32f103_usb_driver
|
||||
#define USB_IRQ NVIC_USB_LP_CAN_RX0_IRQ
|
||||
#define USB_ISR usb_lp_can_rx0_isr
|
||||
#define USB_ISR usb_lp_can_rx0_isr
|
||||
/* Interrupt priorities. Low numbers are high priority.
|
||||
* For now USART1 preempts USB which may spin while buffer is drained.
|
||||
* TIM2 is used for traceswo capture and must be highest priority.
|
||||
|
|
|
@ -43,19 +43,19 @@ void dfu_detach(void)
|
|||
int main(void)
|
||||
{
|
||||
/* Check the force bootloader pin*/
|
||||
uint16_t pin_b;
|
||||
uint16_t pin_b;
|
||||
rcc_periph_clock_enable(RCC_GPIOA);
|
||||
rcc_periph_clock_enable(RCC_GPIOB);
|
||||
/* Switch PB5 (SWIM_RST_IN) up */
|
||||
gpio_set(GPIOB, GPIO5);
|
||||
gpio_set_mode(GPIOB, GPIO_MODE_OUTPUT_2_MHZ,
|
||||
GPIO_CNF_OUTPUT_PUSHPULL, GPIO5);
|
||||
GPIO_CNF_OUTPUT_PUSHPULL, GPIO5);
|
||||
gpio_set(GPIOB, GPIO5);
|
||||
pin_b = gpio_get(GPIOB, GPIO6);
|
||||
pin_b = gpio_get(GPIOB, GPIO6);
|
||||
/* Check state on PB6 ((SWIM_RST) and release PB5*/
|
||||
pin_b = gpio_get(GPIOB, GPIO6);
|
||||
pin_b = gpio_get(GPIOB, GPIO6);
|
||||
gpio_set_mode(GPIOB, GPIO_MODE_INPUT,
|
||||
GPIO_CNF_INPUT_FLOAT, GPIO5);
|
||||
GPIO_CNF_INPUT_FLOAT, GPIO5);
|
||||
if(((GPIOA_CRL & 0x40) == 0x40) && pin_b)
|
||||
dfu_jump_app_if_valid();
|
||||
|
||||
|
@ -65,10 +65,10 @@ int main(void)
|
|||
systick_set_clocksource(STK_CSR_CLKSOURCE_AHB_DIV8);
|
||||
systick_set_reload(900000);
|
||||
|
||||
/* Handle USB disconnect/connect */
|
||||
/* Handle USB disconnect/connect */
|
||||
/* Just in case: Disconnect USB cable by resetting USB Device
|
||||
* and pulling USB_DP low
|
||||
* Device will reconnect automatically as Pull-Up is hard wired*/
|
||||
* and pulling USB_DP low
|
||||
* Device will reconnect automatically as Pull-Up is hard wired*/
|
||||
rcc_periph_reset_pulse(RST_USB);
|
||||
rcc_periph_clock_enable(RCC_USB);
|
||||
rcc_periph_clock_enable(RCC_GPIOA);
|
||||
|
@ -76,7 +76,7 @@ int main(void)
|
|||
gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_2_MHZ,
|
||||
GPIO_CNF_OUTPUT_OPENDRAIN, GPIO12);
|
||||
|
||||
/* Handle LED*/
|
||||
/* Handle LED*/
|
||||
gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_2_MHZ,
|
||||
GPIO_CNF_OUTPUT_PUSHPULL, GPIO8);
|
||||
|
||||
|
@ -90,5 +90,5 @@ int main(void)
|
|||
|
||||
void sys_tick_handler(void)
|
||||
{
|
||||
gpio_toggle(GPIOA, GPIO8);
|
||||
gpio_toggle(GPIOA, GPIO8);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue