-
Notifications
You must be signed in to change notification settings - Fork 0
/
stm32_spi.h
51 lines (37 loc) · 1 KB
/
stm32_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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __STM32_SPI_H__
#define __STM32_SPI_H__
#ifdef __cplusplus
extern "C"
{
#endif
#include <assert.h>
#include "spi_api.h"
#include "spi.h"
class spi_port
{
SPI_TypeDef *port;
SPI_InitTypeDef *port_config;
public:
SPI_HandleTypeDef handle;
spi_port(SPI_TypeDef *port);
void init(SPI_InitTypeDef *device_config);
void checkout(SPI_InitTypeDef *device_config);
};
class spi_device : public spi_api
{
spi_port *port;
SPI_InitTypeDef *device_config;
GPIO_TypeDef *nss_port;
uint16_t nss_pin;
public:
spi_device(spi_port *port, SPI_InitTypeDef *device_config, GPIO_TypeDef *nss_port, uint16_t nss_pin);
void start() override;
void stop() override;
void sendByte(uint8_t byte) override;
uint8_t receiveByte() override;
};
#ifdef __cplusplus
}
#endif
#endif /* __STM32_SPI_H__ */