h2zero / n-able-Arduino

An arduino core for ARM based BLE devices supported by the NimBLE stack.
GNU Lesser General Public License v2.1
36 stars 15 forks source link

Fix nRF52810 build with Arduino and SPI/I2C #54

Closed h2zero closed 5 months ago

h2zero commented 5 months ago

Fixes #50, #52

@jackb60

jackb60 commented 5 months ago

This appears to break I2C compatibility with the NRF52832. When attempting to compile for NRF52832, I get

[My sketch location.ino]: undefined reference to `Wire'
collect2.exe: error: ld returned 1 exit status

It isn't an issue with my sketch, as it compiles fine for NRF52832 with the previous Wire_nRF52.cpp

Works for NRF52810 though.

I'll see if I can figure out the problem. Thank you for this library and the fixes.

jackb60 commented 5 months ago

For whatever reason, changing line 402 in Wire_nRF52.cpp from #if defined(SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQn) to #if defined(NRF_TWIM1) fixed the issue. Now it works for both NRF52810 and NRF52832.

h2zero commented 5 months ago

Thanks! I'll make some adjustments.

jackb60 commented 5 months ago

Looks good. I wonder if you also want to change line 411 in Wire_nRF52.cpp from #if defined(SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQn) to #if defined(NRF_TWIM1) given the previous issue with SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQn

h2zero commented 5 months ago

Done, this should work now.

h2zero commented 5 months ago

Looks good. I wonder if you also want to change line 411 in Wire_nRF52.cpp from #if defined(SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQn) to #if defined(NRF_TWIM1) given the previous issue with SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQn

Sorry I missed this comment, yes that seems better for sure at this moment as that doesn't look to actually be #defined anywhere but is instead an enum value. For now I will use your suggestion but look to change it in the future if it no longer discriminates accurately enough.

Thanks for all the help!!!

h2zero commented 5 months ago

@jackb60 Have you tested this with any devices connected to SPI/I2C? Would be great to know that its working as well as compiling 😄

jackb60 commented 5 months ago

Yes I have devices attached to both SPI and I2C and they are working (tested with NRF52810).

h2zero commented 5 months ago

Perfect, I will merge this then. Thanks again!