forked from openLRSng/openLRSng
-
Notifications
You must be signed in to change notification settings - Fork 10
/
openLRSng.ino
112 lines (95 loc) · 4.37 KB
/
openLRSng.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
// **********************************************************
// ************************ openLRSng ***********************
// **********************************************************
// ** by Kari Hautio - kha @ AeroQuad/RCGroups/IRC(Freenode)
// ** other commits by cTn-dev, rlboyd, DTFUHF, pwarren
//
// Developer chat at IRC: #openLRS @ freenode
//
// This code is based on original OpenLRS and thUndeadMod
//
// Donations for development tools and utilities (beer) here
// https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=DSWGKGKPRX5CS
//
// Please note that for basic usage there is no need to use this
// code in source form. Instead use configurator program available
// freely in Google Chrome store.
// http://goo.gl/iX7dJx
//
// **********************************************************
// ************ based on: OpenLRS thUndeadMod ***************
// Mihai Andrian - thUndead http://www.fpvuk.org/forum/index.php?topic=3642.0
//
// **********************************************************
// *************** based on: OpenLRS Code *******************
// *** OpenLRS Designed by Melih Karakelle on 2010-2011 ***
// ** an Arudino based RC Rx/Tx system with extra futures **
// ** This Source code licensed under GPL **
// **********************************************************
// **********************************************************
// **************** original OpenLRS DEVELOPERS *************
// Mihai Andrian - thUndead http://www.fpvuk.org/forum/index.php?topic=3642.0
// Melih Karakelle (http://www.flytron.com) (forum nick name: Flytron)
// Jan-Dirk Schuitemaker (http://www.schuitemaker.org/) (forum nick name: CrashingDutchman)
// Etienne Saint-Paul (http://www.gameseed.fr) (forum nick name: Etienne)
//################################
//### HW CONFIGURATION SECTION ###
//################################
// NOTE: All settings are made via the CLI or configurator interface at runtime
// To compile with Arduino select TX/RX and BOARD_TYPE setting as needed below
//####### COMPILATION TARGET #######
// Enable to compile transmitter code, default is RX (remove leading //)
//#define COMPILE_TX 0 // compile RX code
#define COMPILE_TX 1 // compile TX code
//####### TX BOARD TYPE #######
// Enable one of the lines below (remove leading //)
//#define BOARD_TYPE 0 // 0 = Flytron OpenLRS M1 Tx Board (not verified)
//#define BOARD_TYPE 1 // 1 = Flytron OpenLRS M1 Rx Board as TX (not verified)
//#define BOARD_TYPE 2 // 2 = Flytron OpenLRS M2/M3 Tx Board / OrangeRx UHF TX
//#define BOARD_TYPE 3 // 3 = Flytron OpenLRS Rx v2 Board / OrangeRx UHF RX / HawkEye UHF RX (RX and TX supported)
//#define BOARD_TYPE 4 // 4 = OpenLRSngTX / HawkEye UHF TX
//#define BOARD_TYPE 5 // 5 = OpenLRSngRX-4/6ch (DTF UHF/HawkEye) (RX and TX supported)
#define BOARD_TYPE 6 // 6 = DTF UHF/HawkEye DeluxeTX (Atmega32u4)
//#define BOARD_TYPE 9 // 9 = BroversityRX
//### Module type selection (default = 433, only needed for modified HW)
//#define RFMTYPE 868
//#define RFMTYPE 915
//### Enabled Features (some features can be enabled / disabled with compile flag)
#define CLI // Command-line interface
#define CONFIGURATOR // Phoenix Serial Protocol (required for Configurator to work)
//### DEBUG flags, may be dangerous
//#define TEST_NO_ACK_BY_CH1 // disable sending of acks from RX by channel 1
//#define TEST_HALT_RX_BY_CH2 // freeze RX
//#define TEST_HALT_TX_BY_CH3 // freeze TX
//#define SLAVE_STATISTICS // output master/slave stats on RX serial
//#define DEBUG_DUMP_PPM // dump PPM data on serial (both TX/RX)
//####### Transparant serial #######
#define COM_BUF_MAXSIZE 32 // maximum downlink packet size. Max value is 64 , No use having higher than SERIAL_BUFSIZE, (also 1 byte per rf packet is dedicated for datalength and flags). Mavlink telemetry mode allows for serial downlink != 9
//####### MAVLink #######
#define MAVLINK_INJECT_INTERVAL 1000000
//####################
//### CODE SECTION ###
//####################
#include "serialport.h"
#define DefineSerialPort(_name, _num) FastSerialPort(_name, _num)
#include <Arduino.h>
#include "version.h"
#include "binding.h"
#include "hardware.h"
#include "wd.h"
#include "common.h"
#if (COMPILE_TX == 1)
#include "binary_com.h"
#include "rxc.h"
#ifdef CLI_ENABLED
#include "dialog.h"
#endif
#include "frskytx.h"
#include "chpicker.h"
#include "TX.h"
#else
#include "mavlink.h"
#include "I2C.h"
#include "serialPPM.h"
#include "RX.h"
#endif