Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
mcp3208.cpp
00001 // 00002 // 00003 // 00004 #include "mcp3208.h" 00005 00006 00007 MCP3208::MCP3208(PinName mosi, PinName miso, PinName clk, PinName cs) 00008 : _spi(mosi,miso,clk), 00009 _cs(cs), 00010 _vref(5.0) 00011 { 00012 _spi.frequency(2000000); 00013 _spi.format(12,3); 00014 _cs = 1; 00015 } 00016 00017 int 00018 MCP3208::binary(int ch) 00019 { 00020 _cs = 0; 00021 int ret = _spi.write((0x18|ch)<<2); 00022 int adb = _spi.write(0); 00023 _cs = 1; 00024 return adb; 00025 } 00026 00027 float 00028 MCP3208::volt(int ch) 00029 { 00030 return _vref * binary(ch) / 4095; 00031 } 00032
Generated on Sun Jul 17 2022 20:38:33 by
1.7.2