mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-23 16:25:31 +03:00
Adding some const qualifiers
This commit is contained in:
parent
806f43cdbf
commit
d48496c988
6 changed files with 19 additions and 16 deletions
|
@ -173,11 +173,12 @@ void pwmCompleteOneshotMotorUpdate(uint8_t motorCount)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void motorInit(motorConfig_t *motorConfig, uint16_t idlePulse, uint8_t motorCount)
|
void motorInit(const motorConfig_t *motorConfig, uint16_t idlePulse, uint8_t motorCount)
|
||||||
{
|
{
|
||||||
uint32_t timerMhzCounter;
|
uint32_t timerMhzCounter;
|
||||||
pwmWriteFuncPtr pwmWritePtr;
|
pwmWriteFuncPtr pwmWritePtr;
|
||||||
|
bool useUnsyncedPwm = motorConfig->useUnsyncedPwm;
|
||||||
|
|
||||||
switch (motorConfig->motorPwmProtocol) {
|
switch (motorConfig->motorPwmProtocol) {
|
||||||
default:
|
default:
|
||||||
case (PWM_TYPE_ONESHOT125):
|
case (PWM_TYPE_ONESHOT125):
|
||||||
|
@ -195,17 +196,17 @@ void motorInit(motorConfig_t *motorConfig, uint16_t idlePulse, uint8_t motorCoun
|
||||||
case (PWM_TYPE_BRUSHED):
|
case (PWM_TYPE_BRUSHED):
|
||||||
timerMhzCounter = PWM_BRUSHED_TIMER_MHZ;
|
timerMhzCounter = PWM_BRUSHED_TIMER_MHZ;
|
||||||
pwmWritePtr = pwmWriteBrushed;
|
pwmWritePtr = pwmWriteBrushed;
|
||||||
motorConfig->useUnsyncedPwm = true;
|
useUnsyncedPwm = true;
|
||||||
idlePulse = 0;
|
idlePulse = 0;
|
||||||
break;
|
break;
|
||||||
case (PWM_TYPE_STANDARD):
|
case (PWM_TYPE_STANDARD):
|
||||||
timerMhzCounter = PWM_TIMER_MHZ;
|
timerMhzCounter = PWM_TIMER_MHZ;
|
||||||
pwmWritePtr = pwmWriteStandard;
|
pwmWritePtr = pwmWriteStandard;
|
||||||
motorConfig->useUnsyncedPwm = true;
|
useUnsyncedPwm = true;
|
||||||
idlePulse = 0;
|
idlePulse = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int motorIndex = 0; motorIndex < MAX_SUPPORTED_MOTORS && motorIndex < motorCount; motorIndex++) {
|
for (int motorIndex = 0; motorIndex < MAX_SUPPORTED_MOTORS && motorIndex < motorCount; motorIndex++) {
|
||||||
ioTag_t tag = motorConfig->ioTags[motorIndex];
|
ioTag_t tag = motorConfig->ioTags[motorIndex];
|
||||||
|
|
||||||
|
@ -226,7 +227,7 @@ void motorInit(motorConfig_t *motorConfig, uint16_t idlePulse, uint8_t motorCoun
|
||||||
}
|
}
|
||||||
|
|
||||||
motors[motorIndex].pwmWritePtr = pwmWritePtr;
|
motors[motorIndex].pwmWritePtr = pwmWritePtr;
|
||||||
if (motorConfig->useUnsyncedPwm) {
|
if (useUnsyncedPwm) {
|
||||||
const uint32_t hz = timerMhzCounter * 1000000;
|
const uint32_t hz = timerMhzCounter * 1000000;
|
||||||
pwmOutConfig(&motors[motorIndex], timer, timerMhzCounter, hz / motorConfig->motorPwmProtocol, idlePulse);
|
pwmOutConfig(&motors[motorIndex], timer, timerMhzCounter, hz / motorConfig->motorPwmProtocol, idlePulse);
|
||||||
} else {
|
} else {
|
||||||
|
@ -249,7 +250,7 @@ void pwmWriteServo(uint8_t index, uint16_t value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void servoInit(servoConfig_t *servoConfig)
|
void servoInit(const servoConfig_t *servoConfig)
|
||||||
{
|
{
|
||||||
for (uint8_t servoIndex = 0; servoIndex < MAX_SUPPORTED_SERVOS; servoIndex++) {
|
for (uint8_t servoIndex = 0; servoIndex < MAX_SUPPORTED_SERVOS; servoIndex++) {
|
||||||
ioTag_t tag = servoConfig->ioTags[servoIndex];
|
ioTag_t tag = servoConfig->ioTags[servoIndex];
|
||||||
|
|
|
@ -55,8 +55,8 @@ typedef struct {
|
||||||
IO_t io;
|
IO_t io;
|
||||||
} pwmOutputPort_t;
|
} pwmOutputPort_t;
|
||||||
|
|
||||||
void motorInit(motorConfig_t *motorConfig, uint16_t idlePulse, uint8_t motorCount);
|
void motorInit(const motorConfig_t *motorConfig, uint16_t idlePulse, uint8_t motorCount);
|
||||||
void servoInit(servoConfig_t *servoConfig);
|
void servoInit(const servoConfig_t *servoConfig);
|
||||||
|
|
||||||
void pwmServoConfig(const struct timerHardware_s *timerHardware, uint8_t servoIndex, uint16_t servoPwmRate, uint16_t servoCenterPulse);
|
void pwmServoConfig(const struct timerHardware_s *timerHardware, uint8_t servoIndex, uint16_t servoPwmRate, uint16_t servoCenterPulse);
|
||||||
|
|
||||||
|
|
|
@ -392,7 +392,8 @@ int beeperTableEntryCount(void)
|
||||||
/*
|
/*
|
||||||
* Returns true if the beeper is on, false otherwise
|
* Returns true if the beeper is on, false otherwise
|
||||||
*/
|
*/
|
||||||
bool isBeeperOn(void) {
|
bool isBeeperOn(void)
|
||||||
|
{
|
||||||
return beeperIsOn;
|
return beeperIsOn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -280,8 +280,11 @@ void init(void)
|
||||||
pwmRxSetInputFilteringMode(masterConfig.inputFilteringMode);
|
pwmRxSetInputFilteringMode(masterConfig.inputFilteringMode);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
mixerUsePWMOutputConfiguration(masterConfig.motorConfig.useUnsyncedPwm);
|
bool usingUnsyncedOutput = (masterConfig.motorConfig.useUnsyncedPwm
|
||||||
|
|| masterConfig.motorConfig.motorPwmProtocol == PWM_TYPE_BRUSHED
|
||||||
|
|| masterConfig.motorConfig.motorPwmProtocol == PWM_TYPE_STANDARD);
|
||||||
|
mixerUsePWMOutputConfiguration(usingUnsyncedOutput);
|
||||||
|
|
||||||
systemState |= SYSTEM_STATE_MOTORS_READY;
|
systemState |= SYSTEM_STATE_MOTORS_READY;
|
||||||
|
|
||||||
#ifdef BEEPER
|
#ifdef BEEPER
|
||||||
|
|
|
@ -50,7 +50,7 @@ float sonarMaxTiltCos;
|
||||||
|
|
||||||
static int32_t calculatedAltitude;
|
static int32_t calculatedAltitude;
|
||||||
|
|
||||||
void sonarInit(sonarConfig_t *sonarConfig)
|
void sonarInit(const sonarConfig_t *sonarConfig)
|
||||||
{
|
{
|
||||||
sonarRange_t sonarRange;
|
sonarRange_t sonarRange;
|
||||||
|
|
||||||
|
|
|
@ -26,9 +26,7 @@ extern int16_t sonarMaxRangeCm;
|
||||||
extern int16_t sonarCfAltCm;
|
extern int16_t sonarCfAltCm;
|
||||||
extern int16_t sonarMaxAltWithTiltCm;
|
extern int16_t sonarMaxAltWithTiltCm;
|
||||||
|
|
||||||
struct sonarHardware_s;
|
void sonarInit(const sonarConfig_t *sonarConfig);
|
||||||
const struct sonarHardware_s *sonarGetHardwareConfiguration(currentSensor_e currentSensor);
|
|
||||||
void sonarInit(sonarConfig_t *sonarConfig);
|
|
||||||
void sonarUpdate(void);
|
void sonarUpdate(void);
|
||||||
int32_t sonarRead(void);
|
int32_t sonarRead(void);
|
||||||
int32_t sonarCalculateAltitude(int32_t sonarDistance, float cosTiltAngle);
|
int32_t sonarCalculateAltitude(int32_t sonarDistance, float cosTiltAngle);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue