From d54bf1a4333b15979dd1b3c19c74f5c62b566a96 Mon Sep 17 00:00:00 2001 From: Jonas Gunz Date: Fri, 20 Feb 2015 18:34:30 +0100 Subject: Added Project Files Added files --- Keithley179.c | 195 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ Keithley179.cproj | 132 ++++++++++++++++++++++++++++++++++++ 2 files changed, 327 insertions(+) create mode 100644 Keithley179.c create mode 100644 Keithley179.cproj diff --git a/Keithley179.c b/Keithley179.c new file mode 100644 index 0000000..734336c --- /dev/null +++ b/Keithley179.c @@ -0,0 +1,195 @@ + +#ifndef F_CPU +#define F_CPU 4000000UL +#endif + +#include +#include + +#define UART_BAUDRATE 9600 + +#define UBRR_VAL (F_CPU / UART_BAUDRATE * 16) - 1 + +#define b1 PC0 +#define b2 PC1 +#define b3 PC2 +#define b4 PC3 + +#define d1 PD7 +#define d2 PD4 +#define d3 PD5 +#define d4 PD6 +#define d5 PC3 + +#define busy PB7 //Busy not Used + +//Status +uint8_t UART_RX; +uint8_t UART_RX_END; +uint8_t UART_isInit; + +//Buffers +char out[5]; //Buffer for ADC Input +char in[16]; //UART Input Buffer +uint8_t in_cntr; //Counter for UART Input Buffer + +ISR(USART_RXC_vect) +{ + cli(); + in[in_cntr] = UDR; + if(in[in_cntr] == '\n') + UART_RX_END = 1; //Set RX End Flag + + //Check if Buffer is full + if(in_cntr < 15) + in_cntr ++; + else + { + in_cntr = 0; + UART_RX_END = 1; //Set RX End Flag + } + sei(); +}//USART_RXC_vect + +void UART_Init(); +/* +*Initializes the UART Interface +*/ + +void UART_Handle(); +/* +* should be called on Interrupt of UART +* Handles UART Communication +*/ + +void UART_Send(char *_cSend); +/* +*Sends String over UART +*/ + +int main(void) +{ + //clear Buffers + for(int i = 0; i < 5;i++) + { + out[i] = 0; + } + + for(int i = 0; i < 16;i++) + { + in[i] = 0; + } + + + char temp = 0; + in_cntr = 0; + + UART_RX = 0; + UART_RX_END = 0; + UART_isInit = 0; + + //Set DDRD as Input + DDRD = 0; + DDRC = 0; + + DDRD |= (1<> 4; + temp = 0; + + while(!(PORTD & (1<> 4; + temp = 0; + + while(!(PORTD & (1<> 4; + temp = 0; + + while(!(PORTD & (1<> 4; + temp = 0; + + while(!(PORTC & (1<> 4; + temp = 0; + + + //Convert to ASCII + for(int i = 0; i < 5;i++) + { + out[i] = out[i] + 48; + } + + UART_Send(out); + //Handle UART + //UART_Handle(); + + //Reset Buffer + for(int i = 0; i < 5;i++) + { + out[i] = 0; + } + + } + + return 0; +}//main + + + +void UART_Init() +{ + if(UART_isInit == 0) + { + //Calculate Value for Register + uint16_t baudrate = (4000000 / (9600 * 16)) - 1; + + //Set Baudrate + UBRRL = baudrate; + UBRRH = (baudrate >> 8); + + UCSRB |= (1< + + + 2.0 + 6.2 + com.Atmel.AVRGCC8.C + {a92aedb3-f7af-427a-b816-80c012deb17d} + ATmega8 + none + Executable + C + $(MSBuildProjectName) + .elf + $(MSBuildProjectDirectory)\$(Configuration) + Keithley179 + Keithley179 + Keithley179 + Native + true + false + true + true + 0x20000000 + + exception_table + 2 + 0 + + + + + + + + + + + + + com.atmel.avrdbg.tool.ispmk2 + ISP + + + + false + 500000 + + ISP + + com.atmel.avrdbg.tool.ispmk2 + 000200185657 + AVRISP mkII + + true + + + + + ISP + + com.atmel.avrdbg.tool.simulator + + + Simulator + + + + + + True + True + True + True + True + True + + + NDEBUG + + + Optimize for size (-Os) + True + True + True + + + libm + + + + + + + + + True + True + True + True + True + True + + + DEBUG + + + Optimize (-O1) + True + True + Default (-g2) + True + + + libm + + + Default (-Wa,-g) + + + + + + compile + + + + + compile + + + + \ No newline at end of file -- cgit v1.2.3