920
920
initAS7262 (const uint8_t i2cAddress , WarpI2CDeviceState volatile * deviceStatePointer )
921
921
{
922
922
deviceStatePointer -> i2cAddress = i2cAddress ;
923
- deviceStatePointer -> signalType = ( kWarpTypeMaskLambda450V |
923
+ deviceStatePointer -> signalType = ( kWarpTypeMaskTemperature |
924
+ kWarpTypeMaskLambda450V |
924
925
kWarpTypeMaskLambda500B |
925
926
kWarpTypeMaskLambda550G |
926
927
kWarpTypeMaskLambda570Y |
@@ -936,7 +937,10 @@ readSensorRegisterAS7262(uint8_t deviceRegister)
936
937
/*
937
938
* The sensor has only 3 real registers: STATUS Register 0x00, WRITE Register 0x01 and READ register 0x02.
938
939
*/
939
- uint8_t cmdBuf_write [2 ] = {kWarpI2C_AS726x_SLAVE_WRITE_REG ,0xFF };
940
+ uint8_t cmdBuf_write [2 ] = {kWarpI2C_AS726x_SLAVE_WRITE_REG , 0xFF };
941
+ uint8_t cmdBuf_LEDCTRL [2 ] = {kWarpI2C_AS726x_SLAVE_WRITE_REG , 0x87 };
942
+ uint8_t cmdBuf_LEDON [2 ] = {kWarpI2C_AS726x_SLAVE_WRITE_REG , 0x1B };
943
+ uint8_t cmdBuf_LEDOFF [2 ] = {kWarpI2C_AS726x_SLAVE_WRITE_REG , 0x00 };
940
944
uint8_t cmdBuf_read [1 ] = {kWarpI2C_AS726x_SLAVE_READ_REG };
941
945
i2c_status_t returnValue ;
942
946
@@ -954,7 +958,31 @@ readSensorRegisterAS7262(uint8_t deviceRegister)
954
958
955
959
956
960
cmdBuf_write [1 ] = deviceRegister ;
957
-
961
+
962
+ /*
963
+ * The LED control register details can be found in Figure 26 of AS7262 detailed descriptions on page 26.
964
+ */
965
+ returnValue = I2C_DRV_MasterSendDataBlocking (
966
+ 0 /* I2C peripheral instance */ ,
967
+ & slave /* The pointer to the I2C device information structure */ ,
968
+ cmdBuf_LEDCTRL /* The pointer to the commands to be transferred */ ,
969
+ 2 /* The length in bytes of the commands to be transferred */ ,
970
+ NULL /* The pointer to the data to be transferred */ ,
971
+ 0 /* The length in bytes of the data to be transferred */ ,
972
+ 500 /* timeout in milliseconds */ );
973
+
974
+ /*
975
+ * This turns on the LED before reading the data
976
+ */
977
+ returnValue = I2C_DRV_MasterSendDataBlocking (
978
+ 0 /* I2C peripheral instance */ ,
979
+ & slave /* The pointer to the I2C device information structure */ ,
980
+ cmdBuf_LEDON /* The pointer to the commands to be transferred */ ,
981
+ 2 /* The length in bytes of the commands to be transferred */ ,
982
+ NULL /* The pointer to the data to be transferred */ ,
983
+ 0 /* The length in bytes of the data to be transferred */ ,
984
+ 500 /* timeout in milliseconds */ );
985
+
958
986
/*
959
987
* See Page 8 to Page 11 of AS726X Design Considerations for writing to and reading from virtual registers.
960
988
* Write transaction writes the value of the virtual register one wants to read from to the WRITE register 0x01.
@@ -966,7 +994,7 @@ readSensorRegisterAS7262(uint8_t deviceRegister)
966
994
2 /* The length in bytes of the commands to be transferred */ ,
967
995
NULL /* The pointer to the data to be transferred */ ,
968
996
0 /* The length in bytes of the data to be transferred */ ,
969
- 500 /* timeout in milliseconds */ );
997
+ 500 /* timeout in milliseconds */ );
970
998
971
999
/*
972
1000
* Read transaction which reads from the READ register 0x02.
@@ -979,7 +1007,7 @@ readSensorRegisterAS7262(uint8_t deviceRegister)
979
1007
1 /* The length in bytes of the commands to be transferred */ ,
980
1008
NULL /* The pointer to the data to be transferred */ ,
981
1009
0 /* The length in bytes of the data to be transferred */ ,
982
- 500 /* timeout in milliseconds */ );
1010
+ 500 /* timeout in milliseconds */ );
983
1011
984
1012
returnValue = I2C_DRV_MasterReceiveDataBlocking (
985
1013
0 /* I2C peripheral instance */ ,
@@ -990,6 +1018,27 @@ readSensorRegisterAS7262(uint8_t deviceRegister)
990
1018
1 /* The length in bytes of the data to be transferred and data is transferred from the sensor to master via bus */ ,
991
1019
500 /* timeout in milliseconds */ );
992
1020
1021
+ returnValue = I2C_DRV_MasterSendDataBlocking (
1022
+ 0 /* I2C peripheral instance */ ,
1023
+ & slave /* The pointer to the I2C device information structure */ ,
1024
+ cmdBuf_LEDCTRL /* The pointer to the commands to be transferred */ ,
1025
+ 2 /* The length in bytes of the commands to be transferred */ ,
1026
+ NULL /* The pointer to the data to be transferred */ ,
1027
+ 0 /* The length in bytes of the data to be transferred */ ,
1028
+ 500 /* timeout in milliseconds */ );
1029
+
1030
+ /*
1031
+ * This turns off the LED after finish reading the data
1032
+ */
1033
+ returnValue = I2C_DRV_MasterSendDataBlocking (
1034
+ 0 /* I2C peripheral instance */ ,
1035
+ & slave /* The pointer to the I2C device information structure */ ,
1036
+ cmdBuf_LEDOFF /* The pointer to the commands to be transferred */ ,
1037
+ 2 /* The length in bytes of the commands to be transferred */ ,
1038
+ NULL /* The pointer to the data to be transferred */ ,
1039
+ 0 /* The length in bytes of the data to be transferred */ ,
1040
+ 500 /* timeout in milliseconds */ );
1041
+
993
1042
if (returnValue == kStatus_I2C_Success )
994
1043
{
995
1044
//...
@@ -1006,7 +1055,8 @@ void
1006
1055
initAS7263 (const uint8_t i2cAddress , WarpI2CDeviceState volatile * deviceStatePointer )
1007
1056
{
1008
1057
deviceStatePointer -> i2cAddress = i2cAddress ;
1009
- deviceStatePointer -> signalType = ( kWarpTypeMaskLambda610R |
1058
+ deviceStatePointer -> signalType = ( kWarpTypeMaskTemperature |
1059
+ kWarpTypeMaskLambda610R |
1010
1060
kWarpTypeMaskLambda680S |
1011
1061
kWarpTypeMaskLambda730T |
1012
1062
kWarpTypeMaskLambda760U |
@@ -1016,13 +1066,17 @@ initAS7263(const uint8_t i2cAddress, WarpI2CDeviceState volatile * deviceStateP
1016
1066
return ;
1017
1067
}
1018
1068
1069
+
1019
1070
WarpStatus
1020
1071
readSensorRegisterAS7263 (uint8_t deviceRegister )
1021
1072
{
1022
1073
/*
1023
1074
* The sensor has only 3 real registers: STATUS Register 0x00, WRITE Register 0x01 and READ register 0x02.
1024
1075
*/
1025
1076
uint8_t cmdBuf_write [2 ] = {kWarpI2C_AS726x_SLAVE_WRITE_REG ,0xFF };
1077
+ uint8_t cmdBuf_LEDCTRL [2 ] = {kWarpI2C_AS726x_SLAVE_WRITE_REG , 0x87 };
1078
+ uint8_t cmdBuf_LEDON [2 ] = {kWarpI2C_AS726x_SLAVE_WRITE_REG , 0x1B };
1079
+ uint8_t cmdBuf_LEDOFF [2 ] = {kWarpI2C_AS726x_SLAVE_WRITE_REG , 0x00 };
1026
1080
uint8_t cmdBuf_read [1 ] = {kWarpI2C_AS726x_SLAVE_READ_REG };
1027
1081
i2c_status_t returnValue ;
1028
1082
@@ -1040,7 +1094,31 @@ readSensorRegisterAS7263(uint8_t deviceRegister)
1040
1094
1041
1095
1042
1096
cmdBuf_write [1 ] = deviceRegister ;
1043
-
1097
+
1098
+ /*
1099
+ * The LED control register details can be found in Figure 27 of AS7263 detailed descriptions on page 24.
1100
+ */
1101
+ returnValue = I2C_DRV_MasterSendDataBlocking (
1102
+ 0 /* I2C peripheral instance */ ,
1103
+ & slave /* The pointer to the I2C device information structure */ ,
1104
+ cmdBuf_LEDCTRL /* The pointer to the commands to be transferred */ ,
1105
+ 2 /* The length in bytes of the commands to be transferred */ ,
1106
+ NULL /* The pointer to the data to be transferred */ ,
1107
+ 0 /* The length in bytes of the data to be transferred */ ,
1108
+ 500 /* timeout in milliseconds */ );
1109
+
1110
+ /*
1111
+ * This turns on the LED before reading the data
1112
+ */
1113
+ returnValue = I2C_DRV_MasterSendDataBlocking (
1114
+ 0 /* I2C peripheral instance */ ,
1115
+ & slave /* The pointer to the I2C device information structure */ ,
1116
+ cmdBuf_LEDON /* The pointer to the commands to be transferred */ ,
1117
+ 2 /* The length in bytes of the commands to be transferred */ ,
1118
+ NULL /* The pointer to the data to be transferred */ ,
1119
+ 0 /* The length in bytes of the data to be transferred */ ,
1120
+ 500 /* timeout in milliseconds */ );
1121
+
1044
1122
/*
1045
1123
* See Page 8 to Page 11 of AS726X Design Considerations for writing to and reading from virtual registers.
1046
1124
* Write transaction writes the value of the virtual register one wants to read from to the WRITE register 0x01.
@@ -1076,6 +1154,27 @@ readSensorRegisterAS7263(uint8_t deviceRegister)
1076
1154
1 /* The length in bytes of the data to be transferred and data is transferred from the sensor to master via bus */ ,
1077
1155
500 /* timeout in milliseconds */ );
1078
1156
1157
+ returnValue = I2C_DRV_MasterSendDataBlocking (
1158
+ 0 /* I2C peripheral instance */ ,
1159
+ & slave /* The pointer to the I2C device information structure */ ,
1160
+ cmdBuf_LEDCTRL /* The pointer to the commands to be transferred */ ,
1161
+ 2 /* The length in bytes of the commands to be transferred */ ,
1162
+ NULL /* The pointer to the data to be transferred */ ,
1163
+ 0 /* The length in bytes of the data to be transferred */ ,
1164
+ 500 /* timeout in milliseconds */ );
1165
+
1166
+ /*
1167
+ * This turns off the LED after finish reading the data
1168
+ */
1169
+ returnValue = I2C_DRV_MasterSendDataBlocking (
1170
+ 0 /* I2C peripheral instance */ ,
1171
+ & slave /* The pointer to the I2C device information structure */ ,
1172
+ cmdBuf_LEDOFF /* The pointer to the commands to be transferred */ ,
1173
+ 2 /* The length in bytes of the commands to be transferred */ ,
1174
+ NULL /* The pointer to the data to be transferred */ ,
1175
+ 0 /* The length in bytes of the data to be transferred */ ,
1176
+ 500 /* timeout in milliseconds */ );
1177
+
1079
1178
if (returnValue == kStatus_I2C_Success )
1080
1179
{
1081
1180
//...
@@ -2292,7 +2391,7 @@ main(void)
2292
2391
case 'j' :
2293
2392
{
2294
2393
bool autoIncrement , chatty ;
2295
- int spinDelay , repetitionsPerAddress , chunkReadsPerAddress ;
2394
+ int spinDelay , repetitionsPerAddress , chunkReadsPerAddress , overallNumberOfRepetitions ;
2296
2395
int adaptiveSssupplyMaxMillivolts ;
2297
2396
uint8_t referenceByte ;
2298
2397
@@ -2323,11 +2422,16 @@ main(void)
2323
2422
2324
2423
SEGGER_RTT_WriteString (0 , "\r\n\tReference byte for comparisons (e.g., '3e')> " );brieflyToggleEnablingSWD ();
2325
2424
referenceByte = readHexByte ();
2425
+
2426
+ SEGGER_RTT_WriteString (0 , "\r\n\tOverall number of repetitions (e.g., '0000')> " );brieflyToggleEnablingSWD ();
2427
+ overallNumberOfRepetitions = read4digits ();
2326
2428
2327
2429
SEGGER_RTT_printf (0 , "\r\n\tRepeating dev%d @ 0x%02x, reps=%d, pull=%d, delay=%dms:\n\n" ,
2328
2430
menuTargetSensor , menuRegisterAddress , repetitionsPerAddress , menuI2cPullupEnable , spinDelay );brieflyToggleEnablingSWD ();
2329
2431
2330
- repeatRegisterReadForDeviceAndAddress ( menuTargetSensor /*warpSensorDevice*/ ,
2432
+ for (int i = 0 ; i < overallNumberOfRepetitions ; i ++ )
2433
+ {
2434
+ repeatRegisterReadForDeviceAndAddress ( menuTargetSensor /*warpSensorDevice*/ ,
2331
2435
menuRegisterAddress /*baseAddress */ ,
2332
2436
menuI2cPullupEnable ,
2333
2437
autoIncrement /*autoIncrement*/ ,
@@ -2339,6 +2443,7 @@ main(void)
2339
2443
adaptiveSssupplyMaxMillivolts ,
2340
2444
referenceByte
2341
2445
);
2446
+ }
2342
2447
2343
2448
break ;
2344
2449
}
@@ -3572,4 +3677,4 @@ activateAllLowPowerSensorModes(void)
3572
3677
* For now, simply hold its reset line low.
3573
3678
*/
3574
3679
GPIO_DRV_ClearPinOutput (kWarpPinADXL362_CS_PAN1326_nSHUTD );
3575
- }
3680
+ }
0 commit comments