ardupilot/libraries/AP_HAL_ChibiOS/hwdef/common/bouncebuffer.h
Andrew Tridgell 26d1371d25 HAL_ChibiOS: separate out DMA allocation for sdcard IO
this fixes an issue with DMA to SPI6 on STM32H7. On the H7 SRAM4 can
be used for DMA and BDMA to all devices except for SDMMC which uses
IDMA.

by separating out DMA of sdcard data from other data we can arrange
for DMA to all devices to work
2019-03-09 07:33:47 +11:00

50 lines
1.2 KiB
C

/*
bouncebuffer code for supporting ChibiOS drivers that use DMA, but may be passed memory that
is not DMA safe.
This API assumes that there will be only one user of a bouncebuffer at a time
*/
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
struct bouncebuffer_t {
uint8_t *dma_buf;
uint8_t *orig_buf;
uint32_t size;
bool busy;
bool is_sdcard;
};
/*
initialise a bouncebuffer
*/
void bouncebuffer_init(struct bouncebuffer_t **bouncebuffer, uint32_t prealloc_bytes, bool sdcard);
/*
setup for reading from a device into memory, allocating a bouncebuffer if needed
*/
void bouncebuffer_setup_read(struct bouncebuffer_t *bouncebuffer, uint8_t **buf, uint32_t size);
/*
finish a read operation
*/
void bouncebuffer_finish_read(struct bouncebuffer_t *bouncebuffer, const uint8_t *buf, uint32_t size);
/*
setup for reading from memory to a device, allocating a bouncebuffer if needed
*/
void bouncebuffer_setup_write(struct bouncebuffer_t *bouncebuffer, const uint8_t **buf, uint32_t size);
/*
finish a write operation
*/
void bouncebuffer_finish_write(struct bouncebuffer_t *bouncebuffer, const uint8_t *buf);
#ifdef __cplusplus
}
#endif