mirror of
https://github.com/opentx/opentx.git
synced 2025-07-26 01:35:21 +03:00
Issue 83 fixed
Problem with wav files played twice when loading a model Different EEPROM format for Expos/DRs on ARM Issue 102 fixed
This commit is contained in:
parent
223c0645e8
commit
bf2055e1ad
9 changed files with 107 additions and 67 deletions
|
@ -40,6 +40,7 @@
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
extern void init_SDcard();
|
extern void init_SDcard();
|
||||||
|
extern void sdInit();
|
||||||
extern void sdPoll10mS();
|
extern void sdPoll10mS();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -466,7 +466,7 @@ bool ee32LoadGeneral()
|
||||||
|
|
||||||
void eeLoadModel(uint8_t id)
|
void eeLoadModel(uint8_t id)
|
||||||
{
|
{
|
||||||
uint16_t size ;
|
uint16_t size;
|
||||||
|
|
||||||
if (id<MAX_MODELS) {
|
if (id<MAX_MODELS) {
|
||||||
|
|
||||||
|
@ -474,6 +474,8 @@ void eeLoadModel(uint8_t id)
|
||||||
pausePulses();
|
pausePulses();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pauseMixerCalculations();
|
||||||
|
|
||||||
size = File_system[id+1].size ;
|
size = File_system[id+1].size ;
|
||||||
|
|
||||||
memset(&g_model, 0, sizeof(g_model));
|
memset(&g_model, 0, sizeof(g_model));
|
||||||
|
@ -508,6 +510,9 @@ void eeLoadModel(uint8_t id)
|
||||||
|
|
||||||
resetProto();
|
resetProto();
|
||||||
resetAll();
|
resetAll();
|
||||||
|
|
||||||
|
resumeMixerCalculations();
|
||||||
|
// TODO pulses should be started after mixer calculations ...
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -874,6 +874,60 @@ void sdPoll10mS()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void sdInit()
|
||||||
|
{
|
||||||
|
Sd_rca = 0;
|
||||||
|
sdErrorCount = 0;
|
||||||
|
|
||||||
|
Card_state = SD_ST_EMPTY;
|
||||||
|
if (!CardIsConnected())
|
||||||
|
return;
|
||||||
|
|
||||||
|
Card_state = SD_ST_INIT1;
|
||||||
|
sdCmd0();
|
||||||
|
|
||||||
|
Card_state = SD_ST_INIT2;
|
||||||
|
sdCmd8(1);
|
||||||
|
|
||||||
|
Card_state = SD_ST_IDLE;
|
||||||
|
sdMemInit(1, &Cmd_A41_resp);
|
||||||
|
|
||||||
|
Card_state = SD_ST_READY;
|
||||||
|
uint8_t retry;
|
||||||
|
for (retry=0; retry<10; retry++) {
|
||||||
|
if (!sdCmd2()) break;
|
||||||
|
CoTickDelay(1); // 2ms
|
||||||
|
}
|
||||||
|
|
||||||
|
if (retry == 10)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Card_state = SD_ST_IDENT;
|
||||||
|
|
||||||
|
for (retry=0; retry<10; retry++) {
|
||||||
|
if (!sdCmd3()) break;
|
||||||
|
CoTickDelay(1); // 2ms
|
||||||
|
}
|
||||||
|
|
||||||
|
if (retry == 10)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Card_state = SD_ST_STBY;
|
||||||
|
sdCmd9();
|
||||||
|
sdCmd7(); // Select Card
|
||||||
|
|
||||||
|
Card_state = SD_ST_TRAN;
|
||||||
|
sdAcmd51();
|
||||||
|
sdAcmd6(); // Set bus width to 4 bits, and speed to 9 MHz
|
||||||
|
|
||||||
|
// Should check the card can do this ****
|
||||||
|
Card_state = SD_ST_DATA;
|
||||||
|
|
||||||
|
f_mount(0, &g_FATFS_Obj);
|
||||||
|
retrieveAvailableAudioFiles();
|
||||||
|
Card_state = SD_ST_MOUNTED;
|
||||||
|
}
|
||||||
|
|
||||||
// Checks for card ready for read/write
|
// Checks for card ready for read/write
|
||||||
// returns 1 for YES, 0 for NO
|
// returns 1 for YES, 0 for NO
|
||||||
uint32_t sd_card_ready( void )
|
uint32_t sd_card_ready( void )
|
||||||
|
|
|
@ -1328,25 +1328,6 @@ bool reachExpoMixCountLimit(uint8_t expo)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(PCBV4)
|
|
||||||
inline void pauseMixerCalculations()
|
|
||||||
{
|
|
||||||
cli();
|
|
||||||
TIMSK5 &= ~(1<<OCIE5A);
|
|
||||||
sei();
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void resumeMixerCalculations()
|
|
||||||
{
|
|
||||||
cli();
|
|
||||||
TIMSK5 |= (1<<OCIE5A);
|
|
||||||
sei();
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
#define pauseMixerCalculations()
|
|
||||||
#define resumeMixerCalculations()
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void deleteExpoMix(uint8_t expo, uint8_t idx)
|
void deleteExpoMix(uint8_t expo, uint8_t idx)
|
||||||
{
|
{
|
||||||
pauseMixerCalculations();
|
pauseMixerCalculations();
|
||||||
|
@ -1553,12 +1534,6 @@ void menuProcExpoOne(uint8_t event)
|
||||||
lcd_outdezAtt(EXPO_ONE_2ND_COLUMN+3*FW, y, ed->weight, attr|INFLIGHT((int8_t&)ed->weight));
|
lcd_outdezAtt(EXPO_ONE_2ND_COLUMN+3*FW, y, ed->weight, attr|INFLIGHT((int8_t&)ed->weight));
|
||||||
if (attr) CHECK_INFLIGHT_INCDEC_MODELVAR(event, (int8_t&)ed->weight, 0, 100, 0, STR_DRWEIGHT);
|
if (attr) CHECK_INFLIGHT_INCDEC_MODELVAR(event, (int8_t&)ed->weight, 0, 100, 0, STR_DRWEIGHT);
|
||||||
break;
|
break;
|
||||||
#if defined(PCBARM)
|
|
||||||
case EXPO_FIELD_EXPO:
|
|
||||||
lcd_outdezAtt(EXPO_ONE_2ND_COLUMN+3*FW, y, ed->expo, attr|INFLIGHT(ed->expo));
|
|
||||||
if (attr) CHECK_INFLIGHT_INCDEC_MODELVAR(event, ed->expo, -100, 100, 0, STR_DREXPO);
|
|
||||||
break;
|
|
||||||
#else
|
|
||||||
case EXPO_FIELD_EXPO:
|
case EXPO_FIELD_EXPO:
|
||||||
if (ed->curveMode==MODE_EXPO || ed->curveParam==0) {
|
if (ed->curveMode==MODE_EXPO || ed->curveParam==0) {
|
||||||
ed->curveMode = MODE_EXPO;
|
ed->curveMode = MODE_EXPO;
|
||||||
|
@ -1569,20 +1544,7 @@ void menuProcExpoOne(uint8_t event)
|
||||||
lcd_putsAtt(EXPO_ONE_2ND_COLUMN, y, STR_NA, attr);
|
lcd_putsAtt(EXPO_ONE_2ND_COLUMN, y, STR_NA, attr);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#endif
|
|
||||||
#if defined(CURVES)
|
#if defined(CURVES)
|
||||||
#if defined(PCBARM)
|
|
||||||
case EXPO_FIELD_CURVE:
|
|
||||||
putsCurve(EXPO_ONE_2ND_COLUMN, y, ed->curve, attr);
|
|
||||||
if (attr) {
|
|
||||||
CHECK_INCDEC_MODELVAR(event, ed->curve, 0, CURVE_BASE+MAX_CURVES-1);
|
|
||||||
if (ed->curve>=CURVE_BASE && event==EVT_KEY_FIRST(KEY_MENU)) {
|
|
||||||
s_curveChan = ed->curve - CURVE_BASE;
|
|
||||||
pushMenu(menuProcCurveOne);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
#else
|
|
||||||
case EXPO_FIELD_CURVE:
|
case EXPO_FIELD_CURVE:
|
||||||
if (ed->curveMode!=MODE_EXPO || ed->curveParam==0) {
|
if (ed->curveMode!=MODE_EXPO || ed->curveParam==0) {
|
||||||
putsCurve(EXPO_ONE_2ND_COLUMN, y, ed->curveParam, attr);
|
putsCurve(EXPO_ONE_2ND_COLUMN, y, ed->curveParam, attr);
|
||||||
|
@ -1600,7 +1562,6 @@ void menuProcExpoOne(uint8_t event)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
#if defined(FLIGHT_PHASES)
|
#if defined(FLIGHT_PHASES)
|
||||||
case EXPO_FIELD_FLIGHT_PHASE:
|
case EXPO_FIELD_FLIGHT_PHASE:
|
||||||
ed->phases = editPhases(EXPO_ONE_2ND_COLUMN-2*FW, y, event, ed->phases, attr);
|
ed->phases = editPhases(EXPO_ONE_2ND_COLUMN-2*FW, y, event, ed->phases, attr);
|
||||||
|
@ -2000,17 +1961,10 @@ void menuProcExpoMix(uint8_t expo, uint8_t _event_)
|
||||||
CHECK_INCDEC_MODELVAR(_event, ed->weight, 0, 100);
|
CHECK_INCDEC_MODELVAR(_event, ed->weight, 0, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(PCBARM)
|
|
||||||
if (ed->curve)
|
|
||||||
putsCurve(EXPO_LINE_EXPO_POS-3*FW, y, ed->curve);
|
|
||||||
else if (ed->expo)
|
|
||||||
lcd_outdezAtt(EXPO_LINE_EXPO_POS, y, ed->expo, 0);
|
|
||||||
#else
|
|
||||||
if (ed->curveMode == MODE_CURVE)
|
if (ed->curveMode == MODE_CURVE)
|
||||||
putsCurve(EXPO_LINE_EXPO_POS-3*FW, y, ed->curveParam);
|
putsCurve(EXPO_LINE_EXPO_POS-3*FW, y, ed->curveParam);
|
||||||
else
|
else
|
||||||
lcd_outdezAtt(EXPO_LINE_EXPO_POS, y, ed->curveParam, 0);
|
lcd_outdezAtt(EXPO_LINE_EXPO_POS, y, ed->curveParam, 0);
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(PCBARM)
|
#if defined(PCBARM)
|
||||||
if (ed->name[0]) {
|
if (ed->name[0]) {
|
||||||
|
|
|
@ -172,12 +172,12 @@ PACK(typedef struct t_EEGeneral {
|
||||||
PACK(typedef struct t_ExpoData {
|
PACK(typedef struct t_ExpoData {
|
||||||
uint8_t mode; // 0=end, 1=pos, 2=neg, 3=both
|
uint8_t mode; // 0=end, 1=pos, 2=neg, 3=both
|
||||||
uint8_t chn;
|
uint8_t chn;
|
||||||
int8_t curve; // 0=no curve, 1-6=std curves, 7-22=CV1-CV16
|
|
||||||
int8_t swtch;
|
int8_t swtch;
|
||||||
uint16_t phases;
|
uint16_t phases;
|
||||||
int8_t weight;
|
int8_t weight;
|
||||||
|
uint8_t curveMode;
|
||||||
char name[6];
|
char name[6];
|
||||||
int8_t expo;
|
int8_t curveParam;
|
||||||
}) ExpoData;
|
}) ExpoData;
|
||||||
#else
|
#else
|
||||||
PACK(typedef struct t_ExpoData {
|
PACK(typedef struct t_ExpoData {
|
||||||
|
|
|
@ -32,10 +32,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined(PCBARM) && !defined(SIMU)
|
#if defined(PCBARM) && !defined(SIMU)
|
||||||
extern "C" {
|
|
||||||
#include <CoOS.h>
|
|
||||||
}
|
|
||||||
|
|
||||||
#define MIXER_STACK_SIZE 500
|
#define MIXER_STACK_SIZE 500
|
||||||
#define MENUS_STACK_SIZE 1000
|
#define MENUS_STACK_SIZE 1000
|
||||||
#define AUDIO_STACK_SIZE 500
|
#define AUDIO_STACK_SIZE 500
|
||||||
|
@ -54,6 +50,7 @@ OS_FlagID audioFlag;
|
||||||
|
|
||||||
OS_MutexID sdMutex;
|
OS_MutexID sdMutex;
|
||||||
OS_MutexID audioMutex;
|
OS_MutexID audioMutex;
|
||||||
|
OS_MutexID mixerMutex;
|
||||||
|
|
||||||
/*OS_TID btTask;
|
/*OS_TID btTask;
|
||||||
OS_STK btStack[BT_STACK_SIZE];
|
OS_STK btStack[BT_STACK_SIZE];
|
||||||
|
@ -433,19 +430,12 @@ void applyExpos(int16_t *anas)
|
||||||
int16_t v = anas2[ed.chn];
|
int16_t v = anas2[ed.chn];
|
||||||
if((v<0 && ed.mode&1) || (v>=0 && ed.mode&2)) {
|
if((v<0 && ed.mode&1) || (v>=0 && ed.mode&2)) {
|
||||||
cur_chn = ed.chn;
|
cur_chn = ed.chn;
|
||||||
#if defined(PCBARM)
|
|
||||||
if (ed.curve)
|
|
||||||
v = applyCurve(v, ed.curve);
|
|
||||||
if (ed.expo)
|
|
||||||
v = expo(v, ed.expo);
|
|
||||||
#else
|
|
||||||
if (ed.curveParam) {
|
if (ed.curveParam) {
|
||||||
if (ed.curveMode == MODE_CURVE)
|
if (ed.curveMode == MODE_CURVE)
|
||||||
v = applyCurve(v, ed.curveParam);
|
v = applyCurve(v, ed.curveParam);
|
||||||
else
|
else
|
||||||
v = expo(v, ed.curveParam);
|
v = expo(v, ed.curveParam);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
v = ((int32_t)v * ed.weight) / 100;
|
v = ((int32_t)v * ed.weight) / 100;
|
||||||
anas[cur_chn] = v;
|
anas[cur_chn] = v;
|
||||||
}
|
}
|
||||||
|
@ -998,8 +988,6 @@ void doSplash()
|
||||||
lcdSetRefVolt(contrast);
|
lcdSetRefVolt(contrast);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
clearKeyEvents();
|
|
||||||
|
|
||||||
#ifndef SIMU
|
#ifndef SIMU
|
||||||
for(uint8_t i=0; i<32; i++)
|
for(uint8_t i=0; i<32; i++)
|
||||||
getADC_filt(); // init ADC array
|
getADC_filt(); // init ADC array
|
||||||
|
@ -3116,8 +3104,6 @@ inline void open9xInit(OPEN9X_INIT_ARGS)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
clearKeyEvents(); //make sure no keys are down before proceeding
|
|
||||||
|
|
||||||
lcdSetRefVolt(g_eeGeneral.contrast);
|
lcdSetRefVolt(g_eeGeneral.contrast);
|
||||||
backlightOn();
|
backlightOn();
|
||||||
|
|
||||||
|
@ -3149,7 +3135,9 @@ void mixerTask(void * pdata)
|
||||||
|
|
||||||
if (s_current_protocol < PROTO_NONE) {
|
if (s_current_protocol < PROTO_NONE) {
|
||||||
if (tick10ms) checkTrims();
|
if (tick10ms) checkTrims();
|
||||||
|
CoEnterMutexSection(mixerMutex);
|
||||||
doMixerCalculations(tmr10ms, tick10ms);
|
doMixerCalculations(tmr10ms, tick10ms);
|
||||||
|
CoLeaveMutexSection(mixerMutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
heartbeat |= HEART_TIMER10ms;
|
heartbeat |= HEART_TIMER10ms;
|
||||||
|
@ -3717,13 +3705,15 @@ int main(void)
|
||||||
init_rotary_sw();
|
init_rotary_sw();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef PCBARM
|
#if !defined(PCBARM)
|
||||||
open9xInit(mcusr);
|
open9xInit(mcusr);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PCBARM)
|
#if defined(PCBARM)
|
||||||
CoInitOS();
|
CoInitOS();
|
||||||
|
|
||||||
|
sdInit();
|
||||||
|
|
||||||
// btFlag = CoCreateFlag(TRUE, FALSE); // Auto-reset, start FALSE
|
// btFlag = CoCreateFlag(TRUE, FALSE); // Auto-reset, start FALSE
|
||||||
// btTimer = CoCreateTmr(TMR_TYPE_PERIODIC, 1000/(1000/CFG_SYSTICK_FREQ), 1000/(1000/CFG_SYSTICK_FREQ), btTimerHandle);
|
// btTimer = CoCreateTmr(TMR_TYPE_PERIODIC, 1000/(1000/CFG_SYSTICK_FREQ), 1000/(1000/CFG_SYSTICK_FREQ), btTimerHandle);
|
||||||
|
|
||||||
|
@ -3737,6 +3727,7 @@ int main(void)
|
||||||
|
|
||||||
sdMutex = CoCreateMutex();
|
sdMutex = CoCreateMutex();
|
||||||
audioMutex = CoCreateMutex();
|
audioMutex = CoCreateMutex();
|
||||||
|
mixerMutex = CoCreateMutex();
|
||||||
|
|
||||||
CoStartOS();
|
CoStartOS();
|
||||||
#else
|
#else
|
||||||
|
|
36
src/open9x.h
36
src/open9x.h
|
@ -729,6 +729,42 @@ template<class t> FORCEINLINE t limit(t mi, t x, t ma) { return min(max(mi,x),ma
|
||||||
uint16_t isqrt32(uint32_t n);
|
uint16_t isqrt32(uint32_t n);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(PCBARM)
|
||||||
|
#if !defined(SIMU)
|
||||||
|
extern "C" {
|
||||||
|
#include <CoOS.h>
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern OS_MutexID mixerMutex;
|
||||||
|
inline void pauseMixerCalculations()
|
||||||
|
{
|
||||||
|
CoEnterMutexSection(mixerMutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void resumeMixerCalculations()
|
||||||
|
{
|
||||||
|
CoLeaveMutexSection(mixerMutex);
|
||||||
|
}
|
||||||
|
#elif defined(PCBV4)
|
||||||
|
inline void pauseMixerCalculations()
|
||||||
|
{
|
||||||
|
cli();
|
||||||
|
TIMSK5 &= ~(1<<OCIE5A);
|
||||||
|
sei();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void resumeMixerCalculations()
|
||||||
|
{
|
||||||
|
cli();
|
||||||
|
TIMSK5 |= (1<<OCIE5A);
|
||||||
|
sei();
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
#define pauseMixerCalculations()
|
||||||
|
#define resumeMixerCalculations()
|
||||||
|
#endif
|
||||||
|
|
||||||
/// Markiert einen EEPROM-Bereich als dirty. der Bereich wird dann in
|
/// Markiert einen EEPROM-Bereich als dirty. der Bereich wird dann in
|
||||||
/// eeCheck ins EEPROM zurueckgeschrieben.
|
/// eeCheck ins EEPROM zurueckgeschrieben.
|
||||||
void eeWriteBlockCmp(const void *i_pointer_ram, uint16_t i_pointer_eeprom, size_t size);
|
void eeWriteBlockCmp(const void *i_pointer_ram, uint16_t i_pointer_eeprom, size_t size);
|
||||||
|
|
|
@ -68,8 +68,6 @@ inline const pm_char *SDCARD_ERROR(FRESULT result)
|
||||||
return STR_SDCARD_ERROR;
|
return STR_SDCARD_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern void sdPoll10mS();
|
|
||||||
|
|
||||||
#if defined(PCBARM) && !(defined(SIMU))
|
#if defined(PCBARM) && !(defined(SIMU))
|
||||||
extern "C" {
|
extern "C" {
|
||||||
extern uint32_t sd_card_ready();
|
extern uint32_t sd_card_ready();
|
||||||
|
|
|
@ -295,6 +295,7 @@ void eeprom_read_block (void *pointer_ram,
|
||||||
#define wdt_reset() sleep(1/*ms*/)
|
#define wdt_reset() sleep(1/*ms*/)
|
||||||
#define board_init()
|
#define board_init()
|
||||||
|
|
||||||
|
#define OS_MutexID int
|
||||||
#define CoSetFlag(...)
|
#define CoSetFlag(...)
|
||||||
#define CoClearFlag(...)
|
#define CoClearFlag(...)
|
||||||
#define CoSetTmrCnt(...)
|
#define CoSetTmrCnt(...)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue