diff --git a/libraries/AP_HAL_PX4/Util.cpp b/libraries/AP_HAL_PX4/Util.cpp index 953d61d037..dce8882639 100644 --- a/libraries/AP_HAL_PX4/Util.cpp +++ b/libraries/AP_HAL_PX4/Util.cpp @@ -224,4 +224,23 @@ void PX4Util::set_imu_target_temp(int8_t *target) _heater.target = target; } + +extern "C" { + extern void *fat_dma_alloc(size_t); + extern void fat_dma_free(void *, size_t); +} + +/* + allocate DMA-capable memory if possible. Otherwise return normal + memory. +*/ +void *PX4Util::dma_allocate(size_t size) +{ + return fat_dma_alloc(size); +} +void PX4Util::dma_free(void *ptr, size_t size) +{ + fat_dma_free(ptr, size); +} + #endif // CONFIG_HAL_BOARD == HAL_BOARD_PX4 diff --git a/libraries/AP_HAL_PX4/Util.h b/libraries/AP_HAL_PX4/Util.h index f2ac3a3aa9..fea9323699 100644 --- a/libraries/AP_HAL_PX4/Util.h +++ b/libraries/AP_HAL_PX4/Util.h @@ -60,6 +60,10 @@ public: void set_imu_temp(float current) override; void set_imu_target_temp(int8_t *target) override; + + // allocate and free DMA-capable memory if possible. Otherwise return normal memory + void *dma_allocate(size_t size) override; + void dma_free(void *ptr, size_t size) override; private: int _safety_handle;