remove unused code and enabled 3 GPIO1 intr
This commit is contained in:
parent
0f665e497d
commit
85ccba387b
|
@ -51,4 +51,7 @@ modules.order
|
||||||
Module.symvers
|
Module.symvers
|
||||||
Mkfile.old
|
Mkfile.old
|
||||||
dkms.conf
|
dkms.conf
|
||||||
|
*.mxproject
|
||||||
|
*.extsettings
|
||||||
|
*.cyclo
|
||||||
|
|
||||||
|
|
|
@ -92,6 +92,13 @@ void MX_TOF_Init(void);
|
||||||
#define USARTx_TX_Pin GPIO_PIN_2
|
#define USARTx_TX_Pin GPIO_PIN_2
|
||||||
#define USARTx_TX_GPIO_Port GPIOA
|
#define USARTx_TX_GPIO_Port GPIOA
|
||||||
|
|
||||||
|
#if defined(STM32WLE5xx) || defined(STM32WL55xx)
|
||||||
|
#define I2C2_SCL_PIN GPIO_PIN_12
|
||||||
|
#define I2C2_SDA_PIN GPIO_PIN_11
|
||||||
|
#define I2C2_SCL_PORT GPIOA
|
||||||
|
#define I2C2_SDA_PORT GPIOA
|
||||||
|
#endif
|
||||||
|
|
||||||
/* USER CODE BEGIN Private defines */
|
/* USER CODE BEGIN Private defines */
|
||||||
#define TOF_C_INT_Pin GPIO_PIN_10
|
#define TOF_C_INT_Pin GPIO_PIN_10
|
||||||
#define TOF_C_INT_GPIO_Port GPIOA
|
#define TOF_C_INT_GPIO_Port GPIOA
|
||||||
|
|
|
@ -180,7 +180,7 @@ enum sts_ctrl_cmd_tune_para{
|
||||||
#if (defined(YUNHORN_STS_R0_ENABLED) || defined(YUNHORN_STS_R1_ENABLED) || defined(YUNHORN_STS_R2_ENABLED) || defined(YUNHORN_STS_R5_ENABLED))
|
#if (defined(YUNHORN_STS_R0_ENABLED) || defined(YUNHORN_STS_R1_ENABLED) || defined(YUNHORN_STS_R2_ENABLED) || defined(YUNHORN_STS_R5_ENABLED))
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
uint16_t distance_mm; /*measured distance in mm, min=0mm, max=2500mm. */
|
uint16_t distance_mm; /*Default distance sensor measured distance in mm, min=0mm, max=2500mm. */
|
||||||
uint16_t battery_mV; /*mV, 1000mv-5000mv, regular 3300mV - 3600mV --4200mV */
|
uint16_t battery_mV; /*mV, 1000mv-5000mv, regular 3300mV - 3600mV --4200mV */
|
||||||
|
|
||||||
uint8_t on_off_event; /* 1: liquid sensed, 0: no liquid sensed */
|
uint8_t on_off_event; /* 1: liquid sensed, 0: no liquid sensed */
|
||||||
|
@ -188,8 +188,8 @@ typedef struct
|
||||||
|
|
||||||
uint8_t distance_mm_h; /*MSB */
|
uint8_t distance_mm_h; /*MSB */
|
||||||
uint8_t distance_mm_l; /*LSB max=255 mm for short range measure */
|
uint8_t distance_mm_l; /*LSB max=255 mm for short range measure */
|
||||||
uint16_t distance1_mm;
|
uint16_t distance1_mm; /* Additional #1 distance sensor */
|
||||||
uint16_t distance2_mm;
|
uint16_t distance2_mm; /* Additional #2 distance sensor */
|
||||||
|
|
||||||
uint8_t battery_Pct; /* % of battery two digits, 88% (00-99)% */
|
uint8_t battery_Pct; /* % of battery two digits, 88% (00-99)% */
|
||||||
uint8_t dutycycletimelevel; /* level=0,255 */
|
uint8_t dutycycletimelevel; /* level=0,255 */
|
||||||
|
|
|
@ -766,7 +766,7 @@ static void SendTxData(void)
|
||||||
STS_R0_SensorDataTypeDef r0_data;
|
STS_R0_SensorDataTypeDef r0_data;
|
||||||
UTIL_TIMER_Time_t nextTxIn = 0;
|
UTIL_TIMER_Time_t nextTxIn = 0;
|
||||||
|
|
||||||
APP_LOG(TS_ON, VLEVEL_L, "\r\n Flag: Heart-beat-timer = %u \r\n upload_message_timer %u \r\n sensor_data_ready = %u \r\n",
|
APP_LOG(TS_ON, VLEVEL_H, "\r\n Flag: Heart-beat-timer = %u \r\n upload_message_timer %u \r\n sensor_data_ready = %u \r\n",
|
||||||
heart_beat_timer, upload_message_timer, sensor_data_ready);
|
heart_beat_timer, upload_message_timer, sensor_data_ready);
|
||||||
|
|
||||||
|
|
||||||
|
@ -800,7 +800,7 @@ static void SendTxData(void)
|
||||||
{
|
{
|
||||||
heart_beat_timer = 0;
|
heart_beat_timer = 0;
|
||||||
AppData.Port = LORAWAN_USER_HTBT_PORT; //LORAWAN_USER_APP_PORT+1;
|
AppData.Port = LORAWAN_USER_HTBT_PORT; //LORAWAN_USER_APP_PORT+1;
|
||||||
APP_LOG(TS_ON, VLEVEL_L, "\r\n------------ Heart-Beat ------------- \r\n ------------------\r\nDistance0 = %d mm, \r\nDistance1 = %d mm,\r\nDistance2 = %d mm, \r\nVBAT=%d\r\n",
|
APP_LOG(TS_ON, VLEVEL_H, "\r\n------------ Heart-Beat ------------- \r\n ------------------\r\nDistance0 = %d mm, \r\nDistance1 = %d mm,\r\nDistance2 = %d mm, \r\nVBAT=%d\r\n",
|
||||||
r0_data.distance_mm,r0_data.distance1_mm,r0_data.distance2_mm, r0_data.battery_Pct);
|
r0_data.distance_mm,r0_data.distance1_mm,r0_data.distance2_mm, r0_data.battery_Pct);
|
||||||
|
|
||||||
} else if ((upload_message_timer)||(sensor_data_ready)) //sensor_data_ready for manual push button-1 trigger)
|
} else if ((upload_message_timer)||(sensor_data_ready)) //sensor_data_ready for manual push button-1 trigger)
|
||||||
|
@ -816,7 +816,7 @@ static void SendTxData(void)
|
||||||
AppData.Buffer[i++] = (uint8_t)(r0_data.distance2_mm >>8)&0xff; //#09
|
AppData.Buffer[i++] = (uint8_t)(r0_data.distance2_mm >>8)&0xff; //#09
|
||||||
AppData.Buffer[i++] = (uint8_t)(r0_data.distance2_mm)&0xff; //#10
|
AppData.Buffer[i++] = (uint8_t)(r0_data.distance2_mm)&0xff; //#10
|
||||||
|
|
||||||
APP_LOG(TS_ON, VLEVEL_L, "\r\n------------ Heart-Beat ------------- \r\n ------------------\r\nDistance0 = %d mm, \r\nDistance1 = %d mm,\r\nDistance2 = %d mm, \r\nVBAT=%d\r\n",
|
APP_LOG(TS_ON, VLEVEL_H, "\r\n------------ Heart-Beat ------------- \r\n ------------------\r\nDistance0 = %d mm, \r\nDistance1 = %d mm,\r\nDistance2 = %d mm, \r\nVBAT=%d\r\n",
|
||||||
r0_data.distance_mm,r0_data.distance1_mm,r0_data.distance2_mm, r0_data.battery_Pct);
|
r0_data.distance_mm,r0_data.distance1_mm,r0_data.distance2_mm, r0_data.battery_Pct);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -162,9 +162,28 @@ int XWL55_WLE5_53L0X_SetIntrStateId(int EnableIntr, int DevNo)
|
||||||
int status;
|
int status;
|
||||||
IRQn_Type IntrNo;
|
IRQn_Type IntrNo;
|
||||||
int IntrPin;
|
int IntrPin;
|
||||||
|
switch (DevNo){
|
||||||
|
case 0:
|
||||||
|
IntrNo = VL53L0X_GPIO1_L_INTx;
|
||||||
|
IntrPin= VL53L0X_GPIO1_L_GPIO_PIN;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
IntrNo = VL53L0X_GPIO1_C_INTx;
|
||||||
|
IntrPin= VL53L0X_GPIO1_C_GPIO_PIN;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
IntrNo = VL53L0X_GPIO1_R_INTx;
|
||||||
|
IntrPin= VL53L0X_GPIO1_R_GPIO_PIN;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
/*
|
||||||
IntrNo = VL53L0X_GPIO1_C_INTx;
|
IntrNo = VL53L0X_GPIO1_C_INTx;
|
||||||
IntrPin= VL53L0X_GPIO1_C_GPIO_PIN;
|
IntrPin= VL53L0X_GPIO1_C_GPIO_PIN;
|
||||||
|
*/
|
||||||
status = 0;
|
status = 0;
|
||||||
|
|
||||||
if( EnableIntr ){
|
if( EnableIntr ){
|
||||||
|
|
|
@ -135,13 +135,22 @@ extern void XNUCLEO53L1A1_USART2_UART_Init(void);
|
||||||
#define VL53L0X_GPIO1_C_OPTION 1
|
#define VL53L0X_GPIO1_C_OPTION 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* ############ FOR SHARED GPIO1 INTR TO MCU ###### */
|
||||||
#define VL53L0X_GPIO1_C_GPIO_PORT GPIOA
|
#define VL53L0X_GPIO1_C_GPIO_PORT GPIOA
|
||||||
#define VL53L0X_GPIO1_C_CLK_ENABLE __GPIOA_CLK_ENABLE
|
#define VL53L0X_GPIO1_C_CLK_ENABLE __GPIOA_CLK_ENABLE
|
||||||
#define VL53L0X_GPIO1_C_GPIO_PIN GPIO_PIN_10
|
#define VL53L0X_GPIO1_C_GPIO_PIN GPIO_PIN_10
|
||||||
|
|
||||||
#define VL53L0X_GPIO1_C_INTx EXTI15_10_IRQn
|
#define VL53L0X_GPIO1_C_INTx EXTI15_10_IRQn
|
||||||
|
|
||||||
|
#define VL53L0X_GPIO1_L_GPIO_PORT GPIOA
|
||||||
|
#define VL53L0X_GPIO1_L_CLK_ENABLE __GPIOA_CLK_ENABLE
|
||||||
|
#define VL53L0X_GPIO1_L_GPIO_PIN GPIO_PIN_10
|
||||||
|
#define VL53L0X_GPIO1_L_INTx EXTI15_10_IRQn
|
||||||
|
|
||||||
|
#define VL53L0X_GPIO1_R_GPIO_PORT GPIOA
|
||||||
|
#define VL53L0X_GPIO1_R_CLK_ENABLE __GPIOA_CLK_ENABLE
|
||||||
|
#define VL53L0X_GPIO1_R_GPIO_PIN GPIO_PIN_10
|
||||||
|
#define VL53L0X_GPIO1_R_INTx EXTI15_10_IRQn
|
||||||
|
/* ############ FOR SHARED GPIO1 INTR TO MCU ###### */
|
||||||
|
|
||||||
/** @} */ /* defgroup L53L1A1_GPIO1_MAP */
|
/** @} */ /* defgroup L53L1A1_GPIO1_MAP */
|
||||||
|
|
||||||
|
|
|
@ -133,10 +133,9 @@ int sts_tof_vl53l0x_DetectSensors(void)
|
||||||
|
|
||||||
for (i=0; i < MAX_TOF_COUNT; i++) {
|
for (i=0; i < MAX_TOF_COUNT; i++) {
|
||||||
XWL55_WLE5_53L0X_ResetId(i,0);
|
XWL55_WLE5_53L0X_ResetId(i,0);
|
||||||
|
XWL55_WLE5_53L0X_SetIntrStateId(1,i);
|
||||||
}
|
}
|
||||||
|
|
||||||
XWL55_WLE5_53L0X_SetIntrStateId(0,0);
|
|
||||||
|
|
||||||
/* detect all sensors (even on-board)*/
|
/* detect all sensors (even on-board)*/
|
||||||
for (i=0; i < MAX_TOF_COUNT; i++)
|
for (i=0; i < MAX_TOF_COUNT; i++)
|
||||||
{
|
{
|
||||||
|
@ -145,19 +144,19 @@ int sts_tof_vl53l0x_DetectSensors(void)
|
||||||
pDev->I2cDevAddr = 0x52;
|
pDev->I2cDevAddr = 0x52;
|
||||||
pDev->Present = 0;
|
pDev->Present = 0;
|
||||||
XWL55_WLE5_53L0X_ResetId(pDev->Id, 1);
|
XWL55_WLE5_53L0X_ResetId(pDev->Id, 1);
|
||||||
HAL_Delay(30);
|
HAL_Delay(3);
|
||||||
FinalAddress = 0x52+(i+1)*2;
|
FinalAddress = 0x52+(i+1)*2;
|
||||||
|
|
||||||
APP_LOG(TS_OFF, VLEVEL_L, "\r\n Detect TOF sensors #%u with I2CDevAddr=0x%02x \r\n", i, pDev->I2cDevAddr);
|
//APP_LOG(TS_OFF, VLEVEL_H, "\r\n Detect TOF sensors #%u with I2CDevAddr=0x%02x \r\n", i, pDev->I2cDevAddr);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
/* Set I2C standard mode (400 KHz) before doing the first register access */
|
/* Set I2C standard mode (400 KHz) before doing the first register access */
|
||||||
//if (status == VL53L0X_ERROR_NONE)
|
//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 */
|
/* Try to read one register using default 0x52 address */
|
||||||
status = VL53L0X_RdWord(pDev, VL53L0X_REG_IDENTIFICATION_MODEL_ID, &Id);
|
status = VL53L0X_RdWord(pDev, VL53L0X_REG_IDENTIFICATION_MODEL_ID, &Id);
|
||||||
APP_LOG(TS_OFF, VLEVEL_L, "#%u read id = %04x I2C ADDR=0x%2X\r\n",i, Id, pDev->I2cDevAddr);
|
//APP_LOG(TS_OFF, VLEVEL_H, "#%u read id = %04x I2C ADDR=0x%2X\r\n",i, Id, pDev->I2cDevAddr);
|
||||||
if (status) {
|
if (status) {
|
||||||
APP_LOG(TS_OFF, VLEVEL_L, "# Read id fail\n");
|
APP_LOG(TS_OFF, VLEVEL_L, "# Read id fail\n");
|
||||||
break;
|
break;
|
||||||
|
@ -175,12 +174,12 @@ int sts_tof_vl53l0x_DetectSensors(void)
|
||||||
status = VL53L0X_DataInit(pDev);
|
status = VL53L0X_DataInit(pDev);
|
||||||
if( status == 0 ){
|
if( status == 0 ){
|
||||||
pDev->Present = 1;
|
pDev->Present = 1;
|
||||||
APP_LOG(TS_OFF, VLEVEL_L, "#%u VL53L0X_SetDeviceAddress to 0x%02x\r\n",i, pDev->I2cDevAddr);
|
//APP_LOG(TS_OFF, VLEVEL_H, "#%u VL53L0X_SetDeviceAddress to 0x%02x\r\n",i, pDev->I2cDevAddr);
|
||||||
|
|
||||||
nDevPresent++;
|
nDevPresent++;
|
||||||
nDevMask |= 1 << i;
|
nDevMask |= 1 << i;
|
||||||
pDev->Present = 1;
|
pDev->Present = 1;
|
||||||
APP_LOG(TS_OFF, VLEVEL_L, "VL53L0X %d Present and initiated to final 0x%2x, Position Mask=0x%02x\r\n", pDev->Id, pDev->I2cDevAddr, nDevMask);
|
//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{
|
else{
|
||||||
|
@ -222,7 +221,7 @@ void sts_tof_vl53l0x_SetupSingleShot(RangingConfig_e rangingConfig)
|
||||||
|
|
||||||
if( VL53L0XDevs[i].Present){
|
if( VL53L0XDevs[i].Present){
|
||||||
|
|
||||||
APP_LOG(TS_OFF, VLEVEL_L, "\r\n ###### Starting Range #%u sensor \r\n",i);
|
//APP_LOG(TS_OFF, VLEVEL_H, "\r\n ###### Starting Range #%u sensor \r\n",i);
|
||||||
|
|
||||||
status=VL53L0X_StaticInit(&VL53L0XDevs[i]);
|
status=VL53L0X_StaticInit(&VL53L0XDevs[i]);
|
||||||
if( status ){
|
if( status ){
|
||||||
|
@ -344,7 +343,7 @@ void STS_TOF_VL53L0X_Range_Process(void)
|
||||||
if ((nDevMask ==0) || (nSensorPresent ==0))
|
if ((nDevMask ==0) || (nSensorPresent ==0))
|
||||||
{
|
{
|
||||||
nSensorPresent = sts_tof_vl53l0x_DetectSensors(); // confirm sensor online
|
nSensorPresent = sts_tof_vl53l0x_DetectSensors(); // confirm sensor online
|
||||||
APP_LOG(TS_OFF, VLEVEL_L, "\r\n %u pcs sensor(s) online \r\n", nSensorPresent);
|
APP_LOG(TS_OFF, VLEVEL_H, "\r\n %u pcs sensor(s) online \r\n", nSensorPresent);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nSensorPresent > 0)
|
if (nSensorPresent > 0)
|
||||||
|
@ -378,7 +377,7 @@ void STS_TOF_VL53L0X_Range_Process(void)
|
||||||
HAL_Delay(30);
|
HAL_Delay(30);
|
||||||
} // for i < MAX_TOF_COUNT
|
} // for i < MAX_TOF_COUNT
|
||||||
|
|
||||||
APP_LOG(TS_OFF, VLEVEL_L, "\r\n## Measured Range: \r\nTOF #0 = %4u mm, \r\nTOF #1 = %4u mm, \r\nTOF #2 = %4u mm\r\n",
|
APP_LOG(TS_OFF, VLEVEL_H, "\r\n## Measured Range: \r\nTOF #0 = %4u mm, \r\nTOF #1 = %4u mm, \r\nTOF #2 = %4u mm\r\n",
|
||||||
(int)sts_tof_distance_data[0],(int)sts_tof_distance_data[1],(int)sts_tof_distance_data[2]);
|
(int)sts_tof_distance_data[0],(int)sts_tof_distance_data[1],(int)sts_tof_distance_data[2]);
|
||||||
} // nSensorPresent >0
|
} // nSensorPresent >0
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue