MSPM0_ValvanoWare  1.0
ECE445L starter code
SlidePot.h
1 // SlidePot.h
2 // Runs on MSPM0
3 // Provide functions that initialize ADC1 channel 5, PB18 and use a slide pot to measure distance
4 // Created: 12/29/2023
5 // Student names: change this to your names or look very silly
6 // Last modification date: change this to the last modification date or look very silly
7 
8 #ifndef SLIDEPOT_H
9 #define SLIDEPOT_H
10 #include <stdint.h>
11 
12 class SlidePot{ private:
13  uint32_t data; // raw ADC value
14  int32_t flag; // 0 if data is not valid, 1 if valid
15  uint32_t distance; // distance in 0.001cm
16 // distance = (slope*data+offset)/4096
17  uint32_t slope; // calibration coeffients
18  uint32_t offset;
19 public:
20  SlidePot(uint32_t m, uint32_t b); // initialize slide pot
21  void Init(void);
22  uint32_t In(void); // return last ADC sample value (0 to 4095)
23  void Save(uint32_t n); // save ADC, set semaphore
24  void Sync(void); // wait for semaphore
25  uint32_t Convert(uint32_t n); // convert ADC to raw sample
26  float FloatConvert(uint32_t n); // do not use this function
27  uint32_t Distance(void); // return last distance value (0 to 2000), 0.001cm
28 };
29 #endif
Definition: SlidePot.h:12