altos/stmf0: Add ao_spi_put_pins for MS5067 driver
[fw/altos] / src / stmf0 / ao_arch_funcs.h
index 5a9cf6b5258f87620bf70e9965f5b616431f383b..1a9f28e30ef0b68d4f7ac69fe846e16dea915bb5 100644 (file)
@@ -73,6 +73,7 @@ ao_spi_speed(uint32_t hz)
 
 #define AO_SPI_INDEX(id)       ((id) & AO_SPI_INDEX_MASK)
 #define AO_SPI_CONFIG(id)      ((id) & AO_SPI_CONFIG_MASK)
+#define AO_SPI_PIN_CONFIG(id)  ((id) & (AO_SPI_INDEX_MASK | AO_SPI_CONFIG_MASK))
 
 #define AO_SPI_CPOL_BIT                4
 #define AO_SPI_CPHA_BIT                5
@@ -94,6 +95,9 @@ ao_spi_get(uint8_t spi_index, uint32_t speed);
 void
 ao_spi_put(uint8_t spi_index);
 
+void
+ao_spi_put_pins(uint8_t spi_index);
+
 void
 ao_spi_send(const void *block, uint16_t len, uint8_t spi_index);
 
@@ -150,7 +154,7 @@ ao_spi_recv_byte(uint8_t spi_index)
        stm_spi->dr = 0xff;
        while (!(stm_spi->sr & (1 << STM_SPI_SR_RXNE)))
                ;
-       return stm_spi->dr;
+       return (uint8_t) stm_spi->dr;
 }
 
 void
@@ -214,16 +218,16 @@ static inline void ao_enable_port(struct stm_gpio *port)
 static inline void ao_disable_port(struct stm_gpio *port)
 {
        if ((port) == &stm_gpioa) {
-               stm_rcc.ahbenr &= ~(1 << STM_RCC_AHBENR_IOPAEN);
+               stm_rcc.ahbenr &= ~(1UL << STM_RCC_AHBENR_IOPAEN);
                ao_power_unregister(&ao_power_gpioa);
        } else if ((port) == &stm_gpiob) {
-               stm_rcc.ahbenr &= ~(1 << STM_RCC_AHBENR_IOPBEN);
+               stm_rcc.ahbenr &= ~(1UL << STM_RCC_AHBENR_IOPBEN);
                ao_power_unregister(&ao_power_gpiob);
        } else if ((port) == &stm_gpioc) {
-               stm_rcc.ahbenr &= ~(1 << STM_RCC_AHBENR_IOPCEN);
+               stm_rcc.ahbenr &= ~(1UL << STM_RCC_AHBENR_IOPCEN);
                ao_power_unregister(&ao_power_gpioc);
        } else if ((port) == &stm_gpiof) {
-               stm_rcc.ahbenr &= ~(1 << STM_RCC_AHBENR_IOPFEN);
+               stm_rcc.ahbenr &= ~(1UL << STM_RCC_AHBENR_IOPFEN);
                ao_power_unregister(&ao_power_gpiof);
        }
 }