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

feature/adc-interface #5

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

feature/adc-interface #5

wants to merge 9 commits into from

Conversation

wxkim
Copy link
Member

@wxkim wxkim commented Aug 22, 2024

Summary

Remarks

Checks

  • Tested
  • Stakeholder approval

@wxkim wxkim changed the title adc interface created feature/adc-interface Aug 26, 2024
@wxkim wxkim requested a review from NicoOhR September 9, 2024 04:37
@wxkim wxkim marked this pull request as ready for review September 10, 2024 04:33
Copy link
Member

@NicoOhR NicoOhR left a 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

private:

protected:
std::shared_ptr<std::vector<uint16_t>> adc_buf; //container for adc read
Copy link
Member

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?

Copy link
Member Author

@wxkim wxkim Sep 10, 2024

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.


protected:
std::shared_ptr<std::vector<uint16_t>> adc_buf; //container for adc read
size_t buffer_size; //unsigned
Copy link
Member

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

Copy link
Member Author

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

Comment on lines 47 to 60
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");
}
}
Copy link
Member

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!

@wxkim
Copy link
Member Author

wxkim commented Sep 15, 2024

builds with 0 error and 1 warning (that has to do with the linker).
ready to flash and test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants