Krolyxon
Commit 1d55752

Branches

Tags

Refs →

orion-rf.piolibdepsesp32-s3-n16r8RF24utilitypigpioRF24_arch_config.h

71 lines · 2.0 KB · Objective-C

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#ifndef RF24_UTILITY_PIGPIO_RF24_ARCH_CONFIG_H_
10#define RF24_UTILITY_PIGPIO_RF24_ARCH_CONFIG_H_
11
12#define RF24_LINUX
13
14#include <stdint.h> // uint16_t
15#include <stdio.h> // printf
16#include <string.h> // strlen
17#include "spi.h"
18#include "gpio.h"
19#include "compatibility.h"
20
21//#define RF24_SPI_SPEED RF24_SPIDEV_SPEED
22
23#define _BV(x) (1 << (x))
24#define _SPI spi
25
26#ifdef RF24_DEBUG
27 #define IF_RF24_DEBUG(x) ({ x; })
28#else
29 #define IF_RF24_DEBUG(x)
30#endif
31
32// Avoid spurious warnings
33#if 1
34 #if !defined(NATIVE) && defined(ARDUINO)
35 #undef PROGMEM
36 #define PROGMEM __attribute__((section(".progmem.data")))
37 #undef PSTR
38 #define PSTR(s) (__extension__({static const char __c[] PROGMEM = (s); &__c[0]; }))
39 #endif
40#endif
41
42#if RF24_SPI_SPEED > 1000000
43 #undef RF24_SPI_SPEED
44 #define RF24_SPI_SPEED 1000000
45#endif
46
47typedef uint16_t prog_uint16_t;
48typedef uint8_t rf24_gpio_pin_t;
49#define RF24_PIN_INVALID 0xFF
50
51#define PSTR(x) (x)
52#define printf_P printf
53#define strlen_P strlen
54#define PROGMEM
55#define pgm_read_word(p) (*(const unsigned short*)(p))
56#define PRIPSTR "%s"
57#define pgm_read_byte(p) (*(const unsigned char*)(p))
58#define pgm_read_ptr(p) (*(void* const*)(p))
59
60// Function, constant map as a result of migrating from Arduino
61#define LOW GPIO::OUTPUT_LOW
62#define HIGH GPIO::OUTPUT_HIGH
63#define INPUT GPIO::DIRECTION_IN
64#define OUTPUT GPIO::DIRECTION_OUT
65#define digitalWrite(pin, value) GPIO::write(pin, value)
66#define pinMode(pin, direction) GPIO::open(pin, direction)
67#define delay(millisec) __msleep(millisec)
68#define delayMicroseconds(usec) __usleep(usec)
69#define millis() __millis()
70
71#endif // RF24_UTILITY_PIGPIO_RF24_ARCH_CONFIG_H_