MEGA2560 update (all commits merged in only one)

This commit is contained in:
bsongis
2014-12-09 18:57:43 +01:00
parent 361fbd83dc
commit 404b55c87f
8 changed files with 123 additions and 386 deletions
+13 -2
View File
@@ -588,6 +588,7 @@ ifeq ($(PCB), MEGA2560)
OPT = s
CPPDEFS = -DF_CPU=$(F_CPU)UL -DPCBMEGA2560 -DCPUM2560 -DEEPROM_VARIANT=0 -DAUDIO -DRTCLOCK
SDCARD = YES
BUZZER = YES
THR_TRACE = YES
INCDIRS += targets/mega2560 targets/stock FatFs FatFs/option
BOARDSRC = main_avr.cpp targets/mega2560/board_mega2560.cpp
@@ -600,10 +601,20 @@ ifeq ($(PCB), MEGA2560)
ifeq ($(SDCARD), YES)
EXTRABOARDSRC += FatFs/ff.c FatFs/fattime.c FatFs/option/ccsbcs.c targets/gruvin9x/diskio.cpp
CPPDEFS += -DRTCLOCK
CPPSRC += rtc.cpp targets/mega2560/rtc_driver.cpp
CPPSRC += rtc.cpp targets/gruvin9x/rtc_driver.cpp
endif
ifeq ($(BUZZER), YES)
CPPDEFS += -DBUZZER
CPPSRC += buzzer.cpp
endif
ifeq ($(VOICE), YES)
CPPDEFS += -DVOICE
CPPSRC += targets/gruvin9x/somo14d.cpp
endif
# Enable extra rotary encoders (Gruvin9x board only)
# Enable extra rotary encoders
# Values = YES, NO
ROTARY_ENCODERS = 2
CPPDEFS += -DROTARY_ENCODERS=${ROTARY_ENCODERS}
+4 -2
View File
@@ -1513,7 +1513,7 @@ void getADC()
#if !defined(CPUARM)
void getADC_bandgap()
{
#if defined(CPUM2560)
#if defined(PCBGRUVIN9X)
static uint8_t s_bgCheck = 0;
static uint16_t s_bgSum = 0;
ADCSRA|=0x40; // request sample
@@ -1527,6 +1527,8 @@ void getADC_bandgap()
s_bgSum += ADC;
}
ADCSRB |= (1<<MUX5);
#elif defined(PCBMEGA2560)
BandGap = 2000;
#else
// TODO is the next line needed (because it has been called before perMain)?
ADMUX = 0x1E|ADC_VREF_TYPE; // Switch MUX to internal 1.22V reference
@@ -1666,7 +1668,7 @@ void doMixerCalculations()
Current_analogue = (Current_analogue*31 + s_anaFilt[8] ) >> 5 ;
if (Current_analogue > Current_max)
Current_max = Current_analogue ;
#elif defined(CPUM2560) && !defined(SIMU)
#elif defined(PCBGRUVIN9X) && !defined(SIMU)
// For PCB V4, use our own 1.2V, external reference (connected to ADC3)
ADCSRB &= ~(1<<MUX5);
ADMUX = 0x03|ADC_VREF_TYPE; // Switch MUX to internal reference
+10 -10
View File
@@ -78,7 +78,7 @@ void set_timer3_ppm( void ) ;
void startPulses()
{
#if defined(PCBGRUVIN9X)
#if defined(CPUM2560)
#if defined(DSM2_SERIAL)
if (!IS_DSM2_PROTOCOL(g_model.protocol))
#endif
@@ -129,7 +129,7 @@ ISR(TIMER1_COMPA_vect) //2MHz pulse generation (BLOCKING ISR)
return;
}
#if !defined(PCBGRUVIN9X)
#if !defined(CPUM2560)
// Original bitbang for PPM
if (s_current_protocol[0] != PROTO_NONE) {
if (g_ppmPulsePolarity) {
@@ -141,8 +141,8 @@ ISR(TIMER1_COMPA_vect) //2MHz pulse generation (BLOCKING ISR)
g_ppmPulsePolarity = 1;
}
}
#else // defined(PCBGRUVIN9X)
// PCBGRUVIN9X zero jitter hardware toggled PPM_out
#else // defined(CPUM2560)
// CPUM2560 zero jitter hardware toggled PPM_out
OCR1B = *((uint16_t*)pulses2MHzRPtr); // duplicate capture (Timer1 in CTC mode, so restricted to OCR1A for int vector)
// Toggle bit: Can't read PPM_OUT I/O pin when OC1B is connected (on the ATmega2560 -- can on ATmega64A!)
@@ -501,7 +501,7 @@ void sendByteDsm2(uint8_t b) //max 10changes 0 10 10 10 10 1
len += BITLEN_DSM2;
}
else {
#if defined(PCBGRUVIN9X)
#if defined(CPUM2560)
// G: Compensate for main clock synchronisation -- to get accurate 8us bit length
// NOTE: This has now been tested as NOT required on the stock board, with the ATmega64A chip.
_send_1(nlev ? len-5 : len+3);
@@ -513,7 +513,7 @@ void sendByteDsm2(uint8_t b) //max 10changes 0 10 10 10 10 1
}
b = (b>>1) | 0x80; //shift in stop bit
}
#if defined (PCBGRUVIN9X)
#if defined (CPUM2560)
_send_1(len+BITLEN_DSM2+3); // 2 stop bits
#else
_send_1(len+BITLEN_DSM2-1); // 2 stop bits
@@ -568,7 +568,7 @@ void setupPulsesDSM2()
pulses2MHzWPtr -= 1; //remove last stopbits and
#if !defined(PCBGRUVIN9X)
#if !defined(CPUM2560)
//G: Removed to get waveform correct on analyser. Leave in for stock board until tests can be done.
_send_1(255); // prolong them
#endif
@@ -757,7 +757,7 @@ void setupPulses()
if (s_pulses_paused)
required_protocol = PROTO_NONE;
#if defined(PCBGRUVIN9X) && defined(DSM2_PPM) && defined(TX_CADDY)
#if defined(CPUM2560) && defined(DSM2_PPM) && defined(TX_CADDY)
// This should be here, executed on every loop, to ensure re-setting of the
// TX moudle power control output register, in case of electrical glitch.
// (Following advice of Atmel for MCU's used in industrial / mission cricital
@@ -911,7 +911,7 @@ void setupPulses()
sei();
#endif
setupPulsesDSM2(); // Different versions for DSM2=SERIAL vs. DSM2=PPM
#if defined(PCBGRUVIN9X) && defined(DSM2_PPM)
#if defined(CPUM2560) && defined(DSM2_PPM)
// Ensure each DSM2=PPM serial packet starts out with the correct bit polarity
TCCR1A = (0 << WGM10) | (3<<COM1B1); // Make Waveform Generator 'SET' OCR1B pin on next compare event and ...
TCCR1C = (1<<FOC1B); // ... force compare event, to set OCR1B pin high.
@@ -950,7 +950,7 @@ void setupPulses()
#if defined(DSM2_PPM) || defined(PXX)
ISR(TIMER1_CAPT_vect) // 2MHz pulse generation
{
#if defined (PCBGRUVIN9X)
#if defined (CPUM2560)
/*** G9X V4 hardware toggled PPM_out avoids any chance of output timing jitter ***/
+4 -17
View File
@@ -1,22 +1,9 @@
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
- Gruvin9x features (soft-off, SD-Card, RTC, haptic, voice, rotary encoders)
- Artronic LCD 128x64 ST7565R
- Aurora9 or T9X gimballs
- home made case
@@ -42,13 +42,13 @@ inline void boardInit()
{
// Set up I/O port data directions and initial states (unused pin setting : input, pull-up on)
DDRA = 0b11111111; PORTA = 0b00000000; // LCD data
DDRB = 0b01110111; PORTB = 0b00001111; // 7:PPM_IN 6:PPM_OUT, 5:SimCTRL, 4:Buzzer, SDCARD[3:MISO 2:MOSI 1:SCK 0:CS]
DDRB = 0b01110111; PORTB = 0b00101111; // 7:PPM_IN 6:PPM_OUT, 5:SimCTRL, 4:Buzzer, SDCARD[3:MISO 2:MOSI 1:SCK 0:CS]
DDRC = 0b11111100; PORTC = 0b00000011; // 7-3:LCD, 2:BackLight, 1:ID2_SW, 0:ID1_SW
DDRD = 0b00000000; PORTD = 0b11111111; // 7:AilDR_SW, 6:N/A, 5:N/A, 4:N/A, 3:RENC2_B, 2:RENC2_A, 1:N/A, 0:N/A
DDRE = 0b00000010; PORTE = 0b11111100; // 7:N/A, 6:N/A, 5:RENC1_B, 4:RENC1_A, 3:N/A, 2:N/A, 1:TELEM_TX, 0:TELEM_RX
DDRF = 0b00000000; PORTF = 0b11111111; // 7-0:Trim switch inputs
DDRG = 0b00000000; PORTG = 0b11111111; // 7:N/A, 6:N/A, 5:N/A, 4:N/A, 3:N/A, 2:TCut_SW, 1:Gear_SW, 0: RudDr_SW
DDRH = 0b00011000; PORTH = 0b10010111; // 7:N/A, 6:RFPw, 5:JackPres, 4:HoldPw, 3:Speaker, 2:N/A, 1:N/A, 0:N/A
DDRH = 0b00011000; PORTH = 0b11100111; // 7:N/A, 6:RFPw, 5:JackPres, 4:HoldPw, 3:Speaker, 2:N/A, 1:N/A, 0:N/A
DDRJ = 0b00000000; PORTJ = 0b11111111; // 7:N/A, 6:N/A, 5:N/A, 4:N/A, 3:N/A, 2:N/A, 1:RENC2_push, 0:RENC1_push
DDRK = 0b00000000; PORTK = 0b00000000; // Analogic input (no pull-ups)
DDRL = 0b00000000; PORTL = 0b11111111; // 7:TRN_SW 6:EleDR_SW, 5:ESC, 4:MENU 3:Keyb_Left, 2:Keyb_Right, 1:Keyb_Up, 0:Keyb_Down
+90 -98
View File
@@ -40,35 +40,35 @@
#include "../common_avr/board_avr.h"
#define GPIO_BUTTON_MENU pinl //ok
#define GPIO_BUTTON_EXIT pinl //ok
#define GPIO_BUTTON_RIGHT pinl //ok
#define GPIO_BUTTON_LEFT pinl //ok
#define GPIO_BUTTON_UP pinl //ok
#define GPIO_BUTTON_DOWN pinl //ok
#define PIN_BUTTON_MENU (1<<INP_L_KEY_MEN) //ok
#define PIN_BUTTON_EXIT (1<<INP_L_KEY_EXT) //ok
#define PIN_BUTTON_UP (1<<INP_L_KEY_UP) //ok
#define PIN_BUTTON_DOWN (1<<INP_L_KEY_DWN) //ok
#define PIN_BUTTON_RIGHT (1<<INP_L_KEY_RGT) //ok
#define PIN_BUTTON_LEFT (1<<INP_L_KEY_LFT) //ok
#define GPIO_BUTTON_MENU pinl
#define GPIO_BUTTON_EXIT pinl
#define GPIO_BUTTON_RIGHT pinl
#define GPIO_BUTTON_LEFT pinl
#define GPIO_BUTTON_UP pinl
#define GPIO_BUTTON_DOWN pinl
#define PIN_BUTTON_MENU (1<<INP_L_KEY_MEN)
#define PIN_BUTTON_EXIT (1<<INP_L_KEY_EXT)
#define PIN_BUTTON_UP (1<<INP_L_KEY_UP)
#define PIN_BUTTON_DOWN (1<<INP_L_KEY_DWN)
#define PIN_BUTTON_RIGHT (1<<INP_L_KEY_RGT)
#define PIN_BUTTON_LEFT (1<<INP_L_KEY_LFT)
#define GPIO_TRIM_LH_L pinf //ok
#define GPIO_TRIM_LV_DN pinf //ok
#define GPIO_TRIM_RV_UP pinf //ok
#define GPIO_TRIM_RH_L pinf //ok
#define GPIO_TRIM_LH_R pinf //ok
#define GPIO_TRIM_LV_UP pinf //ok
#define GPIO_TRIM_RV_DN pinf //ok
#define GPIO_TRIM_RH_R pinf //ok
#define PIN_TRIM_LH_L (1<<INP_F_TRM_LH_DWN) //ok
#define PIN_TRIM_LV_DN (1<<INP_F_TRM_LV_DWN) //ok
#define PIN_TRIM_RV_UP (1<<INP_F_TRM_RV_UP) //ok
#define PIN_TRIM_RH_L (1<<INP_F_TRM_RH_DWN) //ok
#define PIN_TRIM_LH_R (1<<INP_F_TRM_LH_UP) //ok
#define PIN_TRIM_LV_UP (1<<INP_F_TRM_LV_UP) //ok
#define PIN_TRIM_RV_DN (1<<INP_F_TRM_RV_DWN) //ok
#define PIN_TRIM_RH_R (1<<INP_F_TRM_RH_UP) //ok
#define GPIO_TRIM_LH_L pinf
#define GPIO_TRIM_LV_DN pinf
#define GPIO_TRIM_RV_UP pinf
#define GPIO_TRIM_RH_L pinf
#define GPIO_TRIM_LH_R pinf
#define GPIO_TRIM_LV_UP pinf
#define GPIO_TRIM_RV_DN pinf
#define GPIO_TRIM_RH_R pinf
#define PIN_TRIM_LH_L (1<<INP_F_TRM_LH_DWN)
#define PIN_TRIM_LV_DN (1<<INP_F_TRM_LV_DWN)
#define PIN_TRIM_RV_UP (1<<INP_F_TRM_RV_UP)
#define PIN_TRIM_RH_L (1<<INP_F_TRM_RH_DWN)
#define PIN_TRIM_LH_R (1<<INP_F_TRM_LH_UP)
#define PIN_TRIM_LV_UP (1<<INP_F_TRM_LV_UP)
#define PIN_TRIM_RV_DN (1<<INP_F_TRM_RV_DWN)
#define PIN_TRIM_RH_R (1<<INP_F_TRM_RH_UP)
#define TIMER_16KHZ_VECT TIMER2_OVF_vect
#define COUNTER_16KHZ TCNT2
@@ -79,18 +79,14 @@
#define PAUSE_PPMIN_INTERRUPT() TIMSK3 &= ~(1<<ICIE3)
#define RESUME_PPMIN_INTERRUPT() TIMSK3 |= (1<<ICIE3)
#define SLAVE_MODE() (PINH & (1<<INP_H_RF_POW)) //not tested
#define JACK_PPM_OUT() PORTB |= (1<<OUT_B_SIM_CTL) //not tested
#define JACK_PPM_IN() PORTB &= ~(1<<OUT_B_SIM_CTL) //not tested
#define speakerOn() TCCR0A |= (1 << COM0A0) //not tested
#define speakerOff() TCCR0A &= ~(1 << COM0A0) //not tested
#define SLAVE_MODE() (PINH & (1<<INP_H_RF_POW))
#define JACK_PPM_OUT() PORTB |= (1<<OUT_B_SIM_CTL)
#define JACK_PPM_IN() PORTB &= ~(1<<OUT_B_SIM_CTL)
#define __BACKLIGHT_ON PORTC |= (1 << OUT_C_LIGHT)
#define __BACKLIGHT_OFF PORTC &= ~(1 << OUT_C_LIGHT)
#define IS_BACKLIGHT_ON() (PORTC & (1<<OUT_C_LIGHT))
#define __BACKLIGHT_ON PORTC |= (1 << OUT_C_LIGHT) //ok
#define __BACKLIGHT_OFF PORTC &= ~(1 << OUT_C_LIGHT) //ok
#define IS_BACKLIGHT_ON() (PORTC & (1<<OUT_C_LIGHT)) //ok
// SD driver //to verify
// SD driver
#define sdDone()
#if !defined(SIMU)
bool sdMounted();
@@ -103,78 +99,70 @@
#endif
// Keyboard driver
# define INP_L_KEY_EXT 5 //ok
# define INP_L_KEY_MEN 4 //ok
# define INP_L_KEY_LFT 3 //ok
# define INP_L_KEY_RGT 2 //ok
# define INP_L_KEY_UP 1 //ok
# define INP_L_KEY_DWN 0 //ok
# define INP_L_KEY_EXT 5
# define INP_L_KEY_MEN 4
# define INP_L_KEY_LFT 3
# define INP_L_KEY_RGT 2
# define INP_L_KEY_UP 1
# define INP_L_KEY_DWN 0
// Trims driver
# define INP_F_TRM_RH_UP 7 //ok
# define INP_F_TRM_RH_DWN 6 //ok
# define INP_F_TRM_RV_UP 5 //ok
# define INP_F_TRM_RV_DWN 4 //ok
# define INP_F_TRM_LV_UP 3 //ok
# define INP_F_TRM_LV_DWN 2 //ok
# define INP_F_TRM_LH_UP 1 //ok
# define INP_F_TRM_LH_DWN 0 //ok
# define INP_F_TRM_RH_UP 7
# define INP_F_TRM_RH_DWN 6
# define INP_F_TRM_RV_UP 5
# define INP_F_TRM_RV_DWN 4
# define INP_F_TRM_LV_UP 3
# define INP_F_TRM_LV_DWN 2
# define INP_F_TRM_LH_UP 1
# define INP_F_TRM_LH_DWN 0
// Switchs driver
# define INP_C_ID2 1 //ok
# define INP_C_ID1 0 //ok
# define INP_D_AileDR 7 //ok
# define INP_G_ThrCt 2 //ok
# define INP_G_Gear 1 //ok
# define INP_G_RuddDR 0 //ok
# define INP_L_ElevDR 6 //ok
# define INP_L_Trainer 7 //ok
# define INP_C_ID2 1
# define INP_C_ID1 0
# define INP_D_AileDR 7
# define INP_G_ThrCt 2
# define INP_G_Gear 1
# define INP_G_RuddDR 0
# define INP_L_ElevDR 6
# define INP_L_Trainer 7
// Servitudes driver
# define INP_B_PPM_IN 7 //not tested
# define OUT_B_PPM 6 //to verify
# define OUT_B_SIM_CTL 5 //not tested
# define OUT_B_BUZZER 4 //to verify
# define INP_H_RF_POW 6 //not tested
# define INP_B_PPM_IN 7
# define OUT_B_PPM 6
# define OUT_B_SIM_CTL 5
# define OUT_B_BUZZER 4
# define INP_D_I2C_SCL 1
# define INP_D_I2C_SDA 0
# define INP_E_TELEM_RX 1
# define OUT_E_TELEM_TX 0
# define INP_H_RF_POW 6
//#define INP_H_ 5 //reserved JACKPRES
//#define INP_H_ 4 //reserved HOLDPWR
# define OUT_H_Speaker 3 //not tested
# define INP_E_TELEM_RX 1 //same as Gruvin9x
# define OUT_E_TELEM_TX 0 //same as Gruvin9x
# define OUT_H_Speaker 3
# define OUT_H_HAPTIC 0
// Rotary encoders driver
# define INP_E_ROT_ENC_1_A 4 //ok
# define INP_E_ROT_ENC_1_B 5 //ok
# define INP_D_ROT_ENC_2_A 2 //ok
# define INP_D_ROT_ENC_2_B 3 //ok
# define INP_J_ROT_ENC_1_PUSH 0 //ok
# define INP_J_ROT_ENC_2_PUSH 1 //ok
# define REA_DOWN() (~PINJ & (1<<INP_J_ROT_ENC_1_PUSH)) //ok
# define REB_DOWN() (~PINJ & (1<<INP_J_ROT_ENC_2_PUSH)) //ok
# define ROTENC_DOWN() (REA_DOWN() || REB_DOWN()) //ok
// Old #define from Gruvin9x
/*
# define OUT_E_BUZZER 3 //to erase
# define INP_E_USB_D_PLS 4 //to erase
# define INP_E_USB_D_NEG 2 //to erase
# define OUT_D_HAPTIC 7 //to erase
# define INP_D_SPARE4 6 //to erase
# define INP_D_I2C_SCL 1 //to erase
# define INP_D_I2C_SDA 0 //to erase
*/
# define INP_E_ROT_ENC_1_A 4
# define INP_E_ROT_ENC_1_B 5
# define INP_D_ROT_ENC_2_A 2
# define INP_D_ROT_ENC_2_B 3
# define INP_J_ROT_ENC_1_PUSH 0
# define INP_J_ROT_ENC_2_PUSH 1
# define REA_DOWN() (~PINJ & (1<<INP_J_ROT_ENC_1_PUSH))
# define REB_DOWN() (~PINJ & (1<<INP_J_ROT_ENC_2_PUSH))
# define ROTENC_DOWN() (REA_DOWN() || REB_DOWN())
// LCD driver
#define PORTA_LCD_DAT PORTA //ok
#define PORTC_LCD_CTRL PORTC //ok
#define OUT_C_LCD_E 7 //ok
#define OUT_C_LCD_RnW 6 //ok
#define OUT_C_LCD_A0 5 //ok
#define OUT_C_LCD_RES 4 //ok
#define OUT_C_LCD_CS1 3 //ok
#define OUT_C_LIGHT 2 //ok
#define PORTA_LCD_DAT PORTA
#define PORTC_LCD_CTRL PORTC
#define OUT_C_LCD_E 7
#define OUT_C_LCD_RnW 6
#define OUT_C_LCD_A0 5
#define OUT_C_LCD_RES 4
#define OUT_C_LCD_CS1 3
#define OUT_C_LIGHT 2
// DBLKeys driver //ok
// DBLKeys driver
#define KEYS_PRESSED() (~PINL)
#define DBLKEYS_PRESSED_RGT_LFT(i) ((in & ((1<<INP_L_KEY_RGT) + (1<<INP_L_KEY_LFT))) == ((1<<INP_L_KEY_RGT) + (1<<INP_L_KEY_LFT)))
#define DBLKEYS_PRESSED_UP_DWN(i) ((in & ((1<<INP_L_KEY_UP) + (1<<INP_L_KEY_DWN))) == ((1<<INP_L_KEY_UP) + (1<<INP_L_KEY_DWN)))
@@ -196,4 +184,8 @@ void pwrOff();
#define buzzerOn() PORTB |= (1 << OUT_B_BUZZER)
#define buzzerOff() PORTB &= ~(1 << OUT_B_BUZZER)
// Speaker driver
#define speakerOn() TCCR0A |= (1 << COM0A0)
#define speakerOff() TCCR0A &= ~(1 << COM0A0)
#endif
-160
View File
@@ -1,160 +0,0 @@
/*
* 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
*
* opentx 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
-95
View File
@@ -1,95 +0,0 @@
/*
* 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
*
* opentx 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.
*
*/
/*--------------------------------------------------------------------------*/
/* RTC controls */
#include "../opentx.h"
#include "../FatFs/integer.h"
typedef struct {
WORD year; /* 2000..2099 */
BYTE month; /* 1..12 */
BYTE mday; /* 1.. 31 */
BYTE wday; /* 1..7 */
BYTE hour; /* 0..23 */
BYTE min; /* 0..59 */
BYTE sec; /* 0..59 */
} RTC;
void rtc_gettime(struct gtm * utm)
{
RTC rtc = {0,0,0,0,0,0,0};
// TODO g9x_rtc_gettime(&rtc);
utm->tm_year = rtc.year - 1900;
utm->tm_mon = rtc.month - 1;
utm->tm_mday = rtc.mday;
utm->tm_hour = rtc.hour;
utm->tm_min = rtc.min;
utm->tm_sec = rtc.sec;
utm->tm_wday = rtc.wday - 1;
}
void rtcSetTime(struct gtm * t)
{
g_rtcTime = gmktime(t); // update local timestamp and get wday calculated
g_ms100 = 0; // start of next second begins now
#if 0
RTC rtc;
rtc.year = t->tm_year + 1900;
rtc.month = t->tm_mon + 1;
rtc.mday = t->tm_mday;
rtc.hour = t->tm_hour;
rtc.min = t->tm_min;
rtc.sec = t->tm_sec;
rtc.wday = t->tm_wday + 1;
g9x_rtcSetTime(&rtc);
#endif
}
void rtcInit (void)
{
// TODO
struct gtm utm;
rtc_gettime(&utm);
g_rtcTime = gmktime(&utm);
}