forked from dword1511/stm32-vserprog
-
Notifications
You must be signed in to change notification settings - Fork 1
/
spi.h
27 lines (20 loc) · 734 Bytes
/
spi.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#ifndef __STM32_VSERPOG_SPI_H__
#define __STM32_VSERPOG_SPI_H__
#include <stdint.h>
#include <stddef.h>
#include <libopencm3/stm32/gpio.h>
/* libopencm3 for STM32F0x2 lacks AF GPIO definitions. This is for AF0. */
#ifdef STM32F0
#define GPIO_SPI1_NSS GPIO4 /* PA4 */
#define GPIO_SPI1_SCK GPIO5 /* PA5 */
#define GPIO_SPI1_MISO GPIO6 /* PA6 */
#define GPIO_SPI1_MOSI GPIO7 /* PA7 */
#endif /* STM32F0 */
#define GPIO_BANK_SPI1 GPIOA
#define SPI_DEFAULT_CLOCK 10000000
#define SPI_SELECT() gpio_clear(GPIOA, GPIO_SPI1_NSS)
#define SPI_UNSELECT() gpio_set(GPIOA, GPIO_SPI1_NSS)
uint32_t spi_setup(uint32_t speed_hz);
void spi_bulk_read(uint32_t rlen);
void spi_bulk_write(uint32_t slen);
#endif /* __STM32_VSERPOG_SPI_H__ */