| 1 | /* |
| 2 | * Copyright (C) 2011 J. Coliz <maniacbug@ymail.com> |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License |
| 6 | * version 2 as published by the Free Software Foundation. |
| 7 | */ |
| 8 | |
| 9 | /** |
| 10 | * @file RF24_arch_config.h |
| 11 | * General defines and includes for RF24/Linux |
| 12 | */ |
| 13 | |
| 14 | /** |
| 15 | * Example of RF24_arch_config.h for RF24 portability |
| 16 | * |
| 17 | * @defgroup Porting_General Porting: General |
| 18 | * @{ |
| 19 | */ |
| 20 | |
| 21 | #ifndef RF24_UTILITY_TEMPLATE_RF24_ARCH_CONFIG_H_ |
| 22 | #define RF24_UTILITY_TEMPLATE_RF24_ARCH_CONFIG_H_ |
| 23 | |
| 24 | #define RF24_LINUX |
| 25 | |
| 26 | #include <stddef.h> |
| 27 | #include "spi.h" |
| 28 | #include "gpio.h" |
| 29 | #include "compatibility.h" |
| 30 | #include <stdint.h> |
| 31 | #include <stdio.h> |
| 32 | #include <time.h> |
| 33 | #include <string.h> |
| 34 | #include <sys/time.h> |
| 35 | |
| 36 | #define _BV(x) (1 << (x)) |
| 37 | #define _SPI spi |
| 38 | |
| 39 | #ifdef RF24_DEBUG |
| 40 | #define IF_RF24_DEBUG(x) ({ x; }) |
| 41 | #else |
| 42 | #define IF_RF24_DEBUG(x) |
| 43 | #endif |
| 44 | |
| 45 | // Avoid spurious warnings |
| 46 | #if !defined(NATIVE) && defined(ARDUINO) |
| 47 | #undef PROGMEM |
| 48 | #define PROGMEM __attribute__((section(".progmem.data"))) |
| 49 | #undef PSTR |
| 50 | #define PSTR(s) (__extension__({static const char __c[] PROGMEM = (s); &__c[0]; })) |
| 51 | #endif |
| 52 | |
| 53 | typedef uint16_t prog_uint16_t; |
| 54 | typedef uint16_t rf24_gpio_pin_t; |
| 55 | #define PSTR(x) (x) |
| 56 | #define printf_P printf |
| 57 | #define strlen_P strlen |
| 58 | #define PROGMEM |
| 59 | #define pgm_read_word(p) (*(const unsigned short*)(p)) |
| 60 | #define PRIPSTR "%s" |
| 61 | #define pgm_read_byte(p) (*(const unsigned char*)(p)) |
| 62 | |
| 63 | // Function, constant map as a result of migrating from Arduino |
| 64 | #define LOW GPIO::OUTPUT_LOW |
| 65 | #define HIGH GPIO::OUTPUT_HIGH |
| 66 | #define INPUT GPIO::DIRECTION_IN |
| 67 | #define OUTPUT GPIO::DIRECTION_OUT |
| 68 | #define digitalWrite(pin, value) GPIO::write(pin, value) |
| 69 | #define pinMode(pin, direction) GPIO::open(pin, direction) |
| 70 | #define delay(millisec) __msleep(millisec) |
| 71 | #define delayMicroseconds(usec) __usleep(usec) |
| 72 | #define millis() __millis() |
| 73 | |
| 74 | /**@}*/ |
| 75 | |
| 76 | #endif // RF24_UTILITY_TEMPLATE_RF24_ARCH_CONFIG_H_ |