diff --git a/slave2/slave/slave.atsln b/slave2/slave/slave.atsln new file mode 100644 --- /dev/null +++ b/slave2/slave/slave.atsln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Atmel Studio Solution File, Format Version 11.00 +Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "slave", "slave\slave.cproj", "{40D97B6E-7FF4-48E7-9A9E-5E50BA18526B}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|AVR = Debug|AVR + Release|AVR = Release|AVR + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {40D97B6E-7FF4-48E7-9A9E-5E50BA18526B}.Debug|AVR.ActiveCfg = Debug|AVR + {40D97B6E-7FF4-48E7-9A9E-5E50BA18526B}.Debug|AVR.Build.0 = Debug|AVR + {40D97B6E-7FF4-48E7-9A9E-5E50BA18526B}.Release|AVR.ActiveCfg = Release|AVR + {40D97B6E-7FF4-48E7-9A9E-5E50BA18526B}.Release|AVR.Build.0 = Release|AVR + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/slave2/slave/slave/config.h b/slave2/slave/slave/config.h new file mode 100644 --- /dev/null +++ b/slave2/slave/slave/config.h @@ -0,0 +1,16 @@ +/* + * IncFile1.h + * + * Created: 10/25/2012 10:00:09 PM + * Author: mkanning + */ + + + #ifndef CONFIG_H_ + #define CONFIG_H_ + + #define F_CPU 11059200 + #define USART_BAUDRATE 19200 + #define MODULE_ID '2' + + #endif /* CONFIG_H_ */ \ No newline at end of file diff --git a/slave2/slave/slave/lib/led.c b/slave2/slave/slave/lib/led.c new file mode 100644 --- /dev/null +++ b/slave2/slave/slave/lib/led.c @@ -0,0 +1,24 @@ +/* + * CFile1.c + * + * Created: 10/25/2012 10:03:22 PM + * Author: mkanning + */ + + #include + + void led_Configure() { + // Configure ports/pins for LEDs + } + + void led_On(uint8_t led) { + // Turn the specified LED on + } + + void led_Off(uint8_t led) { + // Turn the specified LED off + } + + void led_Toggle(uint8_t led) { + // Toggle the specified LED + } \ No newline at end of file diff --git a/slave2/slave/slave/lib/led.h b/slave2/slave/slave/lib/led.h new file mode 100644 --- /dev/null +++ b/slave2/slave/slave/lib/led.h @@ -0,0 +1,23 @@ +/* + * IncFile1.h + * + * Created: 10/25/2012 10:01:29 PM + * Author: mkanning + */ + + + #ifndef LED_H_ + #define LED_H_ + + #define POWER 1 + #define ERROR 2 + #define STAT 2 + #define OK 2 + + void led_Configure(); + void led_On(uint8_t led); + void led_Off(uint8_t led); + void led_Toggle(uint8_t led); + + + #endif /* LED_H_ */ diff --git a/slave2/slave/slave/lib/serial.c b/slave2/slave/slave/lib/serial.c new file mode 100644 --- /dev/null +++ b/slave2/slave/slave/lib/serial.c @@ -0,0 +1,56 @@ +/* + * CFile1.c + * + * Created: 10/25/2012 10:02:38 PM + * Author: mkanning + */ + + #include + + void serial_SendChar( char byte ) + { + while (!(UCSR0A & (1<> 8); // 0 + //UBRRL = BAUD_PRESCALE; // 8 + //UCSRA = 0; + //UCSRB = 0x18; + //UCSRC = 0x06; + //OCR0B = 0xff; + //OCR0A = 0xff; + //OCR1AL = 0xff; + //OCR1BL = 0xff; + } diff --git a/slave2/slave/slave/lib/serial.h b/slave2/slave/slave/lib/serial.h new file mode 100644 --- /dev/null +++ b/slave2/slave/slave/lib/serial.h @@ -0,0 +1,19 @@ +/* + * IncFile1.h + * + * Created: 10/25/2012 10:01:43 PM + * Author: mkanning + */ + + + #ifndef SERIAL_H_ + #define SERIAL_H_ + + #define BAUD_PRESCALE (((F_CPU / (USART_BAUDRATE * 16UL))) -1 ) + + void serial_SendChar( char byte ); + void serial_SendCommand( char moduleID, char sensorID, uint8_t dataLength, char* data ); + void serial_SendResponseData(); + void serial_Configure(); + + #endif /* SERIAL_H_ */ \ No newline at end of file diff --git a/slave2/slave/slave/lib/serparser.c b/slave2/slave/slave/lib/serparser.c new file mode 100644 --- /dev/null +++ b/slave2/slave/slave/lib/serparser.c @@ -0,0 +1,130 @@ +/* + * serparser.c + * + * Created: 10/25/2012 10:04:09 PM + * Author: mkanning +*/ + + +// ************* Macros *************** +#define SERIAL_RX_HASBYTES UCSR0A & _BV(RXC) +#define MAX_CMD_LEN 16 +#define BROADCAST_ADDR 0 //public address +#include +#include "../config.h" + +//#define DEBUG + +// ************* Command Definitions *************** + +// Serial Commands +enum cmd // CMD ID# +{ + BOARDTEMP = 0, // 0 + PRESSURE, // 1 +}; + +// Incoming command buffer +uint8_t buffer[MAX_CMD_LEN+2]; + +// Current buffer location +uint8_t bufferPosition = 0; + +//ID of the sensor of most recent transmission +char sensorID; + +//checksum to be calculated and then compared to the received checksum +char checksumCalc; + +/* return char from UART (h/w buffer) */ +uint8_t uart_getchar(void) +{ + // Wait for chars + /* while (!(UCSRA & (1< + #include + + #include "lib/serial.h" + + + void micro_Configure() { + // Generic microcontroller config options + } + + int main(void) + { + // Initialize + micro_Configure(); + led_Configure(); + serial_Configure(); // Config serial ports + + while(1) + { + serial_SendCommand('0','A',0,0); + } + } \ No newline at end of file diff --git a/slave2/slave/slave/slave.cproj b/slave2/slave/slave/slave.cproj new file mode 100644 --- /dev/null +++ b/slave2/slave/slave/slave.cproj @@ -0,0 +1,97 @@ + + + + 2.0 + 6.0 + com.Atmel.AVRGCC8 + {40d97b6e-7ff4-48e7-9a9e-5e50ba18526b} + ATmega644P + none + Executable + C + $(MSBuildProjectName) + .elf + $(MSBuildProjectDirectory)\$(Configuration) + slave + slave + slave + Native + true + false + + 0 + 3.1.3 + + + + + True + True + True + True + True + Optimize for size (-Os) + True + True + True + + + m + + + + + + + + + True + True + True + True + True + Optimize (-O1) + True + True + Default (-g2) + True + + + m + + + Default (-Wa,-g) + + + + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + + + + + \ No newline at end of file