Skip to content

Commit 2a55f09

Browse files
committed
fix(PR): Moved SPI helper functions from extralib to own project (!827)
1 parent e6b6622 commit 2a55f09

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

examples/spi_slave/spi_slave.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
#include "ch32fun.h"
22
#include <stdio.h>
33

4-
#define CH32V003_SPI_SPEED_HZ 1000000
5-
#define CH32V003_SPI_DIRECTION_2LINE_TXRX
6-
#define CH32V003_SPI_CLK_MODE_POL0_PHA0
7-
#define CH32V003_SPI_NSS_SOFTWARE_ANY_MANUAL
8-
9-
#include "../../extralibs/ch32v003_SPI.h"
10-
114
#define PIN_CS PC1
125
// Useful to determine the cycle duration with a scope. Goes high the moment CS goes low, and back to low at the last
136
// action within the while loop. Can be removed otherwise.
@@ -36,6 +29,16 @@ void wait_for_state( SpiState desired_state )
3629
}
3730
}
3831

32+
static uint8_t SPI_read_8()
33+
{
34+
return SPI1->DATAR;
35+
}
36+
37+
static void SPI_write_8( uint8_t data )
38+
{
39+
SPI1->DATAR = data;
40+
}
41+
3942
void SPI_Configure()
4043
{
4144
// reset control register

0 commit comments

Comments
 (0)