Arduino board run on Mbed-os6.8.1 (only test purpose not official). Need Mbed Studio(1.3.1) not online compiler. If you compile on the online compiler, you can get a hex file but it does NOT work!!!

Dependencies:   APDS_9960 LPS22HB LSM9DS1 HTS221

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main1.cpp Source File

main1.cpp

00001 /*
00002  * Mbed Application program
00003  *  Nano 33 BLE Sense board runs on mbed-OS6
00004  *      Check I2C control line
00005  *
00006  * Copyright (c) 2020,'21 Kenji Arai / JH1PJL
00007  *      http://www7b.biglobe.ne.jp/~kenjia/
00008  *      https://os.mbed.com/users/kenjiArai/
00009  *      Started:    January   22nd, 2020
00010  *      Revised:    February  28th, 2021
00011  */
00012 
00013 //  Pre-selection --------------------------------------------------------------
00014 #include    "select_example.h"
00015 //#define EXAMPLE_1_CHECK_I2C_DEVICES
00016 #ifdef EXAMPLE_1_CHECK_I2C_DEVICES
00017 
00018 //  Include --------------------------------------------------------------------
00019 #include    "mbed.h"
00020 #include    "nano33blesense_iodef.h"
00021 
00022 //  Definition -----------------------------------------------------------------
00023 
00024 //  Constructor ----------------------------------------------------------------
00025 DigitalOut      sen_pwr(PIN_VDD_ENV, 1);
00026 DigitalOut      i2c_pullup(PIN_I2C_PULLUP, 1);
00027 I2C             i2c(PIN_SDA1, PIN_SCL1);
00028 
00029 //  RAM ------------------------------------------------------------------------
00030 
00031 //  ROM / Constant data --------------------------------------------------------
00032 
00033 //  Function prototypes --------------------------------------------------------
00034 
00035 //  subroutin (must be at this below line and do NOT change order) -------------
00036 #include    "usb_serial_as_stdio.h"
00037 #include    "check_revision.h"
00038 #include    "common.h"
00039 
00040 //------------------------------------------------------------------------------
00041 //  Control Program
00042 //------------------------------------------------------------------------------
00043 int main()
00044 {
00045     usb_serial_initialize();
00046     print_revision();
00047     i2c_pullup = 1;
00048     sen_pwr = 1;
00049     print_usb("Check I2C line\r\n");
00050     ThisThread::sleep_for(200ms);
00051     check_i2c_connected_devices();
00052     while (true) {
00053         print_usb("\r\n");
00054         check_i2c_sensors();
00055         ThisThread::sleep_for(2s);
00056     }
00057 }
00058 
00059 #endif // EXAMPLE_1_CHECK_I2C_DEVICES