mirror of
https://github.com/digistump/DigistumpArduino.git
synced 2025-09-17 17:32:25 -07:00
switch to setup for Arduino Boards Manager
This commit is contained in:
7
digistump-avr/libraries/RF24/tests/README
Normal file
7
digistump-avr/libraries/RF24/tests/README
Normal file
@@ -0,0 +1,7 @@
|
||||
The sketches in this directory are intended to be checkin tests.
|
||||
No code should be pushed to github without these tests passing.
|
||||
|
||||
See "runtests.sh" script inside each sketch dir. This script is fully compatible with
|
||||
git bisest.
|
||||
|
||||
Note that this requires python and py-serial
|
300
digistump-avr/libraries/RF24/tests/native/Jamfile
Normal file
300
digistump-avr/libraries/RF24/tests/native/Jamfile
Normal file
@@ -0,0 +1,300 @@
|
||||
PROJECT_NAME = $(PWD:B) ;
|
||||
PROJECT_DIR = . ;
|
||||
PROJECT_LIBS = RF24 ;
|
||||
|
||||
OUT_DIR = ojam ;
|
||||
F_CPU = 16000000 ;
|
||||
MCU = atmega328p ;
|
||||
PORTS = /dev/tty.usbserial-A600eHIs /dev/tty.usbserial-A40081RP /dev/tty.usbserial-A9007LmI ;
|
||||
|
||||
UPLOAD_RATE = 57600 ;
|
||||
AVRDUDE_PROTOCOL = stk500v1 ;
|
||||
COM = 33 ;
|
||||
|
||||
# Host-specific overrides for locations
|
||||
if $(OS) = MACOSX
|
||||
{
|
||||
ARDUINO_VERSION = 22 ;
|
||||
OLD_DIR = /opt/arduino-0021 ;
|
||||
AVR_TOOLS_PATH = $(OLD_DIR)/hardware/tools/avr/bin ;
|
||||
AVRDUDECONFIG_PATH = $(OLD_DIR)/hardware/tools/avr/etc ;
|
||||
ARDUINO_DIR = /opt/Arduino ;
|
||||
ARDUINO_AVR = /usr/lib/avr/include ;
|
||||
}
|
||||
|
||||
# Where is everything?
|
||||
ARDUINO_VERSION ?= 22 ;
|
||||
SKETCH_DIR = $(HOME)/Source/Arduino ;
|
||||
AVR_TOOLS_PATH ?= /usr/bin ;
|
||||
ARDUINO_DIR ?= /opt/arduino-00$(ARDUINO_VERSION) ;
|
||||
ARDUINO_AVR ?= $(ARDUINO_DIR)/hardware/tools/avr/avr/include/avr ;
|
||||
AVRDUDECONFIG_PATH ?= $(ARDUINO_DIR)/hardware/tools ;
|
||||
ARDUINO_CORE = $(ARDUINO_DIR)/hardware/arduino/cores/arduino ;
|
||||
ARDUINO_LIB = $(ARDUINO_DIR)/libraries ;
|
||||
SKETCH_LIB = $(SKETCH_DIR)/libraries ;
|
||||
AVR_AS = $(AVR_TOOLS_PATH)/avr-as ;
|
||||
AVR_CC = $(AVR_TOOLS_PATH)/avr-gcc ;
|
||||
AVR_CXX = $(AVR_TOOLS_PATH)/avr-g++ ;
|
||||
AVR_LD = $(AVR_TOOLS_PATH)/avr-gcc ;
|
||||
AVR_OBJCOPY = $(AVR_TOOLS_PATH)/avr-objcopy ;
|
||||
AVRDUDE = $(AVR_TOOLS_PATH)/avrdude ;
|
||||
|
||||
DEFINES = F_CPU=$(F_CPU)L ARDUINO=$(ARDUINO_VERSION) VERSION_H HAL=1 ;
|
||||
CTUNING = -ffunction-sections -fdata-sections ;
|
||||
CXXTUNING = -fno-exceptions -fno-strict-aliasing ;
|
||||
ASFLAGS = -mmcu=$(MCU) ;
|
||||
CFLAGS = -Os -Wall -Wextra $(ASFLAGS) $(CTUNING) ;
|
||||
CXXFLAGS = $(CFLAGS) $(CXXTUNING) ;
|
||||
LDFLAGS = -Os -lm -Wl,--gc-sections -mmcu=atmega328p ;
|
||||
|
||||
# Search everywhere for headers
|
||||
HDRS = $(PROJECT_DIR) $(ARDUINO_AVR) $(ARDUINO_CORE) [ GLOB $(ARDUINO_LIB) $(SKETCH_LIB) : [^.]* ] ;
|
||||
HDRS += [ GLOB $(HDRS) : utility ] ;
|
||||
|
||||
# Grab everything from the core directory
|
||||
CORE_MODULES = [ GLOB $(ARDUINO_CORE) : *.c *.cpp ] ;
|
||||
|
||||
# Grab everything from libraries. To avoid this "grab everything" behaviour, you
|
||||
# can specify specific modules to pick up in PROJECT_MODULES
|
||||
LIB_MODULES = [ GLOB $(ARDUINO_LIB)/$(PROJECT_LIBS) $(ARDUINO_LIB)/$(PROJECT_LIBS)/utility $(SKETCH_LIB)/$(PROJECT_LIBS) : *.cpp *.c ] ;
|
||||
|
||||
# In addition to explicitly-specified program modules, pick up anything from the current
|
||||
# dir.
|
||||
PROJECT_MODULES += [ GLOB $(PROJECT_DIR) : *.c *.cpp *.pde ] ;
|
||||
|
||||
# Shortcut for the out files
|
||||
OUT = $(OUT_DIR)/$(PROJECT_NAME) ;
|
||||
|
||||
# AvrDude setup
|
||||
AVRDUDE_FLAGS = -V -F -D -C $(AVRDUDECONFIG_PATH)/avrdude.conf -p $(MCU) -c $(AVRDUDE_PROTOCOL) -b $(UPLOAD_RATE) ;
|
||||
|
||||
rule GitVersion
|
||||
{
|
||||
Always $(<) ;
|
||||
Depends all : $(<) ;
|
||||
}
|
||||
|
||||
actions GitVersion
|
||||
{
|
||||
echo "const char program_version[] = \"\\" > $(<)
|
||||
git log -1 --pretty=format:%h >> $(<)
|
||||
echo "\";" >> $(<)
|
||||
}
|
||||
|
||||
# GitVersion version.h ;
|
||||
|
||||
rule AvrAsm
|
||||
{
|
||||
Depends $(<) : $(>) ;
|
||||
Depends $(<) : $(<:D) ;
|
||||
Clean clean : $(<) ;
|
||||
|
||||
CCHDRS on $(<) = [ on $(<) FIncludes $(HDRS) ] ;
|
||||
CCDEFS on $(<) = [ on $(<) FDefines $(DEFINES) ] ;
|
||||
}
|
||||
|
||||
actions AvrAsm
|
||||
{
|
||||
$(AVR_AS) $(ASFLAGS) -o $(<) $(>)
|
||||
}
|
||||
|
||||
rule AvrCc
|
||||
{
|
||||
Depends $(<) : $(>) ;
|
||||
Depends $(<) : $(<:D) ;
|
||||
Clean clean : $(<) ;
|
||||
|
||||
CCHDRS on $(<) = [ on $(<) FIncludes $(HDRS) ] ;
|
||||
CCDEFS on $(<) = [ on $(<) FDefines $(DEFINES) ] ;
|
||||
}
|
||||
|
||||
actions AvrCc
|
||||
{
|
||||
$(AVR_CC) -c -o $(<) $(CCHDRS) $(CCDEFS) $(CFLAGS) $(>)
|
||||
}
|
||||
|
||||
rule AvrC++
|
||||
{
|
||||
Depends $(<) : $(>) ;
|
||||
Depends $(<) : $(<:D) ;
|
||||
Clean clean : $(<) ;
|
||||
|
||||
CCHDRS on $(<) = [ on $(<) FIncludes $(HDRS) ] ;
|
||||
CCDEFS on $(<) = [ on $(<) FDefines $(DEFINES) ] ;
|
||||
}
|
||||
|
||||
actions AvrC++
|
||||
{
|
||||
$(AVR_CXX) -c -o $(<) $(CCHDRS) $(CCDEFS) $(CXXFLAGS) $(>)
|
||||
}
|
||||
|
||||
rule AvrAsmFromC++
|
||||
{
|
||||
Depends $(<) : $(>) ;
|
||||
Depends $(<) : $(<:D) ;
|
||||
Clean clean : $(<) ;
|
||||
|
||||
CCHDRS on $(<) = [ on $(<) FIncludes $(HDRS) ] ;
|
||||
CCDEFS on $(<) = [ on $(<) FDefines $(DEFINES) ] ;
|
||||
}
|
||||
|
||||
actions AvrAsmFromC++
|
||||
{
|
||||
$(AVR_CXX) -S -fverbose-asm -o $(<) $(CCHDRS) $(CCDEFS) $(CXXFLAGS) $(>)
|
||||
}
|
||||
|
||||
rule Pde
|
||||
{
|
||||
Depends $(<) : $(>) ;
|
||||
Depends $(<) : $(<:D) ;
|
||||
Clean clean : $(<) ;
|
||||
}
|
||||
|
||||
actions Pde
|
||||
{
|
||||
echo "#include <WProgram.h>" > $(<)
|
||||
echo "#line 1 \"$(>)\"" >> $(<)
|
||||
cat $(>) >> $(<)
|
||||
}
|
||||
|
||||
rule AvrPde
|
||||
{
|
||||
local _CPP = $(OUT_DIR)/$(_I:B).cpp ;
|
||||
Pde $(_CPP) : $(>) ;
|
||||
AvrC++ $(<) : $(_CPP) ;
|
||||
}
|
||||
|
||||
rule AvrObject
|
||||
{
|
||||
switch $(>:S)
|
||||
{
|
||||
case .S : AvrAsm $(<) : $(>) ;
|
||||
case .c : AvrCc $(<) : $(>) ;
|
||||
case .cpp : AvrC++ $(<) : $(>) ;
|
||||
case .pde : AvrPde $(<) : $(>) ;
|
||||
}
|
||||
}
|
||||
|
||||
rule AvrObjects
|
||||
{
|
||||
for _I in $(<)
|
||||
{
|
||||
AvrObject $(OUT_DIR)/$(_I:B).o : $(_I) ;
|
||||
}
|
||||
}
|
||||
|
||||
rule AvrMainFromObjects
|
||||
{
|
||||
Depends $(<) : $(>) ;
|
||||
Depends $(<) : $(<:D) ;
|
||||
MkDir $(<:D) ;
|
||||
Depends all : $(<) ;
|
||||
Clean clean : $(<) ;
|
||||
}
|
||||
|
||||
actions AvrMainFromObjects
|
||||
{
|
||||
$(AVR_LD) $(LDFLAGS) -o $(<) $(>)
|
||||
}
|
||||
|
||||
rule AvrMain
|
||||
{
|
||||
AvrMainFromObjects $(<) : $(OUT_DIR)/$(>:B).o ;
|
||||
AvrObjects $(>) ;
|
||||
}
|
||||
|
||||
rule AvrHex
|
||||
{
|
||||
Depends $(<) : $(>) ;
|
||||
Depends $(<) : $(<:D) ;
|
||||
Depends hex : $(<) ;
|
||||
Clean clean : $(<) ;
|
||||
}
|
||||
|
||||
actions AvrHex
|
||||
{
|
||||
$(AVR_OBJCOPY) -O ihex -R .eeprom $(>) $(<)
|
||||
}
|
||||
|
||||
rule AvrUpload
|
||||
{
|
||||
Depends $(1) : $(2) ;
|
||||
Depends $(2) : $(3) ;
|
||||
NotFile $(1) ;
|
||||
Always $(1) ;
|
||||
Always $(2) ;
|
||||
AvrUploadAction $(2) : $(3) ;
|
||||
}
|
||||
|
||||
actions AvrUploadAction
|
||||
{
|
||||
$(AVRDUDE) $(AVRDUDE_FLAGS) -P $(<) $(AVRDUDE_WRITE_FLASH) -U flash:w:$(>):i
|
||||
}
|
||||
|
||||
AvrMain $(OUT).elf : $(CORE_MODULES) $(LIB_MODULES) $(PROJECT_MODULES)
|
||||
AvrHex $(OUT).hex : $(OUT).elf ;
|
||||
|
||||
AvrUpload p6 : /dev/tty.usbserial-A600eHIs : $(OUT).hex ;
|
||||
AvrUpload p4 : /dev/tty.usbserial-A40081RP : $(OUT).hex ;
|
||||
AvrUpload p9 : /dev/tty.usbserial-A9007LmI : $(OUT).hex ;
|
||||
|
||||
#
|
||||
# Native
|
||||
#
|
||||
|
||||
OUT_DIR_NATIVE = out_native ;
|
||||
OUT_NATIVE = $(OUT_DIR_NATIVE)/$(PROJECT_NAME) ;
|
||||
NATIVE_CORE = $(SKETCH_DIR)/hardware/native ;
|
||||
HDRS = $(NATIVE_CORE) $(HDRS) ;
|
||||
NATIVE_CORE_MODULES = [ GLOB $(NATIVE_CORE) : *.c *.cpp ] ;
|
||||
NATIVE_MODULES = ;
|
||||
DEFINES += NATIVE ;
|
||||
|
||||
rule NativePde
|
||||
{
|
||||
local _CPP = $(OUT_DIR_NATIVE)/$(_I:B).cpp ;
|
||||
Pde $(_CPP) : $(>) ;
|
||||
C++ $(<) : $(_CPP) ;
|
||||
}
|
||||
|
||||
rule UserObject
|
||||
{
|
||||
switch $(>)
|
||||
{
|
||||
case *.pde : NativePde $(<) : $(>) ;
|
||||
}
|
||||
}
|
||||
|
||||
rule Objects
|
||||
{
|
||||
for _I in $(<)
|
||||
{
|
||||
local _O = $(OUT_DIR_NATIVE)/$(_I:B).o ;
|
||||
Object $(_O) : $(_I) ;
|
||||
}
|
||||
}
|
||||
|
||||
rule Main
|
||||
{
|
||||
MainFromObjects $(<) : $(OUT_DIR_NATIVE)/$(>:B).o ;
|
||||
Objects $(>) ;
|
||||
}
|
||||
|
||||
actions C++
|
||||
{
|
||||
c++ -c -o $(<) $(CCHDRS) $(CCDEFS) $(>)
|
||||
}
|
||||
|
||||
actions Link
|
||||
{
|
||||
c++ -o $(<) $(>)
|
||||
}
|
||||
|
||||
|
||||
|
||||
MkDir $(OUT_DIR_NATIVE) ;
|
||||
Depends $(OUT_NATIVE) : $(OUT_DIR_NATIVE) ;
|
||||
Main $(OUT_NATIVE) : $(NATIVE_CORE_MODULES) $(NATIVE_MODULES) $(LIB_MODULES) $(PROJECT_MODULES) ;
|
||||
|
||||
Depends native : $(OUT_NATIVE) ;
|
||||
|
223
digistump-avr/libraries/RF24/tests/native/pingpair_irq.pde
Normal file
223
digistump-avr/libraries/RF24/tests/native/pingpair_irq.pde
Normal file
@@ -0,0 +1,223 @@
|
||||
/*
|
||||
Copyright (C) 2011 James Coliz, Jr. <maniacbug@ymail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
version 2 as published by the Free Software Foundation.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Interrupt-driven test for native target
|
||||
*
|
||||
* This example is the friendliest for the native target because it doesn't do
|
||||
* any polling. Made a slight change to call done() at the end of setup.
|
||||
*/
|
||||
|
||||
#include <SPI.h>
|
||||
#include "nRF24L01.h"
|
||||
#include "RF24.h"
|
||||
#include "printf.h"
|
||||
|
||||
//
|
||||
// Hardware configuration
|
||||
//
|
||||
|
||||
// Set up nRF24L01 radio on SPI bus plus pins 8 & 9
|
||||
|
||||
RF24 radio(8,9);
|
||||
|
||||
// sets the role of this unit in hardware. Connect to GND to be the 'pong' receiver
|
||||
// Leave open to be the 'ping' transmitter
|
||||
const short role_pin = 7;
|
||||
|
||||
//
|
||||
// Topology
|
||||
//
|
||||
|
||||
// Single radio pipe address for the 2 nodes to communicate.
|
||||
const uint64_t pipe = 0xE8E8F0F0E1LL;
|
||||
|
||||
//
|
||||
// Role management
|
||||
//
|
||||
// Set up role. This sketch uses the same software for all the nodes in this
|
||||
// system. Doing so greatly simplifies testing. The hardware itself specifies
|
||||
// which node it is.
|
||||
//
|
||||
// This is done through the role_pin
|
||||
//
|
||||
|
||||
// The various roles supported by this sketch
|
||||
typedef enum { role_sender = 1, role_receiver } role_e;
|
||||
|
||||
// The debug-friendly names of those roles
|
||||
const char* role_friendly_name[] = { "invalid", "Sender", "Receiver"};
|
||||
|
||||
// The role of the current running sketch
|
||||
role_e role;
|
||||
|
||||
// Interrupt handler, check the radio because we got an IRQ
|
||||
void check_radio(void);
|
||||
|
||||
void setup(void)
|
||||
{
|
||||
//
|
||||
// Role
|
||||
//
|
||||
|
||||
// set up the role pin
|
||||
pinMode(role_pin, INPUT);
|
||||
digitalWrite(role_pin,HIGH);
|
||||
delay(20); // Just to get a solid reading on the role pin
|
||||
|
||||
// read the address pin, establish our role
|
||||
if ( digitalRead(role_pin) )
|
||||
role = role_sender;
|
||||
else
|
||||
role = role_receiver;
|
||||
|
||||
//
|
||||
// Print preamble
|
||||
//
|
||||
|
||||
Serial.begin(57600);
|
||||
printf_begin();
|
||||
printf("\n\rRF24/examples/pingpair_irq/\n\r");
|
||||
printf("ROLE: %s\n\r",role_friendly_name[role]);
|
||||
|
||||
//
|
||||
// Setup and configure rf radio
|
||||
//
|
||||
|
||||
radio.begin();
|
||||
|
||||
// We will be using the Ack Payload feature, so please enable it
|
||||
radio.enableAckPayload();
|
||||
|
||||
//
|
||||
// Open pipes to other nodes for communication
|
||||
//
|
||||
|
||||
// This simple sketch opens a single pipe for these two nodes to communicate
|
||||
// back and forth. One listens on it, the other talks to it.
|
||||
|
||||
if ( role == role_sender )
|
||||
{
|
||||
radio.openWritingPipe(pipe);
|
||||
}
|
||||
else
|
||||
{
|
||||
radio.openReadingPipe(1,pipe);
|
||||
}
|
||||
|
||||
//
|
||||
// Start listening
|
||||
//
|
||||
|
||||
if ( role == role_receiver )
|
||||
radio.startListening();
|
||||
|
||||
//
|
||||
// Dump the configuration of the rf unit for debugging
|
||||
//
|
||||
|
||||
radio.printDetails();
|
||||
|
||||
//
|
||||
// Attach interrupt handler to interrupt #0 (using pin 2)
|
||||
// on BOTH the sender and receiver
|
||||
//
|
||||
|
||||
attachInterrupt(0, check_radio, FALLING);
|
||||
|
||||
//
|
||||
// On the native target, this is as far as we get
|
||||
//
|
||||
#if NATIVE
|
||||
done();
|
||||
#endif
|
||||
}
|
||||
|
||||
static uint32_t message_count = 0;
|
||||
|
||||
void loop(void)
|
||||
{
|
||||
//
|
||||
// Sender role. Repeatedly send the current time
|
||||
//
|
||||
|
||||
if (role == role_sender)
|
||||
{
|
||||
// Take the time, and send it.
|
||||
unsigned long time = millis();
|
||||
printf("Now sending %lu\n\r",time);
|
||||
radio.startWrite( &time, sizeof(unsigned long) );
|
||||
|
||||
// Try again soon
|
||||
delay(2000);
|
||||
}
|
||||
|
||||
//
|
||||
// Receiver role: Does nothing! All the work is in IRQ
|
||||
//
|
||||
|
||||
}
|
||||
|
||||
void check_radio(void)
|
||||
{
|
||||
// What happened?
|
||||
bool tx,fail,rx;
|
||||
radio.whatHappened(tx,fail,rx);
|
||||
|
||||
// Have we successfully transmitted?
|
||||
if ( tx )
|
||||
{
|
||||
if ( role == role_sender )
|
||||
printf("Send:OK\n\r");
|
||||
|
||||
if ( role == role_receiver )
|
||||
printf("Ack Payload:Sent\n\r");
|
||||
}
|
||||
|
||||
// Have we failed to transmit?
|
||||
if ( fail )
|
||||
{
|
||||
if ( role == role_sender )
|
||||
printf("Send:Failed\n\r");
|
||||
|
||||
if ( role == role_receiver )
|
||||
printf("Ack Payload:Failed\n\r");
|
||||
}
|
||||
|
||||
// Transmitter can power down for now, because
|
||||
// the transmission is done.
|
||||
if ( ( tx || fail ) && ( role == role_sender ) )
|
||||
radio.powerDown();
|
||||
|
||||
// Did we receive a message?
|
||||
if ( rx )
|
||||
{
|
||||
// If we're the sender, we've received an ack payload
|
||||
if ( role == role_sender )
|
||||
{
|
||||
radio.read(&message_count,sizeof(message_count));
|
||||
printf("Ack:%lu\n\r",(unsigned long)message_count);
|
||||
}
|
||||
|
||||
// If we're the receiver, we've received a time message
|
||||
if ( role == role_receiver )
|
||||
{
|
||||
// Get this payload and dump it
|
||||
static unsigned long got_time;
|
||||
radio.read( &got_time, sizeof(got_time) );
|
||||
printf("Got payload %lu\n\r",got_time);
|
||||
|
||||
// Add an ack packet for the next time around. This is a simple
|
||||
// packet counter
|
||||
radio.writeAckPayload( 1, &message_count, sizeof(message_count) );
|
||||
++message_count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// vim:ai:cin:sts=2 sw=2 ft=cpp
|
33
digistump-avr/libraries/RF24/tests/native/printf.h
Normal file
33
digistump-avr/libraries/RF24/tests/native/printf.h
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
Copyright (C) 2011 James Coliz, Jr. <maniacbug@ymail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
version 2 as published by the Free Software Foundation.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file printf.h
|
||||
*
|
||||
* Setup necessary to direct stdout to the Arduino Serial library, which
|
||||
* enables 'printf'
|
||||
*/
|
||||
|
||||
#ifndef __PRINTF_H__
|
||||
#define __PRINTF_H__
|
||||
|
||||
#include "WProgram.h"
|
||||
|
||||
int serial_putc( char c, FILE * )
|
||||
{
|
||||
Serial.write( c );
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
void printf_begin(void)
|
||||
{
|
||||
fdevopen( &serial_putc, 0 );
|
||||
}
|
||||
|
||||
#endif // __PRINTF_H__
|
219
digistump-avr/libraries/RF24/tests/pingpair_blocking/Jamfile
Normal file
219
digistump-avr/libraries/RF24/tests/pingpair_blocking/Jamfile
Normal file
@@ -0,0 +1,219 @@
|
||||
# (1) Project Information
|
||||
|
||||
PROJECT_LIBS = SPI RF24 ;
|
||||
PROJECT_DIRS = $(PWD) ;
|
||||
|
||||
# (2) Board Information
|
||||
|
||||
UPLOAD_PROTOCOL ?= arduino ;
|
||||
UPLOAD_SPEED ?= 115200 ;
|
||||
MCU ?= atmega328p ;
|
||||
F_CPU ?= 16000000 ;
|
||||
CORE ?= arduino ;
|
||||
VARIANT ?= standard ;
|
||||
ARDUINO_VERSION ?= 100 ;
|
||||
|
||||
# (3) USB Ports
|
||||
|
||||
PORTS = p4 p6 p9 u0 u1 u2 ;
|
||||
PORT_p6 = /dev/tty.usbserial-A600eHIs ;
|
||||
PORT_p4 = /dev/tty.usbserial-A40081RP ;
|
||||
PORT_p9 = /dev/tty.usbserial-A9007LmI ;
|
||||
PORT_u0 = /dev/ttyUSB0 ;
|
||||
PORT_u1 = /dev/ttyUSB1 ;
|
||||
PORT_u2 = /dev/ttyUSB2 ;
|
||||
|
||||
# (4) Location of AVR tools
|
||||
#
|
||||
# This configuration assumes using avr-tools that were obtained separate from the Arduino
|
||||
# distribution.
|
||||
|
||||
if $(OS) = MACOSX
|
||||
{
|
||||
AVR_BIN ?= /usr/local/avrtools/bin ;
|
||||
AVR_ETC = /usr/local/avrtools/etc ;
|
||||
AVR_INCLUDE = /usr/local/avrtools/include ;
|
||||
}
|
||||
else
|
||||
{
|
||||
AVR_BIN ?= /usr/bin ;
|
||||
AVR_INCLUDE = /usr/lib/avr/include ;
|
||||
AVR_ETC = /etc ;
|
||||
}
|
||||
|
||||
# (5) Directories where Arduino core and libraries are located
|
||||
|
||||
ARDUINO_DIR ?= /opt/Arduino ;
|
||||
ARDUINO_CORE = $(ARDUINO_DIR)/hardware/arduino/cores/$(CORE) $(ARDUINO_DIR)/hardware/arduino/variants/$(VARIANT) ;
|
||||
ARDUINO_LIB = $(ARDUINO_DIR)/libraries ;
|
||||
SKETCH_LIB = $(HOME)/Source/Arduino/libraries ;
|
||||
|
||||
#
|
||||
# --------------------------------------------------
|
||||
# Below this line usually never needs to be modified
|
||||
#
|
||||
|
||||
# Tool locations
|
||||
|
||||
CC = $(AVR_BIN)/avr-gcc ;
|
||||
C++ = $(AVR_BIN)/avr-g++ ;
|
||||
LINK = $(AVR_BIN)/avr-gcc ;
|
||||
AR = $(AVR_BIN)/avr-ar rcs ;
|
||||
RANLIB = ;
|
||||
OBJCOPY = $(AVR_BIN)/avr-objcopy ;
|
||||
AVRDUDE ?= $(AVR_BIN)/avrdude ;
|
||||
|
||||
# Flags
|
||||
|
||||
DEFINES += F_CPU=$(F_CPU)L ARDUINO=$(ARDUINO_VERSION) VERSION_H ;
|
||||
OPTIM = -Os ;
|
||||
CCFLAGS = -Wall -Wextra -Wno-strict-aliasing -mmcu=$(MCU) -ffunction-sections -fdata-sections ;
|
||||
C++FLAGS = $(CCFLAGS) -fno-exceptions -fno-strict-aliasing ;
|
||||
LINKFLAGS = $(OPTIM) -lm -Wl,--gc-sections -mmcu=$(MCU) ;
|
||||
AVRDUDEFLAGS = -V -F -D -C $(AVR_ETC)/avrdude.conf -p $(MCU) -c $(UPLOAD_PROTOCOL) -b $(UPLOAD_SPEED) ;
|
||||
|
||||
# Search everywhere for headers
|
||||
|
||||
HDRS = $(PROJECT_DIRS) $(AVR_INCLUDE) $(ARDUINO_CORE) $(ARDUINO_LIB)/$(PROJECT_LIBS) $(ARDUINO_LIB)/$(PROJECT_LIBS)/utility $(SKETCH_LIB)/$(PROJECT_LIBS) ;
|
||||
|
||||
# Output locations
|
||||
|
||||
LOCATE_TARGET = $(F_CPU) ;
|
||||
LOCATE_SOURCE = $(F_CPU) ;
|
||||
|
||||
#
|
||||
# Custom rules
|
||||
#
|
||||
|
||||
rule GitVersion
|
||||
{
|
||||
Always $(<) ;
|
||||
Depends all : $(<) ;
|
||||
}
|
||||
|
||||
actions GitVersion
|
||||
{
|
||||
echo "const char program_version[] = \"\\" > $(<)
|
||||
git log -1 --pretty=format:%h >> $(<)
|
||||
echo "\";" >> $(<)
|
||||
}
|
||||
|
||||
GitVersion version.h ;
|
||||
|
||||
rule Pde
|
||||
{
|
||||
Depends $(<) : $(>) ;
|
||||
MakeLocate $(<) : $(LOCATE_SOURCE) ;
|
||||
Clean clean : $(<) ;
|
||||
}
|
||||
|
||||
if ( $(ARDUINO_VERSION) < 100 )
|
||||
{
|
||||
ARDUINO_H = WProgram.h ;
|
||||
}
|
||||
else
|
||||
{
|
||||
ARDUINO_H = Arduino.h ;
|
||||
}
|
||||
|
||||
actions Pde
|
||||
{
|
||||
echo "#include <$(ARDUINO_H)>" > $(<)
|
||||
echo "#line 1 \"$(>)\"" >> $(<)
|
||||
cat $(>) >> $(<)
|
||||
}
|
||||
|
||||
rule C++Pde
|
||||
{
|
||||
local _CPP = $(>:B).cpp ;
|
||||
Pde $(_CPP) : $(>) ;
|
||||
C++ $(<) : $(_CPP) ;
|
||||
}
|
||||
|
||||
rule UserObject
|
||||
{
|
||||
switch $(>:S)
|
||||
{
|
||||
case .ino : C++Pde $(<) : $(>) ;
|
||||
case .pde : C++Pde $(<) : $(>) ;
|
||||
}
|
||||
}
|
||||
|
||||
rule Objects
|
||||
{
|
||||
local _i ;
|
||||
|
||||
for _i in [ FGristFiles $(<) ]
|
||||
{
|
||||
local _b = $(_i:B)$(SUFOBJ) ;
|
||||
local _o = $(_b:G=$(SOURCE_GRIST:E)) ;
|
||||
Object $(_o) : $(_i) ;
|
||||
Depends obj : $(_o) ;
|
||||
}
|
||||
}
|
||||
|
||||
rule Library
|
||||
{
|
||||
LibraryFromObjects $(<) : $(>:B)$(SUFOBJ) ;
|
||||
Objects $(>) ;
|
||||
}
|
||||
|
||||
rule Main
|
||||
{
|
||||
MainFromObjects $(<) : $(>:B)$(SUFOBJ) ;
|
||||
Objects $(>) ;
|
||||
}
|
||||
|
||||
rule Hex
|
||||
{
|
||||
Depends $(<) : $(>) ;
|
||||
MakeLocate $(<) : $(LOCATE_TARGET) ;
|
||||
Depends hex : $(<) ;
|
||||
Clean clean : $(<) ;
|
||||
}
|
||||
|
||||
actions Hex
|
||||
{
|
||||
$(OBJCOPY) -O ihex -R .eeprom $(>) $(<)
|
||||
}
|
||||
|
||||
rule Upload
|
||||
{
|
||||
Depends $(1) : $(2) ;
|
||||
Depends $(2) : $(3) ;
|
||||
NotFile $(1) ;
|
||||
Always $(1) ;
|
||||
Always $(2) ;
|
||||
UploadAction $(2) : $(3) ;
|
||||
}
|
||||
|
||||
actions UploadAction
|
||||
{
|
||||
$(AVRDUDE) $(AVRDUDEFLAGS) -P $(<) $(AVRDUDE_WRITE_FLASH) -U flash:w:$(>):i
|
||||
}
|
||||
|
||||
rule Arduino
|
||||
{
|
||||
LINKFLAGS on $(<) = $(LINKFLAGS) -Wl,-Map=$(LOCATE_TARGET)/$(<:B).map ;
|
||||
Main $(<) : $(>) ;
|
||||
LinkLibraries $(<) : core libs ;
|
||||
Hex $(<:B).hex : $(<) ;
|
||||
for _p in $(PORTS)
|
||||
{
|
||||
Upload $(_p) : $(PORT_$(_p)) : $(<:B).hex ;
|
||||
}
|
||||
}
|
||||
|
||||
#
|
||||
# Targets
|
||||
#
|
||||
|
||||
# Grab everything from the core directory
|
||||
Library core : [ GLOB $(ARDUINO_CORE) : *.c *.cpp ] ;
|
||||
|
||||
# Grab everything from libraries. To avoid this "grab everything" behaviour, you
|
||||
# can specify specific modules to pick up in PROJECT_MODULES
|
||||
Library libs : [ GLOB $(ARDUINO_LIB)/$(PROJECT_LIBS) $(ARDUINO_LIB)/$(PROJECT_LIBS)/utility $(SKETCH_LIB)/$(PROJECT_LIBS) : *.cpp *.c ] ;
|
||||
|
||||
# Main output executable
|
||||
Arduino $(PWD:B).elf : $(PROJECT_MODULES) [ GLOB $(PROJECT_DIRS) : *.c *.cpp *.pde *.ino ] ;
|
@@ -0,0 +1,273 @@
|
||||
/*
|
||||
Copyright (C) 2011 James Coliz, Jr. <maniacbug@ymail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
version 2 as published by the Free Software Foundation.
|
||||
*/
|
||||
|
||||
#include <SPI.h>
|
||||
#include "nRF24L01.h"
|
||||
#include "RF24.h"
|
||||
#include "printf.h"
|
||||
|
||||
//
|
||||
// Test version of RF24, exposes some protected interface
|
||||
//
|
||||
|
||||
class RF24Test: public RF24
|
||||
{
|
||||
public: RF24Test(int a, int b): RF24(a,b) {}
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// Hardware configuration
|
||||
//
|
||||
|
||||
// Set up nRF24L01 radio on SPI bus plus pins 8 & 9
|
||||
|
||||
RF24Test radio(8,9);
|
||||
|
||||
// sets the role of this unit in hardware. Connect to GND to be the 'pong' receiver
|
||||
// Leave open to be the 'ping' transmitter
|
||||
const int role_pin = 7;
|
||||
|
||||
//
|
||||
// Topology
|
||||
//
|
||||
|
||||
// Radio pipe addresses for the 2 nodes to communicate.
|
||||
const uint64_t pipes[2] = { 0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL };
|
||||
|
||||
//
|
||||
// Role management
|
||||
//
|
||||
// Set up role. This sketch uses the same software for all the nodes
|
||||
// in this system. Doing so greatly simplifies testing. The hardware itself specifies
|
||||
// which node it is.
|
||||
//
|
||||
// This is done through the role_pin
|
||||
//
|
||||
|
||||
// The various roles supported by this sketch
|
||||
typedef enum { role_ping_out = 1, role_pong_back } role_e;
|
||||
|
||||
// The debug-friendly names of those roles
|
||||
const char* role_friendly_name[] = { "invalid", "Ping out", "Pong back"};
|
||||
|
||||
// The role of the current running sketch
|
||||
role_e role;
|
||||
|
||||
//
|
||||
// Test state
|
||||
//
|
||||
|
||||
bool done; //*< Are we done with the test? */
|
||||
bool passed; //*< Have we passed the test? */
|
||||
bool notified; //*< Have we notified the user we're done? */
|
||||
const int num_needed = 10; //*< How many success/failures until we're done? */
|
||||
int receives_remaining = num_needed; //*< How many ack packets until we declare victory? */
|
||||
int failures_remaining = num_needed; //*< How many more failed sends until we declare failure? */
|
||||
const int interval = 100; //*< ms to wait between sends */
|
||||
|
||||
char configuration = '1'; //*< Configuration key, one char sent in by the test framework to tell us how to configure, this is the default */
|
||||
|
||||
void one_ok(void)
|
||||
{
|
||||
// Have we received enough yet?
|
||||
if ( ! --receives_remaining )
|
||||
{
|
||||
done = true;
|
||||
passed = true;
|
||||
}
|
||||
}
|
||||
|
||||
void one_failed(void)
|
||||
{
|
||||
// Have we failed enough yet?
|
||||
if ( ! --failures_remaining )
|
||||
{
|
||||
done = true;
|
||||
passed = false;
|
||||
}
|
||||
}
|
||||
|
||||
void setup(void)
|
||||
{
|
||||
//
|
||||
// Role
|
||||
//
|
||||
|
||||
// set up the role pin
|
||||
pinMode(role_pin, INPUT);
|
||||
digitalWrite(role_pin,HIGH);
|
||||
delay(20); // Just to get a solid reading on the role pin
|
||||
|
||||
// read the address pin, establish our role
|
||||
if ( digitalRead(role_pin) )
|
||||
role = role_ping_out;
|
||||
else
|
||||
role = role_pong_back;
|
||||
|
||||
//
|
||||
// Print preamble
|
||||
//
|
||||
|
||||
Serial.begin(57600);
|
||||
printf_begin();
|
||||
printf("\n\rRF24/tests/pingpair_blocking/\n\r");
|
||||
printf("ROLE: %s\n\r",role_friendly_name[role]);
|
||||
|
||||
//
|
||||
// get test config
|
||||
//
|
||||
|
||||
printf("+READY press any key to start\n\r\n\r");
|
||||
|
||||
while (! Serial.available() ) {}
|
||||
configuration = Serial.read();
|
||||
printf("Configuration\t = %c\n\r",configuration);
|
||||
|
||||
//
|
||||
// Setup and configure rf radio
|
||||
//
|
||||
|
||||
radio.begin();
|
||||
|
||||
//
|
||||
// Open pipes to other nodes for communication
|
||||
//
|
||||
|
||||
// This simple sketch opens two pipes for these two nodes to communicate
|
||||
// back and forth.
|
||||
// Open 'our' pipe for writing
|
||||
// Open the 'other' pipe for reading, in position #1 (we can have up to 5 pipes open for reading)
|
||||
|
||||
if ( role == role_ping_out )
|
||||
{
|
||||
radio.openWritingPipe(pipes[0]);
|
||||
radio.openReadingPipe(1,pipes[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
radio.openWritingPipe(pipes[1]);
|
||||
radio.openReadingPipe(1,pipes[0]);
|
||||
}
|
||||
|
||||
//
|
||||
// Start listening
|
||||
//
|
||||
|
||||
radio.startListening();
|
||||
|
||||
//
|
||||
// Dump the configuration of the rf unit for debugging
|
||||
//
|
||||
|
||||
radio.printDetails();
|
||||
|
||||
if ( role == role_pong_back )
|
||||
printf("\n\r+OK ");
|
||||
}
|
||||
|
||||
void loop(void)
|
||||
{
|
||||
//
|
||||
// Ping out role. Repeatedly send the current time
|
||||
//
|
||||
|
||||
if (role == role_ping_out)
|
||||
{
|
||||
// First, stop listening so we can talk.
|
||||
radio.stopListening();
|
||||
|
||||
// Take the time, and send it. This will block until complete
|
||||
unsigned long time = millis();
|
||||
printf("Now sending %lu...",time);
|
||||
radio.write( &time, sizeof(unsigned long) );
|
||||
|
||||
// Now, continue listening
|
||||
radio.startListening();
|
||||
|
||||
// Wait here until we get a response, or timeout (250ms)
|
||||
unsigned long started_waiting_at = millis();
|
||||
bool timeout = false;
|
||||
while ( ! radio.available() && ! timeout )
|
||||
if (millis() - started_waiting_at > 200 )
|
||||
timeout = true;
|
||||
|
||||
// Describe the results
|
||||
if ( timeout )
|
||||
{
|
||||
printf("Failed, response timed out.\n\r");
|
||||
one_failed();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Grab the response, compare, and send to debugging spew
|
||||
unsigned long got_time;
|
||||
radio.read( &got_time, sizeof(unsigned long) );
|
||||
|
||||
// Spew it
|
||||
printf("Got response %lu, round-trip delay: %lu\n\r",got_time,millis()-got_time);
|
||||
one_ok();
|
||||
}
|
||||
|
||||
// Try again later
|
||||
delay(250);
|
||||
}
|
||||
|
||||
//
|
||||
// Pong back role. Receive each packet, dump it out, and send it back
|
||||
//
|
||||
|
||||
if ( role == role_pong_back )
|
||||
{
|
||||
// if there is data ready
|
||||
if ( radio.available() )
|
||||
{
|
||||
// Dump the payloads until we've gotten everything
|
||||
unsigned long got_time;
|
||||
bool done = false;
|
||||
while (!done)
|
||||
{
|
||||
// Fetch the payload, and see if this was the last one.
|
||||
done = radio.read( &got_time, sizeof(unsigned long) );
|
||||
|
||||
// Spew it
|
||||
printf("Got payload %lu...",got_time);
|
||||
|
||||
// Delay just a little bit to let the other unit
|
||||
// make the transition to receiver
|
||||
delay(20);
|
||||
}
|
||||
|
||||
// First, stop listening so we can talk
|
||||
radio.stopListening();
|
||||
|
||||
// Send the final one back.
|
||||
radio.write( &got_time, sizeof(unsigned long) );
|
||||
printf("Sent response.\n\r");
|
||||
|
||||
// Now, resume listening so we catch the next packets.
|
||||
radio.startListening();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Stop the test if we're done and report results
|
||||
//
|
||||
if ( done && ! notified )
|
||||
{
|
||||
notified = true;
|
||||
|
||||
printf("\n\r+OK ");
|
||||
if ( passed )
|
||||
printf("PASS\n\r\n\r");
|
||||
else
|
||||
printf("FAIL\n\r\n\r");
|
||||
}
|
||||
}
|
||||
// vim:cin:ai:sts=2 sw=2 ft=cpp
|
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
Copyright (C) 2011 J. Coliz <maniacbug@ymail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
version 2 as published by the Free Software Foundation.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file printf.h
|
||||
*
|
||||
* Setup necessary to direct stdout to the Arduino Serial library, which
|
||||
* enables 'printf'
|
||||
*/
|
||||
|
||||
#ifndef __PRINTF_H__
|
||||
#define __PRINTF_H__
|
||||
|
||||
#ifdef ARDUINO
|
||||
|
||||
int serial_putc( char c, FILE * )
|
||||
{
|
||||
Serial.write( c );
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
void printf_begin(void)
|
||||
{
|
||||
fdevopen( &serial_putc, 0 );
|
||||
}
|
||||
|
||||
#else
|
||||
#error This example is only for use on Arduino.
|
||||
#endif // ARDUINO
|
||||
|
||||
#endif // __PRINTF_H__
|
@@ -0,0 +1,25 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import sys,serial
|
||||
|
||||
def read_until(token):
|
||||
while 1:
|
||||
line = ser.readline(None)
|
||||
sys.stdout.write(line)
|
||||
|
||||
if (line.startswith(token)):
|
||||
break
|
||||
return line
|
||||
|
||||
|
||||
ser = serial.Serial(sys.argv[1], 57600, timeout=5, dsrdtr=False, rtscts=False)
|
||||
|
||||
read_until("+READY")
|
||||
ser.write(sys.argv[2])
|
||||
|
||||
line = read_until("+OK")
|
||||
ser.close()
|
||||
if (line.find("PASS") != -1):
|
||||
sys.exit(0)
|
||||
else:
|
||||
sys.exit(1)
|
@@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Connect u0 to receiver, u1 to sender
|
||||
|
||||
jam u0 u1 && expect test.ex
|
11
digistump-avr/libraries/RF24/tests/pingpair_blocking/test.ex
Normal file
11
digistump-avr/libraries/RF24/tests/pingpair_blocking/test.ex
Normal file
@@ -0,0 +1,11 @@
|
||||
#/usr/bin/expect
|
||||
|
||||
set timeout 100
|
||||
spawn picocom -b 57600 /dev/ttyUSB0
|
||||
expect "+READY"
|
||||
send "1"
|
||||
expect "+OK"
|
||||
spawn picocom -b 57600 /dev/ttyUSB1
|
||||
expect "+READY"
|
||||
send "1"
|
||||
expect "+OK"
|
219
digistump-avr/libraries/RF24/tests/pingpair_test/Jamfile
Normal file
219
digistump-avr/libraries/RF24/tests/pingpair_test/Jamfile
Normal file
@@ -0,0 +1,219 @@
|
||||
# (1) Project Information
|
||||
|
||||
PROJECT_LIBS = SPI RF24 ;
|
||||
PROJECT_DIRS = $(PWD) ;
|
||||
|
||||
# (2) Board Information
|
||||
|
||||
UPLOAD_PROTOCOL ?= arduino ;
|
||||
UPLOAD_SPEED ?= 115200 ;
|
||||
MCU ?= atmega328p ;
|
||||
F_CPU ?= 16000000 ;
|
||||
CORE ?= arduino ;
|
||||
VARIANT ?= standard ;
|
||||
ARDUINO_VERSION ?= 100 ;
|
||||
|
||||
# (3) USB Ports
|
||||
|
||||
PORTS = p4 p6 p9 u0 u1 u2 ;
|
||||
PORT_p6 = /dev/tty.usbserial-A600eHIs ;
|
||||
PORT_p4 = /dev/tty.usbserial-A40081RP ;
|
||||
PORT_p9 = /dev/tty.usbserial-A9007LmI ;
|
||||
PORT_u0 = /dev/ttyUSB0 ;
|
||||
PORT_u1 = /dev/ttyUSB1 ;
|
||||
PORT_u2 = /dev/ttyUSB2 ;
|
||||
|
||||
# (4) Location of AVR tools
|
||||
#
|
||||
# This configuration assumes using avr-tools that were obtained separate from the Arduino
|
||||
# distribution.
|
||||
|
||||
if $(OS) = MACOSX
|
||||
{
|
||||
AVR_BIN ?= /usr/local/avrtools/bin ;
|
||||
AVR_ETC = /usr/local/avrtools/etc ;
|
||||
AVR_INCLUDE = /usr/local/avrtools/include ;
|
||||
}
|
||||
else
|
||||
{
|
||||
AVR_BIN ?= /usr/bin ;
|
||||
AVR_INCLUDE = /usr/lib/avr/include ;
|
||||
AVR_ETC = /etc ;
|
||||
}
|
||||
|
||||
# (5) Directories where Arduino core and libraries are located
|
||||
|
||||
ARDUINO_DIR ?= /opt/Arduino ;
|
||||
ARDUINO_CORE = $(ARDUINO_DIR)/hardware/arduino/cores/$(CORE) $(ARDUINO_DIR)/hardware/arduino/variants/$(VARIANT) ;
|
||||
ARDUINO_LIB = $(ARDUINO_DIR)/libraries ;
|
||||
SKETCH_LIB = $(HOME)/Source/Arduino/libraries ;
|
||||
|
||||
#
|
||||
# --------------------------------------------------
|
||||
# Below this line usually never needs to be modified
|
||||
#
|
||||
|
||||
# Tool locations
|
||||
|
||||
CC = $(AVR_BIN)/avr-gcc ;
|
||||
C++ = $(AVR_BIN)/avr-g++ ;
|
||||
LINK = $(AVR_BIN)/avr-gcc ;
|
||||
AR = $(AVR_BIN)/avr-ar rcs ;
|
||||
RANLIB = ;
|
||||
OBJCOPY = $(AVR_BIN)/avr-objcopy ;
|
||||
AVRDUDE ?= $(AVR_BIN)/avrdude ;
|
||||
|
||||
# Flags
|
||||
|
||||
DEFINES += F_CPU=$(F_CPU)L ARDUINO=$(ARDUINO_VERSION) VERSION_H ;
|
||||
OPTIM = -Os ;
|
||||
CCFLAGS = -Wall -Wextra -Wno-strict-aliasing -mmcu=$(MCU) -ffunction-sections -fdata-sections ;
|
||||
C++FLAGS = $(CCFLAGS) -fno-exceptions -fno-strict-aliasing ;
|
||||
LINKFLAGS = $(OPTIM) -lm -Wl,--gc-sections -mmcu=$(MCU) ;
|
||||
AVRDUDEFLAGS = -V -F -D -C $(AVR_ETC)/avrdude.conf -p $(MCU) -c $(UPLOAD_PROTOCOL) -b $(UPLOAD_SPEED) ;
|
||||
|
||||
# Search everywhere for headers
|
||||
|
||||
HDRS = $(PROJECT_DIRS) $(AVR_INCLUDE) $(ARDUINO_CORE) $(ARDUINO_LIB)/$(PROJECT_LIBS) $(ARDUINO_LIB)/$(PROJECT_LIBS)/utility $(SKETCH_LIB)/$(PROJECT_LIBS) ;
|
||||
|
||||
# Output locations
|
||||
|
||||
LOCATE_TARGET = $(F_CPU) ;
|
||||
LOCATE_SOURCE = $(F_CPU) ;
|
||||
|
||||
#
|
||||
# Custom rules
|
||||
#
|
||||
|
||||
rule GitVersion
|
||||
{
|
||||
Always $(<) ;
|
||||
Depends all : $(<) ;
|
||||
}
|
||||
|
||||
actions GitVersion
|
||||
{
|
||||
echo "const char program_version[] = \"\\" > $(<)
|
||||
git log -1 --pretty=format:%h >> $(<)
|
||||
echo "\";" >> $(<)
|
||||
}
|
||||
|
||||
GitVersion version.h ;
|
||||
|
||||
rule Pde
|
||||
{
|
||||
Depends $(<) : $(>) ;
|
||||
MakeLocate $(<) : $(LOCATE_SOURCE) ;
|
||||
Clean clean : $(<) ;
|
||||
}
|
||||
|
||||
if ( $(ARDUINO_VERSION) < 100 )
|
||||
{
|
||||
ARDUINO_H = WProgram.h ;
|
||||
}
|
||||
else
|
||||
{
|
||||
ARDUINO_H = Arduino.h ;
|
||||
}
|
||||
|
||||
actions Pde
|
||||
{
|
||||
echo "#include <$(ARDUINO_H)>" > $(<)
|
||||
echo "#line 1 \"$(>)\"" >> $(<)
|
||||
cat $(>) >> $(<)
|
||||
}
|
||||
|
||||
rule C++Pde
|
||||
{
|
||||
local _CPP = $(>:B).cpp ;
|
||||
Pde $(_CPP) : $(>) ;
|
||||
C++ $(<) : $(_CPP) ;
|
||||
}
|
||||
|
||||
rule UserObject
|
||||
{
|
||||
switch $(>:S)
|
||||
{
|
||||
case .ino : C++Pde $(<) : $(>) ;
|
||||
case .pde : C++Pde $(<) : $(>) ;
|
||||
}
|
||||
}
|
||||
|
||||
rule Objects
|
||||
{
|
||||
local _i ;
|
||||
|
||||
for _i in [ FGristFiles $(<) ]
|
||||
{
|
||||
local _b = $(_i:B)$(SUFOBJ) ;
|
||||
local _o = $(_b:G=$(SOURCE_GRIST:E)) ;
|
||||
Object $(_o) : $(_i) ;
|
||||
Depends obj : $(_o) ;
|
||||
}
|
||||
}
|
||||
|
||||
rule Library
|
||||
{
|
||||
LibraryFromObjects $(<) : $(>:B)$(SUFOBJ) ;
|
||||
Objects $(>) ;
|
||||
}
|
||||
|
||||
rule Main
|
||||
{
|
||||
MainFromObjects $(<) : $(>:B)$(SUFOBJ) ;
|
||||
Objects $(>) ;
|
||||
}
|
||||
|
||||
rule Hex
|
||||
{
|
||||
Depends $(<) : $(>) ;
|
||||
MakeLocate $(<) : $(LOCATE_TARGET) ;
|
||||
Depends hex : $(<) ;
|
||||
Clean clean : $(<) ;
|
||||
}
|
||||
|
||||
actions Hex
|
||||
{
|
||||
$(OBJCOPY) -O ihex -R .eeprom $(>) $(<)
|
||||
}
|
||||
|
||||
rule Upload
|
||||
{
|
||||
Depends $(1) : $(2) ;
|
||||
Depends $(2) : $(3) ;
|
||||
NotFile $(1) ;
|
||||
Always $(1) ;
|
||||
Always $(2) ;
|
||||
UploadAction $(2) : $(3) ;
|
||||
}
|
||||
|
||||
actions UploadAction
|
||||
{
|
||||
$(AVRDUDE) $(AVRDUDEFLAGS) -P $(<) $(AVRDUDE_WRITE_FLASH) -U flash:w:$(>):i
|
||||
}
|
||||
|
||||
rule Arduino
|
||||
{
|
||||
LINKFLAGS on $(<) = $(LINKFLAGS) -Wl,-Map=$(LOCATE_TARGET)/$(<:B).map ;
|
||||
Main $(<) : $(>) ;
|
||||
LinkLibraries $(<) : core libs ;
|
||||
Hex $(<:B).hex : $(<) ;
|
||||
for _p in $(PORTS)
|
||||
{
|
||||
Upload $(_p) : $(PORT_$(_p)) : $(<:B).hex ;
|
||||
}
|
||||
}
|
||||
|
||||
#
|
||||
# Targets
|
||||
#
|
||||
|
||||
# Grab everything from the core directory
|
||||
Library core : [ GLOB $(ARDUINO_CORE) : *.c *.cpp ] ;
|
||||
|
||||
# Grab everything from libraries. To avoid this "grab everything" behaviour, you
|
||||
# can specify specific modules to pick up in PROJECT_MODULES
|
||||
Library libs : [ GLOB $(ARDUINO_LIB)/$(PROJECT_LIBS) $(ARDUINO_LIB)/$(PROJECT_LIBS)/utility $(SKETCH_LIB)/$(PROJECT_LIBS) : *.cpp *.c ] ;
|
||||
|
||||
# Main output executable
|
||||
Arduino $(PWD:B).elf : $(PROJECT_MODULES) [ GLOB $(PROJECT_DIRS) : *.c *.cpp *.pde *.ino ] ;
|
@@ -0,0 +1,435 @@
|
||||
/*
|
||||
Copyright (C) 2011 James Coliz, Jr. <maniacbug@ymail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
version 2 as published by the Free Software Foundation.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Full test on single RF pair
|
||||
*
|
||||
* This sketches uses as many RF24 methods as possible in a single test.
|
||||
*
|
||||
* To operate:
|
||||
* Upload this sketch on two nodes, each with IRQ -> pin 2
|
||||
* One node needs pin 7 -> GND, the other NC. That's the receiving node
|
||||
* Monitor the sending node's serial output
|
||||
* Look for "+OK PASS" or "+OK FAIL"
|
||||
*/
|
||||
|
||||
#include <SPI.h>
|
||||
#include "nRF24L01.h"
|
||||
#include "RF24.h"
|
||||
#include "printf.h"
|
||||
|
||||
//
|
||||
// Hardware configuration
|
||||
//
|
||||
|
||||
// Set up nRF24L01 radio on SPI bus plus pins 8 & 9
|
||||
|
||||
RF24 radio(8,9);
|
||||
|
||||
// sets the role of this unit in hardware. Connect to GND to be the 'pong' receiver
|
||||
// Leave open to be the 'ping' transmitter
|
||||
const short role_pin = 7;
|
||||
|
||||
//
|
||||
// Topology
|
||||
//
|
||||
|
||||
// Single radio pipe address for the 2 nodes to communicate.
|
||||
const uint64_t pipe = 0xE8E8F0F0E1LL;
|
||||
|
||||
//
|
||||
// Role management
|
||||
//
|
||||
// Set up role. This sketch uses the same software for all the nodes in this
|
||||
// system. Doing so greatly simplifies testing. The hardware itself specifies
|
||||
// which node it is.
|
||||
//
|
||||
// This is done through the role_pin
|
||||
//
|
||||
|
||||
// The various roles supported by this sketch
|
||||
typedef enum { role_sender = 1, role_receiver } role_e;
|
||||
|
||||
// The debug-friendly names of those roles
|
||||
const char* role_friendly_name[] = { "invalid", "Sender", "Receiver"};
|
||||
|
||||
// The role of the current running sketch
|
||||
role_e role;
|
||||
|
||||
// Interrupt handler, check the radio because we got an IRQ
|
||||
void check_radio(void);
|
||||
|
||||
//
|
||||
// Payload
|
||||
//
|
||||
|
||||
const int min_payload_size = 4;
|
||||
const int max_payload_size = 32;
|
||||
int payload_size_increments_by = 2;
|
||||
int next_payload_size = min_payload_size;
|
||||
|
||||
char receive_payload[max_payload_size+1]; // +1 to allow room for a terminating NULL char
|
||||
|
||||
//
|
||||
// Test state
|
||||
//
|
||||
|
||||
bool done; //*< Are we done with the test? */
|
||||
bool passed; //*< Have we passed the test? */
|
||||
bool notified; //*< Have we notified the user we're done? */
|
||||
const int num_needed = 10; //*< How many success/failures until we're done? */
|
||||
int receives_remaining = num_needed; //*< How many ack packets until we declare victory? */
|
||||
int failures_remaining = num_needed; //*< How many more failed sends until we declare failure? */
|
||||
const int interval = 100; //*< ms to wait between sends */
|
||||
|
||||
char configuration = '1'; //*< Configuration key, one char sent in by the test framework to tell us how to configure, this is the default */
|
||||
|
||||
uint8_t pipe_number = 1; // Which pipe to send on.
|
||||
|
||||
void one_ok(void)
|
||||
{
|
||||
// Have we received enough yet?
|
||||
if ( ! --receives_remaining )
|
||||
{
|
||||
done = true;
|
||||
passed = true;
|
||||
}
|
||||
}
|
||||
|
||||
void one_failed(void)
|
||||
{
|
||||
// Have we failed enough yet?
|
||||
if ( ! --failures_remaining )
|
||||
{
|
||||
done = true;
|
||||
passed = false;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Setup
|
||||
//
|
||||
|
||||
void setup(void)
|
||||
{
|
||||
//
|
||||
// Role
|
||||
//
|
||||
|
||||
// set up the role pin
|
||||
pinMode(role_pin, INPUT);
|
||||
digitalWrite(role_pin,HIGH);
|
||||
delay(20); // Just to get a solid reading on the role pin
|
||||
|
||||
// read the address pin, establish our role
|
||||
if ( digitalRead(role_pin) )
|
||||
role = role_sender;
|
||||
else
|
||||
role = role_receiver;
|
||||
|
||||
//
|
||||
// Print preamble
|
||||
//
|
||||
|
||||
Serial.begin(57600);
|
||||
printf_begin();
|
||||
printf("\n\rRF24/tests/pingpair_test/\n\r");
|
||||
printf("ROLE: %s\n\r",role_friendly_name[role]);
|
||||
|
||||
//
|
||||
// Read configuration from serial
|
||||
//
|
||||
// It would be a much better test if this program could accept configuration
|
||||
// from the serial port. Then it would be possible to run the same test under
|
||||
// lots of different circumstances.
|
||||
//
|
||||
// The idea is that we will print "+READY" at this point. The python script
|
||||
// will wait for it, and then send down a configuration script that we
|
||||
// execute here and then run with.
|
||||
//
|
||||
// The test controller will need to configure the receiver first, then go run
|
||||
// the test on the sender.
|
||||
//
|
||||
|
||||
printf("+READY press any key to start\n\r\n\r");
|
||||
|
||||
while (! Serial.available() ) {}
|
||||
configuration = Serial.read();
|
||||
printf("Configuration\t = %c\n\r",configuration);
|
||||
|
||||
//
|
||||
// Setup and configure rf radio
|
||||
//
|
||||
|
||||
radio.begin();
|
||||
|
||||
// We will be using the Ack Payload feature, so please enable it
|
||||
radio.enableAckPayload();
|
||||
|
||||
// Config 2 is special radio config
|
||||
if (configuration=='2')
|
||||
{
|
||||
radio.setCRCLength(RF24_CRC_8);
|
||||
radio.setDataRate(RF24_250KBPS);
|
||||
radio.setChannel(10);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Otherwise, default radio config
|
||||
|
||||
// Optional: Increase CRC length for improved reliability
|
||||
radio.setCRCLength(RF24_CRC_16);
|
||||
|
||||
// Optional: Decrease data rate for improved reliability
|
||||
radio.setDataRate(RF24_1MBPS);
|
||||
|
||||
// Optional: Pick a high channel
|
||||
radio.setChannel(90);
|
||||
}
|
||||
|
||||
// Config 3 is static payloads only
|
||||
if (configuration == '3')
|
||||
{
|
||||
next_payload_size = 16;
|
||||
payload_size_increments_by = 0;
|
||||
radio.setPayloadSize(next_payload_size);
|
||||
}
|
||||
else
|
||||
{
|
||||
// enable dynamic payloads
|
||||
radio.enableDynamicPayloads();
|
||||
}
|
||||
|
||||
// Config 4 tests out a higher pipe ##
|
||||
if (configuration == '4' && role == role_sender)
|
||||
{
|
||||
// Set top 4 bytes of the address in pipe 1
|
||||
radio.openReadingPipe(1,pipe & 0xFFFFFFFF00ULL);
|
||||
|
||||
// indicate the pipe to use
|
||||
pipe_number = 5;
|
||||
}
|
||||
else if ( role == role_sender )
|
||||
{
|
||||
radio.openReadingPipe(5,0);
|
||||
}
|
||||
|
||||
//
|
||||
// Open pipes to other nodes for communication
|
||||
//
|
||||
|
||||
// This simple sketch opens a single pipe for these two nodes to communicate
|
||||
// back and forth. One listens on it, the other talks to it.
|
||||
|
||||
if ( role == role_sender )
|
||||
{
|
||||
radio.openWritingPipe(pipe);
|
||||
}
|
||||
else
|
||||
{
|
||||
radio.openReadingPipe(pipe_number,pipe);
|
||||
}
|
||||
|
||||
//
|
||||
// Start listening
|
||||
//
|
||||
|
||||
if ( role == role_receiver )
|
||||
radio.startListening();
|
||||
|
||||
//
|
||||
// Dump the configuration of the rf unit for debugging
|
||||
//
|
||||
|
||||
radio.printDetails();
|
||||
|
||||
//
|
||||
// Attach interrupt handler to interrupt #0 (using pin 2)
|
||||
// on BOTH the sender and receiver
|
||||
//
|
||||
|
||||
attachInterrupt(0, check_radio, FALLING);
|
||||
|
||||
if ( role == role_receiver )
|
||||
printf("\n\r+OK ");
|
||||
}
|
||||
|
||||
//
|
||||
// Print buffer
|
||||
//
|
||||
// Printing from the interrupt handler is a bad idea, so we print from there
|
||||
// to this intermediate buffer
|
||||
//
|
||||
|
||||
char prbuf[1000];
|
||||
char *prbuf_end = prbuf + sizeof(prbuf);
|
||||
char *prbuf_in = prbuf;
|
||||
char *prbuf_out = prbuf;
|
||||
|
||||
//
|
||||
// Loop
|
||||
//
|
||||
|
||||
static uint32_t message_count = 0;
|
||||
static uint32_t last_message_count = 0;
|
||||
|
||||
void loop(void)
|
||||
{
|
||||
//
|
||||
// Sender role. Repeatedly send the current time
|
||||
//
|
||||
|
||||
if (role == role_sender && !done)
|
||||
{
|
||||
// The payload will always be the same, what will change is how much of it we send.
|
||||
static char send_payload[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ789012";
|
||||
|
||||
// First, stop listening so we can talk.
|
||||
radio.stopListening();
|
||||
|
||||
// Send it. This will block until complete
|
||||
printf("\n\rNow sending length %i...",next_payload_size);
|
||||
radio.startWrite( send_payload, next_payload_size );
|
||||
|
||||
// Update size for next time.
|
||||
next_payload_size += payload_size_increments_by;
|
||||
if ( next_payload_size > max_payload_size )
|
||||
next_payload_size = min_payload_size;
|
||||
|
||||
// Try again soon
|
||||
delay(interval);
|
||||
|
||||
// Timeout if we have not received anything back ever
|
||||
if ( ! last_message_count && millis() > interval * 100 )
|
||||
{
|
||||
printf("No responses received. Are interrupts connected??\n\r");
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Receiver role: Does nothing! All the work is in IRQ
|
||||
//
|
||||
|
||||
//
|
||||
// Spew print buffer
|
||||
//
|
||||
|
||||
size_t write_length = prbuf_in - prbuf_out;
|
||||
if ( write_length )
|
||||
{
|
||||
Serial.write(reinterpret_cast<uint8_t*>(prbuf_out),write_length);
|
||||
prbuf_out += write_length;
|
||||
}
|
||||
|
||||
//
|
||||
// Stop the test if we're done and report results
|
||||
//
|
||||
if ( done && ! notified )
|
||||
{
|
||||
notified = true;
|
||||
|
||||
printf("\n\r+OK ");
|
||||
if ( passed )
|
||||
printf("PASS\n\r\n\r");
|
||||
else
|
||||
printf("FAIL\n\r\n\r");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void check_radio(void)
|
||||
{
|
||||
// What happened?
|
||||
bool tx,fail,rx;
|
||||
radio.whatHappened(tx,fail,rx);
|
||||
|
||||
// Have we successfully transmitted?
|
||||
if ( tx )
|
||||
{
|
||||
if ( role == role_sender )
|
||||
prbuf_in += sprintf(prbuf_in,"Send:OK ");
|
||||
|
||||
if ( role == role_receiver )
|
||||
prbuf_in += sprintf(prbuf_in,"Ack Payload:Sent\n\r");
|
||||
}
|
||||
|
||||
// Have we failed to transmit?
|
||||
if ( fail )
|
||||
{
|
||||
if ( role == role_sender )
|
||||
{
|
||||
prbuf_in += sprintf(prbuf_in,"Send:Failed ");
|
||||
|
||||
// log status of this line
|
||||
one_failed();
|
||||
}
|
||||
|
||||
if ( role == role_receiver )
|
||||
prbuf_in += sprintf(prbuf_in,"Ack Payload:Failed\n\r");
|
||||
}
|
||||
|
||||
// Transmitter can power down for now, because
|
||||
// the transmission is done.
|
||||
if ( ( tx || fail ) && ( role == role_sender ) )
|
||||
radio.powerDown();
|
||||
|
||||
// Did we receive a message?
|
||||
if ( rx )
|
||||
{
|
||||
// If we're the sender, we've received an ack payload
|
||||
if ( role == role_sender )
|
||||
{
|
||||
radio.read(&message_count,sizeof(message_count));
|
||||
prbuf_in += sprintf(prbuf_in,"Ack:%lu ",message_count);
|
||||
|
||||
// is this ack what we were expecting? to account
|
||||
// for failures, we simply want to make sure we get a
|
||||
// DIFFERENT ack every time.
|
||||
if ( ( message_count != last_message_count ) || ( configuration=='3' && message_count == 16 ) )
|
||||
{
|
||||
prbuf_in += sprintf(prbuf_in,"OK ");
|
||||
one_ok();
|
||||
}
|
||||
else
|
||||
{
|
||||
prbuf_in += sprintf(prbuf_in,"FAILED ");
|
||||
one_failed();
|
||||
}
|
||||
last_message_count = message_count;
|
||||
}
|
||||
|
||||
// If we're the receiver, we've received a time message
|
||||
if ( role == role_receiver )
|
||||
{
|
||||
// Get this payload and dump it
|
||||
size_t len = max_payload_size;
|
||||
memset(receive_payload,0,max_payload_size);
|
||||
|
||||
if ( configuration == '3' )
|
||||
len = next_payload_size;
|
||||
else
|
||||
len = radio.getDynamicPayloadSize();
|
||||
|
||||
radio.read( receive_payload, len );
|
||||
|
||||
// Put a zero at the end for easy printing
|
||||
receive_payload[len] = 0;
|
||||
|
||||
// Spew it
|
||||
prbuf_in += sprintf(prbuf_in,"Recv size=%i val=%s len=%u\n\r",len,receive_payload,strlen(receive_payload));
|
||||
|
||||
// Add an ack packet for the next time around.
|
||||
// Here we will report back how many bytes we got this time.
|
||||
radio.writeAckPayload( pipe_number, &len, sizeof(len) );
|
||||
++message_count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// vim:ai:cin:sts=2 sw=2 ft=cpp
|
37
digistump-avr/libraries/RF24/tests/pingpair_test/printf.h
Normal file
37
digistump-avr/libraries/RF24/tests/pingpair_test/printf.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
Copyright (C) 2011 J. Coliz <maniacbug@ymail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
version 2 as published by the Free Software Foundation.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file printf.h
|
||||
*
|
||||
* Setup necessary to direct stdout to the Arduino Serial library, which
|
||||
* enables 'printf'
|
||||
*/
|
||||
|
||||
#ifndef __PRINTF_H__
|
||||
#define __PRINTF_H__
|
||||
|
||||
#ifdef ARDUINO
|
||||
|
||||
int serial_putc( char c, FILE * )
|
||||
{
|
||||
Serial.write( c );
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
void printf_begin(void)
|
||||
{
|
||||
fdevopen( &serial_putc, 0 );
|
||||
}
|
||||
|
||||
#else
|
||||
#error This example is only for use on Arduino.
|
||||
#endif // ARDUINO
|
||||
|
||||
#endif // __PRINTF_H__
|
25
digistump-avr/libraries/RF24/tests/pingpair_test/runtest.py
Normal file
25
digistump-avr/libraries/RF24/tests/pingpair_test/runtest.py
Normal file
@@ -0,0 +1,25 @@
|
||||
#!/opt/local/bin/python
|
||||
|
||||
import sys,serial
|
||||
|
||||
def read_until(token):
|
||||
while 1:
|
||||
line = ser.readline(None,"\r")
|
||||
sys.stdout.write(line)
|
||||
|
||||
if (line.startswith(token)):
|
||||
break
|
||||
return line
|
||||
|
||||
|
||||
ser = serial.Serial(sys.argv[1], 57600, timeout=5, dsrdtr=False, rtscts=False)
|
||||
|
||||
read_until("+READY")
|
||||
ser.write(sys.argv[2])
|
||||
|
||||
line = read_until("+OK")
|
||||
ser.close()
|
||||
if (line.find("PASS") != -1):
|
||||
sys.exit(0)
|
||||
else:
|
||||
sys.exit(1)
|
21
digistump-avr/libraries/RF24/tests/pingpair_test/runtests.sh
Normal file
21
digistump-avr/libraries/RF24/tests/pingpair_test/runtests.sh
Normal file
@@ -0,0 +1,21 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Connect u0 to receiver, u0 to sender
|
||||
# WARNING: Test config 2 only works with PLUS units.
|
||||
|
||||
jam u0 u1 && expect test.ex 1
|
||||
sleep 1
|
||||
stty 57600 raw ignbrk hup < /dev/ttyUSB0
|
||||
sleep 1
|
||||
stty 57600 raw ignbrk hup < /dev/ttyUSB1
|
||||
expect test.ex 2
|
||||
sleep 1
|
||||
stty 57600 raw ignbrk hup < /dev/ttyUSB0
|
||||
sleep 1
|
||||
stty 57600 raw ignbrk hup < /dev/ttyUSB1
|
||||
expect test.ex 3
|
||||
sleep 1
|
||||
stty 57600 raw ignbrk hup < /dev/ttyUSB0
|
||||
sleep 1
|
||||
stty 57600 raw ignbrk hup < /dev/ttyUSB1
|
||||
expect test.ex 4
|
11
digistump-avr/libraries/RF24/tests/pingpair_test/test.ex
Normal file
11
digistump-avr/libraries/RF24/tests/pingpair_test/test.ex
Normal file
@@ -0,0 +1,11 @@
|
||||
#/usr/bin/expect
|
||||
|
||||
set timeout 100
|
||||
spawn picocom -b 57600 /dev/ttyUSB0
|
||||
expect "+READY"
|
||||
send [lindex $argv 0]
|
||||
expect "+OK"
|
||||
spawn picocom -b 57600 /dev/ttyUSB1
|
||||
expect "+READY"
|
||||
send [lindex $argv 0]
|
||||
expect "+OK"
|
Reference in New Issue
Block a user