mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-28 12:13:33 +08:00
LPC11C24: extended hardware and software version info
This commit is contained in:
@@ -8,7 +8,7 @@ CPPSRC := $(wildcard src/*.cpp) \
|
|||||||
CSRC := $(wildcard lpc_chip_11cxx_lib/src/*.c) \
|
CSRC := $(wildcard lpc_chip_11cxx_lib/src/*.c) \
|
||||||
$(wildcard src/sys/*.c)
|
$(wildcard src/sys/*.c)
|
||||||
|
|
||||||
DEF =
|
DEF = -DFW_VERSION_MAJOR=1 -DFW_VERSION_MINOR=0
|
||||||
|
|
||||||
INC = -Isrc/sys \
|
INC = -Isrc/sys \
|
||||||
-Ilpc_chip_11cxx_lib/inc
|
-Ilpc_chip_11cxx_lib/inc
|
||||||
@@ -30,6 +30,15 @@ INC += -I$(LIBUAVCAN_LPC11C24_INC)
|
|||||||
$(info $(shell $(LIBUAVCAN_DSDLC) $(UAVCAN_DSDL_DIR)))
|
$(info $(shell $(LIBUAVCAN_DSDLC) $(UAVCAN_DSDL_DIR)))
|
||||||
INC += -Idsdlc_generated
|
INC += -Idsdlc_generated
|
||||||
|
|
||||||
|
#
|
||||||
|
# Git commit hash
|
||||||
|
#
|
||||||
|
|
||||||
|
GIT_HASH := $(shell git rev-parse --short HEAD)
|
||||||
|
ifeq ($(words $(GIT_HASH)),1)
|
||||||
|
DEF += -DGIT_HASH=0x$(GIT_HASH)
|
||||||
|
endif
|
||||||
|
|
||||||
#
|
#
|
||||||
# Build configuration
|
# Build configuration
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
#include <algorithm>
|
||||||
#include <board.hpp>
|
#include <board.hpp>
|
||||||
#include <chip.h>
|
#include <chip.h>
|
||||||
#include <uavcan_lpc11c24/uavcan_lpc11c24.hpp>
|
#include <uavcan_lpc11c24/uavcan_lpc11c24.hpp>
|
||||||
@@ -40,6 +41,9 @@ void die()
|
|||||||
while (true) { }
|
while (true) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if __GNUC__
|
||||||
|
__attribute__((noinline))
|
||||||
|
#endif
|
||||||
void init()
|
void init()
|
||||||
{
|
{
|
||||||
if (uavcan_lpc11c24::CanDriver::instance().init(1000000) < 0)
|
if (uavcan_lpc11c24::CanDriver::instance().init(1000000) < 0)
|
||||||
@@ -50,6 +54,19 @@ void init()
|
|||||||
getNode().setNodeID(72);
|
getNode().setNodeID(72);
|
||||||
getNode().setName("org.uavcan.lpc11c24_test");
|
getNode().setName("org.uavcan.lpc11c24_test");
|
||||||
|
|
||||||
|
uavcan::protocol::SoftwareVersion swver;
|
||||||
|
swver.major = FW_VERSION_MAJOR;
|
||||||
|
swver.minor = FW_VERSION_MINOR;
|
||||||
|
swver.vcs_commit = GIT_HASH;
|
||||||
|
swver.optional_field_mask = swver.OPTIONAL_FIELD_MASK_VCS_COMMIT;
|
||||||
|
getNode().setSoftwareVersion(swver);
|
||||||
|
|
||||||
|
uavcan::protocol::HardwareVersion hwver;
|
||||||
|
std::uint8_t uid[board::UniqueIDSize] = {};
|
||||||
|
board::readUniqueID(uid);
|
||||||
|
std::copy(std::begin(uid), std::end(uid), std::begin(hwver.unique_id));
|
||||||
|
getNode().setHardwareVersion(hwver);
|
||||||
|
|
||||||
while (getNode().start() < 0)
|
while (getNode().start() < 0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,8 @@
|
|||||||
#include "board.hpp"
|
#include "board.hpp"
|
||||||
#include <chip.h>
|
#include <chip.h>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
#include <cstring>
|
||||||
|
#include <numeric>
|
||||||
|
|
||||||
#define PDRUNCFGUSEMASK 0x0000ED00
|
#define PDRUNCFGUSEMASK 0x0000ED00
|
||||||
#define PDRUNCFGMASKTMP 0x000000FF
|
#define PDRUNCFGMASKTMP 0x000000FF
|
||||||
@@ -114,6 +116,17 @@ void init()
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
#if __GNUC__
|
||||||
|
__attribute__((optimize(0))) // Optimization must be disabled lest it hardfaults in the IAP call
|
||||||
|
#endif
|
||||||
|
void readUniqueID(uint8_t out_uid[UniqueIDSize])
|
||||||
|
{
|
||||||
|
unsigned aligned_array[4] = {}; // out_uid may be unaligned, so we need to use temp array
|
||||||
|
unsigned iap_command = 58;
|
||||||
|
reinterpret_cast<void(*)(void*, void*)>(0x1FFF1FF1)(&iap_command, aligned_array);
|
||||||
|
std::memcpy(out_uid, aligned_array, 16);
|
||||||
|
}
|
||||||
|
|
||||||
void setStatusLed(bool state)
|
void setStatusLed(bool state)
|
||||||
{
|
{
|
||||||
LPC_GPIO[StatusLedPort].DATA[1 << StatusLedPin] = static_cast<unsigned long>(!state) << StatusLedPin;
|
LPC_GPIO[StatusLedPort].DATA[1 << StatusLedPin] = static_cast<unsigned long>(!state) << StatusLedPin;
|
||||||
|
|||||||
@@ -2,9 +2,15 @@
|
|||||||
* Pavel Kirienko, 2014 <pavel.kirienko@gmail.com>
|
* Pavel Kirienko, 2014 <pavel.kirienko@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
namespace board
|
namespace board
|
||||||
{
|
{
|
||||||
|
|
||||||
|
static const unsigned UniqueIDSize = 16;
|
||||||
|
|
||||||
|
void readUniqueID(uint8_t out_uid[UniqueIDSize]);
|
||||||
|
|
||||||
void setStatusLed(bool state);
|
void setStatusLed(bool state);
|
||||||
void setErrorLed(bool state);
|
void setErrorLed(bool state);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user