Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed rohm-bh1726 rohm-sensor-hal
Fork of rohm-bh1745-hello by
main_classic.cpp
00001 /* Copyright 2016 Rohm Semiconductor 00002 00003 Licensed under the Apache License, Version 2.0 (the "License"); 00004 you may not use this file except in compliance with the License. 00005 You may obtain a copy of the License at 00006 00007 http://www.apache.org/licenses/LICENSE-2.0 00008 00009 Unless required by applicable law or agreed to in writing, software 00010 distributed under the License is distributed on an "AS IS" BASIS, 00011 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00012 See the License for the specific language governing permissions and 00013 limitations under the License. 00014 */ 00015 00016 #include "rohm-sensor-hal/rohm-sensor-hal/rohm_hal.h" //mbed.h, types, DEBUG_print* 00017 #include "rohm-sensor-hal/rohm-sensor-hal/I2CCommon.h" 00018 00019 #include "rohm-bh1726/rohm-bh1726/bh1726_driver.h" 00020 #include "rohm-bh1726/rohm-bh1726/bh1726.h" 00021 00022 Serial pc(USBTX, USBRX); 00023 00024 void bh1726_print_one_value(){ 00025 bool error; 00026 uint16_t data[2]; //2 channels of 16-bit data 00027 00028 error = bh1726_read_data(&data[0]); 00029 if (!error) { 00030 pc.printf("ALS Data0[%4u], Data1[%4u]\n\r", data[0], data[1]); 00031 } 00032 else { 00033 pc.printf("\n\r"); 00034 } 00035 } 00036 00037 void bh1726_print_raw_values(){ 00038 pc.printf("\nbh1726 library test program.\n\r"); 00039 I2CCommonBegin(); 00040 00041 bh1726_wait_until_found(); 00042 bh1726_initial_setup(); 00043 wait(1); 00044 // bh1726_dumpregs(BH1726_REGISTER_DUMP_START, BH1726_REGISTER_DUMP_END); 00045 00046 while(1) { 00047 bh1726_print_one_value(); 00048 wait(0.2); 00049 } 00050 } 00051 00052 00053 int main() { 00054 bh1726_print_raw_values(); 00055 } 00056
Generated on Wed Jul 13 2022 00:12:36 by
1.7.2

Rohm BH1726NUC | Ambient Light Sensor