1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-16 04:45:24 +03:00

F7 optimizations (#5674)

* Revert "Revert "Rewritten F7 dshot to LL (draft)" (#5430)"

This reverts commit aa42a69d2f.

* Reworked F7 linker scripts to maximize performance of both F74x and F72x

* Some comments and changes from original F7 HAL DSHOT

* Prohibit inlining of some functions to place them in ITCM-RAM

* Fixed usartTargetConfigure implicit declaration

* Moved back to SRAM1 as main RAM

* Added SRAM2 attribute

* Fixed LL DSHOT FOR SPRF7DUAL and probably other adv TIM users

* Fixed SPRF7DUAL rev. A motor order

* Enabled CCM for data on F40x

* Fixed F7 startup assembly symbols

* Fixed KISSFCV2F7 linker script

* Added a quick way of building F7 targets only

* Got rid of the useless F7 target script

* Added NOINLINE and got rid of useless __APPLE__ define

* Added some important functions to ITCM

* Added NOINLINE macro for tests

* Copy to ITCM before passing execution into it

* Minimized cache footprint of motor output code

* Evicted low-impact functions from ITCM

* Switched MATEKF722 and SPRACINGF7DUAL to burst DSHOT

* Switched CLRACINGF7 to burst DSHOT

* Moved UART RX&TX buffers to DTCM-RAM to avoid cache incoherency

* Marked taskMainPidLoop for ITCM-RAM, disallowed inlining per-function

* Revert "Added a quick way of building F7 targets only"

This reverts commit 2294518998.
This commit is contained in:
Andrey Mironov 2018-04-19 23:37:32 +03:00 committed by Michael Keller
parent 39fec69fb0
commit bf984f39b1
34 changed files with 503 additions and 345 deletions

View file

@ -28,12 +28,12 @@
#include "timer.h"
#include "drivers/pwm_output.h"
static pwmWriteFn *pwmWrite;
static pwmOutputPort_t motors[MAX_SUPPORTED_MOTORS];
static pwmCompleteWriteFn *pwmCompleteWrite = NULL;
static FAST_RAM pwmWriteFn *pwmWrite;
static FAST_RAM pwmOutputPort_t motors[MAX_SUPPORTED_MOTORS];
static FAST_RAM pwmCompleteWriteFn *pwmCompleteWrite = NULL;
#ifdef USE_DSHOT
loadDmaBufferFn *loadDmaBuffer;
FAST_RAM loadDmaBufferFn *loadDmaBuffer;
#endif
#ifdef USE_SERVOS
@ -48,7 +48,7 @@ static uint16_t freqBeep = 0;
static bool pwmMotorsEnabled = false;
static bool isDshot = false;
#ifdef USE_DSHOT_DMAR
bool useBurstDshot = false;
FAST_RAM bool useBurstDshot = false;
#endif
static void pwmOCConfig(TIM_TypeDef *tim, uint8_t channel, uint16_t value, uint8_t output)
@ -135,12 +135,12 @@ static void pwmWriteStandard(uint8_t index, float value)
}
#ifdef USE_DSHOT
static void pwmWriteDshot(uint8_t index, float value)
static FAST_CODE void pwmWriteDshot(uint8_t index, float value)
{
pwmWriteDshotInt(index, lrintf(value));
}
static uint8_t loadDmaBufferDshot(uint32_t *dmaBuffer, int stride, uint16_t packet)
static FAST_CODE uint8_t loadDmaBufferDshot(uint32_t *dmaBuffer, int stride, uint16_t packet)
{
for (int i = 0; i < 16; i++) {
dmaBuffer[i * stride] = (packet & 0x8000) ? MOTOR_BIT_1 : MOTOR_BIT_0; // MSB first
@ -405,7 +405,7 @@ void pwmWriteDshotCommand(uint8_t index, uint8_t motorCount, uint8_t command)
}
}
uint16_t prepareDshotPacket(motorDmaOutput_t *const motor, const uint16_t value)
FAST_CODE uint16_t prepareDshotPacket(motorDmaOutput_t *const motor, const uint16_t value)
{
uint16_t packet = (value << 1) | (motor->requestTelemetry ? 1 : 0);
motor->requestTelemetry = false; // reset telemetry request to make sure it's triggered only once in a row