├── Arduino Code
├── README
├── RF24-master
│ ├── .gitignore
│ ├── Doxyfile
│ ├── FAQ
│ ├── README.md
│ ├── RF24.cpp
│ ├── RF24.h
│ ├── RF24_config.h
│ ├── doxygen-custom.css
│ ├── examples
│ │ ├── GettingStarted
│ │ │ ├── GettingStarted.pde
│ │ │ ├── Jamfile
│ │ │ └── printf.h
│ │ ├── led_remote
│ │ │ ├── Jamfile
│ │ │ ├── led_remote.pde
│ │ │ └── printf.h
│ │ ├── nordic_fob
│ │ │ ├── Jamfile
│ │ │ ├── nordic_fob.pde
│ │ │ └── printf.h
│ │ ├── pingpair
│ │ │ ├── Jamfile
│ │ │ ├── pingpair.pde
│ │ │ └── printf.h
│ │ ├── pingpair_dyn
│ │ │ ├── Jamfile
│ │ │ ├── pingpair_dyn.pde
│ │ │ └── printf.h
│ │ ├── pingpair_irq
│ │ │ ├── Jamfile
│ │ │ ├── pingpair_irq.pde
│ │ │ └── printf.h
│ │ ├── pingpair_maple
│ │ │ ├── Jamfile
│ │ │ ├── main.cpp
│ │ │ └── pingpair_maple.pde
│ │ ├── pingpair_pl
│ │ │ ├── Jamfile
│ │ │ ├── pingpair_pl.pde
│ │ │ └── printf.h
│ │ ├── pingpair_sleepy
│ │ │ ├── Jamfile
│ │ │ ├── pingpair_sleepy.pde
│ │ │ └── printf.h
│ │ ├── scanner
│ │ │ ├── Jamfile
│ │ │ ├── printf.h
│ │ │ └── scanner.pde
│ │ └── starping
│ │ │ ├── Jamfile
│ │ │ ├── printf.h
│ │ │ └── starping.pde
│ ├── keywords.txt
│ ├── nRF24L01.h
│ ├── printf.h
│ ├── tests
│ │ ├── README
│ │ ├── native
│ │ │ ├── Jamfile
│ │ │ ├── pingpair_irq.pde
│ │ │ └── printf.h
│ │ ├── pingpair_blocking
│ │ │ ├── Jamfile
│ │ │ ├── pingpair_blocking.pde
│ │ │ ├── printf.h
│ │ │ ├── runtest.py
│ │ │ ├── runtests.sh
│ │ │ └── test.ex
│ │ └── pingpair_test
│ │ │ ├── Jamfile
│ │ │ ├── pingpair_test.pde
│ │ │ ├── printf.h
│ │ │ ├── runtest.py
│ │ │ ├── runtests.sh
│ │ │ └── test.ex
│ └── wikidoc.xslt
└── RGB_DRIVER.ino
├── Board Files
├── rgb-board.brd
└── rgb-board.sch
├── CAD Folder
├── ArduinoRamtinTibo.par
├── ArduinoRamtinTibo.stl
├── ArduinoRamtinTiboLid.par
├── ArduinoRamtinTiboLid.stl
└── README.md
├── LICENSE
├── Pictures
├── BoxPicture1.png
├── BoxPicture2.png
├── BoxPicture3.png
├── LidPicture1.png
├── MindMap.png
├── PCB-picture.png
├── PCB.png
├── RF24-Arduino.png
├── RF24-RPI.png
├── Schematic.png
├── demo-landscape.gif
└── demo.gif
└── README.md
/Arduino Code/README:
--------------------------------------------------------------------------------
1 | Empty for now.
2 |
--------------------------------------------------------------------------------
/Arduino Code/RF24-master/.gitignore:
--------------------------------------------------------------------------------
1 | *.bak
2 | *.o
3 | .*.swp
4 | *.orig
5 | .swp
6 | docs/
7 | output/
8 | ojam/
9 | out/
10 | 16000000/
11 | 8000000/
12 | out_native/
13 | version.h
14 | Session.vim
15 |
--------------------------------------------------------------------------------
/Arduino Code/RF24-master/FAQ:
--------------------------------------------------------------------------------
1 | /**
2 | * @page FAQ Frequently Asked Questions
3 | *
4 | * @ref starting
5 | *
6 | * @ref hardware
7 | *
8 | * @ref range
9 | *
10 | * @ref issues
11 | *
12 | * @ref ram
13 | *
14 | * @ref tests
15 | *
16 | * @section starting Where do I start?
17 | *
18 | * See my blog post:
19 | * Getting Started with nRF24L01+ on Arduino
20 | *
21 | * @section hardware Where can I buy some hardware?
22 | *
23 | * @li iTeadStudio sells the basic 2.4G Wireless nRF24L01+ Module for $4. Such a deal!
24 | * @li MDfly.com sells the same unit, 2.4Ghz Wireless nRF24L01+ Transceiver Module for $6.95, but it ships from the US so it gets there a lot faster. Great place to get a few units and get started quickly.
25 | * @li MDfly.com also has the nRF24L01 2.4GHz Transceiver Module w/ Power Amplifier for $13.95, which increases range dramatically and uses a chip antenna
26 | * @li MDfly.com also has the 2.4GHz Transceiver Module w/ Power Amplifier with an external antenna for $19.95
27 | *
28 | * @section range What is the range of these units?
29 | *
30 | * Here are some results from measurements I have taken, using the basic $4 iTeadStudio units.
31 | * I recommend that everyone take their own measurements in their particular circumstances.
32 | *
33 | * @li non-plus unit, 2MBps (worst case), 41+ ft line of sight indoors, immediate dropoff with any deviation from LOS. (41 ft is as far as I can go in my house without turning a corner)
34 | * @li Plus unit, 250kbps (best case), 46 ft around two corners indoors, 49 ft around one corner. More importantly, at 250k, packet loss is almost negligible through almost all of that range.
35 | * @li Both units at 1MBps, plus unit gets about 10% range improvement over non-plus in almost all situations.
36 | *
37 | * @section issues What should I do if I find a problem?
38 | *
39 | * Please open an issue on github if you find any problems using it with any version of Arduino or Maple.
40 | *
41 | * @section ram What is the RAM footprint of this library?
42 | *
43 | * 16 bytes. A single radio object consumes 16 bytes of RAM, and the library
44 | * does not use any other RAM statically.
45 | *
46 | * @section tests Why are the examples in the 'tests' directory failing?
47 | *
48 | * The sketches in the 'tests' directory are not for general use.
49 | * Please use the examples in the 'examples' directory instead.
50 | *
51 | * The 'tests' directory is only for people making changes to the library
52 | * to ensure that their changes do not break anything.
53 | */
54 |
--------------------------------------------------------------------------------
/Arduino Code/RF24-master/README.md:
--------------------------------------------------------------------------------
1 | # Arduino driver for nRF24L01 2.4GHz Wireless Transceiver
2 |
3 | Design Goals: This library is designed to be...
4 |
5 | * Maximally compliant with the intended operation of the chip
6 | * Easy for beginners to use
7 | * Consumed with a public interface that's similiar to other Arduino standard libraries
8 | * Built against the standard SPI library.
9 |
10 | Please refer to:
11 |
12 | * [Documentation Main Page](http://maniacbug.github.com/RF24)
13 | * [RF24 Class Documentation](http://maniacbug.github.com/RF24/classRF24.html)
14 | * [Source Code](https://github.com/maniacbug/RF24)
15 | * [Downloads](https://github.com/maniacbug/RF24/archives/master)
16 | * [Chip Datasheet](http://www.nordicsemi.com/files/Product/data_sheet/nRF24L01_Product_Specification_v2_0.pdf)
17 |
18 | This chip uses the SPI bus, plus two chip control pins. Remember that pin 10 must still remain an output, or
19 | the SPI hardware will go into 'slave' mode.
20 |
21 |
--------------------------------------------------------------------------------
/Arduino Code/RF24-master/RF24_config.h:
--------------------------------------------------------------------------------
1 |
2 | /*
3 | Copyright (C) 2011 J. Coliz
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 | #ifndef __RF24_CONFIG_H__
11 | #define __RF24_CONFIG_H__
12 |
13 | #if ARDUINO < 100
14 | #include
15 | #else
16 | #include
17 | #endif
18 |
19 | #include
20 |
21 | // Stuff that is normally provided by Arduino
22 | #ifdef ARDUINO
23 | #include
24 | #else
25 | #include
26 | #include
27 | #include
28 | extern HardwareSPI SPI;
29 | #define _BV(x) (1<<(x))
30 | #endif
31 |
32 | #undef SERIAL_DEBUG
33 | #ifdef SERIAL_DEBUG
34 | #define IF_SERIAL_DEBUG(x) ({x;})
35 | #else
36 | #define IF_SERIAL_DEBUG(x)
37 | #endif
38 |
39 | // Avoid spurious warnings
40 | #if 1
41 | #if ! defined( NATIVE ) && defined( ARDUINO )
42 | #undef PROGMEM
43 | #define PROGMEM __attribute__(( section(".progmem.data") ))
44 | #undef PSTR
45 | #define PSTR(s) (__extension__({static const char __c[] PROGMEM = (s); &__c[0];}))
46 | #endif
47 | #endif
48 |
49 | // Progmem is Arduino-specific
50 | #ifdef ARDUINO
51 | #include
52 | #define PRIPSTR "%S"
53 | #else
54 | typedef char const char;
55 | typedef uint16_t prog_uint16_t;
56 | #define PSTR(x) (x)
57 | #define printf_P printf
58 | #define strlen_P strlen
59 | #define PROGMEM
60 | #define pgm_read_word(p) (*(p))
61 | #define PRIPSTR "%s"
62 | #endif
63 |
64 | #endif // __RF24_CONFIG_H__
65 | // vim:ai:cin:sts=2 sw=2 ft=cpp
66 |
--------------------------------------------------------------------------------
/Arduino Code/RF24-master/examples/GettingStarted/GettingStarted.pde:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2011 J. Coliz
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 | * Example for Getting Started with nRF24L01+ radios.
11 | *
12 | * This is an example of how to use the RF24 class. Write this sketch to two
13 | * different nodes. Put one of the nodes into 'transmit' mode by connecting
14 | * with the serial monitor and sending a 'T'. The ping node sends the current
15 | * time to the pong node, which responds by sending the value back. The ping
16 | * node can then see how long the whole cycle took.
17 | */
18 |
19 | #include
20 | #include "nRF24L01.h"
21 | #include "RF24.h"
22 | #include "printf.h"
23 |
24 | //
25 | // Hardware configuration
26 | //
27 |
28 | // Set up nRF24L01 radio on SPI bus plus pins 9 & 10
29 |
30 | RF24 radio(9,10);
31 |
32 | //
33 | // Topology
34 | //
35 |
36 | // Radio pipe addresses for the 2 nodes to communicate.
37 | const uint64_t pipes[2] = { 0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL };
38 |
39 | //
40 | // Role management
41 | //
42 | // Set up role. This sketch uses the same software for all the nodes
43 | // in this system. Doing so greatly simplifies testing.
44 | //
45 |
46 | // The various roles supported by this sketch
47 | typedef enum { role_ping_out = 1, role_pong_back } role_e;
48 |
49 | // The debug-friendly names of those roles
50 | const char* role_friendly_name[] = { "invalid", "Ping out", "Pong back"};
51 |
52 | // The role of the current running sketch
53 | role_e role = role_pong_back;
54 |
55 | void setup(void)
56 | {
57 | //
58 | // Print preamble
59 | //
60 |
61 | Serial.begin(57600);
62 | printf_begin();
63 | printf("\n\rRF24/examples/GettingStarted/\n\r");
64 | printf("ROLE: %s\n\r",role_friendly_name[role]);
65 | printf("*** PRESS 'T' to begin transmitting to the other node\n\r");
66 |
67 | //
68 | // Setup and configure rf radio
69 | //
70 |
71 | radio.begin();
72 |
73 | // optionally, increase the delay between retries & # of retries
74 | radio.setRetries(15,15);
75 |
76 | // optionally, reduce the payload size. seems to
77 | // improve reliability
78 | //radio.setPayloadSize(8);
79 |
80 | //
81 | // Open pipes to other nodes for communication
82 | //
83 |
84 | // This simple sketch opens two pipes for these two nodes to communicate
85 | // back and forth.
86 | // Open 'our' pipe for writing
87 | // Open the 'other' pipe for reading, in position #1 (we can have up to 5 pipes open for reading)
88 |
89 | //if ( role == role_ping_out )
90 | {
91 | //radio.openWritingPipe(pipes[0]);
92 | radio.openReadingPipe(1,pipes[1]);
93 | }
94 | //else
95 | {
96 | //radio.openWritingPipe(pipes[1]);
97 | //radio.openReadingPipe(1,pipes[0]);
98 | }
99 |
100 | //
101 | // Start listening
102 | //
103 |
104 | radio.startListening();
105 |
106 | //
107 | // Dump the configuration of the rf unit for debugging
108 | //
109 |
110 | radio.printDetails();
111 | }
112 |
113 | void loop(void)
114 | {
115 | //
116 | // Ping out role. Repeatedly send the current time
117 | //
118 |
119 | if (role == role_ping_out)
120 | {
121 | // First, stop listening so we can talk.
122 | radio.stopListening();
123 |
124 | // Take the time, and send it. This will block until complete
125 | unsigned long time = millis();
126 | printf("Now sending %lu...",time);
127 | bool ok = radio.write( &time, sizeof(unsigned long) );
128 |
129 | if (ok)
130 | printf("ok...");
131 | else
132 | printf("failed.\n\r");
133 |
134 | // Now, continue listening
135 | radio.startListening();
136 |
137 | // Wait here until we get a response, or timeout (250ms)
138 | unsigned long started_waiting_at = millis();
139 | bool timeout = false;
140 | while ( ! radio.available() && ! timeout )
141 | if (millis() - started_waiting_at > 200 )
142 | timeout = true;
143 |
144 | // Describe the results
145 | if ( timeout )
146 | {
147 | printf("Failed, response timed out.\n\r");
148 | }
149 | else
150 | {
151 | // Grab the response, compare, and send to debugging spew
152 | unsigned long got_time;
153 | radio.read( &got_time, sizeof(unsigned long) );
154 |
155 | // Spew it
156 | printf("Got response %lu, round-trip delay: %lu\n\r",got_time,millis()-got_time);
157 | }
158 |
159 | // Try again 1s later
160 | delay(1000);
161 | }
162 |
163 | //
164 | // Pong back role. Receive each packet, dump it out, and send it back
165 | //
166 |
167 | if ( role == role_pong_back )
168 | {
169 | // if there is data ready
170 | if ( radio.available() )
171 | {
172 | // Dump the payloads until we've gotten everything
173 | unsigned long got_time;
174 | bool done = false;
175 | while (!done)
176 | {
177 | // Fetch the payload, and see if this was the last one.
178 | done = radio.read( &got_time, sizeof(unsigned long) );
179 |
180 | // Spew it
181 | printf("Got payload %lu...",got_time);
182 |
183 | // Delay just a little bit to let the other unit
184 | // make the transition to receiver
185 | delay(20);
186 | }
187 |
188 | // First, stop listening so we can talk
189 | radio.stopListening();
190 |
191 | // Send the final one back.
192 | radio.write( &got_time, sizeof(unsigned long) );
193 | printf("Sent response.\n\r");
194 |
195 | // Now, resume listening so we catch the next packets.
196 | radio.startListening();
197 | }
198 | }
199 |
200 | //
201 | // Change roles
202 | //
203 |
204 | if ( Serial.available() )
205 | {
206 | char c = toupper(Serial.read());
207 | if ( c == 'T' && role == role_pong_back )
208 | {
209 | printf("*** CHANGING TO TRANSMIT ROLE -- PRESS 'R' TO SWITCH BACK\n\r");
210 |
211 | // Become the primary transmitter (ping out)
212 | role = role_ping_out;
213 | radio.openWritingPipe(pipes[0]);
214 | radio.openReadingPipe(1,pipes[1]);
215 | }
216 | else if ( c == 'R' && role == role_ping_out )
217 | {
218 | printf("*** CHANGING TO RECEIVE ROLE -- PRESS 'T' TO SWITCH BACK\n\r");
219 |
220 | // Become the primary receiver (pong back)
221 | role = role_pong_back;
222 | radio.openWritingPipe(pipes[1]);
223 | radio.openReadingPipe(1,pipes[0]);
224 | }
225 | }
226 | }
227 | // vim:cin:ai:sts=2 sw=2 ft=cpp
228 |
--------------------------------------------------------------------------------
/Arduino Code/RF24-master/examples/GettingStarted/Jamfile:
--------------------------------------------------------------------------------
1 | # (1) Project Information
2 |
3 | PROJECT_LIBS = SPI RF24 ;
4 |
5 | # (2) Board Information
6 |
7 | UPLOAD_PROTOCOL ?= arduino ;
8 | UPLOAD_SPEED ?= 57600 ;
9 | MCU ?= atmega328p ;
10 | F_CPU ?= 16000000 ;
11 | CORE ?= arduino ;
12 | VARIANT ?= standard ;
13 | ARDUINO_VERSION ?= 100 ;
14 |
15 | # (3) USB Ports
16 |
17 | PORTS = p4 p6 p9 u0 u1 u2 ;
18 | PORT_p6 = /dev/tty.usbserial-A600eHIs ;
19 | PORT_p4 = /dev/tty.usbserial-A40081RP ;
20 | PORT_p9 = /dev/tty.usbserial-A9007LmI ;
21 | PORT_u0 = /dev/ttyUSB0 ;
22 | PORT_u1 = /dev/ttyUSB1 ;
23 | PORT_u2 = /dev/ttyUSB2 ;
24 |
25 | # (4) Location of AVR tools
26 | #
27 | # This configuration assumes using avr-tools that were obtained separate from the Arduino
28 | # distribution.
29 |
30 | if $(OS) = MACOSX
31 | {
32 | AVR_BIN = /usr/local/avrtools/bin ;
33 | AVR_ETC = /usr/local/avrtools/etc ;
34 | AVR_INCLUDE = /usr/local/avrtools/include ;
35 | }
36 | else
37 | {
38 | AVR_BIN ?= /usr/bin ;
39 | AVR_INCLUDE ?= /usr/lib/avr/include ;
40 | AVR_ETC = /etc ;
41 | }
42 |
43 | # (5) Directories where Arduino core and libraries are located
44 |
45 | ARDUINO_DIR ?= /opt/Arduino ;
46 | ARDUINO_CORE = $(ARDUINO_DIR)/hardware/arduino/cores/$(CORE) $(ARDUINO_DIR)/hardware/arduino/variants/$(VARIANT) ;
47 | ARDUINO_LIB = $(ARDUINO_DIR)/libraries ;
48 | SKETCH_LIB = $(HOME)/Source/Arduino/libraries ;
49 |
50 | #
51 | # --------------------------------------------------
52 | # Below this line usually never needs to be modified
53 | #
54 |
55 | # Tool locations
56 |
57 | CC = $(AVR_BIN)/avr-gcc ;
58 | C++ = $(AVR_BIN)/avr-g++ ;
59 | LINK = $(AVR_BIN)/avr-gcc ;
60 | OBJCOPY = $(AVR_BIN)/avr-objcopy ;
61 | AVRDUDE = $(AVR_BIN)/avrdude ;
62 |
63 | # Flags
64 |
65 | DEFINES += F_CPU=$(F_CPU)L ARDUINO=$(ARDUINO_VERSION) VERSION_H ;
66 | OPTIM = -Os ;
67 | CCFLAGS = -Wall -Wextra -mmcu=$(MCU) -ffunction-sections -fdata-sections ;
68 | C++FLAGS = $(CCFLAGS) -fno-exceptions -fno-strict-aliasing ;
69 | LINKFLAGS = $(OPTIM) -lm -Wl,--gc-sections -mmcu=$(MCU) ;
70 | AVRDUDEFLAGS = -V -F -D -C $(AVR_ETC)/avrdude.conf -p $(MCU) -c $(UPLOAD_PROTOCOL) -b $(UPLOAD_SPEED) ;
71 |
72 | # Search everywhere for headers
73 |
74 | HDRS = $(PWD) $(AVR_INCLUDE) $(ARDUINO_CORE) $(ARDUINO_LIB)/$(PROJECT_LIBS) $(ARDUINO_LIB)/$(PROJECT_LIBS)/utility $(SKETCH_LIB)/$(PROJECT_LIBS) ;
75 |
76 | # Output locations
77 |
78 | LOCATE_TARGET = $(F_CPU) ;
79 | LOCATE_SOURCE = $(F_CPU) ;
80 |
81 | #
82 | # Custom rules
83 | #
84 |
85 | rule GitVersion
86 | {
87 | Always $(<) ;
88 | Depends all : $(<) ;
89 | }
90 |
91 | actions GitVersion
92 | {
93 | echo "const char program_version[] = \"\\" > $(<)
94 | git log -1 --pretty=format:%h >> $(<)
95 | echo "\";" >> $(<)
96 | }
97 |
98 | GitVersion version.h ;
99 |
100 | rule Pde
101 | {
102 | Depends $(<) : $(>) ;
103 | MakeLocate $(<) : $(LOCATE_SOURCE) ;
104 | Clean clean : $(<) ;
105 | }
106 |
107 | if ( $(ARDUINO_VERSION) < 100 )
108 | {
109 | ARDUINO_H = WProgram.h ;
110 | }
111 | else
112 | {
113 | ARDUINO_H = Arduino.h ;
114 | }
115 |
116 | actions Pde
117 | {
118 | echo "#include <$(ARDUINO_H)>" > $(<)
119 | echo "#line 1 \"$(>)\"" >> $(<)
120 | cat $(>) >> $(<)
121 | }
122 |
123 | rule C++Pde
124 | {
125 | local _CPP = $(>:B).cpp ;
126 | Pde $(_CPP) : $(>) ;
127 | C++ $(<) : $(_CPP) ;
128 | }
129 |
130 | rule UserObject
131 | {
132 | switch $(>:S)
133 | {
134 | case .ino : C++Pde $(<) : $(>) ;
135 | case .pde : C++Pde $(<) : $(>) ;
136 | }
137 | }
138 |
139 | rule Objects
140 | {
141 | local _i ;
142 |
143 | for _i in [ FGristFiles $(<) ]
144 | {
145 | local _b = $(_i:B)$(SUFOBJ) ;
146 | local _o = $(_b:G=$(SOURCE_GRIST:E)) ;
147 | Object $(_o) : $(_i) ;
148 | Depends obj : $(_o) ;
149 | }
150 | }
151 |
152 | rule Main
153 | {
154 | MainFromObjects $(<) : $(>:B)$(SUFOBJ) ;
155 | Objects $(>) ;
156 | }
157 |
158 | rule Hex
159 | {
160 | Depends $(<) : $(>) ;
161 | MakeLocate $(<) : $(LOCATE_TARGET) ;
162 | Depends hex : $(<) ;
163 | Clean clean : $(<) ;
164 | }
165 |
166 | actions Hex
167 | {
168 | $(OBJCOPY) -O ihex -R .eeprom $(>) $(<)
169 | }
170 |
171 | rule Upload
172 | {
173 | Depends $(1) : $(2) ;
174 | Depends $(2) : $(3) ;
175 | NotFile $(1) ;
176 | Always $(1) ;
177 | Always $(2) ;
178 | UploadAction $(2) : $(3) ;
179 | }
180 |
181 | actions UploadAction
182 | {
183 | $(AVRDUDE) $(AVRDUDEFLAGS) -P $(<) $(AVRDUDE_WRITE_FLASH) -U flash:w:$(>):i
184 | }
185 |
186 | #
187 | # Targets
188 | #
189 |
190 | # Grab everything from the core directory
191 | CORE_MODULES = [ GLOB $(ARDUINO_CORE) : *.c *.cpp ] ;
192 |
193 | # Grab everything from libraries. To avoid this "grab everything" behaviour, you
194 | # can specify specific modules to pick up in PROJECT_MODULES
195 | LIB_MODULES = [ GLOB $(ARDUINO_LIB)/$(PROJECT_LIBS) $(ARDUINO_LIB)/$(PROJECT_LIBS)/utility $(SKETCH_LIB)/$(PROJECT_LIBS) : *.cpp *.c ] ;
196 |
197 | # Grab everything from the current dir
198 | PROJECT_MODULES += [ GLOB $(PWD) : *.c *.cpp *.pde *.ino ] ;
199 |
200 | # Main output executable
201 | MAIN = $(PWD:B).elf ;
202 |
203 | Main $(MAIN) : $(CORE_MODULES) $(LIB_MODULES) $(PROJECT_MODULES) ;
204 | Hex $(MAIN:B).hex : $(MAIN) ;
205 |
206 | # Upload targets
207 | for _p in $(PORTS)
208 | {
209 | Upload $(_p) : $(PORT_$(_p)) : $(MAIN:B).hex ;
210 | }
211 |
--------------------------------------------------------------------------------
/Arduino Code/RF24-master/examples/GettingStarted/printf.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2011 J. Coliz
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 printf.h
11 | *
12 | * Setup necessary to direct stdout to the Arduino Serial library, which
13 | * enables 'printf'
14 | */
15 |
16 | #ifndef __PRINTF_H__
17 | #define __PRINTF_H__
18 |
19 | #ifdef ARDUINO
20 |
21 | int serial_putc( char c, FILE * )
22 | {
23 | Serial.write( c );
24 |
25 | return c;
26 | }
27 |
28 | void printf_begin(void)
29 | {
30 | fdevopen( &serial_putc, 0 );
31 | }
32 |
33 | #else
34 | #error This example is only for use on Arduino.
35 | #endif // ARDUINO
36 |
37 | #endif // __PRINTF_H__
38 |
--------------------------------------------------------------------------------
/Arduino Code/RF24-master/examples/led_remote/Jamfile:
--------------------------------------------------------------------------------
1 | PROJECT_NAME = $(PWD:B) ;
2 | PROJECT_DIR = . ;
3 | PROJECT_LIBS = SPI RF24 ;
4 |
5 | OUT_DIR = ojam ;
6 | F_CPU = 16000000 ;
7 | MCU = atmega328p ;
8 | PORTS = /dev/tty.usbserial-A600eHIs /dev/tty.usbserial-A40081RP /dev/tty.usbserial-A9007LmI ;
9 |
10 | UPLOAD_RATE = 57600 ;
11 | AVRDUDE_PROTOCOL = stk500v1 ;
12 | COM = 33 ;
13 |
14 | # Host-specific overrides for locations
15 | if $(OS) = MACOSX
16 | {
17 | ARDUINO_VERSION = 22 ;
18 | OLD_DIR = /opt/arduino-0021 ;
19 | AVR_TOOLS_PATH = $(OLD_DIR)/hardware/tools/avr/bin ;
20 | AVRDUDECONFIG_PATH = $(OLD_DIR)/hardware/tools/avr/etc ;
21 | ARDUINO_DIR = /opt/Arduino ;
22 | ARDUINO_AVR = /usr/lib/avr/include ;
23 | }
24 |
25 | # Where is everything?
26 | ARDUINO_VERSION ?= 22 ;
27 | AVR_TOOLS_PATH ?= /usr/bin ;
28 | ARDUINO_DIR ?= /opt/arduino-00$(ARDUINO_VERSION) ;
29 | ARDUINO_AVR ?= $(ARDUINO_DIR)/hardware/tools/avr/avr/include/avr ;
30 | AVRDUDECONFIG_PATH ?= $(ARDUINO_DIR)/hardware/tools ;
31 | ARDUINO_CORE = $(ARDUINO_DIR)/hardware/arduino/cores/arduino ;
32 | ARDUINO_LIB = $(ARDUINO_DIR)/libraries ;
33 | SKETCH_LIB = $(HOME)/Source/Arduino/libraries ;
34 | AVR_CC = $(AVR_TOOLS_PATH)/avr-gcc ;
35 | AVR_CXX = $(AVR_TOOLS_PATH)/avr-g++ ;
36 | AVR_LD = $(AVR_TOOLS_PATH)/avr-gcc ;
37 | AVR_OBJCOPY = $(AVR_TOOLS_PATH)/avr-objcopy ;
38 | AVRDUDE = $(AVR_TOOLS_PATH)/avrdude ;
39 |
40 | DEFINES = F_CPU=$(F_CPU)L ARDUINO=$(ARDUINO_VERSION) VERSION_H ;
41 | CTUNING = -ffunction-sections -fdata-sections ;
42 | CXXTUNING = -fno-exceptions -fno-strict-aliasing ;
43 | CFLAGS = -Os -Wall -Wextra -mmcu=$(MCU) $(CTUNING) ;
44 | CXXFLAGS = $(CFLAGS) $(CXXTUNING) ;
45 | LDFLAGS = -Os -lm -Wl,--gc-sections -mmcu=atmega328p ;
46 |
47 | # Search everywhere for headers
48 | HDRS = $(PROJECT_DIR) $(ARDUINO_AVR) $(ARDUINO_CORE) [ GLOB $(ARDUINO_LIB) $(SKETCH_LIB) : [^.]* ] ;
49 |
50 | # Grab everything from the core directory
51 | CORE_MODULES = [ GLOB $(ARDUINO_CORE) : *.c *.cpp ] ;
52 |
53 | # Grab everything from libraries. To avoid this "grab everything" behaviour, you
54 | # can specify specific modules to pick up in PROJECT_MODULES
55 | LIB_MODULES = [ GLOB $(ARDUINO_LIB)/$(PROJECT_LIBS) $(SKETCH_LIB)/$(PROJECT_LIBS) : *.cpp ] ;
56 |
57 | # In addition to explicitly-specified program modules, pick up anything from the current
58 | # dir.
59 | PROJECT_MODULES += [ GLOB $(PROJECT_DIR) : *.c *.cpp *.pde ] ;
60 |
61 | # Shortcut for the out files
62 | OUT = $(OUT_DIR)/$(PROJECT_NAME) ;
63 |
64 | # AvrDude setup
65 | AVRDUDE_FLAGS = -V -F -D -C $(AVRDUDECONFIG_PATH)/avrdude.conf -p $(MCU) -c $(AVRDUDE_PROTOCOL) -b $(UPLOAD_RATE) ;
66 |
67 | rule GitVersion
68 | {
69 | Always $(<) ;
70 | Depends all : $(<) ;
71 | }
72 |
73 | actions GitVersion
74 | {
75 | echo "const char program_version[] = \"\\" > $(<)
76 | git log -1 --pretty=format:%h >> $(<)
77 | echo "\";" >> $(<)
78 | }
79 |
80 | GitVersion version.h ;
81 |
82 | rule AvrCc
83 | {
84 | Depends $(<) : $(>) ;
85 | Depends $(<) : $(<:D) ;
86 | Clean clean : $(<) ;
87 |
88 | CCHDRS on $(<) = [ on $(<) FIncludes $(HDRS) ] ;
89 | CCDEFS on $(<) = [ on $(<) FDefines $(DEFINES) ] ;
90 | }
91 |
92 | actions AvrCc
93 | {
94 | $(AVR_CC) -c -o $(<) $(CCHDRS) $(CCDEFS) $(CFLAGS) $(>)
95 | }
96 |
97 | rule AvrC++
98 | {
99 | Depends $(<) : $(>) ;
100 | Depends $(<) : $(<:D) ;
101 | Clean clean : $(<) ;
102 |
103 | CCHDRS on $(<) = [ on $(<) FIncludes $(HDRS) ] ;
104 | CCDEFS on $(<) = [ on $(<) FDefines $(DEFINES) ] ;
105 | }
106 |
107 | actions AvrC++
108 | {
109 | $(AVR_CXX) -c -o $(<) $(CCHDRS) $(CCDEFS) $(CXXFLAGS) $(>)
110 | }
111 |
112 | rule Pde
113 | {
114 | Depends $(<) : $(>) ;
115 | Depends $(<) : $(<:D) ;
116 | Clean clean : $(<) ;
117 |
118 | }
119 |
120 | actions Pde
121 | {
122 | echo "#include " > $(<)
123 | echo "#line 1 \"$(>)\"" >> $(<)
124 | cat $(>) >> $(<)
125 | }
126 |
127 | rule AvrPde
128 | {
129 | local _CPP = $(OUT_DIR)/$(_I:B).cpp ;
130 | Pde $(_CPP) : $(>) ;
131 | AvrC++ $(<) : $(_CPP) ;
132 | }
133 |
134 | rule AvrObject
135 | {
136 | switch $(>:S)
137 | {
138 | case .c : AvrCc $(<) : $(>) ;
139 | case .cpp : AvrC++ $(<) : $(>) ;
140 | case .pde : AvrPde $(<) : $(>) ;
141 | }
142 | }
143 |
144 | rule AvrObjects
145 | {
146 | for _I in $(<)
147 | {
148 | AvrObject $(OUT_DIR)/$(_I:B).o : $(_I) ;
149 | }
150 | }
151 |
152 | rule AvrMainFromObjects
153 | {
154 | Depends $(<) : $(>) ;
155 | Depends $(<) : $(<:D) ;
156 | MkDir $(<:D) ;
157 | Depends all : $(<) ;
158 | Clean clean : $(<) ;
159 | }
160 |
161 | actions AvrMainFromObjects
162 | {
163 | $(AVR_LD) $(LDFLAGS) -o $(<) $(>)
164 | }
165 |
166 | rule AvrMain
167 | {
168 | AvrMainFromObjects $(<) : $(OUT_DIR)/$(>:B).o ;
169 | AvrObjects $(>) ;
170 | }
171 |
172 | rule AvrHex
173 | {
174 | Depends $(<) : $(>) ;
175 | Depends $(<) : $(<:D) ;
176 | Depends hex : $(<) ;
177 | Clean clean : $(<) ;
178 | }
179 |
180 | actions AvrHex
181 | {
182 | $(AVR_OBJCOPY) -O ihex -R .eeprom $(>) $(<)
183 | }
184 |
185 | rule AvrUpload
186 | {
187 | Depends $(1) : $(2) ;
188 | Depends $(2) : $(3) ;
189 | NotFile $(1) ;
190 | Always $(1) ;
191 | Always $(2) ;
192 | AvrUploadAction $(2) : $(3) ;
193 | }
194 |
195 | actions AvrUploadAction
196 | {
197 | $(AVRDUDE) $(AVRDUDE_FLAGS) -P $(<) $(AVRDUDE_WRITE_FLASH) -U flash:w:$(>):i
198 | }
199 |
200 | AvrMain $(OUT).elf : $(CORE_MODULES) $(LIB_MODULES) $(PROJECT_MODULES) ;
201 | AvrHex $(OUT).hex : $(OUT).elf ;
202 |
203 | AvrUpload p6 : /dev/tty.usbserial-A600eHIs : $(OUT).hex ;
204 | AvrUpload p4 : /dev/tty.usbserial-A40081RP : $(OUT).hex ;
205 | AvrUpload p9 : /dev/tty.usbserial-A9007LmI : $(OUT).hex ;
206 |
207 |
--------------------------------------------------------------------------------
/Arduino Code/RF24-master/examples/led_remote/led_remote.pde:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2011 J. Coliz
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 | * Example LED Remote
11 | *
12 | * This is an example of how to use the RF24 class to control a remote
13 | * bank of LED's using buttons on a remote control.
14 | *
15 | * On the 'remote', connect any number of buttons or switches from
16 | * an arduino pin to ground. Update 'button_pins' to reflect the
17 | * pins used.
18 | *
19 | * On the 'led' board, connect the same number of LED's from an
20 | * arduino pin to a resistor to ground. Update 'led_pins' to reflect
21 | * the pins used. Also connect a separate pin to ground and change
22 | * the 'role_pin'. This tells the sketch it's running on the LED board.
23 | *
24 | * Every time the buttons change on the remote, the entire state of
25 | * buttons is send to the led board, which displays the state.
26 | */
27 |
28 | #include
29 | #include "nRF24L01.h"
30 | #include "RF24.h"
31 | #include "printf.h"
32 |
33 | //
34 | // Hardware configuration
35 | //
36 |
37 | // Set up nRF24L01 radio on SPI bus plus pins 9 & 10
38 |
39 | RF24 radio(9,10);
40 |
41 | // sets the role of this unit in hardware. Connect to GND to be the 'led' board receiver
42 | // Leave open to be the 'remote' transmitter
43 | const int role_pin = A4;
44 |
45 | // Pins on the remote for buttons
46 | const uint8_t button_pins[] = { 2,3,4,5,6,7 };
47 | const uint8_t num_button_pins = sizeof(button_pins);
48 |
49 | // Pins on the LED board for LED's
50 | const uint8_t led_pins[] = { 2,3,4,5,6,7 };
51 | const uint8_t num_led_pins = sizeof(led_pins);
52 |
53 | //
54 | // Topology
55 | //
56 |
57 | // Single radio pipe address for the 2 nodes to communicate.
58 | const uint64_t pipe = 0xE8E8F0F0E1LL;
59 |
60 | //
61 | // Role management
62 | //
63 | // Set up role. This sketch uses the same software for all the nodes in this
64 | // system. Doing so greatly simplifies testing. The hardware itself specifies
65 | // which node it is.
66 | //
67 | // This is done through the role_pin
68 | //
69 |
70 | // The various roles supported by this sketch
71 | typedef enum { role_remote = 1, role_led } role_e;
72 |
73 | // The debug-friendly names of those roles
74 | const char* role_friendly_name[] = { "invalid", "Remote", "LED Board"};
75 |
76 | // The role of the current running sketch
77 | role_e role;
78 |
79 | //
80 | // Payload
81 | //
82 |
83 | uint8_t button_states[num_button_pins];
84 | uint8_t led_states[num_led_pins];
85 |
86 | //
87 | // Setup
88 | //
89 |
90 | void setup(void)
91 | {
92 | //
93 | // Role
94 | //
95 |
96 | // set up the role pin
97 | pinMode(role_pin, INPUT);
98 | digitalWrite(role_pin,HIGH);
99 | delay(20); // Just to get a solid reading on the role pin
100 |
101 | // read the address pin, establish our role
102 | if ( digitalRead(role_pin) )
103 | role = role_remote;
104 | else
105 | role = role_led;
106 |
107 | //
108 | // Print preamble
109 | //
110 |
111 | Serial.begin(57600);
112 | printf_begin();
113 | printf("\n\rRF24/examples/led_remote/\n\r");
114 | printf("ROLE: %s\n\r",role_friendly_name[role]);
115 |
116 | //
117 | // Setup and configure rf radio
118 | //
119 |
120 | radio.begin();
121 |
122 | //
123 | // Open pipes to other nodes for communication
124 | //
125 |
126 | // This simple sketch opens a single pipes for these two nodes to communicate
127 | // back and forth. One listens on it, the other talks to it.
128 |
129 | if ( role == role_remote )
130 | {
131 | radio.openWritingPipe(pipe);
132 | }
133 | else
134 | {
135 | radio.openReadingPipe(1,pipe);
136 | }
137 |
138 | //
139 | // Start listening
140 | //
141 |
142 | if ( role == role_led )
143 | radio.startListening();
144 |
145 | //
146 | // Dump the configuration of the rf unit for debugging
147 | //
148 |
149 | radio.printDetails();
150 |
151 | //
152 | // Set up buttons / LED's
153 | //
154 |
155 | // Set pull-up resistors for all buttons
156 | if ( role == role_remote )
157 | {
158 | int i = num_button_pins;
159 | while(i--)
160 | {
161 | pinMode(button_pins[i],INPUT);
162 | digitalWrite(button_pins[i],HIGH);
163 | }
164 | }
165 |
166 | // Turn LED's ON until we start getting keys
167 | if ( role == role_led )
168 | {
169 | int i = num_led_pins;
170 | while(i--)
171 | {
172 | pinMode(led_pins[i],OUTPUT);
173 | led_states[i] = HIGH;
174 | digitalWrite(led_pins[i],led_states[i]);
175 | }
176 | }
177 |
178 | }
179 |
180 | //
181 | // Loop
182 | //
183 |
184 | void loop(void)
185 | {
186 | //
187 | // Remote role. If the state of any button has changed, send the whole state of
188 | // all buttons.
189 | //
190 |
191 | if ( role == role_remote )
192 | {
193 | // Get the current state of buttons, and
194 | // Test if the current state is different from the last state we sent
195 | int i = num_button_pins;
196 | bool different = false;
197 | while(i--)
198 | {
199 | uint8_t state = ! digitalRead(button_pins[i]);
200 | if ( state != button_states[i] )
201 | {
202 | different = true;
203 | button_states[i] = state;
204 | }
205 | }
206 |
207 | // Send the state of the buttons to the LED board
208 | if ( different )
209 | {
210 | printf("Now sending...");
211 | bool ok = radio.write( button_states, num_button_pins );
212 | if (ok)
213 | printf("ok\n\r");
214 | else
215 | printf("failed\n\r");
216 | }
217 |
218 | // Try again in a short while
219 | delay(20);
220 | }
221 |
222 | //
223 | // LED role. Receive the state of all buttons, and reflect that in the LEDs
224 | //
225 |
226 | if ( role == role_led )
227 | {
228 | // if there is data ready
229 | if ( radio.available() )
230 | {
231 | // Dump the payloads until we've gotten everything
232 | bool done = false;
233 | while (!done)
234 | {
235 | // Fetch the payload, and see if this was the last one.
236 | done = radio.read( button_states, num_button_pins );
237 |
238 | // Spew it
239 | printf("Got buttons\n\r");
240 |
241 | // For each button, if the button now on, then toggle the LED
242 | int i = num_led_pins;
243 | while(i--)
244 | {
245 | if ( button_states[i] )
246 | {
247 | led_states[i] ^= HIGH;
248 | digitalWrite(led_pins[i],led_states[i]);
249 | }
250 | }
251 | }
252 | }
253 | }
254 | }
255 | // vim:ai:cin:sts=2 sw=2 ft=cpp
256 |
--------------------------------------------------------------------------------
/Arduino Code/RF24-master/examples/led_remote/printf.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2011 J. Coliz
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 printf.h
11 | *
12 | * Setup necessary to direct stdout to the Arduino Serial library, which
13 | * enables 'printf'
14 | */
15 |
16 | #ifndef __PRINTF_H__
17 | #define __PRINTF_H__
18 |
19 | #ifdef ARDUINO
20 |
21 | int serial_putc( char c, FILE * )
22 | {
23 | Serial.write( c );
24 |
25 | return c;
26 | }
27 |
28 | void printf_begin(void)
29 | {
30 | fdevopen( &serial_putc, 0 );
31 | }
32 |
33 | #else
34 | #error This example is only for use on Arduino.
35 | #endif // ARDUINO
36 |
37 | #endif // __PRINTF_H__
38 |
--------------------------------------------------------------------------------
/Arduino Code/RF24-master/examples/nordic_fob/Jamfile:
--------------------------------------------------------------------------------
1 | # (1) Project Information
2 |
3 | PROJECT_LIBS = RF24 SPI ;
4 | PROJECT_DIRS = $(PWD) ;
5 |
6 | # (2) Board Information
7 |
8 | UPLOAD_PROTOCOL ?= stk500v1 ;
9 | UPLOAD_SPEED ?= 115200 ;
10 | MCU ?= atmega328p ;
11 | F_CPU ?= 16000000 ;
12 | CORE ?= arduino ;
13 | VARIANT ?= standard ;
14 | ARDUINO_VERSION ?= 100 ;
15 |
16 | # (3) USB Ports
17 |
18 | PORTS = p4 p6 p9 u0 u1 u2 ;
19 | PORT_p6 = /dev/tty.usbserial-A600eHIs ;
20 | PORT_p4 = /dev/tty.usbserial-A40081RP ;
21 | PORT_p9 = /dev/tty.usbserial-A9007LmI ;
22 | PORT_u0 = /dev/ttyUSB0 ;
23 | PORT_u1 = /dev/ttyUSB1 ;
24 | PORT_u2 = /dev/ttyUSB2 ;
25 |
26 | # (4) Location of AVR tools
27 | #
28 | # This configuration assumes using avr-tools that were obtained separate from the Arduino
29 | # distribution.
30 |
31 | if $(OS) = MACOSX
32 | {
33 | AVR_BIN = /usr/local/avrtools/bin ;
34 | AVR_ETC = /usr/local/avrtools/etc ;
35 | AVR_INCLUDE = /usr/local/avrtools/include ;
36 | }
37 | else
38 | {
39 | AVR_BIN = /usr/bin ;
40 | AVR_INCLUDE = /usr/lib/avr/include ;
41 | AVR_ETC = /etc ;
42 | }
43 |
44 | # (5) Directories where Arduino core and libraries are located
45 |
46 | ARDUINO_DIR ?= /opt/Arduino ;
47 | ARDUINO_CORE = $(ARDUINO_DIR)/hardware/arduino/cores/$(CORE) $(ARDUINO_DIR)/hardware/arduino/variants/$(VARIANT) ;
48 | ARDUINO_LIB = $(ARDUINO_DIR)/libraries ;
49 | SKETCH_LIB = $(HOME)/Source/Arduino/libraries ;
50 |
51 | #
52 | # --------------------------------------------------
53 | # Below this line usually never needs to be modified
54 | #
55 |
56 | # Tool locations
57 |
58 | CC = $(AVR_BIN)/avr-gcc ;
59 | C++ = $(AVR_BIN)/avr-g++ ;
60 | LINK = $(AVR_BIN)/avr-gcc ;
61 | AR = $(AVR_BIN)/avr-ar rcs ;
62 | RANLIB = ;
63 | OBJCOPY = $(AVR_BIN)/avr-objcopy ;
64 | AVRDUDE = $(AVR_BIN)/avrdude ;
65 |
66 | # Flags
67 |
68 | DEFINES += F_CPU=$(F_CPU)L ARDUINO=$(ARDUINO_VERSION) VERSION_H ;
69 | OPTIM = -Os ;
70 | CCFLAGS = -Wall -Wextra -Wno-strict-aliasing -mmcu=$(MCU) -ffunction-sections -fdata-sections ;
71 | C++FLAGS = $(CCFLAGS) -fno-exceptions -fno-strict-aliasing ;
72 | LINKFLAGS = $(OPTIM) -lm -Wl,--gc-sections -mmcu=$(MCU) ;
73 | AVRDUDEFLAGS = -V -F -D -C $(AVR_ETC)/avrdude.conf -p $(MCU) -c $(UPLOAD_PROTOCOL) -b $(UPLOAD_SPEED) ;
74 |
75 | # Search everywhere for headers
76 |
77 | HDRS = $(PROJECT_DIRS) $(AVR_INCLUDE) $(ARDUINO_CORE) $(ARDUINO_LIB)/$(PROJECT_LIBS) $(ARDUINO_LIB)/$(PROJECT_LIBS)/utility $(SKETCH_LIB)/$(PROJECT_LIBS) ;
78 |
79 | # Output locations
80 |
81 | LOCATE_TARGET = $(F_CPU) ;
82 | LOCATE_SOURCE = $(F_CPU) ;
83 |
84 | #
85 | # Custom rules
86 | #
87 |
88 | rule GitVersion
89 | {
90 | Always $(<) ;
91 | Depends all : $(<) ;
92 | }
93 |
94 | actions GitVersion
95 | {
96 | echo "const char program_version[] = \"\\" > $(<)
97 | git log -1 --pretty=format:%h >> $(<)
98 | echo "\";" >> $(<)
99 | }
100 |
101 | GitVersion version.h ;
102 |
103 | rule Pde
104 | {
105 | Depends $(<) : $(>) ;
106 | MakeLocate $(<) : $(LOCATE_SOURCE) ;
107 | Clean clean : $(<) ;
108 | }
109 |
110 | if ( $(ARDUINO_VERSION) < 100 )
111 | {
112 | ARDUINO_H = WProgram.h ;
113 | }
114 | else
115 | {
116 | ARDUINO_H = Arduino.h ;
117 | }
118 |
119 | actions Pde
120 | {
121 | echo "#include <$(ARDUINO_H)>" > $(<)
122 | echo "#line 1 \"$(>)\"" >> $(<)
123 | cat $(>) >> $(<)
124 | }
125 |
126 | rule C++Pde
127 | {
128 | local _CPP = $(>:B).cpp ;
129 | Pde $(_CPP) : $(>) ;
130 | C++ $(<) : $(_CPP) ;
131 | }
132 |
133 | rule UserObject
134 | {
135 | switch $(>:S)
136 | {
137 | case .ino : C++Pde $(<) : $(>) ;
138 | case .pde : C++Pde $(<) : $(>) ;
139 | }
140 | }
141 |
142 | rule Objects
143 | {
144 | local _i ;
145 |
146 | for _i in [ FGristFiles $(<) ]
147 | {
148 | local _b = $(_i:B)$(SUFOBJ) ;
149 | local _o = $(_b:G=$(SOURCE_GRIST:E)) ;
150 | Object $(_o) : $(_i) ;
151 | Depends obj : $(_o) ;
152 | }
153 | }
154 |
155 | rule Library
156 | {
157 | LibraryFromObjects $(<) : $(>:B)$(SUFOBJ) ;
158 | Objects $(>) ;
159 | }
160 |
161 | rule Main
162 | {
163 | MainFromObjects $(<) : $(>:B)$(SUFOBJ) ;
164 | Objects $(>) ;
165 | }
166 |
167 | rule Hex
168 | {
169 | Depends $(<) : $(>) ;
170 | MakeLocate $(<) : $(LOCATE_TARGET) ;
171 | Depends hex : $(<) ;
172 | Clean clean : $(<) ;
173 | }
174 |
175 | actions Hex
176 | {
177 | $(OBJCOPY) -O ihex -R .eeprom $(>) $(<)
178 | }
179 |
180 | rule Upload
181 | {
182 | Depends $(1) : $(2) ;
183 | Depends $(2) : $(3) ;
184 | NotFile $(1) ;
185 | Always $(1) ;
186 | Always $(2) ;
187 | UploadAction $(2) : $(3) ;
188 | }
189 |
190 | actions UploadAction
191 | {
192 | $(AVRDUDE) $(AVRDUDEFLAGS) -P $(<) $(AVRDUDE_WRITE_FLASH) -U flash:w:$(>):i
193 | }
194 |
195 | rule Arduino
196 | {
197 | LINKFLAGS on $(<) = $(LINKFLAGS) -Wl,-Map=$(LOCATE_TARGET)/$(<:B).map ;
198 | Main $(<) : $(>) ;
199 | LinkLibraries $(<) : libs core ;
200 | Hex $(<:B).hex : $(<) ;
201 | for _p in $(PORTS)
202 | {
203 | Upload $(_p) : $(PORT_$(_p)) : $(<:B).hex ;
204 | }
205 | }
206 |
207 | #
208 | # Targets
209 | #
210 |
211 | # Grab everything from the core directory
212 | Library core : [ GLOB $(ARDUINO_CORE) : *.c *.cpp ] ;
213 |
214 | # Grab everything from libraries. To avoid this "grab everything" behaviour, you
215 | # can specify specific modules to pick up in PROJECT_MODULES
216 | Library libs : [ GLOB $(ARDUINO_LIB)/$(PROJECT_LIBS) $(ARDUINO_LIB)/$(PROJECT_LIBS)/utility $(SKETCH_LIB)/$(PROJECT_LIBS) : *.cpp *.c ] ;
217 |
218 | # Main output executable
219 | Arduino $(PWD:B).elf : $(PROJECT_MODULES) [ GLOB $(PROJECT_DIRS) : *.c *.cpp *.pde *.ino ] ;
220 |
--------------------------------------------------------------------------------
/Arduino Code/RF24-master/examples/nordic_fob/nordic_fob.pde:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2012 J. Coliz
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 | * Example Nordic FOB Receiver
11 | *
12 | * This is an example of how to use the RF24 class to receive signals from the
13 | * Sparkfun Nordic FOB. Thanks to Kirk Mower for providing test hardware.
14 | *
15 | * See blog post at http://maniacbug.wordpress.com/2012/01/08/nordic-fob/
16 | */
17 |
18 | #include
19 | #include
20 | #include "nRF24L01.h"
21 | #include "printf.h"
22 |
23 | //
24 | // Hardware configuration
25 | //
26 |
27 | // Set up nRF24L01 radio on SPI bus plus pins 9 & 10
28 |
29 | RF24 radio(9,10);
30 |
31 | //
32 | // Payload
33 | //
34 |
35 | struct payload_t
36 | {
37 | uint8_t buttons;
38 | uint16_t id;
39 | uint8_t empty;
40 | };
41 |
42 | const char* button_names[] = { "Up", "Down", "Left", "Right", "Center" };
43 | const int num_buttons = 5;
44 |
45 | //
46 | // Forward declarations
47 | //
48 |
49 | uint16_t flip_endian(uint16_t in);
50 |
51 | //
52 | // Setup
53 | //
54 |
55 | void setup(void)
56 | {
57 | //
58 | // Print preamble
59 | //
60 |
61 | Serial.begin(57600);
62 | printf_begin();
63 | printf("\r\nRF24/examples/nordic_fob/\r\n");
64 |
65 | //
66 | // Setup and configure rf radio according to the built-in parameters
67 | // of the FOB.
68 | //
69 |
70 | radio.begin();
71 | radio.setChannel(2);
72 | radio.setPayloadSize(4);
73 | radio.setAutoAck(false);
74 | radio.setCRCLength(RF24_CRC_8);
75 | radio.openReadingPipe(1,0xE7E7E7E7E7LL);
76 |
77 | //
78 | // Start listening
79 | //
80 |
81 | radio.startListening();
82 |
83 | //
84 | // Dump the configuration of the rf unit for debugging
85 | //
86 |
87 | radio.printDetails();
88 | }
89 |
90 | //
91 | // Loop
92 | //
93 |
94 | void loop(void)
95 | {
96 | //
97 | // Receive each packet, dump it out
98 | //
99 |
100 | // if there is data ready
101 | if ( radio.available() )
102 | {
103 | // Get the packet from the radio
104 | payload_t payload;
105 | radio.read( &payload, sizeof(payload) );
106 |
107 | // Print the ID of this message. Note that the message
108 | // is sent 'big-endian', so we have to flip it.
109 | printf("#%05u Buttons ",flip_endian(payload.id));
110 |
111 | // Print the name of each button
112 | int i = num_buttons;
113 | while (i--)
114 | {
115 | if ( ! ( payload.buttons & _BV(i) ) )
116 | {
117 | printf("%s ",button_names[i]);
118 | }
119 | }
120 |
121 | // If no buttons, print None
122 | if ( payload.buttons == _BV(num_buttons) - 1 )
123 | printf("None");
124 |
125 | printf("\r\n");
126 | }
127 | }
128 |
129 | //
130 | // Helper functions
131 | //
132 |
133 | // Change a big-endian word into a little-endian
134 | uint16_t flip_endian(uint16_t in)
135 | {
136 | uint16_t low = in >> 8;
137 | uint16_t high = in << 8;
138 |
139 | return high | low;
140 | }
141 |
142 | // vim:cin:ai:sts=2 sw=2 ft=cpp
143 |
--------------------------------------------------------------------------------
/Arduino Code/RF24-master/examples/nordic_fob/printf.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2011 J. Coliz
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 printf.h
11 | *
12 | * Setup necessary to direct stdout to the Arduino Serial library, which
13 | * enables 'printf'
14 | */
15 |
16 | #ifndef __PRINTF_H__
17 | #define __PRINTF_H__
18 |
19 | #ifdef ARDUINO
20 |
21 | int serial_putc( char c, FILE * )
22 | {
23 | Serial.write( c );
24 |
25 | return c;
26 | }
27 |
28 | void printf_begin(void)
29 | {
30 | fdevopen( &serial_putc, 0 );
31 | }
32 |
33 | #else
34 | #error This example is only for use on Arduino.
35 | #endif // ARDUINO
36 |
37 | #endif // __PRINTF_H__
38 |
--------------------------------------------------------------------------------
/Arduino Code/RF24-master/examples/pingpair/Jamfile:
--------------------------------------------------------------------------------
1 | # (1) Project Information
2 |
3 | PROJECT_LIBS = SPI RF24 ;
4 | PROJECT_DIRS = $(PWD) ;
5 |
6 | # (2) Board Information
7 |
8 | UPLOAD_PROTOCOL ?= arduino ;
9 | UPLOAD_SPEED ?= 115200 ;
10 | MCU ?= atmega328p ;
11 | F_CPU ?= 16000000 ;
12 | CORE ?= arduino ;
13 | VARIANT ?= standard ;
14 | ARDUINO_VERSION ?= 100 ;
15 |
16 | # (3) USB Ports
17 |
18 | PORTS = p4 p6 p9 u0 u1 u2 ;
19 | PORT_p6 = /dev/tty.usbserial-A600eHIs ;
20 | PORT_p4 = /dev/tty.usbserial-A40081RP ;
21 | PORT_p9 = /dev/tty.usbserial-A9007LmI ;
22 | PORT_u0 = /dev/ttyUSB0 ;
23 | PORT_u1 = /dev/ttyUSB1 ;
24 | PORT_u2 = /dev/ttyUSB2 ;
25 |
26 | # (4) Location of AVR tools
27 | #
28 | # This configuration assumes using avr-tools that were obtained separate from the Arduino
29 | # distribution.
30 |
31 | if $(OS) = MACOSX
32 | {
33 | AVR_BIN ?= /usr/local/avrtools/bin ;
34 | AVR_ETC = /usr/local/avrtools/etc ;
35 | AVR_INCLUDE = /usr/local/avrtools/include ;
36 | }
37 | else
38 | {
39 | AVR_BIN ?= /usr/bin ;
40 | AVR_INCLUDE = /usr/lib/avr/include ;
41 | AVR_ETC = /etc ;
42 | }
43 |
44 | # (5) Directories where Arduino core and libraries are located
45 |
46 | ARDUINO_DIR ?= /opt/Arduino ;
47 | ARDUINO_CORE = $(ARDUINO_DIR)/hardware/arduino/cores/$(CORE) $(ARDUINO_DIR)/hardware/arduino/variants/$(VARIANT) ;
48 | ARDUINO_LIB = $(ARDUINO_DIR)/libraries ;
49 | SKETCH_LIB = $(HOME)/Source/Arduino/libraries ;
50 |
51 | #
52 | # --------------------------------------------------
53 | # Below this line usually never needs to be modified
54 | #
55 |
56 | # Tool locations
57 |
58 | CC = $(AVR_BIN)/avr-gcc ;
59 | C++ = $(AVR_BIN)/avr-g++ ;
60 | LINK = $(AVR_BIN)/avr-gcc ;
61 | AR = $(AVR_BIN)/avr-ar rcs ;
62 | RANLIB = ;
63 | OBJCOPY = $(AVR_BIN)/avr-objcopy ;
64 | AVRDUDE ?= $(AVR_BIN)/avrdude ;
65 |
66 | # Flags
67 |
68 | DEFINES += F_CPU=$(F_CPU)L ARDUINO=$(ARDUINO_VERSION) VERSION_H ;
69 | OPTIM = -Os ;
70 | CCFLAGS = -Wall -Wextra -Wno-strict-aliasing -mmcu=$(MCU) -ffunction-sections -fdata-sections ;
71 | C++FLAGS = $(CCFLAGS) -fno-exceptions -fno-strict-aliasing ;
72 | LINKFLAGS = $(OPTIM) -lm -Wl,--gc-sections -mmcu=$(MCU) ;
73 | AVRDUDEFLAGS = -V -F -D -C $(AVR_ETC)/avrdude.conf -p $(MCU) -c $(UPLOAD_PROTOCOL) -b $(UPLOAD_SPEED) ;
74 |
75 | # Search everywhere for headers
76 |
77 | HDRS = $(PROJECT_DIRS) $(AVR_INCLUDE) $(ARDUINO_CORE) $(ARDUINO_LIB)/$(PROJECT_LIBS) $(ARDUINO_LIB)/$(PROJECT_LIBS)/utility $(SKETCH_LIB)/$(PROJECT_LIBS) ;
78 |
79 | # Output locations
80 |
81 | LOCATE_TARGET = $(F_CPU) ;
82 | LOCATE_SOURCE = $(F_CPU) ;
83 |
84 | #
85 | # Custom rules
86 | #
87 |
88 | rule GitVersion
89 | {
90 | Always $(<) ;
91 | Depends all : $(<) ;
92 | }
93 |
94 | actions GitVersion
95 | {
96 | echo "const char program_version[] = \"\\" > $(<)
97 | git log -1 --pretty=format:%h >> $(<)
98 | echo "\";" >> $(<)
99 | }
100 |
101 | GitVersion version.h ;
102 |
103 | rule Pde
104 | {
105 | Depends $(<) : $(>) ;
106 | MakeLocate $(<) : $(LOCATE_SOURCE) ;
107 | Clean clean : $(<) ;
108 | }
109 |
110 | if ( $(ARDUINO_VERSION) < 100 )
111 | {
112 | ARDUINO_H = WProgram.h ;
113 | }
114 | else
115 | {
116 | ARDUINO_H = Arduino.h ;
117 | }
118 |
119 | actions Pde
120 | {
121 | echo "#include <$(ARDUINO_H)>" > $(<)
122 | echo "#line 1 \"$(>)\"" >> $(<)
123 | cat $(>) >> $(<)
124 | }
125 |
126 | rule C++Pde
127 | {
128 | local _CPP = $(>:B).cpp ;
129 | Pde $(_CPP) : $(>) ;
130 | C++ $(<) : $(_CPP) ;
131 | }
132 |
133 | rule UserObject
134 | {
135 | switch $(>:S)
136 | {
137 | case .ino : C++Pde $(<) : $(>) ;
138 | case .pde : C++Pde $(<) : $(>) ;
139 | }
140 | }
141 |
142 | rule Objects
143 | {
144 | local _i ;
145 |
146 | for _i in [ FGristFiles $(<) ]
147 | {
148 | local _b = $(_i:B)$(SUFOBJ) ;
149 | local _o = $(_b:G=$(SOURCE_GRIST:E)) ;
150 | Object $(_o) : $(_i) ;
151 | Depends obj : $(_o) ;
152 | }
153 | }
154 |
155 | rule Library
156 | {
157 | LibraryFromObjects $(<) : $(>:B)$(SUFOBJ) ;
158 | Objects $(>) ;
159 | }
160 |
161 | rule Main
162 | {
163 | MainFromObjects $(<) : $(>:B)$(SUFOBJ) ;
164 | Objects $(>) ;
165 | }
166 |
167 | rule Hex
168 | {
169 | Depends $(<) : $(>) ;
170 | MakeLocate $(<) : $(LOCATE_TARGET) ;
171 | Depends hex : $(<) ;
172 | Clean clean : $(<) ;
173 | }
174 |
175 | actions Hex
176 | {
177 | $(OBJCOPY) -O ihex -R .eeprom $(>) $(<)
178 | }
179 |
180 | rule Upload
181 | {
182 | Depends $(1) : $(2) ;
183 | Depends $(2) : $(3) ;
184 | NotFile $(1) ;
185 | Always $(1) ;
186 | Always $(2) ;
187 | UploadAction $(2) : $(3) ;
188 | }
189 |
190 | actions UploadAction
191 | {
192 | $(AVRDUDE) $(AVRDUDEFLAGS) -P $(<) $(AVRDUDE_WRITE_FLASH) -U flash:w:$(>):i
193 | }
194 |
195 | rule Arduino
196 | {
197 | LINKFLAGS on $(<) = $(LINKFLAGS) -Wl,-Map=$(LOCATE_TARGET)/$(<:B).map ;
198 | Main $(<) : $(>) ;
199 | LinkLibraries $(<) : core libs ;
200 | Hex $(<:B).hex : $(<) ;
201 | for _p in $(PORTS)
202 | {
203 | Upload $(_p) : $(PORT_$(_p)) : $(<:B).hex ;
204 | }
205 | }
206 |
207 | #
208 | # Targets
209 | #
210 |
211 | # Grab everything from the core directory
212 | Library core : [ GLOB $(ARDUINO_CORE) : *.c *.cpp ] ;
213 |
214 | # Grab everything from libraries. To avoid this "grab everything" behaviour, you
215 | # can specify specific modules to pick up in PROJECT_MODULES
216 | Library libs : [ GLOB $(ARDUINO_LIB)/$(PROJECT_LIBS) $(ARDUINO_LIB)/$(PROJECT_LIBS)/utility $(SKETCH_LIB)/$(PROJECT_LIBS) : *.cpp *.c ] ;
217 |
218 | # Main output executable
219 | Arduino $(PWD:B).elf : $(PROJECT_MODULES) [ GLOB $(PROJECT_DIRS) : *.c *.cpp *.pde *.ino ] ;
220 |
--------------------------------------------------------------------------------
/Arduino Code/RF24-master/examples/pingpair/pingpair.pde:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2011 J. Coliz
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 | * Example RF Radio Ping Pair
11 | *
12 | * This is an example of how to use the RF24 class. Write this sketch to two different nodes,
13 | * connect the role_pin to ground on one. The ping node sends the current time to the pong node,
14 | * which responds by sending the value back. The ping node can then see how long the whole cycle
15 | * took.
16 | */
17 |
18 | #include
19 | #include "nRF24L01.h"
20 | #include "RF24.h"
21 | #include "printf.h"
22 |
23 | //
24 | // Hardware configuration
25 | //
26 |
27 | // Set up nRF24L01 radio on SPI bus plus pins 9 & 10
28 |
29 | RF24 radio(9,10);
30 |
31 | // sets the role of this unit in hardware. Connect to GND to be the 'pong' receiver
32 | // Leave open to be the 'ping' transmitter
33 | const int role_pin = 7;
34 |
35 | //
36 | // Topology
37 | //
38 |
39 | // Radio pipe addresses for the 2 nodes to communicate.
40 | const uint64_t pipes[2] = { 0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL };
41 |
42 | //
43 | // Role management
44 | //
45 | // Set up role. This sketch uses the same software for all the nodes
46 | // in this system. Doing so greatly simplifies testing. The hardware itself specifies
47 | // which node it is.
48 | //
49 | // This is done through the role_pin
50 | //
51 |
52 | // The various roles supported by this sketch
53 | typedef enum { role_ping_out = 1, role_pong_back } role_e;
54 |
55 | // The debug-friendly names of those roles
56 | const char* role_friendly_name[] = { "invalid", "Ping out", "Pong back"};
57 |
58 | // The role of the current running sketch
59 | role_e role;
60 |
61 | void setup(void)
62 | {
63 | //
64 | // Role
65 | //
66 |
67 | // set up the role pin
68 | pinMode(role_pin, INPUT);
69 | digitalWrite(role_pin,HIGH);
70 | delay(20); // Just to get a solid reading on the role pin
71 |
72 | // read the address pin, establish our role
73 | if ( ! digitalRead(role_pin) )
74 | role = role_ping_out;
75 | else
76 | role = role_pong_back;
77 |
78 | //
79 | // Print preamble
80 | //
81 |
82 | Serial.begin(57600);
83 | printf_begin();
84 | printf("\n\rRF24/examples/pingpair/\n\r");
85 | printf("ROLE: %s\n\r",role_friendly_name[role]);
86 |
87 | //
88 | // Setup and configure rf radio
89 | //
90 |
91 | radio.begin();
92 |
93 | // optionally, increase the delay between retries & # of retries
94 | radio.setRetries(15,15);
95 |
96 | // optionally, reduce the payload size. seems to
97 | // improve reliability
98 | radio.setPayloadSize(8);
99 |
100 | //
101 | // Open pipes to other nodes for communication
102 | //
103 |
104 | // This simple sketch opens two pipes for these two nodes to communicate
105 | // back and forth.
106 | // Open 'our' pipe for writing
107 | // Open the 'other' pipe for reading, in position #1 (we can have up to 5 pipes open for reading)
108 |
109 | if ( role == role_ping_out )
110 | {
111 | radio.openWritingPipe(pipes[0]);
112 | radio.openReadingPipe(1,pipes[1]);
113 | }
114 | else
115 | {
116 | radio.openWritingPipe(pipes[1]);
117 | radio.openReadingPipe(1,pipes[0]);
118 | }
119 |
120 | //
121 | // Start listening
122 | //
123 |
124 | radio.startListening();
125 |
126 | //
127 | // Dump the configuration of the rf unit for debugging
128 | //
129 |
130 | radio.printDetails();
131 | }
132 |
133 | void loop(void)
134 | {
135 | //
136 | // Ping out role. Repeatedly send the current time
137 | //
138 |
139 | if (role == role_ping_out)
140 | {
141 | // First, stop listening so we can talk.
142 | radio.stopListening();
143 |
144 | // Take the time, and send it. This will block until complete
145 | unsigned long time = millis();
146 | printf("Now sending %lu...",time);
147 | bool ok = radio.write( &time, sizeof(unsigned long) );
148 |
149 | if (ok)
150 | printf("ok...");
151 | else
152 | printf("failed.\n\r");
153 |
154 | // Now, continue listening
155 | radio.startListening();
156 |
157 | // Wait here until we get a response, or timeout (250ms)
158 | unsigned long started_waiting_at = millis();
159 | bool timeout = false;
160 | while ( ! radio.available() && ! timeout )
161 | if (millis() - started_waiting_at > 200 )
162 | timeout = true;
163 |
164 | // Describe the results
165 | if ( timeout )
166 | {
167 | printf("Failed, response timed out.\n\r");
168 | }
169 | else
170 | {
171 | // Grab the response, compare, and send to debugging spew
172 | unsigned long got_time;
173 | radio.read( &got_time, sizeof(unsigned long) );
174 |
175 | // Spew it
176 | printf("Got response %lu, round-trip delay: %lu\n\r",got_time,millis()-got_time);
177 | }
178 |
179 | // Try again 1s later
180 | delay(1000);
181 | }
182 |
183 | //
184 | // Pong back role. Receive each packet, dump it out, and send it back
185 | //
186 |
187 | if ( role == role_pong_back )
188 | {
189 | // if there is data ready
190 | if ( radio.available() )
191 | {
192 | // Dump the payloads until we've gotten everything
193 | unsigned long got_time;
194 | bool done = false;
195 | while (!done)
196 | {
197 | // Fetch the payload, and see if this was the last one.
198 | done = radio.read( &got_time, sizeof(unsigned long) );
199 |
200 | // Spew it
201 | printf("Got payload %lu...",got_time);
202 |
203 | // Delay just a little bit to let the other unit
204 | // make the transition to receiver
205 | delay(20);
206 | }
207 |
208 | // First, stop listening so we can talk
209 | radio.stopListening();
210 |
211 | // Send the final one back.
212 | radio.write( &got_time, sizeof(unsigned long) );
213 | printf("Sent response.\n\r");
214 |
215 | // Now, resume listening so we catch the next packets.
216 | radio.startListening();
217 | }
218 | }
219 | }
220 | // vim:cin:ai:sts=2 sw=2 ft=cpp
221 |
--------------------------------------------------------------------------------
/Arduino Code/RF24-master/examples/pingpair/printf.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2011 J. Coliz
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 printf.h
11 | *
12 | * Setup necessary to direct stdout to the Arduino Serial library, which
13 | * enables 'printf'
14 | */
15 |
16 | #ifndef __PRINTF_H__
17 | #define __PRINTF_H__
18 |
19 | #ifdef ARDUINO
20 |
21 | int serial_putc( char c, FILE * )
22 | {
23 | Serial.write( c );
24 |
25 | return c;
26 | }
27 |
28 | void printf_begin(void)
29 | {
30 | fdevopen( &serial_putc, 0 );
31 | }
32 |
33 | #else
34 | #error This example is only for use on Arduino.
35 | #endif // ARDUINO
36 |
37 | #endif // __PRINTF_H__
38 |
--------------------------------------------------------------------------------
/Arduino Code/RF24-master/examples/pingpair_dyn/Jamfile:
--------------------------------------------------------------------------------
1 | PROJECT_NAME = $(PWD:B) ;
2 | PROJECT_DIR = . ;
3 | PROJECT_LIBS = SPI RF24 ;
4 |
5 | OUT_DIR = ojam ;
6 | F_CPU = 16000000 ;
7 | MCU = atmega328p ;
8 | PORTS = /dev/tty.usbserial-A600eHIs /dev/tty.usbserial-A40081RP /dev/tty.usbserial-A9007LmI ;
9 |
10 | UPLOAD_RATE = 57600 ;
11 | AVRDUDE_PROTOCOL = stk500v1 ;
12 | COM = 33 ;
13 |
14 | # Host-specific overrides for locations
15 | if $(OS) = MACOSX
16 | {
17 | ARDUINO_VERSION = 22 ;
18 | OLD_DIR = /opt/arduino-0021 ;
19 | AVR_TOOLS_PATH = $(OLD_DIR)/hardware/tools/avr/bin ;
20 | AVRDUDECONFIG_PATH = $(OLD_DIR)/hardware/tools/avr/etc ;
21 | ARDUINO_DIR = /opt/Arduino ;
22 | ARDUINO_AVR = /usr/lib/avr/include ;
23 | }
24 |
25 | # Where is everything?
26 | ARDUINO_VERSION ?= 22 ;
27 | AVR_TOOLS_PATH ?= /usr/bin ;
28 | ARDUINO_DIR ?= /opt/arduino-00$(ARDUINO_VERSION) ;
29 | ARDUINO_AVR ?= $(ARDUINO_DIR)/hardware/tools/avr/avr/include/avr ;
30 | AVRDUDECONFIG_PATH ?= $(ARDUINO_DIR)/hardware/tools ;
31 | ARDUINO_CORE = $(ARDUINO_DIR)/hardware/arduino/cores/arduino ;
32 | ARDUINO_LIB = $(ARDUINO_DIR)/libraries ;
33 | SKETCH_LIB = $(HOME)/Source/Arduino/libraries ;
34 | AVR_CC = $(AVR_TOOLS_PATH)/avr-gcc ;
35 | AVR_CXX = $(AVR_TOOLS_PATH)/avr-g++ ;
36 | AVR_LD = $(AVR_TOOLS_PATH)/avr-gcc ;
37 | AVR_OBJCOPY = $(AVR_TOOLS_PATH)/avr-objcopy ;
38 | AVRDUDE = $(AVR_TOOLS_PATH)/avrdude ;
39 |
40 | DEFINES = F_CPU=$(F_CPU)L ARDUINO=$(ARDUINO_VERSION) VERSION_H ;
41 | CTUNING = -ffunction-sections -fdata-sections ;
42 | CXXTUNING = -fno-exceptions -fno-strict-aliasing ;
43 | CFLAGS = -Os -Wall -Wextra -mmcu=$(MCU) $(CTUNING) ;
44 | CXXFLAGS = $(CFLAGS) $(CXXTUNING) ;
45 | LDFLAGS = -Os -lm -Wl,--gc-sections -mmcu=atmega328p ;
46 |
47 | # Search everywhere for headers
48 | HDRS = $(PROJECT_DIR) $(ARDUINO_AVR) $(ARDUINO_CORE) [ GLOB $(ARDUINO_LIB) $(SKETCH_LIB) : [^.]* ] ;
49 |
50 | # Grab everything from the core directory
51 | CORE_MODULES = [ GLOB $(ARDUINO_CORE) : *.c *.cpp ] ;
52 |
53 | # Grab everything from libraries. To avoid this "grab everything" behaviour, you
54 | # can specify specific modules to pick up in PROJECT_MODULES
55 | LIB_MODULES = [ GLOB $(ARDUINO_LIB)/$(PROJECT_LIBS) $(SKETCH_LIB)/$(PROJECT_LIBS) : *.cpp ] ;
56 |
57 | # In addition to explicitly-specified program modules, pick up anything from the current
58 | # dir.
59 | PROJECT_MODULES += [ GLOB $(PROJECT_DIR) : *.c *.cpp *.pde ] ;
60 |
61 | # Shortcut for the out files
62 | OUT = $(OUT_DIR)/$(PROJECT_NAME) ;
63 |
64 | # AvrDude setup
65 | AVRDUDE_FLAGS = -V -F -D -C $(AVRDUDECONFIG_PATH)/avrdude.conf -p $(MCU) -c $(AVRDUDE_PROTOCOL) -b $(UPLOAD_RATE) ;
66 |
67 | rule GitVersion
68 | {
69 | Always $(<) ;
70 | Depends all : $(<) ;
71 | }
72 |
73 | actions GitVersion
74 | {
75 | echo "const char program_version[] = \"\\" > $(<)
76 | git log -1 --pretty=format:%h >> $(<)
77 | echo "\";" >> $(<)
78 | }
79 |
80 | GitVersion version.h ;
81 |
82 | rule AvrCc
83 | {
84 | Depends $(<) : $(>) ;
85 | Depends $(<) : $(<:D) ;
86 | Clean clean : $(<) ;
87 |
88 | CCHDRS on $(<) = [ on $(<) FIncludes $(HDRS) ] ;
89 | CCDEFS on $(<) = [ on $(<) FDefines $(DEFINES) ] ;
90 | }
91 |
92 | actions AvrCc
93 | {
94 | $(AVR_CC) -c -o $(<) $(CCHDRS) $(CCDEFS) $(CFLAGS) $(>)
95 | }
96 |
97 | rule AvrC++
98 | {
99 | Depends $(<) : $(>) ;
100 | Depends $(<) : $(<:D) ;
101 | Clean clean : $(<) ;
102 |
103 | CCHDRS on $(<) = [ on $(<) FIncludes $(HDRS) ] ;
104 | CCDEFS on $(<) = [ on $(<) FDefines $(DEFINES) ] ;
105 | }
106 |
107 | actions AvrC++
108 | {
109 | $(AVR_CXX) -c -o $(<) $(CCHDRS) $(CCDEFS) $(CXXFLAGS) $(>)
110 | }
111 |
112 | rule Pde
113 | {
114 | Depends $(<) : $(>) ;
115 | Depends $(<) : $(<:D) ;
116 | Clean clean : $(<) ;
117 |
118 | }
119 |
120 | actions Pde
121 | {
122 | echo "#include " > $(<)
123 | echo "#line 1 \"$(>)\"" >> $(<)
124 | cat $(>) >> $(<)
125 | }
126 |
127 | rule AvrPde
128 | {
129 | local _CPP = $(OUT_DIR)/$(_I:B).cpp ;
130 | Pde $(_CPP) : $(>) ;
131 | AvrC++ $(<) : $(_CPP) ;
132 | }
133 |
134 | rule AvrObject
135 | {
136 | switch $(>:S)
137 | {
138 | case .c : AvrCc $(<) : $(>) ;
139 | case .cpp : AvrC++ $(<) : $(>) ;
140 | case .pde : AvrPde $(<) : $(>) ;
141 | }
142 | }
143 |
144 | rule AvrObjects
145 | {
146 | for _I in $(<)
147 | {
148 | AvrObject $(OUT_DIR)/$(_I:B).o : $(_I) ;
149 | }
150 | }
151 |
152 | rule AvrMainFromObjects
153 | {
154 | Depends $(<) : $(>) ;
155 | Depends $(<) : $(<:D) ;
156 | MkDir $(<:D) ;
157 | Depends all : $(<) ;
158 | Clean clean : $(<) ;
159 | }
160 |
161 | actions AvrMainFromObjects
162 | {
163 | $(AVR_LD) $(LDFLAGS) -o $(<) $(>)
164 | }
165 |
166 | rule AvrMain
167 | {
168 | AvrMainFromObjects $(<) : $(OUT_DIR)/$(>:B).o ;
169 | AvrObjects $(>) ;
170 | }
171 |
172 | rule AvrHex
173 | {
174 | Depends $(<) : $(>) ;
175 | Depends $(<) : $(<:D) ;
176 | Depends hex : $(<) ;
177 | Clean clean : $(<) ;
178 | }
179 |
180 | actions AvrHex
181 | {
182 | $(AVR_OBJCOPY) -O ihex -R .eeprom $(>) $(<)
183 | }
184 |
185 | rule AvrUpload
186 | {
187 | Depends $(1) : $(2) ;
188 | Depends $(2) : $(3) ;
189 | NotFile $(1) ;
190 | Always $(1) ;
191 | Always $(2) ;
192 | AvrUploadAction $(2) : $(3) ;
193 | }
194 |
195 | actions AvrUploadAction
196 | {
197 | $(AVRDUDE) $(AVRDUDE_FLAGS) -P $(<) $(AVRDUDE_WRITE_FLASH) -U flash:w:$(>):i
198 | }
199 |
200 | AvrMain $(OUT).elf : $(CORE_MODULES) $(LIB_MODULES) $(PROJECT_MODULES) ;
201 | AvrHex $(OUT).hex : $(OUT).elf ;
202 |
203 | AvrUpload p6 : /dev/tty.usbserial-A600eHIs : $(OUT).hex ;
204 | AvrUpload p4 : /dev/tty.usbserial-A40081RP : $(OUT).hex ;
205 | AvrUpload p9 : /dev/tty.usbserial-A9007LmI : $(OUT).hex ;
206 |
207 |
--------------------------------------------------------------------------------
/Arduino Code/RF24-master/examples/pingpair_dyn/pingpair_dyn.pde:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2011 J. Coliz
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 | * Example using Dynamic Payloads
11 | *
12 | * This is an example of how to use payloads of a varying (dynamic) size.
13 | */
14 |
15 | #include
16 | #include "nRF24L01.h"
17 | #include "RF24.h"
18 | #include "printf.h"
19 |
20 | //
21 | // Hardware configuration
22 | //
23 |
24 | // Set up nRF24L01 radio on SPI bus plus pins 9 & 10
25 |
26 | RF24 radio(9,10);
27 |
28 | // sets the role of this unit in hardware. Connect to GND to be the 'pong' receiver
29 | // Leave open to be the 'ping' transmitter
30 | const int role_pin = 7;
31 |
32 | //
33 | // Topology
34 | //
35 |
36 | // Radio pipe addresses for the 2 nodes to communicate.
37 | const uint64_t pipes[2] = { 0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL };
38 |
39 | //
40 | // Role management
41 | //
42 | // Set up role. This sketch uses the same software for all the nodes
43 | // in this system. Doing so greatly simplifies testing. The hardware itself specifies
44 | // which node it is.
45 | //
46 | // This is done through the role_pin
47 | //
48 |
49 | // The various roles supported by this sketch
50 | typedef enum { role_ping_out = 1, role_pong_back } role_e;
51 |
52 | // The debug-friendly names of those roles
53 | const char* role_friendly_name[] = { "invalid", "Ping out", "Pong back"};
54 |
55 | // The role of the current running sketch
56 | role_e role;
57 |
58 | //
59 | // Payload
60 | //
61 |
62 | const int min_payload_size = 4;
63 | const int max_payload_size = 32;
64 | const int payload_size_increments_by = 2;
65 | int next_payload_size = min_payload_size;
66 |
67 | char receive_payload[max_payload_size+1]; // +1 to allow room for a terminating NULL char
68 |
69 | void setup(void)
70 | {
71 | //
72 | // Role
73 | //
74 |
75 | // set up the role pin
76 | pinMode(role_pin, INPUT);
77 | digitalWrite(role_pin,HIGH);
78 | delay(20); // Just to get a solid reading on the role pin
79 |
80 | // read the address pin, establish our role
81 | if ( digitalRead(role_pin) )
82 | role = role_ping_out;
83 | else
84 | role = role_pong_back;
85 |
86 | //
87 | // Print preamble
88 | //
89 |
90 | Serial.begin(57600);
91 | printf_begin();
92 | printf("\n\rRF24/examples/pingpair_dyn/\n\r");
93 | printf("ROLE: %s\n\r",role_friendly_name[role]);
94 |
95 | //
96 | // Setup and configure rf radio
97 | //
98 |
99 | radio.begin();
100 |
101 | // enable dynamic payloads
102 | radio.enableDynamicPayloads();
103 |
104 | // optionally, increase the delay between retries & # of retries
105 | radio.setRetries(15,15);
106 |
107 | //
108 | // Open pipes to other nodes for communication
109 | //
110 |
111 | // This simple sketch opens two pipes for these two nodes to communicate
112 | // back and forth.
113 | // Open 'our' pipe for writing
114 | // Open the 'other' pipe for reading, in position #1 (we can have up to 5 pipes open for reading)
115 |
116 | if ( role == role_ping_out )
117 | {
118 | radio.openWritingPipe(pipes[0]);
119 | radio.openReadingPipe(1,pipes[1]);
120 | }
121 | else
122 | {
123 | radio.openWritingPipe(pipes[1]);
124 | radio.openReadingPipe(1,pipes[0]);
125 | }
126 |
127 | //
128 | // Start listening
129 | //
130 |
131 | radio.startListening();
132 |
133 | //
134 | // Dump the configuration of the rf unit for debugging
135 | //
136 |
137 | radio.printDetails();
138 | }
139 |
140 | void loop(void)
141 | {
142 | //
143 | // Ping out role. Repeatedly send the current time
144 | //
145 |
146 | if (role == role_ping_out)
147 | {
148 | // The payload will always be the same, what will change is how much of it we send.
149 | static char send_payload[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ789012";
150 |
151 | // First, stop listening so we can talk.
152 | radio.stopListening();
153 |
154 | // Take the time, and send it. This will block until complete
155 | printf("Now sending length %i...",next_payload_size);
156 | radio.write( send_payload, next_payload_size );
157 |
158 | // Now, continue listening
159 | radio.startListening();
160 |
161 | // Wait here until we get a response, or timeout
162 | unsigned long started_waiting_at = millis();
163 | bool timeout = false;
164 | while ( ! radio.available() && ! timeout )
165 | if (millis() - started_waiting_at > 500 )
166 | timeout = true;
167 |
168 | // Describe the results
169 | if ( timeout )
170 | {
171 | printf("Failed, response timed out.\n\r");
172 | }
173 | else
174 | {
175 | // Grab the response, compare, and send to debugging spew
176 | uint8_t len = radio.getDynamicPayloadSize();
177 | radio.read( receive_payload, len );
178 |
179 | // Put a zero at the end for easy printing
180 | receive_payload[len] = 0;
181 |
182 | // Spew it
183 | printf("Got response size=%i value=%s\n\r",len,receive_payload);
184 | }
185 |
186 | // Update size for next time.
187 | next_payload_size += payload_size_increments_by;
188 | if ( next_payload_size > max_payload_size )
189 | next_payload_size = min_payload_size;
190 |
191 | // Try again 1s later
192 | delay(1000);
193 | }
194 |
195 | //
196 | // Pong back role. Receive each packet, dump it out, and send it back
197 | //
198 |
199 | if ( role == role_pong_back )
200 | {
201 | // if there is data ready
202 | if ( radio.available() )
203 | {
204 | // Dump the payloads until we've gotten everything
205 | uint8_t len;
206 | bool done = false;
207 | while (!done)
208 | {
209 | // Fetch the payload, and see if this was the last one.
210 | len = radio.getDynamicPayloadSize();
211 | done = radio.read( receive_payload, len );
212 |
213 | // Put a zero at the end for easy printing
214 | receive_payload[len] = 0;
215 |
216 | // Spew it
217 | printf("Got payload size=%i value=%s\n\r",len,receive_payload);
218 | }
219 |
220 | // First, stop listening so we can talk
221 | radio.stopListening();
222 |
223 | // Send the final one back.
224 | radio.write( receive_payload, len );
225 | printf("Sent response.\n\r");
226 |
227 | // Now, resume listening so we catch the next packets.
228 | radio.startListening();
229 | }
230 | }
231 | }
232 | // vim:cin:ai:sts=2 sw=2 ft=cpp
233 |
--------------------------------------------------------------------------------
/Arduino Code/RF24-master/examples/pingpair_dyn/printf.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2011 J. Coliz
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 printf.h
11 | *
12 | * Setup necessary to direct stdout to the Arduino Serial library, which
13 | * enables 'printf'
14 | */
15 |
16 | #ifndef __PRINTF_H__
17 | #define __PRINTF_H__
18 |
19 | #ifdef ARDUINO
20 |
21 | int serial_putc( char c, FILE * )
22 | {
23 | Serial.write( c );
24 |
25 | return c;
26 | }
27 |
28 | void printf_begin(void)
29 | {
30 | fdevopen( &serial_putc, 0 );
31 | }
32 |
33 | #else
34 | #error This example is only for use on Arduino.
35 | #endif // ARDUINO
36 |
37 | #endif // __PRINTF_H__
38 |
--------------------------------------------------------------------------------
/Arduino Code/RF24-master/examples/pingpair_irq/Jamfile:
--------------------------------------------------------------------------------
1 | # (1) Project Information
2 |
3 | PROJECT_LIBS = SPI RF24 ;
4 | PROJECT_DIRS = $(PWD) ;
5 |
6 | # (2) Board Information
7 |
8 | UPLOAD_PROTOCOL ?= arduino ;
9 | UPLOAD_SPEED ?= 115200 ;
10 | MCU ?= atmega328p ;
11 | F_CPU ?= 16000000 ;
12 | CORE ?= arduino ;
13 | VARIANT ?= standard ;
14 | ARDUINO_VERSION ?= 100 ;
15 |
16 | # (3) USB Ports
17 |
18 | PORTS = p4 p6 p9 u0 u1 u2 ;
19 | PORT_p6 = /dev/tty.usbserial-A600eHIs ;
20 | PORT_p4 = /dev/tty.usbserial-A40081RP ;
21 | PORT_p9 = /dev/tty.usbserial-A9007LmI ;
22 | PORT_u0 = /dev/ttyUSB0 ;
23 | PORT_u1 = /dev/ttyUSB1 ;
24 | PORT_u2 = /dev/ttyUSB2 ;
25 |
26 | # (4) Location of AVR tools
27 | #
28 | # This configuration assumes using avr-tools that were obtained separate from the Arduino
29 | # distribution.
30 |
31 | if $(OS) = MACOSX
32 | {
33 | AVR_BIN ?= /usr/local/avrtools/bin ;
34 | AVR_ETC = /usr/local/avrtools/etc ;
35 | AVR_INCLUDE = /usr/local/avrtools/include ;
36 | }
37 | else
38 | {
39 | AVR_BIN ?= /usr/bin ;
40 | AVR_INCLUDE ?= /usr/lib/avr/include ;
41 | AVR_ETC = /etc ;
42 | }
43 |
44 | # (5) Directories where Arduino core and libraries are located
45 |
46 | ARDUINO_DIR ?= /opt/Arduino ;
47 | ARDUINO_CORE = $(ARDUINO_DIR)/hardware/arduino/cores/$(CORE) $(ARDUINO_DIR)/hardware/arduino/variants/$(VARIANT) ;
48 | ARDUINO_LIB = $(ARDUINO_DIR)/libraries ;
49 | SKETCH_LIB = $(HOME)/Source/Arduino/libraries ;
50 |
51 | #
52 | # --------------------------------------------------
53 | # Below this line usually never needs to be modified
54 | #
55 |
56 | # Tool locations
57 |
58 | CC = $(AVR_BIN)/avr-gcc ;
59 | C++ = $(AVR_BIN)/avr-g++ ;
60 | LINK = $(AVR_BIN)/avr-gcc ;
61 | AR = $(AVR_BIN)/avr-ar rcs ;
62 | RANLIB = ;
63 | OBJCOPY = $(AVR_BIN)/avr-objcopy ;
64 | AVRDUDE ?= $(AVR_BIN)/avrdude ;
65 |
66 | # Flags
67 |
68 | DEFINES += F_CPU=$(F_CPU)L ARDUINO=$(ARDUINO_VERSION) VERSION_H ;
69 | OPTIM = -Os ;
70 | CCFLAGS = -Wall -Wextra -Wno-strict-aliasing -mmcu=$(MCU) -ffunction-sections -fdata-sections ;
71 | C++FLAGS = $(CCFLAGS) -fno-exceptions -fno-strict-aliasing ;
72 | LINKFLAGS = $(OPTIM) -lm -Wl,--gc-sections -mmcu=$(MCU) ;
73 | AVRDUDEFLAGS = -V -F -D -C $(AVR_ETC)/avrdude.conf -p $(MCU) -c $(UPLOAD_PROTOCOL) -b $(UPLOAD_SPEED) ;
74 |
75 | # Search everywhere for headers
76 |
77 | HDRS = $(PROJECT_DIRS) $(AVR_INCLUDE) $(ARDUINO_CORE) $(ARDUINO_LIB)/$(PROJECT_LIBS) $(ARDUINO_LIB)/$(PROJECT_LIBS)/utility $(SKETCH_LIB)/$(PROJECT_LIBS) ;
78 |
79 | # Output locations
80 |
81 | LOCATE_TARGET = $(F_CPU) ;
82 | LOCATE_SOURCE = $(F_CPU) ;
83 |
84 | #
85 | # Custom rules
86 | #
87 |
88 | rule GitVersion
89 | {
90 | Always $(<) ;
91 | Depends all : $(<) ;
92 | }
93 |
94 | actions GitVersion
95 | {
96 | echo "const char program_version[] = \"\\" > $(<)
97 | git log -1 --pretty=format:%h >> $(<)
98 | echo "\";" >> $(<)
99 | }
100 |
101 | GitVersion version.h ;
102 |
103 | rule Pde
104 | {
105 | Depends $(<) : $(>) ;
106 | MakeLocate $(<) : $(LOCATE_SOURCE) ;
107 | Clean clean : $(<) ;
108 | }
109 |
110 | if ( $(ARDUINO_VERSION) < 100 )
111 | {
112 | ARDUINO_H = WProgram.h ;
113 | }
114 | else
115 | {
116 | ARDUINO_H = Arduino.h ;
117 | }
118 |
119 | actions Pde
120 | {
121 | echo "#include <$(ARDUINO_H)>" > $(<)
122 | echo "#line 1 \"$(>)\"" >> $(<)
123 | cat $(>) >> $(<)
124 | }
125 |
126 | rule C++Pde
127 | {
128 | local _CPP = $(>:B).cpp ;
129 | Pde $(_CPP) : $(>) ;
130 | C++ $(<) : $(_CPP) ;
131 | }
132 |
133 | rule UserObject
134 | {
135 | switch $(>:S)
136 | {
137 | case .ino : C++Pde $(<) : $(>) ;
138 | case .pde : C++Pde $(<) : $(>) ;
139 | }
140 | }
141 |
142 | rule Objects
143 | {
144 | local _i ;
145 |
146 | for _i in [ FGristFiles $(<) ]
147 | {
148 | local _b = $(_i:B)$(SUFOBJ) ;
149 | local _o = $(_b:G=$(SOURCE_GRIST:E)) ;
150 | Object $(_o) : $(_i) ;
151 | Depends obj : $(_o) ;
152 | }
153 | }
154 |
155 | rule Library
156 | {
157 | LibraryFromObjects $(<) : $(>:B)$(SUFOBJ) ;
158 | Objects $(>) ;
159 | }
160 |
161 | rule Main
162 | {
163 | MainFromObjects $(<) : $(>:B)$(SUFOBJ) ;
164 | Objects $(>) ;
165 | }
166 |
167 | rule Hex
168 | {
169 | Depends $(<) : $(>) ;
170 | MakeLocate $(<) : $(LOCATE_TARGET) ;
171 | Depends hex : $(<) ;
172 | Clean clean : $(<) ;
173 | }
174 |
175 | actions Hex
176 | {
177 | $(OBJCOPY) -O ihex -R .eeprom $(>) $(<)
178 | }
179 |
180 | rule Upload
181 | {
182 | Depends $(1) : $(2) ;
183 | Depends $(2) : $(3) ;
184 | NotFile $(1) ;
185 | Always $(1) ;
186 | Always $(2) ;
187 | UploadAction $(2) : $(3) ;
188 | }
189 |
190 | actions UploadAction
191 | {
192 | $(AVRDUDE) $(AVRDUDEFLAGS) -P $(<) $(AVRDUDE_WRITE_FLASH) -U flash:w:$(>):i
193 | }
194 |
195 | rule Arduino
196 | {
197 | LINKFLAGS on $(<) = $(LINKFLAGS) -Wl,-Map=$(LOCATE_TARGET)/$(<:B).map ;
198 | Main $(<) : $(>) ;
199 | LinkLibraries $(<) : core libs ;
200 | Hex $(<:B).hex : $(<) ;
201 | for _p in $(PORTS)
202 | {
203 | Upload $(_p) : $(PORT_$(_p)) : $(<:B).hex ;
204 | }
205 | }
206 |
207 | #
208 | # Targets
209 | #
210 |
211 | # Grab everything from the core directory
212 | Library core : [ GLOB $(ARDUINO_CORE) : *.c *.cpp ] ;
213 |
214 | # Grab everything from libraries. To avoid this "grab everything" behaviour, you
215 | # can specify specific modules to pick up in PROJECT_MODULES
216 | Library libs : [ GLOB $(ARDUINO_LIB)/$(PROJECT_LIBS) $(ARDUINO_LIB)/$(PROJECT_LIBS)/utility $(SKETCH_LIB)/$(PROJECT_LIBS) : *.cpp *.c ] ;
217 |
218 | # Main output executable
219 | Arduino $(PWD:B).elf : $(PROJECT_MODULES) [ GLOB $(PROJECT_DIRS) : *.c *.cpp *.pde *.ino ] ;
220 |
--------------------------------------------------------------------------------
/Arduino Code/RF24-master/examples/pingpair_irq/pingpair_irq.pde:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2011 J. Coliz
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 | * Example of using interrupts
11 | *
12 | * This is an example of how to user interrupts to interact with the radio.
13 | * It builds on the pingpair_pl example, and uses ack payloads.
14 | */
15 |
16 | #include
17 | #include "nRF24L01.h"
18 | #include "RF24.h"
19 | #include "printf.h"
20 |
21 | //
22 | // Hardware configuration
23 | //
24 |
25 | // Set up nRF24L01 radio on SPI bus plus pins 9 & 10
26 |
27 | RF24 radio(8,9);
28 |
29 | // sets the role of this unit in hardware. Connect to GND to be the 'pong' receiver
30 | // Leave open to be the 'ping' transmitter
31 | const short role_pin = 7;
32 |
33 | //
34 | // Topology
35 | //
36 |
37 | // Single radio pipe address for the 2 nodes to communicate.
38 | const uint64_t pipe = 0xE8E8F0F0E1LL;
39 |
40 | //
41 | // Role management
42 | //
43 | // Set up role. This sketch uses the same software for all the nodes in this
44 | // system. Doing so greatly simplifies testing. The hardware itself specifies
45 | // which node it is.
46 | //
47 | // This is done through the role_pin
48 | //
49 |
50 | // The various roles supported by this sketch
51 | typedef enum { role_sender = 1, role_receiver } role_e;
52 |
53 | // The debug-friendly names of those roles
54 | const char* role_friendly_name[] = { "invalid", "Sender", "Receiver"};
55 |
56 | // The role of the current running sketch
57 | role_e role;
58 |
59 | // Interrupt handler, check the radio because we got an IRQ
60 | void check_radio(void);
61 |
62 | void setup(void)
63 | {
64 | //
65 | // Role
66 | //
67 |
68 | // set up the role pin
69 | pinMode(role_pin, INPUT);
70 | digitalWrite(role_pin,HIGH);
71 | delay(20); // Just to get a solid reading on the role pin
72 |
73 | // read the address pin, establish our role
74 | if ( digitalRead(role_pin) )
75 | role = role_sender;
76 | else
77 | role = role_receiver;
78 |
79 | //
80 | // Print preamble
81 | //
82 |
83 | Serial.begin(57600);
84 | printf_begin();
85 | printf("\n\rRF24/examples/pingpair_irq/\n\r");
86 | printf("ROLE: %s\n\r",role_friendly_name[role]);
87 |
88 | //
89 | // Setup and configure rf radio
90 | //
91 |
92 | radio.begin();
93 |
94 | // We will be using the Ack Payload feature, so please enable it
95 | radio.enableAckPayload();
96 |
97 | //
98 | // Open pipes to other nodes for communication
99 | //
100 |
101 | // This simple sketch opens a single pipe for these two nodes to communicate
102 | // back and forth. One listens on it, the other talks to it.
103 |
104 | if ( role == role_sender )
105 | {
106 | radio.openWritingPipe(pipe);
107 | }
108 | else
109 | {
110 | radio.openReadingPipe(1,pipe);
111 | }
112 |
113 | //
114 | // Start listening
115 | //
116 |
117 | if ( role == role_receiver )
118 | radio.startListening();
119 |
120 | //
121 | // Dump the configuration of the rf unit for debugging
122 | //
123 |
124 | radio.printDetails();
125 |
126 | //
127 | // Attach interrupt handler to interrupt #0 (using pin 2)
128 | // on BOTH the sender and receiver
129 | //
130 |
131 | attachInterrupt(0, check_radio, FALLING);
132 | }
133 |
134 | static uint32_t message_count = 0;
135 |
136 | void loop(void)
137 | {
138 | //
139 | // Sender role. Repeatedly send the current time
140 | //
141 |
142 | if (role == role_sender)
143 | {
144 | // Take the time, and send it.
145 | unsigned long time = millis();
146 | printf("Now sending %lu\n\r",time);
147 | radio.startWrite( &time, sizeof(unsigned long) );
148 |
149 | // Try again soon
150 | delay(2000);
151 | }
152 |
153 | //
154 | // Receiver role: Does nothing! All the work is in IRQ
155 | //
156 |
157 | }
158 |
159 | void check_radio(void)
160 | {
161 | // What happened?
162 | bool tx,fail,rx;
163 | radio.whatHappened(tx,fail,rx);
164 |
165 | // Have we successfully transmitted?
166 | if ( tx )
167 | {
168 | if ( role == role_sender )
169 | printf("Send:OK\n\r");
170 |
171 | if ( role == role_receiver )
172 | printf("Ack Payload:Sent\n\r");
173 | }
174 |
175 | // Have we failed to transmit?
176 | if ( fail )
177 | {
178 | if ( role == role_sender )
179 | printf("Send:Failed\n\r");
180 |
181 | if ( role == role_receiver )
182 | printf("Ack Payload:Failed\n\r");
183 | }
184 |
185 | // Transmitter can power down for now, because
186 | // the transmission is done.
187 | if ( ( tx || fail ) && ( role == role_sender ) )
188 | radio.powerDown();
189 |
190 | // Did we receive a message?
191 | if ( rx )
192 | {
193 | // If we're the sender, we've received an ack payload
194 | if ( role == role_sender )
195 | {
196 | radio.read(&message_count,sizeof(message_count));
197 | printf("Ack:%lu\n\r",message_count);
198 | }
199 |
200 | // If we're the receiver, we've received a time message
201 | if ( role == role_receiver )
202 | {
203 | // Get this payload and dump it
204 | static unsigned long got_time;
205 | radio.read( &got_time, sizeof(got_time) );
206 | printf("Got payload %lu\n\r",got_time);
207 |
208 | // Add an ack packet for the next time around. This is a simple
209 | // packet counter
210 | radio.writeAckPayload( 1, &message_count, sizeof(message_count) );
211 | ++message_count;
212 | }
213 | }
214 | }
215 |
216 | // vim:ai:cin:sts=2 sw=2 ft=cpp
217 |
--------------------------------------------------------------------------------
/Arduino Code/RF24-master/examples/pingpair_irq/printf.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2011 J. Coliz
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 printf.h
11 | *
12 | * Setup necessary to direct stdout to the Arduino Serial library, which
13 | * enables 'printf'
14 | */
15 |
16 | #ifndef __PRINTF_H__
17 | #define __PRINTF_H__
18 |
19 | #ifdef ARDUINO
20 |
21 | int serial_putc( char c, FILE * )
22 | {
23 | Serial.write( c );
24 |
25 | return c;
26 | }
27 |
28 | void printf_begin(void)
29 | {
30 | fdevopen( &serial_putc, 0 );
31 | }
32 |
33 | #else
34 | #error This example is only for use on Arduino.
35 | #endif // ARDUINO
36 |
37 | #endif // __PRINTF_H__
38 |
--------------------------------------------------------------------------------
/Arduino Code/RF24-master/examples/pingpair_maple/Jamfile:
--------------------------------------------------------------------------------
1 | MCU = cortex-m3 ;
2 | CHIP = STM32F103ZE ;
3 | BOARD = maple_native ;
4 |
5 | #CHIP = at91sam3u4 ;
6 | #BOARD = sam3u-ek ;
7 |
8 | if ! $(TOOLSET)
9 | {
10 | TOOLSET = devkit ;
11 | Echo "Assuming TOOLSET=devkit" ;
12 | }
13 |
14 | if $(TOOLSET) = yagarto
15 | {
16 | TOOLS_PATH = ~/Source/yagarto-4.6.2/bin ;
17 | TOOLS_ARCH = arm-none-eabi- ;
18 | }
19 | if $(TOOLSET) = yagarto-install
20 | {
21 | TOOLS_PATH = ~/Source/yagarto/install/bin ;
22 | TOOLS_ARCH = arm-none-eabi- ;
23 | }
24 | else if $(TOOLSET) = devkit
25 | {
26 | TOOLS_PATH = /opt/devkitARM/bin ;
27 | TOOLS_ARCH = arm-eabi- ;
28 | }
29 | else if $(TOOLSET) = maple
30 | {
31 | TOOLS_PATH = /opt/Maple/Resources/Java/hardware/tools/arm/bin ;
32 | TOOLS_ARCH = arm-none-eabi- ;
33 | }
34 | else if $(TOOLSET) = ports
35 | {
36 | TOOLS_PATH = /opt/local/bin ;
37 | TOOLS_ARCH = arm-none-eabi- ;
38 | }
39 |
40 | CC = $(TOOLS_PATH)/$(TOOLS_ARCH)gcc ;
41 | C++ = $(TOOLS_PATH)/$(TOOLS_ARCH)g++ ;
42 | AS = $(TOOLS_PATH)/$(TOOLS_ARCH)gcc -c ;
43 | LINK = $(TOOLS_PATH)/$(TOOLS_ARCH)g++ ;
44 | OBJCOPY = $(TOOLS_PATH)/$(TOOLS_ARCH)objcopy ;
45 | DFU = dfu-util ;
46 |
47 | DEFINES += VECT_TAB_FLASH BOARD_$(BOARD) MCU_$(CHIP) ERROR_LED_PORT=GPIOC ERROR_LED_PIN=15 STM32_HIGH_DENSITY MAPLE_IDE ;
48 | OPTIM = -Os ;
49 | MFLAGS = cpu=$(MCU) thumb arch=armv7-m ;
50 | CCFLAGS = -Wall -m$(MFLAGS) -g -nostdlib -ffunction-sections -fdata-sections -Wl,--gc-sections ;
51 | C++FLAGS = $(CCFLAGS) -fno-rtti -fno-exceptions ;
52 | LINKFLAGS += -m$(MFLAGS) -Xlinker --gc-sections ;
53 | DFUFLAGS = -a1 -d 0x1eaf:0x0003 -R ;
54 |
55 | MAPLE_DIR = $(HOME)/Source/SAM3U/libmaple ;
56 | MAPLE_LIBS = Servo LiquidCrystal Wire FreeRTOS ;
57 | MAPLE_SUBDIRS = wirish wirish/comm wirish/boards libmaple libmaple/usb libmaple/usb/usb_lib ;
58 |
59 | SKETCH_DIR = $(HOME)/Source/Arduino ;
60 | SKETCH_LIBS = RF24 ;
61 |
62 | MODULE_DIRS = . $(MAPLE_DIR)/$(MAPLE_SUBDIRS) $(MAPLE_DIR)/libraries/$(MAPLE_LIBS) $(SKETCH_DIR)/libraries/$(SKETCH_LIBS) ;
63 | HDRS = $(MODULE_DIRS) ;
64 | LOCATE_TARGET = out/$(TOOLSET) ;
65 | LOCATE_SOURCE = $(LOCATE_TARGET) ;
66 |
67 | rule Pde
68 | {
69 | Depends $(<) : $(>) ;
70 | MakeLocate $(<) : $(LOCATE_SOURCE) ;
71 | Clean clean : $(<) ;
72 | }
73 |
74 | if ( $(ARDUINO_VERSION) < 100 )
75 | {
76 | ARDUINO_H = WProgram.h ;
77 | }
78 | else
79 | {
80 | ARDUINO_H = Arduino.h ;
81 | }
82 |
83 | actions Pde
84 | {
85 | echo "#include <$(ARDUINO_H)>" > $(<)
86 | echo "#line 1 \"$(>)\"" >> $(<)
87 | cat $(>) >> $(<)
88 | }
89 |
90 | rule C++Pde
91 | {
92 | local _CPP = $(>:B).cpp ;
93 | Pde $(_CPP) : $(>) ;
94 | C++ $(<) : $(_CPP) ;
95 | }
96 |
97 | rule Hex
98 | {
99 | Depends $(<) : $(>) ;
100 | MakeLocate $(<) : $(LOCATE_TARGET) ;
101 | Depends hex : $(<) ;
102 | Clean clean : $(<) ;
103 | }
104 |
105 | actions Hex
106 | {
107 | $(OBJCOPY) -O ihex $(>) $(<)
108 | }
109 |
110 | rule Binary
111 | {
112 | Depends $(<) : $(>) ;
113 | MakeLocate $(<) : $(LOCATE_TARGET) ;
114 | Depends binary : $(<) ;
115 | Clean clean : $(<) ;
116 | }
117 |
118 | actions Binary
119 | {
120 | $(OBJCOPY) -O binary $(>) $(<)
121 | }
122 |
123 | rule UserObject
124 | {
125 | switch $(>:S)
126 | {
127 | case .S : As $(<) : $(>) ;
128 | case .ino : C++Pde $(<) : $(>) ;
129 | case .pde : C++Pde $(<) : $(>) ;
130 | }
131 | }
132 |
133 | rule Upload
134 | {
135 | Depends up : $(<) ;
136 | NotFile up ;
137 | Always $(<) ;
138 | Always up ;
139 | }
140 |
141 | actions Upload
142 | {
143 | $(DFU) $(DFUFLAGS) -D $(<)
144 | }
145 |
146 | # Override base objects rule, so all output can go in the output dir
147 | rule Objects
148 | {
149 | local _i ;
150 |
151 | for _i in [ FGristFiles $(<) ]
152 | {
153 | local _b = $(_i:B)$(SUFOBJ) ;
154 | local _o = $(_b:G=$(SOURCE_GRIST:E)) ;
155 | Object $(_o) : $(_i) ;
156 | Depends obj : $(_o) ;
157 | }
158 | }
159 |
160 | # Override base main rule, so all output can go in the output dir
161 | rule Main
162 | {
163 | MainFromObjects $(<) : $(>:B)$(SUFOBJ) ;
164 | Objects $(>) ;
165 | }
166 |
167 | # Modules
168 | MODULES = [ GLOB $(MODULE_DIRS) : *.pde *.c *.cpp *.S ] ;
169 |
170 | # Main output executable
171 | MAIN = $(PWD:B).elf ;
172 |
173 | # Linker script
174 | LINK_DIR = $(MAPLE_DIR)/support/ld ;
175 | LINKSCRIPT = $(LINK_DIR)/$(BOARD)/flash.ld ;
176 |
177 | # Bring in the map and link script
178 | LINKFLAGS += -Wl,-Map=$(LOCATE_TARGET)/$(MAIN:B).map -T$(LINKSCRIPT) -L$(LINK_DIR) ;
179 |
180 | Main $(MAIN) : $(MODULES) ;
181 | Binary $(MAIN:B).bin : $(MAIN) ;
182 | Upload $(MAIN:B).bin ;
183 |
--------------------------------------------------------------------------------
/Arduino Code/RF24-master/examples/pingpair_maple/main.cpp:
--------------------------------------------------------------------------------
1 | #ifdef MAPLE_IDE
2 |
3 | #include
4 | #include "wirish.h"
5 |
6 | extern void setup(void);
7 | extern void loop(void);
8 |
9 | void board_start(const char* program_name)
10 | {
11 | // Set up the LED to steady on
12 | pinMode(BOARD_LED_PIN, OUTPUT);
13 | digitalWrite(BOARD_LED_PIN, HIGH);
14 |
15 | // Setup the button as input
16 | pinMode(BOARD_BUTTON_PIN, INPUT);
17 | digitalWrite(BOARD_BUTTON_PIN, HIGH);
18 |
19 | SerialUSB.begin();
20 | SerialUSB.println("Press BUT");
21 |
22 | // Wait for button press
23 | while ( !isButtonPressed() )
24 | {
25 | }
26 |
27 | SerialUSB.println("Welcome!");
28 | SerialUSB.println(program_name);
29 |
30 | int i = 11;
31 | while (i--)
32 | {
33 | toggleLED();
34 | delay(50);
35 | }
36 | }
37 |
38 | /**
39 | * Custom version of _write, which will print to the USB.
40 | * In order to use it you MUST ADD __attribute__((weak))
41 | * to _write in libmaple/syscalls.c
42 | */
43 | extern "C" int _write (int file, char * ptr, int len)
44 | {
45 | if ( (file != 1) && (file != 2) )
46 | return 0;
47 | else
48 | SerialUSB.write(ptr,len);
49 | return len;
50 | }
51 |
52 | /**
53 | * Re-entrant version of _write. Yagarto and Devkit now use
54 | * the re-entrant newlib, so these get called instead of the
55 | * non_r versions.
56 | */
57 | extern "C" int _write_r (void*, int file, char * ptr, int len)
58 | {
59 | return _write( file, ptr, len);
60 | }
61 |
62 | __attribute__((constructor)) __attribute__ ((weak)) void premain()
63 | {
64 | init();
65 | }
66 |
67 | __attribute__((weak)) void setup(void)
68 | {
69 | board_start("No program defined");
70 | }
71 |
72 | __attribute__((weak)) void loop(void)
73 | {
74 | }
75 |
76 | __attribute__((weak)) int main(void)
77 | {
78 | setup();
79 |
80 | while (true)
81 | {
82 | loop();
83 | }
84 | return 0;
85 | }
86 | #endif // ifdef MAPLE_IDE
87 | // vim:cin:ai:sts=2 sw=2 ft=cpp
88 |
--------------------------------------------------------------------------------
/Arduino Code/RF24-master/examples/pingpair_maple/pingpair_maple.pde:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2011 J. Coliz
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 | * Example RF Radio Ping Pair ... for Maple
11 | *
12 | * This is an example of how to use the RF24 class. Write this sketch to two different nodes,
13 | * connect the role_pin to ground on one. The ping node sends the current time to the pong node,
14 | * which responds by sending the value back. The ping node can then see how long the whole cycle
15 | * took.
16 | */
17 |
18 | #include "WProgram.h"
19 | #include
20 | #include "nRF24L01.h"
21 | #include "RF24.h"
22 |
23 | //
24 | // Maple specific setup. Other than this section, the sketch is the same on Maple as on
25 | // Arduino
26 | //
27 |
28 | #ifdef MAPLE_IDE
29 |
30 | // External startup function
31 | extern void board_start(const char* program_name);
32 |
33 | // Use SPI #2.
34 | HardwareSPI SPI(2);
35 |
36 | #else
37 | #define board_startup printf
38 | #define toggleLED(x) (x)
39 | #endif
40 |
41 | //
42 | // Hardware configuration
43 | //
44 |
45 | // Set up nRF24L01 radio on SPI bus plus pins 7 & 6
46 | // (This works for the Getting Started board plugged into the
47 | // Maple Native backwards.)
48 |
49 | RF24 radio(7,6);
50 |
51 | // sets the role of this unit in hardware. Connect to GND to be the 'pong' receiver
52 | // Leave open to be the 'ping' transmitter
53 | const int role_pin = 10;
54 |
55 | //
56 | // Topology
57 | //
58 |
59 | // Radio pipe addresses for the 2 nodes to communicate.
60 | const uint64_t pipes[2] = { 0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL };
61 |
62 | //
63 | // Role management
64 | //
65 | // Set up role. This sketch uses the same software for all the nodes
66 | // in this system. Doing so greatly simplifies testing. The hardware itself specifies
67 | // which node it is.
68 | //
69 | // This is done through the role_pin
70 | //
71 |
72 | // The various roles supported by this sketch
73 | typedef enum { role_ping_out = 1, role_pong_back } role_e;
74 |
75 | // The debug-friendly names of those roles
76 | const char* role_friendly_name[] = { "invalid", "Ping out", "Pong back"};
77 |
78 | // The role of the current running sketch
79 | role_e role;
80 |
81 | void setup(void)
82 | {
83 | //
84 | // Role
85 | //
86 |
87 | // set up the role pin
88 | pinMode(role_pin, INPUT);
89 | digitalWrite(role_pin,HIGH);
90 | delay(20); // Just to get a solid reading on the role pin
91 |
92 | // read the address pin, establish our role
93 | if ( digitalRead(role_pin) )
94 | role = role_ping_out;
95 | else
96 | role = role_pong_back;
97 |
98 | //
99 | // Print preamble
100 | //
101 |
102 | board_start("\n\rRF24/examples/pingpair/\n\r");
103 | printf("ROLE: %s\n\r",role_friendly_name[role]);
104 |
105 | //
106 | // Setup and configure rf radio
107 | //
108 |
109 | radio.begin();
110 |
111 | // optionally, increase the delay between retries & # of retries
112 | radio.setRetries(15,15);
113 |
114 | // optionally, reduce the payload size. seems to
115 | // improve reliability
116 | radio.setPayloadSize(8);
117 |
118 | //
119 | // Open pipes to other nodes for communication
120 | //
121 |
122 | // This simple sketch opens two pipes for these two nodes to communicate
123 | // back and forth.
124 | // Open 'our' pipe for writing
125 | // Open the 'other' pipe for reading, in position #1 (we can have up to 5 pipes open for reading)
126 |
127 | if ( role == role_ping_out )
128 | {
129 | radio.openWritingPipe(pipes[0]);
130 | radio.openReadingPipe(1,pipes[1]);
131 | }
132 | else
133 | {
134 | radio.openWritingPipe(pipes[1]);
135 | radio.openReadingPipe(1,pipes[0]);
136 | }
137 |
138 | //
139 | // Start listening
140 | //
141 |
142 | radio.startListening();
143 |
144 | //
145 | // Dump the configuration of the rf unit for debugging
146 | //
147 |
148 | radio.printDetails();
149 | }
150 |
151 | void loop(void)
152 | {
153 | //
154 | // Ping out role. Repeatedly send the current time
155 | //
156 |
157 | if (role == role_ping_out)
158 | {
159 | toggleLED();
160 |
161 | // First, stop listening so we can talk.
162 | radio.stopListening();
163 |
164 | // Take the time, and send it. This will block until complete
165 | unsigned long time = millis();
166 | printf("Now sending %lu...",time);
167 | bool ok = radio.write( &time, sizeof(unsigned long) );
168 |
169 | if (ok)
170 | printf("ok...\r\n");
171 | else
172 | printf("failed.\r\n");
173 |
174 | // Now, continue listening
175 | radio.startListening();
176 |
177 | // Wait here until we get a response, or timeout (250ms)
178 | unsigned long started_waiting_at = millis();
179 | bool timeout = false;
180 | while ( ! radio.available() && ! timeout )
181 | if (millis() - started_waiting_at > 200 )
182 | timeout = true;
183 |
184 | // Describe the results
185 | if ( timeout )
186 | {
187 | printf("Failed, response timed out.\r\n");
188 | }
189 | else
190 | {
191 | // Grab the response, compare, and send to debugging spew
192 | unsigned long got_time;
193 | radio.read( &got_time, sizeof(unsigned long) );
194 |
195 | // Spew it
196 | printf("Got response %lu, round-trip delay: %lu\r\n",got_time,millis()-got_time);
197 | }
198 |
199 | toggleLED();
200 |
201 | // Try again 1s later
202 | delay(1000);
203 | }
204 |
205 | //
206 | // Pong back role. Receive each packet, dump it out, and send it back
207 | //
208 |
209 | if ( role == role_pong_back )
210 | {
211 | // if there is data ready
212 | if ( radio.available() )
213 | {
214 | // Dump the payloads until we've gotten everything
215 | unsigned long got_time;
216 | bool done = false;
217 | while (!done)
218 | {
219 | // Fetch the payload, and see if this was the last one.
220 | done = radio.read( &got_time, sizeof(unsigned long) );
221 |
222 | // Spew it
223 | printf("Got payload %lu...",got_time);
224 |
225 | // Delay just a little bit to let the other unit
226 | // make the transition to receiver
227 | delay(20);
228 | }
229 |
230 | // First, stop listening so we can talk
231 | radio.stopListening();
232 |
233 | // Send the final one back.
234 | radio.write( &got_time, sizeof(unsigned long) );
235 | printf("Sent response.\r\n");
236 |
237 | // Now, resume listening so we catch the next packets.
238 | radio.startListening();
239 | }
240 | }
241 | }
242 | // vim:cin:ai:sts=2 sw=2 ft=cpp
243 |
--------------------------------------------------------------------------------
/Arduino Code/RF24-master/examples/pingpair_pl/Jamfile:
--------------------------------------------------------------------------------
1 | PROJECT_NAME = $(PWD:B) ;
2 | PROJECT_DIR = . ;
3 | PROJECT_LIBS = SPI RF24 ;
4 |
5 | OUT_DIR = ojam ;
6 | F_CPU = 16000000 ;
7 | MCU = atmega328p ;
8 | PORTS = /dev/tty.usbserial-A600eHIs /dev/tty.usbserial-A40081RP /dev/tty.usbserial-A9007LmI ;
9 |
10 | UPLOAD_RATE = 57600 ;
11 | AVRDUDE_PROTOCOL = stk500v1 ;
12 | COM = 33 ;
13 |
14 | # Host-specific overrides for locations
15 | if $(OS) = MACOSX
16 | {
17 | ARDUINO_VERSION = 22 ;
18 | OLD_DIR = /opt/arduino-0021 ;
19 | AVR_TOOLS_PATH = $(OLD_DIR)/hardware/tools/avr/bin ;
20 | AVRDUDECONFIG_PATH = $(OLD_DIR)/hardware/tools/avr/etc ;
21 | ARDUINO_DIR = /opt/Arduino ;
22 | ARDUINO_AVR = /usr/lib/avr/include ;
23 | }
24 |
25 | # Where is everything?
26 | ARDUINO_VERSION ?= 22 ;
27 | AVR_TOOLS_PATH ?= /usr/bin ;
28 | ARDUINO_DIR ?= /opt/arduino-00$(ARDUINO_VERSION) ;
29 | ARDUINO_AVR ?= $(ARDUINO_DIR)/hardware/tools/avr/avr/include/avr ;
30 | AVRDUDECONFIG_PATH ?= $(ARDUINO_DIR)/hardware/tools ;
31 | ARDUINO_CORE = $(ARDUINO_DIR)/hardware/arduino/cores/arduino ;
32 | ARDUINO_LIB = $(ARDUINO_DIR)/libraries ;
33 | SKETCH_LIB = $(HOME)/Source/Arduino/libraries ;
34 | AVR_CC = $(AVR_TOOLS_PATH)/avr-gcc ;
35 | AVR_CXX = $(AVR_TOOLS_PATH)/avr-g++ ;
36 | AVR_LD = $(AVR_TOOLS_PATH)/avr-gcc ;
37 | AVR_OBJCOPY = $(AVR_TOOLS_PATH)/avr-objcopy ;
38 | AVRDUDE = $(AVR_TOOLS_PATH)/avrdude ;
39 |
40 | DEFINES = F_CPU=$(F_CPU)L ARDUINO=$(ARDUINO_VERSION) VERSION_H ;
41 | CTUNING = -ffunction-sections -fdata-sections ;
42 | CXXTUNING = -fno-exceptions -fno-strict-aliasing ;
43 | CFLAGS = -Os -Wall -Wextra -mmcu=$(MCU) $(CTUNING) ;
44 | CXXFLAGS = $(CFLAGS) $(CXXTUNING) ;
45 | LDFLAGS = -Os -lm -Wl,--gc-sections -mmcu=atmega328p ;
46 |
47 | # Search everywhere for headers
48 | HDRS = $(PROJECT_DIR) $(ARDUINO_AVR) $(ARDUINO_CORE) [ GLOB $(ARDUINO_LIB) $(SKETCH_LIB) : [^.]* ] ;
49 |
50 | # Grab everything from the core directory
51 | CORE_MODULES = [ GLOB $(ARDUINO_CORE) : *.c *.cpp ] ;
52 |
53 | # Grab everything from libraries. To avoid this "grab everything" behaviour, you
54 | # can specify specific modules to pick up in PROJECT_MODULES
55 | LIB_MODULES = [ GLOB $(ARDUINO_LIB)/$(PROJECT_LIBS) $(SKETCH_LIB)/$(PROJECT_LIBS) : *.cpp ] ;
56 |
57 | # In addition to explicitly-specified program modules, pick up anything from the current
58 | # dir.
59 | PROJECT_MODULES += [ GLOB $(PROJECT_DIR) : *.c *.cpp *.pde ] ;
60 |
61 | # Shortcut for the out files
62 | OUT = $(OUT_DIR)/$(PROJECT_NAME) ;
63 |
64 | # AvrDude setup
65 | AVRDUDE_FLAGS = -V -F -D -C $(AVRDUDECONFIG_PATH)/avrdude.conf -p $(MCU) -c $(AVRDUDE_PROTOCOL) -b $(UPLOAD_RATE) ;
66 |
67 | rule GitVersion
68 | {
69 | Always $(<) ;
70 | Depends all : $(<) ;
71 | }
72 |
73 | actions GitVersion
74 | {
75 | echo "const char program_version[] = \"\\" > $(<)
76 | git log -1 --pretty=format:%h >> $(<)
77 | echo "\";" >> $(<)
78 | }
79 |
80 | GitVersion version.h ;
81 |
82 | rule AvrCc
83 | {
84 | Depends $(<) : $(>) ;
85 | Depends $(<) : $(<:D) ;
86 | Clean clean : $(<) ;
87 |
88 | CCHDRS on $(<) = [ on $(<) FIncludes $(HDRS) ] ;
89 | CCDEFS on $(<) = [ on $(<) FDefines $(DEFINES) ] ;
90 | }
91 |
92 | actions AvrCc
93 | {
94 | $(AVR_CC) -c -o $(<) $(CCHDRS) $(CCDEFS) $(CFLAGS) $(>)
95 | }
96 |
97 | rule AvrC++
98 | {
99 | Depends $(<) : $(>) ;
100 | Depends $(<) : $(<:D) ;
101 | Clean clean : $(<) ;
102 |
103 | CCHDRS on $(<) = [ on $(<) FIncludes $(HDRS) ] ;
104 | CCDEFS on $(<) = [ on $(<) FDefines $(DEFINES) ] ;
105 | }
106 |
107 | actions AvrC++
108 | {
109 | $(AVR_CXX) -c -o $(<) $(CCHDRS) $(CCDEFS) $(CXXFLAGS) $(>)
110 | }
111 |
112 | rule Pde
113 | {
114 | Depends $(<) : $(>) ;
115 | Depends $(<) : $(<:D) ;
116 | Clean clean : $(<) ;
117 |
118 | }
119 |
120 | actions Pde
121 | {
122 | echo "#include " > $(<)
123 | echo "#line 1 \"$(>)\"" >> $(<)
124 | cat $(>) >> $(<)
125 | }
126 |
127 | rule AvrPde
128 | {
129 | local _CPP = $(OUT_DIR)/$(_I:B).cpp ;
130 | Pde $(_CPP) : $(>) ;
131 | AvrC++ $(<) : $(_CPP) ;
132 | }
133 |
134 | rule AvrObject
135 | {
136 | switch $(>:S)
137 | {
138 | case .c : AvrCc $(<) : $(>) ;
139 | case .cpp : AvrC++ $(<) : $(>) ;
140 | case .pde : AvrPde $(<) : $(>) ;
141 | }
142 | }
143 |
144 | rule AvrObjects
145 | {
146 | for _I in $(<)
147 | {
148 | AvrObject $(OUT_DIR)/$(_I:B).o : $(_I) ;
149 | }
150 | }
151 |
152 | rule AvrMainFromObjects
153 | {
154 | Depends $(<) : $(>) ;
155 | Depends $(<) : $(<:D) ;
156 | MkDir $(<:D) ;
157 | Depends all : $(<) ;
158 | Clean clean : $(<) ;
159 | }
160 |
161 | actions AvrMainFromObjects
162 | {
163 | $(AVR_LD) $(LDFLAGS) -o $(<) $(>)
164 | }
165 |
166 | rule AvrMain
167 | {
168 | AvrMainFromObjects $(<) : $(OUT_DIR)/$(>:B).o ;
169 | AvrObjects $(>) ;
170 | }
171 |
172 | rule AvrHex
173 | {
174 | Depends $(<) : $(>) ;
175 | Depends $(<) : $(<:D) ;
176 | Depends hex : $(<) ;
177 | Clean clean : $(<) ;
178 | }
179 |
180 | actions AvrHex
181 | {
182 | $(AVR_OBJCOPY) -O ihex -R .eeprom $(>) $(<)
183 | }
184 |
185 | rule AvrUpload
186 | {
187 | Depends $(1) : $(2) ;
188 | Depends $(2) : $(3) ;
189 | NotFile $(1) ;
190 | Always $(1) ;
191 | Always $(2) ;
192 | AvrUploadAction $(2) : $(3) ;
193 | }
194 |
195 | actions AvrUploadAction
196 | {
197 | $(AVRDUDE) $(AVRDUDE_FLAGS) -P $(<) $(AVRDUDE_WRITE_FLASH) -U flash:w:$(>):i
198 | }
199 |
200 | AvrMain $(OUT).elf : $(CORE_MODULES) $(LIB_MODULES) $(PROJECT_MODULES) ;
201 | AvrHex $(OUT).hex : $(OUT).elf ;
202 |
203 | AvrUpload p6 : /dev/tty.usbserial-A600eHIs : $(OUT).hex ;
204 | AvrUpload p4 : /dev/tty.usbserial-A40081RP : $(OUT).hex ;
205 | AvrUpload p9 : /dev/tty.usbserial-A9007LmI : $(OUT).hex ;
206 |
207 |
--------------------------------------------------------------------------------
/Arduino Code/RF24-master/examples/pingpair_pl/pingpair_pl.pde:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2011 J. Coliz
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 | * Example of using Ack Payloads
11 | *
12 | * This is an example of how to do two-way communication without changing
13 | * transmit/receive modes. Here, a payload is set to the transmitter within
14 | * the Ack packet of each transmission. Note that the payload is set BEFORE
15 | * the sender's message arrives.
16 | */
17 |
18 | #include
19 | #include "nRF24L01.h"
20 | #include "RF24.h"
21 | #include "printf.h"
22 |
23 | //
24 | // Hardware configuration
25 | //
26 |
27 | // Set up nRF24L01 radio on SPI bus plus pins 9 & 10
28 |
29 | RF24 radio(9,10);
30 |
31 | // sets the role of this unit in hardware. Connect to GND to be the 'pong' receiver
32 | // Leave open to be the 'ping' transmitter
33 | const short role_pin = 7;
34 |
35 | //
36 | // Topology
37 | //
38 |
39 | // Single radio pipe address for the 2 nodes to communicate.
40 | const uint64_t pipe = 0xE8E8F0F0E1LL;
41 |
42 | //
43 | // Role management
44 | //
45 | // Set up role. This sketch uses the same software for all the nodes in this
46 | // system. Doing so greatly simplifies testing. The hardware itself specifies
47 | // which node it is.
48 | //
49 | // This is done through the role_pin
50 | //
51 |
52 | // The various roles supported by this sketch
53 | typedef enum { role_sender = 1, role_receiver } role_e;
54 |
55 | // The debug-friendly names of those roles
56 | const char* role_friendly_name[] = { "invalid", "Sender", "Receiver"};
57 |
58 | // The role of the current running sketch
59 | role_e role;
60 |
61 | void setup(void)
62 | {
63 | //
64 | // Role
65 | //
66 |
67 | // set up the role pin
68 | pinMode(role_pin, INPUT);
69 | digitalWrite(role_pin,HIGH);
70 | delay(20); // Just to get a solid reading on the role pin
71 |
72 | // read the address pin, establish our role
73 | if ( digitalRead(role_pin) )
74 | role = role_sender;
75 | else
76 | role = role_receiver;
77 |
78 | //
79 | // Print preamble
80 | //
81 |
82 | Serial.begin(57600);
83 | printf_begin();
84 | printf("\n\rRF24/examples/pingpair_pl/\n\r");
85 | printf("ROLE: %s\n\r",role_friendly_name[role]);
86 |
87 | //
88 | // Setup and configure rf radio
89 | //
90 |
91 | radio.begin();
92 |
93 | // We will be using the Ack Payload feature, so please enable it
94 | radio.enableAckPayload();
95 |
96 | //
97 | // Open pipes to other nodes for communication
98 | //
99 |
100 | // This simple sketch opens a single pipes for these two nodes to communicate
101 | // back and forth. One listens on it, the other talks to it.
102 |
103 | if ( role == role_sender )
104 | {
105 | radio.openWritingPipe(pipe);
106 | }
107 | else
108 | {
109 | radio.openReadingPipe(1,pipe);
110 | }
111 |
112 | //
113 | // Start listening
114 | //
115 |
116 | if ( role == role_receiver )
117 | radio.startListening();
118 |
119 | //
120 | // Dump the configuration of the rf unit for debugging
121 | //
122 |
123 | radio.printDetails();
124 | }
125 |
126 | void loop(void)
127 | {
128 | static uint32_t message_count = 0;
129 |
130 | //
131 | // Sender role. Repeatedly send the current time
132 | //
133 |
134 | if (role == role_sender)
135 | {
136 | // Take the time, and send it. This will block until complete
137 | unsigned long time = millis();
138 | printf("Now sending %lu...",time);
139 | radio.write( &time, sizeof(unsigned long) );
140 |
141 | if ( radio.isAckPayloadAvailable() )
142 | {
143 | radio.read(&message_count,sizeof(message_count));
144 | printf("Ack: [%lu] ",message_count);
145 | }
146 | printf("OK\n\r");
147 |
148 | // Try again soon
149 | delay(2000);
150 | }
151 |
152 | //
153 | // Receiver role. Receive each packet, dump it out, add ack payload for next time
154 | //
155 |
156 | if ( role == role_receiver )
157 | {
158 | // if there is data ready
159 | if ( radio.available() )
160 | {
161 | // Dump the payloads until we've gotten everything
162 | static unsigned long got_time;
163 | bool done = false;
164 | while (!done)
165 | {
166 | // Fetch the payload, and see if this was the last one.
167 | done = radio.read( &got_time, sizeof(unsigned long) );
168 |
169 | // Spew it
170 | printf("Got payload %lu\n",got_time);
171 | }
172 |
173 | // Add an ack packet for the next time around. This is a simple
174 | // packet counter
175 | radio.writeAckPayload( 1, &message_count, sizeof(message_count) );
176 | ++message_count;
177 | }
178 | }
179 | }
180 | // vim:ai:cin:sts=2 sw=2 ft=cpp
181 |
--------------------------------------------------------------------------------
/Arduino Code/RF24-master/examples/pingpair_pl/printf.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2011 J. Coliz
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 printf.h
11 | *
12 | * Setup necessary to direct stdout to the Arduino Serial library, which
13 | * enables 'printf'
14 | */
15 |
16 | #ifndef __PRINTF_H__
17 | #define __PRINTF_H__
18 |
19 | #ifdef ARDUINO
20 |
21 | int serial_putc( char c, FILE * )
22 | {
23 | Serial.write( c );
24 |
25 | return c;
26 | }
27 |
28 | void printf_begin(void)
29 | {
30 | fdevopen( &serial_putc, 0 );
31 | }
32 |
33 | #else
34 | #error This example is only for use on Arduino.
35 | #endif // ARDUINO
36 |
37 | #endif // __PRINTF_H__
38 |
--------------------------------------------------------------------------------
/Arduino Code/RF24-master/examples/pingpair_sleepy/Jamfile:
--------------------------------------------------------------------------------
1 | PROJECT_NAME = $(PWD:B) ;
2 | PROJECT_DIR = . ;
3 | PROJECT_LIBS = SPI RF24 ;
4 |
5 | OUT_DIR = ojam ;
6 | F_CPU = 16000000 ;
7 | MCU = atmega328p ;
8 | PORTS = /dev/tty.usbserial-A600eHIs /dev/tty.usbserial-A40081RP /dev/tty.usbserial-A9007LmI ;
9 |
10 | UPLOAD_RATE = 57600 ;
11 | AVRDUDE_PROTOCOL = stk500v1 ;
12 | COM = 33 ;
13 |
14 | # Host-specific overrides for locations
15 | if $(OS) = MACOSX
16 | {
17 | ARDUINO_VERSION = 22 ;
18 | OLD_DIR = /opt/arduino-0021 ;
19 | AVR_TOOLS_PATH = $(OLD_DIR)/hardware/tools/avr/bin ;
20 | AVRDUDECONFIG_PATH = $(OLD_DIR)/hardware/tools/avr/etc ;
21 | ARDUINO_DIR = /opt/Arduino ;
22 | ARDUINO_AVR = /usr/lib/avr/include ;
23 | }
24 |
25 | # Where is everything?
26 | ARDUINO_VERSION ?= 22 ;
27 | AVR_TOOLS_PATH ?= /usr/bin ;
28 | ARDUINO_DIR ?= /opt/arduino-00$(ARDUINO_VERSION) ;
29 | ARDUINO_AVR ?= $(ARDUINO_DIR)/hardware/tools/avr/avr/include/avr ;
30 | AVRDUDECONFIG_PATH ?= $(ARDUINO_DIR)/hardware/tools ;
31 | ARDUINO_CORE = $(ARDUINO_DIR)/hardware/arduino/cores/arduino ;
32 | ARDUINO_LIB = $(ARDUINO_DIR)/libraries ;
33 | SKETCH_LIB = $(HOME)/Source/Arduino/libraries ;
34 | AVR_CC = $(AVR_TOOLS_PATH)/avr-gcc ;
35 | AVR_CXX = $(AVR_TOOLS_PATH)/avr-g++ ;
36 | AVR_LD = $(AVR_TOOLS_PATH)/avr-gcc ;
37 | AVR_OBJCOPY = $(AVR_TOOLS_PATH)/avr-objcopy ;
38 | AVRDUDE = $(AVR_TOOLS_PATH)/avrdude ;
39 |
40 | DEFINES = F_CPU=$(F_CPU)L ARDUINO=$(ARDUINO_VERSION) VERSION_H ;
41 | CTUNING = -ffunction-sections -fdata-sections ;
42 | CXXTUNING = -fno-exceptions -fno-strict-aliasing ;
43 | CFLAGS = -Os -Wall -Wextra -mmcu=$(MCU) $(CTUNING) ;
44 | CXXFLAGS = $(CFLAGS) $(CXXTUNING) ;
45 | LDFLAGS = -Os -lm -Wl,--gc-sections -mmcu=atmega328p ;
46 |
47 | # Search everywhere for headers
48 | HDRS = $(PROJECT_DIR) $(ARDUINO_AVR) $(ARDUINO_CORE) [ GLOB $(ARDUINO_LIB) $(SKETCH_LIB) : [^.]* ] ;
49 |
50 | # Grab everything from the core directory
51 | CORE_MODULES = [ GLOB $(ARDUINO_CORE) : *.c *.cpp ] ;
52 |
53 | # Grab everything from libraries. To avoid this "grab everything" behaviour, you
54 | # can specify specific modules to pick up in PROJECT_MODULES
55 | LIB_MODULES = [ GLOB $(ARDUINO_LIB)/$(PROJECT_LIBS) $(SKETCH_LIB)/$(PROJECT_LIBS) : *.cpp ] ;
56 |
57 | # In addition to explicitly-specified program modules, pick up anything from the current
58 | # dir.
59 | PROJECT_MODULES += [ GLOB $(PROJECT_DIR) : *.c *.cpp *.pde ] ;
60 |
61 | # Shortcut for the out files
62 | OUT = $(OUT_DIR)/$(PROJECT_NAME) ;
63 |
64 | # AvrDude setup
65 | AVRDUDE_FLAGS = -V -F -D -C $(AVRDUDECONFIG_PATH)/avrdude.conf -p $(MCU) -c $(AVRDUDE_PROTOCOL) -b $(UPLOAD_RATE) ;
66 |
67 | rule GitVersion
68 | {
69 | Always $(<) ;
70 | Depends all : $(<) ;
71 | }
72 |
73 | actions GitVersion
74 | {
75 | echo "const char program_version[] = \"\\" > $(<)
76 | git log -1 --pretty=format:%h >> $(<)
77 | echo "\";" >> $(<)
78 | }
79 |
80 | GitVersion version.h ;
81 |
82 | rule AvrCc
83 | {
84 | Depends $(<) : $(>) ;
85 | Depends $(<) : $(<:D) ;
86 | Clean clean : $(<) ;
87 |
88 | CCHDRS on $(<) = [ on $(<) FIncludes $(HDRS) ] ;
89 | CCDEFS on $(<) = [ on $(<) FDefines $(DEFINES) ] ;
90 | }
91 |
92 | actions AvrCc
93 | {
94 | $(AVR_CC) -c -o $(<) $(CCHDRS) $(CCDEFS) $(CFLAGS) $(>)
95 | }
96 |
97 | rule AvrC++
98 | {
99 | Depends $(<) : $(>) ;
100 | Depends $(<) : $(<:D) ;
101 | Clean clean : $(<) ;
102 |
103 | CCHDRS on $(<) = [ on $(<) FIncludes $(HDRS) ] ;
104 | CCDEFS on $(<) = [ on $(<) FDefines $(DEFINES) ] ;
105 | }
106 |
107 | actions AvrC++
108 | {
109 | $(AVR_CXX) -c -o $(<) $(CCHDRS) $(CCDEFS) $(CXXFLAGS) $(>)
110 | }
111 |
112 | rule Pde
113 | {
114 | Depends $(<) : $(>) ;
115 | Depends $(<) : $(<:D) ;
116 | Clean clean : $(<) ;
117 |
118 | }
119 |
120 | actions Pde
121 | {
122 | echo "#include " > $(<)
123 | echo "#line 1 \"$(>)\"" >> $(<)
124 | cat $(>) >> $(<)
125 | }
126 |
127 | rule AvrPde
128 | {
129 | local _CPP = $(OUT_DIR)/$(_I:B).cpp ;
130 | Pde $(_CPP) : $(>) ;
131 | AvrC++ $(<) : $(_CPP) ;
132 | }
133 |
134 | rule AvrObject
135 | {
136 | switch $(>:S)
137 | {
138 | case .c : AvrCc $(<) : $(>) ;
139 | case .cpp : AvrC++ $(<) : $(>) ;
140 | case .pde : AvrPde $(<) : $(>) ;
141 | }
142 | }
143 |
144 | rule AvrObjects
145 | {
146 | for _I in $(<)
147 | {
148 | AvrObject $(OUT_DIR)/$(_I:B).o : $(_I) ;
149 | }
150 | }
151 |
152 | rule AvrMainFromObjects
153 | {
154 | Depends $(<) : $(>) ;
155 | Depends $(<) : $(<:D) ;
156 | MkDir $(<:D) ;
157 | Depends all : $(<) ;
158 | Clean clean : $(<) ;
159 | }
160 |
161 | actions AvrMainFromObjects
162 | {
163 | $(AVR_LD) $(LDFLAGS) -o $(<) $(>)
164 | }
165 |
166 | rule AvrMain
167 | {
168 | AvrMainFromObjects $(<) : $(OUT_DIR)/$(>:B).o ;
169 | AvrObjects $(>) ;
170 | }
171 |
172 | rule AvrHex
173 | {
174 | Depends $(<) : $(>) ;
175 | Depends $(<) : $(<:D) ;
176 | Depends hex : $(<) ;
177 | Clean clean : $(<) ;
178 | }
179 |
180 | actions AvrHex
181 | {
182 | $(AVR_OBJCOPY) -O ihex -R .eeprom $(>) $(<)
183 | }
184 |
185 | rule AvrUpload
186 | {
187 | Depends $(1) : $(2) ;
188 | Depends $(2) : $(3) ;
189 | NotFile $(1) ;
190 | Always $(1) ;
191 | Always $(2) ;
192 | AvrUploadAction $(2) : $(3) ;
193 | }
194 |
195 | actions AvrUploadAction
196 | {
197 | $(AVRDUDE) $(AVRDUDE_FLAGS) -P $(<) $(AVRDUDE_WRITE_FLASH) -U flash:w:$(>):i
198 | }
199 |
200 | AvrMain $(OUT).elf : $(CORE_MODULES) $(LIB_MODULES) $(PROJECT_MODULES) ;
201 | AvrHex $(OUT).hex : $(OUT).elf ;
202 |
203 | AvrUpload p6 : /dev/tty.usbserial-A600eHIs : $(OUT).hex ;
204 | AvrUpload p4 : /dev/tty.usbserial-A40081RP : $(OUT).hex ;
205 | AvrUpload p9 : /dev/tty.usbserial-A9007LmI : $(OUT).hex ;
206 |
207 |
--------------------------------------------------------------------------------
/Arduino Code/RF24-master/examples/pingpair_sleepy/pingpair_sleepy.pde:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2011 J. Coliz
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 | * Example RF Radio Ping Pair which Sleeps between Sends
11 | *
12 | * This is an example of how to use the RF24 class to create a battery-
13 | * efficient system. It is just like the pingpair.pde example, but the
14 | * ping node powers down the radio and sleeps the MCU after every
15 | * ping/pong cycle.
16 | *
17 | * As with the pingpair.pde example, write this sketch to two different nodes,
18 | * connect the role_pin to ground on one. The ping node sends the current
19 | * time to the pong node, which responds by sending the value back. The ping
20 | * node can then see how long the whole cycle took.
21 | */
22 |
23 | #include
24 | #include
25 | #include
26 | #include "nRF24L01.h"
27 | #include "RF24.h"
28 | #include "printf.h"
29 |
30 | //
31 | // Hardware configuration
32 | //
33 |
34 | // Set up nRF24L01 radio on SPI bus plus pins 9 & 10
35 |
36 | RF24 radio(9,10);
37 |
38 | // sets the role of this unit in hardware. Connect to GND to be the 'pong' receiver
39 | // Leave open to be the 'ping' transmitter
40 | const int role_pin = 7;
41 |
42 | //
43 | // Topology
44 | //
45 |
46 | // Radio pipe addresses for the 2 nodes to communicate.
47 | const uint64_t pipes[2] = { 0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL };
48 |
49 | //
50 | // Role management
51 | //
52 | // Set up role. This sketch uses the same software for all the nodes
53 | // in this system. Doing so greatly simplifies testing. The hardware itself specifies
54 | // which node it is.
55 | //
56 | // This is done through the role_pin
57 | //
58 |
59 | // The various roles supported by this sketch
60 | typedef enum { role_ping_out = 1, role_pong_back } role_e;
61 |
62 | // The debug-friendly names of those roles
63 | const char* role_friendly_name[] = { "invalid", "Ping out", "Pong back"};
64 |
65 | // The role of the current running sketch
66 | role_e role;
67 |
68 | //
69 | // Sleep declarations
70 | //
71 |
72 | typedef enum { wdt_16ms = 0, wdt_32ms, wdt_64ms, wdt_128ms, wdt_250ms, wdt_500ms, wdt_1s, wdt_2s, wdt_4s, wdt_8s } wdt_prescalar_e;
73 |
74 | void setup_watchdog(uint8_t prescalar);
75 | void do_sleep(void);
76 |
77 | const short sleep_cycles_per_transmission = 4;
78 | volatile short sleep_cycles_remaining = sleep_cycles_per_transmission;
79 |
80 | //
81 | // Normal operation
82 | //
83 |
84 | void setup(void)
85 | {
86 | //
87 | // Role
88 | //
89 |
90 | // set up the role pin
91 | pinMode(role_pin, INPUT);
92 | digitalWrite(role_pin,HIGH);
93 | delay(20); // Just to get a solid reading on the role pin
94 |
95 | // read the address pin, establish our role
96 | if ( digitalRead(role_pin) )
97 | role = role_ping_out;
98 | else
99 | role = role_pong_back;
100 |
101 | //
102 | // Print preamble
103 | //
104 |
105 | Serial.begin(57600);
106 | printf_begin();
107 | printf("\n\rRF24/examples/pingpair_sleepy/\n\r");
108 | printf("ROLE: %s\n\r",role_friendly_name[role]);
109 |
110 | //
111 | // Prepare sleep parameters
112 | //
113 |
114 | // Only the ping out role sleeps. Wake up every 4s to send a ping
115 | if ( role == role_ping_out )
116 | setup_watchdog(wdt_1s);
117 |
118 | //
119 | // Setup and configure rf radio
120 | //
121 |
122 | radio.begin();
123 |
124 | //
125 | // Open pipes to other nodes for communication
126 | //
127 |
128 | // This simple sketch opens two pipes for these two nodes to communicate
129 | // back and forth.
130 | // Open 'our' pipe for writing
131 | // Open the 'other' pipe for reading, in position #1 (we can have up to 5 pipes open for reading)
132 |
133 | if ( role == role_ping_out )
134 | {
135 | radio.openWritingPipe(pipes[0]);
136 | radio.openReadingPipe(1,pipes[1]);
137 | }
138 | else
139 | {
140 | radio.openWritingPipe(pipes[1]);
141 | radio.openReadingPipe(1,pipes[0]);
142 | }
143 |
144 | //
145 | // Start listening
146 | //
147 |
148 | radio.startListening();
149 |
150 | //
151 | // Dump the configuration of the rf unit for debugging
152 | //
153 |
154 | radio.printDetails();
155 | }
156 |
157 | void loop(void)
158 | {
159 | //
160 | // Ping out role. Repeatedly send the current time
161 | //
162 |
163 | if (role == role_ping_out)
164 | {
165 | // First, stop listening so we can talk.
166 | radio.stopListening();
167 |
168 | // Take the time, and send it. This will block until complete
169 | unsigned long time = millis();
170 | printf("Now sending %lu...",time);
171 | radio.write( &time, sizeof(unsigned long) );
172 |
173 | // Now, continue listening
174 | radio.startListening();
175 |
176 | // Wait here until we get a response, or timeout (250ms)
177 | unsigned long started_waiting_at = millis();
178 | bool timeout = false;
179 | while ( ! radio.available() && ! timeout )
180 | if (millis() - started_waiting_at > 250 )
181 | timeout = true;
182 |
183 | // Describe the results
184 | if ( timeout )
185 | {
186 | printf("Failed, response timed out.\n\r");
187 | }
188 | else
189 | {
190 | // Grab the response, compare, and send to debugging spew
191 | unsigned long got_time;
192 | radio.read( &got_time, sizeof(unsigned long) );
193 |
194 | // Spew it
195 | printf("Got response %lu, round-trip delay: %lu\n\r",got_time,millis()-got_time);
196 | }
197 |
198 | //
199 | // Shut down the system
200 | //
201 |
202 | // Experiment with some delay here to see if it has an effect
203 | delay(500);
204 |
205 | // Power down the radio. Note that the radio will get powered back up
206 | // on the next write() call.
207 | radio.powerDown();
208 |
209 | // Sleep the MCU. The watchdog timer will awaken in a short while, and
210 | // continue execution here.
211 | while( sleep_cycles_remaining )
212 | do_sleep();
213 |
214 | sleep_cycles_remaining = sleep_cycles_per_transmission;
215 | }
216 |
217 | //
218 | // Pong back role. Receive each packet, dump it out, and send it back
219 | //
220 | // This is untouched from the pingpair example.
221 | //
222 |
223 | if ( role == role_pong_back )
224 | {
225 | // if there is data ready
226 | if ( radio.available() )
227 | {
228 | // Dump the payloads until we've gotten everything
229 | unsigned long got_time;
230 | bool done = false;
231 | while (!done)
232 | {
233 | // Fetch the payload, and see if this was the last one.
234 | done = radio.read( &got_time, sizeof(unsigned long) );
235 |
236 | // Spew it. Include our time, because the ping_out millis counter is unreliable
237 | // due to it sleeping
238 | printf("Got payload %lu @ %lu...",got_time,millis());
239 | }
240 |
241 | // First, stop listening so we can talk
242 | radio.stopListening();
243 |
244 | // Send the final one back.
245 | radio.write( &got_time, sizeof(unsigned long) );
246 | printf("Sent response.\n\r");
247 |
248 | // Now, resume listening so we catch the next packets.
249 | radio.startListening();
250 | }
251 | }
252 | }
253 |
254 | //
255 | // Sleep helpers
256 | //
257 |
258 | // 0=16ms, 1=32ms,2=64ms,3=125ms,4=250ms,5=500ms
259 | // 6=1 sec,7=2 sec, 8=4 sec, 9= 8sec
260 |
261 | void setup_watchdog(uint8_t prescalar)
262 | {
263 | prescalar = min(9,prescalar);
264 | uint8_t wdtcsr = prescalar & 7;
265 | if ( prescalar & 8 )
266 | wdtcsr |= _BV(WDP3);
267 |
268 | MCUSR &= ~_BV(WDRF);
269 | WDTCSR = _BV(WDCE) | _BV(WDE);
270 | WDTCSR = _BV(WDCE) | wdtcsr | _BV(WDIE);
271 | }
272 |
273 | ISR(WDT_vect)
274 | {
275 | --sleep_cycles_remaining;
276 | }
277 |
278 | void do_sleep(void)
279 | {
280 | set_sleep_mode(SLEEP_MODE_PWR_DOWN); // sleep mode is set here
281 | sleep_enable();
282 |
283 | sleep_mode(); // System sleeps here
284 |
285 | sleep_disable(); // System continues execution here when watchdog timed out
286 | }
287 |
288 | // vim:ai:cin:sts=2 sw=2 ft=cpp
289 |
--------------------------------------------------------------------------------
/Arduino Code/RF24-master/examples/pingpair_sleepy/printf.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2011 J. Coliz
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 printf.h
11 | *
12 | * Setup necessary to direct stdout to the Arduino Serial library, which
13 | * enables 'printf'
14 | */
15 |
16 | #ifndef __PRINTF_H__
17 | #define __PRINTF_H__
18 |
19 | #ifdef ARDUINO
20 |
21 | int serial_putc( char c, FILE * )
22 | {
23 | Serial.write( c );
24 |
25 | return c;
26 | }
27 |
28 | void printf_begin(void)
29 | {
30 | fdevopen( &serial_putc, 0 );
31 | }
32 |
33 | #else
34 | #error This example is only for use on Arduino.
35 | #endif // ARDUINO
36 |
37 | #endif // __PRINTF_H__
38 |
--------------------------------------------------------------------------------
/Arduino Code/RF24-master/examples/scanner/Jamfile:
--------------------------------------------------------------------------------
1 | # (1) Project Information
2 |
3 | PROJECT_LIBS = SPI RF24 ;
4 |
5 | # (2) Board Information
6 |
7 | UPLOAD_PROTOCOL ?= stk500v1 ;
8 | UPLOAD_SPEED ?= 57600 ;
9 | MCU ?= atmega328p ;
10 | F_CPU ?= 16000000 ;
11 | CORE ?= arduino ;
12 | VARIANT ?= standard ;
13 | ARDUINO_VERSION ?= 100 ;
14 |
15 | # (3) USB Ports
16 |
17 | PORTS = p4 p6 p9 u0 u1 u2 ;
18 | PORT_p6 = /dev/tty.usbserial-A600eHIs ;
19 | PORT_p4 = /dev/tty.usbserial-A40081RP ;
20 | PORT_p9 = /dev/tty.usbserial-A9007LmI ;
21 | PORT_u0 = /dev/ttyUSB0 ;
22 | PORT_u1 = /dev/ttyUSB1 ;
23 | PORT_u2 = /dev/ttyUSB2 ;
24 |
25 | # (4) Location of AVR tools
26 | #
27 | # This configuration assumes using avr-tools that were obtained separate from the Arduino
28 | # distribution.
29 |
30 | if $(OS) = MACOSX
31 | {
32 | AVR_BIN = /usr/local/avrtools/bin ;
33 | AVR_ETC = /usr/local/avrtools/etc ;
34 | AVR_INCLUDE = /usr/local/avrtools/include ;
35 | }
36 | else
37 | {
38 | AVR_BIN = /usr/bin ;
39 | AVR_INCLUDE = /usr/lib/avr/include ;
40 | AVR_ETC = /etc ;
41 | }
42 |
43 | # (5) Directories where Arduino core and libraries are located
44 |
45 | ARDUINO_DIR ?= /opt/Arduino ;
46 | ARDUINO_CORE = $(ARDUINO_DIR)/hardware/arduino/cores/$(CORE) $(ARDUINO_DIR)/hardware/arduino/variants/$(VARIANT) ;
47 | ARDUINO_LIB = $(ARDUINO_DIR)/libraries ;
48 | SKETCH_LIB = $(HOME)/Source/Arduino/libraries ;
49 |
50 | #
51 | # --------------------------------------------------
52 | # Below this line usually never needs to be modified
53 | #
54 |
55 | # Tool locations
56 |
57 | CC = $(AVR_BIN)/avr-gcc ;
58 | C++ = $(AVR_BIN)/avr-g++ ;
59 | LINK = $(AVR_BIN)/avr-gcc ;
60 | OBJCOPY = $(AVR_BIN)/avr-objcopy ;
61 | AVRDUDE = $(AVR_BIN)/avrdude ;
62 |
63 | # Flags
64 |
65 | DEFINES += F_CPU=$(F_CPU)L ARDUINO=$(ARDUINO_VERSION) VERSION_H ;
66 | OPTIM = -Os ;
67 | CCFLAGS = -Wall -Wextra -mmcu=$(MCU) -ffunction-sections -fdata-sections ;
68 | C++FLAGS = $(CCFLAGS) -fno-exceptions -fno-strict-aliasing ;
69 | LINKFLAGS = $(OPTIM) -lm -Wl,--gc-sections -mmcu=$(MCU) ;
70 | AVRDUDEFLAGS = -V -F -D -C $(AVR_ETC)/avrdude.conf -p $(MCU) -c $(UPLOAD_PROTOCOL) -b $(UPLOAD_SPEED) ;
71 |
72 | # Search everywhere for headers
73 |
74 | HDRS = $(PWD) $(AVR_INCLUDE) $(ARDUINO_CORE) $(ARDUINO_LIB)/$(PROJECT_LIBS) $(ARDUINO_LIB)/$(PROJECT_LIBS)/utility $(SKETCH_LIB)/$(PROJECT_LIBS) ;
75 |
76 | # Output locations
77 |
78 | LOCATE_TARGET = $(F_CPU) ;
79 | LOCATE_SOURCE = $(F_CPU) ;
80 |
81 | #
82 | # Custom rules
83 | #
84 |
85 | rule GitVersion
86 | {
87 | Always $(<) ;
88 | Depends all : $(<) ;
89 | }
90 |
91 | actions GitVersion
92 | {
93 | echo "const char program_version[] = \"\\" > $(<)
94 | git log -1 --pretty=format:%h >> $(<)
95 | echo "\";" >> $(<)
96 | }
97 |
98 | GitVersion version.h ;
99 |
100 | rule Pde
101 | {
102 | Depends $(<) : $(>) ;
103 | MakeLocate $(<) : $(LOCATE_SOURCE) ;
104 | Clean clean : $(<) ;
105 | }
106 |
107 | if ( $(ARDUINO_VERSION) < 100 )
108 | {
109 | ARDUINO_H = WProgram.h ;
110 | }
111 | else
112 | {
113 | ARDUINO_H = Arduino.h ;
114 | }
115 |
116 | actions Pde
117 | {
118 | echo "#include <$(ARDUINO_H)>" > $(<)
119 | echo "#line 1 \"$(>)\"" >> $(<)
120 | cat $(>) >> $(<)
121 | }
122 |
123 | rule C++Pde
124 | {
125 | local _CPP = $(>:B).cpp ;
126 | Pde $(_CPP) : $(>) ;
127 | C++ $(<) : $(_CPP) ;
128 | }
129 |
130 | rule UserObject
131 | {
132 | switch $(>:S)
133 | {
134 | case .ino : C++Pde $(<) : $(>) ;
135 | case .pde : C++Pde $(<) : $(>) ;
136 | }
137 | }
138 |
139 | rule Objects
140 | {
141 | local _i ;
142 |
143 | for _i in [ FGristFiles $(<) ]
144 | {
145 | local _b = $(_i:B)$(SUFOBJ) ;
146 | local _o = $(_b:G=$(SOURCE_GRIST:E)) ;
147 | Object $(_o) : $(_i) ;
148 | Depends obj : $(_o) ;
149 | }
150 | }
151 |
152 | rule Main
153 | {
154 | MainFromObjects $(<) : $(>:B)$(SUFOBJ) ;
155 | Objects $(>) ;
156 | }
157 |
158 | rule Hex
159 | {
160 | Depends $(<) : $(>) ;
161 | MakeLocate $(<) : $(LOCATE_TARGET) ;
162 | Depends hex : $(<) ;
163 | Clean clean : $(<) ;
164 | }
165 |
166 | actions Hex
167 | {
168 | $(OBJCOPY) -O ihex -R .eeprom $(>) $(<)
169 | }
170 |
171 | rule Upload
172 | {
173 | Depends $(1) : $(2) ;
174 | Depends $(2) : $(3) ;
175 | NotFile $(1) ;
176 | Always $(1) ;
177 | Always $(2) ;
178 | UploadAction $(2) : $(3) ;
179 | }
180 |
181 | actions UploadAction
182 | {
183 | $(AVRDUDE) $(AVRDUDEFLAGS) -P $(<) $(AVRDUDE_WRITE_FLASH) -U flash:w:$(>):i
184 | }
185 |
186 | #
187 | # Targets
188 | #
189 |
190 | # Grab everything from the core directory
191 | CORE_MODULES = [ GLOB $(ARDUINO_CORE) : *.c *.cpp ] ;
192 |
193 | # Grab everything from libraries. To avoid this "grab everything" behaviour, you
194 | # can specify specific modules to pick up in PROJECT_MODULES
195 | LIB_MODULES = [ GLOB $(ARDUINO_LIB)/$(PROJECT_LIBS) $(ARDUINO_LIB)/$(PROJECT_LIBS)/utility $(SKETCH_LIB)/$(PROJECT_LIBS) : *.cpp *.c ] ;
196 |
197 | # Grab everything from the current dir
198 | PROJECT_MODULES += [ GLOB $(PWD) : *.c *.cpp *.pde *.ino ] ;
199 |
200 | # Main output executable
201 | MAIN = $(PWD:B).elf ;
202 |
203 | Main $(MAIN) : $(CORE_MODULES) $(LIB_MODULES) $(PROJECT_MODULES) ;
204 | Hex $(MAIN:B).hex : $(MAIN) ;
205 |
206 | # Upload targets
207 | for _p in $(PORTS)
208 | {
209 | Upload $(_p) : $(PORT_$(_p)) : $(MAIN:B).hex ;
210 | }
211 |
--------------------------------------------------------------------------------
/Arduino Code/RF24-master/examples/scanner/printf.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2011 J. Coliz
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 printf.h
11 | *
12 | * Setup necessary to direct stdout to the Arduino Serial library, which
13 | * enables 'printf'
14 | */
15 |
16 | #ifndef __PRINTF_H__
17 | #define __PRINTF_H__
18 |
19 | int serial_putc( char c, FILE * )
20 | {
21 | Serial.write( c );
22 |
23 | return c;
24 | }
25 |
26 | void printf_begin(void)
27 | {
28 | fdevopen( &serial_putc, 0 );
29 | }
30 |
31 | #endif // __PRINTF_H__
32 |
--------------------------------------------------------------------------------
/Arduino Code/RF24-master/examples/scanner/scanner.pde:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2011 J. Coliz
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 | * Channel scanner
11 | *
12 | * Example to detect interference on the various channels available.
13 | * This is a good diagnostic tool to check whether you're picking a
14 | * good channel for your application.
15 | *
16 | * Inspired by cpixip.
17 | * See http://arduino.cc/forum/index.php/topic,54795.0.html
18 | */
19 |
20 | #include
21 | #include "nRF24L01.h"
22 | #include "RF24.h"
23 | #include "printf.h"
24 |
25 | //
26 | // Hardware configuration
27 | //
28 |
29 | // Set up nRF24L01 radio on SPI bus plus pins 9 & 10
30 |
31 | RF24 radio(9,10);
32 |
33 | //
34 | // Channel info
35 | //
36 |
37 | const uint8_t num_channels = 128;
38 | uint8_t values[num_channels];
39 |
40 | //
41 | // Setup
42 | //
43 |
44 | void setup(void)
45 | {
46 | //
47 | // Print preamble
48 | //
49 |
50 | Serial.begin(57600);
51 | printf_begin();
52 | printf("\n\rRF24/examples/scanner/\n\r");
53 |
54 | //
55 | // Setup and configure rf radio
56 | //
57 |
58 | radio.begin();
59 | radio.setAutoAck(false);
60 |
61 | // Get into standby mode
62 | radio.startListening();
63 | radio.stopListening();
64 |
65 | // Print out header, high then low digit
66 | int i = 0;
67 | while ( i < num_channels )
68 | {
69 | printf("%x",i>>4);
70 | ++i;
71 | }
72 | printf("\n\r");
73 | i = 0;
74 | while ( i < num_channels )
75 | {
76 | printf("%x",i&0xf);
77 | ++i;
78 | }
79 | printf("\n\r");
80 | }
81 |
82 | //
83 | // Loop
84 | //
85 |
86 | const int num_reps = 100;
87 |
88 | void loop(void)
89 | {
90 | // Clear measurement values
91 | memset(values,0,sizeof(values));
92 |
93 | // Scan all channels num_reps times
94 | int rep_counter = num_reps;
95 | while (rep_counter--)
96 | {
97 | int i = num_channels;
98 | while (i--)
99 | {
100 | // Select this channel
101 | radio.setChannel(i);
102 |
103 | // Listen for a little
104 | radio.startListening();
105 | delayMicroseconds(128);
106 | radio.stopListening();
107 |
108 | // Did we get a carrier?
109 | if ( radio.testCarrier() )
110 | ++values[i];
111 | }
112 | }
113 |
114 | // Print out channel measurements, clamped to a single hex digit
115 | int i = 0;
116 | while ( i < num_channels )
117 | {
118 | printf("%x",min(0xf,values[i]&0xf));
119 | ++i;
120 | }
121 | printf("\n\r");
122 | }
123 |
124 | // vim:ai:cin:sts=2 sw=2 ft=cpp
125 |
--------------------------------------------------------------------------------
/Arduino Code/RF24-master/examples/starping/Jamfile:
--------------------------------------------------------------------------------
1 | PROJECT_NAME = $(PWD:B) ;
2 | PROJECT_DIR = . ;
3 | PROJECT_LIBS = EEPROM SPI RF24 ;
4 |
5 | OUT_DIR = ojam ;
6 | F_CPU = 16000000 ;
7 | MCU = atmega328p ;
8 | PORTS = /dev/tty.usbserial-A600eHIs /dev/tty.usbserial-A40081RP /dev/tty.usbserial-A9007LmI ;
9 |
10 | UPLOAD_RATE = 57600 ;
11 | AVRDUDE_PROTOCOL = stk500v1 ;
12 | COM = 33 ;
13 |
14 | # Host-specific overrides for locations
15 | if $(OS) = MACOSX
16 | {
17 | ARDUINO_VERSION = 22 ;
18 | OLD_DIR = /opt/arduino-0021 ;
19 | AVR_TOOLS_PATH = $(OLD_DIR)/hardware/tools/avr/bin ;
20 | AVRDUDECONFIG_PATH = $(OLD_DIR)/hardware/tools/avr/etc ;
21 | ARDUINO_DIR = /opt/Arduino ;
22 | ARDUINO_AVR = /usr/lib/avr/include ;
23 | }
24 |
25 | # Where is everything?
26 | ARDUINO_VERSION ?= 22 ;
27 | AVR_TOOLS_PATH ?= /usr/bin ;
28 | ARDUINO_DIR ?= /opt/arduino-00$(ARDUINO_VERSION) ;
29 | ARDUINO_AVR ?= $(ARDUINO_DIR)/hardware/tools/avr/avr/include/avr ;
30 | AVRDUDECONFIG_PATH ?= $(ARDUINO_DIR)/hardware/tools ;
31 | ARDUINO_CORE = $(ARDUINO_DIR)/hardware/arduino/cores/arduino ;
32 | ARDUINO_LIB = $(ARDUINO_DIR)/libraries ;
33 | SKETCH_LIB = $(HOME)/Source/Arduino/libraries ;
34 | AVR_CC = $(AVR_TOOLS_PATH)/avr-gcc ;
35 | AVR_CXX = $(AVR_TOOLS_PATH)/avr-g++ ;
36 | AVR_LD = $(AVR_TOOLS_PATH)/avr-gcc ;
37 | AVR_OBJCOPY = $(AVR_TOOLS_PATH)/avr-objcopy ;
38 | AVRDUDE = $(AVR_TOOLS_PATH)/avrdude ;
39 |
40 | DEFINES = F_CPU=$(F_CPU)L ARDUINO=$(ARDUINO_VERSION) VERSION_H ;
41 | CTUNING = -ffunction-sections -fdata-sections ;
42 | CXXTUNING = -fno-exceptions -fno-strict-aliasing ;
43 | CFLAGS = -Os -Wall -Wextra -mmcu=$(MCU) $(CTUNING) ;
44 | CXXFLAGS = $(CFLAGS) $(CXXTUNING) ;
45 | LDFLAGS = -Os -lm -Wl,--gc-sections -mmcu=atmega328p ;
46 |
47 | # Search everywhere for headers
48 | HDRS = $(PROJECT_DIR) $(ARDUINO_AVR) $(ARDUINO_CORE) [ GLOB $(ARDUINO_LIB) $(SKETCH_LIB) : [^.]* ] ;
49 |
50 | # Grab everything from the core directory
51 | CORE_MODULES = [ GLOB $(ARDUINO_CORE) : *.c *.cpp ] ;
52 |
53 | # Grab everything from libraries. To avoid this "grab everything" behaviour, you
54 | # can specify specific modules to pick up in PROJECT_MODULES
55 | LIB_MODULES = [ GLOB $(ARDUINO_LIB)/$(PROJECT_LIBS) $(SKETCH_LIB)/$(PROJECT_LIBS) : *.cpp ] ;
56 |
57 | # In addition to explicitly-specified program modules, pick up anything from the current
58 | # dir.
59 | PROJECT_MODULES += [ GLOB $(PROJECT_DIR) : *.c *.cpp *.pde ] ;
60 |
61 | # Shortcut for the out files
62 | OUT = $(OUT_DIR)/$(PROJECT_NAME) ;
63 |
64 | # AvrDude setup
65 | AVRDUDE_FLAGS = -V -F -D -C $(AVRDUDECONFIG_PATH)/avrdude.conf -p $(MCU) -c $(AVRDUDE_PROTOCOL) -b $(UPLOAD_RATE) ;
66 |
67 | rule GitVersion
68 | {
69 | Always $(<) ;
70 | Depends all : $(<) ;
71 | }
72 |
73 | actions GitVersion
74 | {
75 | echo "const char program_version[] = \"\\" > $(<)
76 | git log -1 --pretty=format:%h >> $(<)
77 | echo "\";" >> $(<)
78 | }
79 |
80 | GitVersion version.h ;
81 |
82 | rule AvrCc
83 | {
84 | Depends $(<) : $(>) ;
85 | Depends $(<) : $(<:D) ;
86 | Clean clean : $(<) ;
87 |
88 | CCHDRS on $(<) = [ on $(<) FIncludes $(HDRS) ] ;
89 | CCDEFS on $(<) = [ on $(<) FDefines $(DEFINES) ] ;
90 | }
91 |
92 | actions AvrCc
93 | {
94 | $(AVR_CC) -c -o $(<) $(CCHDRS) $(CCDEFS) $(CFLAGS) $(>)
95 | }
96 |
97 | rule AvrC++
98 | {
99 | Depends $(<) : $(>) ;
100 | Depends $(<) : $(<:D) ;
101 | Clean clean : $(<) ;
102 |
103 | CCHDRS on $(<) = [ on $(<) FIncludes $(HDRS) ] ;
104 | CCDEFS on $(<) = [ on $(<) FDefines $(DEFINES) ] ;
105 | }
106 |
107 | actions AvrC++
108 | {
109 | $(AVR_CXX) -c -o $(<) $(CCHDRS) $(CCDEFS) $(CXXFLAGS) $(>)
110 | }
111 |
112 | rule Pde
113 | {
114 | Depends $(<) : $(>) ;
115 | Depends $(<) : $(<:D) ;
116 | Clean clean : $(<) ;
117 |
118 | }
119 |
120 | actions Pde
121 | {
122 | echo "#include " > $(<)
123 | echo "#line 1 \"$(>)\"" >> $(<)
124 | cat $(>) >> $(<)
125 | }
126 |
127 | rule AvrPde
128 | {
129 | local _CPP = $(OUT_DIR)/$(_I:B).cpp ;
130 | Pde $(_CPP) : $(>) ;
131 | AvrC++ $(<) : $(_CPP) ;
132 | }
133 |
134 | rule AvrObject
135 | {
136 | switch $(>:S)
137 | {
138 | case .c : AvrCc $(<) : $(>) ;
139 | case .cpp : AvrC++ $(<) : $(>) ;
140 | case .pde : AvrPde $(<) : $(>) ;
141 | }
142 | }
143 |
144 | rule AvrObjects
145 | {
146 | for _I in $(<)
147 | {
148 | AvrObject $(OUT_DIR)/$(_I:B).o : $(_I) ;
149 | }
150 | }
151 |
152 | rule AvrMainFromObjects
153 | {
154 | Depends $(<) : $(>) ;
155 | Depends $(<) : $(<:D) ;
156 | MkDir $(<:D) ;
157 | Depends all : $(<) ;
158 | Clean clean : $(<) ;
159 | }
160 |
161 | actions AvrMainFromObjects
162 | {
163 | $(AVR_LD) $(LDFLAGS) -o $(<) $(>)
164 | }
165 |
166 | rule AvrMain
167 | {
168 | AvrMainFromObjects $(<) : $(OUT_DIR)/$(>:B).o ;
169 | AvrObjects $(>) ;
170 | }
171 |
172 | rule AvrHex
173 | {
174 | Depends $(<) : $(>) ;
175 | Depends $(<) : $(<:D) ;
176 | Depends hex : $(<) ;
177 | Clean clean : $(<) ;
178 | }
179 |
180 | actions AvrHex
181 | {
182 | $(AVR_OBJCOPY) -O ihex -R .eeprom $(>) $(<)
183 | }
184 |
185 | rule AvrUpload
186 | {
187 | Depends $(1) : $(2) ;
188 | Depends $(2) : $(3) ;
189 | NotFile $(1) ;
190 | Always $(1) ;
191 | Always $(2) ;
192 | AvrUploadAction $(2) : $(3) ;
193 | }
194 |
195 | actions AvrUploadAction
196 | {
197 | $(AVRDUDE) $(AVRDUDE_FLAGS) -P $(<) $(AVRDUDE_WRITE_FLASH) -U flash:w:$(>):i
198 | }
199 |
200 | AvrMain $(OUT).elf : $(CORE_MODULES) $(LIB_MODULES) $(PROJECT_MODULES) ;
201 | AvrHex $(OUT).hex : $(OUT).elf ;
202 |
203 | AvrUpload p6 : /dev/tty.usbserial-A600eHIs : $(OUT).hex ;
204 | AvrUpload p4 : /dev/tty.usbserial-A40081RP : $(OUT).hex ;
205 | AvrUpload p9 : /dev/tty.usbserial-A9007LmI : $(OUT).hex ;
206 |
207 |
--------------------------------------------------------------------------------
/Arduino Code/RF24-master/examples/starping/printf.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2011 J. Coliz
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 printf.h
11 | *
12 | * Setup necessary to direct stdout to the Arduino Serial library, which
13 | * enables 'printf'
14 | */
15 |
16 | #ifndef __PRINTF_H__
17 | #define __PRINTF_H__
18 |
19 | #ifdef ARDUINO
20 |
21 | int serial_putc( char c, FILE * )
22 | {
23 | Serial.write( c );
24 |
25 | return c;
26 | }
27 |
28 | void printf_begin(void)
29 | {
30 | fdevopen( &serial_putc, 0 );
31 | }
32 |
33 | #else
34 | #error This example is only for use on Arduino.
35 | #endif // ARDUINO
36 |
37 | #endif // __PRINTF_H__
38 |
--------------------------------------------------------------------------------
/Arduino Code/RF24-master/examples/starping/starping.pde:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2011 J. Coliz
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 | * Example RF Radio Ping Star Group
11 | *
12 | * This sketch is a more complex example of using the RF24 library for Arduino.
13 | * Deploy this on up to six nodes. Set one as the 'pong receiver' by tying the
14 | * role_pin low, and the others will be 'ping transmit' units. The ping units
15 | * unit will send out the value of millis() once a second. The pong unit will
16 | * respond back with a copy of the value. Each ping unit can get that response
17 | * back, and determine how long the whole cycle took.
18 | *
19 | * This example requires a bit more complexity to determine which unit is which.
20 | * The pong receiver is identified by having its role_pin tied to ground.
21 | * The ping senders are further differentiated by a byte in eeprom.
22 | */
23 |
24 | #include
25 | #include
26 | #include "nRF24L01.h"
27 | #include "RF24.h"
28 | #include "printf.h"
29 |
30 | //
31 | // Hardware configuration
32 | //
33 |
34 | // Set up nRF24L01 radio on SPI bus plus pins 9 & 10
35 |
36 | RF24 radio(9,10);
37 |
38 | // sets the role of this unit in hardware. Connect to GND to be the 'pong' receiver
39 | // Leave open to be the 'pong' receiver.
40 | const int role_pin = 7;
41 |
42 | //
43 | // Topology
44 | //
45 |
46 | // Radio pipe addresses for the nodes to communicate. Only ping nodes need
47 | // dedicated pipes in this topology. Each ping node has a talking pipe
48 | // that it will ping into, and a listening pipe that it will listen for
49 | // the pong. The pong node listens on all the ping node talking pipes
50 | // and sends the pong back on the sending node's specific listening pipe.
51 |
52 | const uint64_t talking_pipes[5] = { 0xF0F0F0F0D2LL, 0xF0F0F0F0C3LL, 0xF0F0F0F0B4LL, 0xF0F0F0F0A5LL, 0xF0F0F0F096LL };
53 | const uint64_t listening_pipes[5] = { 0x3A3A3A3AD2LL, 0x3A3A3A3AC3LL, 0x3A3A3A3AB4LL, 0x3A3A3A3AA5LL, 0x3A3A3A3A96LL };
54 |
55 | //
56 | // Role management
57 | //
58 | // Set up role. This sketch uses the same software for all the nodes
59 | // in this system. Doing so greatly simplifies testing. The hardware itself specifies
60 | // which node it is.
61 | //
62 | // This is done through the role_pin
63 | //
64 |
65 | // The various roles supported by this sketch
66 | typedef enum { role_invalid = 0, role_ping_out, role_pong_back } role_e;
67 |
68 | // The debug-friendly names of those roles
69 | const char* role_friendly_name[] = { "invalid", "Ping out", "Pong back"};
70 |
71 | // The role of the current running sketch
72 | role_e role;
73 |
74 | //
75 | // Address management
76 | //
77 |
78 | // Where in EEPROM is the address stored?
79 | const uint8_t address_at_eeprom_location = 0;
80 |
81 | // What is our address (SRAM cache of the address from EEPROM)
82 | // Note that zero is an INVALID address. The pong back unit takes address
83 | // 1, and the rest are 2-6
84 | uint8_t node_address;
85 |
86 | void setup(void)
87 | {
88 | //
89 | // Role
90 | //
91 |
92 | // set up the role pin
93 | pinMode(role_pin, INPUT);
94 | digitalWrite(role_pin,HIGH);
95 | delay(20); // Just to get a solid reading on the role pin
96 |
97 | // read the address pin, establish our role
98 | if ( digitalRead(role_pin) )
99 | role = role_ping_out;
100 | else
101 | role = role_pong_back;
102 |
103 | //
104 | // Address
105 | //
106 |
107 | if ( role == role_pong_back )
108 | node_address = 1;
109 | else
110 | {
111 | // Read the address from EEPROM
112 | uint8_t reading = EEPROM.read(address_at_eeprom_location);
113 |
114 | // If it is in a valid range for node addresses, it is our
115 | // address.
116 | if ( reading >= 2 && reading <= 6 )
117 | node_address = reading;
118 |
119 | // Otherwise, it is invalid, so set our address AND ROLE to 'invalid'
120 | else
121 | {
122 | node_address = 0;
123 | role = role_invalid;
124 | }
125 | }
126 |
127 | //
128 | // Print preamble
129 | //
130 |
131 | Serial.begin(57600);
132 | printf_begin();
133 | printf("\n\rRF24/examples/starping/\n\r");
134 | printf("ROLE: %s\n\r",role_friendly_name[role]);
135 | printf("ADDRESS: %i\n\r",node_address);
136 |
137 | //
138 | // Setup and configure rf radio
139 | //
140 |
141 | radio.begin();
142 |
143 | //
144 | // Open pipes to other nodes for communication
145 | //
146 |
147 | // The pong node listens on all the ping node talking pipes
148 | // and sends the pong back on the sending node's specific listening pipe.
149 | if ( role == role_pong_back )
150 | {
151 | radio.openReadingPipe(1,talking_pipes[0]);
152 | radio.openReadingPipe(2,talking_pipes[1]);
153 | radio.openReadingPipe(3,talking_pipes[2]);
154 | radio.openReadingPipe(4,talking_pipes[3]);
155 | radio.openReadingPipe(5,talking_pipes[4]);
156 | }
157 |
158 | // Each ping node has a talking pipe that it will ping into, and a listening
159 | // pipe that it will listen for the pong.
160 | if ( role == role_ping_out )
161 | {
162 | // Write on our talking pipe
163 | radio.openWritingPipe(talking_pipes[node_address-2]);
164 | // Listen on our listening pipe
165 | radio.openReadingPipe(1,listening_pipes[node_address-2]);
166 | }
167 |
168 | //
169 | // Start listening
170 | //
171 |
172 | radio.startListening();
173 |
174 | //
175 | // Dump the configuration of the rf unit for debugging
176 | //
177 |
178 | radio.printDetails();
179 |
180 | //
181 | // Prompt the user to assign a node address if we don't have one
182 | //
183 |
184 | if ( role == role_invalid )
185 | {
186 | printf("\n\r*** NO NODE ADDRESS ASSIGNED *** Send 1 through 6 to assign an address\n\r");
187 | }
188 | }
189 |
190 | void loop(void)
191 | {
192 | //
193 | // Ping out role. Repeatedly send the current time
194 | //
195 |
196 | if (role == role_ping_out)
197 | {
198 | // First, stop listening so we can talk.
199 | radio.stopListening();
200 |
201 | // Take the time, and send it. This will block until complete
202 | unsigned long time = millis();
203 | printf("Now sending %lu...",time);
204 | radio.write( &time, sizeof(unsigned long) );
205 |
206 | // Now, continue listening
207 | radio.startListening();
208 |
209 | // Wait here until we get a response, or timeout (250ms)
210 | unsigned long started_waiting_at = millis();
211 | bool timeout = false;
212 | while ( ! radio.available() && ! timeout )
213 | if (millis() - started_waiting_at > 250 )
214 | timeout = true;
215 |
216 | // Describe the results
217 | if ( timeout )
218 | {
219 | printf("Failed, response timed out.\n\r");
220 | }
221 | else
222 | {
223 | // Grab the response, compare, and send to debugging spew
224 | unsigned long got_time;
225 | radio.read( &got_time, sizeof(unsigned long) );
226 |
227 | // Spew it
228 | printf("Got response %lu, round-trip delay: %lu\n\r",got_time,millis()-got_time);
229 | }
230 |
231 | // Try again 1s later
232 | delay(1000);
233 | }
234 |
235 | //
236 | // Pong back role. Receive each packet, dump it out, and send it back
237 | //
238 |
239 | if ( role == role_pong_back )
240 | {
241 | // if there is data ready
242 | uint8_t pipe_num;
243 | if ( radio.available(&pipe_num) )
244 | {
245 | // Dump the payloads until we've gotten everything
246 | unsigned long got_time;
247 | bool done = false;
248 | while (!done)
249 | {
250 | // Fetch the payload, and see if this was the last one.
251 | done = radio.read( &got_time, sizeof(unsigned long) );
252 |
253 | // Spew it
254 | printf("Got payload %lu from node %i...",got_time,pipe_num+1);
255 | }
256 |
257 | // First, stop listening so we can talk
258 | radio.stopListening();
259 |
260 | // Open the correct pipe for writing
261 | radio.openWritingPipe(listening_pipes[pipe_num-1]);
262 |
263 | // Retain the low 2 bytes to identify the pipe for the spew
264 | uint16_t pipe_id = listening_pipes[pipe_num-1] & 0xffff;
265 |
266 | // Send the final one back.
267 | radio.write( &got_time, sizeof(unsigned long) );
268 | printf("Sent response to %04x.\n\r",pipe_id);
269 |
270 | // Now, resume listening so we catch the next packets.
271 | radio.startListening();
272 | }
273 | }
274 |
275 | //
276 | // Listen for serial input, which is how we set the address
277 | //
278 | if (Serial.available())
279 | {
280 | // If the character on serial input is in a valid range...
281 | char c = Serial.read();
282 | if ( c >= '1' && c <= '6' )
283 | {
284 | // It is our address
285 | EEPROM.write(address_at_eeprom_location,c-'0');
286 |
287 | // And we are done right now (no easy way to soft reset)
288 | printf("\n\rManually reset address to: %c\n\rPress RESET to continue!",c);
289 | while(1) ;
290 | }
291 | }
292 | }
293 | // vim:ai:ci sts=2 sw=2 ft=cpp
294 |
--------------------------------------------------------------------------------
/Arduino Code/RF24-master/keywords.txt:
--------------------------------------------------------------------------------
1 | RF24 KEYWORD1
2 | begin KEYWORD2
3 | setChannel KEYWORD2
4 | setPayloadSize KEYWORD2
5 | getPayloadSize KEYWORD2
6 | print_details KEYWORD2
7 | startListening KEYWORD2
8 | stopListening KEYWORD2
9 | write KEYWORD2
10 | available KEYWORD2
11 | read KEYWORD2
12 | openWritingPipe KEYWORD2
13 | openReadingPipe KEYWORD2
--------------------------------------------------------------------------------
/Arduino Code/RF24-master/nRF24L01.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2007 Stefan Engelke
3 |
4 | Permission is hereby granted, free of charge, to any person
5 | obtaining a copy of this software and associated documentation
6 | files (the "Software"), to deal in the Software without
7 | restriction, including without limitation the rights to use, copy,
8 | modify, merge, publish, distribute, sublicense, and/or sell copies
9 | of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be
13 | included in all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 | DEALINGS IN THE SOFTWARE.
23 | */
24 |
25 | /* Memory Map */
26 | #define CONFIG 0x00
27 | #define EN_AA 0x01
28 | #define EN_RXADDR 0x02
29 | #define SETUP_AW 0x03
30 | #define SETUP_RETR 0x04
31 | #define RF_CH 0x05
32 | #define RF_SETUP 0x06
33 | #define STATUS 0x07
34 | #define OBSERVE_TX 0x08
35 | #define CD 0x09
36 | #define RX_ADDR_P0 0x0A
37 | #define RX_ADDR_P1 0x0B
38 | #define RX_ADDR_P2 0x0C
39 | #define RX_ADDR_P3 0x0D
40 | #define RX_ADDR_P4 0x0E
41 | #define RX_ADDR_P5 0x0F
42 | #define TX_ADDR 0x10
43 | #define RX_PW_P0 0x11
44 | #define RX_PW_P1 0x12
45 | #define RX_PW_P2 0x13
46 | #define RX_PW_P3 0x14
47 | #define RX_PW_P4 0x15
48 | #define RX_PW_P5 0x16
49 | #define FIFO_STATUS 0x17
50 | #define DYNPD 0x1C
51 | #define FEATURE 0x1D
52 |
53 | /* Bit Mnemonics */
54 | #define MASK_RX_DR 6
55 | #define MASK_TX_DS 5
56 | #define MASK_MAX_RT 4
57 | #define EN_CRC 3
58 | #define CRCO 2
59 | #define PWR_UP 1
60 | #define PRIM_RX 0
61 | #define ENAA_P5 5
62 | #define ENAA_P4 4
63 | #define ENAA_P3 3
64 | #define ENAA_P2 2
65 | #define ENAA_P1 1
66 | #define ENAA_P0 0
67 | #define ERX_P5 5
68 | #define ERX_P4 4
69 | #define ERX_P3 3
70 | #define ERX_P2 2
71 | #define ERX_P1 1
72 | #define ERX_P0 0
73 | #define AW 0
74 | #define ARD 4
75 | #define ARC 0
76 | #define PLL_LOCK 4
77 | #define RF_DR 3
78 | #define RF_PWR 6
79 | #define RX_DR 6
80 | #define TX_DS 5
81 | #define MAX_RT 4
82 | #define RX_P_NO 1
83 | #define TX_FULL 0
84 | #define PLOS_CNT 4
85 | #define ARC_CNT 0
86 | #define TX_REUSE 6
87 | #define FIFO_FULL 5
88 | #define TX_EMPTY 4
89 | #define RX_FULL 1
90 | #define RX_EMPTY 0
91 | #define DPL_P5 5
92 | #define DPL_P4 4
93 | #define DPL_P3 3
94 | #define DPL_P2 2
95 | #define DPL_P1 1
96 | #define DPL_P0 0
97 | #define EN_DPL 2
98 | #define EN_ACK_PAY 1
99 | #define EN_DYN_ACK 0
100 |
101 | /* Instruction Mnemonics */
102 | #define R_REGISTER 0x00
103 | #define W_REGISTER 0x20
104 | #define REGISTER_MASK 0x1F
105 | #define ACTIVATE 0x50
106 | #define R_RX_PL_WID 0x60
107 | #define R_RX_PAYLOAD 0x61
108 | #define W_TX_PAYLOAD 0xA0
109 | #define W_ACK_PAYLOAD 0xA8
110 | #define FLUSH_TX 0xE1
111 | #define FLUSH_RX 0xE2
112 | #define REUSE_TX_PL 0xE3
113 | #define NOP 0xFF
114 |
115 | /* Non-P omissions */
116 | #define LNA_HCURR 0
117 |
118 | /* P model memory Map */
119 | #define RPD 0x09
120 |
121 | /* P model bit Mnemonics */
122 | #define RF_DR_LOW 5
123 | #define RF_DR_HIGH 3
124 | #define RF_PWR_LOW 1
125 | #define RF_PWR_HIGH 2
126 |
--------------------------------------------------------------------------------
/Arduino Code/RF24-master/printf.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2011 J. Coliz
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 printf.h
11 | *
12 | * Setup necessary to direct stdout to the Arduino Serial library, which
13 | * enables 'printf'
14 | */
15 |
16 | #ifndef __PRINTF_H__
17 | #define __PRINTF_H__
18 |
19 | #ifdef ARDUINO
20 |
21 | int serial_putc( char c, FILE * )
22 | {
23 | Serial.write( c );
24 |
25 | return c;
26 | }
27 |
28 | void printf_begin(void)
29 | {
30 | fdevopen( &serial_putc, 0 );
31 | }
32 |
33 | #else
34 | #error This example is only for use on Arduino.
35 | #endif // ARDUINO
36 |
37 | #endif // __PRINTF_H__
38 |
--------------------------------------------------------------------------------
/Arduino Code/RF24-master/tests/README:
--------------------------------------------------------------------------------
1 | The sketches in this directory are intended to be checkin tests.
2 | No code should be pushed to github without these tests passing.
3 |
4 | See "runtests.sh" script inside each sketch dir. This script is fully compatible with
5 | git bisest.
6 |
7 | Note that this requires python and py-serial
8 |
--------------------------------------------------------------------------------
/Arduino Code/RF24-master/tests/native/Jamfile:
--------------------------------------------------------------------------------
1 | PROJECT_NAME = $(PWD:B) ;
2 | PROJECT_DIR = . ;
3 | PROJECT_LIBS = RF24 ;
4 |
5 | OUT_DIR = ojam ;
6 | F_CPU = 16000000 ;
7 | MCU = atmega328p ;
8 | PORTS = /dev/tty.usbserial-A600eHIs /dev/tty.usbserial-A40081RP /dev/tty.usbserial-A9007LmI ;
9 |
10 | UPLOAD_RATE = 57600 ;
11 | AVRDUDE_PROTOCOL = stk500v1 ;
12 | COM = 33 ;
13 |
14 | # Host-specific overrides for locations
15 | if $(OS) = MACOSX
16 | {
17 | ARDUINO_VERSION = 22 ;
18 | OLD_DIR = /opt/arduino-0021 ;
19 | AVR_TOOLS_PATH = $(OLD_DIR)/hardware/tools/avr/bin ;
20 | AVRDUDECONFIG_PATH = $(OLD_DIR)/hardware/tools/avr/etc ;
21 | ARDUINO_DIR = /opt/Arduino ;
22 | ARDUINO_AVR = /usr/lib/avr/include ;
23 | }
24 |
25 | # Where is everything?
26 | ARDUINO_VERSION ?= 22 ;
27 | SKETCH_DIR = $(HOME)/Source/Arduino ;
28 | AVR_TOOLS_PATH ?= /usr/bin ;
29 | ARDUINO_DIR ?= /opt/arduino-00$(ARDUINO_VERSION) ;
30 | ARDUINO_AVR ?= $(ARDUINO_DIR)/hardware/tools/avr/avr/include/avr ;
31 | AVRDUDECONFIG_PATH ?= $(ARDUINO_DIR)/hardware/tools ;
32 | ARDUINO_CORE = $(ARDUINO_DIR)/hardware/arduino/cores/arduino ;
33 | ARDUINO_LIB = $(ARDUINO_DIR)/libraries ;
34 | SKETCH_LIB = $(SKETCH_DIR)/libraries ;
35 | AVR_AS = $(AVR_TOOLS_PATH)/avr-as ;
36 | AVR_CC = $(AVR_TOOLS_PATH)/avr-gcc ;
37 | AVR_CXX = $(AVR_TOOLS_PATH)/avr-g++ ;
38 | AVR_LD = $(AVR_TOOLS_PATH)/avr-gcc ;
39 | AVR_OBJCOPY = $(AVR_TOOLS_PATH)/avr-objcopy ;
40 | AVRDUDE = $(AVR_TOOLS_PATH)/avrdude ;
41 |
42 | DEFINES = F_CPU=$(F_CPU)L ARDUINO=$(ARDUINO_VERSION) VERSION_H HAL=1 ;
43 | CTUNING = -ffunction-sections -fdata-sections ;
44 | CXXTUNING = -fno-exceptions -fno-strict-aliasing ;
45 | ASFLAGS = -mmcu=$(MCU) ;
46 | CFLAGS = -Os -Wall -Wextra $(ASFLAGS) $(CTUNING) ;
47 | CXXFLAGS = $(CFLAGS) $(CXXTUNING) ;
48 | LDFLAGS = -Os -lm -Wl,--gc-sections -mmcu=atmega328p ;
49 |
50 | # Search everywhere for headers
51 | HDRS = $(PROJECT_DIR) $(ARDUINO_AVR) $(ARDUINO_CORE) [ GLOB $(ARDUINO_LIB) $(SKETCH_LIB) : [^.]* ] ;
52 | HDRS += [ GLOB $(HDRS) : utility ] ;
53 |
54 | # Grab everything from the core directory
55 | CORE_MODULES = [ GLOB $(ARDUINO_CORE) : *.c *.cpp ] ;
56 |
57 | # Grab everything from libraries. To avoid this "grab everything" behaviour, you
58 | # can specify specific modules to pick up in PROJECT_MODULES
59 | LIB_MODULES = [ GLOB $(ARDUINO_LIB)/$(PROJECT_LIBS) $(ARDUINO_LIB)/$(PROJECT_LIBS)/utility $(SKETCH_LIB)/$(PROJECT_LIBS) : *.cpp *.c ] ;
60 |
61 | # In addition to explicitly-specified program modules, pick up anything from the current
62 | # dir.
63 | PROJECT_MODULES += [ GLOB $(PROJECT_DIR) : *.c *.cpp *.pde ] ;
64 |
65 | # Shortcut for the out files
66 | OUT = $(OUT_DIR)/$(PROJECT_NAME) ;
67 |
68 | # AvrDude setup
69 | AVRDUDE_FLAGS = -V -F -D -C $(AVRDUDECONFIG_PATH)/avrdude.conf -p $(MCU) -c $(AVRDUDE_PROTOCOL) -b $(UPLOAD_RATE) ;
70 |
71 | rule GitVersion
72 | {
73 | Always $(<) ;
74 | Depends all : $(<) ;
75 | }
76 |
77 | actions GitVersion
78 | {
79 | echo "const char program_version[] = \"\\" > $(<)
80 | git log -1 --pretty=format:%h >> $(<)
81 | echo "\";" >> $(<)
82 | }
83 |
84 | # GitVersion version.h ;
85 |
86 | rule AvrAsm
87 | {
88 | Depends $(<) : $(>) ;
89 | Depends $(<) : $(<:D) ;
90 | Clean clean : $(<) ;
91 |
92 | CCHDRS on $(<) = [ on $(<) FIncludes $(HDRS) ] ;
93 | CCDEFS on $(<) = [ on $(<) FDefines $(DEFINES) ] ;
94 | }
95 |
96 | actions AvrAsm
97 | {
98 | $(AVR_AS) $(ASFLAGS) -o $(<) $(>)
99 | }
100 |
101 | rule AvrCc
102 | {
103 | Depends $(<) : $(>) ;
104 | Depends $(<) : $(<:D) ;
105 | Clean clean : $(<) ;
106 |
107 | CCHDRS on $(<) = [ on $(<) FIncludes $(HDRS) ] ;
108 | CCDEFS on $(<) = [ on $(<) FDefines $(DEFINES) ] ;
109 | }
110 |
111 | actions AvrCc
112 | {
113 | $(AVR_CC) -c -o $(<) $(CCHDRS) $(CCDEFS) $(CFLAGS) $(>)
114 | }
115 |
116 | rule AvrC++
117 | {
118 | Depends $(<) : $(>) ;
119 | Depends $(<) : $(<:D) ;
120 | Clean clean : $(<) ;
121 |
122 | CCHDRS on $(<) = [ on $(<) FIncludes $(HDRS) ] ;
123 | CCDEFS on $(<) = [ on $(<) FDefines $(DEFINES) ] ;
124 | }
125 |
126 | actions AvrC++
127 | {
128 | $(AVR_CXX) -c -o $(<) $(CCHDRS) $(CCDEFS) $(CXXFLAGS) $(>)
129 | }
130 |
131 | rule AvrAsmFromC++
132 | {
133 | Depends $(<) : $(>) ;
134 | Depends $(<) : $(<:D) ;
135 | Clean clean : $(<) ;
136 |
137 | CCHDRS on $(<) = [ on $(<) FIncludes $(HDRS) ] ;
138 | CCDEFS on $(<) = [ on $(<) FDefines $(DEFINES) ] ;
139 | }
140 |
141 | actions AvrAsmFromC++
142 | {
143 | $(AVR_CXX) -S -fverbose-asm -o $(<) $(CCHDRS) $(CCDEFS) $(CXXFLAGS) $(>)
144 | }
145 |
146 | rule Pde
147 | {
148 | Depends $(<) : $(>) ;
149 | Depends $(<) : $(<:D) ;
150 | Clean clean : $(<) ;
151 | }
152 |
153 | actions Pde
154 | {
155 | echo "#include " > $(<)
156 | echo "#line 1 \"$(>)\"" >> $(<)
157 | cat $(>) >> $(<)
158 | }
159 |
160 | rule AvrPde
161 | {
162 | local _CPP = $(OUT_DIR)/$(_I:B).cpp ;
163 | Pde $(_CPP) : $(>) ;
164 | AvrC++ $(<) : $(_CPP) ;
165 | }
166 |
167 | rule AvrObject
168 | {
169 | switch $(>:S)
170 | {
171 | case .S : AvrAsm $(<) : $(>) ;
172 | case .c : AvrCc $(<) : $(>) ;
173 | case .cpp : AvrC++ $(<) : $(>) ;
174 | case .pde : AvrPde $(<) : $(>) ;
175 | }
176 | }
177 |
178 | rule AvrObjects
179 | {
180 | for _I in $(<)
181 | {
182 | AvrObject $(OUT_DIR)/$(_I:B).o : $(_I) ;
183 | }
184 | }
185 |
186 | rule AvrMainFromObjects
187 | {
188 | Depends $(<) : $(>) ;
189 | Depends $(<) : $(<:D) ;
190 | MkDir $(<:D) ;
191 | Depends all : $(<) ;
192 | Clean clean : $(<) ;
193 | }
194 |
195 | actions AvrMainFromObjects
196 | {
197 | $(AVR_LD) $(LDFLAGS) -o $(<) $(>)
198 | }
199 |
200 | rule AvrMain
201 | {
202 | AvrMainFromObjects $(<) : $(OUT_DIR)/$(>:B).o ;
203 | AvrObjects $(>) ;
204 | }
205 |
206 | rule AvrHex
207 | {
208 | Depends $(<) : $(>) ;
209 | Depends $(<) : $(<:D) ;
210 | Depends hex : $(<) ;
211 | Clean clean : $(<) ;
212 | }
213 |
214 | actions AvrHex
215 | {
216 | $(AVR_OBJCOPY) -O ihex -R .eeprom $(>) $(<)
217 | }
218 |
219 | rule AvrUpload
220 | {
221 | Depends $(1) : $(2) ;
222 | Depends $(2) : $(3) ;
223 | NotFile $(1) ;
224 | Always $(1) ;
225 | Always $(2) ;
226 | AvrUploadAction $(2) : $(3) ;
227 | }
228 |
229 | actions AvrUploadAction
230 | {
231 | $(AVRDUDE) $(AVRDUDE_FLAGS) -P $(<) $(AVRDUDE_WRITE_FLASH) -U flash:w:$(>):i
232 | }
233 |
234 | AvrMain $(OUT).elf : $(CORE_MODULES) $(LIB_MODULES) $(PROJECT_MODULES)
235 | AvrHex $(OUT).hex : $(OUT).elf ;
236 |
237 | AvrUpload p6 : /dev/tty.usbserial-A600eHIs : $(OUT).hex ;
238 | AvrUpload p4 : /dev/tty.usbserial-A40081RP : $(OUT).hex ;
239 | AvrUpload p9 : /dev/tty.usbserial-A9007LmI : $(OUT).hex ;
240 |
241 | #
242 | # Native
243 | #
244 |
245 | OUT_DIR_NATIVE = out_native ;
246 | OUT_NATIVE = $(OUT_DIR_NATIVE)/$(PROJECT_NAME) ;
247 | NATIVE_CORE = $(SKETCH_DIR)/hardware/native ;
248 | HDRS = $(NATIVE_CORE) $(HDRS) ;
249 | NATIVE_CORE_MODULES = [ GLOB $(NATIVE_CORE) : *.c *.cpp ] ;
250 | NATIVE_MODULES = ;
251 | DEFINES += NATIVE ;
252 |
253 | rule NativePde
254 | {
255 | local _CPP = $(OUT_DIR_NATIVE)/$(_I:B).cpp ;
256 | Pde $(_CPP) : $(>) ;
257 | C++ $(<) : $(_CPP) ;
258 | }
259 |
260 | rule UserObject
261 | {
262 | switch $(>)
263 | {
264 | case *.pde : NativePde $(<) : $(>) ;
265 | }
266 | }
267 |
268 | rule Objects
269 | {
270 | for _I in $(<)
271 | {
272 | local _O = $(OUT_DIR_NATIVE)/$(_I:B).o ;
273 | Object $(_O) : $(_I) ;
274 | }
275 | }
276 |
277 | rule Main
278 | {
279 | MainFromObjects $(<) : $(OUT_DIR_NATIVE)/$(>:B).o ;
280 | Objects $(>) ;
281 | }
282 |
283 | actions C++
284 | {
285 | c++ -c -o $(<) $(CCHDRS) $(CCDEFS) $(>)
286 | }
287 |
288 | actions Link
289 | {
290 | c++ -o $(<) $(>)
291 | }
292 |
293 |
294 |
295 | MkDir $(OUT_DIR_NATIVE) ;
296 | Depends $(OUT_NATIVE) : $(OUT_DIR_NATIVE) ;
297 | Main $(OUT_NATIVE) : $(NATIVE_CORE_MODULES) $(NATIVE_MODULES) $(LIB_MODULES) $(PROJECT_MODULES) ;
298 |
299 | Depends native : $(OUT_NATIVE) ;
300 |
301 |
--------------------------------------------------------------------------------
/Arduino Code/RF24-master/tests/native/pingpair_irq.pde:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2011 James Coliz, Jr.
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 | * Interrupt-driven test for native target
11 | *
12 | * This example is the friendliest for the native target because it doesn't do
13 | * any polling. Made a slight change to call done() at the end of setup.
14 | */
15 |
16 | #include
17 | #include "nRF24L01.h"
18 | #include "RF24.h"
19 | #include "printf.h"
20 |
21 | //
22 | // Hardware configuration
23 | //
24 |
25 | // Set up nRF24L01 radio on SPI bus plus pins 8 & 9
26 |
27 | RF24 radio(8,9);
28 |
29 | // sets the role of this unit in hardware. Connect to GND to be the 'pong' receiver
30 | // Leave open to be the 'ping' transmitter
31 | const short role_pin = 7;
32 |
33 | //
34 | // Topology
35 | //
36 |
37 | // Single radio pipe address for the 2 nodes to communicate.
38 | const uint64_t pipe = 0xE8E8F0F0E1LL;
39 |
40 | //
41 | // Role management
42 | //
43 | // Set up role. This sketch uses the same software for all the nodes in this
44 | // system. Doing so greatly simplifies testing. The hardware itself specifies
45 | // which node it is.
46 | //
47 | // This is done through the role_pin
48 | //
49 |
50 | // The various roles supported by this sketch
51 | typedef enum { role_sender = 1, role_receiver } role_e;
52 |
53 | // The debug-friendly names of those roles
54 | const char* role_friendly_name[] = { "invalid", "Sender", "Receiver"};
55 |
56 | // The role of the current running sketch
57 | role_e role;
58 |
59 | // Interrupt handler, check the radio because we got an IRQ
60 | void check_radio(void);
61 |
62 | void setup(void)
63 | {
64 | //
65 | // Role
66 | //
67 |
68 | // set up the role pin
69 | pinMode(role_pin, INPUT);
70 | digitalWrite(role_pin,HIGH);
71 | delay(20); // Just to get a solid reading on the role pin
72 |
73 | // read the address pin, establish our role
74 | if ( digitalRead(role_pin) )
75 | role = role_sender;
76 | else
77 | role = role_receiver;
78 |
79 | //
80 | // Print preamble
81 | //
82 |
83 | Serial.begin(57600);
84 | printf_begin();
85 | printf("\n\rRF24/examples/pingpair_irq/\n\r");
86 | printf("ROLE: %s\n\r",role_friendly_name[role]);
87 |
88 | //
89 | // Setup and configure rf radio
90 | //
91 |
92 | radio.begin();
93 |
94 | // We will be using the Ack Payload feature, so please enable it
95 | radio.enableAckPayload();
96 |
97 | //
98 | // Open pipes to other nodes for communication
99 | //
100 |
101 | // This simple sketch opens a single pipe for these two nodes to communicate
102 | // back and forth. One listens on it, the other talks to it.
103 |
104 | if ( role == role_sender )
105 | {
106 | radio.openWritingPipe(pipe);
107 | }
108 | else
109 | {
110 | radio.openReadingPipe(1,pipe);
111 | }
112 |
113 | //
114 | // Start listening
115 | //
116 |
117 | if ( role == role_receiver )
118 | radio.startListening();
119 |
120 | //
121 | // Dump the configuration of the rf unit for debugging
122 | //
123 |
124 | radio.printDetails();
125 |
126 | //
127 | // Attach interrupt handler to interrupt #0 (using pin 2)
128 | // on BOTH the sender and receiver
129 | //
130 |
131 | attachInterrupt(0, check_radio, FALLING);
132 |
133 | //
134 | // On the native target, this is as far as we get
135 | //
136 | #if NATIVE
137 | done();
138 | #endif
139 | }
140 |
141 | static uint32_t message_count = 0;
142 |
143 | void loop(void)
144 | {
145 | //
146 | // Sender role. Repeatedly send the current time
147 | //
148 |
149 | if (role == role_sender)
150 | {
151 | // Take the time, and send it.
152 | unsigned long time = millis();
153 | printf("Now sending %lu\n\r",time);
154 | radio.startWrite( &time, sizeof(unsigned long) );
155 |
156 | // Try again soon
157 | delay(2000);
158 | }
159 |
160 | //
161 | // Receiver role: Does nothing! All the work is in IRQ
162 | //
163 |
164 | }
165 |
166 | void check_radio(void)
167 | {
168 | // What happened?
169 | bool tx,fail,rx;
170 | radio.whatHappened(tx,fail,rx);
171 |
172 | // Have we successfully transmitted?
173 | if ( tx )
174 | {
175 | if ( role == role_sender )
176 | printf("Send:OK\n\r");
177 |
178 | if ( role == role_receiver )
179 | printf("Ack Payload:Sent\n\r");
180 | }
181 |
182 | // Have we failed to transmit?
183 | if ( fail )
184 | {
185 | if ( role == role_sender )
186 | printf("Send:Failed\n\r");
187 |
188 | if ( role == role_receiver )
189 | printf("Ack Payload:Failed\n\r");
190 | }
191 |
192 | // Transmitter can power down for now, because
193 | // the transmission is done.
194 | if ( ( tx || fail ) && ( role == role_sender ) )
195 | radio.powerDown();
196 |
197 | // Did we receive a message?
198 | if ( rx )
199 | {
200 | // If we're the sender, we've received an ack payload
201 | if ( role == role_sender )
202 | {
203 | radio.read(&message_count,sizeof(message_count));
204 | printf("Ack:%lu\n\r",(unsigned long)message_count);
205 | }
206 |
207 | // If we're the receiver, we've received a time message
208 | if ( role == role_receiver )
209 | {
210 | // Get this payload and dump it
211 | static unsigned long got_time;
212 | radio.read( &got_time, sizeof(got_time) );
213 | printf("Got payload %lu\n\r",got_time);
214 |
215 | // Add an ack packet for the next time around. This is a simple
216 | // packet counter
217 | radio.writeAckPayload( 1, &message_count, sizeof(message_count) );
218 | ++message_count;
219 | }
220 | }
221 | }
222 |
223 | // vim:ai:cin:sts=2 sw=2 ft=cpp
224 |
--------------------------------------------------------------------------------
/Arduino Code/RF24-master/tests/native/printf.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2011 James Coliz, Jr.
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 printf.h
11 | *
12 | * Setup necessary to direct stdout to the Arduino Serial library, which
13 | * enables 'printf'
14 | */
15 |
16 | #ifndef __PRINTF_H__
17 | #define __PRINTF_H__
18 |
19 | #include "WProgram.h"
20 |
21 | int serial_putc( char c, FILE * )
22 | {
23 | Serial.write( c );
24 |
25 | return c;
26 | }
27 |
28 | void printf_begin(void)
29 | {
30 | fdevopen( &serial_putc, 0 );
31 | }
32 |
33 | #endif // __PRINTF_H__
34 |
--------------------------------------------------------------------------------
/Arduino Code/RF24-master/tests/pingpair_blocking/Jamfile:
--------------------------------------------------------------------------------
1 | # (1) Project Information
2 |
3 | PROJECT_LIBS = SPI RF24 ;
4 | PROJECT_DIRS = $(PWD) ;
5 |
6 | # (2) Board Information
7 |
8 | UPLOAD_PROTOCOL ?= arduino ;
9 | UPLOAD_SPEED ?= 115200 ;
10 | MCU ?= atmega328p ;
11 | F_CPU ?= 16000000 ;
12 | CORE ?= arduino ;
13 | VARIANT ?= standard ;
14 | ARDUINO_VERSION ?= 100 ;
15 |
16 | # (3) USB Ports
17 |
18 | PORTS = p4 p6 p9 u0 u1 u2 ;
19 | PORT_p6 = /dev/tty.usbserial-A600eHIs ;
20 | PORT_p4 = /dev/tty.usbserial-A40081RP ;
21 | PORT_p9 = /dev/tty.usbserial-A9007LmI ;
22 | PORT_u0 = /dev/ttyUSB0 ;
23 | PORT_u1 = /dev/ttyUSB1 ;
24 | PORT_u2 = /dev/ttyUSB2 ;
25 |
26 | # (4) Location of AVR tools
27 | #
28 | # This configuration assumes using avr-tools that were obtained separate from the Arduino
29 | # distribution.
30 |
31 | if $(OS) = MACOSX
32 | {
33 | AVR_BIN ?= /usr/local/avrtools/bin ;
34 | AVR_ETC = /usr/local/avrtools/etc ;
35 | AVR_INCLUDE = /usr/local/avrtools/include ;
36 | }
37 | else
38 | {
39 | AVR_BIN ?= /usr/bin ;
40 | AVR_INCLUDE = /usr/lib/avr/include ;
41 | AVR_ETC = /etc ;
42 | }
43 |
44 | # (5) Directories where Arduino core and libraries are located
45 |
46 | ARDUINO_DIR ?= /opt/Arduino ;
47 | ARDUINO_CORE = $(ARDUINO_DIR)/hardware/arduino/cores/$(CORE) $(ARDUINO_DIR)/hardware/arduino/variants/$(VARIANT) ;
48 | ARDUINO_LIB = $(ARDUINO_DIR)/libraries ;
49 | SKETCH_LIB = $(HOME)/Source/Arduino/libraries ;
50 |
51 | #
52 | # --------------------------------------------------
53 | # Below this line usually never needs to be modified
54 | #
55 |
56 | # Tool locations
57 |
58 | CC = $(AVR_BIN)/avr-gcc ;
59 | C++ = $(AVR_BIN)/avr-g++ ;
60 | LINK = $(AVR_BIN)/avr-gcc ;
61 | AR = $(AVR_BIN)/avr-ar rcs ;
62 | RANLIB = ;
63 | OBJCOPY = $(AVR_BIN)/avr-objcopy ;
64 | AVRDUDE ?= $(AVR_BIN)/avrdude ;
65 |
66 | # Flags
67 |
68 | DEFINES += F_CPU=$(F_CPU)L ARDUINO=$(ARDUINO_VERSION) VERSION_H ;
69 | OPTIM = -Os ;
70 | CCFLAGS = -Wall -Wextra -Wno-strict-aliasing -mmcu=$(MCU) -ffunction-sections -fdata-sections ;
71 | C++FLAGS = $(CCFLAGS) -fno-exceptions -fno-strict-aliasing ;
72 | LINKFLAGS = $(OPTIM) -lm -Wl,--gc-sections -mmcu=$(MCU) ;
73 | AVRDUDEFLAGS = -V -F -D -C $(AVR_ETC)/avrdude.conf -p $(MCU) -c $(UPLOAD_PROTOCOL) -b $(UPLOAD_SPEED) ;
74 |
75 | # Search everywhere for headers
76 |
77 | HDRS = $(PROJECT_DIRS) $(AVR_INCLUDE) $(ARDUINO_CORE) $(ARDUINO_LIB)/$(PROJECT_LIBS) $(ARDUINO_LIB)/$(PROJECT_LIBS)/utility $(SKETCH_LIB)/$(PROJECT_LIBS) ;
78 |
79 | # Output locations
80 |
81 | LOCATE_TARGET = $(F_CPU) ;
82 | LOCATE_SOURCE = $(F_CPU) ;
83 |
84 | #
85 | # Custom rules
86 | #
87 |
88 | rule GitVersion
89 | {
90 | Always $(<) ;
91 | Depends all : $(<) ;
92 | }
93 |
94 | actions GitVersion
95 | {
96 | echo "const char program_version[] = \"\\" > $(<)
97 | git log -1 --pretty=format:%h >> $(<)
98 | echo "\";" >> $(<)
99 | }
100 |
101 | GitVersion version.h ;
102 |
103 | rule Pde
104 | {
105 | Depends $(<) : $(>) ;
106 | MakeLocate $(<) : $(LOCATE_SOURCE) ;
107 | Clean clean : $(<) ;
108 | }
109 |
110 | if ( $(ARDUINO_VERSION) < 100 )
111 | {
112 | ARDUINO_H = WProgram.h ;
113 | }
114 | else
115 | {
116 | ARDUINO_H = Arduino.h ;
117 | }
118 |
119 | actions Pde
120 | {
121 | echo "#include <$(ARDUINO_H)>" > $(<)
122 | echo "#line 1 \"$(>)\"" >> $(<)
123 | cat $(>) >> $(<)
124 | }
125 |
126 | rule C++Pde
127 | {
128 | local _CPP = $(>:B).cpp ;
129 | Pde $(_CPP) : $(>) ;
130 | C++ $(<) : $(_CPP) ;
131 | }
132 |
133 | rule UserObject
134 | {
135 | switch $(>:S)
136 | {
137 | case .ino : C++Pde $(<) : $(>) ;
138 | case .pde : C++Pde $(<) : $(>) ;
139 | }
140 | }
141 |
142 | rule Objects
143 | {
144 | local _i ;
145 |
146 | for _i in [ FGristFiles $(<) ]
147 | {
148 | local _b = $(_i:B)$(SUFOBJ) ;
149 | local _o = $(_b:G=$(SOURCE_GRIST:E)) ;
150 | Object $(_o) : $(_i) ;
151 | Depends obj : $(_o) ;
152 | }
153 | }
154 |
155 | rule Library
156 | {
157 | LibraryFromObjects $(<) : $(>:B)$(SUFOBJ) ;
158 | Objects $(>) ;
159 | }
160 |
161 | rule Main
162 | {
163 | MainFromObjects $(<) : $(>:B)$(SUFOBJ) ;
164 | Objects $(>) ;
165 | }
166 |
167 | rule Hex
168 | {
169 | Depends $(<) : $(>) ;
170 | MakeLocate $(<) : $(LOCATE_TARGET) ;
171 | Depends hex : $(<) ;
172 | Clean clean : $(<) ;
173 | }
174 |
175 | actions Hex
176 | {
177 | $(OBJCOPY) -O ihex -R .eeprom $(>) $(<)
178 | }
179 |
180 | rule Upload
181 | {
182 | Depends $(1) : $(2) ;
183 | Depends $(2) : $(3) ;
184 | NotFile $(1) ;
185 | Always $(1) ;
186 | Always $(2) ;
187 | UploadAction $(2) : $(3) ;
188 | }
189 |
190 | actions UploadAction
191 | {
192 | $(AVRDUDE) $(AVRDUDEFLAGS) -P $(<) $(AVRDUDE_WRITE_FLASH) -U flash:w:$(>):i
193 | }
194 |
195 | rule Arduino
196 | {
197 | LINKFLAGS on $(<) = $(LINKFLAGS) -Wl,-Map=$(LOCATE_TARGET)/$(<:B).map ;
198 | Main $(<) : $(>) ;
199 | LinkLibraries $(<) : core libs ;
200 | Hex $(<:B).hex : $(<) ;
201 | for _p in $(PORTS)
202 | {
203 | Upload $(_p) : $(PORT_$(_p)) : $(<:B).hex ;
204 | }
205 | }
206 |
207 | #
208 | # Targets
209 | #
210 |
211 | # Grab everything from the core directory
212 | Library core : [ GLOB $(ARDUINO_CORE) : *.c *.cpp ] ;
213 |
214 | # Grab everything from libraries. To avoid this "grab everything" behaviour, you
215 | # can specify specific modules to pick up in PROJECT_MODULES
216 | Library libs : [ GLOB $(ARDUINO_LIB)/$(PROJECT_LIBS) $(ARDUINO_LIB)/$(PROJECT_LIBS)/utility $(SKETCH_LIB)/$(PROJECT_LIBS) : *.cpp *.c ] ;
217 |
218 | # Main output executable
219 | Arduino $(PWD:B).elf : $(PROJECT_MODULES) [ GLOB $(PROJECT_DIRS) : *.c *.cpp *.pde *.ino ] ;
220 |
--------------------------------------------------------------------------------
/Arduino Code/RF24-master/tests/pingpair_blocking/pingpair_blocking.pde:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2011 James Coliz, Jr.
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 | #include
10 | #include "nRF24L01.h"
11 | #include "RF24.h"
12 | #include "printf.h"
13 |
14 | //
15 | // Test version of RF24, exposes some protected interface
16 | //
17 |
18 | class RF24Test: public RF24
19 | {
20 | public: RF24Test(int a, int b): RF24(a,b) {}
21 | };
22 |
23 |
24 | //
25 | // Hardware configuration
26 | //
27 |
28 | // Set up nRF24L01 radio on SPI bus plus pins 8 & 9
29 |
30 | RF24Test radio(8,9);
31 |
32 | // sets the role of this unit in hardware. Connect to GND to be the 'pong' receiver
33 | // Leave open to be the 'ping' transmitter
34 | const int role_pin = 7;
35 |
36 | //
37 | // Topology
38 | //
39 |
40 | // Radio pipe addresses for the 2 nodes to communicate.
41 | const uint64_t pipes[2] = { 0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL };
42 |
43 | //
44 | // Role management
45 | //
46 | // Set up role. This sketch uses the same software for all the nodes
47 | // in this system. Doing so greatly simplifies testing. The hardware itself specifies
48 | // which node it is.
49 | //
50 | // This is done through the role_pin
51 | //
52 |
53 | // The various roles supported by this sketch
54 | typedef enum { role_ping_out = 1, role_pong_back } role_e;
55 |
56 | // The debug-friendly names of those roles
57 | const char* role_friendly_name[] = { "invalid", "Ping out", "Pong back"};
58 |
59 | // The role of the current running sketch
60 | role_e role;
61 |
62 | //
63 | // Test state
64 | //
65 |
66 | bool done; //*< Are we done with the test? */
67 | bool passed; //*< Have we passed the test? */
68 | bool notified; //*< Have we notified the user we're done? */
69 | const int num_needed = 10; //*< How many success/failures until we're done? */
70 | int receives_remaining = num_needed; //*< How many ack packets until we declare victory? */
71 | int failures_remaining = num_needed; //*< How many more failed sends until we declare failure? */
72 | const int interval = 100; //*< ms to wait between sends */
73 |
74 | char configuration = '1'; //*< Configuration key, one char sent in by the test framework to tell us how to configure, this is the default */
75 |
76 | void one_ok(void)
77 | {
78 | // Have we received enough yet?
79 | if ( ! --receives_remaining )
80 | {
81 | done = true;
82 | passed = true;
83 | }
84 | }
85 |
86 | void one_failed(void)
87 | {
88 | // Have we failed enough yet?
89 | if ( ! --failures_remaining )
90 | {
91 | done = true;
92 | passed = false;
93 | }
94 | }
95 |
96 | void setup(void)
97 | {
98 | //
99 | // Role
100 | //
101 |
102 | // set up the role pin
103 | pinMode(role_pin, INPUT);
104 | digitalWrite(role_pin,HIGH);
105 | delay(20); // Just to get a solid reading on the role pin
106 |
107 | // read the address pin, establish our role
108 | if ( digitalRead(role_pin) )
109 | role = role_ping_out;
110 | else
111 | role = role_pong_back;
112 |
113 | //
114 | // Print preamble
115 | //
116 |
117 | Serial.begin(57600);
118 | printf_begin();
119 | printf("\n\rRF24/tests/pingpair_blocking/\n\r");
120 | printf("ROLE: %s\n\r",role_friendly_name[role]);
121 |
122 | //
123 | // get test config
124 | //
125 |
126 | printf("+READY press any key to start\n\r\n\r");
127 |
128 | while (! Serial.available() ) {}
129 | configuration = Serial.read();
130 | printf("Configuration\t = %c\n\r",configuration);
131 |
132 | //
133 | // Setup and configure rf radio
134 | //
135 |
136 | radio.begin();
137 |
138 | //
139 | // Open pipes to other nodes for communication
140 | //
141 |
142 | // This simple sketch opens two pipes for these two nodes to communicate
143 | // back and forth.
144 | // Open 'our' pipe for writing
145 | // Open the 'other' pipe for reading, in position #1 (we can have up to 5 pipes open for reading)
146 |
147 | if ( role == role_ping_out )
148 | {
149 | radio.openWritingPipe(pipes[0]);
150 | radio.openReadingPipe(1,pipes[1]);
151 | }
152 | else
153 | {
154 | radio.openWritingPipe(pipes[1]);
155 | radio.openReadingPipe(1,pipes[0]);
156 | }
157 |
158 | //
159 | // Start listening
160 | //
161 |
162 | radio.startListening();
163 |
164 | //
165 | // Dump the configuration of the rf unit for debugging
166 | //
167 |
168 | radio.printDetails();
169 |
170 | if ( role == role_pong_back )
171 | printf("\n\r+OK ");
172 | }
173 |
174 | void loop(void)
175 | {
176 | //
177 | // Ping out role. Repeatedly send the current time
178 | //
179 |
180 | if (role == role_ping_out)
181 | {
182 | // First, stop listening so we can talk.
183 | radio.stopListening();
184 |
185 | // Take the time, and send it. This will block until complete
186 | unsigned long time = millis();
187 | printf("Now sending %lu...",time);
188 | radio.write( &time, sizeof(unsigned long) );
189 |
190 | // Now, continue listening
191 | radio.startListening();
192 |
193 | // Wait here until we get a response, or timeout (250ms)
194 | unsigned long started_waiting_at = millis();
195 | bool timeout = false;
196 | while ( ! radio.available() && ! timeout )
197 | if (millis() - started_waiting_at > 200 )
198 | timeout = true;
199 |
200 | // Describe the results
201 | if ( timeout )
202 | {
203 | printf("Failed, response timed out.\n\r");
204 | one_failed();
205 | }
206 | else
207 | {
208 | // Grab the response, compare, and send to debugging spew
209 | unsigned long got_time;
210 | radio.read( &got_time, sizeof(unsigned long) );
211 |
212 | // Spew it
213 | printf("Got response %lu, round-trip delay: %lu\n\r",got_time,millis()-got_time);
214 | one_ok();
215 | }
216 |
217 | // Try again later
218 | delay(250);
219 | }
220 |
221 | //
222 | // Pong back role. Receive each packet, dump it out, and send it back
223 | //
224 |
225 | if ( role == role_pong_back )
226 | {
227 | // if there is data ready
228 | if ( radio.available() )
229 | {
230 | // Dump the payloads until we've gotten everything
231 | unsigned long got_time;
232 | bool done = false;
233 | while (!done)
234 | {
235 | // Fetch the payload, and see if this was the last one.
236 | done = radio.read( &got_time, sizeof(unsigned long) );
237 |
238 | // Spew it
239 | printf("Got payload %lu...",got_time);
240 |
241 | // Delay just a little bit to let the other unit
242 | // make the transition to receiver
243 | delay(20);
244 | }
245 |
246 | // First, stop listening so we can talk
247 | radio.stopListening();
248 |
249 | // Send the final one back.
250 | radio.write( &got_time, sizeof(unsigned long) );
251 | printf("Sent response.\n\r");
252 |
253 | // Now, resume listening so we catch the next packets.
254 | radio.startListening();
255 |
256 | }
257 | }
258 |
259 | //
260 | // Stop the test if we're done and report results
261 | //
262 | if ( done && ! notified )
263 | {
264 | notified = true;
265 |
266 | printf("\n\r+OK ");
267 | if ( passed )
268 | printf("PASS\n\r\n\r");
269 | else
270 | printf("FAIL\n\r\n\r");
271 | }
272 | }
273 | // vim:cin:ai:sts=2 sw=2 ft=cpp
274 |
--------------------------------------------------------------------------------
/Arduino Code/RF24-master/tests/pingpair_blocking/printf.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2011 J. Coliz
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 printf.h
11 | *
12 | * Setup necessary to direct stdout to the Arduino Serial library, which
13 | * enables 'printf'
14 | */
15 |
16 | #ifndef __PRINTF_H__
17 | #define __PRINTF_H__
18 |
19 | #ifdef ARDUINO
20 |
21 | int serial_putc( char c, FILE * )
22 | {
23 | Serial.write( c );
24 |
25 | return c;
26 | }
27 |
28 | void printf_begin(void)
29 | {
30 | fdevopen( &serial_putc, 0 );
31 | }
32 |
33 | #else
34 | #error This example is only for use on Arduino.
35 | #endif // ARDUINO
36 |
37 | #endif // __PRINTF_H__
38 |
--------------------------------------------------------------------------------
/Arduino Code/RF24-master/tests/pingpair_blocking/runtest.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 |
3 | import sys,serial
4 |
5 | def read_until(token):
6 | while 1:
7 | line = ser.readline(None)
8 | sys.stdout.write(line)
9 |
10 | if (line.startswith(token)):
11 | break
12 | return line
13 |
14 |
15 | ser = serial.Serial(sys.argv[1], 57600, timeout=5, dsrdtr=False, rtscts=False)
16 |
17 | read_until("+READY")
18 | ser.write(sys.argv[2])
19 |
20 | line = read_until("+OK")
21 | ser.close()
22 | if (line.find("PASS") != -1):
23 | sys.exit(0)
24 | else:
25 | sys.exit(1)
26 |
--------------------------------------------------------------------------------
/Arduino Code/RF24-master/tests/pingpair_blocking/runtests.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # Connect u0 to receiver, u1 to sender
4 |
5 | jam u0 u1 && expect test.ex
6 |
--------------------------------------------------------------------------------
/Arduino Code/RF24-master/tests/pingpair_blocking/test.ex:
--------------------------------------------------------------------------------
1 | #/usr/bin/expect
2 |
3 | set timeout 100
4 | spawn picocom -b 57600 /dev/ttyUSB0
5 | expect "+READY"
6 | send "1"
7 | expect "+OK"
8 | spawn picocom -b 57600 /dev/ttyUSB1
9 | expect "+READY"
10 | send "1"
11 | expect "+OK"
12 |
--------------------------------------------------------------------------------
/Arduino Code/RF24-master/tests/pingpair_test/Jamfile:
--------------------------------------------------------------------------------
1 | # (1) Project Information
2 |
3 | PROJECT_LIBS = SPI RF24 ;
4 | PROJECT_DIRS = $(PWD) ;
5 |
6 | # (2) Board Information
7 |
8 | UPLOAD_PROTOCOL ?= arduino ;
9 | UPLOAD_SPEED ?= 115200 ;
10 | MCU ?= atmega328p ;
11 | F_CPU ?= 16000000 ;
12 | CORE ?= arduino ;
13 | VARIANT ?= standard ;
14 | ARDUINO_VERSION ?= 100 ;
15 |
16 | # (3) USB Ports
17 |
18 | PORTS = p4 p6 p9 u0 u1 u2 ;
19 | PORT_p6 = /dev/tty.usbserial-A600eHIs ;
20 | PORT_p4 = /dev/tty.usbserial-A40081RP ;
21 | PORT_p9 = /dev/tty.usbserial-A9007LmI ;
22 | PORT_u0 = /dev/ttyUSB0 ;
23 | PORT_u1 = /dev/ttyUSB1 ;
24 | PORT_u2 = /dev/ttyUSB2 ;
25 |
26 | # (4) Location of AVR tools
27 | #
28 | # This configuration assumes using avr-tools that were obtained separate from the Arduino
29 | # distribution.
30 |
31 | if $(OS) = MACOSX
32 | {
33 | AVR_BIN ?= /usr/local/avrtools/bin ;
34 | AVR_ETC = /usr/local/avrtools/etc ;
35 | AVR_INCLUDE = /usr/local/avrtools/include ;
36 | }
37 | else
38 | {
39 | AVR_BIN ?= /usr/bin ;
40 | AVR_INCLUDE = /usr/lib/avr/include ;
41 | AVR_ETC = /etc ;
42 | }
43 |
44 | # (5) Directories where Arduino core and libraries are located
45 |
46 | ARDUINO_DIR ?= /opt/Arduino ;
47 | ARDUINO_CORE = $(ARDUINO_DIR)/hardware/arduino/cores/$(CORE) $(ARDUINO_DIR)/hardware/arduino/variants/$(VARIANT) ;
48 | ARDUINO_LIB = $(ARDUINO_DIR)/libraries ;
49 | SKETCH_LIB = $(HOME)/Source/Arduino/libraries ;
50 |
51 | #
52 | # --------------------------------------------------
53 | # Below this line usually never needs to be modified
54 | #
55 |
56 | # Tool locations
57 |
58 | CC = $(AVR_BIN)/avr-gcc ;
59 | C++ = $(AVR_BIN)/avr-g++ ;
60 | LINK = $(AVR_BIN)/avr-gcc ;
61 | AR = $(AVR_BIN)/avr-ar rcs ;
62 | RANLIB = ;
63 | OBJCOPY = $(AVR_BIN)/avr-objcopy ;
64 | AVRDUDE ?= $(AVR_BIN)/avrdude ;
65 |
66 | # Flags
67 |
68 | DEFINES += F_CPU=$(F_CPU)L ARDUINO=$(ARDUINO_VERSION) VERSION_H ;
69 | OPTIM = -Os ;
70 | CCFLAGS = -Wall -Wextra -Wno-strict-aliasing -mmcu=$(MCU) -ffunction-sections -fdata-sections ;
71 | C++FLAGS = $(CCFLAGS) -fno-exceptions -fno-strict-aliasing ;
72 | LINKFLAGS = $(OPTIM) -lm -Wl,--gc-sections -mmcu=$(MCU) ;
73 | AVRDUDEFLAGS = -V -F -D -C $(AVR_ETC)/avrdude.conf -p $(MCU) -c $(UPLOAD_PROTOCOL) -b $(UPLOAD_SPEED) ;
74 |
75 | # Search everywhere for headers
76 |
77 | HDRS = $(PROJECT_DIRS) $(AVR_INCLUDE) $(ARDUINO_CORE) $(ARDUINO_LIB)/$(PROJECT_LIBS) $(ARDUINO_LIB)/$(PROJECT_LIBS)/utility $(SKETCH_LIB)/$(PROJECT_LIBS) ;
78 |
79 | # Output locations
80 |
81 | LOCATE_TARGET = $(F_CPU) ;
82 | LOCATE_SOURCE = $(F_CPU) ;
83 |
84 | #
85 | # Custom rules
86 | #
87 |
88 | rule GitVersion
89 | {
90 | Always $(<) ;
91 | Depends all : $(<) ;
92 | }
93 |
94 | actions GitVersion
95 | {
96 | echo "const char program_version[] = \"\\" > $(<)
97 | git log -1 --pretty=format:%h >> $(<)
98 | echo "\";" >> $(<)
99 | }
100 |
101 | GitVersion version.h ;
102 |
103 | rule Pde
104 | {
105 | Depends $(<) : $(>) ;
106 | MakeLocate $(<) : $(LOCATE_SOURCE) ;
107 | Clean clean : $(<) ;
108 | }
109 |
110 | if ( $(ARDUINO_VERSION) < 100 )
111 | {
112 | ARDUINO_H = WProgram.h ;
113 | }
114 | else
115 | {
116 | ARDUINO_H = Arduino.h ;
117 | }
118 |
119 | actions Pde
120 | {
121 | echo "#include <$(ARDUINO_H)>" > $(<)
122 | echo "#line 1 \"$(>)\"" >> $(<)
123 | cat $(>) >> $(<)
124 | }
125 |
126 | rule C++Pde
127 | {
128 | local _CPP = $(>:B).cpp ;
129 | Pde $(_CPP) : $(>) ;
130 | C++ $(<) : $(_CPP) ;
131 | }
132 |
133 | rule UserObject
134 | {
135 | switch $(>:S)
136 | {
137 | case .ino : C++Pde $(<) : $(>) ;
138 | case .pde : C++Pde $(<) : $(>) ;
139 | }
140 | }
141 |
142 | rule Objects
143 | {
144 | local _i ;
145 |
146 | for _i in [ FGristFiles $(<) ]
147 | {
148 | local _b = $(_i:B)$(SUFOBJ) ;
149 | local _o = $(_b:G=$(SOURCE_GRIST:E)) ;
150 | Object $(_o) : $(_i) ;
151 | Depends obj : $(_o) ;
152 | }
153 | }
154 |
155 | rule Library
156 | {
157 | LibraryFromObjects $(<) : $(>:B)$(SUFOBJ) ;
158 | Objects $(>) ;
159 | }
160 |
161 | rule Main
162 | {
163 | MainFromObjects $(<) : $(>:B)$(SUFOBJ) ;
164 | Objects $(>) ;
165 | }
166 |
167 | rule Hex
168 | {
169 | Depends $(<) : $(>) ;
170 | MakeLocate $(<) : $(LOCATE_TARGET) ;
171 | Depends hex : $(<) ;
172 | Clean clean : $(<) ;
173 | }
174 |
175 | actions Hex
176 | {
177 | $(OBJCOPY) -O ihex -R .eeprom $(>) $(<)
178 | }
179 |
180 | rule Upload
181 | {
182 | Depends $(1) : $(2) ;
183 | Depends $(2) : $(3) ;
184 | NotFile $(1) ;
185 | Always $(1) ;
186 | Always $(2) ;
187 | UploadAction $(2) : $(3) ;
188 | }
189 |
190 | actions UploadAction
191 | {
192 | $(AVRDUDE) $(AVRDUDEFLAGS) -P $(<) $(AVRDUDE_WRITE_FLASH) -U flash:w:$(>):i
193 | }
194 |
195 | rule Arduino
196 | {
197 | LINKFLAGS on $(<) = $(LINKFLAGS) -Wl,-Map=$(LOCATE_TARGET)/$(<:B).map ;
198 | Main $(<) : $(>) ;
199 | LinkLibraries $(<) : core libs ;
200 | Hex $(<:B).hex : $(<) ;
201 | for _p in $(PORTS)
202 | {
203 | Upload $(_p) : $(PORT_$(_p)) : $(<:B).hex ;
204 | }
205 | }
206 |
207 | #
208 | # Targets
209 | #
210 |
211 | # Grab everything from the core directory
212 | Library core : [ GLOB $(ARDUINO_CORE) : *.c *.cpp ] ;
213 |
214 | # Grab everything from libraries. To avoid this "grab everything" behaviour, you
215 | # can specify specific modules to pick up in PROJECT_MODULES
216 | Library libs : [ GLOB $(ARDUINO_LIB)/$(PROJECT_LIBS) $(ARDUINO_LIB)/$(PROJECT_LIBS)/utility $(SKETCH_LIB)/$(PROJECT_LIBS) : *.cpp *.c ] ;
217 |
218 | # Main output executable
219 | Arduino $(PWD:B).elf : $(PROJECT_MODULES) [ GLOB $(PROJECT_DIRS) : *.c *.cpp *.pde *.ino ] ;
220 |
--------------------------------------------------------------------------------
/Arduino Code/RF24-master/tests/pingpair_test/pingpair_test.pde:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2011 James Coliz, Jr.
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 | * Full test on single RF pair
11 | *
12 | * This sketches uses as many RF24 methods as possible in a single test.
13 | *
14 | * To operate:
15 | * Upload this sketch on two nodes, each with IRQ -> pin 2
16 | * One node needs pin 7 -> GND, the other NC. That's the receiving node
17 | * Monitor the sending node's serial output
18 | * Look for "+OK PASS" or "+OK FAIL"
19 | */
20 |
21 | #include
22 | #include "nRF24L01.h"
23 | #include "RF24.h"
24 | #include "printf.h"
25 |
26 | //
27 | // Hardware configuration
28 | //
29 |
30 | // Set up nRF24L01 radio on SPI bus plus pins 8 & 9
31 |
32 | RF24 radio(8,9);
33 |
34 | // sets the role of this unit in hardware. Connect to GND to be the 'pong' receiver
35 | // Leave open to be the 'ping' transmitter
36 | const short role_pin = 7;
37 |
38 | //
39 | // Topology
40 | //
41 |
42 | // Single radio pipe address for the 2 nodes to communicate.
43 | const uint64_t pipe = 0xE8E8F0F0E1LL;
44 |
45 | //
46 | // Role management
47 | //
48 | // Set up role. This sketch uses the same software for all the nodes in this
49 | // system. Doing so greatly simplifies testing. The hardware itself specifies
50 | // which node it is.
51 | //
52 | // This is done through the role_pin
53 | //
54 |
55 | // The various roles supported by this sketch
56 | typedef enum { role_sender = 1, role_receiver } role_e;
57 |
58 | // The debug-friendly names of those roles
59 | const char* role_friendly_name[] = { "invalid", "Sender", "Receiver"};
60 |
61 | // The role of the current running sketch
62 | role_e role;
63 |
64 | // Interrupt handler, check the radio because we got an IRQ
65 | void check_radio(void);
66 |
67 | //
68 | // Payload
69 | //
70 |
71 | const int min_payload_size = 4;
72 | const int max_payload_size = 32;
73 | int payload_size_increments_by = 2;
74 | int next_payload_size = min_payload_size;
75 |
76 | char receive_payload[max_payload_size+1]; // +1 to allow room for a terminating NULL char
77 |
78 | //
79 | // Test state
80 | //
81 |
82 | bool done; //*< Are we done with the test? */
83 | bool passed; //*< Have we passed the test? */
84 | bool notified; //*< Have we notified the user we're done? */
85 | const int num_needed = 10; //*< How many success/failures until we're done? */
86 | int receives_remaining = num_needed; //*< How many ack packets until we declare victory? */
87 | int failures_remaining = num_needed; //*< How many more failed sends until we declare failure? */
88 | const int interval = 100; //*< ms to wait between sends */
89 |
90 | char configuration = '1'; //*< Configuration key, one char sent in by the test framework to tell us how to configure, this is the default */
91 |
92 | uint8_t pipe_number = 1; // Which pipe to send on.
93 |
94 | void one_ok(void)
95 | {
96 | // Have we received enough yet?
97 | if ( ! --receives_remaining )
98 | {
99 | done = true;
100 | passed = true;
101 | }
102 | }
103 |
104 | void one_failed(void)
105 | {
106 | // Have we failed enough yet?
107 | if ( ! --failures_remaining )
108 | {
109 | done = true;
110 | passed = false;
111 | }
112 | }
113 |
114 | //
115 | // Setup
116 | //
117 |
118 | void setup(void)
119 | {
120 | //
121 | // Role
122 | //
123 |
124 | // set up the role pin
125 | pinMode(role_pin, INPUT);
126 | digitalWrite(role_pin,HIGH);
127 | delay(20); // Just to get a solid reading on the role pin
128 |
129 | // read the address pin, establish our role
130 | if ( digitalRead(role_pin) )
131 | role = role_sender;
132 | else
133 | role = role_receiver;
134 |
135 | //
136 | // Print preamble
137 | //
138 |
139 | Serial.begin(57600);
140 | printf_begin();
141 | printf("\n\rRF24/tests/pingpair_test/\n\r");
142 | printf("ROLE: %s\n\r",role_friendly_name[role]);
143 |
144 | //
145 | // Read configuration from serial
146 | //
147 | // It would be a much better test if this program could accept configuration
148 | // from the serial port. Then it would be possible to run the same test under
149 | // lots of different circumstances.
150 | //
151 | // The idea is that we will print "+READY" at this point. The python script
152 | // will wait for it, and then send down a configuration script that we
153 | // execute here and then run with.
154 | //
155 | // The test controller will need to configure the receiver first, then go run
156 | // the test on the sender.
157 | //
158 |
159 | printf("+READY press any key to start\n\r\n\r");
160 |
161 | while (! Serial.available() ) {}
162 | configuration = Serial.read();
163 | printf("Configuration\t = %c\n\r",configuration);
164 |
165 | //
166 | // Setup and configure rf radio
167 | //
168 |
169 | radio.begin();
170 |
171 | // We will be using the Ack Payload feature, so please enable it
172 | radio.enableAckPayload();
173 |
174 | // Config 2 is special radio config
175 | if (configuration=='2')
176 | {
177 | radio.setCRCLength(RF24_CRC_8);
178 | radio.setDataRate(RF24_250KBPS);
179 | radio.setChannel(10);
180 | }
181 | else
182 | {
183 | //Otherwise, default radio config
184 |
185 | // Optional: Increase CRC length for improved reliability
186 | radio.setCRCLength(RF24_CRC_16);
187 |
188 | // Optional: Decrease data rate for improved reliability
189 | radio.setDataRate(RF24_1MBPS);
190 |
191 | // Optional: Pick a high channel
192 | radio.setChannel(90);
193 | }
194 |
195 | // Config 3 is static payloads only
196 | if (configuration == '3')
197 | {
198 | next_payload_size = 16;
199 | payload_size_increments_by = 0;
200 | radio.setPayloadSize(next_payload_size);
201 | }
202 | else
203 | {
204 | // enable dynamic payloads
205 | radio.enableDynamicPayloads();
206 | }
207 |
208 | // Config 4 tests out a higher pipe ##
209 | if (configuration == '4' && role == role_sender)
210 | {
211 | // Set top 4 bytes of the address in pipe 1
212 | radio.openReadingPipe(1,pipe & 0xFFFFFFFF00ULL);
213 |
214 | // indicate the pipe to use
215 | pipe_number = 5;
216 | }
217 | else if ( role == role_sender )
218 | {
219 | radio.openReadingPipe(5,0);
220 | }
221 |
222 | //
223 | // Open pipes to other nodes for communication
224 | //
225 |
226 | // This simple sketch opens a single pipe for these two nodes to communicate
227 | // back and forth. One listens on it, the other talks to it.
228 |
229 | if ( role == role_sender )
230 | {
231 | radio.openWritingPipe(pipe);
232 | }
233 | else
234 | {
235 | radio.openReadingPipe(pipe_number,pipe);
236 | }
237 |
238 | //
239 | // Start listening
240 | //
241 |
242 | if ( role == role_receiver )
243 | radio.startListening();
244 |
245 | //
246 | // Dump the configuration of the rf unit for debugging
247 | //
248 |
249 | radio.printDetails();
250 |
251 | //
252 | // Attach interrupt handler to interrupt #0 (using pin 2)
253 | // on BOTH the sender and receiver
254 | //
255 |
256 | attachInterrupt(0, check_radio, FALLING);
257 |
258 | if ( role == role_receiver )
259 | printf("\n\r+OK ");
260 | }
261 |
262 | //
263 | // Print buffer
264 | //
265 | // Printing from the interrupt handler is a bad idea, so we print from there
266 | // to this intermediate buffer
267 | //
268 |
269 | char prbuf[1000];
270 | char *prbuf_end = prbuf + sizeof(prbuf);
271 | char *prbuf_in = prbuf;
272 | char *prbuf_out = prbuf;
273 |
274 | //
275 | // Loop
276 | //
277 |
278 | static uint32_t message_count = 0;
279 | static uint32_t last_message_count = 0;
280 |
281 | void loop(void)
282 | {
283 | //
284 | // Sender role. Repeatedly send the current time
285 | //
286 |
287 | if (role == role_sender && !done)
288 | {
289 | // The payload will always be the same, what will change is how much of it we send.
290 | static char send_payload[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ789012";
291 |
292 | // First, stop listening so we can talk.
293 | radio.stopListening();
294 |
295 | // Send it. This will block until complete
296 | printf("\n\rNow sending length %i...",next_payload_size);
297 | radio.startWrite( send_payload, next_payload_size );
298 |
299 | // Update size for next time.
300 | next_payload_size += payload_size_increments_by;
301 | if ( next_payload_size > max_payload_size )
302 | next_payload_size = min_payload_size;
303 |
304 | // Try again soon
305 | delay(interval);
306 |
307 | // Timeout if we have not received anything back ever
308 | if ( ! last_message_count && millis() > interval * 100 )
309 | {
310 | printf("No responses received. Are interrupts connected??\n\r");
311 | done = true;
312 | }
313 | }
314 |
315 | //
316 | // Receiver role: Does nothing! All the work is in IRQ
317 | //
318 |
319 | //
320 | // Spew print buffer
321 | //
322 |
323 | size_t write_length = prbuf_in - prbuf_out;
324 | if ( write_length )
325 | {
326 | Serial.write(reinterpret_cast(prbuf_out),write_length);
327 | prbuf_out += write_length;
328 | }
329 |
330 | //
331 | // Stop the test if we're done and report results
332 | //
333 | if ( done && ! notified )
334 | {
335 | notified = true;
336 |
337 | printf("\n\r+OK ");
338 | if ( passed )
339 | printf("PASS\n\r\n\r");
340 | else
341 | printf("FAIL\n\r\n\r");
342 | }
343 |
344 | }
345 |
346 | void check_radio(void)
347 | {
348 | // What happened?
349 | bool tx,fail,rx;
350 | radio.whatHappened(tx,fail,rx);
351 |
352 | // Have we successfully transmitted?
353 | if ( tx )
354 | {
355 | if ( role == role_sender )
356 | prbuf_in += sprintf(prbuf_in,"Send:OK ");
357 |
358 | if ( role == role_receiver )
359 | prbuf_in += sprintf(prbuf_in,"Ack Payload:Sent\n\r");
360 | }
361 |
362 | // Have we failed to transmit?
363 | if ( fail )
364 | {
365 | if ( role == role_sender )
366 | {
367 | prbuf_in += sprintf(prbuf_in,"Send:Failed ");
368 |
369 | // log status of this line
370 | one_failed();
371 | }
372 |
373 | if ( role == role_receiver )
374 | prbuf_in += sprintf(prbuf_in,"Ack Payload:Failed\n\r");
375 | }
376 |
377 | // Transmitter can power down for now, because
378 | // the transmission is done.
379 | if ( ( tx || fail ) && ( role == role_sender ) )
380 | radio.powerDown();
381 |
382 | // Did we receive a message?
383 | if ( rx )
384 | {
385 | // If we're the sender, we've received an ack payload
386 | if ( role == role_sender )
387 | {
388 | radio.read(&message_count,sizeof(message_count));
389 | prbuf_in += sprintf(prbuf_in,"Ack:%lu ",message_count);
390 |
391 | // is this ack what we were expecting? to account
392 | // for failures, we simply want to make sure we get a
393 | // DIFFERENT ack every time.
394 | if ( ( message_count != last_message_count ) || ( configuration=='3' && message_count == 16 ) )
395 | {
396 | prbuf_in += sprintf(prbuf_in,"OK ");
397 | one_ok();
398 | }
399 | else
400 | {
401 | prbuf_in += sprintf(prbuf_in,"FAILED ");
402 | one_failed();
403 | }
404 | last_message_count = message_count;
405 | }
406 |
407 | // If we're the receiver, we've received a time message
408 | if ( role == role_receiver )
409 | {
410 | // Get this payload and dump it
411 | size_t len = max_payload_size;
412 | memset(receive_payload,0,max_payload_size);
413 |
414 | if ( configuration == '3' )
415 | len = next_payload_size;
416 | else
417 | len = radio.getDynamicPayloadSize();
418 |
419 | radio.read( receive_payload, len );
420 |
421 | // Put a zero at the end for easy printing
422 | receive_payload[len] = 0;
423 |
424 | // Spew it
425 | prbuf_in += sprintf(prbuf_in,"Recv size=%i val=%s len=%u\n\r",len,receive_payload,strlen(receive_payload));
426 |
427 | // Add an ack packet for the next time around.
428 | // Here we will report back how many bytes we got this time.
429 | radio.writeAckPayload( pipe_number, &len, sizeof(len) );
430 | ++message_count;
431 | }
432 | }
433 | }
434 |
435 | // vim:ai:cin:sts=2 sw=2 ft=cpp
436 |
--------------------------------------------------------------------------------
/Arduino Code/RF24-master/tests/pingpair_test/printf.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2011 J. Coliz
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 printf.h
11 | *
12 | * Setup necessary to direct stdout to the Arduino Serial library, which
13 | * enables 'printf'
14 | */
15 |
16 | #ifndef __PRINTF_H__
17 | #define __PRINTF_H__
18 |
19 | #ifdef ARDUINO
20 |
21 | int serial_putc( char c, FILE * )
22 | {
23 | Serial.write( c );
24 |
25 | return c;
26 | }
27 |
28 | void printf_begin(void)
29 | {
30 | fdevopen( &serial_putc, 0 );
31 | }
32 |
33 | #else
34 | #error This example is only for use on Arduino.
35 | #endif // ARDUINO
36 |
37 | #endif // __PRINTF_H__
38 |
--------------------------------------------------------------------------------
/Arduino Code/RF24-master/tests/pingpair_test/runtest.py:
--------------------------------------------------------------------------------
1 | #!/opt/local/bin/python
2 |
3 | import sys,serial
4 |
5 | def read_until(token):
6 | while 1:
7 | line = ser.readline(None,"\r")
8 | sys.stdout.write(line)
9 |
10 | if (line.startswith(token)):
11 | break
12 | return line
13 |
14 |
15 | ser = serial.Serial(sys.argv[1], 57600, timeout=5, dsrdtr=False, rtscts=False)
16 |
17 | read_until("+READY")
18 | ser.write(sys.argv[2])
19 |
20 | line = read_until("+OK")
21 | ser.close()
22 | if (line.find("PASS") != -1):
23 | sys.exit(0)
24 | else:
25 | sys.exit(1)
26 |
--------------------------------------------------------------------------------
/Arduino Code/RF24-master/tests/pingpair_test/runtests.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # Connect u0 to receiver, u0 to sender
4 | # WARNING: Test config 2 only works with PLUS units.
5 |
6 | jam u0 u1 && expect test.ex 1
7 | sleep 1
8 | stty 57600 raw ignbrk hup < /dev/ttyUSB0
9 | sleep 1
10 | stty 57600 raw ignbrk hup < /dev/ttyUSB1
11 | expect test.ex 2
12 | sleep 1
13 | stty 57600 raw ignbrk hup < /dev/ttyUSB0
14 | sleep 1
15 | stty 57600 raw ignbrk hup < /dev/ttyUSB1
16 | expect test.ex 3
17 | sleep 1
18 | stty 57600 raw ignbrk hup < /dev/ttyUSB0
19 | sleep 1
20 | stty 57600 raw ignbrk hup < /dev/ttyUSB1
21 | expect test.ex 4
22 |
--------------------------------------------------------------------------------
/Arduino Code/RF24-master/tests/pingpair_test/test.ex:
--------------------------------------------------------------------------------
1 | #/usr/bin/expect
2 |
3 | set timeout 100
4 | spawn picocom -b 57600 /dev/ttyUSB0
5 | expect "+READY"
6 | send [lindex $argv 0]
7 | expect "+OK"
8 | spawn picocom -b 57600 /dev/ttyUSB1
9 | expect "+READY"
10 | send [lindex $argv 0]
11 | expect "+OK"
12 |
--------------------------------------------------------------------------------
/Arduino Code/RF24-master/wikidoc.xslt:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
=== ===
9 |
10 |
11 |
12 |
13 | ''''
14 |
15 | Parameters:
16 |
17 |
18 |
19 | * '''':
20 |
21 |
22 |
23 |
24 |
25 | Returns:
26 |
27 | *
28 |
29 |
30 | Warning:
31 |
32 |
33 |
34 |
<pre>
</pre>
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/Arduino Code/RGB_DRIVER.ino:
--------------------------------------------------------------------------------
1 | #include "nRF24L01.h"
2 | #include "RF24.h"
3 | #include "RF24_config.h"
4 | #include
5 |
6 | /////////////////////////////-RF24-////////////////////////////////////////
7 | RF24 radio(9, 10); //RF24 pins
8 | const uint64_t pipe = 0xF0F0F0F0E1LL; //ID
9 | unsigned long RGB = 0;
10 | /////////////////////////////////////////////////////////////////////////
11 |
12 | //////////////////////////////-RGB-/////////////////////////////////////////
13 | #define REDPIN 5
14 | #define GREENPIN 6
15 | #define BLUEPIN 3
16 | #define FADESPEED 5 // make this higher to slow down fading
17 | int r, g, b;
18 | int blueMask = 0xFF0000, greenMask = 0xFF00, redMask = 0xFF; //decoding masks
19 | //////////////////////////////////////////////////////////////////////////
20 |
21 |
22 | void setup(void) {
23 |
24 | //Radio module setup
25 | radio.begin();
26 | radio.openReadingPipe(1, pipe);
27 | radio.startListening();
28 |
29 | //RGB pin setup
30 | pinMode(REDPIN, OUTPUT);
31 | pinMode(GREENPIN, OUTPUT);
32 | pinMode(BLUEPIN, OUTPUT);
33 |
34 | //serial Setup
35 | Serial.begin(9600);
36 | Serial.println("Started Listening...");
37 | }
38 |
39 | void loop(void)
40 | {
41 |
42 | if (radio.available()) { //signal recieved
43 |
44 | if ( !radio.read(&RGB, sizeof(unsigned long)) ) {
45 | Serial.println("ACK not received by client.");
46 | }
47 | //Decode RGB value
48 | r = (RGB & 0xFF);
49 | g = ((RGB & 0xFF00) >> 8);
50 | b = ((RGB & 0xFF0000) >> 16);
51 |
52 | //Serial Print
53 | Serial.print("Recieved RGB-value: R= "); Serial.print(r); Serial.print(", G= ");
54 | Serial.print(g); Serial.print(", B= "); Serial.println(b);
55 |
56 | }
57 |
58 | //set RGB pins
59 | analogWrite(REDPIN, r);
60 | analogWrite(GREENPIN, g);
61 | analogWrite(BLUEPIN, b);
62 |
63 | }
64 |
65 | //fade function you can play with
66 | void fade(void) {
67 | // fade from blue to violet
68 | for (r = 0; r < 256; r++) {
69 | analogWrite(REDPIN, r);
70 | delay(FADESPEED);
71 |
72 | }
73 | // fade from violet to red
74 | for (b = 255; b > 0; b--) {
75 | analogWrite(BLUEPIN, b);
76 | delay(FADESPEED);
77 |
78 | }
79 | // fade from red to yellow
80 | for (g = 0; g < 256; g++) {
81 | analogWrite(GREENPIN, g);
82 | delay(FADESPEED);
83 |
84 | }
85 | // fade from yellow to green
86 | for (r = 255; r > 0; r--) {
87 | analogWrite(REDPIN, r);
88 | delay(FADESPEED);
89 |
90 | }
91 | // fade from green to teal
92 | for (b = 0; b < 256; b++) {
93 | analogWrite(BLUEPIN, b);
94 | delay(FADESPEED);
95 |
96 | }
97 | // fade from teal to blue
98 | for (g = 255; g > 0; g--) {
99 | analogWrite(GREENPIN, g);
100 | delay(FADESPEED);
101 | }
102 |
103 | }
104 |
105 |
106 |
--------------------------------------------------------------------------------
/CAD Folder/ArduinoRamtinTibo.par:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tibbis/LED-Strip-HomeKit-Driver/282d0d1f5fd228e966d98aafbd263a5bcd588d2e/CAD Folder/ArduinoRamtinTibo.par
--------------------------------------------------------------------------------
/CAD Folder/ArduinoRamtinTiboLid.par:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tibbis/LED-Strip-HomeKit-Driver/282d0d1f5fd228e966d98aafbd263a5bcd588d2e/CAD Folder/ArduinoRamtinTiboLid.par
--------------------------------------------------------------------------------
/CAD Folder/README.md:
--------------------------------------------------------------------------------
1 | Empty for now
2 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright {yyyy} {name of copyright owner}
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/Pictures/BoxPicture1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tibbis/LED-Strip-HomeKit-Driver/282d0d1f5fd228e966d98aafbd263a5bcd588d2e/Pictures/BoxPicture1.png
--------------------------------------------------------------------------------
/Pictures/BoxPicture2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tibbis/LED-Strip-HomeKit-Driver/282d0d1f5fd228e966d98aafbd263a5bcd588d2e/Pictures/BoxPicture2.png
--------------------------------------------------------------------------------
/Pictures/BoxPicture3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tibbis/LED-Strip-HomeKit-Driver/282d0d1f5fd228e966d98aafbd263a5bcd588d2e/Pictures/BoxPicture3.png
--------------------------------------------------------------------------------
/Pictures/LidPicture1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tibbis/LED-Strip-HomeKit-Driver/282d0d1f5fd228e966d98aafbd263a5bcd588d2e/Pictures/LidPicture1.png
--------------------------------------------------------------------------------
/Pictures/MindMap.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tibbis/LED-Strip-HomeKit-Driver/282d0d1f5fd228e966d98aafbd263a5bcd588d2e/Pictures/MindMap.png
--------------------------------------------------------------------------------
/Pictures/PCB-picture.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tibbis/LED-Strip-HomeKit-Driver/282d0d1f5fd228e966d98aafbd263a5bcd588d2e/Pictures/PCB-picture.png
--------------------------------------------------------------------------------
/Pictures/PCB.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tibbis/LED-Strip-HomeKit-Driver/282d0d1f5fd228e966d98aafbd263a5bcd588d2e/Pictures/PCB.png
--------------------------------------------------------------------------------
/Pictures/RF24-Arduino.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tibbis/LED-Strip-HomeKit-Driver/282d0d1f5fd228e966d98aafbd263a5bcd588d2e/Pictures/RF24-Arduino.png
--------------------------------------------------------------------------------
/Pictures/RF24-RPI.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tibbis/LED-Strip-HomeKit-Driver/282d0d1f5fd228e966d98aafbd263a5bcd588d2e/Pictures/RF24-RPI.png
--------------------------------------------------------------------------------
/Pictures/Schematic.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tibbis/LED-Strip-HomeKit-Driver/282d0d1f5fd228e966d98aafbd263a5bcd588d2e/Pictures/Schematic.png
--------------------------------------------------------------------------------
/Pictures/demo-landscape.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tibbis/LED-Strip-HomeKit-Driver/282d0d1f5fd228e966d98aafbd263a5bcd588d2e/Pictures/demo-landscape.gif
--------------------------------------------------------------------------------
/Pictures/demo.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tibbis/LED-Strip-HomeKit-Driver/282d0d1f5fd228e966d98aafbd263a5bcd588d2e/Pictures/demo.gif
--------------------------------------------------------------------------------