Traxxas TQ 1st gen: try 5
[DIY-Multiprotocol-TX-Module.git] / Multiprotocol / TEST_cc2500.ino
blobbd838ccedc379a5059f1df7b440981e4301823af
1 /*
2  This project is free software: you can redistribute it and/or modify
3  it under the terms of the GNU General Public License as published by
4  the Free Software Foundation, either version 3 of the License, or
5  (at your option) any later version.
7 Multiprotocol is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10  GNU General Public License for more details.
12  You should have received a copy of the GNU General Public License
13  along with Multiprotocol.  If not, see <http://www.gnu.org/licenses/>.
14  */
16 #if defined(TEST_CC2500_INO)
18 #include "iface_nrf250k.h"
20 #define TEST_INITIAL_WAIT    500
21 #define TEST_PACKET_PERIOD   10000
22 #define TEST_PAYLOAD_SIZE    10
23 #define TEST_RF_NUM_CHANNELS 3
25 uint16_t TEST_callback()
27         option=1;
28         if(phase)
29                 XN297L_WritePayload(packet, TEST_PAYLOAD_SIZE);
30         else
31         {
32                 if(Channel_data[CH5]<CHANNEL_MIN_COMMAND)
33                         hopping_frequency_no=0;
34                 else if(Channel_data[CH5]>CHANNEL_MAX_COMMAND)
35                         hopping_frequency_no=2;
36                 else
37                         hopping_frequency_no=1;
38                 XN297L_Hopping(hopping_frequency_no);
39                 CC2500_WriteReg(CC2500_3E_PATABLE,convert_channel_8b(CH6));
40                 debugln("CH:%d, PWR:%d",hopping_frequency_no,convert_channel_8b(CH6));
41         }
42         phase ^= 1;
43         return TEST_PACKET_PERIOD>>1;
46 void TEST_init()
48         option=1;
50         hopping_frequency[0]=0;
51         hopping_frequency[1]=40;
52         hopping_frequency[2]=80;
53         XN297L_Init();
54         XN297L_HoppingCalib(TEST_RF_NUM_CHANNELS);      // Calibrate all channels
55         XN297L_SetTXAddr((uint8_t*)"RADIO", 5);
56         hopping_frequency_no = 0;
57         phase=0;
58         for(uint8_t i=0; i<TEST_PAYLOAD_SIZE; i++)
59                 packet[i]= i;
62 #endif