mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-18 13:55:18 +03:00
parent
f3404bfcbb
commit
281bfb4bf6
2 changed files with 32 additions and 10 deletions
|
@ -30,16 +30,6 @@
|
||||||
|
|
||||||
#define FC_VERSION_STRING STR(FC_VERSION_MAJOR) "." STR(FC_VERSION_MINOR) "." STR(FC_VERSION_PATCH_LEVEL)
|
#define FC_VERSION_STRING STR(FC_VERSION_MAJOR) "." STR(FC_VERSION_MINOR) "." STR(FC_VERSION_PATCH_LEVEL)
|
||||||
|
|
||||||
#ifndef __BOARD__
|
|
||||||
#define BOARD_NAME FC_FIRMWARE_NAME
|
|
||||||
#else
|
|
||||||
#define BOARD_NAME __BOARD__
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef MANUFACTURER_ID
|
|
||||||
#define MANUFACTURER_ID FC_FIRMWARE_IDENTIFIER
|
|
||||||
#endif
|
|
||||||
|
|
||||||
extern const char* const targetName;
|
extern const char* const targetName;
|
||||||
|
|
||||||
#define GIT_SHORT_REVISION_LENGTH 7 // lower case hexadecimal digits.
|
#define GIT_SHORT_REVISION_LENGTH 7 // lower case hexadecimal digits.
|
||||||
|
|
|
@ -26,21 +26,25 @@
|
||||||
#if defined(USE_BOARD_INFO)
|
#if defined(USE_BOARD_INFO)
|
||||||
#include "pg/board.h"
|
#include "pg/board.h"
|
||||||
|
|
||||||
|
#if !defined(BOARD_NAME)
|
||||||
static bool boardInformationSet = false;
|
static bool boardInformationSet = false;
|
||||||
static char manufacturerId[MAX_MANUFACTURER_ID_LENGTH + 1];
|
static char manufacturerId[MAX_MANUFACTURER_ID_LENGTH + 1];
|
||||||
static char boardName[MAX_BOARD_NAME_LENGTH + 1];
|
static char boardName[MAX_BOARD_NAME_LENGTH + 1];
|
||||||
static bool boardInformationWasUpdated = false;
|
static bool boardInformationWasUpdated = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
static bool signatureSet = false;
|
static bool signatureSet = false;
|
||||||
static uint8_t signature[SIGNATURE_LENGTH];
|
static uint8_t signature[SIGNATURE_LENGTH];
|
||||||
|
|
||||||
void initBoardInformation(void)
|
void initBoardInformation(void)
|
||||||
{
|
{
|
||||||
|
#if !defined(BOARD_NAME)
|
||||||
boardInformationSet = boardConfig()->boardInformationSet;
|
boardInformationSet = boardConfig()->boardInformationSet;
|
||||||
if (boardInformationSet) {
|
if (boardInformationSet) {
|
||||||
strncpy(manufacturerId, boardConfig()->manufacturerId, MAX_MANUFACTURER_ID_LENGTH + 1);
|
strncpy(manufacturerId, boardConfig()->manufacturerId, MAX_MANUFACTURER_ID_LENGTH + 1);
|
||||||
strncpy(boardName, boardConfig()->boardName, MAX_BOARD_NAME_LENGTH + 1);
|
strncpy(boardName, boardConfig()->boardName, MAX_BOARD_NAME_LENGTH + 1);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
signatureSet = boardConfig()->signatureSet;
|
signatureSet = boardConfig()->signatureSet;
|
||||||
if (signatureSet) {
|
if (signatureSet) {
|
||||||
|
@ -50,21 +54,36 @@ void initBoardInformation(void)
|
||||||
|
|
||||||
const char *getManufacturerId(void)
|
const char *getManufacturerId(void)
|
||||||
{
|
{
|
||||||
|
#if defined(MANUFACTURER_ID) && defined(BOARD_NAME)
|
||||||
|
return STR(MANUFACTURER_ID);
|
||||||
|
#elif defined(BOARD_NAME)
|
||||||
|
return "----";
|
||||||
|
#else
|
||||||
return manufacturerId;
|
return manufacturerId;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *getBoardName(void)
|
const char *getBoardName(void)
|
||||||
{
|
{
|
||||||
|
#if defined(BOARD_NAME)
|
||||||
|
return STR(BOARD_NAME);
|
||||||
|
#else
|
||||||
return boardName;
|
return boardName;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool boardInformationIsSet(void)
|
bool boardInformationIsSet(void)
|
||||||
{
|
{
|
||||||
|
#if defined(BOARD_NAME)
|
||||||
|
return true;
|
||||||
|
#else
|
||||||
return boardInformationSet;
|
return boardInformationSet;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool setManufacturerId(const char *newManufacturerId)
|
bool setManufacturerId(const char *newManufacturerId)
|
||||||
{
|
{
|
||||||
|
#if !defined(BOARD_NAME)
|
||||||
if (!boardInformationSet || strlen(manufacturerId) == 0) {
|
if (!boardInformationSet || strlen(manufacturerId) == 0) {
|
||||||
strncpy(manufacturerId, newManufacturerId, MAX_MANUFACTURER_ID_LENGTH + 1);
|
strncpy(manufacturerId, newManufacturerId, MAX_MANUFACTURER_ID_LENGTH + 1);
|
||||||
|
|
||||||
|
@ -74,10 +93,15 @@ bool setManufacturerId(const char *newManufacturerId)
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
UNUSED(newManufacturerId);
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool setBoardName(const char *newBoardName)
|
bool setBoardName(const char *newBoardName)
|
||||||
{
|
{
|
||||||
|
#if !defined(BOARD_NAME)
|
||||||
if (!boardInformationSet || strlen(boardName) == 0) {
|
if (!boardInformationSet || strlen(boardName) == 0) {
|
||||||
strncpy(boardName, newBoardName, MAX_BOARD_NAME_LENGTH + 1);
|
strncpy(boardName, newBoardName, MAX_BOARD_NAME_LENGTH + 1);
|
||||||
|
|
||||||
|
@ -87,10 +111,15 @@ bool setBoardName(const char *newBoardName)
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
UNUSED(newBoardName);
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool persistBoardInformation(void)
|
bool persistBoardInformation(void)
|
||||||
{
|
{
|
||||||
|
#if !defined(BOARD_NAME)
|
||||||
if (boardInformationWasUpdated) {
|
if (boardInformationWasUpdated) {
|
||||||
strncpy(boardConfigMutable()->manufacturerId, manufacturerId, MAX_MANUFACTURER_ID_LENGTH + 1);
|
strncpy(boardConfigMutable()->manufacturerId, manufacturerId, MAX_MANUFACTURER_ID_LENGTH + 1);
|
||||||
strncpy(boardConfigMutable()->boardName, boardName, MAX_BOARD_NAME_LENGTH + 1);
|
strncpy(boardConfigMutable()->boardName, boardName, MAX_BOARD_NAME_LENGTH + 1);
|
||||||
|
@ -102,6 +131,9 @@ bool persistBoardInformation(void)
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(USE_SIGNATURE)
|
#if defined(USE_SIGNATURE)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue