MCP3425 library
Embed:
(wiki syntax)
Show/hide line numbers
MCP3425.h
00001 //********************** 00002 // MCP3425.h for mbed 00003 // 00004 // (C)Copyright 2014 All rights reserved by Y.Onodera 00005 // http://einstlab.web.fc2.com 00006 //********************** 00007 00008 #ifndef MCP3425_H_ 00009 #define MCP3425_H_ 00010 00011 #define MCP3425_ADDR 0xD0 00012 00013 #include "mbed.h" 00014 #include "typedef.h" 00015 00016 00017 typedef union 00018 { 00019 unsigned char UC; 00020 struct 00021 { 00022 unsigned char G:2; // 00=1, 01=2, 10=4, 11=8 Gain 00023 unsigned char S:2; // 00=12bits, 01=14bits, 10=16bits 00024 unsigned char OC:1; // 0=One-shot, 1=Continuous 00025 unsigned char C:2; // NA 00026 unsigned char RDY:1; // wrinting 1=Initiate, reading 0=Ready 00027 } bit; 00028 } CONFIG; 00029 00030 00031 00032 class MCP3425{ 00033 public: 00034 MCP3425 (PinName sda, PinName scl); 00035 MCP3425 (I2C& p_i2c); 00036 void init(); 00037 short get(); 00038 00039 protected: 00040 00041 I2C _i2c; 00042 00043 CONFIG config; 00044 WORD_VAL ad; 00045 char buf[3]; 00046 00047 }; 00048 00049 #endif /* MCP3425_H_ */ 00050 00051 00052
Generated on Tue Jul 26 2022 08:57:44 by
1.7.2