@@ -957,7 +957,10 @@ readSensorRegisterAS7262(uint8_t deviceRegister)
957
957
958
958
959
959
cmdBuf_write [1 ] = deviceRegister ;
960
-
960
+
961
+ /*
962
+ * The LED control register details can be found in Figure 26 of AS7262 detailed descriptions on page 26.
963
+ */
961
964
returnValue = I2C_DRV_MasterSendDataBlocking (
962
965
0 /* I2C peripheral instance */ ,
963
966
& slave /* The pointer to the I2C device information structure */ ,
@@ -968,7 +971,7 @@ readSensorRegisterAS7262(uint8_t deviceRegister)
968
971
500 /* timeout in milliseconds */ );
969
972
970
973
/*
971
- * The LED control register details can be found in Figure 26 of AS7262 detailed descriptions on page 26.
974
+ * This turns on the LED before reading the data
972
975
*/
973
976
returnValue = I2C_DRV_MasterSendDataBlocking (
974
977
0 /* I2C peripheral instance */ ,
@@ -1024,7 +1027,7 @@ readSensorRegisterAS7262(uint8_t deviceRegister)
1024
1027
500 /* timeout in milliseconds */ );
1025
1028
1026
1029
/*
1027
- * The LED control register details can be found in Figure 26 of AS7262 detailed descriptions on page 26.
1030
+ * This turns off the LED after finish reading the data
1028
1031
*/
1029
1032
returnValue = I2C_DRV_MasterSendDataBlocking (
1030
1033
0 /* I2C peripheral instance */ ,
@@ -1035,7 +1038,6 @@ readSensorRegisterAS7262(uint8_t deviceRegister)
1035
1038
0 /* The length in bytes of the data to be transferred */ ,
1036
1039
500 /* timeout in milliseconds */ );
1037
1040
1038
-
1039
1041
if (returnValue == kStatus_I2C_Success )
1040
1042
{
1041
1043
//...
@@ -1070,6 +1072,9 @@ readSensorRegisterAS7263(uint8_t deviceRegister)
1070
1072
* The sensor has only 3 real registers: STATUS Register 0x00, WRITE Register 0x01 and READ register 0x02.
1071
1073
*/
1072
1074
uint8_t cmdBuf_write [2 ] = {kWarpI2C_AS726x_SLAVE_WRITE_REG ,0xFF };
1075
+ uint8_t cmdBuf_LEDCTRL [2 ] = {kWarpI2C_AS726x_SLAVE_WRITE_REG , 0x87 };
1076
+ uint8_t cmdBuf_LEDON [2 ] = {kWarpI2C_AS726x_SLAVE_WRITE_REG , 0x1B };
1077
+ uint8_t cmdBuf_LEDOFF [2 ] = {kWarpI2C_AS726x_SLAVE_WRITE_REG , 0x00 };
1073
1078
uint8_t cmdBuf_read [1 ] = {kWarpI2C_AS726x_SLAVE_READ_REG };
1074
1079
i2c_status_t returnValue ;
1075
1080
@@ -1087,7 +1092,31 @@ readSensorRegisterAS7263(uint8_t deviceRegister)
1087
1092
1088
1093
1089
1094
cmdBuf_write [1 ] = deviceRegister ;
1090
-
1095
+
1096
+ /*
1097
+ * The LED control register details can be found in Figure 27 of AS7263 detailed descriptions on page 24.
1098
+ */
1099
+ returnValue = I2C_DRV_MasterSendDataBlocking (
1100
+ 0 /* I2C peripheral instance */ ,
1101
+ & slave /* The pointer to the I2C device information structure */ ,
1102
+ cmdBuf_LEDCTRL /* The pointer to the commands to be transferred */ ,
1103
+ 2 /* The length in bytes of the commands to be transferred */ ,
1104
+ NULL /* The pointer to the data to be transferred */ ,
1105
+ 0 /* The length in bytes of the data to be transferred */ ,
1106
+ 500 /* timeout in milliseconds */ );
1107
+
1108
+ /*
1109
+ * This turns on the LED before reading the data
1110
+ */
1111
+ returnValue = I2C_DRV_MasterSendDataBlocking (
1112
+ 0 /* I2C peripheral instance */ ,
1113
+ & slave /* The pointer to the I2C device information structure */ ,
1114
+ cmdBuf_LEDON /* The pointer to the commands to be transferred */ ,
1115
+ 2 /* The length in bytes of the commands to be transferred */ ,
1116
+ NULL /* The pointer to the data to be transferred */ ,
1117
+ 0 /* The length in bytes of the data to be transferred */ ,
1118
+ 500 /* timeout in milliseconds */ );
1119
+
1091
1120
/*
1092
1121
* See Page 8 to Page 11 of AS726X Design Considerations for writing to and reading from virtual registers.
1093
1122
* Write transaction writes the value of the virtual register one wants to read from to the WRITE register 0x01.
@@ -1123,6 +1152,18 @@ readSensorRegisterAS7263(uint8_t deviceRegister)
1123
1152
1 /* The length in bytes of the data to be transferred and data is transferred from the sensor to master via bus */ ,
1124
1153
500 /* timeout in milliseconds */ );
1125
1154
1155
+ /*
1156
+ * This turns off the LED after finish reading the data
1157
+ */
1158
+ returnValue = I2C_DRV_MasterSendDataBlocking (
1159
+ 0 /* I2C peripheral instance */ ,
1160
+ & slave /* The pointer to the I2C device information structure */ ,
1161
+ cmdBuf_LEDOFF /* The pointer to the commands to be transferred */ ,
1162
+ 2 /* The length in bytes of the commands to be transferred */ ,
1163
+ NULL /* The pointer to the data to be transferred */ ,
1164
+ 0 /* The length in bytes of the data to be transferred */ ,
1165
+ 500 /* timeout in milliseconds */ );
1166
+
1126
1167
if (returnValue == kStatus_I2C_Success )
1127
1168
{
1128
1169
//...
0 commit comments