1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-20 10:54:14 +01:00

PIOS, Modules/FirmwareIAP: Use correct HAL for CPU serial

This commit is contained in:
Corvus Corax 2011-04-23 18:30:32 +02:00
parent e4112e210f
commit 192e31986d
3 changed files with 24 additions and 17 deletions

View File

@ -71,8 +71,6 @@ static uint32_t iap_calc_crc(void);
static void read_description(uint8_t *);
static void read_cpuserial(uint8_t *);
FirmwareIAPObjData data;
static uint32_t get_time(void);
@ -100,7 +98,7 @@ int32_t FirmwareIAPInitialize()
{
data.BoardType= BOARD_TYPE;
read_description(data.Description);
read_cpuserial(data.CPUSerial);
PIOS_SYS_SerialNumberGetBinary(data.CPUSerial);
data.BoardRevision= BOARD_REVISION;
data.ArmReset=0;
data.crc = 0;
@ -136,7 +134,7 @@ static void FirmwareIAPCallback(UAVObjEvent* ev)
if((data.BoardType==BOARD_TYPE)&&(data.crc != iap_calc_crc()))
{
read_description(data.Description);
read_cpuserial(data.CPUSerial);
PIOS_SYS_SerialNumberGetBinary(data.CPUSerial);
data.BoardRevision=BOARD_REVISION;
data.crc = iap_calc_crc();
FirmwareIAPObjSet( &data );
@ -252,19 +250,6 @@ static void read_description(uint8_t * array)
}
}
/**
* Read the CPU Serial number.
* @param array has to be 12 bytes long.
*/
static void read_cpuserial(uint8_t * array)
{
uint8_t x = 0;
for (uint8_t i = 0; i < 12; i++) {
array[x] = *FLASH_If_Read(0x1ffff7e8 + i);
++x;
}
}
/**
* Executed by event dispatcher callback to reset INS before resetting OP
*/

View File

@ -134,6 +134,27 @@ uint32_t PIOS_SYS_getCPUFlashSize(void)
return ((uint32_t) MEM16(0x1FFFF7E0) * 1000);
}
/**
* Returns the serial number as a string
* param[out] str pointer to a string which can store at least 32 digits + zero terminator!
* (24 digits returned for STM32)
* return < 0 if feature not supported
*/
int32_t PIOS_SYS_SerialNumberGetBinary(uint8_t *array)
{
int i;
/* Stored in the so called "electronic signature" */
for (i = 0; i < 12; ++i) {
uint8_t b = MEM8(0x1ffff7e8 + i);
array[i] = b;
}
/* No error */
return 0;
}
/**
* Returns the serial number as a string
* param[out] str pointer to a string which can store at least 32 digits + zero terminator!

View File

@ -36,6 +36,7 @@
extern void PIOS_SYS_Init(void);
extern int32_t PIOS_SYS_Reset(void);
extern uint32_t PIOS_SYS_getCPUFlashSize(void);
extern int32_t PIOS_SYS_SerialNumberGetBinary(uint8_t *array);
extern int32_t PIOS_SYS_SerialNumberGet(char *str);
#endif /* PIOS_SYS_H */