[stock] Issue 157 fixed
[gruvin9x] Issue 160 fixed
This commit is contained in:
+3
-1
@@ -100,10 +100,12 @@ extern "C" {
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#define _USE_LFN 2 /* 0 to 3 */
|
||||
#define _MAX_LFN 255 /* Maximum LFN length to handle (12 to 255) */
|
||||
#else
|
||||
#define _USE_LFN 1 /* 0 to 3 */
|
||||
#define _MAX_LFN 32 /* Maximum LFN length to handle (12 to 255) */
|
||||
#endif
|
||||
#define _MAX_LFN 255 /* Maximum LFN length to handle (12 to 255) */
|
||||
|
||||
/* The _USE_LFN option switches the LFN support.
|
||||
/
|
||||
/ 0: Disable LFN feature. _MAX_LFN and _LFN_UNICODE have no effect.
|
||||
|
||||
+2
-2
@@ -520,8 +520,8 @@ ifeq ($(PCB), GRUVIN9X)
|
||||
|
||||
ifeq ($(SDCARD), YES)
|
||||
CPPDEFS += -DRTCLOCK
|
||||
CPPSRC += rtc.cpp gruvin9x/rtc_driver.cpp gruvin9x/diskio.cpp
|
||||
EXTRABOARDSRC += FatFs/ff.c FatFs/fattime.c FatFs/option/ccsbcs.c
|
||||
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)
|
||||
|
||||
@@ -109,11 +109,6 @@ inline void board_init()
|
||||
OCR4A = 0x7d;
|
||||
TCCR4B = (1 << WGM42) | (3<<CS40); // CTC OCR1A, 16MHz / 64 (4us ticks)
|
||||
|
||||
/* Mixer interrupt */
|
||||
OCR5A = 0x7d * 40; /* 20ms */
|
||||
TCCR5B = (1 << WGM52) | (3<<CS50); // CTC OCR1A, 16MHz / 64 (4us ticks)
|
||||
TIMSK5 |= (1<<OCIE5A);
|
||||
|
||||
#if defined(EXTRA_ROTARY_ENCODERS)
|
||||
//configure uart1 here
|
||||
DDRD &= ~(1 << 2);
|
||||
@@ -301,3 +296,5 @@ void readKeysAndTrims()
|
||||
++enuk;
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t nextMixerTime = 0;
|
||||
|
||||
@@ -34,5 +34,23 @@
|
||||
#ifndef board_gruvin9x_h
|
||||
#define board_gruvin9x_h
|
||||
|
||||
extern uint16_t nextMixerTime;
|
||||
|
||||
#define TIMER_16KHZ_VECT TIMER2_OVF_vect
|
||||
#define COUNTER_16KHZ TCNT2
|
||||
#define TIMER_10MS_VECT TIMER2_COMPA_vect
|
||||
#define PAUSE_10MS_INTERRUPT() TIMSK2 &= ~(1<<OCIE2A)
|
||||
#define RESUME_10MS_INTERRUPT() TIMSK2 |= (1<<OCIE2A)
|
||||
#define SCHEDULE_MIXER(delay) nextMixerTime = getTmr16KHz() + (delay)
|
||||
#define PAUSE_PULSES_INTERRUPT() TIMSK1 &= ~(1<<OCIE1A)
|
||||
#define RESUME_PULSES_INTERRUPT() TIMSK1 |= (1<<OCIE1A)
|
||||
#define PAUSE_PPMIN_INTERRUPT() TIMSK3 &= ~(1<<ICIE3)
|
||||
#define RESUME_PPMIN_INTERRUPT() TIMSK3 |= (1<<ICIE3)
|
||||
|
||||
#define SLAVE_MODE() (PING & (1<<INP_G_RF_POW))
|
||||
#define JACK_PPM_OUT() PORTG |= (1<<OUT_G_SIM_CTL)
|
||||
#define JACK_PPM_IN() PORTG &= ~(1<<OUT_G_SIM_CTL)
|
||||
|
||||
extern void sdPoll10ms();
|
||||
|
||||
#endif
|
||||
|
||||
+6
-1
@@ -47,9 +47,10 @@
|
||||
extern "C" {
|
||||
extern void init_SDcard();
|
||||
extern void sdInit();
|
||||
extern void sdPoll10mS();
|
||||
}
|
||||
|
||||
#define sdPoll10ms()
|
||||
|
||||
void usbMassStorage();
|
||||
|
||||
#define PIN_ENABLE 0x001
|
||||
@@ -98,4 +99,8 @@ extern uint32_t Current_used;
|
||||
extern uint16_t sessionTimer;
|
||||
#endif
|
||||
|
||||
#define SLAVE_MODE() (check_soft_power() == e_power_trainer)
|
||||
#define JACK_PPM_OUT() PIOC->PIO_PDR = PIO_PC22
|
||||
#define JACK_PPM_IN() PIOC->PIO_PER = PIO_PC22
|
||||
|
||||
#endif
|
||||
|
||||
@@ -182,3 +182,23 @@ void readKeysAndTrims()
|
||||
++enuk;
|
||||
}
|
||||
}
|
||||
|
||||
bool checkSlaveMode()
|
||||
{
|
||||
// no power -> only phone jack = slave mode
|
||||
static bool lastSlaveMode = false;
|
||||
static uint8_t checkDelay = 0;
|
||||
if (IS_AUDIO_BUSY()) {
|
||||
checkDelay = 20;
|
||||
}
|
||||
else if (checkDelay) {
|
||||
--checkDelay;
|
||||
}
|
||||
else {
|
||||
lastSlaveMode = (PING & (1<<INP_G_RF_POW));
|
||||
}
|
||||
return lastSlaveMode;
|
||||
}
|
||||
|
||||
uint16_t nextMixerTime = 0;
|
||||
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Authors (alphabetical order)
|
||||
* - Bertrand Songis <bsongis@gmail.com>
|
||||
* - Bryan J. Rentoul (Gruvin) <gruvin@gmail.com>
|
||||
* - Cameron Weeks <th9xer@gmail.com>
|
||||
* - Erez Raviv
|
||||
* - Jean-Pierre Parisy
|
||||
* - Karl Szmutny <shadow@privy.de>
|
||||
* - 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 board_stock_h
|
||||
#define board_stock_h
|
||||
|
||||
extern uint16_t nextMixerTime;
|
||||
|
||||
#define TIMER_16KHZ_VECT TIMER0_OVF_vect
|
||||
#define COUNTER_16KHZ TCNT0
|
||||
|
||||
#define TIMER_10MS_VECT TIMER0_COMP_vect
|
||||
#define PAUSE_10MS_INTERRUPT() TIMSK &= ~(1<<OCIE0)
|
||||
#define RESUME_10MS_INTERRUPT() TIMSK |= (1<<OCIE0)
|
||||
|
||||
#define PAUSE_PULSES_INTERRUPT() TIMSK &= ~(1<<OCIE1A);
|
||||
#define RESUME_PULSES_INTERRUPT() TIMSK |= (1<<OCIE1A)
|
||||
|
||||
#define SCHEDULE_MIXER(delay) nextMixerTime = getTmr16KHz() + (delay)
|
||||
|
||||
#define PAUSE_PPMIN_INTERRUPT() ETIMSK &= ~(1<<TICIE3)
|
||||
#define RESUME_PPMIN_INTERRUPT() ETIMSK |= (1<<TICIE3)
|
||||
|
||||
bool checkSlaveMode();
|
||||
#define SLAVE_MODE() checkSlaveMode()
|
||||
#define JACK_PPM_OUT() PORTG &= ~(1<<OUT_G_SIM_CTL)
|
||||
#define JACK_PPM_IN() PORTG |= (1<<OUT_G_SIM_CTL)
|
||||
|
||||
#endif
|
||||
+8
-8
@@ -39,14 +39,7 @@ void putEvent(uint8_t evt)
|
||||
s_evt = evt;
|
||||
}
|
||||
|
||||
#if defined(PCBSTD)
|
||||
uint8_t getEvent()
|
||||
{
|
||||
uint8_t evt = s_evt;
|
||||
s_evt = 0;
|
||||
return evt;
|
||||
}
|
||||
#else
|
||||
#if defined(PCBSKY9X)
|
||||
uint8_t getEvent(bool trim)
|
||||
{
|
||||
uint8_t evt = s_evt;
|
||||
@@ -61,6 +54,13 @@ uint8_t getEvent(bool trim)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#else
|
||||
uint8_t getEvent()
|
||||
{
|
||||
uint8_t evt = s_evt;
|
||||
s_evt = 0;
|
||||
return evt;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
|
||||
+2
-2
@@ -106,7 +106,7 @@ void eeWriteBlockCmp(const void *i_pointer_ram, uint16_t i_pointer_eeprom, size_
|
||||
#endif
|
||||
|
||||
if (s_sync_write) {
|
||||
while (eeprom_buffer_size > 0) WDT_RESET_STOCK();
|
||||
while (eeprom_buffer_size > 0) wdt_reset();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -794,7 +794,7 @@ void RlcFile::nextRlcWriteStep()
|
||||
|
||||
void RlcFile::flush()
|
||||
{
|
||||
while (eeprom_buffer_size > 0) WDT_RESET_STOCK();
|
||||
while (eeprom_buffer_size > 0) wdt_reset();
|
||||
|
||||
s_sync_write = true;
|
||||
while (m_write_len && !s_write_err)
|
||||
|
||||
+5
-4
@@ -1189,6 +1189,11 @@ uint8_t barCoord(int16_t value, int16_t min, int16_t max)
|
||||
|
||||
void menuTelemetryFrsky(uint8_t event)
|
||||
{
|
||||
if (event == EVT_KEY_FIRST(KEY_EXIT)) {
|
||||
chainMenu(menuMainView);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (event) {
|
||||
case EVT_KEY_BREAK(KEY_UP):
|
||||
if (s_frsky_view-- == 0)
|
||||
@@ -1200,10 +1205,6 @@ void menuTelemetryFrsky(uint8_t event)
|
||||
s_frsky_view = 0;
|
||||
break;
|
||||
|
||||
case EVT_KEY_FIRST(KEY_EXIT):
|
||||
chainMenu(menuMainView);
|
||||
break;
|
||||
|
||||
case EVT_KEY_FIRST(KEY_MENU):
|
||||
resetTelemetry();
|
||||
break;
|
||||
|
||||
@@ -715,7 +715,7 @@ void menuGeneralSdManager(uint8_t event)
|
||||
void menuGeneralTrainer(uint8_t event)
|
||||
{
|
||||
uint8_t y;
|
||||
bool slave = SLAVE_MODE;
|
||||
bool slave = SLAVE_MODE();
|
||||
|
||||
MENU(STR_MENUTRAINER, menuTabDiag, e_Trainer, slave ? 1 : 7, {0, 2, 2, 2, 2, 0/*, 0*/});
|
||||
|
||||
|
||||
+61
-29
@@ -99,12 +99,31 @@ volatile BYTE Timer1, Timer2; /* 100Hz decrement timer */
|
||||
static
|
||||
BYTE CardType; /* Card type flags */
|
||||
|
||||
#if defined(SIMU)
|
||||
#define loop_mixer_until_bit_is_set loop_until_bit_is_set
|
||||
#else
|
||||
inline void checkMixer()
|
||||
{
|
||||
uint16_t t0 = getTmr16KHz();
|
||||
int16_t delta = t0 - nextMixerTime;
|
||||
if (delta < 0) return;
|
||||
|
||||
nextMixerTime = t0 + 20*16;
|
||||
doMixerCalculations();
|
||||
|
||||
t0 = getTmr16KHz() - t0;
|
||||
lastMixerDuration = t0;
|
||||
if (t0 > maxMixerDuration) maxMixerDuration = t0;
|
||||
}
|
||||
|
||||
#define loop_mixer_until_bit_is_set(sfr, bit) do { checkMixer(); wdt_reset(); } while (bit_is_clear(sfr, bit))
|
||||
#endif
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Transmit a byte to MMC via SPI (Platform dependent) */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
#define xmit_spi(dat) SPDR=(dat); loop_until_bit_is_set(SPSR,SPIF)
|
||||
#define xmit_spi(dat) SPDR=(dat); loop_mixer_until_bit_is_set(SPSR,SPIF)
|
||||
|
||||
|
||||
|
||||
@@ -116,12 +135,12 @@ static
|
||||
BYTE rcvr_spi (void)
|
||||
{
|
||||
SPDR = 0xFF;
|
||||
loop_until_bit_is_set(SPSR, SPIF);
|
||||
loop_mixer_until_bit_is_set(SPSR, SPIF);
|
||||
return SPDR;
|
||||
}
|
||||
|
||||
/* Alternative macro to receive data fast */
|
||||
#define rcvr_spi_m(dst) SPDR=0xFF; loop_until_bit_is_set(SPSR,SPIF); *(dst)=SPDR
|
||||
#define rcvr_spi_m(dst) SPDR=0xFF; loop_mixer_until_bit_is_set(SPSR,SPIF); *(dst)=SPDR
|
||||
|
||||
|
||||
|
||||
@@ -615,35 +634,48 @@ DRESULT disk_ioctl (
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* This function must be called in period of 10ms */
|
||||
|
||||
void sdPoll10mS (void)
|
||||
void sdPoll10ms()
|
||||
{
|
||||
BYTE s;
|
||||
|
||||
/*
|
||||
n = Timer1; // 100Hz decrement timer
|
||||
if (n) Timer1 = --n;
|
||||
n = Timer2;
|
||||
if (n) Timer2 = --n;
|
||||
*/
|
||||
if (Timer1) Timer1--;
|
||||
if (Timer2) Timer2--;
|
||||
BYTE s;
|
||||
|
||||
s = Stat;
|
||||
|
||||
/* G: Not implemented
|
||||
if (SOCKWP) // Write protected
|
||||
s |= STA_PROTECT;
|
||||
else // Write enabled
|
||||
s &= ~STA_PROTECT;
|
||||
if (SOCKINS) // Card inserted
|
||||
s &= ~STA_NODISK;
|
||||
else // Socket empty
|
||||
s |= (STA_NODISK | STA_NOINIT);
|
||||
*/
|
||||
s &= ~STA_NODISK;
|
||||
s &= ~STA_PROTECT;
|
||||
/*
|
||||
n = Timer1; // 100Hz decrement timer
|
||||
if (n) Timer1 = --n;
|
||||
n = Timer2;
|
||||
if (n) Timer2 = --n;
|
||||
*/
|
||||
if (Timer1) Timer1--;
|
||||
if (Timer2) Timer2--;
|
||||
|
||||
Stat = s;
|
||||
s = Stat;
|
||||
|
||||
/* G: Not implemented
|
||||
if (SOCKWP) // Write protected
|
||||
s |= STA_PROTECT;
|
||||
else // Write enabled
|
||||
s &= ~STA_PROTECT;
|
||||
if (SOCKINS) // Card inserted
|
||||
s &= ~STA_NODISK;
|
||||
else // Socket empty
|
||||
s |= (STA_NODISK | STA_NOINIT);
|
||||
*/
|
||||
s &= ~STA_NODISK;
|
||||
s &= ~STA_PROTECT;
|
||||
|
||||
Stat = s;
|
||||
}
|
||||
|
||||
#if !defined(SIMU)
|
||||
void sdMountPoll()
|
||||
{
|
||||
static uint8_t mountTimer;
|
||||
if (mountTimer-- == 0) {
|
||||
mountTimer = 100;
|
||||
if (g_FATFS_Obj.fs_type == 0) {
|
||||
f_mount(0, &g_FATFS_Obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
FATFS g_FATFS_Obj;
|
||||
|
||||
+1
-1
@@ -193,7 +193,7 @@ void menuTelemetryJeti(uint8_t event)
|
||||
case EVT_KEY_FIRST(KEY_EXIT):
|
||||
JETI_DisableRXD();
|
||||
chainMenu(menuMainView);
|
||||
break;
|
||||
return;
|
||||
}
|
||||
|
||||
for (uint8_t i = 0; i < 16; i++)
|
||||
|
||||
+2
-2
@@ -150,7 +150,7 @@ void menuMainView(uint8_t event)
|
||||
case EVT_KEY_STATISTICS:
|
||||
chainMenu(menuStatisticsView);
|
||||
killEvents(event);
|
||||
break;
|
||||
return;
|
||||
case EVT_KEY_TELEMETRY:
|
||||
#if defined(FRSKY)
|
||||
chainMenu(menuTelemetryFrsky);
|
||||
@@ -169,7 +169,7 @@ void menuMainView(uint8_t event)
|
||||
chainMenu(menuStatisticsDebug);
|
||||
#endif
|
||||
killEvents(event);
|
||||
break;
|
||||
return;
|
||||
case EVT_KEY_FIRST(KEY_EXIT):
|
||||
if (s_timerState[0]==TMR_BEEPING) {
|
||||
s_timerState[0] = TMR_STOPPED;
|
||||
|
||||
+1
-1
@@ -903,7 +903,7 @@ void menuTelemetryMavlink(uint8_t event) {
|
||||
case EVT_KEY_FIRST(KEY_EXIT):
|
||||
//MAVLINK_Quit();
|
||||
chainMenu(menuMainView);
|
||||
break;
|
||||
return;
|
||||
}
|
||||
|
||||
switch (MAVLINK_menu) {
|
||||
|
||||
+16
-16
@@ -394,18 +394,18 @@ void menuTelemetryNMEA1(uint8_t event)
|
||||
{
|
||||
case EVT_KEY_BREAK(KEY_LEFT):
|
||||
chainMenu(menuTelemetryNMEA4);
|
||||
break;
|
||||
return;
|
||||
case EVT_KEY_BREAK(KEY_RIGHT):
|
||||
chainMenu(menuTelemetryNMEA2);
|
||||
break;
|
||||
return;
|
||||
case EVT_KEY_LONG(KEY_UP):
|
||||
NMEA_DisableRXD();
|
||||
chainMenu(menuStatisticsView);
|
||||
break;
|
||||
return;
|
||||
case EVT_KEY_LONG(KEY_DOWN):
|
||||
NMEA_DisableRXD();
|
||||
chainMenu(menuMainView);
|
||||
break;
|
||||
return;
|
||||
case EVT_KEY_FIRST(KEY_MENU):
|
||||
if (show_timer == 0) {
|
||||
show_timer = 1;
|
||||
@@ -507,21 +507,21 @@ void menuTelemetryNMEA2(uint8_t event)
|
||||
ignore_break=0;
|
||||
break;}
|
||||
chainMenu(menuTelemetryNMEA1);
|
||||
break;
|
||||
return;
|
||||
case EVT_KEY_BREAK(KEY_RIGHT):
|
||||
if (ignore_break==1) {
|
||||
ignore_break=0;
|
||||
break;}
|
||||
chainMenu(menuTelemetryNMEA3);
|
||||
break;
|
||||
return;
|
||||
case EVT_KEY_LONG(KEY_UP):
|
||||
NMEA_DisableRXD();
|
||||
chainMenu(menuStatisticsView);
|
||||
break;
|
||||
return;
|
||||
case EVT_KEY_LONG(KEY_DOWN):
|
||||
NMEA_DisableRXD();
|
||||
chainMenu(menuMainView);
|
||||
break;
|
||||
return;
|
||||
|
||||
//Beep setting
|
||||
case EVT_KEY_LONG(KEY_LEFT):
|
||||
@@ -662,18 +662,18 @@ void menuTelemetryNMEA3(uint8_t event)
|
||||
{
|
||||
case EVT_KEY_BREAK(KEY_LEFT):
|
||||
chainMenu(menuTelemetryNMEA2);
|
||||
break;
|
||||
return;
|
||||
case EVT_KEY_BREAK(KEY_RIGHT):
|
||||
chainMenu(menuTelemetryNMEA4);
|
||||
break;
|
||||
return;
|
||||
case EVT_KEY_LONG(KEY_UP):
|
||||
NMEA_DisableRXD();
|
||||
chainMenu(menuStatisticsView);
|
||||
break;
|
||||
return;
|
||||
case EVT_KEY_LONG(KEY_DOWN):
|
||||
NMEA_DisableRXD();
|
||||
chainMenu(menuMainView);
|
||||
break;
|
||||
return;
|
||||
}
|
||||
initval (LONG_BUF(0), PACK_RMC, SOG);
|
||||
initval (LONG_BUF(1), PACK_RMC, COG);
|
||||
@@ -711,18 +711,18 @@ void menuTelemetryNMEA4(uint8_t event)
|
||||
{
|
||||
case EVT_KEY_BREAK(KEY_LEFT):
|
||||
chainMenu(menuTelemetryNMEA3);
|
||||
break;
|
||||
return;
|
||||
case EVT_KEY_BREAK(KEY_RIGHT):
|
||||
chainMenu(menuTelemetryNMEA1);
|
||||
break;
|
||||
return;
|
||||
case EVT_KEY_LONG(KEY_UP):
|
||||
NMEA_DisableRXD();
|
||||
chainMenu(menuStatisticsView);
|
||||
break;
|
||||
return;
|
||||
case EVT_KEY_LONG(KEY_DOWN):
|
||||
NMEA_DisableRXD();
|
||||
chainMenu(menuMainView);
|
||||
break;
|
||||
return;
|
||||
}
|
||||
// expecting LAT value in POS packet to be stored in the first buffer
|
||||
initval (LONG_BUF(0), PACK_GGA, LAT);
|
||||
|
||||
+99
-223
@@ -95,10 +95,9 @@ uint8_t g_tmr1Latency_min;
|
||||
|
||||
uint8_t unexpectedShutdown = 0;
|
||||
|
||||
uint16_t g_timeMainMax;
|
||||
#if defined(PCBGRUVIN9X)
|
||||
uint8_t lastMixerDuration;
|
||||
#endif
|
||||
/* mixer duration in 1/16ms */
|
||||
uint16_t maxMixerDuration;
|
||||
uint16_t lastMixerDuration;
|
||||
|
||||
#if defined(AUDIO) && !defined(PCBSKY9X)
|
||||
audioQueue audio;
|
||||
@@ -1259,7 +1258,7 @@ void checkSwitches()
|
||||
|
||||
checkBacklight();
|
||||
|
||||
WDT_RESET_STOCK();
|
||||
wdt_reset();
|
||||
|
||||
#ifdef SIMU
|
||||
if (!main_thread_running) return;
|
||||
@@ -1286,7 +1285,7 @@ void alert(const pm_char * t, const pm_char *s MESSAGE_SOUND_ARG)
|
||||
|
||||
checkBacklight();
|
||||
|
||||
WDT_RESET_STOCK();
|
||||
wdt_reset();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1324,19 +1323,19 @@ void message(const pm_char *title, const pm_char *t, const char *last MESSAGE_SO
|
||||
int8_t trimGvar[NUM_STICKS] = { -1, -1, -1, -1 };
|
||||
#endif
|
||||
|
||||
#if defined(PCBSTD)
|
||||
uint8_t checkTrim(uint8_t event)
|
||||
{
|
||||
int8_t k = (event & EVT_KEY_MASK) - TRM_BASE;
|
||||
int8_t s = g_model.trimInc;
|
||||
if (k>=0 && k<8 && !IS_KEY_BREAK(event)) {
|
||||
#else
|
||||
#if defined(PCBSKY9X)
|
||||
void checkTrims()
|
||||
{
|
||||
uint8_t event = getEvent(true);
|
||||
if (event && !IS_KEY_BREAK(event)) {
|
||||
int8_t k = (event & EVT_KEY_MASK) - TRM_BASE;
|
||||
int8_t s = g_model.trimInc;
|
||||
#else
|
||||
uint8_t checkTrim(uint8_t event)
|
||||
{
|
||||
int8_t k = (event & EVT_KEY_MASK) - TRM_BASE;
|
||||
int8_t s = g_model.trimInc;
|
||||
if (k>=0 && k<8 && !IS_KEY_BREAK(event)) {
|
||||
#endif
|
||||
// LH_DWN LH_UP LV_DWN LV_UP RV_DWN RV_UP RH_DWN RH_UP
|
||||
uint8_t idx = CONVERT_MODE(1+k/2) - 1;
|
||||
@@ -1430,11 +1429,11 @@ void checkTrims()
|
||||
else {
|
||||
AUDIO_TRIM(event, after);
|
||||
}
|
||||
#if defined(PCBSTD)
|
||||
#if !defined(PCBSKY9X)
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
#if defined(PCBSTD)
|
||||
#if !defined(PCBSKY9X)
|
||||
return event;
|
||||
#endif
|
||||
}
|
||||
@@ -1632,30 +1631,6 @@ void getADC_bandgap()
|
||||
uint8_t g_vbat100mV = 0;
|
||||
uint16_t g_LightOffCounter;
|
||||
|
||||
#if !defined(PCBSKY9X)
|
||||
FORCEINLINE bool checkSlaveMode()
|
||||
{
|
||||
// no power -> only phone jack = slave mode
|
||||
|
||||
#if defined(PCBGRUVIN9X)
|
||||
return SLAVE_MODE;
|
||||
#else
|
||||
static bool lastSlaveMode = false;
|
||||
static uint8_t checkDelay = 0;
|
||||
if (IS_AUDIO_BUSY()) {
|
||||
checkDelay = 20;
|
||||
}
|
||||
else if (checkDelay) {
|
||||
--checkDelay;
|
||||
}
|
||||
else {
|
||||
lastSlaveMode = SLAVE_MODE;
|
||||
}
|
||||
return lastSlaveMode;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
uint16_t s_timeCumTot;
|
||||
uint16_t s_timeCumThr; // THR in 1/16 sec
|
||||
uint16_t s_timeCum16ThrP; // THR% in 1/16 sec
|
||||
@@ -2363,7 +2338,7 @@ void perOut(uint8_t tick10ms)
|
||||
sDelay[i] = md->delayUp * 50;
|
||||
}
|
||||
if (sDelay[i] > 0) { // perform delay
|
||||
sDelay[i] -= tick10ms;
|
||||
sDelay[i] = max(0, sDelay[i]-tick10ms);
|
||||
if (!md->swtch) {
|
||||
v = -1024;
|
||||
}
|
||||
@@ -2387,7 +2362,7 @@ void perOut(uint8_t tick10ms)
|
||||
sDelay[i] = md->delayDown * 50;
|
||||
}
|
||||
if (sDelay[i] > 0) { // perform delay
|
||||
sDelay[i] -= tick10ms;
|
||||
sDelay[i] = max(0, sDelay[i]-tick10ms);
|
||||
if (!md->swtch) v = +1024;
|
||||
has_delay = true;
|
||||
}
|
||||
@@ -2510,9 +2485,24 @@ void perOut(uint8_t tick10ms)
|
||||
ACTIVE_MIXES_TYPE activeMixes;
|
||||
#endif
|
||||
int32_t sum_chans512[NUM_CHNOUT] = {0};
|
||||
inline void doMixerCalculations(tmr10ms_t tmr10ms, uint8_t tick10ms)
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
inline bool doMixerCalculations()
|
||||
#else
|
||||
inline void doMixerCalculations()
|
||||
#endif
|
||||
{
|
||||
#ifdef BOLD_FONT
|
||||
#if defined(PCBGRUVIN9X) && defined(DEBUG) && !defined(VOICE)
|
||||
PORTH |= 0x40; // PORTH:6 LOW->HIGH signals start of mixer interrupt
|
||||
#endif
|
||||
|
||||
static tmr10ms_t lastTMR;
|
||||
|
||||
tmr10ms_t tmr10ms = get_tmr10ms();
|
||||
uint8_t tick10ms = (tmr10ms >= lastTMR ? tmr10ms - lastTMR : 1);
|
||||
lastTMR = tmr10ms;
|
||||
|
||||
#if defined(BOLD_FONT)
|
||||
activeMixes = 0;
|
||||
#endif
|
||||
|
||||
@@ -2602,12 +2592,20 @@ inline void doMixerCalculations(tmr10ms_t tmr10ms, uint8_t tick10ms)
|
||||
sei();
|
||||
}
|
||||
|
||||
#if defined(PCBGRUVIN9X) && defined(DEBUG) && !defined(VOICE)
|
||||
PORTH &= ~0x40; // PORTH:6 HIGH->LOW signals end of mixer interrupt
|
||||
#endif
|
||||
|
||||
// Bandgap has had plenty of time to settle...
|
||||
#if !defined(PCBSKY9X)
|
||||
getADC_bandgap();
|
||||
#endif
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
if (!tick10ms) return false; //make sure the rest happen only every 10ms.
|
||||
#else
|
||||
if (!tick10ms) return; //make sure the rest happen only every 10ms.
|
||||
#endif
|
||||
|
||||
/* Throttle trace */
|
||||
int16_t val;
|
||||
@@ -2813,43 +2811,48 @@ inline void doMixerCalculations(tmr10ms_t tmr10ms, uint8_t tick10ms)
|
||||
setVolume(requiredSpeakerVolume);
|
||||
currentSpeakerVolume = requiredSpeakerVolume;
|
||||
}
|
||||
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
void perMain()
|
||||
{
|
||||
static tmr10ms_t lastTMR;
|
||||
tmr10ms_t tmr10ms = get_tmr10ms();
|
||||
uint8_t tick10ms = (tmr10ms >= lastTMR ? tmr10ms - lastTMR : 1);
|
||||
lastTMR = tmr10ms;
|
||||
#if defined(SIMU)
|
||||
doMixerCalculations();
|
||||
#elif !defined(PCBSKY9X)
|
||||
uint16_t t0 = getTmr16KHz();
|
||||
int16_t delta = t0 - nextMixerTime;
|
||||
if (delta < 0) return;
|
||||
|
||||
#if defined(PCBSTD) || defined(SIMU)
|
||||
doMixerCalculations(tmr10ms, tick10ms);
|
||||
nextMixerTime = t0 + 20*16;
|
||||
doMixerCalculations();
|
||||
|
||||
t0 = getTmr16KHz() - t0;
|
||||
lastMixerDuration = t0;
|
||||
if (t0 > maxMixerDuration) maxMixerDuration = t0;
|
||||
#endif
|
||||
|
||||
// TODO same code here + integrate the timer which could be common
|
||||
#if defined(PCBSKY9X)
|
||||
if (Tenms) {
|
||||
Tenms = 0 ;
|
||||
if (!Tenms) return;
|
||||
Tenms = 0 ;
|
||||
|
||||
if (Eeprom32_process_state != E32_IDLE)
|
||||
ee32_process();
|
||||
else if (TIME_TO_WRITE)
|
||||
eeCheck();
|
||||
|
||||
Current_accumulator += Current_analogue ;
|
||||
static uint32_t OneSecTimer;
|
||||
if (++OneSecTimer >= 100) {
|
||||
OneSecTimer -= 100 ;
|
||||
sessionTimer += 1;
|
||||
Current_used += Current_accumulator / 100 ; // milliAmpSeconds (but scaled)
|
||||
Current_accumulator = 0 ;
|
||||
}
|
||||
|
||||
#if defined(SDCARD) && !defined(SIMU)
|
||||
sdPoll10mS();
|
||||
#endif
|
||||
Current_accumulator += Current_analogue ;
|
||||
static uint32_t OneSecTimer;
|
||||
if (++OneSecTimer >= 100) {
|
||||
OneSecTimer -= 100 ;
|
||||
sessionTimer += 1;
|
||||
Current_used += Current_accumulator / 100 ; // milliAmpSeconds (but scaled)
|
||||
Current_accumulator = 0 ;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
if (Eeprom32_process_state != E32_IDLE)
|
||||
ee32_process();
|
||||
else if (TIME_TO_WRITE)
|
||||
eeCheck();
|
||||
#else
|
||||
if (!eeprom_buffer_size) {
|
||||
if (theFile.isWriting())
|
||||
@@ -2859,33 +2862,20 @@ void perMain()
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!tick10ms) return; //make sure the rest happen only every 10ms.
|
||||
|
||||
#if defined(SDCARD)
|
||||
#if defined(PCBGRUVIN9X)
|
||||
static uint8_t mountTimer;
|
||||
if (mountTimer-- == 0) {
|
||||
mountTimer = 100;
|
||||
if (g_FATFS_Obj.fs_type == 0) {
|
||||
f_mount(0, &g_FATFS_Obj);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
sdMountPoll();
|
||||
writeLogs();
|
||||
#endif
|
||||
|
||||
lcd_clear();
|
||||
|
||||
#if defined(PCBSKY9X) && defined(SIMU)
|
||||
checkTrims();
|
||||
#endif
|
||||
|
||||
#if defined(PCBSTD)
|
||||
#if defined(PCBSKY9X)
|
||||
uint8_t evt = getEvent(false);
|
||||
#else
|
||||
uint8_t evt = getEvent();
|
||||
evt = checkTrim(evt);
|
||||
#else
|
||||
uint8_t evt = getEvent(false);
|
||||
#endif
|
||||
|
||||
if (g_LightOffCounter) g_LightOffCounter--;
|
||||
@@ -2897,44 +2887,27 @@ void perMain()
|
||||
check_frsky();
|
||||
#endif
|
||||
|
||||
lcd_clear();
|
||||
const char *warn = s_warning;
|
||||
g_menuStack[g_menuStackPtr](warn ? 0 : evt);
|
||||
if (warn) displayWarning(evt);
|
||||
drawStatusLine();
|
||||
refreshDisplay();
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
if ( check_soft_power() == e_power_trainer ) { // On trainer power
|
||||
PIOC->PIO_PDR = PIO_PC22 ; // Disable bit C22 Assign to peripheral
|
||||
if (SLAVE_MODE()) {
|
||||
JACK_PPM_OUT();
|
||||
}
|
||||
else {
|
||||
PIOC->PIO_PER = PIO_PC22 ; // Enable bit C22 as input
|
||||
JACK_PPM_IN();
|
||||
}
|
||||
#elif defined(PCBGRUVIN9X)
|
||||
// PPM signal on phono-jack. In or out? ...
|
||||
if(checkSlaveMode()) {
|
||||
PORTG |= (1<<OUT_G_SIM_CTL); // 1=ppm out
|
||||
}
|
||||
else{
|
||||
PORTG &= ~(1<<OUT_G_SIM_CTL); // 0=ppm in
|
||||
}
|
||||
#elif defined(PCBSTD)
|
||||
// PPM signal on phono-jack. In or out? ...
|
||||
if(checkSlaveMode()) {
|
||||
PORTG &= ~(1<<OUT_G_SIM_CTL); // 0=ppm out
|
||||
}
|
||||
else{
|
||||
PORTG |= (1<<OUT_G_SIM_CTL); // 1=ppm-in
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
static uint8_t counter = 0;
|
||||
if (g_menuStack[g_menuStackPtr] == menuGeneralDiagAna) {
|
||||
g_vbat100mV = 0;
|
||||
counter = 0;
|
||||
}
|
||||
if (counter-- == 0) {
|
||||
counter = 10;
|
||||
#else
|
||||
if ((tmr10ms & 0x1f) == 2 /*every 10ms*32*/ || g_menuStack[g_menuStackPtr] == menuGeneralDiagAna) {
|
||||
#endif
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
int32_t instant_vbat = anaIn(7);
|
||||
@@ -2954,7 +2927,7 @@ void perMain()
|
||||
s_batCheck += 32;
|
||||
s_batSum += instant_vbat;
|
||||
|
||||
if (g_vbat100mV == 0 || g_menuStack[g_menuStackPtr] == menuGeneralDiagAna) {
|
||||
if (g_vbat100mV == 0) {
|
||||
g_vbat100mV = instant_vbat;
|
||||
s_batSum = 0;
|
||||
s_batCheck = 0;
|
||||
@@ -2983,11 +2956,7 @@ uint8_t ppmInState = 0; //0=unsync 1..8= wait for value i-1
|
||||
#if !defined(SIMU) && !defined(PCBSKY9X)
|
||||
|
||||
volatile uint8_t g_tmr16KHz; //continuous timer 16ms (16MHz/1024/256) -- 8-bit counter overflow
|
||||
#if defined (PCBGRUVIN9X)
|
||||
ISR(TIMER2_OVF_vect)
|
||||
#else
|
||||
ISR(TIMER0_OVF_vect) // TODO now NOBLOCK in er9x
|
||||
#endif
|
||||
ISR(TIMER_16KHZ_VECT, ISR_NOBLOCK)
|
||||
{
|
||||
g_tmr16KHz++; // gruvin: Not 16KHz. Overflows occur at 61.035Hz (1/256th of 15.625KHz)
|
||||
// to give *16.384ms* intervals. Kind of matters for accuracy elsewhere. ;)
|
||||
@@ -2999,80 +2968,15 @@ uint16_t getTmr16KHz()
|
||||
{
|
||||
while(1){
|
||||
uint8_t hb = g_tmr16KHz;
|
||||
#if defined (PCBGRUVIN9X)
|
||||
uint8_t lb = TCNT2;
|
||||
#else
|
||||
uint8_t lb = TCNT0;
|
||||
#endif
|
||||
uint8_t lb = COUNTER_16KHZ;
|
||||
if(hb-g_tmr16KHz==0) return (hb<<8)|lb;
|
||||
}
|
||||
}
|
||||
|
||||
#if defined (PCBGRUVIN9X)
|
||||
|
||||
/**** SCHEDULED MIXER INTERRUPT ****/
|
||||
|
||||
// On G9X board, we use TIMER5 to schedule mixer execution, to achieve
|
||||
// minimal system latency between reading sticks and outputting data.
|
||||
ISR(TIMER5_COMPA_vect, ISR_NOBLOCK)
|
||||
{
|
||||
#if defined(DEBUG) && !defined(VOICE)
|
||||
PORTH |= 0x40; // PORTH:6 LOW->HIGH signals start of mixer interrupt
|
||||
#endif
|
||||
|
||||
cli();
|
||||
TIMSK5 &= ~(1<<OCIE5A); //stop reentrance
|
||||
OCR5A = 0x7d * 40; /* 20ms */
|
||||
sei();
|
||||
|
||||
uint16_t t0 = getTmr16KHz();
|
||||
|
||||
static tmr10ms_t lastTMR;
|
||||
tmr10ms_t tmr10ms = get_tmr10ms();
|
||||
uint8_t tick10ms = (tmr10ms >= lastTMR ? tmr10ms - lastTMR : 1);
|
||||
lastTMR = tmr10ms;
|
||||
|
||||
if (s_current_protocol < PROTO_NONE) {
|
||||
doMixerCalculations(tmr10ms, tick10ms);
|
||||
checkTrims();
|
||||
}
|
||||
|
||||
heartbeat |= HEART_TIMER10ms;
|
||||
|
||||
if (heartbeat == HEART_TIMER_PULSES+HEART_TIMER10ms) {
|
||||
wdt_reset();
|
||||
heartbeat = 0;
|
||||
}
|
||||
|
||||
t0 = getTmr16KHz() - t0;
|
||||
lastMixerDuration = t0 / 8;
|
||||
if (t0 > g_timeMainMax) g_timeMainMax = t0 ;
|
||||
|
||||
cli();
|
||||
TIMSK5 |= (1<<OCIE5A); //stop reentrance
|
||||
sei();
|
||||
|
||||
#if defined(DEBUG) && !defined(VOICE)
|
||||
PORTH &= ~0x40; // PORTH:6 HIGH->LOW signals end of mixer interrupt
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined (PCBGRUVIN9X)
|
||||
ISR(TIMER2_COMPA_vect, ISR_NOBLOCK) //10ms timer
|
||||
#else
|
||||
// Clocks every 64 uS
|
||||
ISR(TIMER0_COMP_vect, ISR_NOBLOCK) //10ms timer
|
||||
#endif
|
||||
ISR(TIMER_10MS_VECT, ISR_NOBLOCK) // 10ms timer
|
||||
{
|
||||
cli();
|
||||
|
||||
#if defined(PCBGRUVIN9X)
|
||||
TIMSK2 &= ~(1<<OCIE2A); // stop reentrance
|
||||
#else
|
||||
TIMSK &= ~(1<<OCIE0); // stop reentrance
|
||||
#endif
|
||||
|
||||
PAUSE_10MS_INTERRUPT();
|
||||
sei();
|
||||
|
||||
#if defined(PCBGRUVIN9X)
|
||||
@@ -3112,32 +3016,24 @@ ISR(TIMER0_COMP_vect, ISR_NOBLOCK) //10ms timer
|
||||
|
||||
AUDIO_HEARTBEAT();
|
||||
|
||||
#ifdef HAPTIC
|
||||
#if defined(HAPTIC)
|
||||
HAPTIC_HEARTBEAT();
|
||||
#endif
|
||||
|
||||
per10ms();
|
||||
|
||||
#if defined(PCBGRUVIN9X) && defined(SDCARD)
|
||||
sdPoll10mS();
|
||||
#if defined(SDCARD)
|
||||
sdPoll10ms();
|
||||
#endif
|
||||
|
||||
#if !defined(PCBGRUVIN9X)
|
||||
heartbeat |= HEART_TIMER10ms; // TODO check heartbeat everywhere!
|
||||
#endif
|
||||
heartbeat |= HEART_TIMER10ms;
|
||||
|
||||
#if defined(PCBSTD) && (defined(AUDIO) || defined(VOICE))
|
||||
} // end 10ms event
|
||||
#endif
|
||||
|
||||
cli();
|
||||
|
||||
#if defined(PCBGRUVIN9X)
|
||||
TIMSK2 |= (1<<OCIE2A);
|
||||
#else
|
||||
TIMSK |= (1<<OCIE0);
|
||||
#endif
|
||||
|
||||
RESUME_10MS_INTERRUPT();
|
||||
sei();
|
||||
}
|
||||
|
||||
@@ -3153,11 +3049,7 @@ ISR(TIMER3_CAPT_vect) // G: High frequency noise can cause stack overflo with IS
|
||||
uint16_t capture=ICR3;
|
||||
|
||||
// Prevent rentrance for this IRQ only
|
||||
#if defined (PCBGRUVIN9X)
|
||||
TIMSK3 &= ~(1<<ICIE3);
|
||||
#else
|
||||
ETIMSK &= ~(1<<TICIE3);
|
||||
#endif
|
||||
PAUSE_PPMIN_INTERRUPT();
|
||||
sei(); // enable other interrupts
|
||||
|
||||
uint16_t val = (capture - lastCapt) / 2;
|
||||
@@ -3183,11 +3075,7 @@ ISR(TIMER3_CAPT_vect) // G: High frequency noise can cause stack overflo with IS
|
||||
lastCapt = capture;
|
||||
|
||||
cli(); // disable other interrupts for stack pops before this function's RETI
|
||||
#if defined (PCBGRUVIN9X)
|
||||
TIMSK3 |= (1<<ICIE3);
|
||||
#else
|
||||
ETIMSK |= (1<<TICIE3);
|
||||
#endif
|
||||
RESUME_PPMIN_INTERRUPT();
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3534,19 +3422,14 @@ void mixerTask(void * pdata)
|
||||
if (!s_pulses_paused) {
|
||||
uint16_t t0 = getTmr2MHz();
|
||||
|
||||
static tmr10ms_t lastTMR;
|
||||
tmr10ms_t tmr10ms = get_tmr10ms();
|
||||
uint8_t tick10ms = (tmr10ms >= lastTMR ? tmr10ms - lastTMR : 1);
|
||||
lastTMR = tmr10ms;
|
||||
|
||||
if (s_current_protocol < PROTO_NONE) {
|
||||
CoEnterMutexSection(mixerMutex);
|
||||
doMixerCalculations(tmr10ms, tick10ms);
|
||||
bool tick10ms = doMixerCalculations();
|
||||
CoLeaveMutexSection(mixerMutex);
|
||||
if (tick10ms) checkTrims();
|
||||
}
|
||||
|
||||
heartbeat |= HEART_TIMER10ms;
|
||||
heartbeat |= HEART_TIMER10ms; // TODO not here but in 10ms interrupt!
|
||||
|
||||
if (heartbeat == HEART_TIMER_PULSES+HEART_TIMER10ms) {
|
||||
wdt_reset();
|
||||
@@ -3554,7 +3437,7 @@ void mixerTask(void * pdata)
|
||||
}
|
||||
|
||||
t0 = getTmr2MHz() - t0;
|
||||
if (t0 > g_timeMainMax) g_timeMainMax = t0 ;
|
||||
if (t0 > maxMixerDuration) maxMixerDuration = t0 ;
|
||||
}
|
||||
|
||||
CoTickDelay(1); // 2ms for now
|
||||
@@ -3733,20 +3616,13 @@ int main(void)
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if defined(PCBSTD)
|
||||
uint16_t t0 = getTmr16KHz();
|
||||
#endif
|
||||
|
||||
perMain();
|
||||
|
||||
#if defined(PCBSTD)
|
||||
#if !defined(PCBSKY9X)
|
||||
if(heartbeat == HEART_TIMER_PULSES+HEART_TIMER10ms) {
|
||||
wdt_reset();
|
||||
heartbeat = 0;
|
||||
}
|
||||
|
||||
t0 = getTmr16KHz() - t0;
|
||||
if (t0 > g_timeMainMax) g_timeMainMax = t0;
|
||||
#endif
|
||||
}
|
||||
#endif // PCBSKY9X
|
||||
|
||||
+7
-33
@@ -138,12 +138,6 @@
|
||||
#define IF_GVARS(x)
|
||||
#endif
|
||||
|
||||
#if defined(PCBSTD)
|
||||
#define WDT_RESET_STOCK() wdt_reset()
|
||||
#else
|
||||
#define WDT_RESET_STOCK()
|
||||
#endif
|
||||
|
||||
/*
|
||||
#define HELI_VARIANT 0x0004
|
||||
#define VOICE_VARIANT 0x0008
|
||||
@@ -157,6 +151,8 @@
|
||||
#include "board_sky9x.h"
|
||||
#elif defined(PCBGRUVIN9X)
|
||||
#include "board_gruvin9x.h"
|
||||
#else
|
||||
#include "board_stock.h"
|
||||
#endif
|
||||
|
||||
#if defined(SIMU)
|
||||
@@ -400,12 +396,6 @@ extern uint8_t s_bind_allowed;
|
||||
|
||||
#endif // defined (PCBGRUVIN9X)
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#define SLAVE_MODE (check_soft_power() == e_power_trainer)
|
||||
#else
|
||||
#define SLAVE_MODE (PING & (1<<INP_G_RF_POW))
|
||||
#endif
|
||||
|
||||
extern const pm_uint8_t bchout_ar[];
|
||||
extern const pm_uint8_t modn12x3[];
|
||||
|
||||
@@ -644,10 +634,10 @@ extern char idx2char(int8_t idx);
|
||||
void clearKeyEvents();
|
||||
void pauseEvents(uint8_t enuk);
|
||||
void killEvents(uint8_t enuk);
|
||||
#if defined(PCBSTD)
|
||||
uint8_t getEvent();
|
||||
#else
|
||||
#if defined(PCBSKY9X)
|
||||
uint8_t getEvent(bool trim);
|
||||
#else
|
||||
uint8_t getEvent();
|
||||
#endif
|
||||
void putEvent(uint8_t evt);
|
||||
|
||||
@@ -787,10 +777,8 @@ void resetAll();
|
||||
extern uint8_t unexpectedShutdown;
|
||||
extern uint8_t g_tmr1Latency_max;
|
||||
extern uint8_t g_tmr1Latency_min;
|
||||
extern uint16_t g_timeMainMax;
|
||||
#if defined(PCBGRUVIN9X)
|
||||
extern uint8_t lastMixerDuration;
|
||||
#endif
|
||||
extern uint16_t maxMixerDuration;
|
||||
extern uint16_t lastMixerDuration;
|
||||
|
||||
#if defined(THRTRACE)
|
||||
#define MAXTRACE 120
|
||||
@@ -930,20 +918,6 @@ inline void resumeMixerCalculations()
|
||||
{
|
||||
CoLeaveMutexSection(mixerMutex);
|
||||
}
|
||||
#elif defined(PCBGRUVIN9X)
|
||||
inline void pauseMixerCalculations()
|
||||
{
|
||||
cli();
|
||||
TIMSK5 &= ~(1<<OCIE5A);
|
||||
sei();
|
||||
}
|
||||
|
||||
inline void resumeMixerCalculations()
|
||||
{
|
||||
cli();
|
||||
TIMSK5 |= (1<<OCIE5A);
|
||||
sei();
|
||||
}
|
||||
#else
|
||||
#define pauseMixerCalculations()
|
||||
#define resumeMixerCalculations()
|
||||
|
||||
+22
-38
@@ -147,23 +147,13 @@ ISR(TIMER1_COMPA_vect) //2MHz pulse generation (BLOCKING ISR)
|
||||
|
||||
pulses2MHzRPtr += sizeof(uint16_t); // non PPM protocols use uint8_t pulse buffer
|
||||
if (*((uint16_t*)pulses2MHzRPtr) == 0) {
|
||||
|
||||
#if defined(PCBGRUVIN9X)
|
||||
TIMSK1 &= ~(1<<OCIE1A); // stop reentrance (disable Timer1 interrupt)
|
||||
#else
|
||||
TIMSK &= ~(1<<OCIE1A); // stop reentrance (disable Timer1 interrupt)
|
||||
#endif
|
||||
|
||||
PAUSE_PULSES_INTERRUPT();
|
||||
setupPulses(); // does not sei() for setupPulsesPPM
|
||||
|
||||
// if setupPulses changed protocol to one that doesn't use COMPA then don't re-enable.
|
||||
if (!IS_PXX_PROTOCOL(s_current_protocol) && !IS_DSM2_PROTOCOL(s_current_protocol)) {
|
||||
// cli is not needed because for PPM protocols interrupts are not enabled when entering here
|
||||
#if defined(PCBGRUVIN9X)
|
||||
TIMSK1 |= (1<<OCIE1A); // re-enable Timer1 interrupt
|
||||
#else
|
||||
TIMSK |= (1<<OCIE1A); // re-enable Timer1 interrupt
|
||||
#endif
|
||||
RESUME_PULSES_INTERRUPT();
|
||||
sei();
|
||||
}
|
||||
}
|
||||
@@ -495,23 +485,21 @@ void sendByteDsm2(uint8_t b) //max 10changes 0 10 10 10 10 1
|
||||
{
|
||||
bool lev = 0;
|
||||
uint8_t len = BITLEN_DSM2; //max val: 9*16 < 256
|
||||
for( uint8_t i=0; i<=8; i++){ //8Bits + Stop=1
|
||||
for (uint8_t i=0; i<=8; i++) { //8Bits + Stop=1
|
||||
bool nlev = b & 1; //lsb first
|
||||
if(lev == nlev){
|
||||
len += BITLEN_DSM2;
|
||||
}else{
|
||||
#if defined (PCBGRUVIN9X)
|
||||
// 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.
|
||||
if (nlev)
|
||||
_send_1(len-5);// -1);
|
||||
else
|
||||
_send_1(len+3);
|
||||
if (lev == nlev){
|
||||
len += BITLEN_DSM2;
|
||||
}
|
||||
else {
|
||||
#if defined(PCBGRUVIN9X)
|
||||
// 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);
|
||||
#else
|
||||
_send_1(len -1);
|
||||
_send_1(len -1);
|
||||
#endif
|
||||
len = BITLEN_DSM2;
|
||||
lev = nlev;
|
||||
len = BITLEN_DSM2;
|
||||
lev = nlev;
|
||||
}
|
||||
b = (b>>1) | 0x80; //shift in stop bit
|
||||
}
|
||||
@@ -894,6 +882,8 @@ void setupPulses()
|
||||
|
||||
#ifdef PXX
|
||||
case PROTO_PXX:
|
||||
// schedule next Mixer calculations
|
||||
SCHEDULE_MIXER(20*16-lastMixerDuration-2*16/*1ms*/);
|
||||
sei();
|
||||
setupPulsesPXX();
|
||||
break;
|
||||
@@ -901,11 +891,8 @@ void setupPulses()
|
||||
|
||||
#ifdef DSM2
|
||||
case PROTO_DSM2:
|
||||
#if defined(PCBGRUVIN9X)
|
||||
// schedule next Mixer interrupt
|
||||
OCR5A = (uint16_t)0x7d * (44-lastMixerDuration-2/*1ms*/);
|
||||
TCNT5 = 0;
|
||||
#endif
|
||||
// schedule next Mixer calculations
|
||||
SCHEDULE_MIXER(22*16-lastMixerDuration-2*16/*1ms*/);
|
||||
sei();
|
||||
setupPulsesDsm2(); // Different versions for DSM2=SERIAL vs. DSM2=PPM
|
||||
#if defined(PCBGRUVIN9X) && defined(DSM2_PPM)
|
||||
@@ -917,7 +904,7 @@ void setupPulses()
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef IRPROTOS
|
||||
#if defined(IRPROTOS)
|
||||
case PROTO_PICZ:
|
||||
setupPulsesPiccoZ(g_model.ppmNCH);
|
||||
// TODO BSS stbyLevel = 0; //start with 1
|
||||
@@ -925,14 +912,11 @@ void setupPulses()
|
||||
#endif
|
||||
|
||||
default: // standard PPM protocol
|
||||
#ifndef SIMU
|
||||
#if !defined(SIMU)
|
||||
g_ppmPulsePolarity = g_model.pulsePol;
|
||||
#endif
|
||||
#if defined(PCBGRUVIN9X)
|
||||
// schedule next Mixer interrupt
|
||||
OCR5A = (uint16_t)0x7d * (45+g_model.ppmFrameLength-lastMixerDuration-2/*1ms*/);
|
||||
TCNT5 = 0;
|
||||
#endif
|
||||
// schedule next Mixer calculations
|
||||
SCHEDULE_MIXER(45*8+g_model.ppmFrameLength*8-lastMixerDuration-2*16/*1ms*/);
|
||||
// no sei here
|
||||
setupPulsesPPM(PROTO_PPM);
|
||||
// if PPM16, PPM16 pulses are set up automatically within the interrupts
|
||||
|
||||
+5
-2
@@ -69,8 +69,11 @@ inline const pm_char *SDCARD_ERROR(FRESULT result)
|
||||
return STR_SDCARD_ERROR;
|
||||
}
|
||||
|
||||
// TODO move the ARM function definition here (when cpp)
|
||||
extern void sdPoll10mS();
|
||||
#if defined(SIMU)
|
||||
#define sdMountPoll()
|
||||
#else
|
||||
extern void sdMountPoll();
|
||||
#endif
|
||||
|
||||
#if defined(PCBSKY9X) && !(defined(SIMU))
|
||||
extern "C" {
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* MMCv3/SDv1/SDv2 (in SPI mode) control module (C)ChaN, 2010 */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Only rcvr_spi(), xmit_spi(), sdPoll10mS() and some macros */
|
||||
/* Only rcvr_spi(), xmit_spi(), sdPoll10ms() and some macros */
|
||||
/* are platform dependent. */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
@@ -956,7 +956,7 @@ FATFS g_FATFS_Obj = { 0 };
|
||||
|
||||
extern void retrieveAvailableAudioFiles();
|
||||
|
||||
void sdPoll10mS()
|
||||
void sdMountPoll()
|
||||
{
|
||||
if (!Card_initialized)
|
||||
return;
|
||||
|
||||
@@ -40,11 +40,11 @@ void menuStatisticsView(uint8_t event)
|
||||
{
|
||||
case EVT_KEY_FIRST(KEY_UP):
|
||||
chainMenu(menuStatisticsDebug);
|
||||
break;
|
||||
return;
|
||||
case EVT_KEY_FIRST(KEY_DOWN):
|
||||
case EVT_KEY_FIRST(KEY_EXIT):
|
||||
chainMenu(menuMainView);
|
||||
break;
|
||||
return;
|
||||
}
|
||||
|
||||
lcd_puts( 1*FW, FH*1, STR_TM1TM2);
|
||||
@@ -105,16 +105,16 @@ void menuStatisticsDebug(uint8_t event)
|
||||
g_tmr1Latency_min = 0xff;
|
||||
g_tmr1Latency_max = 0;
|
||||
#endif
|
||||
g_timeMainMax = 0;
|
||||
maxMixerDuration = 0;
|
||||
AUDIO_KEYPAD_UP();
|
||||
break;
|
||||
case EVT_KEY_FIRST(KEY_DOWN):
|
||||
chainMenu(menuStatisticsView);
|
||||
break;
|
||||
return;
|
||||
case EVT_KEY_FIRST(KEY_UP):
|
||||
case EVT_KEY_FIRST(KEY_EXIT):
|
||||
chainMenu(menuMainView);
|
||||
break;
|
||||
return;
|
||||
}
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
@@ -143,8 +143,8 @@ void menuStatisticsDebug(uint8_t event)
|
||||
putsTelemetryValue(20*FW+2, 4*FH, Coproc_maxtemp, UNIT_DEGREES, 0);
|
||||
}
|
||||
|
||||
lcd_putsLeft(5*FH, STR_TMAINMAXMS);
|
||||
lcd_outdezAtt(MENU_DEBUG_COL_OFS, 5*FH, (g_timeMainMax)/20, PREC2);
|
||||
lcd_putsLeft(5*FH, STR_TMIXMAXMS);
|
||||
lcd_outdezAtt(MENU_DEBUG_COL_OFS, 5*FH, (maxMixerDuration)/20, PREC2);
|
||||
|
||||
lcd_putsLeft(6*FH, STR_FREESTACKMINB);
|
||||
lcd_outdezAtt(13*FW, 6*FH, stack_free(0), UNSIGN);
|
||||
@@ -159,8 +159,8 @@ void menuStatisticsDebug(uint8_t event)
|
||||
lcd_outdez8(MENU_DEBUG_COL_OFS , 2*FH, g_tmr1Latency_min/2 );
|
||||
lcd_putsLeft(3*FH, STR_TMR1JITTERUS);
|
||||
lcd_outdez8(MENU_DEBUG_COL_OFS , 3*FH, (g_tmr1Latency_max - g_tmr1Latency_min) /2 );
|
||||
lcd_putsLeft(4*FH, STR_TMAINMAXMS);
|
||||
lcd_outdezAtt(MENU_DEBUG_COL_OFS, 4*FH, (g_timeMainMax*100)/16, PREC2);
|
||||
lcd_putsLeft(4*FH, STR_TMIXMAXMS);
|
||||
lcd_outdezAtt(MENU_DEBUG_COL_OFS, 4*FH, (maxMixerDuration*100)/16, PREC2);
|
||||
lcd_putsLeft(5*FH, STR_FREESTACKMINB);
|
||||
lcd_outdezAtt(14*FW, 5*FH, stack_free(), UNSIGN) ;
|
||||
#endif
|
||||
|
||||
@@ -214,7 +214,7 @@ const pm_char STR_TOT[] PROGMEM = TR_TOT;
|
||||
const pm_char STR_TMR1LATMAXUS[] PROGMEM = TR_TMR1LATMAXUS;
|
||||
const pm_char STR_TMR1LATMINUS[] PROGMEM = TR_TMR1LATMINUS;
|
||||
const pm_char STR_TMR1JITTERUS[] PROGMEM = TR_TMR1JITTERUS;
|
||||
const pm_char STR_TMAINMAXMS[] PROGMEM = TR_TMAINMAXMS;
|
||||
const pm_char STR_TMIXMAXMS[] PROGMEM = TR_TMIXMAXMS;
|
||||
#ifdef DEBUG
|
||||
const pm_char STR_T10MSUS[] PROGMEM = TR_T10MSUS;
|
||||
#endif
|
||||
|
||||
+1
-1
@@ -323,7 +323,7 @@ extern const pm_char STR_TOT[];
|
||||
extern const pm_char STR_TMR1LATMAXUS[];
|
||||
extern const pm_char STR_TMR1LATMINUS[];
|
||||
extern const pm_char STR_TMR1JITTERUS[];
|
||||
extern const pm_char STR_TMAINMAXMS[];
|
||||
extern const pm_char STR_TMIXMAXMS[];
|
||||
extern const pm_char STR_T10MSUS[];
|
||||
extern const pm_char STR_FREESTACKMINB[];
|
||||
extern const pm_char STR_MENUTORESET[];
|
||||
|
||||
@@ -342,9 +342,9 @@
|
||||
#define TR_TMR1LATMINUS "Tmr1Lat min\006us"
|
||||
#define TR_TMR1JITTERUS "Tmr1 Jitter\006us"
|
||||
#if defined(PCBSKY9X)
|
||||
#define TR_TMAINMAXMS "Tmain max\010ms"
|
||||
#define TR_TMIXMAXMS "Tmix max\012ms"
|
||||
#else
|
||||
#define TR_TMAINMAXMS "Tmain max\012ms"
|
||||
#define TR_TMIXMAXMS "Tmix max\014ms"
|
||||
#endif
|
||||
#define TR_T10MSUS "T10ms\016us"
|
||||
#define TR_FREESTACKMINB "Free Stack\010b"
|
||||
|
||||
@@ -343,9 +343,9 @@
|
||||
#define TR_TMR1LATMINUS "Tmr1Lat min\006us"
|
||||
#define TR_TMR1JITTERUS "Tmr1 Jitter\006us"
|
||||
#if defined(PCBSKY9X)
|
||||
#define TR_TMAINMAXMS "Tmain max\010ms"
|
||||
#define TR_TMIXMAXMS "Tmix max\012ms"
|
||||
#else
|
||||
#define TR_TMAINMAXMS "Tmain max\012ms"
|
||||
#define TR_TMIXMAXMS "Tmix max\014ms"
|
||||
#endif
|
||||
#define TR_T10MSUS "T10ms\016us"
|
||||
#define TR_FREESTACKMINB "Free Stack\010b"
|
||||
|
||||
@@ -343,9 +343,9 @@
|
||||
#define TR_TMR1LATMINUS "Tmr1Lat min\006us"
|
||||
#define TR_TMR1JITTERUS "Tmr1 Jitter\006us"
|
||||
#if defined(PCBSKY9X)
|
||||
#define TR_TMAINMAXMS "Tmain max\010ms"
|
||||
#define TR_TMIXMAXMS "Tmix max\012ms"
|
||||
#else
|
||||
#define TR_TMAINMAXMS "Tmain max\012ms"
|
||||
#define TR_TMIXMAXMS "Tmix max\014ms"
|
||||
#endif
|
||||
#define TR_T10MSUS "T10ms\016us"
|
||||
#define TR_FREESTACKMINB "Free Stack\010b"
|
||||
|
||||
@@ -337,9 +337,9 @@
|
||||
#define TR_TMR1LATMINUS "Tmr1Lat min\006us"
|
||||
#define TR_TMR1JITTERUS "Tmr1 Jitter\006us"
|
||||
#if defined(PCBSKY9X)
|
||||
#define TR_TMAINMAXMS "Tmain max\010ms"
|
||||
#define TR_TMIXMAXMS "Tmix max\012ms"
|
||||
#else
|
||||
#define TR_TMAINMAXMS "Tmain max\012ms"
|
||||
#define TR_TMIXMAXMS "Tmix max\014ms"
|
||||
#endif
|
||||
#define TR_T10MSUS "T10ms\016us"
|
||||
#define TR_FREESTACKMINB "Pila libre\010b"
|
||||
|
||||
@@ -343,9 +343,9 @@
|
||||
#define TR_TMR1LATMINUS "Tmr1Lat min\006us"
|
||||
#define TR_TMR1JITTERUS "Tmr1 Jitter\006us"
|
||||
#if defined(PCBSKY9X)
|
||||
#define TR_TMAINMAXMS "Tmain max\010ms"
|
||||
#define TR_TMIXMAXMS "Tmix max\012ms"
|
||||
#else
|
||||
#define TR_TMAINMAXMS "Tmain max\012ms"
|
||||
#define TR_TMIXMAXMS "Tmix max\014ms"
|
||||
#endif
|
||||
#define TR_T10MSUS "T10ms\016us"
|
||||
#define TR_FREESTACKMINB "Free Stack\010b"
|
||||
|
||||
@@ -341,9 +341,9 @@
|
||||
#define TR_TMR1LATMINUS "Tmr1Lat min\006us"
|
||||
#define TR_TMR1JITTERUS "Tmr1 Jitter\006us"
|
||||
#if defined(PCBSKY9X)
|
||||
#define TR_TMAINMAXMS "Tmain max\004ms"
|
||||
#define TR_TMIXMAXMS "Tmix max\012ms"
|
||||
#else
|
||||
#define TR_TMAINMAXMS "Tmain max\005ms"
|
||||
#define TR_TMIXMAXMS "Tmix max\014ms"
|
||||
#endif
|
||||
#define TR_T10MSUS "T10ms\007us"
|
||||
#define TR_FREESTACKMINB "Free Stack\004b"
|
||||
|
||||
@@ -343,9 +343,9 @@
|
||||
#define TR_TMR1LATMINUS "Tmr1Lat min\006us"
|
||||
#define TR_TMR1JITTERUS "Tmr1 Jitter\006us"
|
||||
#if defined(PCBSKY9X)
|
||||
#define TR_TMAINMAXMS "Tmain max\010ms"
|
||||
#define TR_TMIXMAXMS "Tmix max\012ms"
|
||||
#else
|
||||
#define TR_TMAINMAXMS "Tmain max\012ms"
|
||||
#define TR_TMIXMAXMS "Tmix max\014ms"
|
||||
#endif
|
||||
#define TR_T10MSUS "T10ms\016us"
|
||||
#define TR_FREESTACKMINB "Pilha Livre\010b"
|
||||
|
||||
@@ -346,9 +346,9 @@
|
||||
#define TR_TMR1LATMINUS "Tmr1Lat min\006us"
|
||||
#define TR_TMR1JITTERUS "Tmr1 Jitter\006us"
|
||||
#if defined(PCBSKY9X)
|
||||
#define TR_TMAINMAXMS "Tmain max\010ms"
|
||||
#define TR_TMIXMAXMS "Tmix max\012ms"
|
||||
#else
|
||||
#define TR_TMAINMAXMS "Tmain max\012ms"
|
||||
#define TR_TMIXMAXMS "Tmix max\014ms"
|
||||
#endif
|
||||
#define TR_T10MSUS "T10ms\016us"
|
||||
#define TR_FREESTACKMINB "Free Stack\010b"
|
||||
|
||||
Reference in New Issue
Block a user