/* This project is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Multiprotocol is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Multiprotocol. If not, see . */ #include "config.h" #include "tx_def.h" #include "common.h" #include "Multiprotocol.h" #include "cc2500_spi.h" #include "input.h" /******************************/ /** FrSky D and X routines **/ /******************************/ #if defined(FRSKYD_CC2500_INO) || defined(FRSKYX_CC2500_INO) #endif /******************************/ /** FrSky V, D and X routines **/ /******************************/ #if defined(FRSKYV_CC2500_INO) || defined(FRSKYD_CC2500_INO) || defined(FRSKYX_CC2500_INO) uint8_t FRSKY_common_startreg_cc2500_conf[] = { CC2500_02_IOCFG0 , CC2500_00_IOCFG2 , CC2500_17_MCSM1 , CC2500_18_MCSM0 , CC2500_06_PKTLEN , CC2500_07_PKTCTRL1 , CC2500_08_PKTCTRL0 , CC2500_3E_PATABLE , CC2500_0B_FSCTRL1 , CC2500_0C_FSCTRL0 , // replaced by option value CC2500_0D_FREQ2 , CC2500_0E_FREQ1 , CC2500_0F_FREQ0 , CC2500_10_MDMCFG4 , CC2500_11_MDMCFG3 , CC2500_12_MDMCFG2 , CC2500_13_MDMCFG1 , CC2500_14_MDMCFG0 , CC2500_15_DEVIATN }; #if defined(FRSKYV_CC2500_INO) uint8_t FRSKYV_cc2500_conf[] = { /*02_IOCFG0*/ 0x06 , /*00_IOCFG2*/ 0x06 , /*17_MCSM1*/ 0x0c , /*18_MCSM0*/ 0x18 , /*06_PKTLEN*/ 0xff , /*07_PKTCTRL1*/ 0x04 , /*08_PKTCTRL0*/ 0x05 , /*3E_PATABLE*/ 0xfe , /*0B_FSCTRL1*/ 0x08 , /*0C_FSCTRL0*/ 0x00 , /*0D_FREQ2*/ 0x5c , /*0E_FREQ1*/ 0x58 , /*0F_FREQ0*/ 0x9d , /*10_MDMCFG4*/ 0xAA , /*11_MDMCFG3*/ 0x10 , /*12_MDMCFG2*/ 0x93 , /*13_MDMCFG1*/ 0x23 , /*14_MDMCFG0*/ 0x7a , /*15_DEVIATN*/ 0x41 }; #endif #if defined(FRSKYD_CC2500_INO) uint8_t FRSKYD_cc2500_conf[] = { /*02_IOCFG0*/ 0x06 , /*00_IOCFG2*/ 0x06 , /*17_MCSM1*/ 0x0c , /*18_MCSM0*/ 0x18 , /*06_PKTLEN*/ 0x19 , /*07_PKTCTRL1*/ 0x04 , /*08_PKTCTRL0*/ 0x05 , /*3E_PATABLE*/ 0xff , /*0B_FSCTRL1*/ 0x08 , /*0C_FSCTRL0*/ 0x00 , /*0D_FREQ2*/ 0x5c , /*0E_FREQ1*/ 0x76 , /*0F_FREQ0*/ 0x27 , /*10_MDMCFG4*/ 0xAA , /*11_MDMCFG3*/ 0x39 , /*12_MDMCFG2*/ 0x11 , /*13_MDMCFG1*/ 0x23 , /*14_MDMCFG0*/ 0x7a , /*15_DEVIATN*/ 0x42 }; #endif #if defined(FRSKYX_CC2500_INO) uint8_t FRSKYX_cc2500_conf[] = { //FRSKYX /*02_IOCFG0*/ 0x06 , /*00_IOCFG2*/ 0x06 , /*17_MCSM1*/ 0x0c , /*18_MCSM0*/ 0x18 , /*06_PKTLEN*/ 0x1E , /*07_PKTCTRL1*/ 0x04 , /*08_PKTCTRL0*/ 0x01 , /*3E_PATABLE*/ 0xff , /*0B_FSCTRL1*/ 0x0A , /*0C_FSCTRL0*/ 0x00 , /*0D_FREQ2*/ 0x5c , /*0E_FREQ1*/ 0x76 , /*0F_FREQ0*/ 0x27 , /*10_MDMCFG4*/ 0x7B , /*11_MDMCFG3*/ 0x61 , /*12_MDMCFG2*/ 0x13 , /*13_MDMCFG1*/ 0x23 , /*14_MDMCFG0*/ 0x7a , /*15_DEVIATN*/ 0x51 }; uint8_t FRSKYXEU_cc2500_conf[] = { /*02_IOCFG0*/ 0x06 , /*00_IOCFG2*/ 0x06 , /*17_MCSM1*/ 0x0E , /*18_MCSM0*/ 0x18 , /*06_PKTLEN*/ 0x23 , /*07_PKTCTRL1*/ 0x04 , /*08_PKTCTRL0*/ 0x01 , /*3E_PATABLE*/ 0xff , /*0B_FSCTRL1*/ 0x08 , /*0C_FSCTRL0*/ 0x00 , /*0D_FREQ2*/ 0x5c , /*0E_FREQ1*/ 0x80 , /*0F_FREQ0*/ 0x00 , /*10_MDMCFG4*/ 0x7B , /*11_MDMCFG3*/ 0xF8 , /*12_MDMCFG2*/ 0x03 , /*13_MDMCFG1*/ 0x23 , /*14_MDMCFG0*/ 0x7a , /*15_DEVIATN*/ 0x53 }; #endif void FRSKY_init_cc2500(const uint8_t *ptr) { for (uint8_t i = 0; i < 19; i++) { uint8_t reg = FRSKY_common_startreg_cc2500_conf[i]; uint8_t val = ptr[i]; if (reg == CC2500_0C_FSCTRL0) val = option; CC2500_WriteReg(reg, val); } prev_option = option ; // Save option to monitor FSCTRL0 change for (uint8_t i = 0; i < 17; i++) { uint8_t reg = FRSKY_common_end_cc2500_conf[i][0]; uint8_t val = FRSKY_common_end_cc2500_conf[i][1]; CC2500_WriteReg(reg, val); } CC2500_SetTxRxMode(TX_EN); CC2500_SetPower(); CC2500_Strobe(CC2500_SIDLE); // Go to idle... } #endif