mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-15 20:35:33 +03:00
Merge pull request #964 from nzmichaelh/more-const
various: optimise RAM and flash usage
This commit is contained in:
commit
55180070d6
6 changed files with 26 additions and 42 deletions
|
@ -140,12 +140,12 @@ void useRcControlsConfig(modeActivationCondition_t *modeActivationConditions, es
|
|||
#define BASEFLIGHT_IDENTIFIER "BAFL";
|
||||
|
||||
#define FLIGHT_CONTROLLER_IDENTIFIER_LENGTH 4
|
||||
static const char *flightControllerIdentifier = CLEANFLIGHT_IDENTIFIER; // 4 UPPER CASE alpha numeric characters that identify the flight controller.
|
||||
static const char * const flightControllerIdentifier = CLEANFLIGHT_IDENTIFIER; // 4 UPPER CASE alpha numeric characters that identify the flight controller.
|
||||
|
||||
#define FLIGHT_CONTROLLER_VERSION_LENGTH 3
|
||||
#define FLIGHT_CONTROLLER_VERSION_MASK 0xFFF
|
||||
|
||||
const char *boardIdentifier = TARGET_BOARD_IDENTIFIER;
|
||||
static const char * const boardIdentifier = TARGET_BOARD_IDENTIFIER;
|
||||
#define BOARD_IDENTIFIER_LENGTH 4 // 4 UPPER CASE alpha numeric characters that identify the board being used.
|
||||
#define BOARD_HARDWARE_REVISION_LENGTH 2
|
||||
|
||||
|
@ -396,40 +396,24 @@ static mspPort_t mspPorts[MAX_MSP_PORT_COUNT];
|
|||
|
||||
static mspPort_t *currentPort;
|
||||
|
||||
static void serialize32(uint32_t a)
|
||||
{
|
||||
static uint8_t t;
|
||||
t = a;
|
||||
serialWrite(mspSerialPort, t);
|
||||
currentPort->checksum ^= t;
|
||||
t = a >> 8;
|
||||
serialWrite(mspSerialPort, t);
|
||||
currentPort->checksum ^= t;
|
||||
t = a >> 16;
|
||||
serialWrite(mspSerialPort, t);
|
||||
currentPort->checksum ^= t;
|
||||
t = a >> 24;
|
||||
serialWrite(mspSerialPort, t);
|
||||
currentPort->checksum ^= t;
|
||||
}
|
||||
|
||||
static void serialize16(int16_t a)
|
||||
{
|
||||
static uint8_t t;
|
||||
t = a;
|
||||
serialWrite(mspSerialPort, t);
|
||||
currentPort->checksum ^= t;
|
||||
t = a >> 8 & 0xff;
|
||||
serialWrite(mspSerialPort, t);
|
||||
currentPort->checksum ^= t;
|
||||
}
|
||||
|
||||
static void serialize8(uint8_t a)
|
||||
{
|
||||
serialWrite(mspSerialPort, a);
|
||||
currentPort->checksum ^= a;
|
||||
}
|
||||
|
||||
static void serialize16(uint16_t a)
|
||||
{
|
||||
serialize8((uint8_t)(a >> 0));
|
||||
serialize8((uint8_t)(a >> 8));
|
||||
}
|
||||
|
||||
static void serialize32(uint32_t a)
|
||||
{
|
||||
serialize16((uint16_t)(a >> 0));
|
||||
serialize16((uint16_t)(a >> 16));
|
||||
}
|
||||
|
||||
static uint8_t read8(void)
|
||||
{
|
||||
return currentPort->inBuf[currentPort->indRX++] & 0xff;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue