Repo restyled using astyle (#683)
The rules are in .tools/astyle/config/style.cfg and can also be reviewed at https://www.mysensors.org/view/260#coding-guidelines-core-library
This commit is contained in:
+62
-60
@@ -27,65 +27,66 @@
|
||||
|
||||
// SPI settings
|
||||
#if !defined(MY_RF24_SPI_MAX_SPEED)
|
||||
// default 2Mhz - safe for nRF24L01+ clones
|
||||
#define MY_RF24_SPI_MAX_SPEED 2000000
|
||||
// default 2Mhz - safe for nRF24L01+ clones
|
||||
#define MY_RF24_SPI_MAX_SPEED 2000000
|
||||
#endif
|
||||
#define MY_RF24_SPI_DATA_ORDER MSBFIRST
|
||||
#define MY_RF24_SPI_DATA_MODE SPI_MODE0
|
||||
|
||||
#if defined (ARDUINO) && !defined (__arm__) && !defined (_SPI)
|
||||
#include <SPI.h>
|
||||
#if defined(MY_SOFTSPI)
|
||||
SoftSPI<MY_SOFT_SPI_MISO_PIN, MY_SOFT_SPI_MOSI_PIN, MY_SOFT_SPI_SCK_PIN, MY_RF24_SPI_DATA_MODE> _SPI;
|
||||
#else
|
||||
#define _SPI SPI
|
||||
#endif
|
||||
#include <SPI.h>
|
||||
#if defined(MY_SOFTSPI)
|
||||
SoftSPI<MY_SOFT_SPI_MISO_PIN, MY_SOFT_SPI_MOSI_PIN, MY_SOFT_SPI_SCK_PIN, MY_RF24_SPI_DATA_MODE>
|
||||
_SPI;
|
||||
#else
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#define _BV(x) (1<<(x))
|
||||
|
||||
#if defined(__arm__)
|
||||
#include <SPI.h>
|
||||
#else
|
||||
extern HardwareSPI SPI;
|
||||
#endif
|
||||
|
||||
#if !defined(_SPI)
|
||||
#define _SPI SPI
|
||||
#endif
|
||||
#define _SPI SPI
|
||||
#endif
|
||||
#else
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#define _BV(x) (1<<(x))
|
||||
|
||||
#if defined(__arm__)
|
||||
#include <SPI.h>
|
||||
#else
|
||||
extern HardwareSPI SPI;
|
||||
#endif
|
||||
|
||||
#if !defined(_SPI)
|
||||
#define _SPI SPI
|
||||
#endif
|
||||
#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
|
||||
// SoftSPI does not support usingInterrupt()
|
||||
#ifdef MY_SOFTSPI
|
||||
#error RF24 IRQ usage cannot be used with Soft SPI
|
||||
#endif
|
||||
// ESP8266 does not support usingInterrupt()
|
||||
#ifdef ARDUINO_ARCH_ESP8266
|
||||
#error RF24 IRQ usage cannot be used with ESP8266
|
||||
#endif
|
||||
#ifndef SPI_HAS_TRANSACTION
|
||||
#error RF24 IRQ usage requires transactional SPI support
|
||||
#endif
|
||||
#if !defined(MY_RF24_IRQ_PIN)
|
||||
#error Message buffering feature requires MY_RF24_IRQ_PIN to be defined!
|
||||
#endif
|
||||
// SoftSPI does not support usingInterrupt()
|
||||
#ifdef MY_SOFTSPI
|
||||
#error RF24 IRQ usage cannot be used with Soft SPI
|
||||
#endif
|
||||
// ESP8266 does not support usingInterrupt()
|
||||
#ifdef ARDUINO_ARCH_ESP8266
|
||||
#error RF24 IRQ usage cannot be used with ESP8266
|
||||
#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
|
||||
#ifdef MY_RX_MESSAGE_BUFFER_SIZE
|
||||
#error Receive message buffering requires RF24 IRQ usage
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
// RF24 settings
|
||||
#if defined(MY_RX_MESSAGE_BUFFER_FEATURE)
|
||||
#define MY_RF24_CONFIGURATION (uint8_t) ((RF24_CRC_16 << 2) | (1 << RF24_MASK_TX_DS) | (1 << RF24_MASK_MAX_RT))
|
||||
#define MY_RF24_CONFIGURATION (uint8_t) ((RF24_CRC_16 << 2) | (1 << RF24_MASK_TX_DS) | (1 << RF24_MASK_MAX_RT))
|
||||
#else
|
||||
#define MY_RF24_CONFIGURATION (uint8_t) (RF24_CRC_16 << 2)
|
||||
#define MY_RF24_CONFIGURATION (uint8_t) (RF24_CRC_16 << 2)
|
||||
#endif
|
||||
#define MY_RF24_FEATURE (uint8_t)( _BV(RF24_EN_DPL) | _BV(RF24_EN_ACK_PAY) )
|
||||
#define MY_RF24_RF_SETUP (uint8_t)( ((MY_RF24_DATARATE & 0b10 ) << 4) | ((MY_RF24_DATARATE & 0b01 ) << 3) | (MY_RF24_PA_LEVEL << 1) ) + 1 // +1 for Si24R1
|
||||
@@ -94,11 +95,11 @@
|
||||
#define RF24_BROADCAST_PIPE (1)
|
||||
#define RF24_NODE_PIPE (0)
|
||||
|
||||
// debug
|
||||
// debug
|
||||
#if defined(MY_DEBUG_VERBOSE_RF24)
|
||||
#define RF24_DEBUG(x,...) debug(x, ##__VA_ARGS__)
|
||||
#define RF24_DEBUG(x,...) debug(x, ##__VA_ARGS__)
|
||||
#else
|
||||
#define RF24_DEBUG(x,...)
|
||||
#define RF24_DEBUG(x,...)
|
||||
#endif
|
||||
|
||||
// PA levels
|
||||
@@ -113,8 +114,8 @@
|
||||
#define RF24_250KBPS (2)
|
||||
|
||||
// CRC
|
||||
#define RF24_CRC_DISABLED (0)
|
||||
#define RF24_CRC_8 (2)
|
||||
#define RF24_CRC_DISABLED (0)
|
||||
#define RF24_CRC_8 (2)
|
||||
#define RF24_CRC_16 (3)
|
||||
|
||||
// ARD, auto retry delay
|
||||
@@ -232,9 +233,10 @@
|
||||
|
||||
// functions
|
||||
|
||||
LOCAL void RF24_csn(const bool level);
|
||||
LOCAL void RF24_ce(const bool level);
|
||||
LOCAL uint8_t RF24_spiMultiByteTransfer(const uint8_t cmd, uint8_t* buf, const uint8_t len, const bool aReadMode);
|
||||
LOCAL void RF24_csn(const bool level);
|
||||
LOCAL void RF24_ce(const bool level);
|
||||
LOCAL uint8_t RF24_spiMultiByteTransfer(const uint8_t cmd, uint8_t* buf, const uint8_t len,
|
||||
const bool aReadMode);
|
||||
LOCAL uint8_t RF24_spiByteTransfer(const uint8_t cmd);
|
||||
LOCAL uint8_t RF24_RAW_readByteRegister(const uint8_t cmd);
|
||||
LOCAL uint8_t RF24_RAW_writeByteRegister(const uint8_t cmd, const uint8_t value);
|
||||
@@ -250,11 +252,11 @@ LOCAL uint8_t RF24_getFIFOStatus(void);
|
||||
LOCAL void RF24_openWritingPipe(uint8_t recipient);
|
||||
LOCAL void RF24_startListening(void);
|
||||
LOCAL void RF24_stopListening(void);
|
||||
LOCAL void RF24_powerDown(void);
|
||||
LOCAL void RF24_powerDown(void);
|
||||
LOCAL bool RF24_sendMessage(const uint8_t recipient, const void* buf, const uint8_t len);
|
||||
LOCAL uint8_t RF24_getDynamicPayloadSize(void);
|
||||
LOCAL bool RF24_isDataAvailable();
|
||||
LOCAL uint8_t RF24_readMessage(void* buf);
|
||||
LOCAL uint8_t RF24_readMessage(void* buf);
|
||||
LOCAL void RF24_setNodeAddress(const uint8_t address);
|
||||
LOCAL uint8_t RF24_getNodeID(void);
|
||||
LOCAL bool RF24_sanityCheck(void);
|
||||
@@ -275,14 +277,14 @@ LOCAL void RF24_setStatus(const uint8_t status);
|
||||
LOCAL void RF24_enableFeatures(void);
|
||||
|
||||
#if defined(MY_RX_MESSAGE_BUFFER_FEATURE)
|
||||
typedef void (*RF24_receiveCallbackType)(void);
|
||||
/**
|
||||
* Register a callback, which will be called (from interrupt context) for every message received.
|
||||
* @note When a callback is registered, it _must_ retrieve the message from the nRF24
|
||||
* by calling RF24_readMessage(). Otherwise the interrupt will not get deasserted
|
||||
* and message reception will stop.
|
||||
*/
|
||||
LOCAL void RF24_registerReceiveCallback(RF24_receiveCallbackType cb);
|
||||
typedef void (*RF24_receiveCallbackType)(void);
|
||||
/**
|
||||
* Register a callback, which will be called (from interrupt context) for every message received.
|
||||
* @note When a callback is registered, it _must_ retrieve the message from the nRF24
|
||||
* by calling RF24_readMessage(). Otherwise the interrupt will not get deasserted
|
||||
* and message reception will stop.
|
||||
*/
|
||||
LOCAL void RF24_registerReceiveCallback(RF24_receiveCallbackType cb);
|
||||
#endif
|
||||
|
||||
#endif // __RF24_H__
|
||||
Reference in New Issue
Block a user