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.
Dependencies: mbed
main.cpp
- Committer:
- prinonis
- Date:
- 2015-03-29
- Revision:
- 2:2c163adb4304
- Parent:
- 1:0940fc3527d9
File content as of revision 2:2c163adb4304:
#include "mbed.h"
#include "debug.h"
#include "INA219.h"
#define SAMP_FREQ
union packet_t
{
struct
{
unsigned int index;
float busVoltage;
float shuntVoltage;
float shuntCurrent;
};
char raw[];
};
int main()
{
Adafruit_INA219 sensor(I2C_SDA, I2C_SCL);
packet_t packet;
Timer timer;
debug dbg;
dbg.init( 230400 );
sensor.begin();
timer.start();
unsigned char header[] = { 0xDE, 0xAD };
while( 1 )
{
dbg.inf_pc->putc( header[0] );
dbg.inf_pc->putc( header[1] );
packet.index = timer.read_us();
packet.busVoltage = sensor.getBusVoltage_V();
packet.shuntVoltage = sensor.getShuntVoltage_mV();
packet.shuntCurrent = sensor.getCurrent_mA();
for( int i = 0; i < sizeof( packet ); i++ )
{
dbg.inf_pc->putc( packet.raw[i] );
}
dbg.flip();
wait_ms( 1 );
}
}