mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-15 17:03:34 +08:00
common board idenity cleanup and add mfguid to api
Remove the notion of legacy from the api. The board level code will perform the traslation to lecacy format on the STM32. new targets will not need to do this as there is no case where the serial number were used by mfg for tracking. Extend board common api to get mfguid and mfguid formatted This adds an api that return the MFGUID as an array of bytes or a string. The data is returned with the MSD at index 0 and the LSD at index PX4_CPU_MFGUID_BYTE_LENGTH-1. Removed all reodering defines from the api and hal
This commit is contained in:
committed by
Lorenz Meier
parent
b182a5eeca
commit
bc8b117e85
@@ -10,18 +10,24 @@
|
||||
#define PX4_I2C_OBDEV_LED 0x55
|
||||
|
||||
#define BOARD_OVERRIDE_UUID "SIMULATIONID"
|
||||
#define BOARD_OVERRIDE_MFGUID BOARD_OVERRIDE_UUID
|
||||
#define SIM_FORMATED_UUID "000000010000000200000003"
|
||||
#define PX4_CPU_UUID_BYTE_LENGTH 12
|
||||
#define PX4_CPU_UUID_WORD32_LENGTH 3
|
||||
#define PX4_CPU_UUID_WORD32_LEGACY_FORMAT_SIZE (PX4_CPU_UUID_WORD32_LENGTH-1+(2*PX4_CPU_UUID_BYTE_LENGTH))
|
||||
#define PX4_CPU_MFGUID_BYTE_LENGTH PX4_CPU_UUID_BYTE_LENGTH
|
||||
#define PX4_CPU_UUID_WORD32_UNIQUE_H 2 /* Most significant digits change the least */
|
||||
#define PX4_CPU_UUID_WORD32_UNIQUE_M 1 /* Middle significant digits */
|
||||
#define PX4_CPU_UUID_WORD32_UNIQUE_L 0 /* Least significant digits change the most */
|
||||
#define PX4_CPU_UUID_WORD32_FORMAT_SIZE (PX4_CPU_UUID_WORD32_LENGTH-1+(2*PX4_CPU_UUID_BYTE_LENGTH)+1)
|
||||
#define PX4_CPU_MFGUID_FORMAT_SIZE ((2*PX4_CPU_MFGUID_BYTE_LENGTH)+1)
|
||||
|
||||
#define BOARD_OVERRIDE_CPU_VERSION (-1)
|
||||
#define board_mcu_version(rev, revstr, errata) BOARD_OVERRIDE_CPU_VERSION
|
||||
typedef unsigned char raw_uuid_byte_t[PX4_CPU_UUID_BYTE_LENGTH];
|
||||
typedef unsigned int raw_uuid_uint32_t[PX4_CPU_UUID_WORD32_LENGTH];
|
||||
typedef unsigned char uuid_byte_t[PX4_CPU_UUID_BYTE_LENGTH];
|
||||
typedef unsigned int uuid_uint32_t[PX4_CPU_UUID_WORD32_LENGTH];
|
||||
|
||||
#define board_get_uuid_raw32(id, null) do {id[0]=0;id[1]=1;id[2]=2;} while(0)
|
||||
#define board_get_uuid_formated32(format_buffer, size, format, seperator, optional_reorder) do { strcpy(format_buffer, SIM_FORMATED_UUID); } while(0)
|
||||
#define board_get_uuid32(id) do {for(int _idi=0; _idi < PX4_CPU_UUID_WORD32_LENGTH; _idi++) {id[_idi] = _idi;}} while(0)
|
||||
#define board_get_uuid32_formated(format_buffer, size, format, seperator) do { strcpy(format_buffer, SIM_FORMATED_UUID); } while(0)
|
||||
|
||||
|
||||
#define CONFIG_NFILE_STREAMS 1
|
||||
|
||||
@@ -63,26 +63,59 @@ __BEGIN_DECLS
|
||||
* init32_t[1] PX4_CPU_UUID_ADDRESS[1] bits 63:32 (offset 4)
|
||||
* init32_t[2] PX4_CPU_UUID_ADDRESS[3] bits 96:64 (offset 8)
|
||||
*
|
||||
* PX4 uses the legacy uint32 ordering
|
||||
* word [0] [1] [2]
|
||||
* bits 31-00, 63-32, 95-64
|
||||
* The original PX4 stm32 (legacy) based implementation **displayed** the
|
||||
* UUID as: ABCD EFGH IJKL
|
||||
* Where:
|
||||
* A was bit 31 and D was bit 0
|
||||
* E was bit 63 and H was bit 32
|
||||
* I was bit 95 and L was bit 64
|
||||
*
|
||||
* Since the string was used by some manufactures to identify the units
|
||||
* it must be preserved.
|
||||
*
|
||||
* For new targets moving forward we will use
|
||||
* IJKL EFGH ABCD
|
||||
*/
|
||||
# define PX4_CPU_UUID_BYTE_LENGTH 12
|
||||
# define PX4_CPU_UUID_WORD32_LENGTH (PX4_CPU_UUID_BYTE_LENGTH/sizeof(uint32_t))
|
||||
# define PX4_CPU_UUID_WORD32_LEGACY_FORMAT_ORDER {0,1,2}
|
||||
# define PX4_CPU_UUID_WORD32_LEGACY_FORMAT_SIZE (PX4_CPU_UUID_WORD32_LENGTH-1+(2*PX4_CPU_UUID_BYTE_LENGTH))
|
||||
|
||||
/* The mfguid will be an array of bytes with
|
||||
* MSD @ index 0 - LSD @ index PX4_CPU_MFGUID_BYTE_LENGTH-1
|
||||
*
|
||||
* It wil be conferted to a string with the MSD on left and LSD on the right most position.
|
||||
*/
|
||||
# define PX4_CPU_MFGUID_BYTE_LENGTH PX4_CPU_UUID_BYTE_LENGTH
|
||||
|
||||
/* By not defining PX4_CPU_UUID_CORRECT_CORRELATION the following maintains the legacy incorrect order
|
||||
* used for selection of significant digits of the UUID in the PX4 code base.
|
||||
* This is done to avoid the ripple effects changing the IDs used on STM32 base platforms
|
||||
*/
|
||||
# if defined(PX4_CPU_UUID_CORRECT_CORRELATION)
|
||||
# define PX4_CPU_UUID_WORD32_UNIQUE_H 0 /* Least significant digits change the most */
|
||||
# define PX4_CPU_UUID_WORD32_UNIQUE_M 1 /* Middle significant digits */
|
||||
# define PX4_CPU_UUID_WORD32_UNIQUE_L 2 /* Most significant digits change the least */
|
||||
# else
|
||||
/* Legacy incorrect ordering */
|
||||
# define PX4_CPU_UUID_WORD32_UNIQUE_H 2 /* Most significant digits change the least */
|
||||
# define PX4_CPU_UUID_WORD32_UNIQUE_M 1 /* Middle significant digits */
|
||||
# define PX4_CPU_UUID_WORD32_UNIQUE_L 0 /* Least significant digits change the most */
|
||||
# endif
|
||||
|
||||
/* Separator nnn:nnn:nnnn 2 char per byte term */
|
||||
# define PX4_CPU_UUID_WORD32_FORMAT_SIZE (PX4_CPU_UUID_WORD32_LENGTH-1+(2*PX4_CPU_UUID_BYTE_LENGTH)+1)
|
||||
# define PX4_CPU_MFGUID_FORMAT_SIZE ((2*PX4_CPU_MFGUID_BYTE_LENGTH)+1)
|
||||
|
||||
# define px4_spibus_initialize(port_1based) stm32_spibus_initialize(port_1based)
|
||||
|
||||
# define px4_i2cbus_initialize(bus_num_1based) stm32_i2cbus_initialize(bus_num_1based)
|
||||
# define px4_i2cbus_uninitialize(pdev) stm32_i2cbus_uninitialize(pdev)
|
||||
|
||||
# define px4_arch_configgpio(pinset) stm32_configgpio(pinset)
|
||||
# define px4_arch_unconfiggpio(pinset) stm32_unconfiggpio(pinset)
|
||||
# define px4_arch_gpioread(pinset) stm32_gpioread(pinset)
|
||||
# define px4_arch_gpiowrite(pinset, value) stm32_gpiowrite(pinset, value)
|
||||
# define px4_arch_gpiosetevent(pinset,r,f,e,fp) stm32_gpiosetevent(pinset,r,f, e,fp)
|
||||
# endif
|
||||
# define px4_arch_configgpio(pinset) stm32_configgpio(pinset)
|
||||
# define px4_arch_unconfiggpio(pinset) stm32_unconfiggpio(pinset)
|
||||
# define px4_arch_gpioread(pinset) stm32_gpioread(pinset)
|
||||
# define px4_arch_gpiowrite(pinset, value) stm32_gpiowrite(pinset, value)
|
||||
# define px4_arch_gpiosetevent(pinset,r,f,e,fp) stm32_gpiosetevent(pinset,r,f, e,fp)
|
||||
#endif
|
||||
#include <arch/board/board.h>
|
||||
__END_DECLS
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user