Paparazzi UAS  v5.10_stable-5-g83a0da5-dirty
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
cyrf6936.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2013 Freek van Tienen <freek.v.tienen@gmail.com>
3  *
4  * This file is part of paparazzi.
5  *
6  * paparazzi is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * paparazzi is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with paparazzi; see the file COPYING. If not, write to
18  * the Free Software Foundation, 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  */
21 
27 #ifndef CYRF6936_H
28 #define CYRF6936_H
29 
30 #include "cyrf6936_regs.h"
31 #include "mcu_periph/spi.h"
32 
33 #define CYRF6936_MAX_BUFFER 80
35 /* The different statuses the cyrf6936 chip can be in */
45 };
46 
47 /* The structure for the cyrf6936 chip that handles all the buffers and requests */
48 struct Cyrf6936 {
49  struct spi_periph *spi_p;
51  volatile enum Cyrf6936Status status;
59  bool has_irq;
66 };
67 
68 extern void cyrf6936_init(struct Cyrf6936 *cyrf, struct spi_periph *spi_p, const uint8_t slave_idx,
69  const uint32_t rst_port, const uint16_t rst_pin);
70 void cyrf6936_event(struct Cyrf6936 *cyrf);
71 
72 bool cyrf6936_write(struct Cyrf6936 *cyrf, const uint8_t addr, const uint8_t data);
73 bool cyrf6936_multi_write(struct Cyrf6936 *cyrf, const uint8_t data[][2], const uint8_t length);
74 bool cyrf6936_write_chan_sop_data_crc(struct Cyrf6936 *cyrf, const uint8_t chan, const uint8_t sop_code[],
75  const uint8_t data_code[], const uint16_t crc_seed);
77 bool cyrf6936_send(struct Cyrf6936 *cyrf, const uint8_t data[], const uint8_t length);
78 
79 #endif /* CYRF6936_H */
unsigned short uint16_t
Definition: types.h:16
struct spi_transaction spi_t
The SPI transaction used for the writing and reading of registers.
Definition: cyrf6936.h:50
bool has_irq
When the CYRF6936 is done reading the irq.
Definition: cyrf6936.h:59
uint8_t buffer_idx
The index of the buffer used for MULTIWRITE and used as sub-status for other statuses.
Definition: cyrf6936.h:57
uint8_t buffer[CYRF6936_MAX_BUFFER]
The buffer used to write/read multiple registers.
Definition: cyrf6936.h:55
The chip is setting the channel, SOP code, DATA code and the CRC seed.
Definition: cyrf6936.h:42
bool cyrf6936_write(struct Cyrf6936 *cyrf, const uint8_t addr, const uint8_t data)
Write to one register.
Definition: cyrf6936.c:330
uint8_t rx_packet[16]
The last received packet.
Definition: cyrf6936.h:65
Cyrf6936Status
Definition: cyrf6936.h:36
The chip is idle and can be used.
Definition: cyrf6936.h:38
uint8_t rx_status
The last receive status.
Definition: cyrf6936.h:63
bool cyrf6936_multi_write(struct Cyrf6936 *cyrf, const uint8_t data[][2], const uint8_t length)
Write to multiple registers one byte.
Definition: cyrf6936.c:341
SPI transaction structure.
Definition: spi.h:142
bool cyrf6936_send(struct Cyrf6936 *cyrf, const uint8_t data[], const uint8_t length)
Send a packet with a certain length.
Definition: cyrf6936.c:432
Register defines for the CYRF6936 2.4GHz radio chip.
struct spi_periph * spi_p
The SPI peripheral for the connection.
Definition: cyrf6936.h:49
bool cyrf6936_read_rx_irq_status_packet(struct Cyrf6936 *cyrf)
Read the RX IRQ status register, the rx status register and the rx packet.
Definition: cyrf6936.c:412
The chip is getting the receive irq status, receive status and the receive packet.
Definition: cyrf6936.h:43
The chip is busy sending a packet.
Definition: cyrf6936.h:44
uint8_t rx_irq_status
The last receive interrupt status.
Definition: cyrf6936.h:62
Architecture independent SPI (Serial Peripheral Interface) API.
enum Cyrf6936Status status
The status of the CYRF6936 chip.
Definition: cyrf6936.h:51
SPI peripheral structure.
Definition: spi.h:168
The chip is writing multiple registers.
Definition: cyrf6936.h:40
uint8_t mfg_id[6]
The manufacturer id of the CYRF6936 chip.
Definition: cyrf6936.h:60
uint8_t input_buf[17]
The input buffer for the SPI transaction.
Definition: cyrf6936.h:52
unsigned long uint32_t
Definition: types.h:18
void cyrf6936_event(struct Cyrf6936 *cyrf)
The on event call for the CYRF6936 chip.
Definition: cyrf6936.c:86
uint8_t buffer_length
The length of the buffer used for MULTIWRITE.
Definition: cyrf6936.h:56
The chip is busy with getting the manufacturer ID.
Definition: cyrf6936.h:39
uint8_t rx_count
The length of the received packet.
Definition: cyrf6936.h:64
The chip isn't initialized.
Definition: cyrf6936.h:37
The chip is writing a data code.
Definition: cyrf6936.h:41
unsigned char uint8_t
Definition: types.h:14
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.
Definition: cyrf6936.c:47
#define CYRF6936_MAX_BUFFER
The max buffer size in the cyrf6936 structure.
Definition: cyrf6936.h:33
uint8_t slave_idx
slave id: SPI_SLAVE0 to SPI_SLAVE4
Definition: spi.h:147
uint8_t tx_irq_status
The last send interrupt status.
Definition: cyrf6936.h:61
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.
Definition: cyrf6936.c:373
uint8_t output_buf[17]
The output buffer for the SPI transaction.
Definition: cyrf6936.h:53