mirror of https://github.com/ArduPilot/ardupilot
AP_HAL_ChibiOS: use NEW_NOTHROW for new(std::nothrow)
This commit is contained in:
parent
375eab8560
commit
8dbad82c8a
|
@ -770,7 +770,7 @@ AP_HAL::AnalogSource* AnalogIn::channel(int16_t pin)
|
||||||
WITH_SEMAPHORE(_semaphore);
|
WITH_SEMAPHORE(_semaphore);
|
||||||
for (uint8_t j=0; j<ANALOG_MAX_CHANNELS; j++) {
|
for (uint8_t j=0; j<ANALOG_MAX_CHANNELS; j++) {
|
||||||
if (_channels[j] == nullptr) {
|
if (_channels[j] == nullptr) {
|
||||||
_channels[j] = new AnalogSource(pin);
|
_channels[j] = NEW_NOTHROW AnalogSource(pin);
|
||||||
return _channels[j];
|
return _channels[j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -847,7 +847,7 @@ bool CANIface::init(const uint32_t bitrate, const CANIface::OperatingMode mode)
|
||||||
mode_ = mode;
|
mode_ = mode;
|
||||||
|
|
||||||
if (can_ifaces[0] == nullptr) {
|
if (can_ifaces[0] == nullptr) {
|
||||||
can_ifaces[0] = new CANIface(0);
|
can_ifaces[0] = NEW_NOTHROW CANIface(0);
|
||||||
Debug("Failed to allocate CAN iface 0");
|
Debug("Failed to allocate CAN iface 0");
|
||||||
if (can_ifaces[0] == nullptr) {
|
if (can_ifaces[0] == nullptr) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -52,7 +52,7 @@ extern const AP_HAL::HAL& hal;
|
||||||
// initialize the FFT state machine
|
// initialize the FFT state machine
|
||||||
AP_HAL::DSP::FFTWindowState* DSP::fft_init(uint16_t window_size, uint16_t sample_rate, uint8_t sliding_window_size)
|
AP_HAL::DSP::FFTWindowState* DSP::fft_init(uint16_t window_size, uint16_t sample_rate, uint8_t sliding_window_size)
|
||||||
{
|
{
|
||||||
DSP::FFTWindowStateARM* fft = new DSP::FFTWindowStateARM(window_size, sample_rate, sliding_window_size);
|
DSP::FFTWindowStateARM* fft = NEW_NOTHROW DSP::FFTWindowStateARM(window_size, sample_rate, sliding_window_size);
|
||||||
if (fft == nullptr || fft->_hanning_window == nullptr || fft->_rfft_data == nullptr || fft->_freq_bins == nullptr || fft->_derivative_freq_bins == nullptr) {
|
if (fft == nullptr || fft->_hanning_window == nullptr || fft->_rfft_data == nullptr || fft->_freq_bins == nullptr || fft->_derivative_freq_bins == nullptr) {
|
||||||
delete fft;
|
delete fft;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -134,7 +134,7 @@ AP_HAL::Device::PeriodicHandle DeviceBus::register_periodic_callback(uint32_t pe
|
||||||
AP_HAL::panic("Failed to create bus thread %s", name);
|
AP_HAL::panic("Failed to create bus thread %s", name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DeviceBus::callback_info *callback = new DeviceBus::callback_info;
|
DeviceBus::callback_info *callback = NEW_NOTHROW DeviceBus::callback_info;
|
||||||
if (callback == nullptr) {
|
if (callback == nullptr) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -285,14 +285,14 @@ AP_HAL::DigitalSource* GPIO::channel(uint16_t pin)
|
||||||
{
|
{
|
||||||
#if HAL_WITH_IO_MCU
|
#if HAL_WITH_IO_MCU
|
||||||
if (AP_BoardConfig::io_enabled() && iomcu.valid_GPIO_pin(pin)) {
|
if (AP_BoardConfig::io_enabled() && iomcu.valid_GPIO_pin(pin)) {
|
||||||
return new IOMCU_DigitalSource(pin);
|
return NEW_NOTHROW IOMCU_DigitalSource(pin);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
struct gpio_entry *g = gpio_by_pin_num(pin);
|
struct gpio_entry *g = gpio_by_pin_num(pin);
|
||||||
if (!g) {
|
if (!g) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return new DigitalSource(g->pal_line);
|
return NEW_NOTHROW DigitalSource(g->pal_line);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern const AP_HAL::HAL& hal;
|
extern const AP_HAL::HAL& hal;
|
||||||
|
|
|
@ -102,7 +102,7 @@ I2CBus I2CDeviceManager::businfo[ARRAY_SIZE(I2CD)];
|
||||||
void I2CBus::dma_init(void)
|
void I2CBus::dma_init(void)
|
||||||
{
|
{
|
||||||
chMtxObjectInit(&dma_lock);
|
chMtxObjectInit(&dma_lock);
|
||||||
dma_handle = new Shared_DMA(I2CD[busnum].dma_channel_tx, I2CD[busnum].dma_channel_rx,
|
dma_handle = NEW_NOTHROW Shared_DMA(I2CD[busnum].dma_channel_tx, I2CD[busnum].dma_channel_rx,
|
||||||
FUNCTOR_BIND_MEMBER(&I2CBus::dma_allocate, void, Shared_DMA *),
|
FUNCTOR_BIND_MEMBER(&I2CBus::dma_allocate, void, Shared_DMA *),
|
||||||
FUNCTOR_BIND_MEMBER(&I2CBus::dma_deallocate, void, Shared_DMA *));
|
FUNCTOR_BIND_MEMBER(&I2CBus::dma_deallocate, void, Shared_DMA *));
|
||||||
}
|
}
|
||||||
|
@ -459,7 +459,7 @@ I2CDeviceManager::get_device(uint8_t bus, uint8_t address,
|
||||||
if (bus >= ARRAY_SIZE(I2CD)) {
|
if (bus >= ARRAY_SIZE(I2CD)) {
|
||||||
return AP_HAL::OwnPtr<AP_HAL::I2CDevice>(nullptr);
|
return AP_HAL::OwnPtr<AP_HAL::I2CDevice>(nullptr);
|
||||||
}
|
}
|
||||||
auto dev = AP_HAL::OwnPtr<AP_HAL::I2CDevice>(new I2CDevice(bus, address, bus_clock, use_smbus, timeout_ms));
|
auto dev = AP_HAL::OwnPtr<AP_HAL::I2CDevice>(NEW_NOTHROW I2CDevice(bus, address, bus_clock, use_smbus, timeout_ms));
|
||||||
return dev;
|
return dev;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -945,7 +945,7 @@ bool RCOutput::setup_group_DMA(pwm_group &group, uint32_t bitrate, uint32_t bit_
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if (!group.dma_handle) {
|
if (!group.dma_handle) {
|
||||||
group.dma_handle = new Shared_DMA(group.dma_up_stream_id, SHARED_DMA_NONE,
|
group.dma_handle = NEW_NOTHROW Shared_DMA(group.dma_up_stream_id, SHARED_DMA_NONE,
|
||||||
FUNCTOR_BIND_MEMBER(&RCOutput::dma_allocate, void, Shared_DMA *),
|
FUNCTOR_BIND_MEMBER(&RCOutput::dma_allocate, void, Shared_DMA *),
|
||||||
FUNCTOR_BIND_MEMBER(&RCOutput::dma_deallocate, void, Shared_DMA *));
|
FUNCTOR_BIND_MEMBER(&RCOutput::dma_deallocate, void, Shared_DMA *));
|
||||||
if (!group.dma_handle) {
|
if (!group.dma_handle) {
|
||||||
|
@ -2565,7 +2565,7 @@ bool RCOutput::set_serial_led_rgb_data(const uint16_t chan, int8_t led, uint8_t
|
||||||
for (uint8_t j = 0; j < 4; j++) {
|
for (uint8_t j = 0; j < 4; j++) {
|
||||||
delete[] grp->serial_led_data[j];
|
delete[] grp->serial_led_data[j];
|
||||||
grp->serial_led_data[j] = nullptr;
|
grp->serial_led_data[j] = nullptr;
|
||||||
grp->serial_led_data[j] = new SerialLed[grp->serial_nleds];
|
grp->serial_led_data[j] = NEW_NOTHROW SerialLed[grp->serial_nleds];
|
||||||
if (grp->serial_led_data[j] == nullptr) {
|
if (grp->serial_led_data[j] == nullptr) {
|
||||||
// if allocation failed clear all memory
|
// if allocation failed clear all memory
|
||||||
for (uint8_t k = 0; k < 4; k++) {
|
for (uint8_t k = 0; k < 4; k++) {
|
||||||
|
|
|
@ -101,7 +101,7 @@ bool RCOutput::bdshot_setup_group_ic_DMA(pwm_group &group)
|
||||||
if (group.dma_ch[i].stream_id == group.dma_up_stream_id) {
|
if (group.dma_ch[i].stream_id == group.dma_up_stream_id) {
|
||||||
group.bdshot.ic_dma_handle[i] = group.dma_handle;
|
group.bdshot.ic_dma_handle[i] = group.dma_handle;
|
||||||
} else {
|
} else {
|
||||||
group.bdshot.ic_dma_handle[i] = new Shared_DMA(group.dma_ch[i].stream_id, SHARED_DMA_NONE,
|
group.bdshot.ic_dma_handle[i] = NEW_NOTHROW Shared_DMA(group.dma_ch[i].stream_id, SHARED_DMA_NONE,
|
||||||
FUNCTOR_BIND_MEMBER(&RCOutput::bdshot_ic_dma_allocate, void, Shared_DMA *),
|
FUNCTOR_BIND_MEMBER(&RCOutput::bdshot_ic_dma_allocate, void, Shared_DMA *),
|
||||||
FUNCTOR_BIND_MEMBER(&RCOutput::bdshot_ic_dma_deallocate, void, Shared_DMA *));
|
FUNCTOR_BIND_MEMBER(&RCOutput::bdshot_ic_dma_deallocate, void, Shared_DMA *));
|
||||||
}
|
}
|
||||||
|
@ -165,7 +165,7 @@ bool RCOutput::bdshot_setup_group_ic_DMA(pwm_group &group)
|
||||||
group.bdshot.ic_dma_handle[i] = group.dma_handle;
|
group.bdshot.ic_dma_handle[i] = group.dma_handle;
|
||||||
} else {
|
} else {
|
||||||
// we can use the next channel
|
// we can use the next channel
|
||||||
group.bdshot.ic_dma_handle[i] = new Shared_DMA(group.dma_ch[curr_chan].stream_id, SHARED_DMA_NONE,
|
group.bdshot.ic_dma_handle[i] = NEW_NOTHROW Shared_DMA(group.dma_ch[curr_chan].stream_id, SHARED_DMA_NONE,
|
||||||
FUNCTOR_BIND_MEMBER(&RCOutput::bdshot_ic_dma_allocate, void, Shared_DMA *),
|
FUNCTOR_BIND_MEMBER(&RCOutput::bdshot_ic_dma_allocate, void, Shared_DMA *),
|
||||||
FUNCTOR_BIND_MEMBER(&RCOutput::bdshot_ic_dma_deallocate, void, Shared_DMA *));
|
FUNCTOR_BIND_MEMBER(&RCOutput::bdshot_ic_dma_deallocate, void, Shared_DMA *));
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,7 +82,7 @@ SPIBus::SPIBus(uint8_t _bus) :
|
||||||
chMtxObjectInit(&dma_lock);
|
chMtxObjectInit(&dma_lock);
|
||||||
|
|
||||||
// allow for sharing of DMA channels with other peripherals
|
// allow for sharing of DMA channels with other peripherals
|
||||||
dma_handle = new Shared_DMA(spi_devices[bus].dma_channel_rx,
|
dma_handle = NEW_NOTHROW Shared_DMA(spi_devices[bus].dma_channel_rx,
|
||||||
spi_devices[bus].dma_channel_tx,
|
spi_devices[bus].dma_channel_tx,
|
||||||
FUNCTOR_BIND_MEMBER(&SPIBus::dma_allocate, void, Shared_DMA *),
|
FUNCTOR_BIND_MEMBER(&SPIBus::dma_allocate, void, Shared_DMA *),
|
||||||
FUNCTOR_BIND_MEMBER(&SPIBus::dma_deallocate, void, Shared_DMA *));
|
FUNCTOR_BIND_MEMBER(&SPIBus::dma_deallocate, void, Shared_DMA *));
|
||||||
|
@ -470,7 +470,7 @@ SPIDeviceManager::get_device(const char *name)
|
||||||
}
|
}
|
||||||
if (busp == nullptr) {
|
if (busp == nullptr) {
|
||||||
// create a new one
|
// create a new one
|
||||||
busp = new SPIBus(desc.bus);
|
busp = NEW_NOTHROW SPIBus(desc.bus);
|
||||||
if (busp == nullptr) {
|
if (busp == nullptr) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -480,7 +480,7 @@ SPIDeviceManager::get_device(const char *name)
|
||||||
buses = busp;
|
buses = busp;
|
||||||
}
|
}
|
||||||
|
|
||||||
return AP_HAL::OwnPtr<AP_HAL::SPIDevice>(new SPIDevice(*busp, desc));
|
return AP_HAL::OwnPtr<AP_HAL::SPIDevice>(NEW_NOTHROW SPIDevice(*busp, desc));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SPIDeviceManager::set_register_rw_callback(const char* name, AP_HAL::Device::RegisterRWCb cb)
|
void SPIDeviceManager::set_register_rw_callback(const char* name, AP_HAL::Device::RegisterRWCb cb)
|
||||||
|
|
|
@ -414,7 +414,7 @@ void UARTDriver::_begin(uint32_t b, uint16_t rxS, uint16_t txS)
|
||||||
// we only allow for sharing of the TX DMA channel, not the RX
|
// we only allow for sharing of the TX DMA channel, not the RX
|
||||||
// DMA channel, as the RX side is active all the time, so
|
// DMA channel, as the RX side is active all the time, so
|
||||||
// cannot be shared
|
// cannot be shared
|
||||||
dma_handle = new Shared_DMA(sdef.dma_tx_stream_id,
|
dma_handle = NEW_NOTHROW Shared_DMA(sdef.dma_tx_stream_id,
|
||||||
SHARED_DMA_NONE,
|
SHARED_DMA_NONE,
|
||||||
FUNCTOR_BIND_MEMBER(&UARTDriver::dma_tx_allocate, void, Shared_DMA *),
|
FUNCTOR_BIND_MEMBER(&UARTDriver::dma_tx_allocate, void, Shared_DMA *),
|
||||||
FUNCTOR_BIND_MEMBER(&UARTDriver::dma_tx_deallocate, void, Shared_DMA *));
|
FUNCTOR_BIND_MEMBER(&UARTDriver::dma_tx_deallocate, void, Shared_DMA *));
|
||||||
|
|
|
@ -212,7 +212,7 @@ WSPIDeviceManager::get_device(const char *name)
|
||||||
}
|
}
|
||||||
if (busp == nullptr) {
|
if (busp == nullptr) {
|
||||||
// create a new one
|
// create a new one
|
||||||
busp = new WSPIBus(desc.bus);
|
busp = NEW_NOTHROW WSPIBus(desc.bus);
|
||||||
if (busp == nullptr) {
|
if (busp == nullptr) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -222,7 +222,7 @@ WSPIDeviceManager::get_device(const char *name)
|
||||||
buses = busp;
|
buses = busp;
|
||||||
}
|
}
|
||||||
|
|
||||||
return AP_HAL::OwnPtr<AP_HAL::WSPIDevice>(new WSPIDevice(*busp, desc));
|
return AP_HAL::OwnPtr<AP_HAL::WSPIDevice>(NEW_NOTHROW WSPIDevice(*busp, desc));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // #if HAL_USE_WSPI == TRUE && defined(HAL_QPI_DEVICE_LIST)
|
#endif // #if HAL_USE_WSPI == TRUE && defined(HAL_QPI_DEVICE_LIST)
|
||||||
|
|
|
@ -249,7 +249,7 @@ void Shared_DMA::dma_info(ExpandingString &str)
|
||||||
{
|
{
|
||||||
// no buffer allocated, start counting
|
// no buffer allocated, start counting
|
||||||
if (_contention_stats == nullptr) {
|
if (_contention_stats == nullptr) {
|
||||||
_contention_stats = new dma_stats[SHARED_DMA_MAX_STREAM_ID+1];
|
_contention_stats = NEW_NOTHROW dma_stats[SHARED_DMA_MAX_STREAM_ID+1];
|
||||||
// return zeros on first fetch
|
// return zeros on first fetch
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue