diff options
| author | Sadeep Madurange <sadeep@asciimx.com> | 2024-11-23 21:52:11 +0800 |
|---|---|---|
| committer | Sadeep Madurange <sadeep@asciimx.com> | 2024-11-23 21:52:11 +0800 |
| commit | 55966d2101ea7605f1e33bb1533a9debc0546121 (patch) | |
| tree | e8012e3db751d3f9a34eefc34c094cde4a8f508d /rf_test/spi.c | |
| parent | cbe4ea329552b9ca5eb35dccd5b180f7658781ce (diff) | |
| download | smart-home-55966d2101ea7605f1e33bb1533a9debc0546121.tar.gz | |
wip: move SPI code to rfm.c
Diffstat (limited to 'rf_test/spi.c')
| -rw-r--r-- | rf_test/spi.c | 48 |
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; -} - |
