mirror of
https://github.com/pascallanger/DIY-Multiprotocol-TX-Module.git
synced 2025-02-04 17:48:11 +00:00
Change CC2500 emulation layer to support NRF24L01 @250K
This commit is contained in:
parent
8b7bd00a48
commit
73d7728e08
@ -16,7 +16,7 @@ Multiprotocol is distributed in the hope that it will be useful,
|
||||
|
||||
#if defined(GD00X_NRF24L01_INO)
|
||||
|
||||
#include "iface_xn297l.h"
|
||||
#include "iface_nrf250k.h"
|
||||
|
||||
//#define FORCE_GD00X_ORIGINAL_ID
|
||||
|
||||
|
@ -16,7 +16,7 @@ Multiprotocol is distributed in the hope that it will be useful,
|
||||
|
||||
#if defined(KF606_NRF24L01_INO)
|
||||
|
||||
#include "iface_xn297l.h"
|
||||
#include "iface_nrf250k.h"
|
||||
|
||||
//#define FORCE_KF606_ORIGINAL_ID
|
||||
|
||||
|
@ -18,7 +18,7 @@
|
||||
#if defined(MJXQ_NRF24L01_INO)
|
||||
|
||||
#include "iface_nrf24l01.h"
|
||||
#include "iface_xn297l.h"
|
||||
#include "iface_nrf250k.h"
|
||||
|
||||
#define MJXQ_BIND_COUNT 150
|
||||
#define MJXQ_PACKET_PERIOD 4000 // Timeout for callback in uSec
|
||||
|
@ -19,7 +19,7 @@
|
||||
#define VERSION_MAJOR 1
|
||||
#define VERSION_MINOR 3
|
||||
#define VERSION_REVISION 0
|
||||
#define VERSION_PATCH_LEVEL 68
|
||||
#define VERSION_PATCH_LEVEL 69
|
||||
|
||||
//******************
|
||||
// Protocols
|
||||
|
@ -13,7 +13,7 @@
|
||||
along with Multiprotocol. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifdef NRF24L01_INSTALLED
|
||||
#include "iface_xn297l.h"
|
||||
#include "iface_nrf250k.h"
|
||||
|
||||
static void __attribute__((unused)) XN297L_Init()
|
||||
{
|
||||
@ -350,4 +350,87 @@ static void __attribute__((unused)) XN297L_SetFreqOffset()
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void __attribute__((unused)) NRF250K_SetTXAddr(uint8_t* addr, uint8_t len)
|
||||
{
|
||||
#ifdef CC2500_INSTALLED
|
||||
if(option==0)
|
||||
#endif
|
||||
{//NRF
|
||||
NRF24L01_WriteRegisterMulti(NRF24L01_10_TX_ADDR, addr, len);
|
||||
return;
|
||||
}
|
||||
//CC2500
|
||||
#ifdef CC2500_INSTALLED
|
||||
if (len > 5) len = 5;
|
||||
if (len < 3) len = 3;
|
||||
xn297_addr_len = len;
|
||||
memcpy(xn297_tx_addr, addr, len);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void __attribute__((unused)) NRF250K_WritePayload(uint8_t* msg, uint8_t len)
|
||||
{
|
||||
#ifdef CC2500_INSTALLED
|
||||
if(option==0)
|
||||
#endif
|
||||
{//NRF
|
||||
NRF24L01_FlushTx();
|
||||
NRF24L01_WriteReg(NRF24L01_07_STATUS, _BV(NRF24L01_07_TX_DS) | _BV(NRF24L01_07_RX_DR) | _BV(NRF24L01_07_MAX_RT));
|
||||
NRF24L01_WritePayload(msg, len);
|
||||
return;
|
||||
}
|
||||
//CC2500
|
||||
#ifdef CC2500_INSTALLED
|
||||
uint8_t buf[35];
|
||||
uint8_t last = 0;
|
||||
uint8_t i;
|
||||
|
||||
//nrf preamble
|
||||
if(xn297_tx_addr[xn297_addr_len - 1] & 0x80)
|
||||
buf[0]=0x55;
|
||||
else
|
||||
buf[0]=0xAA;
|
||||
last++;
|
||||
// address
|
||||
for (i = 0; i < xn297_addr_len; ++i)
|
||||
buf[last++] = xn297_tx_addr[xn297_addr_len - i - 1];
|
||||
// payload
|
||||
for (i = 0; i < len; ++i)
|
||||
// bit-reverse bytes in packet
|
||||
buf[last++] = msg[i];
|
||||
|
||||
// crc
|
||||
uint16_t crc = 0xffff;
|
||||
for (uint8_t i = 1; i < last; ++i)
|
||||
crc = crc16_update(crc, buf[i], 8);
|
||||
buf[last++] = crc >> 8;
|
||||
buf[last++] = crc & 0xff;
|
||||
|
||||
// stop TX/RX
|
||||
CC2500_Strobe(CC2500_SIDLE);
|
||||
// flush tx FIFO
|
||||
CC2500_Strobe(CC2500_SFTX);
|
||||
// packet length
|
||||
CC2500_WriteReg(CC2500_3F_TXFIFO, last);
|
||||
// nrf packet
|
||||
CC2500_WriteRegisterMulti(CC2500_3F_TXFIFO, buf, last);
|
||||
// transmit
|
||||
CC2500_Strobe(CC2500_STX);
|
||||
#endif
|
||||
}
|
||||
|
||||
static boolean __attribute__((unused)) NRF250K_IsPacketSent()
|
||||
{
|
||||
#ifdef CC2500_INSTALLED
|
||||
if(option==0)
|
||||
#endif
|
||||
{ //NRF
|
||||
return NRF24L01_ReadReg(NRF24L01_07_STATUS) & _BV(NRF24L01_07_TX_DS);
|
||||
}
|
||||
#ifdef CC2500_INSTALLED
|
||||
return CC2500_ReadReg(CC2500_35_MARCSTATE)==0x01; // State is IDLE
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
@ -16,7 +16,7 @@
|
||||
|
||||
#if defined(V911S_NRF24L01_INO)
|
||||
|
||||
#include "iface_xn297l.h"
|
||||
#include "iface_nrf250k.h"
|
||||
|
||||
//#define V911S_ORIGINAL_ID
|
||||
|
||||
|
@ -16,7 +16,7 @@ Multiprotocol is distributed in the hope that it will be useful,
|
||||
|
||||
#if defined(XK_NRF24L01_INO)
|
||||
|
||||
#include "iface_xn297l.h"
|
||||
#include "iface_nrf250k.h"
|
||||
|
||||
//#define FORCE_XK_ORIGINAL_ID
|
||||
|
||||
|
@ -16,7 +16,7 @@ Multiprotocol is distributed in the hope that it will be useful,
|
||||
|
||||
#if defined(ZSX_NRF24L01_INO)
|
||||
|
||||
#include "iface_xn297l.h"
|
||||
#include "iface_nrf250k.h"
|
||||
|
||||
//#define FORCE_ZSX_ORIGINAL_ID
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#ifndef _IFACE_XN297L_H_
|
||||
#ifndef _IFACE_NRF250K_H_
|
||||
|
||||
#define _IFACE_XN297L_H_
|
||||
#define _IFACE_NRF250K_H_
|
||||
|
||||
#if defined (CC2500_INSTALLED)
|
||||
#include "iface_cc2500.h"
|
||||
@ -9,6 +9,7 @@
|
||||
#include "iface_nrf24l01.h"
|
||||
#endif
|
||||
|
||||
//XN297L
|
||||
static void __attribute__((unused)) XN297L_Init();
|
||||
static void __attribute__((unused)) XN297L_SetTXAddr(const uint8_t*, uint8_t);
|
||||
static void __attribute__((unused)) XN297L_WritePayload(uint8_t*, uint8_t);
|
||||
@ -19,4 +20,15 @@ static void __attribute__((unused)) XN297L_RFChannel(uint8_t);
|
||||
static void __attribute__((unused)) XN297L_SetPower();
|
||||
static void __attribute__((unused)) XN297L_SetFreqOffset();
|
||||
|
||||
//NRF250K
|
||||
#define NRF250K_Init() XN297L_Init()
|
||||
#define NRF250K_HoppingCalib(X) XN297L_HoppingCalib(X)
|
||||
#define NRF250K_Hopping(X) XN297L_Hopping(X)
|
||||
#define NRF250K_RFChannel(X) XN297L_RFChannel(X)
|
||||
#define NRF250K_SetPower() XN297L_SetPower()
|
||||
#define NRF250K_SetFreqOffset() XN297L_SetFreqOffset()
|
||||
static void __attribute__((unused)) NRF250K_SetTXAddr(uint8_t*, uint8_t);
|
||||
static void __attribute__((unused)) NRF250K_WritePayload(uint8_t*, uint8_t);
|
||||
static boolean __attribute__((unused)) NRF250K_IsPacketSent();
|
||||
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user