/* * Authors (alphabetical order) * - Bertrand Songis * - Bryan J. Rentoul (Gruvin) * * gruvin9x is based on code named er9x by * Author - Erez Raviv , which is in turn * was based on 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 "gruvin9x.h" #ifndef SIMU #ifdef ASYNC_WRITE uint16_t eeprom_pointer; const char* eeprom_buffer_data; volatile size_t eeprom_buffer_size = 0; inline void eeprom_write_byte() { EEAR = eeprom_pointer; EEDR = *eeprom_buffer_data; #if defined (PCBV3) EECR |= 1< 0) { eeprom_write_byte(); } else { #if defined (PCBV3) EECR &= ~(1< 0); } #else ///opt/cross/avr/include/avr/eeprom.h static inline void __attribute__ ((always_inline)) eeprom_write_byte_cmp (uint8_t dat, uint16_t pointer_eeprom) { //see /home/thus/work/avr/avrsdk4/avr-libc-1.4.4/libc/misc/eeprom.S:98 143 #if defined (PCBV3) while(EECR & (1<16) m_dblcnt=0; //pause zu lang fuer double m_cnt = 0; } break; //fallthrough case KSTATE_START: putEvent(EVT_KEY_FIRST(enuk)); m_dblcnt++; m_state = KSTATE_RPTDELAY; m_cnt = 0; break; case KSTATE_RPTDELAY: // gruvin: delay state before first key repeat if(m_cnt == 24) putEvent(EVT_KEY_LONG(enuk)); if (m_cnt == 40) { m_state = 16; m_cnt = 0; } break; case 16: case 8: case 4: case 2: if(m_cnt >= 48) { //3 6 12 24 48 pulses in every 480ms m_state >>= 1; m_cnt = 0; } //fallthrough case 1: if( (m_cnt & (m_state-1)) == 0) putEvent(EVT_KEY_REPT(enuk)); break; case KSTATE_PAUSE: //pause if(m_cnt >= 64) { m_state = 8; m_cnt = 0; } break; case KSTATE_KILLED: //killed break; } } bool keyState(EnumKeys enuk) { if(enuk < (int)DIM(keys)) return keys[enuk].state() ? 1 : 0; switch(enuk){ case SW_ElevDR : return PINE & (1<> 4); PORTD = 0xFF; #else in = ~PIND; // Legacy support for USART1 free hardware mod [DEPRECATED] #if defined(USART1FREED) // mask out original INP_D_TRM_LV_UP and INP_D_TRM_LV_DWN bits in &= ~((1< 10ms intervals if ( FrskyAlarmSendState ) FRSKY10mspoll() ; if (frskyStreaming > 0) frskyStreaming--; else if (g_eeGeneral.enableTelemetryAlarm && (g_model.frsky.channels[0].ratio || g_model.frsky.channels[1].ratio)) { #if defined (BEEPSPKR) if (!(g_tmr10ms % 30)) beepWarn2Spkr((g_tmr10ms % 60) ? 25 : 20); #else if (!(g_tmr10ms % 30)) { warble = !(g_tmr10ms % 60); beepWarn2(); } #endif } #endif // These moved here from perOut() [gruvin9x.cpp] to improve beep trigger reliability. #if defined (BEEPSPKR) if(mixWarning & 1) if(((g_tmr10ms&0xFF)== 0)) beepWarn1Spkr(BEEP_DEFAULT_FREQ+7); if(mixWarning & 2) if(((g_tmr10ms&0xFF)== 64) || ((g_tmr10ms&0xFF)== 72)) beepWarn1Spkr(BEEP_DEFAULT_FREQ+9); if(mixWarning & 4) if(((g_tmr10ms&0xFF)==128) || ((g_tmr10ms&0xFF)==136) || ((g_tmr10ms&0xFF)==144)) beepWarn1Spkr(BEEP_DEFAULT_FREQ+11); #else if(mixWarning & 1) if(((g_tmr10ms&0xFF)== 0)) beepWarn1(); if(mixWarning & 2) if(((g_tmr10ms&0xFF)== 64) || ((g_tmr10ms&0xFF)== 72)) beepWarn1(); if(mixWarning & 4) if(((g_tmr10ms&0xFF)==128) || ((g_tmr10ms&0xFF)==136) || ((g_tmr10ms&0xFF)==144)) beepWarn1(); #endif }