mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-30 14:13:35 +08:00
systemlib/board_serial uses common board api for UUID
This commit is contained in:
committed by
Lorenz Meier
parent
459f71f579
commit
24f5461402
@@ -41,20 +41,17 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <px4_config.h>
|
#include <px4_config.h>
|
||||||
#include "otp.h"
|
#include <string.h>
|
||||||
#include "board_serial.h"
|
#include "board_serial.h"
|
||||||
|
|
||||||
int get_board_serial(uint8_t *serialid)
|
int get_board_serial(raw_uuid_byte_t serialid)
|
||||||
{
|
{
|
||||||
const volatile uint32_t *udid_ptr = (const uint32_t *)STM32_SYSMEM_UID;
|
#if defined(BOARD_OVERRIDE_UUID)
|
||||||
union udid id;
|
memcpy(serialid, BOARD_OVERRIDE_UUID, PX4_CPU_UUID_BYTE_LENGTH);
|
||||||
val_read((uint32_t *)&id, udid_ptr, sizeof(id));
|
#else
|
||||||
|
uuid_uint8_reorder_t odering = {3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8};
|
||||||
|
|
||||||
/* Copy the serial from the chips non-write memory and swap endianess */
|
/* Copy the serial from the chips non-write memory and swap endianess */
|
||||||
serialid[0] = id.data[3]; serialid[1] = id.data[2]; serialid[2] = id.data[1]; serialid[3] = id.data[0];
|
board_get_uuid(serialid, odering);
|
||||||
serialid[4] = id.data[7]; serialid[5] = id.data[6]; serialid[6] = id.data[5]; serialid[7] = id.data[4];
|
#endif
|
||||||
serialid[8] = id.data[11]; serialid[9] = id.data[10]; serialid[10] = id.data[9]; serialid[11] = id.data[8];
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
*
|
*
|
||||||
* Copyright (c) 2012-2014 PX4 Development Team. All rights reserved.
|
* Copyright (c) 2012-2014, 2017 PX4 Development Team. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
@@ -42,10 +42,10 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <stdint.h> // uint8_t
|
#include <px4_config.h>
|
||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
|
|
||||||
__EXPORT int get_board_serial(uint8_t *serialid);
|
__EXPORT int get_board_serial(raw_uuid_byte_t serialid);
|
||||||
|
|
||||||
__END_DECLS
|
__END_DECLS
|
||||||
|
|||||||
Reference in New Issue
Block a user