Permalink
Browse files

[cortex][samd21] Blink example on Arduino M0

  • Loading branch information...
jlbirccyn committed Jan 20, 2017
1 parent 4ee0d82 commit cfeff15a5a68a2a41c868912be2f855d5ae689dd
@@ -0,0 +1,50 @@
# Blink example
This application is a simple periodic example which toggles the Arduino M0 builtin led (pin 13).
Have a look into "blink.oil" file.
The system is based scheduled with a 1ms SysTick "SystemCounter".
The task "blink" toggles the yellow (PA.17) led when executed.
This is not scheduled when the program starts.
This task is activated by the alarm `blink_blink`. The alarm:
* starts 250ms (`ALARMTIME`) after "StartOS".
* has a 250ms (`CYCLETIME`) period.
## Build prerequiste
Currently we use a SEGGER J-Link EDU to flash the Arduino M0. Launch the GDB server with the command:
```
JLinkGDBServer -device ATSAMD21J18 -if SWD
```
## Build for GNU/Linux, Mac and Windows (cli)
The option `CPU->OS->BUILD->SYSTEM` should be set to `PYTHON`.
Configure the application with:
```
goil --target=cortex/armv6m/samd21/ArduinoM0 --templates=../../../../../../goil/templates blink.oil
```
The `goil` compiler generates the `make.py` [python build script](https://github.com/TrampolineRTOS/trampoline/wiki/Application-Build-system). Then run the script:
```
./make.py
```
The `blink_exe` should be generated.
## Clean
Use the `clean` target of the make.py:
```
./make.py clean
```
@@ -0,0 +1,23 @@
#include "tpl_os.h"
//the READY tasks state definition conflicts with registers definition (in sam.h)
#undef READY
#include "sam.h"
#define APP_Task_blink_START_SEC_CODE
#include "tpl_memmap.h"
FUNC(int, OS_APPL_CODE) main(void)
{
//led on PA.17
PORT->Group[0].DIRSET.reg = 1<<17;
StartOS(OSDEFAULTAPPMODE);
return 0;
}
TASK(blink)
{
PORT->Group[0].OUTTGL.reg= 1<<17;
TerminateTask();
}
#define APP_Task_blink_STOP_SEC_CODE
#include "tpl_memmap.h"
@@ -0,0 +1,63 @@
OIL_VERSION = "2.5";
IMPLEMENTATION trampoline {
/* This fix the default STACKSIZE of tasks */
TASK {
UINT32 STACKSIZE = 300 ;
} ;
/* This fix the default STACKSIZE of ISRs */
ISR {
UINT32 STACKSIZE = 200 ;
} ;
};
CPU blink {
OS config {
STATUS = EXTENDED;
BUILD = TRUE {
TRAMPOLINE_BASE_PATH = "../../../../../..";
APP_SRC = "blink.c";
APP_NAME = "blink_exe";
CFLAGS = "-O3";
LDFLAGS = "-Map=blink.map";
COMPILER = "arm-none-eabi-gcc";
ASSEMBLER = "arm-none-eabi-as";
LINKER = "arm-none-eabi-ld";
COPIER = "arm-none-eabi-objcopy";
SYSTEM = PYTHON;
//SYSTEM = ATMELSTUDIO;
};
SYSTEM_CALL = TRUE;
MEMMAP = TRUE {
COMPILER = gcc;
LINKER = gnu_ld { SCRIPT = "script.ld"; };
ASSEMBLER = gnu_as;
MEMORY_PROTECTION = FALSE;
};
};
APPMODE std {};
TASK blink {
PRIORITY = 1;
AUTOSTART = FALSE;
ACTIVATION = 1;
SCHEDULE = FULL;
};
ALARM blink_blink {
COUNTER = SystemCounter;
ACTION = ACTIVATETASK {
TASK = blink;
};
AUTOSTART = TRUE {
APPMODE = std;
ALARMTIME = 250;
CYCLETIME = 250;
};
};
};
@@ -14,6 +14,7 @@ CPU buildOptions {
COMMONFLAGS = "-mthumb"; // Thumb instruction set
COMMONFLAGS = "-mfloat-abi=soft"; // Floating point numbers are computed in software
COMMONFLAGS = "-nostartfiles"; // Default startfiles (crt0.c) are not used
COMMONFLAGS = "-fno-builtin"; // Do not used built in gcc functions
COMMONFLAGS = "--specs=nosys.specs"; //
COMMONFLAGS = "-fno-exceptions"; // No exceptions managed
COMMONFLAGS = "-nostdlib"; // Do not used implicitely the standard libraries to link
@@ -0,0 +1,7 @@
CPU XPlainedPro {
PLATFORM_FILES XPlainedPro {
PATH = "cortex/armv6m/samd21/ArduinoM0";
CFILE = "system_samd21_ArduinoM0_48MHz.c";
};
};
Oops, something went wrong.

0 comments on commit cfeff15

Please sign in to comment.