summaryrefslogtreecommitdiffstats
path: root/rf_test/spi.c
diff options
context:
space:
mode:
authorSadeep Madurange <sadeep@asciimx.com>2024-11-23 21:52:11 +0800
committerSadeep Madurange <sadeep@asciimx.com>2024-11-23 21:52:11 +0800
commit55966d2101ea7605f1e33bb1533a9debc0546121 (patch)
treee8012e3db751d3f9a34eefc34c094cde4a8f508d /rf_test/spi.c
parentcbe4ea329552b9ca5eb35dccd5b180f7658781ce (diff)
downloadsmart-home-55966d2101ea7605f1e33bb1533a9debc0546121.tar.gz
wip: move SPI code to rfm.c
Diffstat (limited to 'rf_test/spi.c')
-rw-r--r--rf_test/spi.c48
1 files changed, 0 insertions, 48 deletions
diff --git a/rf_test/spi.c b/rf_test/spi.c
deleted file mode 100644
index 282cdce..0000000
--- a/rf_test/spi.c
+++ /dev/null
@@ -1,48 +0,0 @@
-#include <avr/io.h>
-
-#include "spi.h"
-
-#define SS_PIN PB2
-#define SS_DDR DDRB
-#define SS_PORT PORTB
-
-void spi_init(void)
-{
- SS_DDR |= (1 << SS_PIN);
- SS_PORT |= (1 << SS_PIN);
-
- DDR_SPI = (1 << DD_MOSI) | (1 << DD_SCK);
- SPCR = (1 << SPE) | (1 << MSTR) | (1 << SPR0);
-}
-
-uint8_t spi_send(uint8_t data)
-{
- SS_PORT |= (1 << SS_PIN);
-
- SPDR = data;
- while (!(SPSR & (1 << SPIF)))
- ;
- data = SPDR;
-
- SS_PORT &= ~(1 << SS_PIN);
-
- return data;
-}
-
-uint8_t spi_send(uint8_t addr, uint8_t data)
-{
- SS_PORT |= (1 << SS_PIN);
-
- SPDR = addr;
- while (!(SPSR & (1 << SPIF)))
- ;
-
- SPDR = data;
- while (!(SPSR & (1 << SPIF)))
- ;
-
- SS_PORT &= ~(1 << SS_PIN);
-
- return data;
-}
-