Skip to content
Snippets Groups Projects
Commit e4de8b4c authored by Brandon Rodriguez's avatar Brandon Rodriguez
Browse files

Working base program

parent f59ac2cb
Branches
No related merge requests found
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include <libemb/serial/serial.h> #include <libemb/serial/serial.h>
#include <libemb/conio/conio.h> #include <libemb/conio/conio.h>
void FlashLED(int outputSignal);
int main(void) { int main(void) {
...@@ -11,46 +12,59 @@ int main(void) { ...@@ -11,46 +12,59 @@ int main(void) {
BCSCTL1 = CALBC1_1MHZ; BCSCTL1 = CALBC1_1MHZ;
DCOCTL = CALDCO_1MHZ; DCOCTL = CALDCO_1MHZ;
P1DIR |= 0b01000001; // Prime for output on P1.0 and P1.6 P1DIR = 0b01000001; // Prime for output on P1.0 and P1.6
//P1OUT |= 0b01000001; // Output signal P1OUT = 0b00000000; // Output no signal at first.
serial_init(9600); serial_init(9600);
// Initialize variables. // Initialize variables.
char input; char input;
int outputSignal = 0b00000000;
unsigned int inputInt; unsigned int inputInt;
unsigned int remainder; unsigned int remainder;
for(;;) { for(;;) {
char c = cio_getc(); char c = cio_getc();
cio_printf("Debugging: c = %c \n\r", c); cio_printf(" Debugging: c = %c \n\r", c);
}
return 0;
}
/*
for (;;) {
// Read input.
char c = cio_getc();
cio_printf("Debugging: c = %c \n", c);
// If return key is hit, // If return key is hit,
if (c == "\n\r") { if (c == '\r') {
// Determine even or odd and output signal. // Determine even or odd and output signal.
inputInt = input - '0'; inputInt = input - '0';
cio_printf("Debugging: inputInt = %u \n", inputInt); cio_printf(" Debugging: inputInt = %u \n\r", inputInt);
remainder = inputInt % 2; remainder = inputInt % 2;
cio_printf("Debugging: remainder = %u \n", remainder); cio_printf(" Debugging: remainder = %u \n\r", remainder);
// Set LED's accordingly. Even flash green. Odd flash red.
if (remainder == 0) {
// Set green for signal.
cio_printf(" Debugging: Even. Green. \n\r");
outputSignal = 0b01000000;
FlashLED(outputSignal);
} else {
// Output red for signal.
cio_printf(" Debugging: Odd. Red. \n\r");
outputSignal = 0b00000001;
FlashLED(outputSignal);
}
} else { } else {
// Save value for return key. // Save value for return key.
input = c; input = c;
cio_printf("Debugging: input = %c \n", input); cio_printf(" Debugging: input = %c \n\r", input);
} }
} }
return 0; return 0;
}*/ }
void FlashLED(int outputSignal) {
// Output LED signal.
for (int i = 0; i < 10; i++) {
P1OUT = 0b00000000;
__delay_cycles(100000);
P1OUT = outputSignal;
__delay_cycles(100000);
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment