Skip to content

Commit

Permalink
Cherry picked commits pulled from baruch/nRF24LE1_Programmer
Browse files Browse the repository at this point in the history
  • Loading branch information
DeanCording committed Dec 7, 2014
1 parent 42e0067 commit c01392a
Show file tree
Hide file tree
Showing 6 changed files with 309 additions and 26 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
**/.directory
**/build-*
92 changes: 92 additions & 0 deletions Read_Infopage/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# STANDARD ARDUINO WORKFLOW
#
# Given a normal sketch directory, all you need to do is to create
# a small Makefile which defines a few things, and then includes this one.
#
# For example:
#
# ARDUINO_LIBS = Ethernet Ethernet/utility SPI
# BOARD_TAG = uno
# ARDUINO_PORT = /dev/cu.usb*
#
# include /usr/share/arduino/Arduino.mk
#
# Hopefully these will be self-explanatory but in case they're not:
#
# ARDUINO_LIBS - A list of any libraries used by the sketch (we
# assume these are in $(ARDUINO_DIR)/hardware/libraries
# or your sketchbook's libraries directory)
#
# ARDUINO_PORT - The port where the Arduino can be found (only needed
# when uploading)
#
# BOARD_TAG - The ard-parse-boards tag for the board e.g. uno or mega
# 'make show_boards' shows a list
#
# If you have your additional libraries relative to your source, rather
# than in your "sketchbook", also set USER_LIB_PATH, like this example:
#
# USER_LIB_PATH := $(realpath ../../libraries)
#
# If you've added the Arduino-Makefile repository to your git repo as a
# submodule (or other similar arrangement), you might have lines like this
# in your Makefile:
#
# ARDMK_DIR := $(realpath ../../tools/Arduino-Makefile)
# include $(ARDMK_DIR)/arduino-mk/Arduino.mk
#
# In any case, once this file has been created the typical workflow is just
#
# $ make upload
#
# All of the object files are created in the build-{BOARD_TAG} subdirectory
# All sources should be in the current directory and can include:
# - at most one .pde or .ino file which will be treated as C++ after
# the standard Arduino header and footer have been affixed.
# - any number of .c, .cpp, .s and .h files
#
# Included libraries are built in the build-{BOARD_TAG}/libs subdirectory.
#
# Besides make upload you can also
# make - no upload
# make clean - remove all our dependencies
# make depends - update dependencies
# make reset - reset the Arduino by tickling DTR on the serial port
# make raw_upload - upload without first resetting
# make show_boards - list all the boards defined in boards.txt
# make monitor - connect to the Arduino's serial port
# make size - show the size of the compiled output (relative to
# resources, if you have a patched avr-size)
# make disasm - generate a .lss file in build-cli that contains
# disassembly of the compiled file interspersed
# with your original source code.
# make verify_size - Verify that the size of the final file is less than
# the capacity of the micro controller.
# make eeprom - upload the eep file
# make raw_eeprom - upload the eep file without first resetting
#
########################################################################
#
# SERIAL MONITOR
#
# The serial monitor just invokes the GNU screen program with suitable
# options. For more information see screen (1) and search for
# 'character special device'.
#
# The really useful thing to know is that ^A-k gets you out!
#
# The fairly useful thing to know is that you can bind another key to
# escape too, by creating $HOME{.screenrc} containing e.g.
#
# bindkey ^C kill
#
# If you want to change the baudrate, just set MONITOR_BAUDRATE. If you
# don't set it, it tries to read from the sketch. If it couldn't read
# from the sketch, then it defaults to 9600 baud.
#
########################################################################

