HAL_ChibiOS: added preallocation of DMA bouncebuffers

we need 512 bytes for microSD
This commit is contained in:
Andrew Tridgell 2018-07-12 13:12:21 +10:00
parent e193a161f2
commit f083b80700
4 changed files with 10 additions and 5 deletions

View File

@ -31,8 +31,8 @@ static const AP_HAL::HAL &hal = AP_HAL::get_HAL();
DeviceBus::DeviceBus(uint8_t _thread_priority) : DeviceBus::DeviceBus(uint8_t _thread_priority) :
thread_priority(_thread_priority) thread_priority(_thread_priority)
{ {
bouncebuffer_init(&bounce_buffer_tx); bouncebuffer_init(&bounce_buffer_tx, 10);
bouncebuffer_init(&bounce_buffer_rx); bouncebuffer_init(&bounce_buffer_rx, 10);
} }
/* /*

View File

@ -32,10 +32,15 @@
/* /*
initialise a bouncebuffer initialise a bouncebuffer
*/ */
void bouncebuffer_init(struct bouncebuffer_t **bouncebuffer) void bouncebuffer_init(struct bouncebuffer_t **bouncebuffer, uint32_t prealloc_bytes)
{ {
(*bouncebuffer) = calloc(1, sizeof(struct bouncebuffer_t)); (*bouncebuffer) = calloc(1, sizeof(struct bouncebuffer_t));
osalDbgAssert(((*bouncebuffer) != NULL), "bouncebuffer init"); osalDbgAssert(((*bouncebuffer) != NULL), "bouncebuffer init");
if (prealloc_bytes) {
(*bouncebuffer)->dma_buf = malloc_dma(prealloc_bytes);
osalDbgAssert(((*bouncebuffer)->dma_buf != NULL), "bouncebuffer preallocate");
(*bouncebuffer)->size = prealloc_bytes;
}
} }
/* /*

View File

@ -21,7 +21,7 @@ struct bouncebuffer_t {
/* /*
initialise a bouncebuffer initialise a bouncebuffer
*/ */
void bouncebuffer_init(struct bouncebuffer_t **bouncebuffer); void bouncebuffer_init(struct bouncebuffer_t **bouncebuffer, uint32_t prealloc_bytes);
/* /*
setup for reading from a device into memory, allocating a bouncebuffer if needed setup for reading from a device into memory, allocating a bouncebuffer if needed

View File

@ -46,7 +46,7 @@ void sdcard_init()
sdcard_init_done = true; sdcard_init_done = true;
#if HAL_USE_SDC #if HAL_USE_SDC
bouncebuffer_init(&SDCD1.bouncebuffer); bouncebuffer_init(&SDCD1.bouncebuffer, 512);
sdcStart(&SDCD1, NULL); sdcStart(&SDCD1, NULL);