altos: Use new ao_spi_speed inline to set SPI speeds using spec'd frequencies
[fw/altos] / src / drivers / ao_mpu9250.c
index 1b31edf4611754fe1b8c8d8fe52562b161e8579e..09b65bfa749c8cd7de7b1e5f6ff712d5cc602c74 100644 (file)
@@ -34,7 +34,11 @@ static uint8_t       ao_mpu9250_configured;
 
 #if AO_MPU9250_SPI
 
-#define ao_mpu9250_spi_get()   ao_spi_get(AO_MPU9250_SPI_BUS, AO_SPI_SPEED_1MHz)
+#ifndef AO_MPU9250_SPI_SPEED
+#define AO_MPU9250_SPI_SPEED   ao_spi_speed(1000000)   /* 1MHz max SCLK */
+#endif
+
+#define ao_mpu9250_spi_get()   ao_spi_get(AO_MPU9250_SPI_BUS, AO_MPU9250_SPI_SPEED)
 #define ao_mpu9250_spi_put()   ao_spi_put(AO_MPU9250_SPI_BUS)
 
 #define ao_mpu9250_spi_start()         ao_spi_set_cs(AO_MPU9250_SPI_CS_PORT,   \
@@ -559,7 +563,7 @@ ao_mpu9250_init(void)
         */
 
        ao_cur_task = &ao_mpu9250_task;
-       ao_spi_get(AO_MPU9250_SPI_BUS, AO_SPI_SPEED_1MHz);
+       ao_mpu9250_spi_get();
        ao_cur_task = NULL;
 #endif
        ao_cmd_register(&ao_mpu9250_cmds[0]);