You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
823 B

#ifndef __SPI_H____
#define __SPI_H____
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include "config.h"
typedef struct spi_descr *spi_t;
#define SPI_MODE_0 (0)
#define SPI_MODE_1 (1)
#define SPI_MODE_2 (2)
#define SPI_MODE_3 (3)
#define SPI_CS_LOW (0)
#define SPI_CS_HIGH (1)
int spi_setup(spi_t, uint32_t cs, int mode, int bps);
void spi_set_speed(spi_t spi, int bps);
void spi_set_mode(spi_t, int mode);
void spi_close(spi_t spi);
uint8_t spi_send_byte(spi_t spi, uint8_t data);
int spi_transfer(spi_t spi, const uint8_t *tx, uint8_t *rx, int len);
void spi_cs(spi_t spi, int cs);
uint8_t spi_txrx(spi_t spi, uint8_t data);
#if (TARGET_HAS_SPI1)
extern struct spi_descr spi0;
#endif
#if (TARGET_HAS_SPI2)
extern struct spi_descr spi1;
#endif
#ifdef __cplusplus
}
#endif
#endif