2 * This file is part of Cleanflight and Betaflight.
4 * Cleanflight and Betaflight are free software. You can redistribute
5 * this software and/or modify this software under the terms of the
6 * GNU General Public License as published by the Free Software
7 * Foundation, either version 3 of the License, or (at your option)
10 * Cleanflight and Betaflight are distributed in the hope that they
11 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
12 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this software.
18 * If not, see <http://www.gnu.org/licenses/>.
26 #if defined(USE_BOARD_INFO)
29 static bool boardInformationSet
= false;
30 static char manufacturerId
[MAX_MANUFACTURER_ID_LENGTH
+ 1];
31 static char boardName
[MAX_BOARD_NAME_LENGTH
+ 1];
32 static bool boardInformationWasUpdated
= false;
34 static bool signatureSet
= false;
35 static uint8_t signature
[SIGNATURE_LENGTH
];
37 void initBoardInformation(void)
39 boardInformationSet
= boardConfig()->boardInformationSet
;
40 if (boardInformationSet
) {
41 strncpy(manufacturerId
, boardConfig()->manufacturerId
, MAX_MANUFACTURER_ID_LENGTH
);
42 strncpy(boardName
, boardConfig()->boardName
, MAX_BOARD_NAME_LENGTH
);
45 signatureSet
= boardConfig()->signatureSet
;
47 memcpy(signature
, boardConfig()->signature
, SIGNATURE_LENGTH
);
51 const char *getManufacturerId(void)
53 return manufacturerId
;
56 const char *getBoardName(void)
61 bool boardInformationIsSet(void)
63 return boardInformationSet
;
66 bool setManufacturerId(const char *newManufacturerId
)
68 if (!boardInformationSet
|| strlen(manufacturerId
) == 0) {
69 strncpy(manufacturerId
, newManufacturerId
, MAX_MANUFACTURER_ID_LENGTH
);
71 boardInformationWasUpdated
= true;
79 bool setBoardName(const char *newBoardName
)
81 if (!boardInformationSet
|| strlen(boardName
) == 0) {
82 strncpy(boardName
, newBoardName
, MAX_BOARD_NAME_LENGTH
);
84 boardInformationWasUpdated
= true;
92 bool persistBoardInformation(void)
94 if (boardInformationWasUpdated
) {
95 strncpy(boardConfigMutable()->manufacturerId
, manufacturerId
, MAX_MANUFACTURER_ID_LENGTH
);
96 strncpy(boardConfigMutable()->boardName
, boardName
, MAX_BOARD_NAME_LENGTH
);
97 boardConfigMutable()->boardInformationSet
= true;
99 initBoardInformation();
107 #if defined(USE_SIGNATURE)
108 const uint8_t *getSignature(void)
113 bool signatureIsSet(void)
118 bool setSignature(const uint8_t *newSignature
)
121 memcpy(signature
, newSignature
, SIGNATURE_LENGTH
);
129 bool persistSignature(void)
132 memcpy(boardConfigMutable()->signature
, signature
, SIGNATURE_LENGTH
);
133 boardConfigMutable()->signatureSet
= true;
135 initBoardInformation();
143 #endif // USE_BOARD_INFO