Update SPI driver
This commit is contained in:
@@ -21,4 +21,42 @@
|
||||
#ifndef __SPI_H__
|
||||
#define __SPI_H__
|
||||
|
||||
#include <stm32/stm32f4xx.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
enum stm_spi_prescaler {
|
||||
SPI_PRSC_DIV2 = 0,
|
||||
SPI_PRSC_DIV4 = 1,
|
||||
SPI_PRSC_DIV8 = 2,
|
||||
SPI_PRSC_DIV16 = 3,
|
||||
SPI_PRSC_DIV32 = 4,
|
||||
SPI_PRSC_DIV64 = 5,
|
||||
SPI_PRSC_DIV128 = 6,
|
||||
SPI_PRSC_DIV256 = 7,
|
||||
};
|
||||
|
||||
struct stm_spi_settings {
|
||||
void (*cs_activate)(void);
|
||||
void (*cs_deactivate)(void);
|
||||
bool cpol;
|
||||
bool cpha;
|
||||
bool master;
|
||||
bool msb_first;
|
||||
enum stm_spi_prescaler prescaler;
|
||||
};
|
||||
|
||||
struct stm_spi_dev {
|
||||
uint32_t magic;
|
||||
SPI_TypeDef *spi_regs;
|
||||
struct stm_spi_settings settings;
|
||||
};
|
||||
|
||||
typedef void * stm_spi_handle;
|
||||
|
||||
stm_spi_handle spi_init(struct stm_spi_dev *spi_dev_struct, SPI_TypeDef *spi_regs, const struct stm_spi_settings *settings);
|
||||
|
||||
void spi_deinit(stm_spi_handle handle);
|
||||
|
||||
int spi_transfer(stm_spi_handle handle, const uint8_t *tx, uint8_t *rx, uint32_t count, bool handle_cs);
|
||||
|
||||
#endif /* __SPI_H__ */
|
||||
|
Reference in New Issue
Block a user