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.
Diff: ADS1015.cpp
- Revision:
- 1:c1ddf7c2d65b
- Parent:
- 0:94493b8b0fb0
- Child:
- 2:2bf91fd23a1a
--- a/ADS1015.cpp Tue Jun 26 13:30:53 2018 +0000
+++ b/ADS1015.cpp Wed Jun 27 09:11:26 2018 +0000
@@ -1,6 +1,20 @@
#include "mbed.h"
#include "ADS1015.h"
+#define CONFIG 0x81E3 | AD1015_CONFIG_FSR_4096
+
+double getSample(I2C* i2c_plate, uint8_t ADC_address, uint16_t sensor_address)
+{
+ sensor_address = CONFIG | sensor_address;
+
+ startSingleShotConversion(i2c_plate, ADC_address, sensor_address);
+ wait_ms(0.1);
+ startSingleShotConversion(i2c_plate, ADC_address, sensor_address);
+ wait_ms(0.3);
+
+ return readConversionResult(i2c_plate, ADC_address, sensor_address);
+}
+
void startSingleShotConversion(I2C* i2c_plate, uint8_t address, uint16_t config)
{
char txbuf[10];