X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Fstm%2Fao_arch_funcs.h;h=62b100631bc0bf87320c0e7afd5ece89fd8caa2b;hb=03dc80d15a2f8fe9d7340351226dadd8bc3cfdb9;hp=447042dd6a0ad3bda8c04d8c74d5368dc780d7d9;hpb=f11f05c5d634de2a80c34d0d3dc93925980f52e6;p=fw%2Faltos diff --git a/src/stm/ao_arch_funcs.h b/src/stm/ao_arch_funcs.h index 447042dd..62b10063 100644 --- a/src/stm/ao_arch_funcs.h +++ b/src/stm/ao_arch_funcs.h @@ -40,36 +40,54 @@ ao_spi_recv(void *block, uint16_t len, uint8_t spi_index); void ao_spi_duplex(void *out, void *in, uint16_t len, uint8_t spi_index); +#define AO_SPI_SPEED_FAST STM_SPI_CR1_BR_PCLK_16 +#define AO_SPI_SPEED_200kHz STM_SPI_CR1_BR_PCLK_256 + +extern uint16_t ao_spi_speed[STM_NUM_SPI]; + +#define ao_spi_slow(bus) (ao_spi_speed[bus] = AO_SPI_SPEED_200kHz) + +#define ao_spi_fast(bus) (ao_spi_speed[bus] = AO_SPI_SPEED_FAST) + void ao_spi_init(void); #define ao_spi_get_mask(reg,mask,bus) do { \ ao_spi_get(bus); \ - (reg).bsrr = ((uint32_t) mask) << 16; \ + (reg)->bsrr = ((uint32_t) mask) << 16; \ } while (0) #define ao_spi_put_mask(reg,mask,bus) do { \ - (reg).bsrr = mask; \ + (reg)->bsrr = mask; \ ao_spi_put(bus); \ } while (0) +#define ao_spi_get_bit(reg,bit,pin,bus) ao_spi_get_mask(reg,(1<