Advertisement
Guest User

Untitled

a guest
Nov 13th, 2015
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 4.33 KB | None | 0 0
  1.  
  2. /*
  3.  Copyright (C) 2011 J. Coliz <maniacbug@ymail.com>
  4.  
  5.  This program is free software; you can redistribute it and/or
  6.  modify it under the terms of the GNU General Public License
  7.  version 2 as published by the Free Software Foundation.
  8.  */
  9.  
  10.  /* spaniakos <spaniakos@gmail.com>
  11.   Added __ARDUINO_X86__ support
  12. */
  13.  
  14. #ifndef __RF24_CONFIG_H__
  15. #define __RF24_CONFIG_H__
  16.  
  17.   /*** USER DEFINES:  ***/  
  18.   //#define FAILURE_HANDLING
  19.   //#define SERIAL_DEBUG
  20.   //#define MINIMAL
  21.   //#define SPI_UART  // Requires library from https://github.com/TMRh20/Sketches/tree/master/SPI_UART
  22.   //#define SOFTSPI   // Requires library from https://github.com/greiman/DigitalIO
  23.  
  24.   /**********************/
  25.   #define rf24_max(a,b) (a>b?a:b)
  26.   #define rf24_min(a,b) (a<b?a:b)
  27.  
  28.   #if defined SPI_HAS_TRANSACTION && !defined SPI_UART && !defined SOFTSPI
  29.     #define RF24_SPI_TRANSACTIONS
  30.   #endif
  31.  
  32. //Generic Linux/ARM and //http://iotdk.intel.com/docs/master/mraa/
  33. #if ( defined (__linux) || defined (LINUX) ) && defined( __arm__ ) || defined(MRAA) // BeagleBone Black running GNU/Linux or any other ARM-based linux device
  34.  
  35.   // The Makefile checks for bcm2835 (RPi) and copies the correct includes.h file to /utility/includes.h (Default is spidev config)
  36.   // This behavior can be overridden by calling 'make RF24_SPIDEV=1' or 'make RF24_MRAA=1'
  37.   // The includes.h file defines either RF24_RPi, MRAA or RF24_BBB and includes the correct RF24_arch_config.h file
  38.   #include "utility/includes.h"
  39.  
  40. //ATTiny  
  41. #elif defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) || defined(__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny2313__) || defined(__AVR_ATtiny4313__)
  42.  
  43.   #define RF24_TINY
  44.   #include "utility/ATTiny/RF24_arch_config.h"
  45.  
  46. //LittleWire  
  47. #elif defined(LITTLEWIRE)
  48.  
  49.   #include "utility/LittleWire/RF24_arch_config.h"
  50.  
  51. //Teensy  
  52. #elif defined (TEENSYDUINO)
  53.  
  54.   #include "utility/Teensy/RF24_arch_config.h"  
  55. //Everything else
  56. #else
  57.  
  58.   #include <Arduino.h>
  59.  
  60.   // RF modules support 10 Mhz SPI bus speed
  61.   const uint32_t RF_SPI_SPEED = 10000000;  
  62.  
  63. #if defined (ARDUINO) && !defined (__arm__) && !defined (__ARDUINO_X86__)
  64.       #if defined SPI_UART
  65.         #include <SPI_UART.h>
  66.         #define _SPI uspi
  67.       #elif defined SOFTSPI
  68.       // change these pins to your liking
  69.       //
  70.       const uint8_t SOFT_SPI_MISO_PIN = 16;
  71.       const uint8_t SOFT_SPI_MOSI_PIN = 15;
  72.       const uint8_t SOFT_SPI_SCK_PIN = 14;  
  73.       const uint8_t SPI_MODE = 0;
  74.       #define _SPI spi
  75.      
  76.       #else    
  77.         #include <SPI.h>
  78.         #define _SPI SPI
  79.       #endif
  80. #else
  81.   // Define _BV for non-Arduino platforms and for Arduino DUE
  82.   #include <stdint.h>
  83.   #include <stdio.h>
  84.   #include <string.h>
  85.  
  86.  
  87.  #if defined(__arm__) || defined (__ARDUINO_X86__)
  88.    #include <SPI.h>
  89.  #endif
  90.  
  91.  
  92.  #define _BV(x) (1<<(x))
  93.  #if !defined(__arm__) && !defined (__ARDUINO_X86__)
  94.    extern HardwareSPI SPI;
  95.  #endif
  96.  
  97.  
  98.   #define _SPI SPI
  99. #endif
  100.  
  101.   #ifdef SERIAL_DEBUG
  102.     #define IF_SERIAL_DEBUG(x) ({x;})
  103.   #else
  104.     #define IF_SERIAL_DEBUG(x)
  105.     #if defined(RF24_TINY)
  106.     #define printf_P(...)
  107.     #endif
  108.   #endif
  109.  
  110. #if  defined (__ARDUINO_X86__)
  111.     #define printf_P printf
  112.     #define _BV(bit) (1<<(bit))
  113. #endif
  114.  
  115. // Progmem is Arduino-specific
  116. // Arduino DUE is arm and does not include avr/pgmspace
  117. #if defined (ARDUINO_ARCH_ESP8266)
  118.  
  119.   #define PSTR(x) (x)
  120.   #define printf Serial.printf
  121.   #define sprintf(...) os_sprintf( __VA_ARGS__ )
  122.   #define printf_P printf
  123.   #define strlen_P strlen  
  124.   #define PROGMEM
  125.   #define pgm_read_byte(addr) (*(const unsigned char *)(addr))
  126.   #define pgm_read_word(p) (*(p))
  127.   #define PRIPSTR "%s"
  128.  
  129. #elif defined(ARDUINO) && ! defined(__arm__) && !defined (__ARDUINO_X86__)
  130.     #ifdef ESP8266
  131. #include <progmem.h>
  132. #else
  133. #include <avr/progmem.h>
  134. #endif
  135.     #define PRIPSTR "%S"
  136. #else
  137.   #if ! defined(ARDUINO) // This doesn't work on Arduino DUE
  138.     typedef char const char;
  139.   #else // Fill in pgm_read_byte that is used, but missing from DUE
  140.     #define pgm_read_byte(addr) (*(const unsigned char *)(addr))
  141.   #endif
  142.  
  143.  
  144.   typedef uint16_t prog_uint16_t;
  145.   #define PSTR(x) (x)
  146.   #define printf_P printf
  147.   #define strlen_P strlen
  148.   #define PROGMEM
  149.   #define pgm_read_word(p) (*(p))
  150.  
  151.   #define PRIPSTR "%s"
  152.  
  153. #endif
  154.  
  155. #endif
  156.  
  157.  
  158.  
  159. #endif // __RF24_CONFIG_H__
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement