Shield Code 6.0
Loading...
Searching...
No Matches
Max1148.hpp
Go to the documentation of this file.
1
18/*
19External clock mode is fine. Don't need to be concerned about noise. Means don't do the 8 us delay thing.
20Noise in the data sehet has more to do with the circuitb oard layout
21
22Need to know that bc different control lines on the PC board.
23
24There are two SPI boxes. Use one for the memory and one for the ADC. Arduino should manage on its own.
25 Does it give access to the second SPI? not that important.
26*/
27#ifndef MAX1148_HPP
28#define MAX1148_HPP
29#include <Arduino.h>
30#include <SPI.h>
31
32#define SPI_SPEED 2000000
33#define SPI_MODE SPI_MODE0
34#define ADC_CHANNEL 0
35#define ADC_PIN 10
36#define ADC_CS_PIN 10
37#define ADC_READ 0x00
38
44enum class Channel : uint8_t{
45 CHAN0 = 0x8F,
46 CHAN1 = 0xCF,
47 CHAN2 = 0x9F,
48 CHAN3 = 0xDF,
49 CHAN4 = 0xAF,
50 CHAN5 = 0xEF,
51 CHAN6 = 0xBF,
52 CHAN7 = 0xFF
53 };
57class Max1148{
61 friend class Pip;
62 private:
66 int cs_pin;
70 uint8_t channel;
74 void csl();
78 void csh();
84 uint16_t adc_read_avg(int avg_number);
88 uint16_t adc_read();
89 public:
95 this->channel = static_cast<uint8_t>(channel);
96 pinMode(cs_pin, OUTPUT);
97 }
98};
99
100
101#endif
#define ADC_CS_PIN
Definition: Max1148.hpp:36
Channel
Control bytes for the Max1148 ADC. Only modifiable parameter is the channel. We use single ended,...
Definition: Max1148.hpp:44
Manages interfacing with Max1148 ADC.
Definition: Max1148.hpp:57
Max1148(Channel channel)
ADC constructor. Sets cs_pin as per ADC_CS_PIN macro. Chooses channel from Channel enum.
Definition: Max1148.hpp:94
void csh()
Sets the chip select pin to high.
Definition: Max1148.cpp:43
void csl()
Sets the chip select pin to low.
Definition: Max1148.cpp:38
uint16_t adc_read()
Reads a single ADC value from the Max1148 ADC. Used in adc_read_avg.
Definition: Max1148.cpp:16
uint8_t channel
Channel for the ADC. Selected in the constructor.
Definition: Max1148.hpp:70
int cs_pin
Chip select pin for the ADC.
Definition: Max1148.hpp:66
uint16_t adc_read_avg(int avg_number)
Reads an average ADC value from the Max1148 ADC. Uses Arduino's SPI library. We don't use this anymor...
Definition: Max1148.cpp:3
Manages the Pip sensor sweep and associated data.
Definition: Pip.hpp:33