From bec173556d0e36faca2bf61e91264e3a467adb1f Mon Sep 17 00:00:00 2001 From: gruvin Date: Sat, 18 Aug 2012 11:35:08 +0000 Subject: [PATCH] Stripped ^M (CR's) from end of all lines in board_gruvin9x.cpp (Serves as first test commit for me, also.) --- src/board_gruvin9x.cpp | 558 ++++++++++++++++++++--------------------- 1 file changed, 279 insertions(+), 279 deletions(-) diff --git a/src/board_gruvin9x.cpp b/src/board_gruvin9x.cpp index 833a47f1a..7b0917a26 100644 --- a/src/board_gruvin9x.cpp +++ b/src/board_gruvin9x.cpp @@ -1,142 +1,142 @@ -/* - * Authors (alphabetical order) - * - Bertrand Songis - * - Bryan J. Rentoul (Gruvin) - * - Cameron Weeks - * - Erez Raviv - * - Jean-Pierre Parisy - * - Karl Szmutny - * - Michael Blandford - * - Michal Hlavinka - * - Pat Mackenzie - * - Philip Moss - * - Rob Thomson - * - Romolo Manfredini - * - 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" - -#ifdef SDCARD -uint8_t g_ms100 = 0; // global to allow time set function to reset to zero -#endif - -#ifndef SIMU -inline void board_init() -{ - // Set up I/O port data directions and initial states - DDRA = 0xff; PORTA = 0x00; // LCD data - DDRB = 0b11000111; PORTB = 0b00111111; // 7:SPKR, 6:PPM_OUT, 5:TrainSW, 4:IDL2_SW, SDCARD[3:MISO 2:MOSI 1:SCK 0:CS] - DDRC = 0x3f; PORTC = 0xc0; // 7:AilDR, 6:EleDR, LCD[5,4,3,2,1], 0:BackLight - DDRD = 0b11000000; PORTD = 0b11111100; // 7:VIB, 6:LED BL, 5:RENC2_PUSH, 4:RENC1_PUSH, 3:RENC2_B, 2:RENC2_A, 1:I2C_SDA, 0:I2C_SCL - DDRE = 0b00001010; PORTE = 0b11110100; // 7:PPM_IN, 6: RENC1_B, 5:RENC1_A, 4:USB_DNEG, 3:BUZZER, 2:USB_DPOS, 1:TELEM_TX, 0:TELEM_RX(pull-up off) - DDRF = 0x00; PORTF = 0x00; // 7-4:JTAG, 3:ADC_REF_1.2V input, 2-0:ADC_SPARE_2-0 - DDRG = 0b00010000; PORTG = 0xff; // 7-6:N/A, 5:GearSW, 4: Sim_Ctrl[out], 3:IDL1_Sw, 2:TCut_Sw, 1:RF_Power[in], 0: RudDr_Sw - DDRH = 0b00110000; PORTH = 0b11011111; // 7:0 Spare port [6:SOMO14D-BUSY 5:SOMO14D-DATA 4:SOMO14D-CLK] [2:VIB_OPTION -- setting to input for now] - DDRJ = 0x00; PORTJ = 0xff; // 7-0:Trim switch inputs - DDRK = 0x00; PORTK = 0x00; // anain. No pull-ups! -#ifdef REV0 - DDRL = 0x80; PORTL = 0x7f; // 7: Hold_PWR_On (1=On, default Off), 6:Jack_Presence_TTL, 5-0: User Button inputs -#else - DDRL = 0x80; PORTL = 0xff; // 7: Hold_PWR_On (1=On, default Off), 6:Jack_Presence_TTL, 5-0: User Button inputs -#endif - - ADMUX=ADC_VREF_TYPE; - ADCSRA=0x85; // ADC enabled, pre-scaler division=32 (no interrupt, no auto-triggering) - ADCSRB=(1< + * - Bryan J. Rentoul (Gruvin) + * - Cameron Weeks + * - Erez Raviv + * - Jean-Pierre Parisy + * - Karl Szmutny + * - Michael Blandford + * - Michal Hlavinka + * - Pat Mackenzie + * - Philip Moss + * - Rob Thomson + * - Romolo Manfredini + * - 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" + +#ifdef SDCARD +uint8_t g_ms100 = 0; // global to allow time set function to reset to zero +#endif + +#ifndef SIMU +inline void board_init() +{ + // Set up I/O port data directions and initial states + DDRA = 0xff; PORTA = 0x00; // LCD data + DDRB = 0b11000111; PORTB = 0b00111111; // 7:SPKR, 6:PPM_OUT, 5:TrainSW, 4:IDL2_SW, SDCARD[3:MISO 2:MOSI 1:SCK 0:CS] + DDRC = 0x3f; PORTC = 0xc0; // 7:AilDR, 6:EleDR, LCD[5,4,3,2,1], 0:BackLight + DDRD = 0b11000000; PORTD = 0b11111100; // 7:VIB, 6:LED BL, 5:RENC2_PUSH, 4:RENC1_PUSH, 3:RENC2_B, 2:RENC2_A, 1:I2C_SDA, 0:I2C_SCL + DDRE = 0b00001010; PORTE = 0b11110100; // 7:PPM_IN, 6: RENC1_B, 5:RENC1_A, 4:USB_DNEG, 3:BUZZER, 2:USB_DPOS, 1:TELEM_TX, 0:TELEM_RX(pull-up off) + DDRF = 0x00; PORTF = 0x00; // 7-4:JTAG, 3:ADC_REF_1.2V input, 2-0:ADC_SPARE_2-0 + DDRG = 0b00010000; PORTG = 0xff; // 7-6:N/A, 5:GearSW, 4: Sim_Ctrl[out], 3:IDL1_Sw, 2:TCut_Sw, 1:RF_Power[in], 0: RudDr_Sw + DDRH = 0b00110000; PORTH = 0b11011111; // 7:0 Spare port [6:SOMO14D-BUSY 5:SOMO14D-DATA 4:SOMO14D-CLK] [2:VIB_OPTION -- setting to input for now] + DDRJ = 0x00; PORTJ = 0xff; // 7-0:Trim switch inputs + DDRK = 0x00; PORTK = 0x00; // anain. No pull-ups! +#ifdef REV0 + DDRL = 0x80; PORTL = 0x7f; // 7: Hold_PWR_On (1=On, default Off), 6:Jack_Presence_TTL, 5-0: User Button inputs +#else + DDRL = 0x80; PORTL = 0xff; // 7: Hold_PWR_On (1=On, default Off), 6:Jack_Presence_TTL, 5-0: User Button inputs +#endif + + ADMUX=ADC_VREF_TYPE; + ADCSRA=0x85; // ADC enabled, pre-scaler division=32 (no interrupt, no auto-triggering) + ADCSRB=(1<> 1) & 0x01; + /* Get status and 9th bit, then data */ + /* from buffer */ + uint16_t resh = UCSR1B; + uint16_t resl = UDR1; + uint16_t res = 0; + + /* Filter the 9th bit, then return */ + resh = (resh >> 1) & 0x01; res = ((resh << 8) | resl); if((res == 0x180) | (res == 0x1C0)){ //button REb filter keys[BTN_REa].input((res & 0x1C0) == 0x1C0, BTN_REa); } else if((res & 0x100) == 0x100){ //rotary filter vpotToChange = res & 0xEF; vpot_mod_state = 1; - } + } else { if(vpot_mod_state & (vpotToChange < NUM_ROTARY_ENCODERS)) { @@ -173,141 +173,141 @@ ISR(USART1_RX_vect) } } #endif //EXTRA_ROTARY_ENCODERS - -#endif - -uint8_t check_soft_power() -{ -#if !defined(SIMU) && !defined(REV0) - if ((PING & 0b00000010) && (~PINL & 0b01000000)) - return e_power_off; -#endif - return e_power_on; -} - -void soft_power_off() -{ -#ifndef REV0 - PORTL = 0x7f; -#endif -} - -#ifndef SIMU -FORCEINLINE -#endif -uint8_t keyDown() -{ - return (~PINL) & 0x3F; -} - -bool keyState(EnumKeys enuk) -{ - uint8_t result = 0 ; - - if (enuk < (int)DIM(keys)) - return keys[enuk].state() ? 1 : 0; - - switch(enuk){ - case SW_ElevDR: - result = PINC & (1<> 3; - - for(int i=1; i<7; i++) - { - //INP_B_KEY_MEN 1 .. INP_B_KEY_LFT 6 - keys[enuk].input(in & (1<> 3; + + for(int i=1; i<7; i++) + { + //INP_B_KEY_MEN 1 .. INP_B_KEY_LFT 6 + keys[enuk].input(in & (1<