From f9f1d9f0311d8c84e8f2accac4ba5ea5f5481d6a Mon Sep 17 00:00:00 2001 From: Olivier Matz Date: Sun, 29 Sep 2013 16:52:28 +0200 Subject: [PATCH] support new board (fpv motherboard v1) --- .config | 16 ++++++++++------ Makefile | 2 +- main.c | 32 +++++++++++++++++++++++++------- 3 files changed, 36 insertions(+), 14 deletions(-) diff --git a/.config b/.config index d8f1bf6..4fdc62b 100644 --- a/.config +++ b/.config @@ -11,6 +11,7 @@ # CONFIG_MCU_AT90S2343 is not set # CONFIG_MCU_ATTINY22 is not set # CONFIG_MCU_ATTINY26 is not set +# CONFIG_MCU_ATTINY45 is not set # CONFIG_MCU_AT90S4414 is not set # CONFIG_MCU_AT90S4433 is not set # CONFIG_MCU_AT90S4434 is not set @@ -40,8 +41,8 @@ # CONFIG_MCU_ATMEGA32 is not set # CONFIG_MCU_ATMEGA323 is not set # CONFIG_MCU_ATMEGA325 is not set +# CONFIG_MCU_ATMEGA328P is not set # CONFIG_MCU_ATMEGA3250 is not set -CONFIG_MCU_ATMEGA328P=y # CONFIG_MCU_ATMEGA64 is not set # CONFIG_MCU_ATMEGA645 is not set # CONFIG_MCU_ATMEGA6450 is not set @@ -52,6 +53,9 @@ CONFIG_MCU_ATMEGA328P=y # CONFIG_MCU_AT90S1200 is not set # CONFIG_MCU_ATMEGA2560 is not set # CONFIG_MCU_ATMEGA256 is not set +# CONFIG_MCU_ATXMEGA128A1 is not set +CONFIG_MCU_ATMEGA168P=y +# CONFIG_MCU_ATMEGA1284P is not set CONFIG_QUARTZ=8000000 # @@ -94,7 +98,6 @@ CONFIG_MODULE_SCHEDULER_TIMER0=y # # Communication modules # -# CONFIG_MODULE_LUFA is not set # CONFIG_MODULE_UART is not set # CONFIG_MODULE_UART_9BITS is not set # CONFIG_MODULE_UART_CREATE_CONFIG is not set @@ -236,16 +239,17 @@ CONFIG_AVRDUDE=y # CONFIG_AVRDUDE_PROG_PAVR is not set # CONFIG_AVRDUDE_PROG_BUTTERFLY is not set # CONFIG_AVRDUDE_PROG_AVR910 is not set +# CONFIG_AVRDUDE_PROG_AVR911 is not set # CONFIG_AVRDUDE_PROG_STK500 is not set -# CONFIG_AVRDUDE_PROG_STK500V1 is not set -CONFIG_AVRDUDE_PROG_ARDUINO=y # CONFIG_AVRDUDE_PROG_AVRISP is not set # CONFIG_AVRDUDE_PROG_BSD is not set # CONFIG_AVRDUDE_PROG_DAPA is not set # CONFIG_AVRDUDE_PROG_JTAG1 is not set # CONFIG_AVRDUDE_PROG_AVR109 is not set -CONFIG_AVRDUDE_PORT="/dev/ttyUSB0" -CONFIG_AVRDUDE_BAUDRATE=57600 +CONFIG_AVRDUDE_PROG_AVRISPMKII=y +# CONFIG_AVRDUDE_PROG_ARDUINO is not set +CONFIG_AVRDUDE_PORT="usb" +CONFIG_AVRDUDE_BAUDRATE=19200 # # Avarice diff --git a/Makefile b/Makefile index 18a0882..cf5ec3a 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ TARGET = main -AVERSIVE_DIR =../.. +AVERSIVE_DIR ?= ../.. # List C source files here. (C dependencies are automatically generated.) SRC = $(TARGET).c diff --git a/main.c b/main.c index dd98345..ad0af05 100644 --- a/main.c +++ b/main.c @@ -1,4 +1,5 @@ #include +#include struct servo { uint8_t bit; @@ -6,9 +7,13 @@ struct servo { }; static struct servo servo_table[] = { + { + .bit = 2, + .command = 300, + }, { .bit = 3, - .command = 0, + .command = 700, }, { .bit = 4, @@ -37,6 +42,9 @@ static volatile uint8_t rxidx; #define BYPASS_ENABLE 14 #define BYPASS_DISABLE 15 +#define LED_ON() do { PORTB |= 0x02; } while(0) +#define LED_OFF() do { PORTB &= ~0x02; } while(0) + /* * SPI protocol: * @@ -152,11 +160,19 @@ int main(void) uint8_t t, diff; /* LED */ - DDRB = 0x20; + DDRB = 0x02; + +#if 0 /* LED debug */ + while (1) { + LED_ON(); + wait_ms(100); + LED_OFF(); + wait_ms(100); + } +#endif - /* servo outputs */ - DDRD = 0xf8; - DDRB |= 0x01; + /* servo outputs PD2-PD7 */ + DDRD = 0xfc; /* start timer1 at clk/1 (8Mhz) */ TCNT1 = 0; @@ -171,7 +187,7 @@ int main(void) sei(); - bypass = 1; + bypass = 0; while (1) { t = TCNT0; for (i = 0; i < NB_SERVO; i++) { @@ -186,9 +202,11 @@ int main(void) } /* bypass mode */ while (bypass == 1) { - PORTD = ((PINC & 0x0f) << 3) | ((PINB & 0x01) << 7); + LED_ON(); + PORTD = (PINC & 0x3f) << 2; poll_spi(); } + LED_OFF(); } return 0; -- 2.20.1