Merge branch 'master' of ssh://git.gag.com/scm/git/fw/altos
[fw/altos] / src / stm / ao_arch_funcs.h
index 083f7a2beb7ad394e57c200d9b1f13dd2ff5f020..9f31a36fa6f9e8bc5a58b98f46b6b1ce3a2aa038 100644 (file)
@@ -148,7 +148,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
@@ -182,8 +182,8 @@ ao_spi_try_get_mask(struct stm_gpio *reg, uint16_t mask, uint8_t bus, uint32_t s
                ao_spi_put(bus);                \
        } while (0)
 
-#define ao_spi_get_bit(reg,bit,bus,speed) ao_spi_get_mask(reg,(1<<bit),bus,speed)
-#define ao_spi_put_bit(reg,bit,bus) ao_spi_put_mask(reg,(1<<bit),bus)
+#define ao_spi_get_bit(reg,bit,bus,speed) ao_spi_get_mask(reg,1<<(bit),bus,speed)
+#define ao_spi_put_bit(reg,bit,bus) ao_spi_put_mask(reg,1<<(bit),bus)
 
 #define ao_enable_port(port) do {                                      \
                if ((port) == &stm_gpioa)                               \
@@ -200,15 +200,15 @@ ao_spi_try_get_mask(struct stm_gpio *reg, uint16_t mask, uint8_t bus, uint32_t s
 
 #define ao_disable_port(port) do {                                     \
                if ((port) == &stm_gpioa)                               \
-                       stm_rcc.ahbenr &= ~(1 << STM_RCC_AHBENR_GPIOAEN); \
+                       stm_rcc.ahbenr &= ~(1UL << STM_RCC_AHBENR_GPIOAEN); \
                else if ((port) == &stm_gpiob)                          \
-                       stm_rcc.ahbenr &= ~(1 << STM_RCC_AHBENR_GPIOBEN); \
+                       stm_rcc.ahbenr &= ~(1UL << STM_RCC_AHBENR_GPIOBEN); \
                else if ((port) == &stm_gpioc)                          \
-                       stm_rcc.ahbenr &= ~(1 << STM_RCC_AHBENR_GPIOCEN); \
+                       stm_rcc.ahbenr &= ~(1UL << STM_RCC_AHBENR_GPIOCEN); \
                else if ((port) == &stm_gpiod)                          \
-                       stm_rcc.ahbenr &= ~(1 << STM_RCC_AHBENR_GPIODEN); \
+                       stm_rcc.ahbenr &= ~(1UL << STM_RCC_AHBENR_GPIODEN); \
                else if ((port) == &stm_gpioe)                          \
-                       stm_rcc.ahbenr &= ~(1 << STM_RCC_AHBENR_GPIOEEN); \
+                       stm_rcc.ahbenr &= ~(1UL << STM_RCC_AHBENR_GPIOEEN); \
        } while (0)
 
 
@@ -239,7 +239,7 @@ ao_spi_try_get_mask(struct stm_gpio *reg, uint16_t mask, uint8_t bus, uint32_t s
 #define AO_OUTPUT_PUSH_PULL    STM_OTYPER_PUSH_PULL
 #define AO_OUTPUT_OPEN_DRAIN   STM_OTYPER_OPEN_DRAIN
 
-#define ao_gpio_set_output_mode(port,bit,mode) \
+#define ao_gpio_set_output_mode(port,pin,mode) \
        stm_otyper_set(port, pin, mode)
 
 #define ao_gpio_set_mode(port,bit,mode) do {                           \