12bit 8ch ADC with SWSPI instead to support variable SPI bit length
Fork of MCP3208_Y by
mcp3208.h@1:0876e83ba21b, 2012-10-24 (annotated)
- Committer:
- ykuroda
- Date:
- Wed Oct 24 05:52:21 2012 +0000
- Revision:
- 1:0876e83ba21b
- Parent:
- 0:2300f3b42cdb
- Child:
- 2:701c3096336e
refine code
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ykuroda | 0:2300f3b42cdb | 1 | // |
ykuroda | 0:2300f3b42cdb | 2 | // |
ykuroda | 0:2300f3b42cdb | 3 | // |
ykuroda | 0:2300f3b42cdb | 4 | #ifndef _MCP3208_H |
ykuroda | 0:2300f3b42cdb | 5 | #define _MCP3208_H |
ykuroda | 0:2300f3b42cdb | 6 | |
ykuroda | 0:2300f3b42cdb | 7 | #include <mbed.h> |
ykuroda | 0:2300f3b42cdb | 8 | |
ykuroda | 0:2300f3b42cdb | 9 | class MCP3208 { |
ykuroda | 0:2300f3b42cdb | 10 | protected: |
ykuroda | 0:2300f3b42cdb | 11 | SPI _spi; |
ykuroda | 0:2300f3b42cdb | 12 | DigitalOut _cs; |
ykuroda | 1:0876e83ba21b | 13 | float _vref; |
ykuroda | 0:2300f3b42cdb | 14 | |
ykuroda | 0:2300f3b42cdb | 15 | public: |
ykuroda | 0:2300f3b42cdb | 16 | MCP3208(PinName mosi=p11, PinName miso=p12, PinName clk=p13, PinName cs=p14); |
ykuroda | 0:2300f3b42cdb | 17 | int binary(int ch); |
ykuroda | 0:2300f3b42cdb | 18 | float volt(int ch); |
ykuroda | 1:0876e83ba21b | 19 | float vref(float v){return _vref=v;} |
ykuroda | 0:2300f3b42cdb | 20 | }; |
ykuroda | 0:2300f3b42cdb | 21 | |
ykuroda | 1:0876e83ba21b | 22 | #endif //_MCP3208_H |