@@ -936,7 +936,10 @@ readSensorRegisterAS7262(uint8_t deviceRegister)
936
936
/*
937
937
* The sensor has only 3 real registers: STATUS Register 0x00, WRITE Register 0x01 and READ register 0x02.
938
938
*/
939
- uint8_t cmdBuf_write [2 ] = {kWarpI2C_AS726x_SLAVE_WRITE_REG ,0xFF };
939
+ uint8_t cmdBuf_write [2 ] = {kWarpI2C_AS726x_SLAVE_WRITE_REG , 0xFF };
940
+ uint8_t cmdBuf_LEDCTRL [2 ] = {kWarpI2C_AS726x_SLAVE_WRITE_REG , 0x87 };
941
+ uint8_t cmdBuf_LEDON [2 ] = {kWarpI2C_AS726x_SLAVE_WRITE_REG , 0x1B };
942
+ uint8_t cmdBuf_LEDOFF [2 ] = {kWarpI2C_AS726x_SLAVE_WRITE_REG , 0x00 };
940
943
uint8_t cmdBuf_read [1 ] = {kWarpI2C_AS726x_SLAVE_READ_REG };
941
944
i2c_status_t returnValue ;
942
945
@@ -955,6 +958,27 @@ readSensorRegisterAS7262(uint8_t deviceRegister)
955
958
956
959
cmdBuf_write [1 ] = deviceRegister ;
957
960
961
+ returnValue = I2C_DRV_MasterSendDataBlocking (
962
+ 0 /* I2C peripheral instance */ ,
963
+ & slave /* The pointer to the I2C device information structure */ ,
964
+ cmdBuf_LEDCTRL /* The pointer to the commands to be transferred */ ,
965
+ 2 /* The length in bytes of the commands to be transferred */ ,
966
+ NULL /* The pointer to the data to be transferred */ ,
967
+ 0 /* The length in bytes of the data to be transferred */ ,
968
+ 500 /* timeout in milliseconds */ );
969
+
970
+ /*
971
+ * The LED control register details can be found in Figure 26 of AS7262 detailed descriptions on page 26.
972
+ */
973
+ returnValue = I2C_DRV_MasterSendDataBlocking (
974
+ 0 /* I2C peripheral instance */ ,
975
+ & slave /* The pointer to the I2C device information structure */ ,
976
+ cmdBuf_LEDON /* The pointer to the commands to be transferred */ ,
977
+ 2 /* The length in bytes of the commands to be transferred */ ,
978
+ NULL /* The pointer to the data to be transferred */ ,
979
+ 0 /* The length in bytes of the data to be transferred */ ,
980
+ 500 /* timeout in milliseconds */ );
981
+
958
982
/*
959
983
* See Page 8 to Page 11 of AS726X Design Considerations for writing to and reading from virtual registers.
960
984
* Write transaction writes the value of the virtual register one wants to read from to the WRITE register 0x01.
@@ -966,7 +990,7 @@ readSensorRegisterAS7262(uint8_t deviceRegister)
966
990
2 /* The length in bytes of the commands to be transferred */ ,
967
991
NULL /* The pointer to the data to be transferred */ ,
968
992
0 /* The length in bytes of the data to be transferred */ ,
969
- 500 /* timeout in milliseconds */ );
993
+ 500 /* timeout in milliseconds */ );
970
994
971
995
/*
972
996
* Read transaction which reads from the READ register 0x02.
@@ -979,7 +1003,7 @@ readSensorRegisterAS7262(uint8_t deviceRegister)
979
1003
1 /* The length in bytes of the commands to be transferred */ ,
980
1004
NULL /* The pointer to the data to be transferred */ ,
981
1005
0 /* The length in bytes of the data to be transferred */ ,
982
- 500 /* timeout in milliseconds */ );
1006
+ 500 /* timeout in milliseconds */ );
983
1007
984
1008
returnValue = I2C_DRV_MasterReceiveDataBlocking (
985
1009
0 /* I2C peripheral instance */ ,
@@ -990,6 +1014,28 @@ readSensorRegisterAS7262(uint8_t deviceRegister)
990
1014
1 /* The length in bytes of the data to be transferred and data is transferred from the sensor to master via bus */ ,
991
1015
500 /* timeout in milliseconds */ );
992
1016
1017
+ returnValue = I2C_DRV_MasterSendDataBlocking (
1018
+ 0 /* I2C peripheral instance */ ,
1019
+ & slave /* The pointer to the I2C device information structure */ ,
1020
+ cmdBuf_LEDCTRL /* The pointer to the commands to be transferred */ ,
1021
+ 2 /* The length in bytes of the commands to be transferred */ ,
1022
+ NULL /* The pointer to the data to be transferred */ ,
1023
+ 0 /* The length in bytes of the data to be transferred */ ,
1024
+ 500 /* timeout in milliseconds */ );
1025
+
1026
+ /*
1027
+ * The LED control register details can be found in Figure 26 of AS7262 detailed descriptions on page 26.
1028
+ */
1029
+ returnValue = I2C_DRV_MasterSendDataBlocking (
1030
+ 0 /* I2C peripheral instance */ ,
1031
+ & slave /* The pointer to the I2C device information structure */ ,
1032
+ cmdBuf_LEDOFF /* The pointer to the commands to be transferred */ ,
1033
+ 2 /* The length in bytes of the commands to be transferred */ ,
1034
+ NULL /* The pointer to the data to be transferred */ ,
1035
+ 0 /* The length in bytes of the data to be transferred */ ,
1036
+ 500 /* timeout in milliseconds */ );
1037
+
1038
+
993
1039
if (returnValue == kStatus_I2C_Success )
994
1040
{
995
1041
//...
@@ -1016,6 +1062,7 @@ initAS7263(const uint8_t i2cAddress, WarpI2CDeviceState volatile * deviceStateP
1016
1062
return ;
1017
1063
}
1018
1064
1065
+
1019
1066
WarpStatus
1020
1067
readSensorRegisterAS7263 (uint8_t deviceRegister )
1021
1068
{
0 commit comments