diff --git a/Core/Src/sts_cmox_hmac_sha.c b/Core/Src/sts_cmox_hmac_sha.c index ed4438e..b09541e 100644 --- a/Core/Src/sts_cmox_hmac_sha.c +++ b/Core/Src/sts_cmox_hmac_sha.c @@ -34,30 +34,18 @@ hmac_result_t hmac_result; uint32_t sts_hmac_verify(void) { - uint8_t i=0; - uint8_t uid[8]=""; + uint8_t uid[8]={0x0}; uint32_t ret=0; hmac_result.ac_pass = 60; hmac_result.hmac_tag_size = 0; GetUniqueId(uid); ret = sts_hmac_sha1((const uint8_t *) mKey, sizeof(mKey), (const uint8_t*)(uid+4), 4, &hmac_result); - for (i=0;i 10)? periodicity : 10; // in seconds unit TxPeriodicity= periodicity*1000; // to ms - if ((sts_cfg_nvm.ac[0] ==0x0 )&& (sts_cfg_nvm.ac[19]==0x0)) - { - OnTxPeriodicityChanged(APP_TX_DUTYCYCLE); // in msec unit - - } else - { // ensure it's not in production yet - OnTxPeriodicityChanged(TxPeriodicity); // in msec unit - } - uint32_t samplingperiodicity = (sts_cfg_nvm.sampling); //Heart-beat or Sampling interval if ((char)sts_cfg_nvm.s_unit =='M') { samplingperiodicity *= 60; @@ -2054,16 +2045,25 @@ void OnRestoreSTSCFGContextProcess(void) samplingperiodicity *= 1; } - //Heart-beat or Sampling interval - samplingperiodicity = (samplingperiodicity > 0)? samplingperiodicity : 1; // in seconds unit - HeartBeatPeriodicity = samplingperiodicity*1000; + if ((sts_cfg_nvm.ac[0] ==0x0 )&& (sts_cfg_nvm.ac[19]==0x0)) + { + OnTxPeriodicityChanged(APP_TX_DUTYCYCLE); // in msec unit + OnYunhornSTSHeartBeatPeriodicityChanged(HeartBeatPeriodicity); + } else + { // ensure it's not in production yet + OnTxPeriodicityChanged(TxPeriodicity); // in msec unit + //Heart-beat or Sampling interval + samplingperiodicity = (samplingperiodicity > 0)? samplingperiodicity : 1; // in seconds unit + HeartBeatPeriodicity = samplingperiodicity*1000; + #if defined(YUNHORN_STS_O6_ENABLED) ||defined(YUNHORN_STS_O5_ENABLED) - OnYunhornSTSSamplingPeriodicityChanged(HeartBeatPeriodicity); // in m-sec unit + OnYunhornSTSSamplingPeriodicityChanged(HeartBeatPeriodicity); // in m-sec unit #endif #if defined(YUNHORN_STS_R0_ENABLED)||defined(YUNHORN_STS_R5_ENABLED) - OnYunhornSTSHeartBeatPeriodicityChanged(HeartBeatPeriodicity); + OnYunhornSTSHeartBeatPeriodicityChanged(HeartBeatPeriodicity); #endif + } sts_work_mode = sts_cfg_nvm.work_mode; sts_service_mask = sts_cfg_nvm.sts_service_mask; diff --git a/STM32CubeIDE/.settings/language.settings.xml b/STM32CubeIDE/.settings/language.settings.xml index 90dc1e6..0faf4e3 100644 --- a/STM32CubeIDE/.settings/language.settings.xml +++ b/STM32CubeIDE/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -16,7 +16,7 @@ - + diff --git a/TOF/App/app_tof_vl53l0x_range.c b/TOF/App/app_tof_vl53l0x_range.c index cf060a9..87c0a50 100644 --- a/TOF/App/app_tof_vl53l0x_range.c +++ b/TOF/App/app_tof_vl53l0x_range.c @@ -44,6 +44,7 @@ * @defgroup ErrCode Errors code shown on display * @{ */ +#define STS_MAX_L0_RANGE ((uint32_t) 2000) #define ERR_DETECT -1 #define ERR_DEMO_RANGE_ONE 1 #define ERR_DEMO_RANGE_MULTI 2 @@ -153,7 +154,7 @@ int sts_tof_vl53l0x_DetectSensors(void) do { /* Set I2C standard mode (400 KHz) before doing the first register access */ //if (status == VL53L0X_ERROR_NONE) - //status = VL53L0X_WrByte(pDev, 0x88, 0x00); + status = VL53L0X_WrByte(pDev, 0x88, 0x00); /* Try to read one register using default 0x52 address */ status = VL53L0X_RdWord(pDev, VL53L0X_REG_IDENTIFICATION_MODEL_ID, &Id); @@ -172,21 +173,23 @@ int sts_tof_vl53l0x_DetectSensors(void) pDev->I2cDevAddr = FinalAddress; /* Check all is OK with the new I2C address and initialize the sensor */ status = VL53L0X_RdWord(pDev, VL53L0X_REG_IDENTIFICATION_MODEL_ID, &Id); + if (status !=0) + { + APP_LOG(TS_OFF, VLEVEL_H, "#i VL53L0X_RdWord fail\r\n"); + break; + } status = VL53L0X_DataInit(pDev); if( status == 0 ){ pDev->Present = 1; - //APP_LOG(TS_OFF, VLEVEL_H, "#%u VL53L0X_SetDeviceAddress to 0x%02x\r\n",i, pDev->I2cDevAddr); - - nDevPresent++; - nDevMask |= 1 << i; - pDev->Present = 1; - APP_LOG(TS_OFF, VLEVEL_H, "VL53L0X %d Present and initiated to final 0x%2x, Position Mask=0x%02x\r\n", pDev->Id, pDev->I2cDevAddr, nDevMask); - } else{ APP_LOG(TS_OFF, VLEVEL_H, "VL53L0X_DataInit %d fail\r\n", Id); break; } + nDevPresent++; + nDevMask |= 1 << i; + pDev->Present = 1; + APP_LOG(TS_OFF, VLEVEL_H, "VL53L0X %d Present and initiated to final 0x%2x, Position Mask=0x%02x\r\n", pDev->Id, pDev->I2cDevAddr, nDevMask); } else { APP_LOG(TS_OFF, VLEVEL_H, "# unknown ID %x\r\n", Id); @@ -344,9 +347,9 @@ void STS_TOF250_Range_Process(void) int i2c_time_out = I2C_TIME_OUT_BASE + count*I2C_TIME_OUT_BYTE; sensor_data_ready = 0 ; - sts_tof_distance_data[0] = 0; - sts_tof_distance_data[1] = 0; - sts_tof_distance_data[2] = 0; + sts_tof_distance_data[0] = STS_MAX_L0_RANGE; + sts_tof_distance_data[1] = STS_MAX_L0_RANGE; + sts_tof_distance_data[2] = STS_MAX_L0_RANGE; status = HAL_I2C_Master_Receive(&hi2c2, TOF250_I2C_ADDR, pdata, count, i2c_time_out); if (status == HAL_OK) { @@ -367,17 +370,15 @@ void STS_TOF_VL53L0X_Range_Process(void) nSensorPresent = sts_tof_vl53l0x_DetectSensors(); // confirm sensor online APP_LOG(TS_OFF, VLEVEL_H, "\r\n %u pcs sensor(s) online \r\n", nSensorPresent); } - sts_tof_distance_data[0] = 0; - sts_tof_distance_data[1] = 0; - sts_tof_distance_data[2] = 0; + sts_tof_distance_data[0] = STS_MAX_L0_RANGE; + sts_tof_distance_data[1] = STS_MAX_L0_RANGE; + sts_tof_distance_data[2] = STS_MAX_L0_RANGE; if (nSensorPresent > 0) { // RangingConfig == HIGH ACCURACY, LONG RANGE, HIGH SPEED sts_tof_vl53l0x_SetupSingleShot(RangingConfig); - sts_tof_distance_data[0]=0; - sts_tof_distance_data[1]=0; - sts_tof_distance_data[2]=0; + sensor_data_ready = 0 ; for (i=0; i< MAX_TOF_COUNT; i++) { @@ -390,6 +391,7 @@ void STS_TOF_VL53L0X_Range_Process(void) if( RangingMeasurementData.RangeStatus == 0 ) { sts_tof_distance_data[i] = (int)VL53L0XDevs[i].LeakyRange; + if (sts_tof_distance_data[i] == 0) sts_tof_distance_data[i]+= STS_MAX_L0_RANGE; nDevMask |= (1 << i); sensor_data_ready |= 1; } else