Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AFHDS protocol implementation #168

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions radio/src/gui/128x64/model_setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,8 @@ void menuModelSetup(event_t event)
INTERNAL_MODULE_CHANNELS_ROWS,
#endif
#if defined(PCBI6X)
IF_INTERNAL_MODULE_ON(1), // Subtype
IF_INTERNAL_MODULE_ON(1), // Servo Freq
IF_INTERNAL_MODULE_ON((g_model.moduleData[INTERNAL_MODULE].rfProtocol==PROTO_AFHDS2A_SPI)?1:HIDDEN_ROW), // Subtype
IF_INTERNAL_MODULE_ON((g_model.moduleData[INTERNAL_MODULE].rfProtocol==PROTO_AFHDS2A_SPI)?1:HIDDEN_ROW), // Servo Freq
#endif
IF_INTERNAL_MODULE_ON(HAS_RF_PROTOCOL_MODELINDEX(g_model.moduleData[INTERNAL_MODULE].rfProtocol) ? (uint8_t)2 : (uint8_t)1),
IF_INTERNAL_MODULE_ON(FAILSAFE_ROWS(INTERNAL_MODULE)),
Expand Down Expand Up @@ -785,10 +785,16 @@ void menuModelSetup(event_t event)
EE_MODEL,
isRfProtocolAvailable);
if (checkIncDec_Ret) { // modified?
g_model.moduleData[INTERNAL_MODULE].type = MODULE_TYPE_AFHDS2A_SPI;
if (g_model.moduleData[INTERNAL_MODULE].rfProtocol == RF_PROTO_OFF){
if (g_model.moduleData[INTERNAL_MODULE].rfProtocol == RF_I6X_PROTO_OFF){
g_model.moduleData[INTERNAL_MODULE].type = MODULE_TYPE_NONE;
}else if(g_model.moduleData[INTERNAL_MODULE].rfProtocol == RF_I6X_PROTO_AFHDS2A){
g_model.moduleData[INTERNAL_MODULE].type = MODULE_TYPE_AFHDS2A_SPI;
}
#if defined(AFHDS)
else{
g_model.moduleData[INTERNAL_MODULE].type = MODULE_TYPE_AFHDS_SPI;
}
#endif
}
}
break;
Expand Down Expand Up @@ -859,7 +865,7 @@ void menuModelSetup(event_t event)
g_model.moduleData[EXTERNAL_MODULE].type,
MODULE_TYPE_NONE,
#if defined(PCBI6X)
IS_TRAINER_EXTERNAL_MODULE() ? MODULE_TYPE_NONE : MODULE_TYPE_COUNT-2, // exclude AFHDS2A
IS_TRAINER_EXTERNAL_MODULE() ? MODULE_TYPE_NONE : MODULE_TYPE_CROSSFIRE, // exclude AFHDS2A and AFHDS
#else
IS_TRAINER_EXTERNAL_MODULE() ? MODULE_TYPE_NONE : MODULE_TYPE_COUNT-1,
#endif
Expand Down
15 changes: 13 additions & 2 deletions radio/src/myeeprom.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ enum CurveRefType {
#define GV1_LARGE 1024
#define GV_RANGE_WEIGHT 500
#define GV_RANGE_OFFSET 500
#define DELAY_MAX 250 /* 25 seconds */
#define SLOW_MAX 250 /* 25 seconds */
#define DELAY_MAX 250 /* 25 seconds */
#define SLOW_MAX 250 /* 25 seconds */

#define MD_WEIGHT(md) (md->weight)
#define MD_WEIGHT_TO_UNION(md, var) var.word = md->weight
Expand Down Expand Up @@ -343,6 +343,9 @@ enum Protocols {
#endif
#if defined(PCBI6X)
PROTO_AFHDS2A_SPI,
#if defined(AFHDS)
PROTO_AFHDS_SPI,
#endif
#endif
PROTO_NONE
};
Expand All @@ -366,7 +369,12 @@ enum XJTRFProtocols {
enum I6XProtocols {
RF_I6X_PROTO_OFF = -1,
RF_I6X_PROTO_AFHDS2A,
#if defined(AFHDS)
RF_I6X_PROTO_AFHDS,
RF_I6X_PROTO_LAST = RF_I6X_PROTO_AFHDS
#else
RF_I6X_PROTO_LAST = RF_I6X_PROTO_AFHDS2A
#endif
};

enum R9MSubTypes {
Expand Down Expand Up @@ -472,6 +480,9 @@ enum ModuleTypes {
MODULE_TYPE_SBUS,
#endif
MODULE_TYPE_AFHDS2A_SPI,
#if defined(AFHDS)
MODULE_TYPE_AFHDS_SPI,
#endif
MODULE_TYPE_COUNT
};

Expand Down
18 changes: 16 additions & 2 deletions radio/src/pulses/pulses_arm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ uint8_t getRequiredProtocol(uint8_t port) {
required_protocol = PROTO_PXX;
break;
#endif
#if defined(AFHDS)
case MODULE_TYPE_AFHDS_SPI:
required_protocol = PROTO_AFHDS_SPI;
break;
#endif
case MODULE_TYPE_AFHDS2A_SPI:
required_protocol = PROTO_AFHDS2A_SPI;
break;
Expand Down Expand Up @@ -150,7 +155,7 @@ bool setupPulses(uint8_t port) {
bool send = false;

uint8_t required_protocol = getRequiredProtocol(port);

heartbeat |= (HEART_TIMER_PULSES << port);

if (s_current_protocol[port] != required_protocol) {
Expand Down Expand Up @@ -184,9 +189,12 @@ bool setupPulses(uint8_t port) {

#if defined(MULTIMODULE)
case PROTO_MULTIMODULE:
#endif
#if defined(AFHDS)
case PROTO_AFHDS_SPI:
#endif
case PROTO_AFHDS2A_SPI:
disable_afhds2a(port);
disable_internal_rf(port);
break;
#if !defined(PCBI6X)
case PROTO_SBUS:
Expand Down Expand Up @@ -320,6 +328,12 @@ bool setupPulses(uint8_t port) {
case PROTO_PPM:
init_ppm(port);
break;
#if defined(AFHDS)
case PROTO_AFHDS_SPI:
init_afhds(port);
mixerSchedulerSetPeriod(INTERNAL_MODULE, 3860);
break;
#endif
case PROTO_AFHDS2A_SPI:
init_afhds2a(port);
mixerSchedulerSetPeriod(INTERNAL_MODULE, 3860);
Expand Down
Loading