ARDUINO_LIBS = SPI SoftwareSerial
BOARD_TAG = uno
ARDUINO_PORT = /dev/ttyACM*
include /usr/share/arduino/Arduino.mk
25 changes: 14 additions & 11 deletions Read_Infopage/Read_Infopage.ino
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
/*
Read_Infopage
Reads InfoPage contents from Nordic nRF24LE1 SOC RF chips using SPI interface from an Arduino.
Useful for making a backup of the system variables stored in the InfoPage.
Upload sketch, start serial monitor, type 'GO' to start sketch running.
Copyright (c) 2014 Dean Cording
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

/*
Expand Down Expand Up @@ -96,7 +96,7 @@
#define RDISMB 0x85 // Enable flash readback protection
#define ENDEBUG 0x86 // Enable HW debug features

/* NOTE: The InfoPage area DSYS are used to store nRF24LE1 system and tuning parameters.
/* NOTE: The InfoPage area DSYS are used to store nRF24LE1 system and tuning parameters.
* Erasing the content of this area WILL cause changes to device behavior and performance. InfoPage area
* DSYS should ALWAYS be read out and stored prior to using ERASE ALL. Upon completion of the
* erase the DSYS information must be written back to the flash InfoPage.
Expand Down Expand Up @@ -132,15 +132,18 @@ void setup() {

Serial.println("READY");
// Wait for GO command from Serial
//while (!Serial.find("GO\n"));
while (!Serial.find("GO\n"));
Serial.println("READYING");
delay(1000);
Serial.println("SETTING UP");

// Put nRF24LE1 into programming mode
digitalWrite(PROG, HIGH);
digitalWrite(_RESET_, LOW);
delay(10);
digitalWrite(_RESET_, HIGH);

// Set InfoPage bit so InfoPage flash is read
// Set InfoPage bit so InfoPage flash is read
digitalWrite(_FCSN_, LOW);
SPI.transfer(RDSR);
fsr = SPI.transfer(0x00);
Expand Down Expand Up @@ -178,7 +181,7 @@ void setup() {
Serial.print(": ");
Serial.println(spi_data);
}
digitalWrite(_FCSN_, HIGH);
digitalWrite(_FCSN_, HIGH);

done:
Serial.println("DONE");
Expand Down
92 changes: 92 additions & 0 deletions Read_Mainpage/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# STANDARD ARDUINO WORKFLOW
#
# Given a normal sketch directory, all you need to do is to create
# a small Makefile which defines a few things, and then includes this one.
#
# For example:
#
# ARDUINO_LIBS = Ethernet Ethernet/utility SPI
# BOARD_TAG = uno
# ARDUINO_PORT = /dev/cu.usb*
#
# include /usr/share/arduino/Arduino.mk
#
# Hopefully these will be self-explanatory but in case they're not:
#
# ARDUINO_LIBS - A list of any libraries used by the sketch (we
# assume these are in $(ARDUINO_DIR)/hardware/libraries
# or your sketchbook's libraries directory)
#
# ARDUINO_PORT - The port where the Arduino can be found (only needed
# when uploading)
#
# BOARD_TAG - The ard-parse-boards tag for the board e.g. uno or mega
# 'make show_boards' shows a list
#
# If you have your additional libraries relative to your source, rather
# than in your "sketchbook", also set USER_LIB_PATH, like this example:
#
# USER_LIB_PATH := $(realpath ../../libraries)
#
# If you've added the Arduino-Makefile repository to your git repo as a
# submodule (or other similar arrangement), you might have lines like this
# in your Makefile:
#
# ARDMK_DIR := $(realpath ../../tools/Arduino-Makefile)
# include $(ARDMK_DIR)/arduino-mk/Arduino.mk
#
# In any case, once this file has been created the typical workflow is just
#
# $ make upload
#
# All of the object files are created in the build-{BOARD_TAG} subdirectory
# All sources should be in the current directory and can include:
# - at most one .pde or .ino file which will be treated as C++ after
# the standard Arduino header and footer have been affixed.
# - any number of .c, .cpp, .s and .h files
#
# Included libraries are built in the build-{BOARD_TAG}/libs subdirectory.
#
# Besides make upload you can also
# make - no upload
# make clean - remove all our dependencies
# make depends - update dependencies
# make reset - reset the Arduino by tickling DTR on the serial port
# make raw_upload - upload without first resetting
# make show_boards - list all the boards defined in boards.txt
# make monitor - connect to the Arduino's serial port
# make size - show the size of the compiled output (relative to
# resources, if you have a patched avr-size)
# make disasm - generate a .lss file in build-cli that contains
# disassembly of the compiled file interspersed
# with your original source code.
# make verify_size - Verify that the size of the final file is less than
# the capacity of the micro controller.
# make eeprom - upload the eep file
# make raw_eeprom - upload the eep file without first resetting
#
########################################################################
#
# SERIAL MONITOR
#
# The serial monitor just invokes the GNU screen program with suitable
# options. For more information see screen (1) and search for
# 'character special device'.
#
# The really useful thing to know is that ^A-k gets you out!
#
# The fairly useful thing to know is that you can bind another key to
# escape too, by creating $HOME{.screenrc} containing e.g.
#
# bindkey ^C kill
#
# If you want to change the baudrate, just set MONITOR_BAUDRATE. If you
# don't set it, it tries to read from the sketch. If it couldn't read
# from the sketch, then it defaults to 9600 baud.
#
########################################################################

ARDUINO_LIBS = SPI SoftwareSerial
BOARD_TAG = uno
ARDUINO_PORT = /dev/ttyACM*
include /usr/share/arduino/Arduino.mk
33 changes: 18 additions & 15 deletions Read_Mainpage/Read_Mainpage.ino
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
/*
Read_Mainpage
Reads MainPage flash contents from Nordic nRF24LE1 SOC RF chips using SPI interface from
Reads MainPage flash contents from Nordic nRF24LE1 SOC RF chips using SPI interface from
an Arduino.
Upload sketch, start serial monitor, type 'GO' to start sketch running.
Copyright (c) 2014 Dean Cording
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

/*
Expand Down Expand Up @@ -96,7 +96,7 @@
#define RDISMB 0x85 // Enable flash readback protection
#define ENDEBUG 0x86 // Enable HW debug features

/* NOTE: The InfoPage area DSYS are used to store nRF24LE1 system and tuning parameters.
/* NOTE: The InfoPage area DSYS are used to store nRF24LE1 system and tuning parameters.
* Erasing the content of this area WILL cause changes to device behavior and performance. InfoPage area
* DSYS should ALWAYS be read out and stored prior to using ERASE ALL. Upon completion of the
* erase the DSYS information must be written back to the flash InfoPage.
Expand Down Expand Up @@ -132,15 +132,18 @@ void setup() {

Serial.println("READY");
// Wait for GO command from Serial
//while (!Serial.find("GO\n"));
while (!Serial.find("GO\n"));
Serial.println("READYING");
delay(1000);
Serial.println("SETTING UP");

// Put nRF24LE1 into programming mode
digitalWrite(PROG, HIGH);
digitalWrite(_RESET_, LOW);
delay(10);
digitalWrite(_RESET_, HIGH);

// Set InfoPage bit so InfoPage flash is read
// Set InfoPage bit so InfoPage flash is read
digitalWrite(_FCSN_, LOW);
SPI.transfer(RDSR);
fsr = SPI.transfer(0x00);
Expand Down Expand Up @@ -170,15 +173,15 @@ void setup() {
SPI.transfer(READ);
SPI.transfer(0);
SPI.transfer(0);
for (int index = 0; index < 100; index++) {
for (int index = 0; index < 16*1024; index++) {
spi_data = SPI.transfer(0x00);
Serial.print(index);
Serial.print(": ");
Serial.println(spi_data);
}
digitalWrite(_FCSN_, HIGH);
digitalWrite(_FCSN_, HIGH);

done:
done:
Serial.println("DONE");

// Take nRF24LE1 out of programming mode
Expand All @@ -194,7 +197,7 @@ done:


void loop() {

// Do nothing
delay(1000);
}
Expand Down
Loading

0 comments on commit c01392a

Please sign in to comment.