From d2a71b921f9b838f2d2b1119644f51595bc5ae7b Mon Sep 17 00:00:00 2001 From: henyxia Date: Wed, 4 Mar 2015 18:31:23 +0100 Subject: [PATCH] Initial serial controlled version Makefile adapted to match with the port configuration --- Makefile | 14 +++++++------- main.c | 39 ++++++++++++++++++++++++++++++--------- 2 files changed, 37 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index 85c916d..089dcfb 100755 --- a/Makefile +++ b/Makefile @@ -1,18 +1,18 @@ -export CC = avr-gcc +CC = avr-gcc -export MCU = atmega328p -export TARGET_ARCH = -mmcu=$(MCU) +MCU = atmega328p +TARGET_ARCH = -mmcu=$(MCU) -export CFLAGS = -Wall -I. -DF_CPU=16000000 -Os #-g -export LDFLAGS = -g $(TARGET_ARCH) -lm -Wl,--gc-sections # -Os +CFLAGS = -Wall -I. -DF_CPU=16000000 -Os #-g +LDFLAGS = -g $(TARGET_ARCH) -lm -Wl,--gc-sections # -Os TARGET = usb -TERM = /dev/ttyACM0 +TERM = /dev/ttyACM1 CPPFLAGS = -mmcu=$(MCU) PGMER = -c stk500v1 -b 57600 -P $(TERM) PGMERISP = -c stk500v1 -b 115200 -P $(TERM) ARVDUDECONF= -C /usr/local/arduino/arduino-0022/hardware/tools/avrdude.conf -export DUDE = /usr/bin/avrdude -F -v -p $(MCU) $(AVRDUDECONF) +DUDE = /usr/bin/avrdude -F -v -p $(MCU) $(AVRDUDECONF) C_SRC = $(wildcard *.c) OBJS = $(C_SRC:.c=.o) diff --git a/main.c b/main.c index dcbee71..83866be 100755 --- a/main.c +++ b/main.c @@ -6,10 +6,9 @@ unsigned int joystick_lr; unsigned int joystick_ud; -void init_serial(unsigned long int speed) +void init_serial(int speed) { - //UBRR0 = CPU_FREQ/((speed)<<4)-1; - UBRR0 = 8; + UBRR0 = CPU_FREQ/(((unsigned long int)speed)<<4)-1; UCSR0B = (1<