mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-20 06:45:16 +03:00
Improvement - Ensure memory used only during system init is returned to
the heap. This saves at least 18 bytes of ram.
This commit is contained in:
parent
eeb13b427d
commit
56d6e9012f
1 changed files with 25 additions and 14 deletions
25
src/main.c
25
src/main.c
|
@ -48,6 +48,10 @@ extern rcReadRawDataPtr rcReadRawFunc;
|
||||||
|
|
||||||
extern uint32_t previousTime;
|
extern uint32_t previousTime;
|
||||||
|
|
||||||
|
#ifdef SOFTSERIAL_LOOPBACK
|
||||||
|
serialPort_t *loopbackPort
|
||||||
|
#endif
|
||||||
|
|
||||||
failsafe_t *failsafe;
|
failsafe_t *failsafe;
|
||||||
|
|
||||||
void initPrintfSupport(void);
|
void initPrintfSupport(void);
|
||||||
|
@ -86,11 +90,11 @@ void productionDebug(void)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int main(void)
|
void init(void)
|
||||||
{
|
{
|
||||||
uint8_t i;
|
uint8_t i;
|
||||||
drv_pwm_config_t pwm_params; // FIXME never freed, remains on heap
|
drv_pwm_config_t pwm_params;
|
||||||
drv_adc_config_t adc_params; // FIXME never freed, remains on heap
|
drv_adc_config_t adc_params;
|
||||||
bool sensorsOK = false;
|
bool sensorsOK = false;
|
||||||
|
|
||||||
initPrintfSupport();
|
initPrintfSupport();
|
||||||
|
@ -233,20 +237,27 @@ int main(void)
|
||||||
}
|
}
|
||||||
serialPrint(loopbackPort, "LOOPBACK\r\n");
|
serialPrint(loopbackPort, "LOOPBACK\r\n");
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
// loopy
|
|
||||||
while (1) {
|
|
||||||
loop();
|
|
||||||
|
|
||||||
#ifdef SOFTSERIAL_LOOPBACK
|
#ifdef SOFTSERIAL_LOOPBACK
|
||||||
|
void processLoopback(void) {
|
||||||
if (loopbackPort) {
|
if (loopbackPort) {
|
||||||
while (serialTotalBytesWaiting(loopbackPort)) {
|
while (serialTotalBytesWaiting(loopbackPort)) {
|
||||||
uint8_t b = serialRead(loopbackPort);
|
uint8_t b = serialRead(loopbackPort);
|
||||||
serialWrite(loopbackPort, b);
|
serialWrite(loopbackPort, b);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
#define processLoopback()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
init();
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
loop();
|
||||||
|
processLoopback();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue