Basic example that demonstrates functionalities of the BMC 150 SiP.
Dependencies: adc52832_common mbed
main.cpp@0:8b32cf6a0351, 2017-07-31 (annotated)
- Committer:
- jurica238814
- Date:
- Mon Jul 31 10:29:34 2017 +0000
- Revision:
- 0:8b32cf6a0351
Init commit. Basic functionalities example.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jurica238814 | 0:8b32cf6a0351 | 1 | /* |
jurica238814 | 0:8b32cf6a0351 | 2 | * Something nice =) |
jurica238814 | 0:8b32cf6a0351 | 3 | * Jurica Resetar @ aconno.de |
jurica238814 | 0:8b32cf6a0351 | 4 | * |
jurica238814 | 0:8b32cf6a0351 | 5 | */ |
jurica238814 | 0:8b32cf6a0351 | 6 | |
jurica238814 | 0:8b32cf6a0351 | 7 | #include "mbed.h" |
jurica238814 | 0:8b32cf6a0351 | 8 | #include "bmc150.h" |
jurica238814 | 0:8b32cf6a0351 | 9 | #include "acd52832_bsp.h" |
jurica238814 | 0:8b32cf6a0351 | 10 | #include "utilities.h" |
jurica238814 | 0:8b32cf6a0351 | 11 | |
jurica238814 | 0:8b32cf6a0351 | 12 | #define SPI_MISO (p17) |
jurica238814 | 0:8b32cf6a0351 | 13 | #define SPI_MOSI (p18) |
jurica238814 | 0:8b32cf6a0351 | 14 | #define SPI_CLK (p20) |
jurica238814 | 0:8b32cf6a0351 | 15 | #define BMC150_SPI_CS (p19) |
jurica238814 | 0:8b32cf6a0351 | 16 | |
jurica238814 | 0:8b32cf6a0351 | 17 | #define VCC_ON_PIN (p25) |
jurica238814 | 0:8b32cf6a0351 | 18 | |
jurica238814 | 0:8b32cf6a0351 | 19 | DigitalOut bmcCs(BMC150_SPI_CS); |
jurica238814 | 0:8b32cf6a0351 | 20 | DigitalOut vccOn(VCC_ON_PIN); |
jurica238814 | 0:8b32cf6a0351 | 21 | DigitalOut readyLED(PIN_LED_RED); |
jurica238814 | 0:8b32cf6a0351 | 22 | SPI spi(SPI_MOSI, SPI_MISO, SPI_CLK); // mosi, miso, sclk |
jurica238814 | 0:8b32cf6a0351 | 23 | BMC150 bmc(spi, bmcCs); |
jurica238814 | 0:8b32cf6a0351 | 24 | |
jurica238814 | 0:8b32cf6a0351 | 25 | int main(){ |
jurica238814 | 0:8b32cf6a0351 | 26 | uint8_t temperature; |
jurica238814 | 0:8b32cf6a0351 | 27 | readyLED = 0; |
jurica238814 | 0:8b32cf6a0351 | 28 | vccOn = 1; // Turn VCC_ON on for BMC150 |
jurica238814 | 0:8b32cf6a0351 | 29 | wait_ms(100); |
jurica238814 | 0:8b32cf6a0351 | 30 | readyLED = 1; |
jurica238814 | 0:8b32cf6a0351 | 31 | |
jurica238814 | 0:8b32cf6a0351 | 32 | temperature = bmc.readTemperature(); |
jurica238814 | 0:8b32cf6a0351 | 33 | |
jurica238814 | 0:8b32cf6a0351 | 34 | } |