#ifndef SPI_DMA_H
#define SPI_DMA_H

#include "ch32v003fun.h"

typedef enum {
  IDLE,
  TRANSMITTING,
  RECEIVING,
  TX_DONE,
  RX_DONE
} transfer_state_t;

// SPI DMA initialization function
void init_spidma(void);

// SPI DMA buffer read
void spidma_read_buffer(uint8_t *buf, uint16_t len);

// SPI DMA buffer write
void spidma_write_buffer(uint8_t *buf, uint16_t len);

// // SPI (non-DMA) byte read
// uint8_t spi_read_byte();

// // SPI (non-DMA) byte write
// void spi_write_byte(uint8_t byte);

// activate CS
void spi_select(void);

// deactivate CS
void spi_unselect(void);

#endif  // SPI_DMA_H
