yepThe argument is a trigger number such DMAMUX_SOURCE_SPI0_TX, isn't it?
i think you will get some type of fault, though paul will have to answer that.How does the DMAChannel class report that no channel is available when I try to allocate too many channels?
if (++ch >= DMA_NUM_CHANNELS) {
__enable_irq();
TCD = (TCD_t *)0;
channel = 16;
return; // no more channels available
// attempts to use this object will hardfault
}
In case a someDriver.begin() tries to allocate a channel that can't be allocated and then fails by returning false, I can emit a message over Serial (or some other method) that points to a possible cause for the problem. A hardfault is less comfortable to debug.By really, what are you going to do if it's false?
Yup, you'll get a memory fault when trying to write and of the settings. Of course, that only happens if all 16 channels are already in use.
I could be talked into adding (or accepting a pull request for) a bool operator, similar to how "while(!Serial)" tells you if the Arduino Serial Monitor has opened. By really, what are you going to do if it's false?
if(opMode == I2C_OP_MODE_DMA)
{
// attempt to get a DMA Channel
i2c->DMA = new DMAChannel();
// check if object created but no available channel
if(i2c->DMA != nullptr && i2c->DMA->channel == DMA_NUM_CHANNELS)
{
// revert to ISR mode if no DMA channels avail
delete i2c->DMA;
i2c->opMode = I2C_OP_MODE_ISR;
}
...
...