luat_spislave.h 895 B

123456789101112131415161718192021222324252627282930
  1. /*
  2. SPI从机模式的驱动头文件
  3. */
  4. #ifndef LUAT_SPISLAVE_H
  5. #define LUAT_SPISLAVE_H
  6. #include "luat_base.h"
  7. #include "luat_spi.h"
  8. // typedef struct luat_spislave_conf {
  9. // luat_spi_t base; // 继承spi配置结构体
  10. // size_t buff_len; // 接收长度,注意tx/rx是相同大小的,默认4k
  11. // uint8_t *rx_buff; // 接收缓冲区
  12. // uint8_t *tx_buff; // 发送缓冲区
  13. // } luat_spislave_conf_t;
  14. /*初始化SPI从机*/
  15. int luat_spislave_setup(luat_spi_t* conf);
  16. /*反初始化SPI从机*/
  17. int luat_spislave_close(int spi_id);
  18. /*开始SPI传输,异步的 */
  19. int luat_spislave_start(int spi_id, const char* send_buf, char* recv_buf, size_t length);
  20. /*停止SPI传输*/
  21. int luat_spislave_stop(int spi_id);
  22. /*获取接收到的长度 */
  23. int luat_spislave_get_rxlen(int spi_id);
  24. /*停止传输并获取接收到的长度 */
  25. int luat_spislave_stopAndGetlen(int spi_id);
  26. #endif