初始化提交
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
Copyright (C) 2011 J. Coliz <maniacbug@ymail.com>
|
||||
|
||||
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.
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file RF24_arch_config.h
|
||||
* General defines and includes for RF24/Linux
|
||||
*/
|
||||
|
||||
/**
|
||||
* Example of RF24_arch_config.h for RF24 portability
|
||||
*
|
||||
* @defgroup Porting_General Porting: General
|
||||
*
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __ARCH_CONFIG_H__
|
||||
#define __ARCH_CONFIG_H__
|
||||
|
||||
#define RF24_LINUX
|
||||
|
||||
#include <stddef.h>
|
||||
#include "spi.h"
|
||||
#include "gpio.h"
|
||||
#include "compatibility.h"
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <string.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#define _BV(x) (1 << (x))
|
||||
#define _SPI spi
|
||||
|
||||
#undef SERIAL_DEBUG
|
||||
#ifdef SERIAL_DEBUG
|
||||
#define IF_SERIAL_DEBUG(x) ({x;})
|
||||
#else
|
||||
#define IF_SERIAL_DEBUG(x)
|
||||
#endif
|
||||
|
||||
// Avoid spurious warnings
|
||||
#if 1
|
||||
#if !defined(NATIVE) && defined(ARDUINO)
|
||||
#undef PROGMEM
|
||||
#define PROGMEM __attribute__(( section(".progmem.data") ))
|
||||
#undef PSTR
|
||||
#define PSTR(s) (__extension__({static const char __c[] PROGMEM = (s); &__c[0];}))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
typedef uint16_t prog_uint16_t;
|
||||
#define PSTR(x) (x)
|
||||
#define printf_P printf
|
||||
#define strlen_P strlen
|
||||
#define PROGMEM
|
||||
#define pgm_read_word(p) (*(p))
|
||||
#define PRIPSTR "%s"
|
||||
#define pgm_read_byte(p) (*(p))
|
||||
|
||||
// Function, constant map as a result of migrating from Arduino
|
||||
#define LOW GPIO::OUTPUT_LOW
|
||||
#define HIGH GPIO::OUTPUT_HIGH
|
||||
#define INPUT GPIO::DIRECTION_IN
|
||||
#define OUTPUT GPIO::DIRECTION_OUT
|
||||
#define digitalWrite(pin, value) GPIO::write(pin, value)
|
||||
#define pinMode(pin, direction) GPIO::open(pin, direction)
|
||||
#define delay(milisec) __msleep(milisec)
|
||||
#define delayMicroseconds(usec) __usleep(usec)
|
||||
#define millis() __millis()
|
||||
|
||||
#endif // __ARCH_CONFIG_H__
|
||||
|
||||
|
||||
/*@}*/
|
||||
47
arduino-cli/libraries/RF24/utility/Template/compatibility.h
Normal file
47
arduino-cli/libraries/RF24/utility/Template/compatibility.h
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* File: compatiblity.h
|
||||
* Author: purinda
|
||||
*
|
||||
* Created on 24 June 2012, 3:08 PM
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file compatibility.h
|
||||
* Class declaration for SPI helper files
|
||||
*/
|
||||
|
||||
/**
|
||||
* Example of compatibility.h class declaration for timing functions portability
|
||||
*
|
||||
* @defgroup Porting_Timing Porting: Timing
|
||||
*
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef COMPATIBLITY_H
|
||||
#define COMPATIBLITY_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
void __msleep(int milisec);
|
||||
|
||||
void __usleep(int milisec);
|
||||
|
||||
void __start_timer();
|
||||
|
||||
long __millis();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* COMPATIBLITY_H */
|
||||
|
||||
/*@}*/
|
||||
63
arduino-cli/libraries/RF24/utility/Template/gpio.h
Normal file
63
arduino-cli/libraries/RF24/utility/Template/gpio.h
Normal file
@@ -0,0 +1,63 @@
|
||||
|
||||
|
||||
/**
|
||||
* @file gpio.h
|
||||
* Class declaration for SPI helper files
|
||||
*/
|
||||
|
||||
/**
|
||||
* Example of gpio.h class declaration for GPIO portability
|
||||
*
|
||||
* @defgroup Porting_GPIO Porting: GPIO
|
||||
*
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
#ifndef H
|
||||
#define H
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
//class GPIO {
|
||||
public:
|
||||
/* Constants */
|
||||
static const int DIRECTION_OUT = 1;
|
||||
static const int DIRECTION_IN = 0;
|
||||
|
||||
static const int OUTPUT_HIGH = 1;
|
||||
static const int OUTPUT_LOW = 0;
|
||||
|
||||
GPIO();
|
||||
|
||||
/**
|
||||
* Similar to Arduino pinMode(pin,mode);
|
||||
* @param port
|
||||
* @param DDR
|
||||
*/
|
||||
static void open(int port, int DDR);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param port
|
||||
*/
|
||||
static void close(int port);
|
||||
|
||||
/**
|
||||
* Similar to Arduino digitalRead(pin);
|
||||
* @param port
|
||||
* @param value
|
||||
*/
|
||||
static int read(int port);
|
||||
|
||||
/**
|
||||
* Similar to Arduino digitalWrite(pin,state);
|
||||
* @param port
|
||||
* @param value
|
||||
*/
|
||||
static void write(int port, int value);
|
||||
|
||||
virtual ~ GPIO();
|
||||
|
||||
};
|
||||
|
||||
/*@}*/
|
||||
30
arduino-cli/libraries/RF24/utility/Template/includes.h
Normal file
30
arduino-cli/libraries/RF24/utility/Template/includes.h
Normal file
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* @file includes.h
|
||||
* Configuration defines for RF24/Linux
|
||||
*/
|
||||
|
||||
/**
|
||||
* Example of includes.h for RF24 Linux portability
|
||||
*
|
||||
* @defgroup Porting_Includes Porting: Includes
|
||||
*
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef __RF24_INCLUDES_H__
|
||||
#define __RF24_INCLUDES_H__
|
||||
|
||||
/**
|
||||
* Define a specific platform for this configuration
|
||||
*/
|
||||
#define RF24_BBB
|
||||
|
||||
/**
|
||||
* Load the correct configuration for this platform
|
||||
*/
|
||||
#include "BBB/RF24_arch_config.h"
|
||||
|
||||
#endif
|
||||
|
||||
/*@}*/
|
||||
81
arduino-cli/libraries/RF24/utility/Template/spi.h
Normal file
81
arduino-cli/libraries/RF24/utility/Template/spi.h
Normal file
@@ -0,0 +1,81 @@
|
||||
/**
|
||||
* @file spi.h
|
||||
* Class declaration for SPI helper files
|
||||
*/
|
||||
|
||||
/**
|
||||
* Example of spi.h class declaration for SPI portability
|
||||
*
|
||||
* @defgroup Porting_SPI Porting: SPI
|
||||
*
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
#include <string>
|
||||
#include <stdint.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <getopt.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <inttypes.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/spi/spidev.h>
|
||||
|
||||
using namespace std;
|
||||
//class SPI {
|
||||
public:
|
||||
|
||||
/**
|
||||
* SPI constructor
|
||||
*/
|
||||
SPI();
|
||||
|
||||
/**
|
||||
* Start SPI
|
||||
*/
|
||||
void begin(int busNo);
|
||||
|
||||
/**
|
||||
* Transfer a single byte
|
||||
* @param tx_ Byte to send
|
||||
* @return Data returned via spi
|
||||
*/
|
||||
uint8_t transfer(uint8_t tx_);
|
||||
|
||||
/**
|
||||
* Transfer a buffer of data
|
||||
* @param tbuf Transmit buffer
|
||||
* @param rbuf Receive buffer
|
||||
* @param len Length of the data
|
||||
*/
|
||||
void transfernb(char* tbuf, char* rbuf, uint32_t len);
|
||||
|
||||
/**
|
||||
* Transfer a buffer of data without an rx buffer
|
||||
* @param buf Pointer to a buffer of data
|
||||
* @param len Length of the data
|
||||
*/
|
||||
void transfern(char* buf, uint32_t len);
|
||||
|
||||
virtual ~ SPI();
|
||||
|
||||
private:
|
||||
|
||||
/** Default SPI device */
|
||||
string device;
|
||||
/** SPI Mode set */
|
||||
uint8_t mode;
|
||||
/** word size*/
|
||||
uint8_t bits;
|
||||
/** Set SPI speed*/
|
||||
uint32_t speed;
|
||||
int fd;
|
||||
|
||||
void init();
|
||||
|
||||
};
|
||||
|
||||
|
||||
/*@}*/
|
||||
Reference in New Issue
Block a user