dependent repository for sendFootSensorsPackets (The UDP packet repos)

Dependents:   sendFootSensorsPacketsFinalUDP

Committer:
mmellor
Date:
Fri Jul 01 18:53:27 2016 +0000
Revision:
0:e44491917262
UDP Packet Sender (UDP packets constructed on the mbed side)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mmellor 0:e44491917262 1 //
mmellor 0:e44491917262 2 //
mmellor 0:e44491917262 3 //
mmellor 0:e44491917262 4 #include "mcp3208.h"
mmellor 0:e44491917262 5
mmellor 0:e44491917262 6
mmellor 0:e44491917262 7 MCP3208::MCP3208(PinName mosi, PinName miso, PinName clk, PinName cs)
mmellor 0:e44491917262 8 : _spi(mosi,miso,clk),
mmellor 0:e44491917262 9 _cs(cs),
mmellor 0:e44491917262 10 _vref(5.0)
mmellor 0:e44491917262 11 {
mmellor 0:e44491917262 12 _spi.frequency(2000000);
mmellor 0:e44491917262 13 _spi.format(12,3);
mmellor 0:e44491917262 14 _cs = 1;
mmellor 0:e44491917262 15 }
mmellor 0:e44491917262 16
mmellor 0:e44491917262 17 int
mmellor 0:e44491917262 18 MCP3208::binary(int ch)
mmellor 0:e44491917262 19 {
mmellor 0:e44491917262 20 _cs = 0;
mmellor 0:e44491917262 21 int ret = _spi.write((0x18|ch)<<2);
mmellor 0:e44491917262 22 int adb = _spi.write(0);
mmellor 0:e44491917262 23 _cs = 1;
mmellor 0:e44491917262 24 return adb;
mmellor 0:e44491917262 25 }
mmellor 0:e44491917262 26
mmellor 0:e44491917262 27 float
mmellor 0:e44491917262 28 MCP3208::volt(int ch)
mmellor 0:e44491917262 29 {
mmellor 0:e44491917262 30 return _vref * binary(ch) / 4095;
mmellor 0:e44491917262 31 }