Paparazzi UAS  v5.2.2_stable-0-gd6b9f29
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
superbitrf.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 DATALINK_SUPERBITRF_H
28 #define DATALINK_SUPERBITRF_H
29 
30 #include "mcu_periph/gpio.h"
31 #include "peripherals/cyrf6936.h"
34 
35 /* The timings in microseconds */
36 #define SUPERBITRF_BIND_RECV_TIME 10000
37 #define SUPERBITRF_SYNC_RECV_TIME 7000
38 #define SUPERBITRF_RECV_TIME 20000
39 #define SUPERBITRF_RECV_SHORT_TIME 6000
40 #define SUPERBITRF_DATARECV_TIME 10000
41 #define SUPERBITRF_DATARECVB_TIME 6000
43 /* The different statuses the superbitRF can be in */
52 };
53 
54 /* The different resolutions a transmitter can be in */
58 };
59 
60 /* The different protocols a transmitter can send */
62  DSM_DSM2_1 = 0x01,
63  DSM_DSM2_2 = 0x02,
64  DSM_DSM2P = 0x10,
65  DSM_DSMXP = 0x11,
66  DSM_DSMX_1 = 0xA2,
67  DSM_DSMX_2 = 0xB2,
68 };
69 #define IS_DSM2(x) (x == DSM_DSM2P || x == DSM_DSM2_1 || x == DSM_DSM2_2)
70 #define IS_DSMX(x) (!IS_DSM2(x))
71 
72 /* The superbitrf structure */
73 struct SuperbitRF {
74  struct Cyrf6936 cyrf6936;
75  volatile enum SuperbitRFStatus status;
78  bool_t timer_overflow;
83  bool_t packet_loss;
94  uint8_t bind_mfg_id[4];
97  volatile enum dsm_protocol protocol;
98  volatile enum dsm_resolution resolution;
113 };
114 
115 /* The superbitrf functions and structures */
116 extern struct SuperbitRF superbitrf;
117 extern void superbitrf_init(void);
118 extern void superbitrf_event(void);
119 extern void superbitrf_set_mfg_id(uint32_t id);
121 
122 /* The datalink defines */
123 #define SuperbitRFInit() { }//superbitrf_init(); }
124 #define SuperbitRFCheckFreeSpace(_x) (((superbitrf.tx_insert_idx+1) %128) != superbitrf.tx_extract_idx)
125 #define SuperbitRFTransmit(_x) { \
126  superbitrf.tx_buffer[superbitrf.tx_insert_idx] = _x; \
127  superbitrf.tx_insert_idx = (superbitrf.tx_insert_idx+1) %128; \
128  }
129 #define SuperbitRFSendMessage() { }
130 #define SuperbitRFCheckAndParse() { }
131 
132 #endif /* DATALINK_SUPERBITRF_H */
Driver for the cyrf6936 2.4GHz radio chip.
unsigned short uint16_t
Definition: types.h:16
uint16_t crc_seed
The CRC seed that is calculated with the bind MFG id.
Definition: superbitrf.h:99
uint8_t channel_idx
The current channel index.
Definition: superbitrf.h:86
bool_t timer_overflow
When the timer overflows.
Definition: superbitrf.h:78
enum dsm_resolution resolution
The resolution that the transmitter has.
Definition: superbitrf.h:98
Some architecture independent helper functions for GPIOs.
uint8_t sop_col
The sop code column number calculated with the bind MFG id.
Definition: superbitrf.h:100
Extra datalink using PPRZ protocol.
uint8_t bind_mfg_id[4]
The MFG id where the receiver is bound to.
Definition: superbitrf.h:44
struct Cyrf6936 cyrf6936
The cyrf chip used.
Definition: superbitrf.h:74
uint8_t tx_buffer[128]
The transmit buffer.
Definition: superbitrf.h:110
uint8_t state
The states each status can be in.
Definition: superbitrf.h:76
uint32_t timer
The timer in microseconds.
Definition: superbitrf.h:77
int16_t rc_values[14]
The rc values from the packet.
Definition: superbitrf.h:106
bool_t rc_frame_available
When a RC frame is available.
Definition: superbitrf.h:103
uint32_t uplink_count
How many valid uplink packages are received.
Definition: superbitrf.h:91
enum SuperbitRFStatus status
The status of the superbitRF.
Definition: superbitrf.h:75
uint32_t rc_count
How many valid RC packages are received.
Definition: superbitrf.h:92
unsigned long uint32_t
Definition: types.h:18
uint8_t tx_insert_idx
The transmit buffer insert index.
Definition: superbitrf.h:111
signed short int16_t
Definition: types.h:17
uint32_t irq_count
How many interrupts are made.
Definition: superbitrf.h:88
uint32_t tx_packet_count
How many packets are send(also the invalid)
Definition: superbitrf.h:90
uint8_t tx_extract_idx
The transmit buffer extract index.
Definition: superbitrf.h:112
uint32_t transfer_timeouts
The amount of timeouts during transfer.
Definition: superbitrf.h:80
struct pprz_transport rx_transport
The receive transport.
Definition: superbitrf.h:108
uint8_t data_col
The data code column number calculated with the bind MFG id.
Definition: superbitrf.h:101
uint8_t channels[23]
The channels used for DSM2/DSMX.
Definition: superbitrf.h:85
uint8_t packet_loss_bit
The packet loss indicating bit.
Definition: superbitrf.h:82
unsigned char uint8_t
Definition: types.h:14
bool_t packet_loss
When we have packet loss last packet.
Definition: superbitrf.h:83
uint8_t timeouts
The amount of timeouts.
Definition: superbitrf.h:79
uint8_t num_channels
The number of channels the transmitter has.
Definition: superbitrf.h:46
uint8_t channel
The current channel number.
Definition: superbitrf.h:87
uint32_t bind_mfg_id32
The MFG id where the receiver is bound to in uint32.
Definition: superbitrf.h:45
uint32_t rx_packet_count
How many packets are received(also the invalid)
Definition: superbitrf.h:89
uint32_t resync_count
The amount of resyncs needed during transfer.
Definition: superbitrf.h:81
uint32_t timing1
Time between last receive in microseconds.
Definition: superbitrf.h:104
enum dsm_protocol protocol
The protocol the transmitter uses.
Definition: superbitrf.h:47
uint32_t timing2
Time between second last receive in microseconds.
Definition: superbitrf.h:105