mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-23 00:05:33 +03:00
Add USE_LEDSTRIP_CACHE_MGMT option to use explicit cache management for LED strip.
Ensure DMA_RAM section is at start of RAM and the the region defining the shareable region is covered. Enable USE_LEDSTRIP_CACHE_MGMT on NUCLEOH743 target
This commit is contained in:
parent
57c9c12781
commit
cb908a6893
7 changed files with 42 additions and 15 deletions
|
@ -50,8 +50,6 @@ REGION_ALIAS("STACKRAM", DTCM_RAM)
|
|||
REGION_ALIAS("FASTRAM", DTCM_RAM)
|
||||
REGION_ALIAS("MAIN", FLASH)
|
||||
|
||||
INCLUDE "stm32_h750_common.ld"
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.DMA_RAM (NOLOAD) :
|
||||
|
@ -91,4 +89,5 @@ SECTIONS
|
|||
} >RAM
|
||||
}
|
||||
|
||||
INCLUDE "stm32_h750_common.ld"
|
||||
INCLUDE "stm32_h750_common_post.ld"
|
||||
|
|
|
@ -50,8 +50,6 @@ REGION_ALIAS("STACKRAM", DTCM_RAM)
|
|||
REGION_ALIAS("FASTRAM", DTCM_RAM)
|
||||
REGION_ALIAS("MAIN", FLASH)
|
||||
|
||||
INCLUDE "stm32_h750_common.ld"
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.DMA_RAM (NOLOAD) :
|
||||
|
@ -91,4 +89,5 @@ SECTIONS
|
|||
} >RAM
|
||||
}
|
||||
|
||||
INCLUDE "stm32_h750_common.ld"
|
||||
INCLUDE "stm32_h750_common_post.ld"
|
||||
|
|
|
@ -73,8 +73,6 @@ REGION_ALIAS("STACKRAM", DTCM_RAM)
|
|||
REGION_ALIAS("FASTRAM", DTCM_RAM)
|
||||
REGION_ALIAS("MAIN", CODE_RAM)
|
||||
|
||||
INCLUDE "stm32_h750_common.ld"
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.DMA_RAM (NOLOAD) :
|
||||
|
@ -114,6 +112,7 @@ SECTIONS
|
|||
} >RAM
|
||||
}
|
||||
|
||||
INCLUDE "stm32_h750_common.ld"
|
||||
INCLUDE "stm32_h750_common_post.ld"
|
||||
INCLUDE "stm32_ram_h750_exst_post.ld"
|
||||
|
||||
|
|
|
@ -44,6 +44,16 @@
|
|||
|
||||
#include "light_ws2811strip.h"
|
||||
|
||||
#ifdef USE_LEDSTRIP_CACHE_MGMT
|
||||
// WS2811_DMA_BUFFER_SIZE is multiples of uint32_t
|
||||
// Number of bytes required for buffer
|
||||
#define WS2811_DMA_BUF_BYTES (WS2811_DMA_BUFFER_SIZE * sizeof (uint32_t))
|
||||
// Number of bytes required to cache align buffer
|
||||
#define WS2811_DMA_BUF_CACHE_ALIGN_BYTES ((WS2811_DMA_BUF_BYTES + 0x20) & ~0x1f)
|
||||
// Size of array to create a cache aligned buffer
|
||||
#define WS2811_DMA_BUF_CACHE_ALIGN_LENGTH (WS2811_DMA_BUF_CACHE_ALIGN_BYTES / sizeof (uint32_t))
|
||||
__attribute__((aligned(32))) uint32_t ledStripDMABuffer[WS2811_DMA_BUF_CACHE_ALIGN_LENGTH];
|
||||
#else
|
||||
#if defined(STM32F1) || defined(STM32F3)
|
||||
uint8_t ledStripDMABuffer[WS2811_DMA_BUFFER_SIZE];
|
||||
#elif defined(STM32F7)
|
||||
|
@ -53,6 +63,7 @@ DMA_RAM uint32_t ledStripDMABuffer[WS2811_DMA_BUFFER_SIZE];
|
|||
#else
|
||||
uint32_t ledStripDMABuffer[WS2811_DMA_BUFFER_SIZE];
|
||||
#endif
|
||||
#endif
|
||||
|
||||
static ioTag_t ledStripIoTag;
|
||||
static bool ws2811Initialised = false;
|
||||
|
@ -184,6 +195,10 @@ void ws2811UpdateStrip(ledStripFormatRGB_e ledFormat)
|
|||
}
|
||||
needsFullRefresh = false;
|
||||
|
||||
#ifdef USE_LEDSTRIP_CACHE_MGMT
|
||||
SCB_CleanDCache_by_Addr(ledStripDMABuffer, WS2811_DMA_BUF_CACHE_ALIGN_BYTES);
|
||||
#endif
|
||||
|
||||
ws2811LedDataTransferInProgress = true;
|
||||
ws2811LedStripDMAEnable();
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#if defined(USE_WS2811_SINGLE_COLOUR)
|
||||
#define WS2811_DATA_BUFFER_SIZE 1
|
||||
#define WS2811_DMA_BUFFER_SIZE (WS2811_DATA_BUFFER_SIZE * WS2811_BITS_PER_LED)
|
||||
// Do 2 extra iterations of the DMA transfer with the ouptut set to low to generate the > 50us delay.
|
||||
// Do 2 extra iterations of the DMA transfer with the output set to low to generate the > 50us delay.
|
||||
#define WS2811_DELAY_ITERATIONS 2
|
||||
#else
|
||||
#define WS2811_DATA_BUFFER_SIZE WS2811_LED_STRIP_LENGTH
|
||||
|
@ -41,6 +41,23 @@
|
|||
#define WS2811_DMA_BUFFER_SIZE (WS2811_DATA_BUFFER_SIZE * WS2811_BITS_PER_LED + WS2811_DELAY_BUFFER_LENGTH)
|
||||
#endif
|
||||
|
||||
#ifdef USE_LEDSTRIP_CACHE_MGMT
|
||||
// WS2811_DMA_BUFFER_SIZE is multiples of uint32_t
|
||||
// Number of bytes required for buffer
|
||||
#define WS2811_DMA_BUF_BYTES (WS2811_DMA_BUFFER_SIZE * sizeof (uint32_t))
|
||||
// Number of bytes required to cache align buffer
|
||||
#define WS2811_DMA_BUF_CACHE_ALIGN_BYTES ((WS2811_DMA_BUF_BYTES + 0x20) & ~0x1f)
|
||||
// Size of array to create a cache aligned buffer
|
||||
#define WS2811_DMA_BUF_CACHE_ALIGN_LENGTH (WS2811_DMA_BUF_CACHE_ALIGN_BYTES / sizeof (uint32_t))
|
||||
extern uint32_t ledStripDMABuffer[WS2811_DMA_BUF_CACHE_ALIGN_LENGTH];
|
||||
#else
|
||||
#if defined(STM32F1) || defined(STM32F3)
|
||||
extern uint8_t ledStripDMABuffer[WS2811_DMA_BUFFER_SIZE];
|
||||
#else
|
||||
extern uint32_t ledStripDMABuffer[WS2811_DMA_BUFFER_SIZE];
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define WS2811_TIMER_MHZ 48
|
||||
#define WS2811_CARRIER_HZ 800000
|
||||
|
||||
|
@ -71,11 +88,6 @@ void setUsedLedCount(unsigned ledCount);
|
|||
|
||||
bool isWS2811LedStripReady(void);
|
||||
|
||||
#if defined(STM32F1) || defined(STM32F3)
|
||||
extern uint8_t ledStripDMABuffer[WS2811_DMA_BUFFER_SIZE];
|
||||
#else
|
||||
extern uint32_t ledStripDMABuffer[WS2811_DMA_BUFFER_SIZE];
|
||||
#endif
|
||||
extern volatile bool ws2811LedDataTransferInProgress;
|
||||
|
||||
extern uint16_t BIT_COMPARE_1;
|
||||
|
|
|
@ -68,7 +68,7 @@ void memProtConfigure(mpuRegion_t *regions, unsigned regionCount)
|
|||
|
||||
int msbpos = flsl(length) - 1;
|
||||
|
||||
if (length == (1U << msbpos)) {
|
||||
if (length != (1U << msbpos)) {
|
||||
msbpos += 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,6 +29,9 @@
|
|||
#define LED1_PIN PB7 // PE1 on NUCLEO-H743ZI2 (may collide with UART8_TX)
|
||||
//#define LED2_PIN PB14 // SDMMC2_D0
|
||||
|
||||
// Use explicit cache management as per https://github.com/betaflight/betaflight/pull/10378
|
||||
#define USE_LEDSTRIP_CACHE_MGMT
|
||||
|
||||
// Nucleo-H743 has one button (The blue USER button).
|
||||
// Force two buttons to look at the single button so config reset on button works
|
||||
#define USE_BUTTONS
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue