-
Notifications
You must be signed in to change notification settings - Fork 0
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
feature/adc-interface #5
base: main
Are you sure you want to change the base?
Conversation
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.
Good stuff, we should definitely verify that it works on a dev board with some potentiometers before merging in
Platform/Interfaces/iadc.hpp
Outdated
private: | ||
|
||
protected: | ||
std::shared_ptr<std::vector<uint16_t>> adc_buf; //container for adc read |
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.
I'm wondering why the adc_buffer would be a shared pointer?
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.
made shared pointer so different threads could use it at once. also because shared pointers avoid deep copies when referenced by multiple other functions.
Platform/Interfaces/iadc.hpp
Outdated
|
||
protected: | ||
std::shared_ptr<std::vector<uint16_t>> adc_buf; //container for adc read | ||
size_t buffer_size; //unsigned |
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.
I think that if we want to control the maximum size of the buffer, maybe it'd be better to use a normal array, that is unless the helper functions of the std::vector class are too nice to pass up on
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.
i think vector class member functions such as pushback would be very useful here, and any other member function defined would just be extra useful utility not defined in array
Platform/STM/F4/ADC/adc_stmf4.cpp
Outdated
void AdcStmF4::writeToBuffer() //redundant? | ||
{ | ||
uint16_t ADC_Conversion_Result = convert(); | ||
|
||
if( (adc_buf != nullptr) && (adc_buf->size() < buffer_size) ) | ||
{ | ||
adc_buf->push_back(convert()); | ||
} | ||
|
||
else | ||
{//use during debug | ||
printf("ADC Buffer Error or Buffer Full\n"); | ||
} | ||
} |
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.
A little redundant, since most of the time the ADC will write directory to memory via DMA, nice error handling!
builds with 0 error and 1 warning (that has to do with the linker). |
Summary
Remarks
Checks