mirror of
https://github.com/opentx/opentx.git
synced 2025-07-24 00:35:18 +03:00
Move ppm related options into own struct
This allows to have the ppm related options in a union with a other module protocol specific options for the multi module.
This commit is contained in:
parent
9762656ad0
commit
c788ad6add
9 changed files with 53 additions and 45 deletions
|
@ -689,10 +689,12 @@ PACK(struct ModuleData {
|
|||
uint8_t failsafeMode:7;
|
||||
uint8_t invertedSerial:1; // telemetry serial inverted from standard
|
||||
int16_t failsafeChannels[NUM_CHNOUT];
|
||||
int8_t ppmDelay:6;
|
||||
uint8_t ppmPulsePol:1;
|
||||
uint8_t ppmOutputType:1; // false = open drain, true = push pull
|
||||
int8_t ppmFrameLength;
|
||||
struct {
|
||||
int8_t delay:6;
|
||||
uint8_t pulsePol:1;
|
||||
uint8_t outputType:1; // false = open drain, true = push pull
|
||||
int8_t frameLength;
|
||||
} ppm;
|
||||
});
|
||||
|
||||
/*
|
||||
|
|
|
@ -562,21 +562,21 @@ void menuModelSetup(uint8_t event)
|
|||
if (IS_MODULE_PPM(moduleIdx)) {
|
||||
lcd_putsLeft(y, STR_PPMFRAME);
|
||||
lcdDrawText(MODEL_SETUP_2ND_COLUMN+3*FW, y, STR_MS);
|
||||
lcdDrawNumber(MODEL_SETUP_2ND_COLUMN, y, (int16_t)moduleData.ppmFrameLength*5 + 225, (menuHorizontalPosition<=0 ? attr : 0) | PREC1|LEFT);
|
||||
lcdDrawNumber(MODEL_SETUP_2ND_COLUMN, y, (int16_t)moduleData.ppm.frameLength*5 + 225, (menuHorizontalPosition<=0 ? attr : 0) | PREC1|LEFT);
|
||||
lcdDrawChar(MODEL_SETUP_2ND_COLUMN+8*FW+2, y, 'u');
|
||||
lcdDrawNumber(MODEL_SETUP_2ND_COLUMN+8*FW+2, y, (moduleData.ppmDelay*50)+300, (CURSOR_ON_LINE() || menuHorizontalPosition==1) ? attr : 0);
|
||||
lcdDrawChar(MODEL_SETUP_2ND_COLUMN+10*FW, y, moduleData.ppmPulsePol ? '+' : '-', (CURSOR_ON_LINE() || menuHorizontalPosition==2) ? attr : 0);
|
||||
lcdDrawNumber(MODEL_SETUP_2ND_COLUMN+8*FW+2, y, (moduleData.ppm.delay*50)+300, (CURSOR_ON_LINE() || menuHorizontalPosition==1) ? attr : 0);
|
||||
lcdDrawChar(MODEL_SETUP_2ND_COLUMN+10*FW, y, moduleData.ppm.pulsePol ? '+' : '-', (CURSOR_ON_LINE() || menuHorizontalPosition==2) ? attr : 0);
|
||||
|
||||
if (attr && (editMode>0 || p1valdiff)) {
|
||||
switch (menuHorizontalPosition) {
|
||||
case 0:
|
||||
CHECK_INCDEC_MODELVAR(event, moduleData.ppmFrameLength, -20, 35);
|
||||
CHECK_INCDEC_MODELVAR(event, moduleData.ppm.frameLength, -20, 35);
|
||||
break;
|
||||
case 1:
|
||||
CHECK_INCDEC_MODELVAR(event, moduleData.ppmDelay, -4, 10);
|
||||
CHECK_INCDEC_MODELVAR(event, moduleData.ppm.delay, -4, 10);
|
||||
break;
|
||||
case 2:
|
||||
CHECK_INCDEC_MODELVAR_ZERO(event, moduleData.ppmPulsePol, 1);
|
||||
CHECK_INCDEC_MODELVAR_ZERO(event, moduleData.ppm.pulsePol, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -611,20 +611,20 @@ bool menuModelSetup(evt_t event)
|
|||
ModuleData & moduleData = g_model.moduleData[moduleIdx];
|
||||
if (IS_MODULE_PPM(moduleIdx)) {
|
||||
lcdDrawText(MENUS_MARGIN_LEFT, y, STR_PPMFRAME);
|
||||
lcdDrawNumber(MODEL_SETUP_2ND_COLUMN, y, (int16_t)moduleData.ppmFrameLength*5 + 225, (menuHorizontalPosition<=0 ? attr : 0) | PREC1|LEFT, 0, NULL, STR_MS);
|
||||
lcdDrawNumber(MODEL_SETUP_2ND_COLUMN+90, y, (moduleData.ppmDelay*50)+300, (CURSOR_ON_LINE() || menuHorizontalPosition==1) ? attr|RIGHT : RIGHT, 0, NULL, "us");
|
||||
lcdDrawText(MODEL_SETUP_2ND_COLUMN+120, y, moduleData.ppmPulsePol ? "+" : "-", (CURSOR_ON_LINE() || menuHorizontalPosition==2) ? attr : 0);
|
||||
lcdDrawNumber(MODEL_SETUP_2ND_COLUMN, y, (int16_t)moduleData.ppm.frameLength*5 + 225, (menuHorizontalPosition<=0 ? attr : 0) | PREC1|LEFT, 0, NULL, STR_MS);
|
||||
lcdDrawNumber(MODEL_SETUP_2ND_COLUMN+90, y, (moduleData.ppm.delay*50)+300, (CURSOR_ON_LINE() || menuHorizontalPosition==1) ? attr|RIGHT : RIGHT, 0, NULL, "us");
|
||||
lcdDrawText(MODEL_SETUP_2ND_COLUMN+120, y, moduleData.ppm.pulsePol ? "+" : "-", (CURSOR_ON_LINE() || menuHorizontalPosition==2) ? attr : 0);
|
||||
|
||||
if (attr && s_editMode>0) {
|
||||
switch (menuHorizontalPosition) {
|
||||
case 0:
|
||||
CHECK_INCDEC_MODELVAR(event, moduleData.ppmFrameLength, -20, 35);
|
||||
CHECK_INCDEC_MODELVAR(event, moduleData.ppm.frameLength, -20, 35);
|
||||
break;
|
||||
case 1:
|
||||
CHECK_INCDEC_MODELVAR(event, moduleData.ppmDelay, -4, 10);
|
||||
CHECK_INCDEC_MODELVAR(event, moduleData.ppm.delay, -4, 10);
|
||||
break;
|
||||
case 2:
|
||||
CHECK_INCDEC_MODELVAR_ZERO(event, moduleData.ppmPulsePol, 1);
|
||||
CHECK_INCDEC_MODELVAR_ZERO(event, moduleData.ppm.pulsePol, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -737,21 +737,21 @@ void menuModelSetup(uint8_t event)
|
|||
if (IS_MODULE_PPM(moduleIdx)) {
|
||||
lcd_putsLeft(y, STR_PPMFRAME);
|
||||
lcdDrawText(MODEL_SETUP_2ND_COLUMN+3*FW, y, STR_MS);
|
||||
lcdDrawNumber(MODEL_SETUP_2ND_COLUMN, y, (int16_t)moduleData.ppmFrameLength*5 + 225, (menuHorizontalPosition<=0 ? attr : 0) | PREC1|LEFT);
|
||||
lcdDrawNumber(MODEL_SETUP_2ND_COLUMN, y, (int16_t)moduleData.ppm.frameLength*5 + 225, (menuHorizontalPosition<=0 ? attr : 0) | PREC1|LEFT);
|
||||
lcdDrawChar(MODEL_SETUP_2ND_COLUMN+8*FW+2, y, 'u');
|
||||
lcdDrawNumber(MODEL_SETUP_2ND_COLUMN+8*FW+2, y, (moduleData.ppmDelay*50)+300, (CURSOR_ON_LINE() || menuHorizontalPosition==1) ? attr : 0);
|
||||
lcdDrawChar(MODEL_SETUP_2ND_COLUMN+10*FW, y, moduleData.ppmPulsePol ? '+' : '-', (CURSOR_ON_LINE() || menuHorizontalPosition==2) ? attr : 0);
|
||||
lcdDrawNumber(MODEL_SETUP_2ND_COLUMN+8*FW+2, y, (moduleData.ppm.delay*50)+300, (CURSOR_ON_LINE() || menuHorizontalPosition==1) ? attr : 0);
|
||||
lcdDrawChar(MODEL_SETUP_2ND_COLUMN+10*FW, y, moduleData.ppm.pulsePol ? '+' : '-', (CURSOR_ON_LINE() || menuHorizontalPosition==2) ? attr : 0);
|
||||
|
||||
if (attr && s_editMode>0) {
|
||||
switch (menuHorizontalPosition) {
|
||||
case 0:
|
||||
CHECK_INCDEC_MODELVAR(event, moduleData.ppmFrameLength, -20, 35);
|
||||
CHECK_INCDEC_MODELVAR(event, moduleData.ppm.frameLength, -20, 35);
|
||||
break;
|
||||
case 1:
|
||||
CHECK_INCDEC_MODELVAR(event, moduleData.ppmDelay, -4, 10);
|
||||
CHECK_INCDEC_MODELVAR(event, moduleData.ppm.delay, -4, 10);
|
||||
break;
|
||||
case 2:
|
||||
CHECK_INCDEC_MODELVAR_ZERO(event, moduleData.ppmPulsePol, 1);
|
||||
CHECK_INCDEC_MODELVAR_ZERO(event, moduleData.ppm.pulsePol, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@
|
|||
#define GVAR_VALUE(gv, fm) g_model.flightModeData[fm].gvars[gv]
|
||||
#endif
|
||||
|
||||
#define SET_DEFAULT_PPM_FRAME_LENGTH(idx) g_model.moduleData[idx].ppmFrameLength = 4 * max((int8_t)0, g_model.moduleData[idx].channelsCount)
|
||||
#define SET_DEFAULT_PPM_FRAME_LENGTH(idx) g_model.moduleData[idx].ppm.frameLength = 4 * max((int8_t)0, g_model.moduleData[idx].channelsCount)
|
||||
|
||||
#if defined(PCBTARANIS) || defined(PCBHORUS)
|
||||
#define IS_TRAINER_EXTERNAL_MODULE() (g_model.trainerMode == TRAINER_MODE_MASTER_SBUS_EXTERNAL_MODULE || g_model.trainerMode == TRAINER_MODE_MASTER_CPPM_EXTERNAL_MODULE)
|
||||
|
|
|
@ -35,8 +35,8 @@ void setupPulsesPPM(unsigned int port) // Don't enable interru
|
|||
// TODO move register stuff to driver
|
||||
register Pwm *pwmptr = PWM;
|
||||
uint32_t pwmCh = (port == EXTERNAL_MODULE ? 3 : 1);
|
||||
pwmptr->PWM_CH_NUM[pwmCh].PWM_CDTYUPD = (g_model.moduleData[port].ppmDelay * 50 + 300) * 2; //Stoplen *2
|
||||
if (g_model.moduleData[port].ppmPulsePol)
|
||||
pwmptr->PWM_CH_NUM[pwmCh].PWM_CDTYUPD = (g_model.moduleData[port].ppm.delay * 50 + 300) * 2; //Stoplen *2
|
||||
if (g_model.moduleData[port].ppm.pulsePol)
|
||||
pwmptr->PWM_CH_NUM[pwmCh].PWM_CMR &= ~0x00000200 ; // CPOL
|
||||
else
|
||||
pwmptr->PWM_CH_NUM[pwmCh].PWM_CMR |= 0x00000200 ; // CPOL
|
||||
|
@ -48,7 +48,7 @@ void setupPulsesPPM(unsigned int port) // Don't enable interru
|
|||
ppmPulsesData->ptr = ptr;
|
||||
|
||||
int32_t rest = 22500u * 2;
|
||||
rest += (int32_t(g_model.moduleData[port].ppmFrameLength)) * 1000;
|
||||
rest += (int32_t(g_model.moduleData[port].ppm.frameLength)) * 1000;
|
||||
for (uint32_t i=firstCh; i<lastCh; i++) {
|
||||
int16_t v = limit((int16_t)-PPM_range, channelOutputs[i], (int16_t)PPM_range) + 2*PPM_CH_CENTER(i);
|
||||
rest -= v;
|
||||
|
@ -61,19 +61,19 @@ void setupPulsesPPM(unsigned int port) // Don't enable interru
|
|||
|
||||
#if !defined(PCBSKY9X)
|
||||
rest -= 1000;
|
||||
uint32_t ppmDelay = (g_model.moduleData[port].ppmDelay * 50 + 300) * 2;
|
||||
uint32_t ppmDelay = (g_model.moduleData[port].ppm.delay * 50 + 300) * 2;
|
||||
// set idle time, ppm delay and ppm polarity
|
||||
if (port == TRAINER_MODULE) {
|
||||
set_trainer_ppm_parameters(rest, ppmDelay, !g_model.moduleData[TRAINER_MODULE].ppmPulsePol); // ppmPulsePol: 0 - positive, 1 - negative
|
||||
set_trainer_ppm_parameters(rest, ppmDelay, !g_model.moduleData[TRAINER_MODULE].ppm.pulsePol); // ppmPulsePol: 0 - positive, 1 - negative
|
||||
}
|
||||
else if (port == EXTERNAL_MODULE) {
|
||||
set_external_ppm_parameters(rest, ppmDelay, !g_model.moduleData[EXTERNAL_MODULE].ppmPulsePol);
|
||||
set_external_ppm_parameters(rest, ppmDelay, !g_model.moduleData[EXTERNAL_MODULE].ppm.pulsePol);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(TARANIS_INTERNAL_PPM)
|
||||
else if (port == INTERNAL_MODULE) {
|
||||
set_internal_ppm_parameters(rest, ppmDelay, !g_model.moduleData[INTERNAL_MODULE].ppmPulsePol);
|
||||
set_internal_ppm_parameters(rest, ppmDelay, !g_model.moduleData[INTERNAL_MODULE].ppm.pulsePol);
|
||||
}
|
||||
#endif // #if defined(TARANIS_INTERNAL_PPM)
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
//This file was auto-generated by generate_datacopy.py script on Fri Mar 25 14:17:31 2016. Do not edit this file!
|
||||
//This file was auto-generated by generate_datacopy.py script on Fri Mar 25 14:26:09 2016. Do not edit this file!
|
||||
|
||||
|
||||
|
||||
|
@ -194,10 +194,7 @@ void copyModuleData(A * dest, B * src)
|
|||
dest->failsafeMode = src->failsafeMode;
|
||||
dest->invertedSerial = src->invertedSerial;
|
||||
memcpy(dest->failsafeChannels, src->failsafeChannels, sizeof(dest->failsafeChannels));
|
||||
dest->ppmDelay = src->ppmDelay;
|
||||
dest->ppmPulsePol = src->ppmPulsePol;
|
||||
dest->ppmOutputType = src->ppmOutputType;
|
||||
dest->ppmFrameLength = src->ppmFrameLength;
|
||||
copyModuleData_ppm(&dest->ppm, &src->ppm);
|
||||
}
|
||||
|
||||
template <class A, class B>
|
||||
|
@ -338,3 +335,12 @@ void copyTelemetrySensor_custom(A * dest, B * src)
|
|||
dest->ratio = src->ratio;
|
||||
dest->offset = src->offset;
|
||||
}
|
||||
|
||||
template <class A, class B>
|
||||
void copyModuleData_ppm(A * dest, B * src)
|
||||
{
|
||||
dest->delay = src->delay;
|
||||
dest->pulsePol = src->pulsePol;
|
||||
dest->outputType = src->outputType;
|
||||
dest->frameLength = src->frameLength;
|
||||
}
|
||||
|
|
|
@ -871,9 +871,9 @@ void ConvertModel_216_to_217(ModelData & model)
|
|||
for (int j=0; j<NUM_CHNOUT; j++) {
|
||||
newModel.moduleData[i].failsafeChannels[j] = oldModel.moduleData[i].failsafeChannels[j];
|
||||
}
|
||||
newModel.moduleData[i].ppmDelay = oldModel.moduleData[i].ppmDelay;
|
||||
newModel.moduleData[i].ppmFrameLength = oldModel.moduleData[i].ppmFrameLength;
|
||||
newModel.moduleData[i].ppmPulsePol = oldModel.moduleData[i].ppmPulsePol;
|
||||
newModel.moduleData[i].ppm.delay = oldModel.moduleData[i].ppmDelay;
|
||||
newModel.moduleData[i].ppm.frameLength = oldModel.moduleData[i].ppmFrameLength;
|
||||
newModel.moduleData[i].ppm.pulsePol = oldModel.moduleData[i].ppmPulsePol;
|
||||
}
|
||||
|
||||
#if defined(PCBTARANIS)
|
||||
|
|
|
@ -27,7 +27,7 @@ void module_output_active()
|
|||
pioptr->PIO_ABCDSR[1] |= PIO_PA17 ; // Peripheral C
|
||||
pioptr->PIO_PDR = PIO_PA17 ; // Disable bit A17 Assign to peripheral
|
||||
#if defined(REVX)
|
||||
if (g_model.moduleData[EXTERNAL_MODULE].ppmOutputType) {
|
||||
if (g_model.moduleData[EXTERNAL_MODULE].ppm.OutputType) {
|
||||
pioptr->PIO_MDDR = PIO_PA17 ; // Push Pull O/p in A17
|
||||
}
|
||||
else {
|
||||
|
@ -52,13 +52,13 @@ void init_main_ppm(uint32_t period, uint32_t out_enable)
|
|||
pwmptr = PWM ;
|
||||
// PWM3 for PPM output
|
||||
pwmptr->PWM_CH_NUM[3].PWM_CMR = 0x0004000B ; // CLKA
|
||||
if (!g_model.moduleData[EXTERNAL_MODULE].ppmPulsePol) {
|
||||
if (!g_model.moduleData[EXTERNAL_MODULE].ppm.pulsePol) {
|
||||
pwmptr->PWM_CH_NUM[3].PWM_CMR |= 0x00000200 ; // CPOL
|
||||
}
|
||||
pwmptr->PWM_CH_NUM[3].PWM_CPDR = period ; // Period in half uS
|
||||
pwmptr->PWM_CH_NUM[3].PWM_CPDRUPD = period ; // Period in half uS
|
||||
pwmptr->PWM_CH_NUM[3].PWM_CDTY = g_model.moduleData[EXTERNAL_MODULE].ppmDelay*100+600; // Duty in half uS
|
||||
pwmptr->PWM_CH_NUM[3].PWM_CDTYUPD = g_model.moduleData[EXTERNAL_MODULE].ppmDelay*100+600; // Duty in half uS
|
||||
pwmptr->PWM_CH_NUM[3].PWM_CDTY = g_model.moduleData[EXTERNAL_MODULE].ppm.delay*100+600; // Duty in half uS
|
||||
pwmptr->PWM_CH_NUM[3].PWM_CDTYUPD = g_model.moduleData[EXTERNAL_MODULE].ppm.delay*100+600; // Duty in half uS
|
||||
pwmptr->PWM_ENA = PWM_ENA_CHID3 ; // Enable channel 3
|
||||
pwmptr->PWM_IER1 = PWM_IER1_CHID3 ;
|
||||
|
||||
|
@ -66,13 +66,13 @@ void init_main_ppm(uint32_t period, uint32_t out_enable)
|
|||
// PWM1 for PPM2
|
||||
configure_pins(PIO_PC15, PIN_PERIPHERAL | PIN_INPUT | PIN_PER_B | PIN_PORTC | PIN_NO_PULLUP ) ;
|
||||
pwmptr->PWM_CH_NUM[1].PWM_CMR = 0x0000000B ; // CLKB
|
||||
if (!g_model.moduleData[EXTRA_MODULE].ppmPulsePol) {
|
||||
if (!g_model.moduleData[EXTRA_MODULE].ppm.pulsePol) {
|
||||
pwmptr->PWM_CH_NUM[1].PWM_CMR |= 0x00000200 ; // CPOL
|
||||
}
|
||||
pwmptr->PWM_CH_NUM[1].PWM_CPDR = period ; // Period
|
||||
pwmptr->PWM_CH_NUM[1].PWM_CPDRUPD = period ; // Period
|
||||
pwmptr->PWM_CH_NUM[1].PWM_CDTY = g_model.moduleData[EXTRA_MODULE].ppmDelay*100+600 ; // Duty
|
||||
pwmptr->PWM_CH_NUM[1].PWM_CDTYUPD = g_model.moduleData[EXTRA_MODULE].ppmDelay*100+600 ; // Duty
|
||||
pwmptr->PWM_CH_NUM[1].PWM_CDTY = g_model.moduleData[EXTRA_MODULE].ppm.delay*100+600 ; // Duty
|
||||
pwmptr->PWM_CH_NUM[1].PWM_CDTYUPD = g_model.moduleData[EXTRA_MODULE].ppm.delay*100+600 ; // Duty
|
||||
pwmptr->PWM_ENA = PWM_ENA_CHID1 ; // Enable channel 1
|
||||
pwmptr->PWM_IER1 = PWM_IER1_CHID1 ;
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue