feat: SPI DMA
Squashed commit of the following: commit c3e1f696b4fbafb6dd30c6934e4c7c181562e055 Author: kuwoyuki <kuwoyuki@cock.li> Date: Sat Oct 12 20:43:12 2024 +0600 chore: spi dma commit d1e7df60be3e06ed85ce8639516e299085d3c72b Author: kuwoyuki <kuwoyuki@cock.li> Date: Sat Oct 12 15:14:11 2024 +0600 static dummies commit 81682428b471f825e3350e37aa74c373b46d4fef Author: kuwoyuki <kuwoyuki@cock.li> Date: Sat Oct 12 14:45:39 2024 +0600 dma works? commit 150c97a4b566712a502d8a2861a2dc0864324d61 Author: kuwoyuki <kuwoyuki@cock.li> Date: Sat Oct 12 02:07:39 2024 +0600 dma?
This commit is contained in:
9
include/gpio.h
Normal file
9
include/gpio.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#ifndef GPIO_H
|
||||
#define GPIO_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
// Function prototype for initializing GPIO
|
||||
void init_gpio(void);
|
||||
|
||||
#endif // GPIO_H
|
||||
35
include/spi_dma.h
Normal file
35
include/spi_dma.h
Normal file
@@ -0,0 +1,35 @@
|
||||
#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
|
||||
@@ -12,6 +12,6 @@
|
||||
(UART_BAUD_RATE)) // USART1
|
||||
|
||||
// Function prototypes
|
||||
void setup_uart(int uart_brr);
|
||||
void init_uart(int uart_brr);
|
||||
|
||||
#endif // UART_H
|
||||
|
||||
@@ -4,21 +4,27 @@
|
||||
#include <stdint.h>
|
||||
|
||||
// Sets the CS pin low
|
||||
void W5500_Select(void);
|
||||
void w5500_select(void);
|
||||
|
||||
// Sets the CS pin high
|
||||
void W5500_Unselect(void);
|
||||
void w5500_unselect(void);
|
||||
|
||||
// Reads a byte via SPI
|
||||
uint8_t W5500_ReadByte(void);
|
||||
uint8_t w5500_read_byte(void);
|
||||
|
||||
// Writes a byte via SPI
|
||||
void W5500_WriteByte(uint8_t byte);
|
||||
void w5500_write_byte(uint8_t byte);
|
||||
|
||||
// Reads multiple bytes via SPI
|
||||
void W5500_ReadBuff(uint8_t* buff, uint16_t len);
|
||||
void w5500_read_buffer(uint8_t* buff, uint16_t len);
|
||||
|
||||
// Writes multiple bytes via SPI
|
||||
void W5500_WriteBuff(uint8_t* buff, uint16_t len);
|
||||
void w5500_write_buffer(uint8_t* buff, uint16_t len);
|
||||
|
||||
// Initializes the W5500 chip
|
||||
void configure_network(void);
|
||||
|
||||
// resolves a domain name
|
||||
void resolve_domain_name(const char* domain_name);
|
||||
|
||||
#endif // W5500_H
|
||||
|
||||
Reference in New Issue
Block a user