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-rpr0521 rohm-sensor-hal
Fork of KX022_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-rpr0521/rohm-rpr0521/rpr0521_driver.h" 00020 #include "rohm-rpr0521/rohm-rpr0521/rpr0521.h" 00021 00022 Serial pc(USBTX, USBRX); 00023 00024 void rpr0521_print_one_value(){ 00025 bool error; 00026 uint16_t data[3]; 00027 00028 error = rpr0521_read_data(&data[0]); 00029 if (!error) { 00030 pc.printf("PS[%4u], Als0[%4u], Als1[%4u]\n\r", data[0], data[1], data[2]); 00031 } 00032 else { 00033 pc.printf("\n\r"); 00034 } 00035 } 00036 00037 void rpr0521_print_raw_values(){ 00038 pc.printf("\nRPR0521 library test program.\n\r"); 00039 I2CCommonBegin(); 00040 00041 rpr0521_wait_until_found(); 00042 pc.printf("\nSensor found.\n\r"); 00043 rpr0521_initial_setup(); 00044 wait(1); 00045 00046 while(1) { 00047 rpr0521_print_one_value(); 00048 wait(0.1); 00049 } 00050 } 00051 00052 00053 int main() { 00054 rpr0521_print_raw_values(); 00055 } 00056
Generated on Tue Jul 19 2022 19:13:17 by
1.7.2

Rohm RPR-0521RS | Light & Proximity Sensor