spi.h 791 B

123456789101112131415161718192021222324252627282930
  1. #ifndef __STM32_VSERPOG_SPI_H__
  2. #define __STM32_VSERPOG_SPI_H__
  3. #include <stdint.h>
  4. #include <stddef.h>
  5. #include <libopencm3/stm32/gpio.h>
  6. /* libopencm3 for STM32F0x2 lacks AF GPIO definitions. This is for AF0. */
  7. #ifdef STM32F0
  8. #define GPIO_SPI1_NSS GPIO4 /* PA4 */
  9. #define GPIO_SPI1_SCK GPIO5 /* PA5 */
  10. #define GPIO_SPI1_MISO GPIO6 /* PA6 */
  11. #define GPIO_SPI1_MOSI GPIO7 /* PA7 */
  12. #endif /* STM32F0 */
  13. #define GPIO_BANK_SPI1 GPIOA
  14. #define SPI_DEFAULT_CLOCK 10000000
  15. #define SPI_SELECT() gpio_clear(GPIOA, GPIO_SPI1_NSS)
  16. #define SPI_UNSELECT() gpio_set(GPIOA, GPIO_SPI1_NSS)
  17. uint32_t spi_setup(uint32_t speed_hz);
  18. void spi_bulk_read(uint32_t rlen);
  19. void spi_bulk_write(uint32_t slen);
  20. void spi_enable_pins(void);
  21. void spi_disable_pins(void);
  22. #endif /* __STM32_VSERPOG_SPI_H__ */