Skip to content

Commit

Permalink
add buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
wxkim committed Sep 9, 2024
1 parent 2053a9b commit 52ec9bf
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
16 changes: 15 additions & 1 deletion Platform/Interfaces/iadc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#define IADC_H

#include <cstdint>
#include <memory>
#include <vector>

namespace platform
{
Expand All @@ -21,13 +23,25 @@ namespace platform
{
public:
virtual ~IADC() = 0;

//adc operations
virtual uint16_t convert() = 0;
virtual void write() = 0;

//buffer mngmt
virtual void read() = 0;

private:

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



};
}

#endif
#endif

//shared pointers buffer and buffer size inside ADCSTMf4
10 changes: 8 additions & 2 deletions Platform/STM/F4/ADC/adc_stmf4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@
*/


#include "../../../Interfaces/iadc.hpp" // dfr custom dependencies
#include "../../../Interfaces/iadc.hpp" // dfr custom interface
#include "adc_stmf4.hpp" //include header

namespace platform {
AdcStmF4::AdcStmF4(ADC_HandleTypeDef* hadc, DMA_HandleTypeDef* hdma, uint16_t pin)
: pin_(pin)
{
MX_ADC1_Init();
HAL_ADC_Init(hadc);
Expand All @@ -34,6 +33,13 @@ namespace platform {

uint16_t value = HAL_ADC_GetValue(hadc);
}



void AdcStmF4::write()
{

}
}


Expand Down
4 changes: 3 additions & 1 deletion Platform/STM/F4/ADC/adc_stmf4.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ namespace platform {

void write();



private:
ADC_HandleTypeDef* hadc;
DMA_HandleTypeDef* hdma;
uint16_t pin_;
//uint16_t pin_;

};
}
Expand Down

0 comments on commit 52ec9bf

Please sign in to comment.