Bsongis/horus xjt external module (#3566)
* [Horus] PXX and DSM2 in external module * [Taranis] Pulses driver refactoring (uses DMA also for PPM in external module and saves 800bytes RAM) * Cosmetics (Pulses driver splitted)
This commit is contained in:
@@ -18,9 +18,9 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "../opentx.h"
|
||||
#include "opentx.h"
|
||||
|
||||
void setupPulsesPPM(unsigned int port) // Don't enable interrupts through here
|
||||
void setupPulsesPPM(uint8_t port) // Don't enable interrupts through here
|
||||
{
|
||||
int16_t PPM_range = g_model.extendedLimits ? (512*LIMIT_EXT_PERCENT/100) * 2 : 512 * 2; //range of 0.7..1.7msec
|
||||
|
||||
@@ -43,23 +43,35 @@ void setupPulsesPPM(unsigned int port) // Don't enable interru
|
||||
#endif
|
||||
|
||||
PpmPulsesData * ppmPulsesData = (port == TRAINER_MODULE ? &trainerPulsesData.ppm : &modulePulsesData[port].ppm);
|
||||
uint16_t * ptr = ppmPulsesData->pulses;
|
||||
|
||||
#if defined(CPUSTM32)
|
||||
ppmPulsesData->ptr = ppmPulsesData->pulses;
|
||||
#else
|
||||
uint16_t * ptr = ppmPulsesData->pulses;
|
||||
ppmPulsesData->ptr = ptr;
|
||||
#endif
|
||||
|
||||
int32_t rest = 22500u * 2;
|
||||
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;
|
||||
#if defined(CPUSTM32)
|
||||
*ppmPulsesData->ptr++ = v; /* as Pat MacKenzie suggests */
|
||||
#else
|
||||
*ptr++ = v; /* as Pat MacKenzie suggests */
|
||||
#endif
|
||||
}
|
||||
if (rest > 65535) rest = 65535; /* prevents overflows */
|
||||
if (rest < 9000) rest = 9000; /* avoids that CCR2 is bigger than ARR which would cause reboot */
|
||||
#if defined(CPUSTM32)
|
||||
*ppmPulsesData->ptr++ = rest;
|
||||
#else
|
||||
*ptr = rest;
|
||||
*(ptr + 1) = 0;
|
||||
#endif
|
||||
|
||||
#if !defined(PCBSKY9X)
|
||||
#if defined(CPUSTM32)
|
||||
rest -= 1000;
|
||||
uint32_t ppmDelay = (g_model.moduleData[port].ppm.delay * 50 + 300) * 2;
|
||||
// set idle time, ppm delay and ppm polarity
|
||||
|
||||
Reference in New Issue
Block a user