stm32: Move usb_request_bootloader() to chip specific code
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
fce98c5519
commit
8cb3d09484
|
@ -5,6 +5,8 @@
|
||||||
// This file may be distributed under the terms of the GNU GPLv3 license.
|
// This file may be distributed under the terms of the GNU GPLv3 license.
|
||||||
|
|
||||||
#include "autoconf.h" // CONFIG_CLOCK_REF_8M
|
#include "autoconf.h" // CONFIG_CLOCK_REF_8M
|
||||||
|
#include "board/irq.h" // irq_disable
|
||||||
|
#include "board/usb_cdc.h" // usb_request_bootloader
|
||||||
#include "internal.h" // enable_pclock
|
#include "internal.h" // enable_pclock
|
||||||
|
|
||||||
#define FREQ_PERIPH (CONFIG_CLOCK_FREQ / 2)
|
#define FREQ_PERIPH (CONFIG_CLOCK_FREQ / 2)
|
||||||
|
@ -104,6 +106,21 @@ gpio_peripheral(uint32_t gpio, uint32_t mode, int pullup)
|
||||||
AFIO->MAPR = AFIO_MAPR_SWJ_CFG_DISABLE;
|
AFIO->MAPR = AFIO_MAPR_SWJ_CFG_DISABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Handle USB reboot requests
|
||||||
|
void
|
||||||
|
usb_request_bootloader(void)
|
||||||
|
{
|
||||||
|
if (!CONFIG_STM32_FLASH_START_2000)
|
||||||
|
return;
|
||||||
|
// Enter "stm32duino" bootloader
|
||||||
|
irq_disable();
|
||||||
|
RCC->APB1ENR |= RCC_APB1ENR_PWREN | RCC_APB1ENR_BKPEN;
|
||||||
|
PWR->CR |= PWR_CR_DBP;
|
||||||
|
BKP->DR10 = 0x01;
|
||||||
|
PWR->CR &=~ PWR_CR_DBP;
|
||||||
|
NVIC_SystemReset();
|
||||||
|
}
|
||||||
|
|
||||||
// Main clock setup called at chip startup
|
// Main clock setup called at chip startup
|
||||||
void
|
void
|
||||||
clock_setup(void)
|
clock_setup(void)
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
// This file may be distributed under the terms of the GNU GPLv3 license.
|
// This file may be distributed under the terms of the GNU GPLv3 license.
|
||||||
|
|
||||||
#include "autoconf.h" // CONFIG_CLOCK_REF_8M
|
#include "autoconf.h" // CONFIG_CLOCK_REF_8M
|
||||||
|
#include "board/usb_cdc.h" // usb_request_bootloader
|
||||||
#include "command.h" // DECL_CONSTANT_STR
|
#include "command.h" // DECL_CONSTANT_STR
|
||||||
#include "internal.h" // enable_pclock
|
#include "internal.h" // enable_pclock
|
||||||
|
|
||||||
|
@ -85,6 +86,12 @@ gpio_peripheral(uint32_t gpio, uint32_t mode, int pullup)
|
||||||
regs->OSPEEDR = (regs->OSPEEDR & ~m_msk) | (0x02 << m_shift);
|
regs->OSPEEDR = (regs->OSPEEDR & ~m_msk) | (0x02 << m_shift);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Handle USB reboot requests
|
||||||
|
void
|
||||||
|
usb_request_bootloader(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
#if CONFIG_CLOCK_REF_8M
|
#if CONFIG_CLOCK_REF_8M
|
||||||
DECL_CONSTANT_STR("RESERVE_PINS_crystal", "PH0,PH1");
|
DECL_CONSTANT_STR("RESERVE_PINS_crystal", "PH0,PH1");
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
#include "board/armcm_timer.h" // udelay
|
#include "board/armcm_timer.h" // udelay
|
||||||
#include "board/gpio.h" // gpio_out_setup
|
#include "board/gpio.h" // gpio_out_setup
|
||||||
#include "board/io.h" // writeb
|
#include "board/io.h" // writeb
|
||||||
#include "board/irq.h" // irq_disable
|
|
||||||
#include "board/usb_cdc.h" // usb_notify_ep0
|
#include "board/usb_cdc.h" // usb_notify_ep0
|
||||||
#include "board/usb_cdc_ep.h" // USB_CDC_EP_BULK_IN
|
#include "board/usb_cdc_ep.h" // USB_CDC_EP_BULK_IN
|
||||||
#include "command.h" // DECL_CONSTANT_STR
|
#include "command.h" // DECL_CONSTANT_STR
|
||||||
|
@ -207,20 +206,6 @@ usb_set_configure(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
usb_request_bootloader(void)
|
|
||||||
{
|
|
||||||
if (!CONFIG_STM32_FLASH_START_2000)
|
|
||||||
return;
|
|
||||||
// Enter "stm32duino" bootloader
|
|
||||||
irq_disable();
|
|
||||||
RCC->APB1ENR |= RCC_APB1ENR_PWREN | RCC_APB1ENR_BKPEN;
|
|
||||||
PWR->CR |= PWR_CR_DBP;
|
|
||||||
BKP->DR10 = 0x01;
|
|
||||||
PWR->CR &=~ PWR_CR_DBP;
|
|
||||||
NVIC_SystemReset();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************
|
/****************************************************************
|
||||||
* Setup and interrupts
|
* Setup and interrupts
|
||||||
|
|
|
@ -338,11 +338,6 @@ usb_set_configure(void)
|
||||||
usb_irq_enable();
|
usb_irq_enable();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
usb_request_bootloader(void)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************
|
/****************************************************************
|
||||||
* Setup and interrupts
|
* Setup and interrupts
|
||||||
|
|
Loading…
Reference in New Issue