85,13 → 85,16 |
FFFF 1F23F000A30426 |
*/ |
|
|
#include <stdlib.h> |
#include "dsl.h" |
#include "rc.h" |
#include "uart0.h" |
|
uint8_t dsl_RSSI = 0; |
uint8_t dsl_Battery = 0; |
uint8_t dsl_Allocation = 0; |
uint8_t PacketBuffer[6]; |
uint8_t Jitter = 0; // same measurement as RC_Quality in rc.c |
|
typedef union |
{ |
110,17 → 113,25 |
int16_t tmp; |
uint8_t index = channel + 1; // mk channels start with 1 |
|
RC_Quality = (212 * (uint16_t)dsl_RSSI) / 128; // have to be scaled approx. by a factor of 1.66 to get 200 at full level |
if(RC_Quality > 255) RC_Quality = 255; |
|
// signal from DSL-receiver is between 7373 (1ms) und 14745 (2ms). |
signal-= 11059; // shift to neutral |
signal/= 24; // scale to mk rc resolution |
|
if(abs(signal-PPM_in[index]) < 6) |
{ |
if(Jitter < 200) Jitter +=10; |
else Jitter = 200; |
} |
|
// calculate exponential history for signal |
tmp = (3 * (PPM_in[index]) + signal) / 4; |
if(tmp > signal+1) tmp--; else |
if(tmp < signal-1) tmp++; |
// calculate signal difference on good signal level |
if(RC_Quality >= 195) PPM_diff[index] = ((tmp - PPM_in[index]) / 3) * 3; // cut off lower 3 bit for noise reduction |
if(Jitter >= 195) PPM_diff[index] = ((tmp - PPM_in[index]) / 3) * 3; // cut off lower 3 bit for noise reduction |
else PPM_diff[index] = 0; |
PPM_in[index] = tmp; // update channel value |
|
127,7 → 138,6 |
if(index == 4) |
{ |
NewPpmData = 0; |
NewRCFrames++; |
} |
} |
|
145,8 → 155,6 |
dsl_Allocation = PacketBuffer[1]; // Get frequency allocation |
// ?? = PacketBuffer[2]; |
dsl_RSSI = PacketBuffer[3]; // Get signal quality |
RC_Quality = (212 * (uint16_t)dsl_RSSI) / 128; // have to be scaled approx. by a factor of 1.66 to get 200 at full level |
if(RC_Quality > 255) RC_Quality = 255; |
dsl_Battery = PacketBuffer[4]; // Get voltage of battery supply |
// ?? = PacketBuffer[5]; |
if(dsl_RSSI == 0) |