mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-01 09:24:10 +01:00
PIOS: BL_HELPER: refactored function names
This commit is contained in:
parent
150464344d
commit
5d952f81e3
@ -1247,10 +1247,10 @@ void firmwareiapobj_callback(AhrsObjHandle obj)
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(firmwareIAPObj.BoardType==BOARD_TYPE && firmwareIAPObj.crc!=FLASH_crc_memory_calc())
|
||||
else if(firmwareIAPObj.BoardType==BOARD_TYPE && firmwareIAPObj.crc!=PIOS_BL_HELPER_CRC_Memory_Calc())
|
||||
{
|
||||
FLASH_read_description(firmwareIAPObj.Description,SIZE_OF_DESCRIPTION);
|
||||
firmwareIAPObj.crc=FLASH_crc_memory_calc();
|
||||
PIOS_BL_HELPER_FLASH_Read_Description(firmwareIAPObj.Description,SIZE_OF_DESCRIPTION);
|
||||
firmwareIAPObj.crc=PIOS_BL_HELPER_CRC_Memory_Calc();
|
||||
firmwareIAPObj.BoardRevision=BOARD_REVISION;
|
||||
FirmwareIAPObjSet(&firmwareIAPObj);
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ int main() {
|
||||
}
|
||||
PIOS_Board_Init();
|
||||
boot_status = idle;
|
||||
Fw_crc = FLASH_crc_memory_calc();
|
||||
Fw_crc = PIOS_BL_HELPER_CRC_Memory_Calc();
|
||||
PIOS_LED_On(LED1);
|
||||
while (1) {
|
||||
process_spi_request();
|
||||
@ -146,7 +146,7 @@ void process_spi_request(void) {
|
||||
|
||||
case OPAHRS_MSG_V0_REQ_FWUP_VERIFY:
|
||||
opahrs_msg_v0_init_user_tx(&user_tx_v0, OPAHRS_MSG_V0_RSP_FWUP_STATUS);
|
||||
Fw_crc = FLASH_crc_memory_calc();
|
||||
Fw_crc = PIOS_BL_HELPER_CRC_Memory_Calc();
|
||||
lfsm_user_set_tx_v0(&user_tx_v0);
|
||||
boot_status = idle;
|
||||
PIOS_LED_Off(LED1);
|
||||
@ -216,7 +216,7 @@ void process_spi_request(void) {
|
||||
uint32_t adr=user_rx_v0.payload.user.v.req.fwdn_data.adress;
|
||||
for(uint8_t x=0;x<4;++x)
|
||||
{
|
||||
user_tx_v0.payload.user.v.rsp.fw_dn.data[x]=*FLASH_If_Read(adr+x);
|
||||
user_tx_v0.payload.user.v.rsp.fw_dn.data[x]=*PIOS_BL_HELPER_FLASH_If_Read(adr+x);
|
||||
}
|
||||
lfsm_user_set_tx_v0(&user_tx_v0);
|
||||
break;
|
||||
@ -226,7 +226,7 @@ void process_spi_request(void) {
|
||||
user_tx_v0.payload.user.v.rsp.fwup_status.status = boot_status;
|
||||
lfsm_user_set_tx_v0(&user_tx_v0);
|
||||
PIOS_LED_On(LED1);
|
||||
if (FLASH_Start() == TRUE) {
|
||||
if (PIOS_BL_HELPER_FLASH_Start() == TRUE) {
|
||||
boot_status = started;
|
||||
PIOS_LED_Off(LED1);
|
||||
} else {
|
||||
|
@ -116,10 +116,10 @@ void DataDownload(DownloadAction action) {
|
||||
}
|
||||
break;
|
||||
case Self_flash:
|
||||
SendBuffer[6 + (x * 4)] = *FLASH_If_Read(offset);
|
||||
SendBuffer[7 + (x * 4)] = *FLASH_If_Read(offset + 1);
|
||||
SendBuffer[8 + (x * 4)] = *FLASH_If_Read(offset + 2);
|
||||
SendBuffer[9 + (x * 4)] = *FLASH_If_Read(offset + 3);
|
||||
SendBuffer[6 + (x * 4)] = *PIOS_BL_HELPER_FLASH_If_Read(offset);
|
||||
SendBuffer[7 + (x * 4)] = *PIOS_BL_HELPER_FLASH_If_Read(offset + 1);
|
||||
SendBuffer[8 + (x * 4)] = *PIOS_BL_HELPER_FLASH_If_Read(offset + 2);
|
||||
SendBuffer[9 + (x * 4)] = *PIOS_BL_HELPER_FLASH_If_Read(offset + 3);
|
||||
break;
|
||||
}
|
||||
*/
|
||||
@ -178,7 +178,7 @@ void processComand(uint8_t *xReceive_Buffer) {
|
||||
uint8_t result = 0;
|
||||
switch (currentProgrammingDestination) {
|
||||
case Self_flash:
|
||||
result = FLASH_Ini();
|
||||
result = PIOS_BL_HELPER_FLASH_Ini();
|
||||
break;
|
||||
case Remote_flash_via_spi:
|
||||
result = TRUE;
|
||||
@ -214,7 +214,7 @@ void processComand(uint8_t *xReceive_Buffer) {
|
||||
if (TransferType == FW) {
|
||||
switch (currentProgrammingDestination) {
|
||||
case Self_flash:
|
||||
result = FLASH_Start();
|
||||
result = PIOS_BL_HELPER_FLASH_Start();
|
||||
break;
|
||||
case Remote_flash_via_spi:
|
||||
result = FALSE;
|
||||
@ -459,7 +459,7 @@ uint8_t isBiggerThanAvailable(DFUTransfer type, uint32_t size) {
|
||||
uint32_t CalcFirmCRC() {
|
||||
switch (currentProgrammingDestination) {
|
||||
case Self_flash:
|
||||
return FLASH_crc_memory_calc();
|
||||
return PIOS_BL_HELPER_CRC_Memory_Calc();
|
||||
break;
|
||||
case Remote_flash_via_spi:
|
||||
return 0;
|
||||
@ -484,7 +484,7 @@ bool flash_read(uint8_t * buffer, uint32_t adr, DFUProgType type) {
|
||||
break;
|
||||
case Self_flash:
|
||||
for (uint8_t x = 0; x < 4; ++x) {
|
||||
buffer[x] = *FLASH_If_Read(adr + x);
|
||||
buffer[x] = *PIOS_BL_HELPER_FLASH_If_Read(adr + x);
|
||||
}
|
||||
return TRUE;
|
||||
break;
|
||||
|
@ -158,7 +158,7 @@ void processComand(uint8_t *xReceive_Buffer) {
|
||||
uint8_t result = 0;
|
||||
switch (currentProgrammingDestination) {
|
||||
case Self_flash:
|
||||
result = FLASH_Ini();
|
||||
result = PIOS_BL_HELPER_FLASH_Ini();
|
||||
break;
|
||||
case Remote_flash_via_spi:
|
||||
result = TRUE;
|
||||
@ -195,7 +195,7 @@ void processComand(uint8_t *xReceive_Buffer) {
|
||||
if (TransferType == FW) {
|
||||
switch (currentProgrammingDestination) {
|
||||
case Self_flash:
|
||||
result = FLASH_Start();
|
||||
result = PIOS_BL_HELPER_FLASH_Start();
|
||||
break;
|
||||
case Remote_flash_via_spi:
|
||||
PIOS_OPAHRS_bl_FwupStart(&rsp);
|
||||
@ -525,7 +525,7 @@ uint32_t CalcFirmCRC() {
|
||||
struct opahrs_msg_v0 rsp;
|
||||
switch (currentProgrammingDestination) {
|
||||
case Self_flash:
|
||||
return FLASH_crc_memory_calc();
|
||||
return PIOS_BL_HELPER_CRC_Memory_Calc();
|
||||
break;
|
||||
case Remote_flash_via_spi:
|
||||
PIOS_OPAHRS_bl_FwupVerify(&rsp);
|
||||
@ -574,7 +574,7 @@ bool flash_read(uint8_t * buffer, uint32_t adr, DFUProgType type) {
|
||||
break;
|
||||
case Self_flash:
|
||||
for (uint8_t x = 0; x < 4; ++x) {
|
||||
buffer[x] = *FLASH_If_Read(adr + x);
|
||||
buffer[x] = *PIOS_BL_HELPER_FLASH_If_Read(adr + x);
|
||||
}
|
||||
return TRUE;
|
||||
break;
|
||||
|
@ -116,10 +116,10 @@ void DataDownload(DownloadAction action) {
|
||||
}
|
||||
break;
|
||||
case Self_flash:
|
||||
SendBuffer[6 + (x * 4)] = *FLASH_If_Read(offset);
|
||||
SendBuffer[7 + (x * 4)] = *FLASH_If_Read(offset + 1);
|
||||
SendBuffer[8 + (x * 4)] = *FLASH_If_Read(offset + 2);
|
||||
SendBuffer[9 + (x * 4)] = *FLASH_If_Read(offset + 3);
|
||||
SendBuffer[6 + (x * 4)] = *PIOS_BL_HELPER_FLASH_If_Read(offset);
|
||||
SendBuffer[7 + (x * 4)] = *PIOS_BL_HELPER_FLASH_If_Read(offset + 1);
|
||||
SendBuffer[8 + (x * 4)] = *PIOS_BL_HELPER_FLASH_If_Read(offset + 2);
|
||||
SendBuffer[9 + (x * 4)] = *PIOS_BL_HELPER_FLASH_If_Read(offset + 3);
|
||||
break;
|
||||
}
|
||||
*/
|
||||
@ -178,7 +178,7 @@ void processComand(uint8_t *xReceive_Buffer) {
|
||||
uint8_t result = 0;
|
||||
switch (currentProgrammingDestination) {
|
||||
case Self_flash:
|
||||
result = FLASH_Ini();
|
||||
result = PIOS_BL_HELPER_FLASH_Ini();
|
||||
break;
|
||||
case Remote_flash_via_spi:
|
||||
result = TRUE;
|
||||
@ -214,7 +214,7 @@ void processComand(uint8_t *xReceive_Buffer) {
|
||||
if (TransferType == FW) {
|
||||
switch (currentProgrammingDestination) {
|
||||
case Self_flash:
|
||||
result = FLASH_Start();
|
||||
result = PIOS_BL_HELPER_FLASH_Start();
|
||||
break;
|
||||
case Remote_flash_via_spi:
|
||||
result = FALSE;
|
||||
@ -459,7 +459,7 @@ uint8_t isBiggerThanAvailable(DFUTransfer type, uint32_t size) {
|
||||
uint32_t CalcFirmCRC() {
|
||||
switch (currentProgrammingDestination) {
|
||||
case Self_flash:
|
||||
return FLASH_crc_memory_calc();
|
||||
return PIOS_BL_HELPER_CRC_Memory_Calc();
|
||||
break;
|
||||
case Remote_flash_via_spi:
|
||||
return 0;
|
||||
@ -484,7 +484,7 @@ bool flash_read(uint8_t * buffer, uint32_t adr, DFUProgType type) {
|
||||
break;
|
||||
case Self_flash:
|
||||
for (uint8_t x = 0; x < 4; ++x) {
|
||||
buffer[x] = *FLASH_If_Read(adr + x);
|
||||
buffer[x] = *PIOS_BL_HELPER_FLASH_If_Read(adr + x);
|
||||
}
|
||||
return TRUE;
|
||||
break;
|
||||
|
@ -93,7 +93,7 @@ static void resetTask(UAVObjEvent *);
|
||||
int32_t FirmwareIAPInitialize()
|
||||
{
|
||||
data.BoardType= BOARD_TYPE;
|
||||
FLASH_read_description(data.Description,FIRMWAREIAPOBJ_DESCRIPTION_NUMELEM);
|
||||
PIOS_BL_HELPER_FLASH_Read_Description(data.Description,FIRMWAREIAPOBJ_DESCRIPTION_NUMELEM);
|
||||
PIOS_SYS_SerialNumberGetBinary(data.CPUSerial);
|
||||
data.BoardRevision= BOARD_REVISION;
|
||||
data.ArmReset=0;
|
||||
@ -127,12 +127,12 @@ static void FirmwareIAPCallback(UAVObjEvent* ev)
|
||||
this_time = get_time();
|
||||
delta = this_time - last_time;
|
||||
last_time = this_time;
|
||||
if((data.BoardType==BOARD_TYPE)&&(data.crc != FLASH_crc_memory_calc()))
|
||||
if((data.BoardType==BOARD_TYPE)&&(data.crc != PIOS_BL_HELPER_CRC_Memory_Calc()))
|
||||
{
|
||||
FLASH_read_description(data.Description,FIRMWAREIAPOBJ_DESCRIPTION_NUMELEM);
|
||||
PIOS_BL_HELPER_FLASH_Read_Description(data.Description,FIRMWAREIAPOBJ_DESCRIPTION_NUMELEM);
|
||||
PIOS_SYS_SerialNumberGetBinary(data.CPUSerial);
|
||||
data.BoardRevision=BOARD_REVISION;
|
||||
data.crc = FLASH_crc_memory_calc();
|
||||
data.crc = PIOS_BL_HELPER_CRC_Memory_Calc();
|
||||
FirmwareIAPObjSet( &data );
|
||||
}
|
||||
if((data.ArmReset==1)&&(iap_state!=IAP_STATE_RESETTING))
|
||||
|
@ -33,19 +33,19 @@
|
||||
#if defined(PIOS_INCLUDE_BL_HELPER)
|
||||
#include "stm32f10x_flash.h"
|
||||
|
||||
uint8_t *FLASH_If_Read(uint32_t SectorAddress)
|
||||
uint8_t *PIOS_BL_HELPER_FLASH_If_Read(uint32_t SectorAddress)
|
||||
{
|
||||
return (uint8_t *) (SectorAddress);
|
||||
}
|
||||
|
||||
#if defined(PIOS_INCLUDE_BL_HELPER_WRITE_SUPPORT)
|
||||
uint8_t FLASH_Ini()
|
||||
uint8_t PIOS_BL_HELPER_FLASH_Ini()
|
||||
{
|
||||
FLASH_Unlock();
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint8_t FLASH_Start()
|
||||
uint8_t PIOS_BL_HELPER_FLASH_Start()
|
||||
{
|
||||
uint32_t pageAdress;
|
||||
pageAdress = START_OF_USER_CODE;
|
||||
@ -73,25 +73,25 @@ uint8_t FLASH_Start()
|
||||
}
|
||||
#endif
|
||||
|
||||
uint32_t FLASH_crc_memory_calc()
|
||||
uint32_t PIOS_BL_HELPER_CRC_Memory_Calc()
|
||||
{
|
||||
CRC_Ini();
|
||||
PIOS_BL_HELPER_CRC_Ini();
|
||||
CRC_ResetDR();
|
||||
CRC_CalcBlockCRC((uint32_t *) START_OF_USER_CODE, (SIZE_OF_CODE) >> 2);
|
||||
return CRC_GetCRC();
|
||||
}
|
||||
|
||||
void FLASH_read_description(uint8_t * array, uint8_t size)
|
||||
void PIOS_BL_HELPER_FLASH_Read_Description(uint8_t * array, uint8_t size)
|
||||
{
|
||||
uint8_t x = 0;
|
||||
if (size>SIZE_OF_DESCRIPTION) size = SIZE_OF_DESCRIPTION;
|
||||
for (uint32_t i = START_OF_USER_CODE + SIZE_OF_CODE; i < START_OF_USER_CODE + SIZE_OF_CODE + size; ++i) {
|
||||
array[x] = *FLASH_If_Read(i);
|
||||
array[x] = *PIOS_BL_HELPER_FLASH_If_Read(i);
|
||||
++x;
|
||||
}
|
||||
}
|
||||
|
||||
void CRC_Ini()
|
||||
void PIOS_BL_HELPER_CRC_Ini()
|
||||
{
|
||||
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_CRC, ENABLE);
|
||||
}
|
||||
|
@ -31,16 +31,16 @@
|
||||
#ifndef PIOS_BL_HELPER_H_
|
||||
#define PIOS_BL_HELPER_H_
|
||||
|
||||
extern uint8_t *FLASH_If_Read(uint32_t SectorAddress);
|
||||
extern uint8_t *PIOS_BL_HELPER_FLASH_If_Read(uint32_t SectorAddress);
|
||||
|
||||
extern uint8_t FLASH_Ini();
|
||||
extern uint8_t PIOS_BL_HELPER_FLASH_Ini();
|
||||
|
||||
extern uint32_t FLASH_crc_memory_calc();
|
||||
extern uint32_t PIOS_BL_HELPER_CRC_Memory_Calc();
|
||||
|
||||
extern void FLASH_read_description(uint8_t * array, uint8_t size);
|
||||
extern void PIOS_BL_HELPER_FLASH_Read_Description(uint8_t * array, uint8_t size);
|
||||
|
||||
extern uint8_t FLASH_Start();
|
||||
extern uint8_t PIOS_BL_HELPER_FLASH_Start();
|
||||
|
||||
extern void CRC_Ini();
|
||||
extern void PIOS_BL_HELPER_CRC_Ini();
|
||||
|
||||
#endif /* PIOS_BL_HELPER_H_ */
|
||||
|
Loading…
Reference in New Issue
Block a user