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/>.
16 #if defined(SKYARTEC_CC2500_INO)
18 #include "iface_cc2500.h"
20 //#define SKYARTEC_FORCE_ID
22 #define SKYARTEC_COARSE 0x00
23 #define SKYARTEC_TX_ADDR rx_tx_addr[1]
24 #define SKYARTEC_TX_CHANNEL rx_tx_addr[0]
41 const PROGMEM uint8_t SKYARTEC_init_values[] = {
42 /* 04 */ 0x13, 0x18, 0xFF, 0x05,
43 /* 08 */ 0x05, 0x43, 0xCD, 0x09, 0x00, 0x5D, 0x93, 0xB1 + SKYARTEC_COARSE,
44 /* 10 */ 0x2D, 0x20, 0x73, 0x22, 0xF8, 0x50, 0x07, 0x30,
45 /* 18 */ 0x18, 0x1D, 0x1C, 0xC7, 0x00, 0xB2, 0x87, 0x6B,
46 /* 20 */ 0xF8, 0xB6, 0x10, 0xEA, 0x0A, 0x00, 0x11, 0x41,
47 /* 28 */ 0x00, 0x59, 0x7F, 0x3F, 0x88, 0x31, 0x0B
50 static void __attribute__((unused)) SKYARTEC_rf_init()
52 CC2500_Strobe(CC2500_SIDLE);
54 for (uint8_t i = 4; i <= 0x2E; ++i)
55 CC2500_WriteReg(i, pgm_read_byte_near(&SKYARTEC_init_values[i-4]));
57 CC2500_WriteReg(CC2500_0C_FSCTRL0, option);
59 CC2500_SetTxRxMode(TX_EN);
61 CC2500_Strobe(CC2500_SFTX);
62 CC2500_Strobe(CC2500_SFRX);
63 CC2500_Strobe(CC2500_SXOFF);
64 CC2500_Strobe(CC2500_SIDLE);
67 static void __attribute__((unused)) SKYARTEC_send_data_packet()
69 //13 c5 01 0259 0168 0000 0259 030c 021a 0489 f3 7e 0a
71 packet[0] = 0x13; //Length
72 packet[1] = SKYARTEC_TX_ADDR; //Tx Addr?
73 packet[2] = 0x01; //???
75 for(uint8_t i = 0; i < 7; i++)
77 uint16_t value = convert_channel_16b_limit(CH_AETR[i],0x000,0x500);
78 packet[3+2*i] = value >> 8;
79 packet[4+2*i] = value & 0xff;
83 for(uint8_t i = 3; i <= 14; i++)
89 packet[19] = packet[3] + packet[5] + packet[7] + packet[9] + packet[11] + packet[13];
91 CC2500_WriteReg(CC2500_04_SYNC1, rx_tx_addr[3]);
92 CC2500_WriteReg(CC2500_05_SYNC0, rx_tx_addr[2]);
93 CC2500_WriteReg(CC2500_09_ADDR, SKYARTEC_TX_ADDR);
94 CC2500_WriteReg(CC2500_0A_CHANNR, SKYARTEC_TX_CHANNEL);
95 CC2500_WriteData(packet, 20);
98 static void __attribute__((unused)) SKYARTEC_send_bind_packet()
100 //0b 7d 01 01 b2 c5 4a 2f 00 00 c5 d6
101 packet[0] = 0x0b; //Length
105 packet[4] = rx_tx_addr[0];
106 packet[5] = rx_tx_addr[1];
107 packet[6] = rx_tx_addr[2];
108 packet[7] = rx_tx_addr[3];
111 packet[10] = SKYARTEC_TX_ADDR;
113 for(uint8_t i = 3; i < 11; i++)
116 CC2500_WriteReg(CC2500_04_SYNC1, 0x7d);
117 CC2500_WriteReg(CC2500_05_SYNC0, 0x7d);
118 CC2500_WriteReg(CC2500_09_ADDR, 0x7d);
119 CC2500_WriteReg(CC2500_0A_CHANNR, 0x7d);
120 CC2500_WriteData(packet, 12);
123 uint16_t SKYARTEC_callback()
127 CC2500_Strobe(CC2500_SIDLE);
128 if (phase == SKYARTEC_LAST)
131 // Tune frequency if it has been changed
132 CC2500_SetFreqOffset();
133 phase = SKYARTEC_PKT1;
139 if (phase == SKYARTEC_PKT1 && bind_counter)
141 SKYARTEC_send_bind_packet();
143 if(bind_counter == 0)
149 telemetry_set_input_sync(6000);
151 SKYARTEC_send_data_packet();
161 #ifdef SKYARTEC_FORCE_ID
162 memset(rx_tx_addr,0x00,4);
164 if(rx_tx_addr[0]==0) rx_tx_addr[0]=0xB2;
165 if(rx_tx_addr[1]==0) rx_tx_addr[1]=0xC5;
166 if(rx_tx_addr[2]==0) rx_tx_addr[2]=0x4A;
167 if(rx_tx_addr[3]==0) rx_tx_addr[3]=0x2F;
170 phase = SKYARTEC_PKT1;