Hi folks-
I'm looking to save a few bucks and reuse my MicroMag3. I'm looking to add the support myself, but wanted to get some feedback before I get in too deep :)
Game plan:
1. MicroMag3 is SPI which means it will have to share with DataFlash and/or the ADC.
2. DataFlash is synchronous, but ADC is not as it has a timer interrupt.
3. Because of #2 it will be much easier to share the DataFlash's SPI than the ADC's SPI'd UART.
4. To ensure that MicroMag3 plays nice with other SPI modules, it will save SPCR and SPSR before every use and restore them after.
5. The compass class will be virtualized, adding a "WorkStep" function to be called in the fast loop as MicroMag3 has no "continuous" mode.
6. I need to find 3 GPIO pins I can use for DataReady, Reset, and SlaveSelect on the MicroMag3. Any recommendations?
P.S.
7. I'm forseeing the need of an SPI arbiter analogous to the I2C one, but I won't get ahead of myself :)
Thanks!
John
Replies
Update: I've got the compass working and I've think I've got a simpler solution for SPI sharing as long as devices are not asynchronous.
I'll add the info later as I have to go to my real job now :)
Very interesting. I'm also hoping to add support for another sensor (the ADNS3080 mouse sensor to be used for position hold) to the SPI bus. I'm already having trouble getting the two sensors to talk although I haven't even got the point of trying to enable both the new sensor and the existing ADC or Dataflash. So I think you're right about #7.
I haven't thought about it a lot but perhaps you might use these pins on the APM for Chip select and reset:
#define CHIP_SELECT 33 // PC4
#define RESET 32 // PC5
You'll need to be careful about the voltage. The ADC's SPI is 5V I believe while your micromag is 3v.
Good luck.