Skip to content

Commit 942fada

Browse files
committed
Set the LED of AS7263 on while reading data
1 parent 017f761 commit 942fada

File tree

1 file changed

+46
-5
lines changed

1 file changed

+46
-5
lines changed

src/boot/ksdk1.1.0/warp-kl03-ksdk1.1-boot.c

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -957,7 +957,10 @@ readSensorRegisterAS7262(uint8_t deviceRegister)
957957

958958

959959
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+
*/
961964
returnValue = I2C_DRV_MasterSendDataBlocking(
962965
0 /* I2C peripheral instance */,
963966
&slave /* The pointer to the I2C device information structure */,
@@ -968,7 +971,7 @@ readSensorRegisterAS7262(uint8_t deviceRegister)
968971
500 /* timeout in milliseconds */);
969972

970973
/*
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
972975
*/
973976
returnValue = I2C_DRV_MasterSendDataBlocking(
974977
0 /* I2C peripheral instance */,
@@ -1024,7 +1027,7 @@ readSensorRegisterAS7262(uint8_t deviceRegister)
10241027
500 /* timeout in milliseconds */);
10251028

10261029
/*
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
10281031
*/
10291032
returnValue = I2C_DRV_MasterSendDataBlocking(
10301033
0 /* I2C peripheral instance */,
@@ -1035,7 +1038,6 @@ readSensorRegisterAS7262(uint8_t deviceRegister)
10351038
0 /* The length in bytes of the data to be transferred */,
10361039
500 /* timeout in milliseconds */);
10371040

1038-
10391041
if (returnValue == kStatus_I2C_Success)
10401042
{
10411043
//...
@@ -1070,6 +1072,9 @@ readSensorRegisterAS7263(uint8_t deviceRegister)
10701072
* The sensor has only 3 real registers: STATUS Register 0x00, WRITE Register 0x01 and READ register 0x02.
10711073
*/
10721074
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};
10731078
uint8_t cmdBuf_read[1] = {kWarpI2C_AS726x_SLAVE_READ_REG};
10741079
i2c_status_t returnValue;
10751080

@@ -1087,7 +1092,31 @@ readSensorRegisterAS7263(uint8_t deviceRegister)
10871092

10881093

10891094
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+
10911120
/*
10921121
* See Page 8 to Page 11 of AS726X Design Considerations for writing to and reading from virtual registers.
10931122
* 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)
11231152
1 /* The length in bytes of the data to be transferred and data is transferred from the sensor to master via bus */,
11241153
500 /* timeout in milliseconds */);
11251154

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+
11261167
if (returnValue == kStatus_I2C_Success)
11271168
{
11281169
//...

0 commit comments

Comments
 (0)