2016-10-16 19:51:42 +02:00
|
|
|
|
2015-12-30 01:41:12 +01:00
|
|
|
/*
|
|
|
|
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 <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
//-------------------------------
|
|
|
|
//-------------------------------
|
|
|
|
//CC2500 SPI routines
|
|
|
|
//-------------------------------
|
|
|
|
//-------------------------------
|
2016-10-16 19:51:42 +02:00
|
|
|
#ifdef CC2500_INSTALLED
|
2015-12-30 01:41:12 +01:00
|
|
|
#include "iface_cc2500.h"
|
|
|
|
|
2016-08-16 16:27:53 +02:00
|
|
|
//----------------------------
|
|
|
|
void CC2500_WriteReg(uint8_t address, uint8_t data)
|
2015-12-30 01:41:12 +01:00
|
|
|
{
|
2016-08-16 16:27:53 +02:00
|
|
|
CC25_CSN_off;
|
|
|
|
SPI_Write(address);
|
|
|
|
NOP();
|
|
|
|
SPI_Write(data);
|
|
|
|
CC25_CSN_on;
|
|
|
|
}
|
2015-12-30 01:41:12 +01:00
|
|
|
|
|
|
|
//----------------------
|
2016-04-06 12:57:42 +02:00
|
|
|
static void CC2500_ReadRegisterMulti(uint8_t address, uint8_t data[], uint8_t length)
|
2015-12-30 01:41:12 +01:00
|
|
|
{
|
|
|
|
CC25_CSN_off;
|
2016-08-16 16:27:53 +02:00
|
|
|
SPI_Write(CC2500_READ_BURST | address);
|
2015-12-30 01:41:12 +01:00
|
|
|
for(uint8_t i = 0; i < length; i++)
|
2016-08-01 21:57:18 +02:00
|
|
|
data[i] = SPI_Read();
|
2015-12-30 01:41:12 +01:00
|
|
|
CC25_CSN_on;
|
|
|
|
}
|
|
|
|
|
2016-08-16 16:27:53 +02:00
|
|
|
//--------------------------------------------
|
|
|
|
static uint8_t CC2500_ReadReg(uint8_t address)
|
|
|
|
{
|
|
|
|
uint8_t result;
|
|
|
|
CC25_CSN_off;
|
|
|
|
SPI_Write(CC2500_READ_SINGLE | address);
|
|
|
|
result = SPI_Read();
|
|
|
|
CC25_CSN_on;
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------
|
|
|
|
void CC2500_ReadData(uint8_t *dpbuffer, uint8_t len)
|
|
|
|
{
|
|
|
|
CC2500_ReadRegisterMulti(CC2500_3F_RXFIFO, dpbuffer, len);
|
|
|
|
}
|
|
|
|
|
2015-12-30 01:41:12 +01:00
|
|
|
//*********************************************
|
2016-08-16 16:27:53 +02:00
|
|
|
void CC2500_Strobe(uint8_t state)
|
|
|
|
{
|
|
|
|
CC25_CSN_off;
|
|
|
|
SPI_Write(state);
|
|
|
|
CC25_CSN_on;
|
|
|
|
}
|
2015-12-30 01:41:12 +01:00
|
|
|
|
Core and all protocols have been updated
Lot of changes in this new master
ChangeLog:
- Core: LED flashing when an invalid protocol has been selected
- Core: Channels 5 to 12 available as switches for all protocols: code
and size optimization
- Documentation (readme.md): fully updated, all protocols/sub
protocols/channels described, models example, many improvements
- All protocols have been updated in some way, here are some highlights:
* Bayang: added picture, video and inverted channels
* CG023->H8_3D: added light and calibration channels
* CX10: added sub protocols Q282, JC3015_1, JC3015_2, MK33041
* ESky: added new protocol - untested
* Hubsan: added compatibility with the new Hubsan Plus protocol
* KN: fully rewritten protocol: added sub protocols WLTOYS and FEILUN,
11 channels support
New version successfully tested on all my models: Flysky RX/F939/V911
protocol Flysky, Frsky RX protocol Frsky, Hubsan X4 protocol Hubsan,
Hisky HCP100/HCP80 protocol Hisky, HK-3000/HK3100 RX protocol
Hisky/HK310, XINXUN X39 protocol YD717/XINXUN, Symax X5C-1 protocol
SymaX/SYMAX, Cheerson CX-10A protocol CX10/BLUE, Eachine 3D-X4 protocol
CG023.
To access new protocols from er9x/ersky9x, you need to build a version
from this github repository https://github.com/pascallanger/mbtx based
on the latest er9x r820 and ersky9x r218.
2016-01-20 10:50:56 +01:00
|
|
|
static void CC2500_WriteRegisterMulti(uint8_t address, const uint8_t data[], uint8_t length)
|
2015-12-30 01:41:12 +01:00
|
|
|
{
|
|
|
|
CC25_CSN_off;
|
2016-08-01 21:57:18 +02:00
|
|
|
SPI_Write(CC2500_WRITE_BURST | address);
|
2015-12-30 01:41:12 +01:00
|
|
|
for(uint8_t i = 0; i < length; i++)
|
2016-08-01 21:57:18 +02:00
|
|
|
SPI_Write(data[i]);
|
2015-12-30 01:41:12 +01:00
|
|
|
CC25_CSN_on;
|
|
|
|
}
|
|
|
|
|
2016-04-06 12:57:42 +02:00
|
|
|
void CC2500_WriteData(uint8_t *dpbuffer, uint8_t len)
|
2015-12-30 01:41:12 +01:00
|
|
|
{
|
2016-08-16 16:27:53 +02:00
|
|
|
CC2500_Strobe(CC2500_SFTX);
|
2015-12-30 01:41:12 +01:00
|
|
|
CC2500_WriteRegisterMulti(CC2500_3F_TXFIFO, dpbuffer, len);
|
2016-08-16 16:27:53 +02:00
|
|
|
CC2500_Strobe(CC2500_STX);
|
2015-12-30 01:41:12 +01:00
|
|
|
}
|
|
|
|
|
2016-08-16 16:27:53 +02:00
|
|
|
void CC2500_SetTxRxMode(uint8_t mode)
|
2015-12-30 01:41:12 +01:00
|
|
|
{
|
2016-08-16 16:27:53 +02:00
|
|
|
if(mode == TX_EN)
|
|
|
|
{//from deviation firmware
|
|
|
|
CC2500_WriteReg(CC2500_00_IOCFG2, 0x2F);
|
2016-12-06 22:30:48 +01:00
|
|
|
CC2500_WriteReg(CC2500_02_IOCFG0, 0x2F | 0x40);
|
2016-08-16 16:27:53 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
if (mode == RX_EN)
|
|
|
|
{
|
|
|
|
CC2500_WriteReg(CC2500_02_IOCFG0, 0x2F);
|
|
|
|
CC2500_WriteReg(CC2500_00_IOCFG2, 0x2F | 0x40);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC2500_WriteReg(CC2500_02_IOCFG0, 0x2F);
|
|
|
|
CC2500_WriteReg(CC2500_00_IOCFG2, 0x2F);
|
|
|
|
}
|
2015-12-30 01:41:12 +01:00
|
|
|
}
|
2016-08-16 16:27:53 +02:00
|
|
|
|
2015-12-30 01:41:12 +01:00
|
|
|
//------------------------
|
Core and all protocols have been updated
Lot of changes in this new master
ChangeLog:
- Core: LED flashing when an invalid protocol has been selected
- Core: Channels 5 to 12 available as switches for all protocols: code
and size optimization
- Documentation (readme.md): fully updated, all protocols/sub
protocols/channels described, models example, many improvements
- All protocols have been updated in some way, here are some highlights:
* Bayang: added picture, video and inverted channels
* CG023->H8_3D: added light and calibration channels
* CX10: added sub protocols Q282, JC3015_1, JC3015_2, MK33041
* ESky: added new protocol - untested
* Hubsan: added compatibility with the new Hubsan Plus protocol
* KN: fully rewritten protocol: added sub protocols WLTOYS and FEILUN,
11 channels support
New version successfully tested on all my models: Flysky RX/F939/V911
protocol Flysky, Frsky RX protocol Frsky, Hubsan X4 protocol Hubsan,
Hisky HCP100/HCP80 protocol Hisky, HK-3000/HK3100 RX protocol
Hisky/HK310, XINXUN X39 protocol YD717/XINXUN, Symax X5C-1 protocol
SymaX/SYMAX, Cheerson CX-10A protocol CX10/BLUE, Eachine 3D-X4 protocol
CG023.
To access new protocols from er9x/ersky9x, you need to build a version
from this github repository https://github.com/pascallanger/mbtx based
on the latest er9x r820 and ersky9x r218.
2016-01-20 10:50:56 +01:00
|
|
|
/*static void cc2500_resetChip(void)
|
2015-12-30 01:41:12 +01:00
|
|
|
{
|
|
|
|
// Toggle chip select signal
|
|
|
|
CC25_CSN_on;
|
2016-08-01 21:57:18 +02:00
|
|
|
delayMicroseconds(30);
|
2015-12-30 01:41:12 +01:00
|
|
|
CC25_CSN_off;
|
2016-08-01 21:57:18 +02:00
|
|
|
delayMicroseconds(30);
|
2015-12-30 01:41:12 +01:00
|
|
|
CC25_CSN_on;
|
2016-08-01 21:57:18 +02:00
|
|
|
delayMicroseconds(45);
|
2016-04-06 12:57:42 +02:00
|
|
|
CC2500_Strobe(CC2500_SRES);
|
2015-12-30 01:41:12 +01:00
|
|
|
_delay_ms(100);
|
|
|
|
}
|
Core and all protocols have been updated
Lot of changes in this new master
ChangeLog:
- Core: LED flashing when an invalid protocol has been selected
- Core: Channels 5 to 12 available as switches for all protocols: code
and size optimization
- Documentation (readme.md): fully updated, all protocols/sub
protocols/channels described, models example, many improvements
- All protocols have been updated in some way, here are some highlights:
* Bayang: added picture, video and inverted channels
* CG023->H8_3D: added light and calibration channels
* CX10: added sub protocols Q282, JC3015_1, JC3015_2, MK33041
* ESky: added new protocol - untested
* Hubsan: added compatibility with the new Hubsan Plus protocol
* KN: fully rewritten protocol: added sub protocols WLTOYS and FEILUN,
11 channels support
New version successfully tested on all my models: Flysky RX/F939/V911
protocol Flysky, Frsky RX protocol Frsky, Hubsan X4 protocol Hubsan,
Hisky HCP100/HCP80 protocol Hisky, HK-3000/HK3100 RX protocol
Hisky/HK310, XINXUN X39 protocol YD717/XINXUN, Symax X5C-1 protocol
SymaX/SYMAX, Cheerson CX-10A protocol CX10/BLUE, Eachine 3D-X4 protocol
CG023.
To access new protocols from er9x/ersky9x, you need to build a version
from this github repository https://github.com/pascallanger/mbtx based
on the latest er9x r820 and ersky9x r218.
2016-01-20 10:50:56 +01:00
|
|
|
*/
|
2015-12-30 01:41:12 +01:00
|
|
|
uint8_t CC2500_Reset()
|
|
|
|
{
|
2016-04-06 12:57:42 +02:00
|
|
|
CC2500_Strobe(CC2500_SRES);
|
2016-08-22 18:17:14 +02:00
|
|
|
delayMilliseconds(1);
|
2015-12-30 01:41:12 +01:00
|
|
|
CC2500_SetTxRxMode(TXRX_OFF);
|
2016-04-06 12:57:42 +02:00
|
|
|
return CC2500_ReadReg(CC2500_0E_FREQ1) == 0xC4;//check if reset
|
2015-12-30 01:41:12 +01:00
|
|
|
}
|
Core and all protocols have been updated
Lot of changes in this new master
ChangeLog:
- Core: LED flashing when an invalid protocol has been selected
- Core: Channels 5 to 12 available as switches for all protocols: code
and size optimization
- Documentation (readme.md): fully updated, all protocols/sub
protocols/channels described, models example, many improvements
- All protocols have been updated in some way, here are some highlights:
* Bayang: added picture, video and inverted channels
* CG023->H8_3D: added light and calibration channels
* CX10: added sub protocols Q282, JC3015_1, JC3015_2, MK33041
* ESky: added new protocol - untested
* Hubsan: added compatibility with the new Hubsan Plus protocol
* KN: fully rewritten protocol: added sub protocols WLTOYS and FEILUN,
11 channels support
New version successfully tested on all my models: Flysky RX/F939/V911
protocol Flysky, Frsky RX protocol Frsky, Hubsan X4 protocol Hubsan,
Hisky HCP100/HCP80 protocol Hisky, HK-3000/HK3100 RX protocol
Hisky/HK310, XINXUN X39 protocol YD717/XINXUN, Symax X5C-1 protocol
SymaX/SYMAX, Cheerson CX-10A protocol CX10/BLUE, Eachine 3D-X4 protocol
CG023.
To access new protocols from er9x/ersky9x, you need to build a version
from this github repository https://github.com/pascallanger/mbtx based
on the latest er9x r820 and ersky9x r218.
2016-01-20 10:50:56 +01:00
|
|
|
/*
|
|
|
|
static void CC2500_SetPower_Value(uint8_t power)
|
2015-12-30 01:41:12 +01:00
|
|
|
{
|
|
|
|
const unsigned char patable[8]= {
|
|
|
|
0xC5, // -12dbm
|
|
|
|
0x97, // -10dbm
|
|
|
|
0x6E, // -8dbm
|
|
|
|
0x7F, // -6dbm
|
|
|
|
0xA9, // -4dbm
|
|
|
|
0xBB, // -2dbm
|
|
|
|
0xFE, // 0dbm
|
|
|
|
0xFF // 1.5dbm
|
|
|
|
};
|
|
|
|
if (power > 7)
|
|
|
|
power = 7;
|
2016-04-06 12:57:42 +02:00
|
|
|
CC2500_WriteReg(CC2500_3E_PATABLE, patable[power]);
|
2015-12-30 01:41:12 +01:00
|
|
|
}
|
Core and all protocols have been updated
Lot of changes in this new master
ChangeLog:
- Core: LED flashing when an invalid protocol has been selected
- Core: Channels 5 to 12 available as switches for all protocols: code
and size optimization
- Documentation (readme.md): fully updated, all protocols/sub
protocols/channels described, models example, many improvements
- All protocols have been updated in some way, here are some highlights:
* Bayang: added picture, video and inverted channels
* CG023->H8_3D: added light and calibration channels
* CX10: added sub protocols Q282, JC3015_1, JC3015_2, MK33041
* ESky: added new protocol - untested
* Hubsan: added compatibility with the new Hubsan Plus protocol
* KN: fully rewritten protocol: added sub protocols WLTOYS and FEILUN,
11 channels support
New version successfully tested on all my models: Flysky RX/F939/V911
protocol Flysky, Frsky RX protocol Frsky, Hubsan X4 protocol Hubsan,
Hisky HCP100/HCP80 protocol Hisky, HK-3000/HK3100 RX protocol
Hisky/HK310, XINXUN X39 protocol YD717/XINXUN, Symax X5C-1 protocol
SymaX/SYMAX, Cheerson CX-10A protocol CX10/BLUE, Eachine 3D-X4 protocol
CG023.
To access new protocols from er9x/ersky9x, you need to build a version
from this github repository https://github.com/pascallanger/mbtx based
on the latest er9x r820 and ersky9x r218.
2016-01-20 10:50:56 +01:00
|
|
|
*/
|
2015-12-30 01:41:12 +01:00
|
|
|
void CC2500_SetPower()
|
|
|
|
{
|
|
|
|
uint8_t power=CC2500_BIND_POWER;
|
2018-01-03 13:04:58 +01:00
|
|
|
if(IS_BIND_DONE)
|
2017-02-23 11:23:25 +01:00
|
|
|
#ifdef CC2500_ENABLE_LOW_POWER
|
|
|
|
power=IS_POWER_FLAG_on?CC2500_HIGH_POWER:CC2500_LOW_POWER;
|
|
|
|
#else
|
|
|
|
power=CC2500_HIGH_POWER;
|
|
|
|
#endif
|
2020-05-02 18:20:47 +02:00
|
|
|
if(IS_LBT_POWER_on)
|
|
|
|
{
|
|
|
|
power=CC2500_LBT_POWER;
|
|
|
|
LBT_POWER_off; // Only accept once
|
|
|
|
}
|
2016-01-02 13:51:16 +01:00
|
|
|
if(IS_RANGE_FLAG_on)
|
|
|
|
power=CC2500_RANGE_POWER;
|
2016-08-15 11:52:43 +02:00
|
|
|
if(prev_power != power)
|
|
|
|
{
|
|
|
|
CC2500_WriteReg(CC2500_3E_PATABLE, power);
|
|
|
|
prev_power=power;
|
|
|
|
}
|
2015-12-30 01:41:12 +01:00
|
|
|
}
|
2021-01-21 11:46:54 +01:00
|
|
|
|
|
|
|
void __attribute__((unused)) CC2500_SetFreqOffset()
|
|
|
|
{
|
|
|
|
if(prev_option != option)
|
|
|
|
{
|
|
|
|
prev_option = option;
|
|
|
|
CC2500_WriteReg(CC2500_0C_FSCTRL0, option);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void __attribute__((unused)) CC2500_250K_Init()
|
|
|
|
{
|
|
|
|
CC2500_Strobe(CC2500_SIDLE);
|
|
|
|
|
|
|
|
// Address Config = No address check
|
|
|
|
// Base Frequency = 2400
|
|
|
|
// CRC Autoflush = false
|
|
|
|
// CRC Enable = false
|
|
|
|
// Channel Spacing = 333.251953
|
|
|
|
// Data Format = Normal mode
|
|
|
|
// Data Rate = 249.939
|
|
|
|
// Deviation = 126.953125
|
|
|
|
// Device Address = 0
|
|
|
|
// Manchester Enable = false
|
|
|
|
// Modulated = true
|
|
|
|
// Modulation Format = GFSK
|
|
|
|
// Packet Length Mode = Variable packet length mode. Packet length configured by the first byte after sync word
|
|
|
|
// RX Filter BW = 203.125000
|
|
|
|
// Sync Word Qualifier Mode = No preamble/sync
|
|
|
|
// TX Power = 0
|
|
|
|
// Whitening = false
|
|
|
|
// Fast Frequency Hopping - no PLL auto calibration
|
2021-03-17 17:05:42 +01:00
|
|
|
/* //Previous config
|
2021-01-21 11:46:54 +01:00
|
|
|
CC2500_WriteReg(CC2500_08_PKTCTRL0, 0x01); // Packet Automation Control
|
|
|
|
CC2500_WriteReg(CC2500_0B_FSCTRL1, 0x0A); // Frequency Synthesizer Control
|
|
|
|
CC2500_WriteReg(CC2500_0C_FSCTRL0, option); // Frequency offset hack
|
|
|
|
CC2500_WriteReg(CC2500_0D_FREQ2, 0x5C); // Frequency Control Word, High Byte
|
|
|
|
CC2500_WriteReg(CC2500_0E_FREQ1, 0x4E); // Frequency Control Word, Middle Byte
|
|
|
|
CC2500_WriteReg(CC2500_0F_FREQ0, 0xC3); // Frequency Control Word, Low Byte
|
|
|
|
CC2500_WriteReg(CC2500_10_MDMCFG4, 0x8D); // Modem Configuration
|
|
|
|
CC2500_WriteReg(CC2500_11_MDMCFG3, 0x3B); // Modem Configuration
|
|
|
|
CC2500_WriteReg(CC2500_12_MDMCFG2, 0x10); // Modem Configuration
|
|
|
|
CC2500_WriteReg(CC2500_13_MDMCFG1, 0x23); // Modem Configuration
|
|
|
|
CC2500_WriteReg(CC2500_14_MDMCFG0, 0xA4); // Modem Configuration
|
|
|
|
CC2500_WriteReg(CC2500_15_DEVIATN, 0x62); // Modem Deviation Setting
|
|
|
|
CC2500_WriteReg(CC2500_18_MCSM0, 0x08); // Main Radio Control State Machine Configuration
|
|
|
|
CC2500_WriteReg(CC2500_19_FOCCFG, 0x1D); // Frequency Offset Compensation Configuration
|
|
|
|
CC2500_WriteReg(CC2500_1A_BSCFG, 0x1C); // Bit Synchronization Configuration
|
|
|
|
CC2500_WriteReg(CC2500_1B_AGCCTRL2, 0xC7); // AGC Control
|
|
|
|
CC2500_WriteReg(CC2500_1C_AGCCTRL1, 0x00); // AGC Control
|
|
|
|
CC2500_WriteReg(CC2500_1D_AGCCTRL0, 0xB0); // AGC Control
|
|
|
|
CC2500_WriteReg(CC2500_21_FREND1, 0xB6); // Front End RX Configuration
|
|
|
|
CC2500_WriteReg(CC2500_23_FSCAL3, 0xEA); // Frequency Synthesizer Calibration
|
|
|
|
CC2500_WriteReg(CC2500_25_FSCAL1, 0x00); // Frequency Synthesizer Calibration
|
|
|
|
CC2500_WriteReg(CC2500_26_FSCAL0, 0x11); // Frequency Synthesizer Calibration
|
2021-03-17 17:05:42 +01:00
|
|
|
*/
|
|
|
|
CC2500_WriteReg(CC2500_07_PKTCTRL1, 0x05); // Packet Automation Control, address check true auto append RSSI & LQI
|
|
|
|
CC2500_WriteReg(CC2500_08_PKTCTRL0, 0x00); // Packet Automation Control, fixed packet len
|
|
|
|
CC2500_WriteReg(CC2500_0B_FSCTRL1, 0x0A); // Frequency Synthesizer Control (IF Frequency)
|
|
|
|
CC2500_WriteReg(CC2500_0C_FSCTRL0, 0x00); // Frequency Synthesizer Control
|
|
|
|
CC2500_WriteReg(CC2500_0D_FREQ2, 0x5C); // Frequency Control Word, High Byte
|
|
|
|
CC2500_WriteReg(CC2500_0E_FREQ1, 0x4E); // Frequency Control Word, Middle Byte
|
|
|
|
CC2500_WriteReg(CC2500_0F_FREQ0, 0xC5); // Frequency Control Word, Low Byte
|
|
|
|
CC2500_WriteReg(CC2500_10_MDMCFG4, 0x3D); // Modem Configuration Set to 406kHz BW filter
|
|
|
|
CC2500_WriteReg(CC2500_11_MDMCFG3, 0x3B); // Modem Configuration
|
|
|
|
CC2500_WriteReg(CC2500_12_MDMCFG2, 0x10); // Modem Configuration, GFSK, no preambule and no sync word -> TX by default
|
|
|
|
CC2500_WriteReg(CC2500_13_MDMCFG1, 0x03); // Modem Configuration, 2 bytes of preamble
|
|
|
|
CC2500_WriteReg(CC2500_14_MDMCFG0, 0xA4); // Modem Configuration
|
|
|
|
CC2500_WriteReg(CC2500_15_DEVIATN, 0x62); // Modem Deviation Setting
|
|
|
|
CC2500_WriteReg(CC2500_18_MCSM0, 0x08); // Main Radio Control State Machine Configuration
|
|
|
|
CC2500_WriteReg(CC2500_19_FOCCFG, 0x1D); // Frequency Offset Compensation Configuration
|
|
|
|
CC2500_WriteReg(CC2500_1A_BSCFG, 0x1C); // Bit Synchronization Configuration
|
|
|
|
CC2500_WriteReg(CC2500_1B_AGCCTRL2, 0xC7); // AGC Control
|
|
|
|
CC2500_WriteReg(CC2500_1C_AGCCTRL1, 0x00); // AGC Control
|
|
|
|
CC2500_WriteReg(CC2500_1D_AGCCTRL0, 0xB0); // AGC Control
|
|
|
|
CC2500_WriteReg(CC2500_21_FREND1, 0xB6); // Front End RX Configuration
|
|
|
|
CC2500_WriteReg(CC2500_23_FSCAL3, 0xEA); // Frequency Synthesizer Calibration
|
|
|
|
CC2500_WriteReg(CC2500_25_FSCAL1, 0x00); // Frequency Synthesizer Calibration
|
|
|
|
CC2500_WriteReg(CC2500_26_FSCAL0, 0x11); // Frequency Synthesizer Calibration
|
|
|
|
|
|
|
|
//Prep RX
|
|
|
|
// Set first 3 bytes of rx addr in [0]->SYNC1, [1]->SYNC0 and [2]->ADDR
|
|
|
|
// CC2500_WriteReg(CC2500_04_SYNC1, [0]); // Sync word, high byte
|
|
|
|
// CC2500_WriteReg(CC2500_05_SYNC0, [1]); // Sync word, low byte
|
|
|
|
// CC2500_WriteReg(CC2500_09_ADDR, [2]); // Set addr
|
|
|
|
//RX
|
|
|
|
// CC2500_WriteReg(CC2500_12_MDMCFG2, 0x12); // Modem Configuration, GFSK, 16/16 Sync Word TX&RX
|
|
|
|
//TX
|
|
|
|
// CC2500_WriteReg(CC2500_12_MDMCFG2, 0x10); // Modem Configuration, GFSK, no preambule and no sync word
|
|
|
|
// need to set packet length before sending/receiving
|
|
|
|
// CC2500_WriteReg(CC2500_06_PKTLEN, cc2500_packet_len); // Packet len, fix packet len
|
2021-01-21 11:46:54 +01:00
|
|
|
|
|
|
|
CC2500_SetTxRxMode(TX_EN);
|
|
|
|
CC2500_SetPower();
|
|
|
|
}
|
|
|
|
void __attribute__((unused)) CC2500_250K_HoppingCalib(uint8_t num_freq)
|
|
|
|
{
|
|
|
|
for (uint8_t i = 0; i < num_freq; i++)
|
|
|
|
{
|
|
|
|
CC2500_Strobe(CC2500_SIDLE);
|
|
|
|
// spacing is 333.25 kHz, must multiply channel by 3
|
|
|
|
CC2500_WriteReg(CC2500_0A_CHANNR, hopping_frequency[i]*3);
|
|
|
|
// calibrate
|
|
|
|
CC2500_Strobe(CC2500_SCAL);
|
|
|
|
delayMicroseconds(900);
|
|
|
|
calData[i]=CC2500_ReadReg(CC2500_25_FSCAL1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void __attribute__((unused)) CC2500_250K_Hopping(uint8_t index)
|
|
|
|
{
|
|
|
|
// spacing is 333.25 kHz, must multiply channel by 3
|
|
|
|
CC2500_WriteReg(CC2500_0A_CHANNR, hopping_frequency[index] * 3);
|
|
|
|
// set PLL calibration
|
|
|
|
CC2500_WriteReg(CC2500_25_FSCAL1, calData[index]);
|
|
|
|
}
|
|
|
|
void __attribute__((unused)) CC2500_250K_RFChannel(uint8_t number)
|
|
|
|
{
|
|
|
|
CC2500_Strobe(CC2500_SIDLE);
|
|
|
|
// spacing is 333.25 kHz, must multiply channel by 3
|
|
|
|
CC2500_WriteReg(CC2500_0A_CHANNR, number*3);
|
|
|
|
// calibrate
|
|
|
|
CC2500_Strobe(CC2500_SCAL);
|
|
|
|
delayMicroseconds(900);
|
|
|
|
}
|
2016-10-16 19:51:42 +02:00
|
|
|
#endif
|