Bsongis/autoupdate (#6521)

Auto update internal chips at boot if /FIRMWARE/autoupdate.frsk is present on SD
This commit is contained in:
Bertrand Songis
2019-06-21 08:52:48 +02:00
committed by GitHub
parent 8cdcf565c2
commit dbec79e10f
10 changed files with 99 additions and 21 deletions
@@ -140,10 +140,40 @@ void telemetryPortSetDirectionInput()
void sportSendByte(uint8_t byte)
{
telemetryPortSetDirectionOutput();
while (!(TELEMETRY_USART->SR & USART_SR_TXE));
USART_SendData(TELEMETRY_USART, byte);
}
void sportSendByteLoop(uint8_t byte)
{
telemetryPortSetDirectionOutput();
outputTelemetryBuffer.data[0] = byte;
DMA_InitTypeDef DMA_InitStructure;
DMA_DeInit(TELEMETRY_DMA_Stream_TX);
DMA_InitStructure.DMA_Channel = TELEMETRY_DMA_Channel_TX;
DMA_InitStructure.DMA_PeripheralBaseAddr = CONVERT_PTR_UINT(&TELEMETRY_USART->DR);
DMA_InitStructure.DMA_DIR = DMA_DIR_MemoryToPeripheral;
DMA_InitStructure.DMA_Memory0BaseAddr = CONVERT_PTR_UINT(outputTelemetryBuffer.data);
DMA_InitStructure.DMA_BufferSize = 1;
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Disable;
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte;
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte;
DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;
DMA_InitStructure.DMA_Priority = DMA_Priority_VeryHigh;
DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Disable;
DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_Full;
DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single;
DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single;
DMA_Init(TELEMETRY_DMA_Stream_TX, &DMA_InitStructure);
DMA_Cmd(TELEMETRY_DMA_Stream_TX, ENABLE);
USART_DMACmd(TELEMETRY_USART, USART_DMAReq_Tx, ENABLE);
}
void sportSendBuffer(const uint8_t * buffer, uint32_t count)
{
telemetryPortSetDirectionOutput();
+5
View File
@@ -4,6 +4,7 @@ option(INTERNAL_MODULE_PPM "Support for PPM internal module hack" OFF)
option(INTERNAL_MODULE_PXX1 "Support for PXX1 internal module replacement" OFF)
option(PXX1 "PXX1 protocol support" ON)
option(PXX2 "PXX2 protocol support" OFF)
option(AUTOUPDATE "Auto update internal chips from SD" OFF)
if(PCB STREQUAL X9E)
set(PWR_BUTTON "PRESS" CACHE STRING "Pwr button type (PRESS/SWITCH)")
@@ -204,6 +205,10 @@ if(PCB STREQUAL X9E OR PCB STREQUAL X7 OR PCB STREQUAL XLITE OR PCB STREQUAL XLI
)
endif()
if(AUTOUPDATE)
add_definitions(-DAUTOUPDATE)
endif()
set(HSE_VALUE 12000000)
set(SDCARD YES)
set(EEPROM EEPROM_RLC)
+5
View File
@@ -137,6 +137,11 @@ void boardInit()
pwrInit();
#if defined(AUTOUPDATE)
telemetryPortInit(FRSKY_SPORT_BAUDRATE, TELEMETRY_SERIAL_WITHOUT_DMA);
sportSendByteLoop(0x7E);
#endif
#if defined(STATUS_LEDS)
ledInit();
ledGreen();
+1
View File
@@ -704,6 +704,7 @@ void telemetryPortInit(uint32_t baudrate, uint8_t mode);
void telemetryPortSetDirectionInput(void);
void telemetryPortSetDirectionOutput(void);
void sportSendByte(uint8_t byte);
void sportSendByteLoop(uint8_t byte);
void sportSendBuffer(const uint8_t * buffer, uint32_t count);
uint8_t telemetryGetByte(uint8_t * byte);
void telemetryClearFifo();
@@ -97,10 +97,40 @@ void telemetryPortSetDirectionInput()
void sportSendByte(uint8_t byte)
{
telemetryPortSetDirectionOutput();
while (!(TELEMETRY_USART->SR & USART_SR_TXE));
USART_SendData(TELEMETRY_USART, byte);
}
void sportSendByteLoop(uint8_t byte)
{
telemetryPortSetDirectionOutput();
outputTelemetryBuffer.data[0] = byte;
DMA_InitTypeDef DMA_InitStructure;
DMA_DeInit(TELEMETRY_DMA_Stream_TX);
DMA_InitStructure.DMA_Channel = TELEMETRY_DMA_Channel_TX;
DMA_InitStructure.DMA_PeripheralBaseAddr = CONVERT_PTR_UINT(&TELEMETRY_USART->DR);
DMA_InitStructure.DMA_DIR = DMA_DIR_MemoryToPeripheral;
DMA_InitStructure.DMA_Memory0BaseAddr = CONVERT_PTR_UINT(outputTelemetryBuffer.data);
DMA_InitStructure.DMA_BufferSize = 1;
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Disable;
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte;
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte;
DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;
DMA_InitStructure.DMA_Priority = DMA_Priority_VeryHigh;
DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Disable;
DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_Full;
DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single;
DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single;
DMA_Init(TELEMETRY_DMA_Stream_TX, &DMA_InitStructure);
DMA_Cmd(TELEMETRY_DMA_Stream_TX, ENABLE);
USART_DMACmd(TELEMETRY_USART, USART_DMAReq_Tx, ENABLE);
}
void sportSendBuffer(const uint8_t * buffer, uint32_t count)
{
telemetryPortSetDirectionOutput();