Skip to content

Nordic RF52 does not correctly support dynamically created SPI/I2C (TWI) devices #5883

Closed
@NeilMacMullen

Description

@NeilMacMullen

Mbed 5.6/5.7
Target: Nordic RF52832

The 52832 supports up to 3 simultaneous SPI/I2C buses. Our board requires 1xI2C and 3xSPI so we statically allocate an I2C and SPI bus then dynamically allocate the remaining bus controller as required.

Unfortunately the reallocation of both I2C and SPI TWO blocks is broken. This code will quickly fault...

 I2C *i2c = new I2C(p16, p15);
 SPI *storageSPI = new SPI(p9, p10, p14);
 while (true)
 {
SPI *gpsSpi = new SPI(p29, p28, p30, p31);
 delete gpsSpi;
SPI *espSpi = new SPI(p6, p8, p7);
delete espSpi;
}

There is a comment in spi_init that indicates that the mbed SPI class does not call spi_free from the destructor. This is true but even if the call is made and the 'bodge' code in spi_init is removed, it doesn't seem possible to correctly reuse previously-freed buses.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions