Natalia Requejo / Mbed OS xDot-Blinky-UNSAM

Dependencies:   ISL29011 libxDot-dev-mbed5-deprecated

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "mDot.h"
00003 #include "rtos.h"
00004 #include "ChannelPlans.h"
00005 #include "ISL29011.h"
00006 
00007 static Serial pc(USBTX, USBRX);
00008 
00009 I2C i2c(I2C_SDA, I2C_SCL);
00010 ISL29011 lux(i2c);
00011 
00012 
00013 DigitalOut led1(LED1);
00014 
00015 void rise() {
00016     pc.printf("RISE\n");
00017     led1.write(true);
00018 }
00019 
00020 void fall() {
00021     pc.printf("FALL\n");
00022     led1.write(false);
00023 }
00024 
00025 
00026 // main() runs in its own thread in the OS
00027 // (note the calls to Thread::wait below for delays)
00028 int main() {
00029     pc.baud(115200);
00030 
00031     pc.printf("Entering main()\r\n");
00032     
00033     /*GPIO_InitTypeDef GPIO_InitStruct;
00034     
00035     GPIO_InitStruct.Pin = GPIO_PIN_0;
00036     GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
00037     GPIO_InitStruct.Pull = GPIO_NOPULL;
00038     HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
00039       */  
00040     lux.setMode(ISL29011::ALS_CONT);
00041     lux.setResolution(ISL29011::ADC_16BIT);
00042     lux.setRange(ISL29011::RNG_64000);
00043 
00044     InterruptIn btn(PA_0); /* S2 - button */
00045     btn.rise(&rise);
00046     btn.fall(&fall);
00047 
00048     while (true) {
00049         pc.printf("Light: %d \r\n", lux.getData());
00050         //led1.write(PA_0);
00051         Thread::wait(1000);
00052         
00053         }
00054 }