Skip to content

Commit

Permalink
AP_HAL_ChibiOS: remove dependency on Semaphores in QSPIDevice in BL
Browse files Browse the repository at this point in the history
  • Loading branch information
bugobliterator authored and tridge committed Sep 1, 2021
1 parent 1afbf66 commit 39bd229
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
8 changes: 8 additions & 0 deletions libraries/AP_HAL_ChibiOS/Device.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@

#include <inttypes.h>
#include <AP_HAL/HAL.h>
#if !defined(HAL_BOOTLOADER_BUILD)
#include "Semaphores.h"
#else
#include <AP_HAL_Empty/Semaphores.h>
#endif
#include "AP_HAL_ChibiOS.h"

#if HAL_USE_I2C == TRUE || HAL_USE_SPI == TRUE || HAL_USE_WSPI == TRUE
Expand All @@ -34,7 +38,11 @@ class DeviceBus {
DeviceBus(uint8_t _thread_priority, bool axi_sram);

struct DeviceBus *next;
#if defined(HAL_BOOTLOADER_BUILD)
Empty::Semaphore semaphore;
#else
Semaphore semaphore;
#endif
Shared_DMA *dma_handle;

AP_HAL::Device::PeriodicHandle register_periodic_callback(uint32_t period_usec, AP_HAL::Device::PeriodicCb, AP_HAL::Device *hal_device);
Expand Down
1 change: 0 additions & 1 deletion libraries/AP_HAL_ChibiOS/QSPIDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include <AP_InternalError/AP_InternalError.h>
#include "Util.h"
#include "Scheduler.h"
#include "Semaphores.h"
#include <stdio.h>
#include "hwdef/common/stm32_util.h"

Expand Down
7 changes: 7 additions & 0 deletions libraries/AP_HAL_ChibiOS/QSPIDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@

#if HAL_USE_WSPI == TRUE && defined(HAL_QSPI_DEVICE_LIST)

#if !defined(HAL_BOOTLOADER_BUILD)
#include "Semaphores.h"
#endif

#include "Scheduler.h"
#include "Device.h"

Expand Down Expand Up @@ -99,8 +102,12 @@ class QSPIDevice : public AP_HAL::QSPIDevice

AP_HAL::Semaphore* get_semaphore() override
{
#if !defined(HAL_BOOTLOADER_BUILD)
// if asking for invalid bus number use bus 0 semaphore
return &bus.semaphore;
#else
return nullptr;
#endif
}

bool acquire_bus(bool acquire);
Expand Down
10 changes: 5 additions & 5 deletions libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py
Original file line number Diff line number Diff line change
Expand Up @@ -884,19 +884,19 @@ def write_mcu_config(f):
#define HAL_NO_RCIN_THREAD
#define HAL_NO_SHARED_DMA FALSE
#define HAL_NO_ROMFS_SUPPORT TRUE
''')
if not env_vars['EXTERNAL_PROG_FLASH_MB']:
f.write('''
#define CH_CFG_USE_TM FALSE
#define CH_CFG_USE_REGISTRY FALSE
#define CH_CFG_USE_WAITEXIT FALSE
#define CH_CFG_USE_MEMPOOLS FALSE
#define CH_DBG_FILL_THREADS FALSE
#define CH_CFG_USE_SEMAPHORES FALSE
#define CH_CFG_USE_HEAP FALSE
#define CH_CFG_USE_MUTEXES FALSE
#define CH_CFG_USE_EVENTS FALSE
#define CH_CFG_USE_EVENTS_TIMEOUT FALSE
''')
if not env_vars['EXTERNAL_PROG_FLASH_MB']:
f.write('''
#define CH_CFG_USE_HEAP FALSE
#define CH_CFG_USE_SEMAPHORES FALSE
#define CH_CFG_USE_MEMCORE FALSE
''')
if env_vars.get('ROMFS_UNCOMPRESSED', False):
Expand Down

0 comments on commit 39bd229

Please sign in to comment.