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:
12
digistump-sam/libraries/RF24Network/examples/maple/Jamfile
Normal file
12
digistump-sam/libraries/RF24Network/examples/maple/Jamfile
Normal file
@@ -0,0 +1,12 @@
|
||||
SubDir TOP ;
|
||||
|
||||
# Set up output directories
|
||||
LOCATE_TARGET = $(SEARCH_SOURCE)/out/$(TOOLSET) ;
|
||||
LOCATE_SOURCE = $(LOCATE_TARGET) ;
|
||||
|
||||
# Pull in local libraries
|
||||
SKETCH_LIBS += RF24Network RF24 ;
|
||||
HDRS += $(HOME)/Source/Arduino/libraries/$(SKETCH_LIBS) ;
|
||||
|
||||
# Main output executable
|
||||
Maple $(SEARCH_SOURCE:B).elf : [ GLOB $(SEARCH_SOURCE) $(HOME)/Source/Arduino/libraries/$(SKETCH_LIBS) : $(MODULE_EXT) ] ;
|
237
digistump-sam/libraries/RF24Network/examples/maple/Jamrules
Normal file
237
digistump-sam/libraries/RF24Network/examples/maple/Jamrules
Normal file
@@ -0,0 +1,237 @@
|
||||
MCU = cortex-m3 ;
|
||||
CHIP = STM32F103ZE ;
|
||||
BOARD = maple_native ;
|
||||
|
||||
#CHIP = at91sam3u4 ;
|
||||
#BOARD = sam3u-ek ;
|
||||
|
||||
if ! $(TOOLSET)
|
||||
{
|
||||
TOOLSET = mix ;
|
||||
Echo "Assuming TOOLSET=mix" ;
|
||||
}
|
||||
else if $(TOOLSET) = cs
|
||||
{
|
||||
TOOLS_PATH = /opt/cs/arm/bin ;
|
||||
TOOLS_ARCH = arm-none-eabi- ;
|
||||
}
|
||||
else if $(TOOLSET) = yagarto
|
||||
{
|
||||
TOOLS_PATH = ~/Source/yagarto-4.6.2/bin ;
|
||||
TOOLS_ARCH = arm-none-eabi- ;
|
||||
}
|
||||
if $(TOOLSET) = yagarto-install
|
||||
{
|
||||
TOOLS_PATH = ~/Source/yagarto/install/bin ;
|
||||
TOOLS_ARCH = arm-none-eabi- ;
|
||||
}
|
||||
else if $(TOOLSET) = devkit
|
||||
{
|
||||
TOOLS_PATH = /opt/devkitARM/bin ;
|
||||
TOOLS_ARCH = arm-eabi- ;
|
||||
}
|
||||
else if $(TOOLSET) = maple
|
||||
{
|
||||
TOOLS_PATH = /opt/Maple/Resources/Java/hardware/tools/arm/bin ;
|
||||
TOOLS_ARCH = arm-none-eabi- ;
|
||||
LINK_DIR = /opt/Maple/Resources/Java/hardware/leaflabs/cores/maple ;
|
||||
MAPLE_DIR = /opt/Maple/Resources/Java/hardware/leaflabs/cores/maple ;
|
||||
MAPLE_SUBDIRS = . ;
|
||||
}
|
||||
else if $(TOOLSET) = mix
|
||||
{
|
||||
TOOLS_PATH = /opt/Maple/Resources/Java/hardware/tools/arm/bin ;
|
||||
TOOLS_ARCH = arm-none-eabi- ;
|
||||
LINKFLAGS += --print-gc-sections ;
|
||||
}
|
||||
else if $(TOOLSET) = ports
|
||||
{
|
||||
TOOLS_PATH = /opt/local/bin ;
|
||||
TOOLS_ARCH = arm-none-eabi- ;
|
||||
}
|
||||
|
||||
# Tool locations
|
||||
|
||||
CC = $(TOOLS_PATH)/$(TOOLS_ARCH)gcc ;
|
||||
C++ = $(TOOLS_PATH)/$(TOOLS_ARCH)g++ ;
|
||||
AS = $(TOOLS_PATH)/$(TOOLS_ARCH)gcc -c ;
|
||||
LINK = $(TOOLS_PATH)/$(TOOLS_ARCH)g++ ;
|
||||
OBJCOPY = $(TOOLS_PATH)/$(TOOLS_ARCH)objcopy ;
|
||||
DFU = dfu-util ;
|
||||
|
||||
# Flags
|
||||
|
||||
DEFINES += VECT_TAB_FLASH BOARD_$(BOARD) MCU_$(CHIP) ERROR_LED_PORT=GPIOC ERROR_LED_PIN=15 STM32_HIGH_DENSITY MAPLE_IDE ;
|
||||
OPTIM = -Os ;
|
||||
MFLAGS = cpu=$(MCU) thumb arch=armv7-m ;
|
||||
CCFLAGS = -Wall -m$(MFLAGS) -g -nostdlib -ffunction-sections -fdata-sections -Wl,--gc-sections ;
|
||||
C++FLAGS = $(CCFLAGS) -fno-rtti -fno-exceptions ;
|
||||
LINKFLAGS += -m$(MFLAGS) -Xlinker --gc-sections ;
|
||||
DFUFLAGS = -a1 -d 0x1eaf:0x0003 -R ;
|
||||
|
||||
# Directories
|
||||
|
||||
MAPLE_DIR ?= /opt/libmaple ;
|
||||
MAPLE_LIBS = Servo LiquidCrystal Wire FreeRTOS ;
|
||||
MAPLE_SUBDIRS ?= libmaple libmaple/usb libmaple/usb/usb_lib wirish wirish/comm wirish/boards ;
|
||||
|
||||
SKETCH_DIR = $(HOME)/Source/Maple ;
|
||||
|
||||
CORE_DIRS = $(MAPLE_DIR)/$(MAPLE_SUBDIRS) $(MAPLE_DIR)/libraries/$(MAPLE_LIBS) ;
|
||||
HDRS = $(CORE_DIRS) ;
|
||||
|
||||
# Modules
|
||||
MODULE_EXT = *.c *.cpp *.S *.pde *.ino *.test ;
|
||||
CORE_MODULES = [ GLOB $(CORE_DIRS) : $(MODULE_EXT) ] ;
|
||||
|
||||
# Unit test framework
|
||||
CXXTEST_DIR = $(HOME)/Source/cxxtest ;
|
||||
#CXXTEST_GEN = $(CXXTEST_DIR)/cxxtestgen.py ;
|
||||
CXXTEST_GEN = $(CXXTEST_DIR)/python/scripts/cxxtestgen ;
|
||||
HDRS += $(CXXTEST_DIR) ;
|
||||
|
||||
# Linker script
|
||||
LINK_DIR ?= $(MAPLE_DIR)/support/ld ;
|
||||
LINKSCRIPT = $(LINK_DIR)/$(BOARD)/flash.ld ;
|
||||
LINKFLAGS += -T$(LINKSCRIPT) -L$(LINK_DIR) ;
|
||||
|
||||
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 TestSuite
|
||||
{
|
||||
Depends $(<) : $(>) ;
|
||||
MakeLocate $(<) : $(LOCATE_SOURCE) ;
|
||||
Clean clean : $(<) ;
|
||||
}
|
||||
|
||||
actions TestSuite
|
||||
{
|
||||
$(CXXTEST_GEN) --part $(>) > $(<)
|
||||
}
|
||||
|
||||
rule TestRoot
|
||||
{
|
||||
MakeLocate $(<) : $(LOCATE_SOURCE) ;
|
||||
}
|
||||
|
||||
actions TestRoot
|
||||
{
|
||||
$(CXXTEST_GEN) --root --error-printer > $(<)
|
||||
}
|
||||
|
||||
rule C++TestSuite
|
||||
{
|
||||
local _CPP = $(>:B).cpp ;
|
||||
TestSuite $(_CPP) : $(>) ;
|
||||
C++ $(<) : $(_CPP) ;
|
||||
}
|
||||
|
||||
rule Hex
|
||||
{
|
||||
Depends $(<) : $(>) ;
|
||||
MakeLocate $(<) : $(LOCATE_TARGET) ;
|
||||
Depends hex : $(<) ;
|
||||
Clean clean : $(<) ;
|
||||
}
|
||||
|
||||
actions Hex
|
||||
{
|
||||
$(OBJCOPY) -O ihex $(>) $(<)
|
||||
}
|
||||
|
||||
rule Binary
|
||||
{
|
||||
Depends $(<) : $(>) ;
|
||||
MakeLocate $(<) : $(LOCATE_TARGET) ;
|
||||
Depends binary : $(<) ;
|
||||
Clean clean : $(<) ;
|
||||
}
|
||||
|
||||
actions Binary
|
||||
{
|
||||
$(OBJCOPY) -O binary $(>) $(<)
|
||||
}
|
||||
|
||||
rule UserObject
|
||||
{
|
||||
switch $(>:S)
|
||||
{
|
||||
case .S : As $(<) : $(>) ;
|
||||
case .ino : C++Pde $(<) : $(>) ;
|
||||
case .pde : C++Pde $(<) : $(>) ;
|
||||
case .test : C++TestSuite $(<) : $(>) ;
|
||||
}
|
||||
}
|
||||
|
||||
rule Upload
|
||||
{
|
||||
Depends up : $(<) ;
|
||||
NotFile up ;
|
||||
Always $(<) ;
|
||||
Always up ;
|
||||
}
|
||||
|
||||
actions Upload
|
||||
{
|
||||
$(DFU) $(DFUFLAGS) -D $(<)
|
||||
}
|
||||
|
||||
# Override base objects rule, so all output can go in the output dir
|
||||
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) ;
|
||||
}
|
||||
}
|
||||
|
||||
# Override base main rule, so all output can go in the output dir
|
||||
rule Main
|
||||
{
|
||||
# Bring in the map
|
||||
LINKFLAGS on $(<) = $(LINKFLAGS) -Wl,-Map=$(LOCATE_TARGET)/$(<:B).map ;
|
||||
|
||||
MakeLocate $(<) ;
|
||||
MainFromObjects $(<) : $(>:B)$(SUFOBJ) ;
|
||||
Objects $(>) ;
|
||||
}
|
||||
|
||||
rule Maple
|
||||
{
|
||||
Main $(<) : $(>) $(CORE_MODULES) ;
|
||||
Binary $(<:B).bin : $(<) ;
|
||||
Upload $(<:B).bin ;
|
||||
}
|
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Simplest possible example of using RF24Network
|
||||
*
|
||||
* TRANSMITTER NODE
|
||||
* Every 2 seconds, says hello to the receiver node.
|
||||
*/
|
||||
|
||||
#include <RF24Network.h>
|
||||
#include <RF24.h>
|
||||
#include <SPI.h>
|
||||
|
||||
//
|
||||
// Maple specific setup. Other than this section, the sketch is the same on Maple as on
|
||||
// Arduino
|
||||
//
|
||||
|
||||
#ifdef MAPLE_IDE
|
||||
|
||||
// External startup function
|
||||
extern void board_start(const char* program_name);
|
||||
|
||||
// Use SPI #2.
|
||||
HardwareSPI SPI(2);
|
||||
|
||||
inline void serial_begin(int _baud)
|
||||
{
|
||||
}
|
||||
#else
|
||||
inline void serial_begin(int _baud)
|
||||
{
|
||||
Serial.begin(_baud);
|
||||
}
|
||||
#define board_startup printf
|
||||
#define toggleLED(x) (x)
|
||||
#endif
|
||||
|
||||
//
|
||||
// Hardware configuration
|
||||
//
|
||||
|
||||
// Set up nRF24L01 radio on SPI bus plus pins 7 & 6
|
||||
// (This works for the Getting Started board plugged into the
|
||||
// Maple Native backwards.)
|
||||
|
||||
RF24 radio(7,6);
|
||||
|
||||
// Network uses that radio
|
||||
RF24Network network(radio);
|
||||
|
||||
// Address of our node
|
||||
const uint16_t this_node = 1;
|
||||
|
||||
// Address of the other node
|
||||
const uint16_t other_node = 0;
|
||||
|
||||
// How often to send 'hello world to the other unit
|
||||
const unsigned long interval = 2000; //ms
|
||||
|
||||
// When did we last send?
|
||||
unsigned long last_sent;
|
||||
|
||||
void setup(void)
|
||||
{
|
||||
serial_begin(57600);
|
||||
board_start("RF24Network/examples/helloworld_tx/");
|
||||
|
||||
SPI.begin();
|
||||
radio.begin();
|
||||
network.begin(/*channel*/ 90, /*node address*/ this_node);
|
||||
}
|
||||
|
||||
void loop(void)
|
||||
{
|
||||
// Pump the network regularly
|
||||
network.update();
|
||||
|
||||
// If it's time to send a message, send it!
|
||||
unsigned long now = millis();
|
||||
if ( now - last_sent > interval )
|
||||
{
|
||||
last_sent = now;
|
||||
|
||||
toggleLED();
|
||||
printf("Sending...\r\n");
|
||||
const char* hello = "Hello, world!";
|
||||
RF24NetworkHeader header(/*to node*/ other_node);
|
||||
bool ok = network.write(header,hello,strlen(hello));
|
||||
if (ok)
|
||||
printf("\tok.\r\n");
|
||||
else
|
||||
{
|
||||
printf("\tfailed.\r\n");
|
||||
delay(250); // extra delay on fail to keep light on longer
|
||||
}
|
||||
toggleLED();
|
||||
}
|
||||
}
|
||||
// vim:ai:cin:sts=2 sw=2 ft=cpp
|
77
digistump-sam/libraries/RF24Network/examples/maple/main.cpp
Normal file
77
digistump-sam/libraries/RF24Network/examples/maple/main.cpp
Normal file
@@ -0,0 +1,77 @@
|
||||
#ifdef MAPLE_IDE
|
||||
|
||||
#include <stdio.h>
|
||||
#include "wirish.h"
|
||||
|
||||
extern void setup(void);
|
||||
extern void loop(void);
|
||||
|
||||
void board_start(const char* program_name)
|
||||
{
|
||||
// Set up the LED to steady on
|
||||
pinMode(BOARD_LED_PIN, OUTPUT);
|
||||
digitalWrite(BOARD_LED_PIN, HIGH);
|
||||
|
||||
// Setup the button as input
|
||||
pinMode(BOARD_BUTTON_PIN, INPUT);
|
||||
digitalWrite(BOARD_BUTTON_PIN, HIGH);
|
||||
|
||||
SerialUSB.begin();
|
||||
SerialUSB.println("Press BUT");
|
||||
|
||||
// Wait for button press
|
||||
while ( !isButtonPressed() )
|
||||
{
|
||||
}
|
||||
|
||||
SerialUSB.println("Welcome!");
|
||||
SerialUSB.println(program_name);
|
||||
|
||||
int i = 11;
|
||||
while (i--)
|
||||
{
|
||||
toggleLED();
|
||||
delay(50);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom version of _write, which will print to the USB.
|
||||
* In order to use it you MUST ADD __attribute__((weak))
|
||||
* to _write in libmaple/syscalls.c
|
||||
*/
|
||||
extern "C" int _write(int file, char * ptr, int len)
|
||||
{
|
||||
if ( (file != 1) && (file != 2) )
|
||||
return 0;
|
||||
else
|
||||
SerialUSB.write(ptr,len);
|
||||
return len;
|
||||
}
|
||||
|
||||
__attribute__((constructor)) __attribute__ ((weak)) void premain()
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
__attribute__((weak)) void setup(void)
|
||||
{
|
||||
board_start("No program defined");
|
||||
}
|
||||
|
||||
__attribute__((weak)) void loop(void)
|
||||
{
|
||||
}
|
||||
|
||||
__attribute__((weak)) int main(void)
|
||||
{
|
||||
setup();
|
||||
|
||||
while (true)
|
||||
{
|
||||
loop();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif // ifdef MAPLE_IDE
|
||||
// vim:cin:ai:sts=2 sw=2 ft=cpp
|
Reference in New Issue
Block a user