New MEGA2560 board

(DIY transmitter based on Arduino MEGA2560)
This commit is contained in:
f.aguerre@wanadoo.fr
2013-03-16 19:55:20 +00:00
parent 0026262520
commit c00620b891
4 changed files with 351 additions and 1 deletions
+37 -1
View File
@@ -50,7 +50,7 @@ DELAY = 5
#----------- BUILD OPTIONS ---------------------------
# PCB version
# Values: 9X, 9X128, 9XR, 9XR128, GRUVIN9X, SKY9X, X9D
# Values: 9X, 9X128, 9XR, 9XR128, GRUVIN9X, MEGA2560, SKY9X, X9D
# Old values STD and STD128 are mapped to 9X and 9X128 for compatibility
PCB = 9X
@@ -248,6 +248,14 @@ ifeq ($(PCB), $(filter $(PCB), STD128 9X128 9XR128))
endif
ifeq ($(PCB), GRUVIN9X)
ARCH = AVR
TRGT = avr-
MCU = atmega2560
CPPDEFS += -DF_CPU=$(F_CPU)UL
SDCARD = NO
endif
ifeq ($(PCB), MEGA2560)
ARCH = AVR
ifeq ($(PCBREV), REV0)
CPPDEFS += -DREV0
@@ -627,6 +635,34 @@ ifeq ($(PCB), GRUVIN9X)
CPPDEFS += -DROTARY_ENCODERS=${ROTARY_ENCODERS}
endif
ifeq ($(PCB), MEGA2560)
# ARDUINO2560 DIY RADIO
OPT = 2
CPPDEFS += -DPCBGRUVIN9X -DEEPROM_VARIANT=0 -DAUDIO -DHAPTIC
EXTRAINCDIRS += gruvin9x stock FatFs FatFs/option
BOARDSRC += mega2560/board_mega2560.cpp
EXTRABOARDSRC += mega2560/lcd_driver_ST7565R.cpp
EEPROMSRC = eeprom_common.cpp eeprom_rlc.cpp
PULSESSRC = pulses_avr.cpp
CPPSRC += audio_avr.cpp haptic.cpp
ifeq ($(SDCARD), YES)
CPPDEFS += -DRTCLOCK
CPPSRC += rtc.cpp gruvin9x/rtc_driver.cpp
EXTRABOARDSRC += FatFs/ff.c FatFs/fattime.c FatFs/option/ccsbcs.c gruvin9x/diskio.cpp
endif
ifeq ($(VOICE), YES)
CPPSRC += gruvin9x/somo14d.cpp
CPPDEFS += -DVOICE
endif
# Enable extra rotary encoders (Gruvin9x board only)
# Values = YES, NO
ROTARY_ENCODERS = 2
CPPDEFS += -DROTARY_ENCODERS=${ROTARY_ENCODERS}
endif
ifeq ($(PCB), $(filter $(PCB), STD128 9X128 9XR128))
# 9x radio with Atmega 64 replace by Atmega 128
OPT = 2
+22
View File
@@ -0,0 +1,22 @@
MEGA2560 board
======================= DESCRIPTION =======================
DIY radio wih :
- Arduino MEGA2560 or compatible
- Artronic LCD 128x64 ST7565R (and, in a second time : Digole LCD 128x64 ST9720)
- Aurora9 gimballs
- home made wood (or fiberglass) case
- Gruvin9x features (soft-off, SD-Card, etc.) with some pins reassignment
Drawings (case, additional cards, wiring) and components listing will follow
========================= STATUS ==========================
LCD driver ST7565R : works
Pins assignment : done (io_mega2560.h)
Additional cards :
- LCD driver (3.3V + backlight) : works
- PPM + power management : in test
- gimballs Op Amp : in test
+160
View File
@@ -0,0 +1,160 @@
/*
* Authors (alphabetical order)
* - Andre Bernet <bernet.andre@gmail.com>
* - Andreas Weitl
* - Bertrand Songis <bsongis@gmail.com>
* - Bryan J. Rentoul (Gruvin) <gruvin@gmail.com>
* - Cameron Weeks <th9xer@gmail.com>
* - Erez Raviv
* - Gabriel Birkus
* - Jean-Pierre Parisy
* - Karl Szmutny
* - Michael Blandford
* - Michal Hlavinka
* - Pat Mackenzie
* - Philip Moss
* - Rob Thomson
* - Romolo Manfredini <romolo.manfredini@gmail.com>
* - Thomas Husterer
*
* open9x is based on code named
* gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/,
* er9x by Erez Raviv: http://code.google.com/p/er9x/,
* and the original (and ongoing) project by
* Thomas Husterer, th9x: http://code.google.com/p/th9x/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#ifndef _HAL_
#define _HAL_
/*
* GPIOS
*/
// Keys
#define GPIO_BUTTON_MENU GPIOL->IDR // only one port : to simplify ? //
#define GPIO_BUTTON_EXIT GPIOL->IDR
#define GPIO_BUTTON_RIGHT GPIOL->IDR
#define GPIO_BUTTON_LEFT GPIOL->IDR
#define GPIO_BUTTON_UP GPIOL->IDR
#define GPIO_BUTTON_DOWN GPIOL->IDR
#define PIN_BUTTON_MENU GPIO_Pin_4
#define PIN_BUTTON_EXIT GPIO_Pin_5
#define PIN_BUTTON_RIGHT GPIO_Pin_2
#define PIN_BUTTON_LEFT GPIO_Pin_3
#define PIN_BUTTON_UP GPIO_Pin_1
#define PIN_BUTTON_DOWN GPIO_Pin_0
// Trims
#define GPIO_TRIM_LH_L GPIOK->IDR // only one port : to simplify ? //
#define GPIO_TRIM_LH_R GPIOK->IDR
#define GPIO_TRIM_LV_DN GPIOK->IDR
#define GPIO_TRIM_LV_UP GPIOK->IDR
#define GPIO_TRIM_RH_L GPIOK->IDR
#define GPIO_TRIM_RH_R GPIOK->IDR
#define GPIO_TRIM_RV_DN GPIOK->IDR
#define GPIO_TRIM_RV_UP GPIOK->IDR
#define PIN_TRIM_LH_L GPIO_Pin_0
#define PIN_TRIM_LH_R GPIO_Pin_1
#define PIN_TRIM_LV_DN GPIO_Pin_2
#define PIN_TRIM_LV_UP GPIO_Pin_3
#define PIN_TRIM_RH_L GPIO_Pin_4
#define PIN_TRIM_RH_R GPIO_Pin_5
#define PIN_TRIM_RV_DN GPIO_Pin_5
#define PIN_TRIM_RV_UP GPIO_Pin_6
// Switchs
#define GPIO_PIN_SW_A GPIOC->IDR // A, B, C... to rename to ID1/2... ? //
#define GPIO_PIN_SW_B GPIOC->IDR
#define GPIO_PIN_SW_C GPIOD->IDR
#define GPIO_PIN_SW_D GPIOG->IDR
#define GPIO_PIN_SW_E GPIOG->IDR
#define GPIO_PIN_SW_F GPIOG->IDR
#define GPIO_PIN_SW_G GPIOL->IDR
#define GPIO_PIN_SW_H GPIOL->IDR
#define PIN_SW_A GPIO_Pin_1
#define PIN_SW_B GPIO_Pin_0
#define PIN_SW_C GPIO_Pin_7
#define PIN_SW_D GPIO_Pin_2
#define PIN_SW_E GPIO_Pin_1
#define PIN_SW_F GPIO_Pin_0
#define PIN_SW_G GPIO_Pin_6
#define PIN_SW_H GPIO_Pin_7
// Rotary encoders
#define GPIO_PIN_ROT_ENC_1_A GPIOH->IDR
#define GPIO_PIN_ROT_ENC_1_B GPIOJ->IDR
#define GPIO_PIN_ROT_ENC_1_PUSH GPIOJ->IDR
#define GPIO_PIN_ROT_ENC_2_A GPIOD->IDR
#define GPIO_PIN_ROT_ENC_2_B GPIOD->IDR
#define GPIO_PIN_ROT_ENC_2_PUSH GPIOH->IDR
#define PIN_ROT_ENC_1_A GPIO_Pin_1
#define PIN_ROT_ENC_1_B GPIO_Pin_0
#define PIN_ROT_ENC_1_PUSH GPIO_Pin_1
#define PIN_ROT_ENC_2_A GPIO_Pin_0
#define PIN_ROT_ENC_2_B GPIO_Pin_3
#define PIN_ROT_ENC_2_PUSH GPIO_Pin_2
// ADC
#define GPIO_PIN_ADC GPIOK->IDR
#define PIN_STK_J1 GPIO_Pin_0
#define PIN_STK_J2 GPIO_Pin_1
#define PIN_STK_J3 GPIO_Pin_2
#define PIN_STK_J4 GPIO_Pin_3
#define PIN_POT_1 GPIO_Pin_4
#define PIN_POT_2 GPIO_Pin_5
#define PIN_POT_3 GPIO_Pin_6
#define PIN_MVOLT GPIO_Pin_7
// Accessories
#define GPIO_PIN_PPM_IN GPIOB->IDR
#define GPIO_PIN_PPM_OUT GPIOB->IDR
#define GPIO_PIN_SIM_CTL GPIOB->IDR
#define GPIO_PIN_TELEM_RX GPIOE->IDR
#define GPIO_PIN_TELEM_TX GPIOE->IDR
#define GPIO_PIN_SPEAKER GPIOE->IDR
#define GPIO_PIN_BUZZER GPIOB->IDR
#define GPIO_PIN_JACK_PRES GPIOH->IDR
#define GPIO_PIN_HOLD_PWR GPIOH->IDR
#define PIN_PPM_IN GPIO_Pin_7
#define PIN_PPM_OUT GPIO_Pin_6
#define PIN_SIM_CTL GPIO_Pin_5
#define PIN_TELEM_RX GPIO_Pin_0
#define PIN_TELEM_TX GPIO_Pin_1
#define PIN_SPEAKER GPIO_Pin_3
#define PIN_BUZZER GPIO_Pin_4
#define PIN_JACK_PRES GPIO_Pin_5
#define PIN_HOLD_PWR GPIO_Pin_4
// LCD
#define GPIO_LCD_DAT GPIOA->IDR
#define GPIO_LCD_CTRL GPIOC->IDR
#define PIN_LCD_E GPIO_Pin_7
#define PIN_LCD_RnW GPIO_Pin_6
#define PIN_LCD_A0 GPIO_Pin_5
#define PIN_LCD_RES GPIO_Pin_4
#define PIN_LCD_CS1 GPIO_Pin_3
#define PIN_LCD_LIGHT GPIO_Pin_2
// SD
#define GPIO_SD GPIOB->IDR
#define PIN_SD_MISO GPIO_Pin_3
#define PIN_SD_MOSI GPIO_Pin_2
#define PIN_SD_SCK GPIO_Pin_1
#define PIN_SD_CS GPIO_Pin_0
#define SD_IS_HC() (0) // ?
#define SD_GET_BLOCKNR() (0) // ?
#define SD_GET_SIZE_MB() (0) // ?
#define SD_GET_SPEED() (0) // ?
#endif
+132
View File
@@ -0,0 +1,132 @@
/*
* Authors (alphabetical order)
* - Andre Bernet <bernet.andre@gmail.com>
* - Andreas Weitl
* - Bertrand Songis <bsongis@gmail.com>
* - Bryan J. Rentoul (Gruvin) <gruvin@gmail.com>
* - Cameron Weeks <th9xer@gmail.com>
* - Erez Raviv
* - Gabriel Birkus
* - Jean-Pierre Parisy
* - Karl Szmutny
* - Michael Blandford
* - Michal Hlavinka
* - Pat Mackenzie
* - Philip Moss
* - Rob Thomson
* - Romolo Manfredini <romolo.manfredini@gmail.com>
* - Thomas Husterer
*
* open9x is based on code named
* gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/,
* er9x by Erez Raviv: http://code.google.com/p/er9x/,
* and the original (and ongoing) project by
* Thomas Husterer, th9x: http://code.google.com/p/th9x/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#include "open9x.h"
#define delay_1us() _delay_us(1)
void delay_1_5us(int ms)
{
for(int i=0; i<ms; i++) delay_1us();
}
void lcdSendCtl(uint8_t val)
{
PORTC_LCD_CTRL &= ~(1<<OUT_C_LCD_CS1);
#ifdef LCD_MULTIPLEX
DDRA = 0xFF; // set LCD_DAT pins to output
#endif
PORTC_LCD_CTRL &= ~(1<<OUT_C_LCD_A0);
PORTC_LCD_CTRL &= ~(1<<OUT_C_LCD_RnW);
PORTA_LCD_DAT = val;
PORTC_LCD_CTRL |= (1<<OUT_C_LCD_E);
PORTC_LCD_CTRL &= ~(1<<OUT_C_LCD_E);
PORTC_LCD_CTRL |= (1<<OUT_C_LCD_A0);
#ifdef LCD_MULTIPLEX
DDRA = 0x00; // set LCD_DAT pins to input
#endif
PORTC_LCD_CTRL |= (1<<OUT_C_LCD_CS1);
}
#if defined(PCBSTD) && defined(VOICE)
volatile uint8_t LcdLock ;
#define LCD_LOCK() LcdLock = 1
#define LCD_UNLOCK() LcdLock = 0
#else
#define LCD_LOCK()
#define LCD_UNLOCK()
#endif
inline void lcdInit()
{
// /home/thus/txt/datasheets/lcd/KS0713.pdf
// ~/txt/flieger/ST7565RV17.pdf from http://www.glyn.de/content.asp?wdid=132&sid=
LCD_LOCK();
PORTC_LCD_CTRL &= ~(1<<OUT_C_LCD_RES); //LCD_RES
delay_1us();
delay_1us();// f520 call 0xf4ce delay_1us() ; 0x0xf4ce
PORTC_LCD_CTRL |= (1<<OUT_C_LCD_RES); // f524 sbi 0x15, 2 IOADR-PORTC_LCD_CTRL; 21 1
delay_1_5us(1500);
lcdSendCtl(0xE2); //Initialize the internal functions
lcdSendCtl(0xAE); //DON = 0: display OFF
lcdSendCtl(0xA0); //ADC = 0: normal direction
lcdSendCtl(0xA6); //REV = 0: non-reverse display
lcdSendCtl(0xA4); //EON = 0: normal display. non-entire
lcdSendCtl(0xA2); //Select LCD bias=0
lcdSendCtl(0xC8); //SHL = 1: inverse direction
lcdSendCtl(0x2F); //Control power circuit operation VC=VR=VF=1
lcdSendCtl(0x25); //Select int resistance ratio R2 R1 R0 =5
lcdSendCtl(0x81); //Set reference voltage Mode
lcdSendCtl(0x22); //24 SV5 SV4 SV3 SV2 SV1 SV0 = 0x18
lcdSendCtl(0xAF); //DON = 1: display ON
lcdSendCtl(0x60); //sets the display start line to zero
g_eeGeneral.contrast = 0x22;
LCD_UNLOCK();
}
void lcdSetRefVolt(uint8_t val)
{
LCD_LOCK();
lcdSendCtl(0x81);
lcdSendCtl(val);
LCD_UNLOCK();
}
void lcdRefresh()
{
LCD_LOCK();
uint8_t *p=displayBuf;
for(uint8_t y=0; y < 8; y++) {
lcdSendCtl(0x01);
lcdSendCtl(0x10); //column addr 0
lcdSendCtl( y | 0xB0); //page addr y
PORTC_LCD_CTRL &= ~(1<<OUT_C_LCD_CS1);
#ifdef LCD_MULTIPLEX
DDRA = 0xFF; // set LCD_DAT pins to output
#endif
PORTC_LCD_CTRL |= (1<<OUT_C_LCD_A0);
PORTC_LCD_CTRL &= ~(1<<OUT_C_LCD_RnW);
for (xcoord_t x=LCD_W; x>0; --x) {
PORTA_LCD_DAT = *p++;
PORTC_LCD_CTRL |= (1<<OUT_C_LCD_E);
PORTC_LCD_CTRL &= ~(1<<OUT_C_LCD_E);
}
PORTC_LCD_CTRL |= (1<<OUT_C_LCD_A0);
PORTC_LCD_CTRL |= (1<<OUT_C_LCD_CS1);
}
LCD_UNLOCK();
}