-
Notifications
You must be signed in to change notification settings - Fork 3k
Improve management handling of multiple instances of analogin ojects #4623
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
Conversation
@LMESTM Does this also reduce the amount of static RAM allocated when an AnalogIn object is not constructed? Does it increase the size of an AnalogIn object? |
@LMESTM It looks like Travis CI failed.
Please fix this compile error. |
Yes and yes as a direct consequence of moving from global to object |
Will check the build failure and update RP |
@theotherjimmy - error reproduced after rebase, then fixed. should be fine now |
@LMESTM Thanks for getting on that! |
retest uvisor |
/morph test |
Result: FAILUREYour command has finished executing! Here's what you wrote!
|
@LMESTM Can you please look at the conflicts? |
@0xc0170 rebased and conflicts solved |
I made a conflict resolution error during last rebase - solved now |
/morph test |
Result: FAILUREYour command has finished executing! Here's what you wrote!
OutputTest failed! |
Maybe a minor thing was overseen in targets/TARGET_STM/TARGET_STM32F2/objects.h
In comparison to all other familiies is contains the line:
|
@ohagendorf good catch - will post update |
/morph test |
Result: FAILUREYour command has finished executing! Here's what you wrote!
|
Rebased - so conflicts resolved |
/morph test |
In this commit, the analogin_s structure is moved to commonn_objects.h file to limit the duplicaion. The ADC handle is moved from a global variable to a struct member of the analogin object. This allows multiple ADC instances to work correctly. Note that State needs to be explicitely set to HAL_ADC_STATE_RESET because the object is not zero initialized.
The adc in analogin_t has the same value as the Instance member of ADC_HandleTypeDef. So we can only rely on the later one.
Same as other families applied here
@0xc0170 There were conflicts due to another merged PR - rebased and conflicts solved |
@LMESTM thanks, please look at travis failure
|
@0xc0170 oops - this was also introduced by the conflicting PR and I missed it during rebase. I was too confident ... compiles fine now. |
Still fails for Travis? |
good job travis ! |
// Get the functions (adc channel) from the pin and assign it to the object | ||
function = pinmap_function(pin, PinMap_ADC); | ||
// Configure GPIO | ||
pinmap_pinout(pin, PinMap_ADC); | ||
} else { | ||
// Internal channels | ||
obj->adc = (ADCName)pinmap_peripheral(pin, PinMap_ADC_Internal); | ||
obj->handle.Instance = (ADC_TypeDef *) pinmap_peripheral(pin, PinMap_ADC); |
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.
Sorry Laurent,
This should be PinMap_ADC_Internal
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.
fixed
// Get the functions (adc channel) from the pin and assign it to the object | ||
function = pinmap_function(pin, PinMap_ADC); | ||
// Configure GPIO | ||
pinmap_pinout(pin, PinMap_ADC); | ||
} else { | ||
// Internal channels | ||
obj->adc = (ADCName)pinmap_peripheral(pin, PinMap_ADC_Internal); | ||
obj->handle.Instance = (ADC_TypeDef *) pinmap_peripheral(pin, PinMap_ADC); |
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.
Same, this should be PinMap_ADC_Internal
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.
fixed
// Get the functions (adc channel) from the pin and assign it to the object | ||
function = pinmap_function(pin, PinMap_ADC); | ||
// Configure GPIO | ||
pinmap_pinout(pin, PinMap_ADC); | ||
} else { | ||
// Internal channels | ||
obj->adc = (ADCName)pinmap_peripheral(pin, PinMap_ADC_Internal); | ||
obj->handle.Instance = (ADC_TypeDef *) pinmap_peripheral(pin, PinMap_ADC); |
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.
Same, PinMap_ADC_Internal
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.
fixed
function = pinmap_function(pin, PinMap_ADC); | ||
// Configure GPIO | ||
pinmap_pinout(pin, PinMap_ADC); | ||
} else { | ||
// Internal channels | ||
obj->adc = (ADCName)pinmap_peripheral(pin, PinMap_ADC_Internal); | ||
obj->handle.Instance = (ADC_TypeDef *) pinmap_peripheral(pin, PinMap_ADC); |
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.
same, PinMap_ADC_Internal
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.
fixed
The instance needs to be searched in PinMap_ADC_Internal, not PinMap_ADC. This was a copy paste error...
@jeromecoutant Thanks ! |
/morph test |
Result: SUCCESSYour command has finished executing! Here's what you wrote!
OutputAll builds and test passed! |
@jeromecoutant happy with the update? |
@LMESTM @jeromecoutant - we assume yes, as no voice against this changeset |
Description
Few reports has raised issue related to multiple instances of analogin objects:
https://developer.mbed.org/questions/67841/Multiple-analogIn-not-working/
This PR solves the issue by replacing usage of a single global variable to store the adc handle by a new handle members in the analogin_s object.
Status
READY
Tests
CI shield tests PASSED OK. (no regression found)