Add shared emulator services, waveform generation and STM32 USB boot ports
This commit is contained in:
26
c/set-protocol/ports/stm32f407-usb-boot/boot_request.c
Normal file
26
c/set-protocol/ports/stm32f407-usb-boot/boot_request.c
Normal file
@@ -0,0 +1,26 @@
|
||||
#include "boot_port.h"
|
||||
#include "stm32f4xx_hal.h"
|
||||
#define REQUEST_MAGIC 0x42555342UL
|
||||
static uint32_t reset_at;
|
||||
static bool reset_pending;
|
||||
static void backup_access(void)
|
||||
{
|
||||
__HAL_RCC_PWR_CLK_ENABLE();
|
||||
PWR->CR |= PWR_CR_DBP;
|
||||
__HAL_RCC_RTC_ENABLE();
|
||||
}
|
||||
bool f407_boot_requested(void)
|
||||
{
|
||||
bool requested;
|
||||
backup_access(); requested=RTC->BKP0R==REQUEST_MAGIC;
|
||||
RTC->BKP0R=0; return requested;
|
||||
}
|
||||
void f407_request_boot(uint32_t now)
|
||||
{
|
||||
backup_access(); RTC->BKP0R=REQUEST_MAGIC;
|
||||
reset_at=now+500; reset_pending=true;
|
||||
}
|
||||
void f407_reset_poll(uint32_t now)
|
||||
{
|
||||
if(reset_pending && (int32_t)(now-reset_at)>=0) NVIC_SystemReset();
|
||||
}
|
||||
Reference in New Issue
Block a user