altos: Add SPI bus parameter to ao_spi_speed The stm32f1 series has two SPI busses and they operate from different base clocks, so the computation of the clock divider to get a particular frequency depends upon which SPI bus is being used. Signed-off-by: Keith Packard <keithp@keithp.com>
altos: Add timeout in MS5607 get_sample code MISO is supposed to rise when the sample value is ready, but sometimes we miss the interrupt which should be generated. I spent a day attempting to fix this, but was unable to make it 100%. Instead, add a 10ms timeout, which is longer than the sample time (8.2ms), and then read MISO directly. If the interrupt fires, we'll read a bit sooner. Signed-off-by: Keith Packard <keithp@keithp.com>
altos: Add timeout for MS5607 ADC conversion The MS5607 should signal conversion done by pulling MISO low, but in case it doesn't, add a 10ms timeout to wake up after the conversion should be done. Signed-off-by: Keith Packard <keithp@keithp.com>
altos/ms5607: Fixup ms5607 changes for other chips A couple of chips don't bother providing duplex, so allow for that. Signed-off-by: Keith Packard <keithp@keithp.com>
altos/ms5607: Use duplex for fetching data Much more efficient than send/recv Signed-off-by: Keith Packard <keithp@keithp.com>
altos/ms5607: Use ao_gpio_set instead of stm_gpio_set The former is architecture independent. Signed-off-by: Keith Packard <keithp@keithp.com>
drivers: Resolve -Wconversion in m25, mma655x, mmc5983, mpu and ms5607 No bugs identified. Signed-off-by: Keith Packard <keithp@keithp.com>
altos: Use new ao_spi_speed inline to set SPI speeds using spec'd frequencies Instead of hand-adjusting SPI speeds for each driver and product based on processor supported rates, create an inline function that takes the maximum frequency supported by the device and maps that to a value supported by the SoC. This ensures that we don't accidentally drive devices faster than they want (as could happen with AO_SPI_SPEED_FAST), but do go as fast as possible in every configuration. Using an inline function means the value is computed at compile time. Signed-off-by: Keith Packard <keithp@keithp.com>
altos: Record all failed sensors and report status at power up Use DATA bits to mark which sensors have failed, then report that in beeps at startup time to help diagnose hardware failures while still allowing the board to be used over USB. Signed-off-by: Keith Packard <keithp@keithp.com>
altos: Allow ms5607 driver to either set ao_sensor_errors or panic Products that want to remain usable (over USB) after a sensor failure don't want to panic when the ms5607 fails, but products with limited ROM space don't want to have extra code to check for the sensor failure and panic. Change the MS5607 driver to allow either option, and then make the micropeak based devices use it. Signed-off-by: Keith Packard <keithp@keithp.com>
altos: Don't dump MS5607 eeprom in 'B' command MicroPeak v2 now has config stuff where these values get shown Signed-off-by: Keith Packard <keithp@keithp.com>
altos/micropeak-v2.0: expose log and config commands over USB This lets AltosUI handle the eeprom data Signed-off-by: Keith Packard <keithp@keithp.com>
altos: Support ao_ms5607_dump when no ms5607 task MicroPeak v2.0 has tasking support, but doesn't have a separate ms5607 task. That means the device isn't getting initialized when not running the flight code, so in cmd mode we need to make sure it's initialized, and we also need to actually fetch a value to display. Signed-off-by: Keith Packard <keithp@keithp.com>
altos/drivers: Use stdbool in ao_ms5607.c We don't have TRUE and FALSE anymore (they were pdclib specific). Signed-off-by: Keith Packard <keithp@keithp.com>
altos: Eliminate 'pin' field from GPIO functions This was used with the 8051 bit-addressing mode to provide single-instruction access to GPIO pins. Signed-off-by: Keith Packard <keithp@keithp.com>
altos: Remove 8051 address space specifiers Signed-off-by: Keith Packard <keithp@keithp.com>
altos: Remove *_TO_DATA macros Now that we don't support 8051, we don't need these Signed-off-by: Keith Packard <keithp@keithp.com>
altos: sdcc doesn't have 'false' and 'true'. Use FALSE and TRUE in ms5607.c driver instead. Signed-off-by: Keith Packard <keithp@keithp.com>
altos/drivers: Shrink ao_ms5607.c code to fit on micropeak still Use some code constructs that make the little AVR processor happier and save about 16 bytes of memory. Signed-off-by: Keith Packard <keithp@keithp.com>
altos: Update sensor data atomically Read data into a temp variable, block interrupts, then update the published value. The bug is easy to see with the HMC5883 which has to byte-swap the output of the chip, and hence can occasionally get caught with the wrong byte order data. Signed-off-by: Keith Packard <keithp@keithp.com>