YAHAL
Yet Another Hardware Abstraction Library
Loading...
Searching...
No Matches
adc_rp2350.h
1// ---------------------------------------------
2// This file is part of
3// _ _ __ _ _ __ __
4// ( \/ ) /__\ ( )_( ) /__\ ( )
5// \ / /(__)\ ) _ ( /(__)\ )(__
6// (__)(__)(__)(_) (_)(__)(__)(____)
7//
8// Yet Another HW Abstraction Library
9// Copyright (C) Andreas Terstegge
10// BSD Licensed (see file LICENSE)
11//
12// ---------------------------------------------
13//
14#ifndef _ADC_RP2350_H_
15#define _ADC_RP2350_H_
16
17#include "adc_interface.h"
18
19class adc_rp2350 : public adc_interface {
20public:
21 static adc_rp2350 inst;
22
23 // Basic ADC functions
24 void adcMode(uint8_t channel, uint16_t mode) override;
25
26 adc_mode_t getMode(uint8_t channel) override;
27
28 uint16_t adcReadRaw(uint8_t channel) override;
29
30 float adcReadVoltage(uint8_t channel) override;
31
32 float rawToVoltage(uint8_t channel, uint16_t raw) override;
33
34private:
35
36 adc_rp2350();
37
38 uint16_t _modes[8] {};
39};
40
41
42// This small wrapper class provides ADC
43// functionality for a single channel.
44
46public:
48 : adc_channel(adc_rp2350::inst) {}
49
50 explicit adc_rp2350_channel(uint16_t c)
51 : adc_channel(adc_rp2350::inst, c) {}
52};
53
54#endif // _ADC_RP2350_H_
55