-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
509 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,182 @@ | ||
MCU = cortex-m3 ; | ||
CHIP = STM32F103ZE ; | ||
BOARD = maple_native ; | ||
|
||
#CHIP = at91sam3u4 ; | ||
#BOARD = sam3u-ek ; | ||
|
||
if ! $(TOOLSET) | ||
{ | ||
TOOLSET = devkit ; | ||
Echo "Assuming TOOLSET=devkit" ; | ||
} | ||
|
||
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- ; | ||
} | ||
else if $(TOOLSET) = ports | ||
{ | ||
TOOLS_PATH = /opt/local/bin ; | ||
TOOLS_ARCH = arm-none-eabi- ; | ||
} | ||
|
||
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 ; | ||
|
||
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 ; | ||
|
||
MAPLE_DIR = $(HOME)/Source/SAM3U/libmaple ; | ||
MAPLE_LIBS = Servo LiquidCrystal Wire FreeRTOS ; | ||
MAPLE_SUBDIRS = wirish wirish/comm wirish/boards libmaple libmaple/usb libmaple/usb/usb_lib ; | ||
|
||
SKETCH_DIR = $(HOME)/Source/Arduino ; | ||
SKETCH_LIBS = RF24 ; | ||
|
||
MODULE_DIRS = . $(MAPLE_DIR)/$(MAPLE_SUBDIRS) $(MAPLE_DIR)/libraries/$(MAPLE_LIBS) $(SKETCH_DIR)/libraries/$(SKETCH_LIBS) ; | ||
HDRS = $(MODULE_DIRS) ; | ||
LOCATE_TARGET = out/$(TOOLSET) ; | ||
LOCATE_SOURCE = $(LOCATE_TARGET) ; | ||
|
||
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 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 $(<) : $(>) ; | ||
} | ||
} | ||
|
||
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 | ||
{ | ||
MainFromObjects $(<) : $(>:B)$(SUFOBJ) ; | ||
Objects $(>) ; | ||
} | ||
|
||
# Modules | ||
MODULES = [ GLOB $(MODULE_DIRS) : *.pde *.c *.cpp *.S ] ; | ||
|
||
# Main output executable | ||
MAIN = $(PWD:B).elf ; | ||
|
||
# Linker script | ||
LINK_DIR = $(MAPLE_DIR)/support/ld ; | ||
LINKSCRIPT = $(LINK_DIR)/$(BOARD)/flash.ld ; | ||
|
||
# Bring in the map and link script | ||
LINKFLAGS += -Wl,-Map=$(LOCATE_TARGET)/$(MAIN:B).map -T$(LINKSCRIPT) -L$(LINK_DIR) ; | ||
|
||
Main $(MAIN) : $(MODULES) ; | ||
Binary $(MAIN:B).bin : $(MAIN) ; | ||
Upload $(MAIN:B).bin ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
#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; | ||
} | ||
|
||
/** | ||
* Re-entrant version of _write. Yagarto and Devkit now use | ||
* the re-entrant newlib, so these get called instead of the | ||
* non_r versions. | ||
*/ | ||
extern "C" int _write_r (void*, int file, char * ptr, int len) | ||
{ | ||
return _write( file, ptr, 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 |
Oops, something went wrong.