34 #include "pprzlink/messages.h"
121 for (i = 0; i < 6; i++) {
222 for (i = 0; i < 16; i++) {
293 for (i = 0; i < length; i++) {
332 const uint8_t data_multi[][2] = {
357 for (i = 0; i < length; i++) {
358 cyrf->
buffer[i * 2] = data[i][0];
359 cyrf->
buffer[i * 2 + 1] = data[i][1];
386 cyrf->
buffer[0] = crc_seed & 0xFF;
387 cyrf->
buffer[1] = (crc_seed >> 8) & 0xFF;
390 for (i = 0; i < 8; i++) {
391 cyrf->
buffer[i + 2] = sop_code[i];
395 for (i = 0; i < 16; i++) {
396 cyrf->
buffer[i + 10] = data_code[i];
446 for (i = 0; i < length; i++) {
447 cyrf->
buffer[i + 1] = data[i];
Driver for the cyrf6936 2.4GHz radio chip.
struct spi_transaction spi_t
The SPI transaction used for the writing and reading of registers.
enum SPIClockPolarity cpol
clock polarity control
bool has_irq
When the CYRF6936 is done reading the irq.
uint8_t buffer_idx
The index of the buffer used for MULTIWRITE and used as sub-status for other statuses.
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
enum SPIClockDiv cdiv
prescaler of main clock to use as SPI clock
uint8_t buffer[CYRF6936_MAX_BUFFER]
The buffer used to write/read multiple registers.
The chip is setting the channel, SOP code, DATA code and the CRC seed.
uint16_t output_length
number of data words to write
static void gpio_clear(ioportid_t port, uint16_t pin)
Clear a gpio output to low level.
uint8_t rx_packet[16]
The last received packet.
The chip is idle and can be used.
uint8_t rx_status
The last receive status.
Some architecture independent helper functions for GPIOs.
bool cyrf6936_write(struct Cyrf6936 *cyrf, const uint8_t addr, const uint8_t data)
Write to one register.
bool cyrf6936_multi_write(struct Cyrf6936 *cyrf, const uint8_t data[][2], const uint8_t length)
Write to multiple registers one byte.
bool spi_submit(struct spi_periph *p, struct spi_transaction *t)
Submit SPI transaction.
bool cyrf6936_read_rx_irq_status_packet(struct Cyrf6936 *cyrf)
Read the RX IRQ status register, the rx status register and the rx packet.
enum SPIBitOrder bitorder
MSB/LSB order.
#define CYRF_DIR
Bit for enabling writing.
struct spi_periph * spi_p
The SPI peripheral for the connection.
void gpio_setup_output(ioportid_t port, uint16_t gpios)
Setup one or more pins of the given GPIO port as outputs.
volatile uint8_t * output_buf
pointer to transmit buffer for DMA
The chip is getting the receive irq status, receive status and the receive packet.
enum SPISlaveSelect select
slave selection behavior
void cyrf6936_event(struct Cyrf6936 *cyrf)
The on event call for the CYRF6936 chip.
The chip is busy sending a packet.
uint8_t rx_irq_status
The last receive interrupt status.
Architecture independent SPI (Serial Peripheral Interface) API.
enum SPIClockPhase cpha
clock phase control
void sys_time_usleep(uint32_t us)
sys_time_usleep(uint32_t us)
enum Cyrf6936Status status
The status of the CYRF6936 chip.
SPI peripheral structure.
The chip is writing multiple registers.
static bool cyrf6936_write_block(struct Cyrf6936 *cyrf, const uint8_t addr, const uint8_t data[], const uint8_t length)
Write multiple bytes to a register.
Architecture independent timing functions.
uint8_t mfg_id[6]
The manufacturer id of the CYRF6936 chip.
uint8_t input_buf[17]
The input buffer for the SPI transaction.
uint8_t buffer_length
The length of the buffer used for MULTIWRITE.
uint16_t input_length
number of data words to read
The chip is busy with getting the manufacturer ID.
static bool cyrf6936_read_block(struct Cyrf6936 *cyrf, const uint8_t addr, const uint8_t length)
Read multiple bytes from a register.
uint8_t rx_count
The length of the received packet.
The chip isn't initialized.
static bool cyrf6936_read_register(struct Cyrf6936 *cyrf, const uint8_t addr)
Read a byte from a register.
The chip is writing a data code.
static bool cyrf6936_write_register(struct Cyrf6936 *cyrf, const uint8_t addr, const uint8_t data)
Write a byte to a register.
bool cyrf6936_write_chan_sop_data_crc(struct Cyrf6936 *cyrf, const uint8_t chan, const uint8_t sop_code[], const uint8_t data_code[], const uint16_t crc_seed)
Set the channel, SOP code, DATA code and the CRC seed.
slave is selected before transaction and unselected after
Common code for AP and FBW telemetry.
enum SPIDataSizeSelect dss
data transfer word size
uint8_t slave_idx
slave id: SPI_SLAVE0 to SPI_SLAVE4
volatile uint8_t * input_buf
pointer to receive buffer for DMA
uint8_t tx_irq_status
The last send interrupt status.
bool cyrf6936_send(struct Cyrf6936 *cyrf, const uint8_t data[], const uint8_t length)
Send a packet with a certain length.
static void gpio_set(ioportid_t port, uint16_t pin)
Set a gpio output to high level.
void cyrf6936_init(struct Cyrf6936 *cyrf, struct spi_periph *spi_p, const uint8_t slave_idx, const uint32_t rst_port, const uint16_t rst_pin)
Initializing the cyrf chip.
enum SPITransactionStatus status
uint8_t output_buf[17]
The output buffer for the SPI transaction.