HAL_PX4: change dma_allocate api to malloc_type

This commit is contained in:
bugobliterator 2018-01-10 03:12:54 +05:30 committed by Andrew Tridgell
parent 9d6ab78376
commit e591265329
2 changed files with 15 additions and 7 deletions

View File

@ -244,18 +244,26 @@ extern "C" {
allocate DMA-capable memory if possible. Otherwise return normal allocate DMA-capable memory if possible. Otherwise return normal
memory. memory.
*/ */
void *PX4Util::dma_allocate(size_t size) void *PX4Util::malloc_type(size_t size, AP_HAL::Util::Memory_Type mem_type)
{ {
#if !defined(CONFIG_ARCH_BOARD_PX4FMU_V1) #if !defined(CONFIG_ARCH_BOARD_PX4FMU_V1)
return fat_dma_alloc(size); if (mem_type == AP_HAL::Util::MEM_DMA_SAFE) {
return fat_dma_alloc(size);
} else {
return malloc(size);
}
#else #else
return malloc(size); return malloc(size);
#endif #endif
} }
void PX4Util::dma_free(void *ptr, size_t size) void PX4Util::free_type(void *ptr, size_t size, AP_HAL::Util::Memory_Type mem_type)
{ {
#if !defined(CONFIG_ARCH_BOARD_PX4FMU_V1) #if !defined(CONFIG_ARCH_BOARD_PX4FMU_V1)
fat_dma_free(ptr, size); if (mem_type == AP_HAL::Util::MEM_DMA_SAFE) {
return fat_dma_free(ptr, size);
} else {
return free(ptr);
}
#else #else
return free(ptr); return free(ptr);
#endif #endif

View File

@ -62,9 +62,9 @@ public:
void set_imu_target_temp(int8_t *target) override; void set_imu_target_temp(int8_t *target) override;
// allocate and free DMA-capable memory if possible. Otherwise return normal memory // allocate and free DMA-capable memory if possible. Otherwise return normal memory
void *dma_allocate(size_t size) override; void *malloc_type(size_t size, AP_HAL::Util::Memory_Type mem_type) override;
void dma_free(void *ptr, size_t size) override; void free_type(void *ptr, size_t size, AP_HAL::Util::Memory_Type mem_type) override;
private: private:
int _safety_handle; int _safety_handle;
PX4::NSHShellStream _shell_stream; PX4::NSHShellStream _shell_stream;