simple MCP4XXX digital potentiometer library
Embed:
(wiki syntax)
Show/hide line numbers
MCP4XXX.h
00001 #ifndef MCP4XXX_H 00002 #define MCP4XXX_H 00003 00004 #include "mbed.h" 00005 00006 #define P0_ADDR 0x00 00007 #define P1_ADDR 0x10 00008 00009 class MCP4XXX { 00010 00011 public: 00012 MCP4XXX(PinName miso, PinName mosi, PinName clk, PinName cs); 00013 ~MCP4XXX(); 00014 void setLevel(unsigned char lvl, bool isP0 = true); // MCP42XX is a dual pot IC 00015 unsigned char getLevel(); 00016 private: 00017 SPI *_spi; 00018 DigitalOut *_cs; 00019 unsigned char _lvl; 00020 }; 00021 00022 #endif
Generated on Thu Jul 21 2022 11:44:55 by 1.7.2