1 #include "cc112x_spi.h"
4 #include "../firmware.h"
6 rfStatus_t cc112xSpiReadReg(uint8_t spi_device, uint16_t addr, uint8_t *data)
9 if((addr & 0xFF00) == 0x0000)
12 return SPI_read8(spi_device, (uint8_t)(addr | 0x80), data);
17 return SPI_read16(spi_device, (addr | 0x8000), data);
21 rfStatus_t cc112xSpiWriteReg(uint8_t spi_device, uint16_t addr, uint8_t *data)
24 if((addr & 0xFF00) == 0x0000)
27 return SPI_write8(spi_device, (uint8_t)(addr & 0x7F), data);
32 return SPI_write16(spi_device, (addr & 0x7FFF), data);
36 rfStatus_t cc112xSpiReadBurstReg(uint8_t spi_device, uint16_t addr, uint8_t *data, uint8_t len)
39 if((addr & 0xFF00) == 0x0000)
42 return SPI_burstread8(spi_device, (uint8_t)(addr | 0x80), data, len);
51 rfStatus_t cc112xSpiWriteBurstReg(uint8_t spi_device, uint16_t addr, uint8_t *data, uint8_t len)
54 if((addr & 0xFF00) == 0x0000)
66 rfStatus_t cc112xSpiWriteTxFifo(uint8_t spi_device, uint8_t *data, uint8_t len)
68 return SPI_burstwrite8(spi_device, (CC112X_BURST_TXFIFO & 0x7F), data, len);
71 rfStatus_t cc112xSpiReadRxFifo(uint8_t spi_device, uint8_t *data, uint8_t len)
73 return SPI_burstread8(spi_device, (CC112X_BURST_RXFIFO | 0x80), data, len);
76 rfStatus_t cc112xGetTxStatus(uint8_t spi_device)
78 return SPI_cmd(spi_device, CC112X_SNOP);
81 rfStatus_t cc112xGetRxStatus(uint8_t spi_device)
83 return SPI_cmd(spi_device, (CC112X_SNOP | 0x80));
uint8_t SPI_burstread8(uint8_t spi_num, uint8_t addr, uint8_t *data, uint32_t len)
uint8_t SPI_burstwrite8(uint8_t spi_num, uint8_t addr, uint8_t *data, uint32_t len)
uint8_t SPI_burstread16(uint8_t spi_num, uint16_t addr, uint8_t *data, uint32_t len)
uint8_t SPI_cmd(uint8_t spi_num, uint8_t cmd)
uint8_t SPI_write8(uint8_t spi_num, uint8_t addr, uint8_t *data)
uint8_t SPI_burstwrite16(uint8_t spi_num, uint16_t addr, uint8_t *data, uint32_t len)
uint8_t SPI_write16(uint8_t spi_num, uint16_t addr, uint8_t *data)
uint8_t SPI_read8(uint8_t spi_num, uint8_t addr, uint8_t *data)
uint8_t SPI_read16(uint8_t spi_num, uint16_t addr, uint8_t *data)