diff --git a/Main.c b/Main.c index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..2c14fee5a87a32eacef8a4f96d582c7badc37a57 100644 --- a/Main.c +++ b/Main.c @@ -0,0 +1,118 @@ + +#include <msp430.h> +#include <libemb/serial/serial.h> +#include <libemb/conio/conio.h> + + +int main(void) { + + // Disable WatchDogTimer and set ClockSpeed. + WDTCTL = WDTPW | WDTHOLD; + BCSCTL1 = CALBC1_1MHZ; + DCOCTL = CALDCO_1MHZ; + + P1DIR |= 0b01000001; // Prime for output on P1.0 and P1.6 + //P1OUT |= 0b01000001; // Output signal + + serial_init(9600); + + // Initialize variables. + char input; + unsigned int inputInt; + unsigned int remainder; + + for(;;) { + cio_printf((char *) "I'm waiting for a character!\n\r"); + char c = cio_getc(); + cio_printc(c); + cio_printf((char *) "\n\r"); + } + + return 0; +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +/* +#include <msp430.h> +#include <libemb/serial/serial.h> +#include <libemb/conio/conio.h> + + +int Main(void) { + + cio_printf("Started program"); + // Disable WatchDogTimer and set ClockSpeed. + WDTCTL = WDTPW | WDTHOLD; + BCSCTL1 = CALBC1_1MHZ; + DCOCTL = CALDCO_1MHZ; + + P1DIR |= 0b01000001; // Prime for output. + + serial_init(9600); + + // Initialize variables. + char input; + unsigned int inputInt; + unsigned int remainder; + + cio_printf("Made variables and junk"); + + + for(;;) { + cio_printf((char *) "I'm waiting for a character!\n\r"); + char c = cio_getc(); + cio_printc(c); + cio_printf((char *) "\n\r"); + } + + + + + for (;;) { + // Read input. + char c = cio_getc(); + cio_printf("Debugging: c = %c \n", c); + + // If return key is hit, + if (c == "\n\r") { + // Determine even or odd and output signal. + inputInt = input - '0'; + cio_printf("Debugging: inputInt = %u \n", inputInt); + remainder = inputInt % 2; + cio_printf("Debugging: remainder = %u \n", remainder); + } else { + // Save value for return key. + input = c; + cio_printf("Debugging: input = %c \n", input); + } + } + + return 0; +}*/ diff --git a/Makefile b/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..d7fb766545d4643ec8e064b52203956c459c2218 --- /dev/null +++ b/Makefile @@ -0,0 +1,41 @@ +# Project name +SOURCE = Main.c +ADDITIONAL = +# Get base name so we can create .elf file +NAME = $(basename $(SOURCE)) +# MSP430 MCU to compile for +CPU = msp430g2553 +# Optimisation level +OPTIMIZATION = -O0 +# Extra variables +CFLAGS = -mmcu=$(CPU) $(OPTIMIZATION) -std=c99 -Wall -g +# Libemb library link flags +LIBEMB = -lshell -lconio -lserial + +# Build and link executable +$(NAME).elf: $(SOURCE) $(ADDITIONAL) +ifeq (,$(findstring libemb,$(shell cat $(SOURCE)))) + msp430-gcc $(CFLAGS) -o $@ $(SOURCE) $(ADDITIONAL) +else + msp430-gcc $(CFLAGS) -o $@ $(SOURCE) $(ADDITIONAL) $(LIBEMB) +endif + msp430-objdump -D $(NAME).elf > $(NAME).hex + +# Flash to board with mspdebug +flash: $(NAME).elf + mspdebug rf2500 "prog $(NAME).elf" + +# Erase board +erase: + mspdebug rf2500 erase + +stuff: hworld.c + echo "I found Main.c!" && cat Main.c + +# Clean up temporary files +clean: + rm -f *.elf *.hex + +# Remote debug board +debug: $(NAME).elf + ( mspdebug rf2500 "gdb" 1>/dev/null & ); msp430-gdb $(NAME).elf -ex "target remote :2000"