EEPROMTEST

Dependencies:   ADS1015 mbed

Fork of Test_nucleo_MCUUU by BAP TUDelft

Committer:
MockyBirdTwo
Date:
Mon May 07 09:08:24 2018 +0000
Revision:
2:78e48758fa6b
Parent:
1:8c5bcf47869e
Child:
3:efb3a5b4bc9e
Child:
4:fd10d8609295
test

Who changed what in which revision?

UserRevisionLine numberNew contents of line
xorjoep 0:952479e15354 1 #include "mbed.h" // Include files and define parameters.
xorjoep 0:952479e15354 2 #include "Adafruit_ADS1015.h"
xorjoep 0:952479e15354 3
xorjoep 0:952479e15354 4 I2C i2c_sensorplate_adc(PB_9, PB_8); // I2C for sensorplate.
xorjoep 0:952479e15354 5 Adafruit_ADS1115 piezo_resistive_adc1(&i2c_sensorplate_adc, 0x48); // i2c pins, i2c address.
xorjoep 0:952479e15354 6 Adafruit_ADS1115 piezo_resistive_adc2(&i2c_sensorplate_adc, 0x49); // i2c pins, i2c address.
xorjoep 0:952479e15354 7 Adafruit_ADS1115 piezo_electric_adc(&i2c_sensorplate_adc, 0x4B); // i2c pins, i2c address.
xorjoep 0:952479e15354 8 Serial usb_serial(SERIAL_TX, SERIAL_RX); // tx, rx
xorjoep 0:952479e15354 9
xorjoep 0:952479e15354 10 int i2c__frequency = 100000; // I2C Frequency.
xorjoep 0:952479e15354 11 int baud_rate = 115200; // Baud rate.
xorjoep 0:952479e15354 12
xorjoep 0:952479e15354 13 DigitalOut myled(LED1);
MockyBirdTwo 2:78e48758fa6b 14 //Test 1 2 3 test test
xorjoep 0:952479e15354 15 int main(){
xorjoep 0:952479e15354 16
xorjoep 0:952479e15354 17
xorjoep 0:952479e15354 18 i2c_sensorplate_adc.frequency(i2c__frequency); // Set frequency for i2c connection to sensorplate (variable is declared in config part).
xorjoep 0:952479e15354 19 usb_serial.baud(baud_rate); // Set serial USB connection baud rate (variable is declared in config part).
xorjoep 0:952479e15354 20
xorjoep 1:8c5bcf47869e 21 usb_serial.printf("Hello World !\n");
xorjoep 1:8c5bcf47869e 22
xorjoep 0:952479e15354 23 piezo_resistive_adc1.setGain(GAIN_TWOTHIRDS); // Set ranges of ADC to +/-6.144V (end is marked with #):
xorjoep 0:952479e15354 24 piezo_resistive_adc2.setGain(GAIN_TWOTHIRDS);
xorjoep 0:952479e15354 25
xorjoep 0:952479e15354 26 usb_serial.printf("Gains set.\n");
xorjoep 0:952479e15354 27 int i = 0;
xorjoep 1:8c5bcf47869e 28
xorjoep 0:952479e15354 29 while(1){
xorjoep 1:8c5bcf47869e 30 wait_ms(2);
xorjoep 0:952479e15354 31
xorjoep 0:952479e15354 32 myled = !myled;
xorjoep 0:952479e15354 33 //usb_serial.printf("Piezo electric 0_1 dif %d \n", piezo_electric_adc.readADC_Differential_0_1()); // First PE readout.
xorjoep 0:952479e15354 34 // usb_serial.printf("Piezo electric 2_3 dif %d \n", piezo_electric_adc.readADC_Differential_2_3());
xorjoep 0:952479e15354 35
xorjoep 0:952479e15354 36 for (uint8_t k = 0; k < 4; ++k) {
xorjoep 1:8c5bcf47869e 37 usb_serial.printf("piezo res %d array %d: %d\n", k, 1, (int16_t) piezo_resistive_adc1.readADC_SingleEnded(k)); // First 4 PR readout.
xorjoep 1:8c5bcf47869e 38 usb_serial.printf("piezo res %d array %d: %d\n", k, 2, (int16_t) piezo_resistive_adc2.readADC_SingleEnded(k)); // First 4 PR readout.
xorjoep 0:952479e15354 39 }
xorjoep 0:952479e15354 40 usb_serial.printf("This program runs since %d seconds.\n", i++);
xorjoep 0:952479e15354 41 }
xorjoep 0:952479e15354 42 }