diff --git a/src/boot/ksdk1.1.0/warp-kl03-ksdk1.1-boot.c b/src/boot/ksdk1.1.0/warp-kl03-ksdk1.1-boot.c index cdb8d2304..f4d8907f9 100755 --- a/src/boot/ksdk1.1.0/warp-kl03-ksdk1.1-boot.c +++ b/src/boot/ksdk1.1.0/warp-kl03-ksdk1.1-boot.c @@ -920,7 +920,8 @@ void initAS7262(const uint8_t i2cAddress, WarpI2CDeviceState volatile * deviceStatePointer) { deviceStatePointer->i2cAddress = i2cAddress; - deviceStatePointer->signalType = ( kWarpTypeMaskLambda450V | + deviceStatePointer->signalType = ( kWarpTypeMaskTemperature| + kWarpTypeMaskLambda450V | kWarpTypeMaskLambda500B | kWarpTypeMaskLambda550G | kWarpTypeMaskLambda570Y | @@ -936,7 +937,10 @@ readSensorRegisterAS7262(uint8_t deviceRegister) /* * The sensor has only 3 real registers: STATUS Register 0x00, WRITE Register 0x01 and READ register 0x02. */ - uint8_t cmdBuf_write[2] = {kWarpI2C_AS726x_SLAVE_WRITE_REG,0xFF}; + uint8_t cmdBuf_write[2] = {kWarpI2C_AS726x_SLAVE_WRITE_REG, 0xFF}; + uint8_t cmdBuf_LEDCTRL[2] = {kWarpI2C_AS726x_SLAVE_WRITE_REG, 0x87}; + uint8_t cmdBuf_LEDON[2] = {kWarpI2C_AS726x_SLAVE_WRITE_REG, 0x1B}; + uint8_t cmdBuf_LEDOFF[2] = {kWarpI2C_AS726x_SLAVE_WRITE_REG, 0x00}; uint8_t cmdBuf_read[1] = {kWarpI2C_AS726x_SLAVE_READ_REG}; i2c_status_t returnValue; @@ -954,7 +958,31 @@ readSensorRegisterAS7262(uint8_t deviceRegister) cmdBuf_write[1] = deviceRegister; - + + /* + * The LED control register details can be found in Figure 26 of AS7262 detailed descriptions on page 26. + */ + returnValue = I2C_DRV_MasterSendDataBlocking( + 0 /* I2C peripheral instance */, + &slave /* The pointer to the I2C device information structure */, + cmdBuf_LEDCTRL /* The pointer to the commands to be transferred */, + 2 /* The length in bytes of the commands to be transferred */, + NULL /* The pointer to the data to be transferred */, + 0 /* The length in bytes of the data to be transferred */, + 500 /* timeout in milliseconds */); + + /* + * This turns on the LED before reading the data + */ + returnValue = I2C_DRV_MasterSendDataBlocking( + 0 /* I2C peripheral instance */, + &slave /* The pointer to the I2C device information structure */, + cmdBuf_LEDON /* The pointer to the commands to be transferred */, + 2 /* The length in bytes of the commands to be transferred */, + NULL /* The pointer to the data to be transferred */, + 0 /* The length in bytes of the data to be transferred */, + 500 /* timeout in milliseconds */); + /* * See Page 8 to Page 11 of AS726X Design Considerations for writing to and reading from virtual registers. * 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) 2 /* The length in bytes of the commands to be transferred */, NULL /* The pointer to the data to be transferred */, 0 /* The length in bytes of the data to be transferred */, - 500 /* timeout in milliseconds */); + 500 /* timeout in milliseconds */); /* * Read transaction which reads from the READ register 0x02. @@ -979,7 +1007,7 @@ readSensorRegisterAS7262(uint8_t deviceRegister) 1 /* The length in bytes of the commands to be transferred */, NULL /* The pointer to the data to be transferred */, 0 /* The length in bytes of the data to be transferred */, - 500 /* timeout in milliseconds */); + 500 /* timeout in milliseconds */); returnValue = I2C_DRV_MasterReceiveDataBlocking( 0 /* I2C peripheral instance */, @@ -990,6 +1018,27 @@ readSensorRegisterAS7262(uint8_t deviceRegister) 1 /* The length in bytes of the data to be transferred and data is transferred from the sensor to master via bus */, 500 /* timeout in milliseconds */); + returnValue = I2C_DRV_MasterSendDataBlocking( + 0 /* I2C peripheral instance */, + &slave /* The pointer to the I2C device information structure */, + cmdBuf_LEDCTRL /* The pointer to the commands to be transferred */, + 2 /* The length in bytes of the commands to be transferred */, + NULL /* The pointer to the data to be transferred */, + 0 /* The length in bytes of the data to be transferred */, + 500 /* timeout in milliseconds */); + + /* + * This turns off the LED after finish reading the data + */ + returnValue = I2C_DRV_MasterSendDataBlocking( + 0 /* I2C peripheral instance */, + &slave /* The pointer to the I2C device information structure */, + cmdBuf_LEDOFF /* The pointer to the commands to be transferred */, + 2 /* The length in bytes of the commands to be transferred */, + NULL /* The pointer to the data to be transferred */, + 0 /* The length in bytes of the data to be transferred */, + 500 /* timeout in milliseconds */); + if (returnValue == kStatus_I2C_Success) { //... @@ -1006,7 +1055,8 @@ void initAS7263(const uint8_t i2cAddress, WarpI2CDeviceState volatile * deviceStatePointer) { deviceStatePointer->i2cAddress = i2cAddress; - deviceStatePointer->signalType = ( kWarpTypeMaskLambda610R | + deviceStatePointer->signalType = ( kWarpTypeMaskTemperature| + kWarpTypeMaskLambda610R | kWarpTypeMaskLambda680S | kWarpTypeMaskLambda730T | kWarpTypeMaskLambda760U | @@ -1016,6 +1066,7 @@ initAS7263(const uint8_t i2cAddress, WarpI2CDeviceState volatile * deviceStateP return; } + WarpStatus readSensorRegisterAS7263(uint8_t deviceRegister) { @@ -1023,6 +1074,9 @@ readSensorRegisterAS7263(uint8_t deviceRegister) * The sensor has only 3 real registers: STATUS Register 0x00, WRITE Register 0x01 and READ register 0x02. */ uint8_t cmdBuf_write[2] = {kWarpI2C_AS726x_SLAVE_WRITE_REG,0xFF}; + uint8_t cmdBuf_LEDCTRL[2] = {kWarpI2C_AS726x_SLAVE_WRITE_REG, 0x87}; + uint8_t cmdBuf_LEDON[2] = {kWarpI2C_AS726x_SLAVE_WRITE_REG, 0x1B}; + uint8_t cmdBuf_LEDOFF[2] = {kWarpI2C_AS726x_SLAVE_WRITE_REG, 0x00}; uint8_t cmdBuf_read[1] = {kWarpI2C_AS726x_SLAVE_READ_REG}; i2c_status_t returnValue; @@ -1040,7 +1094,31 @@ readSensorRegisterAS7263(uint8_t deviceRegister) cmdBuf_write[1] = deviceRegister; - + +/* + * The LED control register details can be found in Figure 27 of AS7263 detailed descriptions on page 24. + */ +returnValue = I2C_DRV_MasterSendDataBlocking( + 0 /* I2C peripheral instance */, + &slave /* The pointer to the I2C device information structure */, + cmdBuf_LEDCTRL /* The pointer to the commands to be transferred */, + 2 /* The length in bytes of the commands to be transferred */, + NULL /* The pointer to the data to be transferred */, + 0 /* The length in bytes of the data to be transferred */, + 500 /* timeout in milliseconds */); + +/* + * This turns on the LED before reading the data + */ +returnValue = I2C_DRV_MasterSendDataBlocking( + 0 /* I2C peripheral instance */, + &slave /* The pointer to the I2C device information structure */, + cmdBuf_LEDON /* The pointer to the commands to be transferred */, + 2 /* The length in bytes of the commands to be transferred */, + NULL /* The pointer to the data to be transferred */, + 0 /* The length in bytes of the data to be transferred */, + 500 /* timeout in milliseconds */); + /* * See Page 8 to Page 11 of AS726X Design Considerations for writing to and reading from virtual registers. * 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) 1 /* The length in bytes of the data to be transferred and data is transferred from the sensor to master via bus */, 500 /* timeout in milliseconds */); + returnValue = I2C_DRV_MasterSendDataBlocking( + 0 /* I2C peripheral instance */, + &slave /* The pointer to the I2C device information structure */, + cmdBuf_LEDCTRL /* The pointer to the commands to be transferred */, + 2 /* The length in bytes of the commands to be transferred */, + NULL /* The pointer to the data to be transferred */, + 0 /* The length in bytes of the data to be transferred */, + 500 /* timeout in milliseconds */); + + /* + * This turns off the LED after finish reading the data + */ + returnValue = I2C_DRV_MasterSendDataBlocking( + 0 /* I2C peripheral instance */, + &slave /* The pointer to the I2C device information structure */, + cmdBuf_LEDOFF /* The pointer to the commands to be transferred */, + 2 /* The length in bytes of the commands to be transferred */, + NULL /* The pointer to the data to be transferred */, + 0 /* The length in bytes of the data to be transferred */, + 500 /* timeout in milliseconds */); + if (returnValue == kStatus_I2C_Success) { //... @@ -2292,7 +2391,7 @@ main(void) case 'j': { bool autoIncrement, chatty; - int spinDelay, repetitionsPerAddress, chunkReadsPerAddress; + int spinDelay, repetitionsPerAddress, chunkReadsPerAddress, overallNumberOfRepetitions; int adaptiveSssupplyMaxMillivolts; uint8_t referenceByte; @@ -2323,11 +2422,16 @@ main(void) SEGGER_RTT_WriteString(0, "\r\n\tReference byte for comparisons (e.g., '3e')> ");brieflyToggleEnablingSWD(); referenceByte = readHexByte(); + + SEGGER_RTT_WriteString(0, "\r\n\tOverall number of repetitions (e.g., '0000')> ");brieflyToggleEnablingSWD(); + overallNumberOfRepetitions = read4digits(); SEGGER_RTT_printf(0, "\r\n\tRepeating dev%d @ 0x%02x, reps=%d, pull=%d, delay=%dms:\n\n", menuTargetSensor, menuRegisterAddress, repetitionsPerAddress, menuI2cPullupEnable, spinDelay);brieflyToggleEnablingSWD(); - repeatRegisterReadForDeviceAndAddress( menuTargetSensor /*warpSensorDevice*/, + for (int i = 0; i < overallNumberOfRepetitions; i++) + { + repeatRegisterReadForDeviceAndAddress( menuTargetSensor /*warpSensorDevice*/, menuRegisterAddress /*baseAddress */, menuI2cPullupEnable, autoIncrement /*autoIncrement*/, @@ -2339,6 +2443,7 @@ main(void) adaptiveSssupplyMaxMillivolts, referenceByte ); + } break; } @@ -3572,4 +3677,4 @@ activateAllLowPowerSensorModes(void) * For now, simply hold its reset line low. */ GPIO_DRV_ClearPinOutput(kWarpPinADXL362_CS_PAN1326_nSHUTD); -} \ No newline at end of file +}