sparkfun / AmbiqSuiteSDK

A copy of the AmbiqSuite SDK available on GitHub. Can be used to include AmbiqSuite as a submodule. May be used to track issues in SDK releases, however this repo is not maintained by AmbiqMicro
39 stars 31 forks source link

I2C example `ios_lram_host` in the SDK has a bug #9

Open burnpanck opened 4 years ago

burnpanck commented 4 years ago

Looking for a good example on how to use the IOM HAL to implement an I2C master, I found ios_lram_host.c. That one has a (minor) bug. Given that Ambiq doesn't seem to have a good issue tracker, I report that bug here instead. Maybe this repo can evolve into a community maintained, better quality SDK?

The example contains the following lines within the function iom_set_up:

    // Enable interrupts for NB send to work
    am_hal_iom_interrupt_enable(g_IOMHandle, 0xFF);

"NB" most likely refers to "non-blocking". However, it turns our that am_hal_iom_interrupt_enable refuses the 0xFF, because the FIFO interrupt "shall not be used" (so the function source sais). It seems that the HAL methods for non-blocking transfers do a lot of interrupt managing anyway, so most likely, it's simply not true that interrupts need to be enabled. While this issue is inconsequential in the example, it is confusing for anyone trying to write high-quality code which does actually check error codes.

oclyke commented 4 years ago

Good catch @burnpanck! Thank you for sharing this information with everyone. Hopefully we will see this improved in future versions of the SDK