Skip to content

Instantly share code, notes, and snippets.

@four0four
Last active November 16, 2015 06:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save four0four/6378ed55952203a5fa2f to your computer and use it in GitHub Desktop.
Save four0four/6378ed55952203a5fa2f to your computer and use it in GitHub Desktop.
Example C8051/ec2-drv project
/*
Homework #1 - except not really
*/
#include <c8051_SDCC.h>
#include <stdio.h>
void main(void)
{
// The following 2 lines MUST be the 1st executable statements in every program
Sys_Init(); /* Initialize UART, System clock and crossbar*/
putchar(' '); /* do this because we tell you to */
// do the thing
printf("Hello, world!\n\r");
}
PROGRAM=hw1
SOURCES=$(PROGRAM).c
# you should probably redefine this with an absolute path, if possible
INCLUDE=../headers
CC=sdcc
PORT="USB"
TARGET="SL51"
GDB=newcdb
all: $(PROGRAM).ihx flash run
$(PROGRAM).ihx: $(SOURCES)
$(CC) --debug -V --nogcse $(SOURCES) -I$(INCLUDE)
# just use newcdb to flash the current program
flash: $(PROGRAM).ihx
$(GDB) -ex="set target $(TARGET)" -ex="set target port $(PORT)" -ex="set target connect" -ex="file $(PROGRAM)" -ex="quit"
# call above, then use newcdb to start the current program (the uC needs a reset once flashed)
run:
$(GDB) -ex="set target $(TARGET)" -ex="set target port $(PORT)" -ex="set target connect" -ex="run" -ex="continue" -ex="quit"
clean:
rm -f *~ *.adb *.asm *.cdb *.ihx *.lnk *.lst *.map *.mem *.rel *.rst *.sym *.lk *.omf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment