-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Method for adding defaults using defines for resources. #12342
Changes from 4 commits
7691a83
5b63881
7096f4d
5538d6c
57a7ba2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,9 +67,22 @@ void pgResetFn_motorConfig(motorConfig_t *motorConfig) | |
#endif | ||
|
||
#ifdef USE_TIMER | ||
for (int motorIndex = 0; motorIndex < MAX_SUPPORTED_MOTORS; motorIndex++) { | ||
motorConfig->dev.ioTags[motorIndex] = timerioTagGetByUsage(TIM_USE_MOTOR, motorIndex); | ||
} | ||
#ifdef MOTOR1_PIN | ||
motorConfig->dev.ioTags[0] = IO_TAG(MOTOR1_PIN); | ||
#endif | ||
#ifdef MOTOR2_PIN | ||
motorConfig->dev.ioTags[1] = IO_TAG(MOTOR2_PIN); | ||
#endif | ||
#ifdef MOTOR3_PIN | ||
motorConfig->dev.ioTags[2] = IO_TAG(MOTOR3_PIN); | ||
#endif | ||
#ifdef MOTOR4_PIN | ||
motorConfig->dev.ioTags[3] = IO_TAG(MOTOR4_PIN); | ||
#endif | ||
blckmn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
/* | ||
NOTE as we predominantly build for quads, the default motor pin defines is 4, | ||
add more if a specific configuration ever requires it. | ||
*/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Also, all SPRacing FC's always have 8 motor outputs. |
||
#endif | ||
|
||
motorConfig->motorPoleCount = 14; // Most brushes motors that we use are 14 poles | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,33 +29,15 @@ | |
|
||
#include "timerio.h" | ||
|
||
#define TIMER_PIN_MAP(idx, pin, pos, dmaOpt) \ | ||
{ config[idx].ioTag = IO_TAG(pin); config[idx].index = pos; config[idx].dmaopt = dmaOpt; } | ||
|
||
PG_REGISTER_ARRAY_WITH_RESET_FN(timerIOConfig_t, MAX_TIMER_PINMAP_COUNT, timerIOConfig, PG_TIMER_IO_CONFIG, 0); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to raise version? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure what you mean? |
||
|
||
void pgResetFn_timerIOConfig(timerIOConfig_t *config) | ||
{ | ||
#if defined(USE_TIMER_MGMT) && USABLE_TIMER_CHANNEL_COUNT > 0 | ||
unsigned configIndex = 0; | ||
for (unsigned timerIndex = 0; timerIndex < USABLE_TIMER_CHANNEL_COUNT; timerIndex++) { | ||
const timerHardware_t *configuredTimer = &timerHardware[timerIndex]; | ||
unsigned positionIndex = 1; | ||
for (unsigned fullTimerIndex = 0; fullTimerIndex < FULL_TIMER_CHANNEL_COUNT; fullTimerIndex++) { | ||
const timerHardware_t *timer = &fullTimerHardware[fullTimerIndex]; | ||
if (timer->tag == configuredTimer->tag) { | ||
if (timer->tim == configuredTimer->tim && timer->channel == configuredTimer->channel) { | ||
config[configIndex].ioTag = timer->tag; | ||
config[configIndex].index = positionIndex; | ||
|
||
config[configIndex].dmaopt = dmaGetOptionByTimer(configuredTimer); | ||
|
||
configIndex++; | ||
|
||
break; | ||
} else { | ||
positionIndex++; | ||
} | ||
} | ||
} | ||
} | ||
#ifdef TIMER_PIN_MAPPING | ||
TIMER_PIN_MAPPING | ||
blckmn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
#else | ||
UNUSED(config); | ||
#endif | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is possible to use (black) macro magic so that CAMERA_CONTROL_PIN will expand to tag if defined (including NONE), and to NONE when undefined. It may also check that TAG definition is valid.
It may make this code more readable ..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ping me if you think it is good idea ..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ping @blckmn ☝️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ledvinap absolutely! You are the king of macros, so happy for you to show how it'd work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#12393