Skip to content

Commit 017f761

Browse files
committed
Set the LED of AS7262 on while reading data
1 parent 4c4b1be commit 017f761

File tree

1 file changed

+50
-3
lines changed

1 file changed

+50
-3
lines changed

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

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -936,7 +936,10 @@ readSensorRegisterAS7262(uint8_t deviceRegister)
936936
/*
937937
* The sensor has only 3 real registers: STATUS Register 0x00, WRITE Register 0x01 and READ register 0x02.
938938
*/
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};
940943
uint8_t cmdBuf_read[1] = {kWarpI2C_AS726x_SLAVE_READ_REG};
941944
i2c_status_t returnValue;
942945

@@ -955,6 +958,27 @@ readSensorRegisterAS7262(uint8_t deviceRegister)
955958

956959
cmdBuf_write[1] = deviceRegister;
957960

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+
958982
/*
959983
* See Page 8 to Page 11 of AS726X Design Considerations for writing to and reading from virtual registers.
960984
* 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)
966990
2 /* The length in bytes of the commands to be transferred */,
967991
NULL /* The pointer to the data to be transferred */,
968992
0 /* The length in bytes of the data to be transferred */,
969-
500 /* timeout in milliseconds */);
993+
500 /* timeout in milliseconds */);
970994

971995
/*
972996
* Read transaction which reads from the READ register 0x02.
@@ -979,7 +1003,7 @@ readSensorRegisterAS7262(uint8_t deviceRegister)
9791003
1 /* The length in bytes of the commands to be transferred */,
9801004
NULL /* The pointer to the data to be transferred */,
9811005
0 /* The length in bytes of the data to be transferred */,
982-
500 /* timeout in milliseconds */);
1006+
500 /* timeout in milliseconds */);
9831007

9841008
returnValue = I2C_DRV_MasterReceiveDataBlocking(
9851009
0 /* I2C peripheral instance */,
@@ -990,6 +1014,28 @@ readSensorRegisterAS7262(uint8_t deviceRegister)
9901014
1 /* The length in bytes of the data to be transferred and data is transferred from the sensor to master via bus */,
9911015
500 /* timeout in milliseconds */);
9921016

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+
9931039
if (returnValue == kStatus_I2C_Success)
9941040
{
9951041
//...
@@ -1016,6 +1062,7 @@ initAS7263(const uint8_t i2cAddress, WarpI2CDeviceState volatile * deviceStateP
10161062
return;
10171063
}
10181064

1065+
10191066
WarpStatus
10201067
readSensorRegisterAS7263(uint8_t deviceRegister)
10211068
{

0 commit comments

Comments
 (0)