串口ok
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
|
||||
|
||||
#ifndef __SPIDEVICE_H__
|
||||
#define __SPIDEVICE_H__
|
||||
|
||||
#include "spi.h"
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <cmsis_os.h>
|
||||
#include "FreeRTOS.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum eSPI_BUS_MODE {
|
||||
SPI_BUS_DMA,
|
||||
SPI_BUS_IT,
|
||||
SPI_BUS_BLOCK,
|
||||
} SPI_BUS_MODE_t;
|
||||
|
||||
typedef struct sSPI_BUS {
|
||||
SPI_HandleTypeDef *hspi;
|
||||
struct sSPI_BUS *next_ptr;
|
||||
volatile TaskHandle_t task_waitfor_cmpl;
|
||||
volatile bool task_waitfor_ret;
|
||||
osMutexId mutex;
|
||||
SPI_BUS_MODE_t mode;
|
||||
} SPI_BUS_t;
|
||||
|
||||
typedef struct sSPI_DEV{
|
||||
SPI_BUS_t *bus;
|
||||
char *name;
|
||||
GPIO_TypeDef* GPIOx;
|
||||
uint16_t GPIO_Pin;
|
||||
uint8_t _read_flag;
|
||||
} SPI_DEV_t;
|
||||
|
||||
int SPI_DEV_open(SPI_DEV_t *spi_dev, char *name,
|
||||
SPI_BUS_t *bus, GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);
|
||||
|
||||
bool SPI_DEV_begin(SPI_DEV_t *spi_dev, uint32_t millisec);
|
||||
|
||||
void SPI_DEV_end(SPI_DEV_t *spi_dev);
|
||||
|
||||
void SPI_DEV_unselect(SPI_DEV_t *spi_dev);
|
||||
void SPI_DEV_select(SPI_DEV_t *spi_dev);
|
||||
|
||||
void SPI_DEV_set_read_flag(SPI_DEV_t *spi_dev, uint8_t flag);
|
||||
|
||||
bool SPI_DEV_read_registers(SPI_DEV_t *spi_dev, uint8_t id, uint8_t *buff_out, size_t len_out);
|
||||
bool SPI_DEV_write_register(SPI_DEV_t *spi_dev, uint8_t id, uint8_t val);
|
||||
|
||||
bool SPI_DEV_transfer(SPI_DEV_t *spi_dev, uint8_t *buff_in, size_t len_in, uint8_t *buff_out, size_t len_out, uint32_t millisec);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* __SPIDEVICE_H__ */
|
||||
Reference in New Issue
Block a user