#define _AO_SPI_SPEED_62500Hz STM_SPI_CR1_BR_PCLK_256
static inline uint32_t
-ao_spi_speed(uint32_t hz)
+ao_spi_speed(int index, uint32_t hz)
{
+ (void) index;
if (hz >= 4000000) return _AO_SPI_SPEED_4MHz;
if (hz >= 2000000) return _AO_SPI_SPEED_2MHz;
if (hz >= 1000000) return _AO_SPI_SPEED_1MHz;
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);
stm_spi->dr = 0xff;
while (!(stm_spi->sr & (1 << STM_SPI_SR_RXNE)))
;
- return stm_spi->dr;
+ return (uint8_t) stm_spi->dr;
}
void
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) \
#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)
#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 { \
asm("mrs %0,psp" : "=&r" (psp));
if (ao_cur_task &&
- psp <= ao_cur_task->stack &&
- psp >= ao_cur_task->stack - 256)
+ (psp <= ao_cur_task->stack8 ||
+ psp >= ao_cur_task->stack8 + AO_STACK_SIZE))
ao_panic(AO_PANIC_STACK);
}
#endif