![](/media/cache/profiles/ae9ad522bcc7a4c068f5c3456748ae65.jpg.50x50_q85.jpg)
External modules with MapleMini (STM32F103RB)
Dependencies: ADS1015 mbed-MapleMini mbed
main.cpp@0:93158ca82b67, 2016-12-18 (annotated)
- Committer:
- vargham
- Date:
- Sun Dec 18 14:11:13 2016 +0000
- Revision:
- 0:93158ca82b67
Added ADS1115 @ i2c
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
vargham | 0:93158ca82b67 | 1 | /* |
vargham | 0:93158ca82b67 | 2 | Maple Mini (STM32F103RB) peripherals tests |
vargham | 0:93158ca82b67 | 3 | by Mark Peter Vargha |
vargham | 0:93158ca82b67 | 4 | */ |
vargham | 0:93158ca82b67 | 5 | |
vargham | 0:93158ca82b67 | 6 | #include "MapleMini.h" |
vargham | 0:93158ca82b67 | 7 | #include "mbed.h" |
vargham | 0:93158ca82b67 | 8 | #include "Adafruit_ADS1015.h" |
vargham | 0:93158ca82b67 | 9 | |
vargham | 0:93158ca82b67 | 10 | DigitalOut boardLed(LED1); |
vargham | 0:93158ca82b67 | 11 | Serial serial(PA_2, PA_3); |
vargham | 0:93158ca82b67 | 12 | I2C i2c(I2C_SDA , I2C_SCL); |
vargham | 0:93158ca82b67 | 13 | Adafruit_ADS1115 ads(&i2c); |
vargham | 0:93158ca82b67 | 14 | Ticker oneSecondTicker; |
vargham | 0:93158ca82b67 | 15 | |
vargham | 0:93158ca82b67 | 16 | void readAds() |
vargham | 0:93158ca82b67 | 17 | { |
vargham | 0:93158ca82b67 | 18 | serial.printf("External analog in\r\n"); |
vargham | 0:93158ca82b67 | 19 | for (int i = 0; i < 4; i++) |
vargham | 0:93158ca82b67 | 20 | { |
vargham | 0:93158ca82b67 | 21 | int16_t adv = ads.readADC_SingleEnded(i); |
vargham | 0:93158ca82b67 | 22 | serial.printf("ADC%d=%+06d\r\n", i, adv); |
vargham | 0:93158ca82b67 | 23 | } |
vargham | 0:93158ca82b67 | 24 | serial.printf("\r\n"); |
vargham | 0:93158ca82b67 | 25 | } |
vargham | 0:93158ca82b67 | 26 | |
vargham | 0:93158ca82b67 | 27 | void inEverySecond() |
vargham | 0:93158ca82b67 | 28 | { |
vargham | 0:93158ca82b67 | 29 | readAds(); |
vargham | 0:93158ca82b67 | 30 | } |
vargham | 0:93158ca82b67 | 31 | |
vargham | 0:93158ca82b67 | 32 | int main() |
vargham | 0:93158ca82b67 | 33 | { |
vargham | 0:93158ca82b67 | 34 | confSysClock(); |
vargham | 0:93158ca82b67 | 35 | serial.baud(115200); |
vargham | 0:93158ca82b67 | 36 | ads.setGain(GAIN_ONE); |
vargham | 0:93158ca82b67 | 37 | oneSecondTicker.attach(&inEverySecond, 1.0); |
vargham | 0:93158ca82b67 | 38 | serial.printf("Maple peripherals tests.\r\n"); |
vargham | 0:93158ca82b67 | 39 | |
vargham | 0:93158ca82b67 | 40 | while(1) |
vargham | 0:93158ca82b67 | 41 | { |
vargham | 0:93158ca82b67 | 42 | |
vargham | 0:93158ca82b67 | 43 | } |
vargham | 0:93158ca82b67 | 44 | } |