-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create new non-timer based blink app
Now that timeslicing is up and running, there is no harm in having a synchronous blink app and it is useful for porting new hardware (before a driver for the hardware driver has been implemented). Renames the timer-based, asynchronous, blink app to "blink" and creates a new synchronous app (that just spins for a while) called "blink_sync".
- Loading branch information
Showing
6 changed files
with
113 additions
and
1 deletion.
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
TOCK_APPS_DIR=.. | ||
APP=c_blinky | ||
APP=blink | ||
|
||
include $(TOCK_APPS_DIR)/Makefile.GenericApp.mk | ||
|
||
|
File renamed without changes.
File renamed without changes.
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,6 @@ | ||
TOCK_APPS_DIR=.. | ||
APP=blink_sync | ||
|
||
include $(TOCK_APPS_DIR)/Makefile.GenericApp.mk | ||
|
||
CPPFLAGS += -DSTACK_SIZE=2048 |
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,56 @@ | ||
ENTRY(_start) | ||
|
||
MEMORY { | ||
FLASH (rx) : ORIGIN = 0x80000000, LENGTH = 0x00080000 | ||
SRAM (RWX) : ORIGIN = 0x00000000, LENGTH = 0x00002000 | ||
} | ||
|
||
SECTIONS { | ||
/* Load information, used by runtime to load app */ | ||
.load_info : | ||
{ | ||
KEEP(*(.load_info)) | ||
} > FLASH =0xFF | ||
|
||
/* Text section, Code! */ | ||
.text : | ||
{ | ||
_text = .; | ||
KEEP (*(.start)) | ||
*(.text*) | ||
*(.rodata*) | ||
KEEP (*(.syscalls)) | ||
_etext = .; | ||
} > FLASH =0xFF | ||
|
||
/* Global Offset Table */ | ||
.got : | ||
{ | ||
_got = .; | ||
*(.got*) | ||
_egot = .; | ||
_plt = .; | ||
*(.got.plt*) | ||
_eplt = .; | ||
} > SRAM AT > FLASH | ||
|
||
/* Data section, static initialized variables | ||
* Note: This is placed in Flash after the text section, but needs to be | ||
* moved to SRAM at runtime | ||
*/ | ||
.data : | ||
{ | ||
_data = .; | ||
*(.data*) | ||
_edata = .; | ||
} > SRAM AT > FLASH | ||
|
||
/* BSS section, static uninitialized variables */ | ||
.bss : | ||
{ | ||
_bss = .; | ||
*(.bss*) | ||
*(COMMON) | ||
_ebss = .; | ||
} > SRAM | ||
} |
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,50 @@ | ||
#include <firestorm.h> | ||
#include <gpio.h> | ||
|
||
/* Delay for for the given microseconds (approximately). | ||
* | ||
* For a 16 MHz CPU, 1us == 16 instructions (assuming each instruction takes | ||
* one cycle). */ | ||
static void busy_delay_us(int duration) | ||
{ | ||
// The inner loop instructions are: 14 NOPs + 1 SUBS/ADDS + 1 CMP | ||
while (duration-- != 0) { | ||
__asm volatile ( | ||
"nop\n" | ||
"nop\n" | ||
"nop\n" | ||
"nop\n" | ||
"nop\n" | ||
"nop\n" | ||
"nop\n" | ||
"nop\n" | ||
"nop\n" | ||
"nop\n" | ||
"nop\n" | ||
"nop\n" | ||
"nop\n" | ||
"nop\n" | ||
); | ||
} | ||
} | ||
|
||
/* Delay for for the given milliseconds (approximately). | ||
* | ||
* Note that this is not precise as there are 2 extra instructions on the inner | ||
* loop. Therefore, there is 1us added every 8 iterations. */ | ||
static void busy_delay_ms(int duration) | ||
{ | ||
while (duration-- != 0) { | ||
busy_delay_us(1000); | ||
} | ||
} | ||
|
||
void main(void) { | ||
gpio_enable_output(LED_0); | ||
|
||
while(1) { | ||
gpio_toggle(LED_0); | ||
busy_delay_ms(500); | ||
} | ||
} | ||
|