sdasd

Revision:
3:83c4958e4bdc
Parent:
1:145f11782373
diff -r 145f11782373 -r 83c4958e4bdc source/rpr0521_driver.cpp
--- a/source/rpr0521_driver.cpp	Tue Sep 20 11:15:09 2016 +0000
+++ b/source/rpr0521_driver.cpp	Thu Jul 01 15:47:03 2021 +0000
@@ -22,16 +22,16 @@
 
 /* rpr0521 driver*/
 
-uint8_t rpr0521_readId(){
+uint8_t rpr0521_readId(int n){
     uint8_t id;
     uint8_t read_bytes;
 
-    read_bytes = read_register(SAD, RPR0521_MANUFACT, &id, 1);
+    read_bytes = read_register(SAD, RPR0521_MANUFACT, &id, 1,n);
     if ( read_bytes > 0 ){
         uint8_t partid;
 
         DEBUG_printf("Manufacturer: %u\n\r", id);
-        read_bytes = read_register(SAD, RPR0521_SYSTEM_CONTROL, &partid, 1);
+        read_bytes = read_register(SAD, RPR0521_SYSTEM_CONTROL, &partid, 1,n);
         if ( read_bytes > 0 ){
             DEBUG_printf("Part ID: %u\n\r", (partid & 0b00111111) );
         return(partid);
@@ -47,51 +47,51 @@
     }
 }
 
-void rpr0521_wait_until_found(){
+void rpr0521_wait_until_found(int n){
     uint8_t id;
     
-    id = rpr0521_readId();
+    id = rpr0521_readId(n);
     while (id == 255){
         wait(100);
-        id = rpr0521_readId();
+        id = rpr0521_readId(n);
         }
     return;
 }
 
 void rpr0521_soft_reset(){
-    write_register(SAD, RPR0521_SYSTEM_CONTROL, RPR0521_SYSTEM_CONTROL_SW_RESET_START);
+    write_register(SAD, RPR0521_SYSTEM_CONTROL, RPR0521_SYSTEM_CONTROL_SW_RESET_START,0);
 }
 
 void rpr0521_clear_interrupt(){
-    write_register(SAD, RPR0521_SYSTEM_CONTROL, RPR0521_SYSTEM_CONTROL_INT_PIN_HI_Z);
+    write_register(SAD, RPR0521_SYSTEM_CONTROL, RPR0521_SYSTEM_CONTROL_INT_PIN_HI_Z,0);
 }
 
-void rpr0521_initial_setup(){
+void rpr0521_initial_setup(int n){
     write_register(SAD, RPR0521_ALS_PS_CONTROL,
         (RPR0521_ALS_PS_CONTROL_ALS_DATA0_GAIN_X1 | 
          RPR0521_ALS_PS_CONTROL_ALS_DATA1_GAIN_X1 | 
-         RPR0521_ALS_PS_CONTROL_LED_CURRENT_25MA)
+         RPR0521_ALS_PS_CONTROL_LED_CURRENT_25MA), n
         );
     write_register(SAD, RPR0521_PS_CONTROL,
         (RPR0521_PS_CONTROL_PS_GAIN_X1 |
-         RPR0521_PS_CONTROL_PERSISTENCE_DRDY )
+         RPR0521_PS_CONTROL_PERSISTENCE_DRDY ),n
         );
     write_register(SAD, RPR0521_MODE_CONTROL,
         (RPR0521_MODE_CONTROL_ALS_EN_TRUE | RPR0521_MODE_CONTROL_PS_EN_TRUE |
          RPR0521_MODE_CONTROL_PS_PULSE_200US | RPR0521_MODE_CONTROL_PS_OPERATING_MODE_NORMAL |
-         RPR0521_MODE_CONTROL_MEASUREMENT_TIME_100MS_100MS)
+         RPR0521_MODE_CONTROL_MEASUREMENT_TIME_100MS_100MS), n
         );
 }
 
 /* input param: data16, pointer to 3*16bit memory 
    return: error, true/false */
-bool rpr0521_read_data(uint16_t* data16){
+bool rpr0521_read_data(uint16_t* data16,int n){
     #define RPR0521_DATA_LEN 6
 
     uint8_t data[RPR0521_DATA_LEN];
     uint8_t read_bytes;
 
-    read_bytes = read_register(SAD, RPR0521_PS_DATA_LSBS, &data[0], RPR0521_DATA_LEN);
+    read_bytes = read_register(SAD, RPR0521_PS_DATA_LSBS, &data[0], RPR0521_DATA_LEN,n);
     if (read_bytes == RPR0521_DATA_LEN){
         data16[0] = (data[0]) | (data[1] << 8); //ps_data
         data16[1] = (data[2]) | (data[3] << 8); //als_data0