diff --git a/Control/firmware/uart_echo.atsln b/Control/firmware/uart_echo.atsln new file mode 100755 index 0000000..233d947 --- /dev/null +++ b/Control/firmware/uart_echo.atsln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Atmel Studio Solution File, Format Version 11.00 +VisualStudioVersion = 14.0.23107.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "uart_echo", "uart_echo\uart_echo.cproj", "{DCE6C7E3-EE26-4D79-826B-08594B9AD897}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|AVR = Debug|AVR + Release|AVR = Release|AVR + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.ActiveCfg = Debug|AVR + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.Build.0 = Debug|AVR + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.ActiveCfg = Release|AVR + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.Build.0 = Release|AVR + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Control/firmware/uart_echo/main.c b/Control/firmware/uart_echo/main.c new file mode 100755 index 0000000..9a570cc --- /dev/null +++ b/Control/firmware/uart_echo/main.c @@ -0,0 +1,172 @@ +/* + * uart_echo.c + * + * Created: 16.08.2018 17:39:49 + * Author : jens + */ + +#include +#include +#include + +#define F_CPU (18432000UL) // MHz +#define USART_BAUDRATE 115200UL +#define BAUD_PRESCALE (((F_CPU / (USART_BAUDRATE * 16UL))) - 1) +#define TIMER_RELOAD (0xFFFF-(F_CPU/1024/4-1)) +static uint8_t rx_data; +static uint8_t count = 0; +volatile uint8_t msgCode = 0; +static uint8_t msgData = 0; +static uint8_t ledState = 0; + +enum MessageCode +{ + NOP=0, + Command, + Timer, + Error = 0xFF +}; + +ISR(USART0_RX_vect) +{ + rx_data = UDR0; + + msgCode = NOP; + if (rx_data == ' ') + { + msgCode = Error; + } + else if (rx_data >= '0' && rx_data <= '9') + { + msgCode = Command; + msgData = rx_data; + } + count++; +} + +ISR (TIMER1_OVF_vect) // Timer1 ISR +{ + msgCode = Timer; + TCNT1 = TIMER_RELOAD; + ledState++; + if (ledState == 4) + { + ledState = 0; + } +} + +void uart_init() +{ + // Set baud rate + UBRR0L = (uint8_t)BAUD_PRESCALE; + UBRR0H = (uint8_t)(BAUD_PRESCALE >> 8); + + // Enable receiver and transmitter + UCSR0B = (1< + + + + + + Device + Startup + + + Atmel + 1.2.0 + D:/Program Files (x86)\Atmel\Studio\7.0\Packs + + + + + D:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.2.150\include + + include + C + + + include + + + + + D:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.2.150\include\avr\iom644pa.h + + header + C + dmamizNMG7EXBqtW9kb8VA== + + include/avr/iom644pa.h + + + + + D:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.2.150\templates\main.c + template + source + C Exe + GD1k8YYhulqRs6FD1B2Hog== + + templates/main.c + Main file (.c) + + + + D:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.2.150\templates\main.cpp + template + source + C Exe + YXFphlh0CtZJU+ebktABgQ== + + templates/main.cpp + Main file (.cpp) + + + + D:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.2.150\gcc\dev\atmega644pa + + libraryPrefix + GCC + + + gcc/dev/atmega644pa + + + + + ATmega_DFP + D:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATmega_DFP/1.2.150/Atmel.ATmega_DFP.pdsc + 1.2.150 + true + ATmega644PA + + + + Resolved + Fixed + true + + + \ No newline at end of file diff --git a/Control/firmware/uart_echo/uart_echo.cproj b/Control/firmware/uart_echo/uart_echo.cproj new file mode 100755 index 0000000..96c7c90 --- /dev/null +++ b/Control/firmware/uart_echo/uart_echo.cproj @@ -0,0 +1,157 @@ + + + + 2.0 + 7.0 + com.Atmel.AVRGCC8.C + dce6c7e3-ee26-4d79-826b-08594b9ad897 + ATmega644PA + none + Executable + C + $(MSBuildProjectName) + .elf + $(MSBuildProjectDirectory)\$(Configuration) + uart_echo + uart_echo + uart_echo + Native + true + false + true + true + 0x20000000 + + true + exception_table + 2 + 0 + 0 + + + + + + + + + + + + + + com.atmel.avrdbg.tool.atmelice + J41800089261 + 0x1E960A + + + + + + + + com.atmel.avrdbg.tool.simulator + + + Simulator + + JTAG + + + + 125000 + 6000000 + + JTAG + + com.atmel.avrdbg.tool.atmelice + J41800089261 + Atmel-ICE + + 6000000 + + + + + -mmcu=atmega644pa -B "%24(PackRepoDir)\atmel\ATmega_DFP\1.2.150\gcc\dev\atmega644pa" + True + True + True + True + False + True + True + + + NDEBUG + + + + + %24(PackRepoDir)\atmel\ATmega_DFP\1.2.150\include + + + Optimize for size (-Os) + True + True + True + + + libm + + + + + %24(PackRepoDir)\atmel\ATmega_DFP\1.2.150\include + + + + + + + + + -mmcu=atmega644pa -B "%24(PackRepoDir)\atmel\ATmega_DFP\1.2.150\gcc\dev\atmega644pa" + True + True + True + True + False + True + True + + + DEBUG + + + + + %24(PackRepoDir)\atmel\ATmega_DFP\1.2.150\include + + + Optimize debugging experience (-Og) + True + True + Default (-g2) + True + + + libm + + + + + %24(PackRepoDir)\atmel\ATmega_DFP\1.2.150\include + + + Default (-Wa,-g) + + + + + + compile + + + + \ No newline at end of file