MikeBland / mbtx

er9x/ersky9x radio firmware
GNU General Public License v2.0
147 stars 56 forks source link

Stop interrupt handlers from corrupting xfire telemetry #40

Closed nrw505 closed 5 years ago

nrw505 commented 5 years ago

USART IRQ handlers write into TelemetryTx.SportTx, which overwrites the data that the BASIC interpreter just wrote into TelemetryTx.XfireTx, as TelemetryTx is a union that overlaps SportTx and XfireTx.

To stop the Xfire send buffer getting zeroes written over it, separate TelemetryTx.SportTx and TelemetryTx.XfireTx into SportTelemetryTx and XFireTelemetryTx so they don't overlap anymore.

nrw505 commented 5 years ago

While there are some indentation changes here they're just changing 2-spaces to tab characters

MikeBland commented 5 years ago

OK, to save on RAM usage, which is why there is a union in the first place (The SKY board only has 48K RAM and I'm trying to leave as much as possible for scripts), I'll implement a change to the union as:

struct t_SportTx { uint8_t *ptr ; uint8_t index ; uint8_t data[16] ; } ;

struct t_XfireTx { uint16_t count ; uint8_t command ; uint8_t data[64] ; } ;

struct t_telemetryTx { uint16_t sportCount ; uint8_t sportBusy ; union { struct t_SportTx SportTx ; struct t_XfireTx XfireTx ; } ; } ;

This puts the 2 variables (now sportCount and sportBusy) in unique locations.

Mike

nrw505 commented 5 years ago

Fixed by 6bfb3fd03aff4c058fabb1705973318505099839