Use mysensors built-in nrf24 library for RPi

This commit is contained in:
Marcelo Aquino
2016-09-14 23:26:12 -03:00
parent 4175a5f423
commit fab2112f9b
22 changed files with 4051 additions and 544 deletions
+43 -10
View File
@@ -29,8 +29,13 @@ LOCAL uint8_t MY_RF24_NODE_ADDRESS = AUTO;
LOCAL RF24_receiveCallbackType RF24_receiveCallback = NULL;
#endif
#ifdef LINUX_ARCH_RASPBERRYPI
uint8_t spi_rxbuff[32+1] ; //SPI receive buffer (payload max 32 bytes)
uint8_t spi_txbuff[32+1] ; //SPI transmit buffer (payload max 32 bytes + 1 byte for the command)
#endif
LOCAL void RF24_csn(bool level) {
digitalWrite(MY_RF24_CS_PIN, level);
digitalWrite(MY_RF24_CS_PIN, level);
}
LOCAL void RF24_ce(bool level) {
@@ -38,6 +43,7 @@ LOCAL void RF24_ce(bool level) {
}
LOCAL uint8_t RF24_spiMultiByteTransfer(uint8_t cmd, uint8_t* buf, uint8_t len, bool aReadMode) {
uint8_t status;
uint8_t* current = buf;
#if !defined(MY_SOFTSPI)
_SPI.beginTransaction(SPISettings(MY_RF24_SPI_MAX_SPEED, MY_RF24_SPI_DATA_ORDER, MY_RF24_SPI_DATA_MODE));
@@ -45,13 +51,40 @@ LOCAL uint8_t RF24_spiMultiByteTransfer(uint8_t cmd, uint8_t* buf, uint8_t len,
RF24_csn(LOW);
// timing
delayMicroseconds(10);
uint8_t status = _SPI.transfer( cmd );
while ( len-- ) {
if (aReadMode) {
status = _SPI.transfer( NOP );
if(buf != NULL) *current++ = status;
} else status = _SPI.transfer(*current++);
}
#ifdef LINUX_ARCH_RASPBERRYPI
uint8_t * prx = spi_rxbuff;
uint8_t * ptx = spi_txbuff;
uint8_t size = len + 1; // Add register value to transmit buffer
*ptx++ = cmd;
while ( len-- ) {
if (aReadMode) {
*ptx++ = NOP ;
} else {
*ptx++ = *current++;
}
}
_SPI.transfernb( (char *) spi_txbuff, (char *) spi_rxbuff, size);
if (aReadMode) {
if (size == 2) {
status = *++prx; // result is 2nd byte of receive buffer
} else {
status = *prx++; // status is 1st byte of receive buffer
// decrement before to skip status byte
while (--size) { *buf++ = *prx++; }
}
} else {
status = *prx; // status is 1st byte of receive buffer
}
#else
status = _SPI.transfer( cmd );
while ( len-- ) {
if (aReadMode) {
status = _SPI.transfer( NOP );
if (buf != NULL) *current++ = status;
} else status = _SPI.transfer(*current++);
}
#endif
RF24_csn(HIGH);
#if !defined(MY_SOFTSPI)
_SPI.endTransaction();
@@ -268,7 +301,7 @@ LOCAL void RF24_irqHandler( void )
// rx coming in during our stay will not be handled and will cause characters to be lost.
// As a workaround we re-enable interrupts to allow nested processing of other interrupts.
// Our own handler is disconnected to prevent recursive calling of this handler.
#ifdef MY_GATEWAY_SERIAL
#if defined(MY_GATEWAY_SERIAL) && !defined(__linux__)
detachInterrupt(digitalPinToInterrupt(MY_RF24_IRQ_PIN));
interrupts();
#endif
@@ -283,7 +316,7 @@ LOCAL void RF24_irqHandler( void )
RF24_receiveCallback(); // Must call RF24_readMessage(), which will clear RX_DR IRQ !
}
// Restore our interrupt handler.
#ifdef MY_GATEWAY_SERIAL
#if defined(MY_GATEWAY_SERIAL) && !defined(__linux__)
noInterrupts();
attachInterrupt(digitalPinToInterrupt(MY_RF24_IRQ_PIN), RF24_irqHandler, FALLING);
#endif
-200
View File
@@ -1,200 +0,0 @@
/**
* The MySensors Arduino library handles the wireless radio link and protocol
* between your home built sensors/actuators and HA controller of choice.
* The sensors forms a self healing radio network with optional repeaters. Each
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
* network topology allowing messages to be routed to nodes.
*
* Created by Marcelo Aquino <marceloaqno@gmail.org>
* Copyright (C) 2016 Marcelo Aquino
* Full contributor list: https://github.com/mysensors/MySensors/graphs/contributors
*
* Documentation: http://www.mysensors.org
* Support Forum: http://forum.mysensors.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
* This is a wrapper for maniacbug's RF24 library, copyright (C) 2011 J. Coliz <maniacbug@ymail.com>
*/
#include <RF24.h>
#include "RF24_Linux.h"
#ifdef MY_RX_MESSAGE_BUFFER_FEATURE
typedef void (*RF24_receiveCallbackType)(void);
void (* RF24_receiveCallback)(void) = NULL;
static pthread_mutex_t rf24_mutex = PTHREAD_MUTEX_INITIALIZER;
#endif
static uint8_t MY_RF24_BASE_ADDR[MY_RF24_ADDR_WIDTH] = { MY_RF24_BASE_RADIO_ID };
static uint8_t MY_RF24_NODE_ADDRESS = AUTO;
RF24 _rf24(RF24_CE_PIN, RF24_CS_PIN, MY_RF24_SPI_MAX_SPEED);
static void RF24_startListening(void) {
RF24_DEBUG(PSTR("start listening\n"));
_rf24.startListening();
}
static void RF24_powerDown(void) {
#ifdef MY_RX_MESSAGE_BUFFER_FEATURE
pthread_mutex_lock(&rf24_mutex);
#endif
_rf24.powerDown();
#ifdef MY_RX_MESSAGE_BUFFER_FEATURE
pthread_mutex_unlock(&rf24_mutex);
#endif
}
static bool RF24_sendMessage( uint8_t recipient, const void* buf, uint8_t len ) {
#ifdef MY_RX_MESSAGE_BUFFER_FEATURE
pthread_mutex_lock(&rf24_mutex);
#endif
// Make sure radio has powered up
_rf24.powerUp();
_rf24.stopListening();
RF24_DEBUG(PSTR("send message to %d, len=%d\n"), recipient,len);
MY_RF24_BASE_ADDR[0] = recipient;
_rf24.openWritingPipe(MY_RF24_BASE_ADDR);
bool ok = _rf24.write(buf, len, recipient == BROADCAST_ADDRESS);
_rf24.startListening();
#ifdef MY_RX_MESSAGE_BUFFER_FEATURE
pthread_mutex_unlock(&rf24_mutex);
#endif
return ok;
}
static bool RF24_isDataAvailable() {
#ifdef MY_RX_MESSAGE_BUFFER_FEATURE
pthread_mutex_lock(&rf24_mutex);
#endif
uint8_t pipe_num = 255;
_rf24.available(&pipe_num);
#ifdef MY_RX_MESSAGE_BUFFER_FEATURE
pthread_mutex_unlock(&rf24_mutex);
#endif
return (pipe_num <= 5);
}
static uint8_t RF24_readMessage( void* buf) {
#ifdef MY_RX_MESSAGE_BUFFER_FEATURE
pthread_mutex_lock(&rf24_mutex);
#endif
uint8_t len = _rf24.getDynamicPayloadSize();
_rf24.read(buf, len);
#ifdef MY_RX_MESSAGE_BUFFER_FEATURE
pthread_mutex_unlock(&rf24_mutex);
#endif
return len;
}
static void RF24_setNodeAddress(uint8_t address) {
#ifdef MY_RX_MESSAGE_BUFFER_FEATURE
pthread_mutex_lock(&rf24_mutex);
#endif
if (address != AUTO){
MY_RF24_NODE_ADDRESS = address;
// enable node pipe
MY_RF24_BASE_ADDR[0] = MY_RF24_NODE_ADDRESS;
_rf24.openReadingPipe(NODE_PIPE, MY_RF24_BASE_ADDR);
// enable autoACK on node pipe
_rf24.setAutoAck(NODE_PIPE, true);
}
#ifdef MY_RX_MESSAGE_BUFFER_FEATURE
pthread_mutex_unlock(&rf24_mutex);
#endif
}
static uint8_t RF24_getNodeID(void) {
return MY_RF24_NODE_ADDRESS;
}
bool RF24_sanityCheck(void) {
bool ok = true;
#ifdef MY_RX_MESSAGE_BUFFER_FEATURE
pthread_mutex_lock(&rf24_mutex);
#endif
// detect HW defect ot interrupted SPI line, CE disconnect cannot be detected
if (_rf24.getPALevel() != MY_RF24_PA_LEVEL || _rf24.getDataRate() != MY_RF24_DATARATE ||
_rf24.getChannel() != MY_RF24_CHANNEL) {
ok = false;
}
#ifdef MY_RX_MESSAGE_BUFFER_FEATURE
pthread_mutex_unlock(&rf24_mutex);
#endif
return ok;
}
#ifdef MY_RX_MESSAGE_BUFFER_FEATURE
void RF24_irqHandler(void) {
if (RF24_receiveCallback) {
while (RF24_isDataAvailable()) {
RF24_receiveCallback();
}
} else {
// clear RX interrupt
bool tx_ok,tx_fail,rx;
_rf24.whatHappened(tx_ok,tx_fail,rx);
}
}
void RF24_registerReceiveCallback(RF24_receiveCallbackType cb) {
RF24_receiveCallback = cb;
}
#endif
static bool RF24_initialize(void) {
// start up the radio library
_rf24.begin();
// determine whether the hardware is an nRF24L01+ or not
if (!_rf24.isPVariant()) {
RF24_DEBUG(PSTR("radio hardware not compatible"));
return false;
}
// set CRC
_rf24.setCRCLength(RF24_CRC_16);
// set address width
_rf24.setAddressWidth(MY_RF24_ADDR_WIDTH);
// auto retransmit delay 1500us, auto retransmit count 15
_rf24.setRetries(5, 15);
// channel
_rf24.setChannel(MY_RF24_CHANNEL);
// PA level
_rf24.setPALevel(MY_RF24_PA_LEVEL);
// data rate
_rf24.setDataRate(MY_RF24_DATARATE);
// sanity check
#if defined(MY_RF24_SANITY_CHECK)
if (!RF24_sanityCheck()) {
RF24_DEBUG(PSTR("RF24:Sanity check failed: configuration mismatch! Check wiring, replace module or non-P version\n"));
return false;
}
#endif
// enable Dynamic payload
_rf24.enableDynamicPayloads();
// enable ACK payload
_rf24.enableAckPayload();
// disable AA on all pipes, activate when node pipe set
_rf24.setAutoAck(false);
// all nodes listen to broadcast pipe (for FIND_PARENT_RESPONSE messages)
MY_RF24_BASE_ADDR[0] = BROADCAST_ADDRESS;
_rf24.openReadingPipe(BROADCAST_PIPE, MY_RF24_BASE_ADDR);
//_rf24.printDetails();
#ifdef MY_RX_MESSAGE_BUFFER_FEATURE
// Mask all interrupts except the receive interrupt
_rf24.maskIRQ(1,1,0);
attachInterrupt(MY_RF24_IRQ_PIN, INT_EDGE_FALLING, RF24_irqHandler);
#endif
return true;
}
-302
View File
@@ -1,302 +0,0 @@
/**
* The MySensors Arduino library handles the wireless radio link and protocol
* between your home built sensors/actuators and HA controller of choice.
* The sensors forms a self healing radio network with optional repeaters. Each
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
* network topology allowing messages to be routed to nodes.
*
* Created by Marcelo Aquino <marceloaqno@gmail.org>
* Copyright (C) 2016 Marcelo Aquino
* Full contributor list: https://github.com/mysensors/MySensors/graphs/contributors
*
* Documentation: http://www.mysensors.org
* Support Forum: http://forum.mysensors.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
*/
#ifndef __RF24_LINUX_H__
#define __RF24_LINUX_H__
// SPI settings
#if !defined(MY_RF24_SPI_MAX_SPEED)
#define MY_RF24_SPI_MAX_SPEED BCM2835_SPI_SPEED_8MHZ
#endif
// verify RF24 IRQ defs
#if defined(MY_RX_MESSAGE_BUFFER_FEATURE)
#if !defined(MY_RF24_IRQ_PIN)
#error Message buffering feature requires MY_RF24_IRQ_PIN to be defined!
#endif
#ifndef SPI_HAS_TRANSACTION
#error RF24 IRQ usage requires transactional SPI support
#endif
#else
#ifdef MY_RX_MESSAGE_BUFFER_SIZE
#error Receive message buffering requires RF24 IRQ usage
#endif
#endif
// pipes
#define BROADCAST_PIPE 1
#define NODE_PIPE 2
// debug
#if defined(MY_DEBUG_VERBOSE_RF24)
#define RF24_DEBUG(x,...) debug(x, ##__VA_ARGS__)
#else
#define RF24_DEBUG(x,...)
#endif
#ifdef LINUX_ARCH_RASPBERRYPI
// CE pin
#ifdef MY_RF24_CE_PIN
#ifdef __RPI_BPLUS
#if MY_RF24_CE_PIN == 3
#define RF24_CE_PIN RPI_BPLUS_GPIO_J8_03
#elif MY_RF24_CE_PIN == 5
#define RF24_CE_PIN RPI_BPLUS_GPIO_J8_05
#elif MY_RF24_CE_PIN == 7
#define RF24_CE_PIN RPI_BPLUS_GPIO_J8_07
#elif MY_RF24_CE_PIN == 8
#define RF24_CE_PIN RPI_BPLUS_GPIO_J8_08
#elif MY_RF24_CE_PIN == 10
#define RF24_CE_PIN RPI_BPLUS_GPIO_J8_10
#elif MY_RF24_CE_PIN == 11
#define RF24_CE_PIN RPI_BPLUS_GPIO_J8_11
#elif MY_RF24_CE_PIN == 12
#define RF24_CE_PIN RPI_BPLUS_GPIO_J8_12
#elif MY_RF24_CE_PIN == 13
#define RF24_CE_PIN RPI_BPLUS_GPIO_J8_13
#elif MY_RF24_CE_PIN == 15
#define RF24_CE_PIN RPI_BPLUS_GPIO_J8_15
#elif MY_RF24_CE_PIN == 16
#define RF24_CE_PIN RPI_BPLUS_GPIO_J8_16
#elif MY_RF24_CE_PIN == 18
#define RF24_CE_PIN RPI_BPLUS_GPIO_J8_18
#elif MY_RF24_CE_PIN == 19
#define RF24_CE_PIN RPI_BPLUS_GPIO_J8_19
#elif MY_RF24_CE_PIN == 21
#define RF24_CE_PIN RPI_BPLUS_GPIO_J8_21
#elif MY_RF24_CE_PIN == 22
#define RF24_CE_PIN RPI_BPLUS_GPIO_J8_22
#elif MY_RF24_CE_PIN == 23
#define RF24_CE_PIN RPI_BPLUS_GPIO_J8_23
#elif MY_RF24_CE_PIN == 24
#define RF24_CE_PIN RPI_BPLUS_GPIO_J8_24
#elif MY_RF24_CE_PIN == 26
#define RF24_CE_PIN RPI_BPLUS_GPIO_J8_26
#elif MY_RF24_CE_PIN == 29
#define RF24_CE_PIN RPI_BPLUS_GPIO_J8_29
#elif MY_RF24_CE_PIN == 31
#define RF24_CE_PIN RPI_BPLUS_GPIO_J8_31
#elif MY_RF24_CE_PIN == 32
#define RF24_CE_PIN RPI_BPLUS_GPIO_J8_32
#elif MY_RF24_CE_PIN == 33
#define RF24_CE_PIN RPI_BPLUS_GPIO_J8_33
#elif MY_RF24_CE_PIN == 35
#define RF24_CE_PIN RPI_BPLUS_GPIO_J8_35
#elif MY_RF24_CE_PIN == 36
#define RF24_CE_PIN RPI_BPLUS_GPIO_J8_36
#elif MY_RF24_CE_PIN == 37
#define RF24_CE_PIN RPI_BPLUS_GPIO_J8_37
#elif MY_RF24_CE_PIN == 38
#define RF24_CE_PIN RPI_BPLUS_GPIO_J8_38
#elif MY_RF24_CE_PIN == 40
#define RF24_CE_PIN RPI_BPLUS_GPIO_J8_40
#else
#error invalid value for MY_RF24_CE_PIN
#endif
#else
#if MY_RF24_CE_PIN == 3
#define RF24_CE_PIN RPI_V2_GPIO_P1_03
#elif MY_RF24_CE_PIN == 5
#define RF24_CE_PIN RPI_V2_GPIO_P1_05
#elif MY_RF24_CE_PIN == 7
#define RF24_CE_PIN RPI_V2_GPIO_P1_07
#elif MY_RF24_CE_PIN == 8
#define RF24_CE_PIN RPI_V2_GPIO_P1_08
#elif MY_RF24_CE_PIN == 10
#define RF24_CE_PIN RPI_V2_GPIO_P1_10
#elif MY_RF24_CE_PIN == 11
#define RF24_CE_PIN RPI_V2_GPIO_P1_11
#elif MY_RF24_CE_PIN == 12
#define RF24_CE_PIN RPI_V2_GPIO_P1_12
#elif MY_RF24_CE_PIN == 13
#define RF24_CE_PIN RPI_V2_GPIO_P1_13
#elif MY_RF24_CE_PIN == 15
#define RF24_CE_PIN RPI_V2_GPIO_P1_15
#elif MY_RF24_CE_PIN == 16
#define RF24_CE_PIN RPI_V2_GPIO_P1_16
#elif MY_RF24_CE_PIN == 18
#define RF24_CE_PIN RPI_V2_GPIO_P1_18
#elif MY_RF24_CE_PIN == 19
#define RF24_CE_PIN RPI_V2_GPIO_P1_19
#elif MY_RF24_CE_PIN == 21
#define RF24_CE_PIN RPI_V2_GPIO_P1_21
#elif MY_RF24_CE_PIN == 22
#define RF24_CE_PIN RPI_V2_GPIO_P1_22
#elif MY_RF24_CE_PIN == 23
#define RF24_CE_PIN RPI_V2_GPIO_P1_23
#elif MY_RF24_CE_PIN == 24
#define RF24_CE_PIN RPI_V2_GPIO_P1_24
#elif MY_RF24_CE_PIN == 26
#define RF24_CE_PIN RPI_V2_GPIO_P1_26
#elif MY_RF24_CE_PIN == 29
#define RF24_CE_PIN RPI_V2_GPIO_P1_29
#elif MY_RF24_CE_PIN == 31
#define RF24_CE_PIN RPI_V2_GPIO_P1_31
#elif MY_RF24_CE_PIN == 32
#define RF24_CE_PIN RPI_V2_GPIO_P1_32
#elif MY_RF24_CE_PIN == 33
#define RF24_CE_PIN RPI_V2_GPIO_P1_33
#elif MY_RF24_CE_PIN == 35
#define RF24_CE_PIN RPI_V2_GPIO_P1_35
#elif MY_RF24_CE_PIN == 36
#define RF24_CE_PIN RPI_V2_GPIO_P1_36
#elif MY_RF24_CE_PIN == 37
#define RF24_CE_PIN RPI_V2_GPIO_P1_37
#elif MY_RF24_CE_PIN == 38
#define RF24_CE_PIN RPI_V2_GPIO_P1_38
#elif MY_RF24_CE_PIN == 40
#define RF24_CE_PIN RPI_V2_GPIO_P1_40
#else
#error invalid value for MY_RF24_CE_PIN
#endif
#endif
#else
#ifdef __RPI_BPLUS
#define RF24_CE_PIN RPI_BPLUS_GPIO_J8_22
#else
#define RF24_CE_PIN RPI_V2_GPIO_P1_22
#endif
#endif
// CS pin
#ifdef MY_RF24_CS_PIN
#ifdef __RPI_BPLUS
#if MY_RF24_CS_PIN == 3
#define RF24_CS_PIN RPI_BPLUS_GPIO_J8_03
#elif MY_RF24_CS_PIN == 5
#define RF24_CS_PIN RPI_BPLUS_GPIO_J8_05
#elif MY_RF24_CS_PIN == 7
#define RF24_CS_PIN RPI_BPLUS_GPIO_J8_07
#elif MY_RF24_CS_PIN == 8
#define RF24_CS_PIN RPI_BPLUS_GPIO_J8_08
#elif MY_RF24_CS_PIN == 10
#define RF24_CS_PIN RPI_BPLUS_GPIO_J8_10
#elif MY_RF24_CS_PIN == 11
#define RF24_CS_PIN RPI_BPLUS_GPIO_J8_11
#elif MY_RF24_CS_PIN == 12
#define RF24_CS_PIN RPI_BPLUS_GPIO_J8_12
#elif MY_RF24_CS_PIN == 13
#define RF24_CS_PIN RPI_BPLUS_GPIO_J8_13
#elif MY_RF24_CS_PIN == 15
#define RF24_CS_PIN RPI_BPLUS_GPIO_J8_15
#elif MY_RF24_CS_PIN == 16
#define RF24_CS_PIN RPI_BPLUS_GPIO_J8_16
#elif MY_RF24_CS_PIN == 18
#define RF24_CS_PIN RPI_BPLUS_GPIO_J8_18
#elif MY_RF24_CS_PIN == 19
#define RF24_CS_PIN RPI_BPLUS_GPIO_J8_19
#elif MY_RF24_CS_PIN == 21
#define RF24_CS_PIN RPI_BPLUS_GPIO_J8_21
#elif MY_RF24_CS_PIN == 22
#define RF24_CS_PIN RPI_BPLUS_GPIO_J8_22
#elif MY_RF24_CS_PIN == 23
#define RF24_CS_PIN RPI_BPLUS_GPIO_J8_23
#elif MY_RF24_CS_PIN == 24
#define RF24_CS_PIN RPI_BPLUS_GPIO_J8_24
#elif MY_RF24_CS_PIN == 26
#define RF24_CS_PIN RPI_BPLUS_GPIO_J8_26
#elif MY_RF24_CS_PIN == 29
#define RF24_CS_PIN RPI_BPLUS_GPIO_J8_29
#elif MY_RF24_CS_PIN == 31
#define RF24_CS_PIN RPI_BPLUS_GPIO_J8_31
#elif MY_RF24_CS_PIN == 32
#define RF24_CS_PIN RPI_BPLUS_GPIO_J8_32
#elif MY_RF24_CS_PIN == 33
#define RF24_CS_PIN RPI_BPLUS_GPIO_J8_33
#elif MY_RF24_CS_PIN == 35
#define RF24_CS_PIN RPI_BPLUS_GPIO_J8_35
#elif MY_RF24_CS_PIN == 36
#define RF24_CS_PIN RPI_BPLUS_GPIO_J8_36
#elif MY_RF24_CS_PIN == 37
#define RF24_CS_PIN RPI_BPLUS_GPIO_J8_37
#elif MY_RF24_CS_PIN == 38
#define RF24_CS_PIN RPI_BPLUS_GPIO_J8_38
#elif MY_RF24_CS_PIN == 40
#define RF24_CS_PIN RPI_BPLUS_GPIO_J8_40
#else
#error invalid value for MY_RF24_CS_PIN
#endif
#else
#if MY_RF24_CS_PIN == 3
#define RF24_CS_PIN RPI_V2_GPIO_P1_03
#elif MY_RF24_CS_PIN == 5
#define RF24_CS_PIN RPI_V2_GPIO_P1_05
#elif MY_RF24_CS_PIN == 7
#define RF24_CS_PIN RPI_V2_GPIO_P1_07
#elif MY_RF24_CS_PIN == 8
#define RF24_CS_PIN RPI_V2_GPIO_P1_08
#elif MY_RF24_CS_PIN == 10
#define RF24_CS_PIN RPI_V2_GPIO_P1_10
#elif MY_RF24_CS_PIN == 11
#define RF24_CS_PIN RPI_V2_GPIO_P1_11
#elif MY_RF24_CS_PIN == 12
#define RF24_CS_PIN RPI_V2_GPIO_P1_12
#elif MY_RF24_CS_PIN == 13
#define RF24_CS_PIN RPI_V2_GPIO_P1_13
#elif MY_RF24_CS_PIN == 15
#define RF24_CS_PIN RPI_V2_GPIO_P1_15
#elif MY_RF24_CS_PIN == 16
#define RF24_CS_PIN RPI_V2_GPIO_P1_16
#elif MY_RF24_CS_PIN == 18
#define RF24_CS_PIN RPI_V2_GPIO_P1_18
#elif MY_RF24_CS_PIN == 19
#define RF24_CS_PIN RPI_V2_GPIO_P1_19
#elif MY_RF24_CS_PIN == 21
#define RF24_CS_PIN RPI_V2_GPIO_P1_21
#elif MY_RF24_CS_PIN == 22
#define RF24_CS_PIN RPI_V2_GPIO_P1_22
#elif MY_RF24_CS_PIN == 23
#define RF24_CS_PIN RPI_V2_GPIO_P1_23
#elif MY_RF24_CS_PIN == 24
#define RF24_CS_PIN BCM2835_SPI_CS0
#elif MY_RF24_CS_PIN == 26
#define RF24_CS_PIN BCM2835_SPI_CS1
#elif MY_RF24_CS_PIN == 29
#define RF24_CS_PIN RPI_V2_GPIO_P1_29
#elif MY_RF24_CS_PIN == 31
#define RF24_CS_PIN RPI_V2_GPIO_P1_31
#elif MY_RF24_CS_PIN == 32
#define RF24_CS_PIN RPI_V2_GPIO_P1_32
#elif MY_RF24_CS_PIN == 33
#define RF24_CS_PIN RPI_V2_GPIO_P1_33
#elif MY_RF24_CS_PIN == 35
#define RF24_CS_PIN RPI_V2_GPIO_P1_35
#elif MY_RF24_CS_PIN == 36
#define RF24_CS_PIN RPI_V2_GPIO_P1_36
#elif MY_RF24_CS_PIN == 37
#define RF24_CS_PIN RPI_V2_GPIO_P1_37
#elif MY_RF24_CS_PIN == 38
#define RF24_CS_PIN RPI_V2_GPIO_P1_38
#elif MY_RF24_CS_PIN == 40
#define RF24_CS_PIN RPI_V2_GPIO_P1_40
#else
#error invalid value for MY_RF24_CS_PIN
#endif
#endif
#else
#ifdef __RPI_BPLUS
#define RF24_CS_PIN RPI_BPLUS_GPIO_J8_24
#else
#define RF24_CS_PIN BCM2835_SPI_CS0
#endif
#endif
#endif
#endif