xDot-Blinky program

Dependencies:   ISL29011 libxDot-dev-mbed5-deprecated

Committer:
NataliaRequejo
Date:
Wed Feb 28 23:58:17 2018 +0000
Revision:
0:95a1feb8741b
XDot-Blinky-UNSAM

Who changed what in which revision?

UserRevisionLine numberNew contents of line
NataliaRequejo 0:95a1feb8741b 1 #include "mbed.h"
NataliaRequejo 0:95a1feb8741b 2 #include "mDot.h"
NataliaRequejo 0:95a1feb8741b 3 #include "rtos.h"
NataliaRequejo 0:95a1feb8741b 4 #include "ChannelPlans.h"
NataliaRequejo 0:95a1feb8741b 5 #include "ISL29011.h"
NataliaRequejo 0:95a1feb8741b 6
NataliaRequejo 0:95a1feb8741b 7 static Serial pc(USBTX, USBRX);
NataliaRequejo 0:95a1feb8741b 8
NataliaRequejo 0:95a1feb8741b 9 I2C i2c(I2C_SDA, I2C_SCL);
NataliaRequejo 0:95a1feb8741b 10 ISL29011 lux(i2c);
NataliaRequejo 0:95a1feb8741b 11
NataliaRequejo 0:95a1feb8741b 12
NataliaRequejo 0:95a1feb8741b 13 DigitalOut led1(LED1);
NataliaRequejo 0:95a1feb8741b 14
NataliaRequejo 0:95a1feb8741b 15 void rise() {
NataliaRequejo 0:95a1feb8741b 16 pc.printf("RISE\n");
NataliaRequejo 0:95a1feb8741b 17 led1.write(true);
NataliaRequejo 0:95a1feb8741b 18 }
NataliaRequejo 0:95a1feb8741b 19
NataliaRequejo 0:95a1feb8741b 20 void fall() {
NataliaRequejo 0:95a1feb8741b 21 pc.printf("FALL\n");
NataliaRequejo 0:95a1feb8741b 22 led1.write(false);
NataliaRequejo 0:95a1feb8741b 23 }
NataliaRequejo 0:95a1feb8741b 24
NataliaRequejo 0:95a1feb8741b 25
NataliaRequejo 0:95a1feb8741b 26 // main() runs in its own thread in the OS
NataliaRequejo 0:95a1feb8741b 27 // (note the calls to Thread::wait below for delays)
NataliaRequejo 0:95a1feb8741b 28 int main() {
NataliaRequejo 0:95a1feb8741b 29 pc.baud(115200);
NataliaRequejo 0:95a1feb8741b 30
NataliaRequejo 0:95a1feb8741b 31 pc.printf("Entering main()\r\n");
NataliaRequejo 0:95a1feb8741b 32
NataliaRequejo 0:95a1feb8741b 33 /*GPIO_InitTypeDef GPIO_InitStruct;
NataliaRequejo 0:95a1feb8741b 34
NataliaRequejo 0:95a1feb8741b 35 GPIO_InitStruct.Pin = GPIO_PIN_0;
NataliaRequejo 0:95a1feb8741b 36 GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
NataliaRequejo 0:95a1feb8741b 37 GPIO_InitStruct.Pull = GPIO_NOPULL;
NataliaRequejo 0:95a1feb8741b 38 HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
NataliaRequejo 0:95a1feb8741b 39 */
NataliaRequejo 0:95a1feb8741b 40 lux.setMode(ISL29011::ALS_CONT);
NataliaRequejo 0:95a1feb8741b 41 lux.setResolution(ISL29011::ADC_16BIT);
NataliaRequejo 0:95a1feb8741b 42 lux.setRange(ISL29011::RNG_64000);
NataliaRequejo 0:95a1feb8741b 43
NataliaRequejo 0:95a1feb8741b 44 InterruptIn btn(PA_0); /* S2 - button */
NataliaRequejo 0:95a1feb8741b 45 btn.rise(&rise);
NataliaRequejo 0:95a1feb8741b 46 btn.fall(&fall);
NataliaRequejo 0:95a1feb8741b 47
NataliaRequejo 0:95a1feb8741b 48 while (true) {
NataliaRequejo 0:95a1feb8741b 49 pc.printf("Light: %d \r\n", lux.getData());
NataliaRequejo 0:95a1feb8741b 50 //led1.write(PA_0);
NataliaRequejo 0:95a1feb8741b 51 Thread::wait(1000);
NataliaRequejo 0:95a1feb8741b 52
NataliaRequejo 0:95a1feb8741b 53 }
NataliaRequejo 0:95a1feb8741b 54 }