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
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
AUTOMERGE: (FAIL)
|
This comment has been minimized.
This comment has been minimized.
…figure the pin mapping. This is done in the config.h as #define TIMER_PIN_MAPPING \ TIMER_PIN_MAP(0, PA0, 1, 0) \ TIMER_PIN_MAP(0, PA1, 1, 0) timerHardware[] dependencies to be removed in another PR
This comment has been minimized.
This comment has been minimized.
@@ -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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what you mean?
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
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.
This is simpler than what we had.
Do you want to test this code? Here you have an automated build: |
/* | ||
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 comment
The reason will be displayed to describe this comment to others. Learn more.
MAX_SUPPORTED_MOTORS
is 8. This should support the same amount of motor pins.
Also, all SPRacing FC's always have 8 motor outputs.
Can you confirm that the above example is incorrect and that the 3rd argument is the index into the array of e.g. Given the
The above example should be corrected to:
which would correspond to:
yes/no? IMHO: In the additionally,
|
referencing both the example in the original post and my comment above, and these files: https://github.com/betaflight/betaflight/blob/4.3-maintenance/src/main/target/SPRACINGH7EXTREME/target.h I tried this:
Which resulted in this:
Note that TIM0 doesn't exist, and channel 27 is erroneous. Obviously, that resulted in total failure... I also tried used the 1 based index for 'pos' based on the example in the OP, but the result was similar.
Here's the config.h file, so the others can try it.
Is there something I'm missing here? How was this PR tested? @haslinghuis @blckmn for PR's like this, can you ensure that they are tested and that working examples are given that others are able to replicate /prior/ to merging them, as is normally the case with PRs. |
cameraControlConfig->ioTag = timerioTagGetByUsage(TIM_USE_CAMERA_CONTROL, 0); | ||
#ifdef CAMERA_CONTROL_PIN | ||
cameraControlConfig->ioTag = IO_TAG(CAMERA_CONTROL_PIN); | ||
#else |
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.
…2342) * Method for adding defaults using defines for resources. * As we will always be using the fullTimerHardware, we just need to configure the pin mapping. This is done in the config.h as #define TIMER_PIN_MAPPING \ TIMER_PIN_MAP(0, PA0, 1, 0) \ TIMER_PIN_MAP(0, PA1, 1, 0) timerHardware[] dependencies to be removed in another PR * Adding missing pin definitions (removing dependency on timerHardware) * Typo * In case MOTOR1_PIN is not defined, but a motor is configured
As we will always be using the fullTimerHardware, we just need to configure the pin mapping.
This is done in the config.h as
Old timerHardware[] dependencies (that no longer exist as there are no target.c files - other than SITL - with them present) to be removed in another PR.