revised to support WL55xx and WLE5xx for GPIO1 Left and Right
This commit is contained in:
parent
85ccba387b
commit
528b647a6e
|
@ -100,23 +100,29 @@ void MX_TOF_Init(void);
|
|||
#endif
|
||||
|
||||
/* USER CODE BEGIN Private defines */
|
||||
#if defined(STM32WLE5xx) || defined(STM32WL55xx)
|
||||
#define TOF_C_INT_Pin GPIO_PIN_10
|
||||
#define TOF_C_INT_GPIO_Port GPIOA
|
||||
#define TOF_C_INT_EXTI_IRQn EXTI15_10_IRQn
|
||||
#define TOF_C_XSHUT_Pin GPIO_PIN_3
|
||||
#define TOF_C_XSHUT_GPIO_Port GPIOB
|
||||
#endif
|
||||
|
||||
#if defined(STM32WL55xx)
|
||||
#define TOF_L_INT_Pin GPIO_PIN_7
|
||||
#define TOF_L_INT_GPIO_Port GPIOC
|
||||
#define TOF_L_INT_EXTI_IRQn EXTI9_5_IRQn
|
||||
#define TOF_L_XSHUT_Pin GPIO_PIN_10
|
||||
#define TOF_L_XSHUT_GPIO_Port GPIOB
|
||||
#endif
|
||||
|
||||
#if defined(STM32WL55xx)
|
||||
#define TOF_R_INT_Pin GPIO_PIN_10
|
||||
#define TOF_R_INT_GPIO_Port GPIOA
|
||||
#define TOF_R_INT_EXTI_IRQn EXTI15_10_IRQn
|
||||
#define TOF_R_XSHUT_Pin GPIO_PIN_5
|
||||
#define TOF_R_XSHUT_GPIO_Port GPIOB
|
||||
#endif
|
||||
|
||||
#define STS_SERVICE_MASK_L0 (0) // Service normal , no mask off
|
||||
#define STS_SERVICE_MASK_L1 (1) // service mask level 1, sensing data upload in silence mode, node appearance silence (no LED, No display, no sound, no vibration)
|
||||
|
|
|
@ -56,7 +56,7 @@ void MX_GPIO_Init(void)
|
|||
|LED3_Pin, GPIO_PIN_RESET);
|
||||
|
||||
/*Configure GPIO pin Output Level */
|
||||
#if (defined(STS_USE_TOF_VL53L0X) || (defined(STS_USE_TOF_VL53L1X)))
|
||||
#if (defined(STS_USE_TOF_VL53L0X) || (defined(STS_USE_TOF_VL53L1X))||(defined(STM32WLE5xx)) || (defined(STM32WL55xx)))
|
||||
HAL_GPIO_WritePin(TOF_C_XSHUT_GPIO_Port, TOF_C_XSHUT_Pin, GPIO_PIN_SET);
|
||||
#endif
|
||||
|
||||
|
@ -98,6 +98,7 @@ void MX_GPIO_Init(void)
|
|||
GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
HAL_GPIO_Init(TOF_C_INT_GPIO_Port, &GPIO_InitStruct);
|
||||
#if defined(STM32WL55xx)
|
||||
/*Configure GPIO pins : TOF_L_INT_Pin */
|
||||
GPIO_InitStruct.Pin = TOF_L_INT_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING;
|
||||
|
@ -108,7 +109,7 @@ void MX_GPIO_Init(void)
|
|||
GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
HAL_GPIO_Init(TOF_R_INT_GPIO_Port, &GPIO_InitStruct);
|
||||
|
||||
#endif
|
||||
/*Configure GPIO pins : TOF_C_XSHUT_Pin */
|
||||
GPIO_InitStruct.Pin = TOF_C_XSHUT_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
|
@ -116,6 +117,7 @@ void MX_GPIO_Init(void)
|
|||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
HAL_GPIO_Init(TOF_C_XSHUT_GPIO_Port, &GPIO_InitStruct);
|
||||
/*Configure GPIO pins : TOF_L_XSHUT_Pin */
|
||||
#if defined(STM32WL55xx)
|
||||
GPIO_InitStruct.Pin = TOF_L_XSHUT_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
||||
|
@ -127,7 +129,7 @@ void MX_GPIO_Init(void)
|
|||
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
HAL_GPIO_Init(TOF_R_XSHUT_GPIO_Port, &GPIO_InitStruct);
|
||||
|
||||
#endif
|
||||
|
||||
/* EXTI interrupt init*/
|
||||
HAL_NVIC_SetPriority(EXTI0_IRQn, 0, 0);
|
||||
|
@ -138,10 +140,12 @@ void MX_GPIO_Init(void)
|
|||
|
||||
HAL_NVIC_SetPriority(TOF_C_INT_EXTI_IRQn, 0, 0);
|
||||
HAL_NVIC_EnableIRQ(TOF_C_INT_EXTI_IRQn);
|
||||
#if defined(STM32WL55xx)
|
||||
HAL_NVIC_SetPriority(TOF_L_INT_EXTI_IRQn, 0, 0);
|
||||
HAL_NVIC_EnableIRQ(TOF_L_INT_EXTI_IRQn);
|
||||
HAL_NVIC_SetPriority(TOF_R_INT_EXTI_IRQn, 0, 0);
|
||||
HAL_NVIC_EnableIRQ(TOF_R_INT_EXTI_IRQn);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN 2 */
|
||||
|
|
|
@ -220,7 +220,9 @@ void XWL55_WLE5_53L0X_ResetId(uint8_t DevNo, int state)
|
|||
|
||||
switch(DevNo) {
|
||||
case XNUCLEO53L0X_LEFT:
|
||||
#if defined(STM32WL55xx)
|
||||
HAL_GPIO_WritePin(TOF_L_XSHUT_GPIO_Port, TOF_L_XSHUT_Pin, ((state == 1)?GPIO_PIN_SET:GPIO_PIN_RESET));
|
||||
#endif
|
||||
break;
|
||||
|
||||
case XNUCLEO53L0X_CENTER:
|
||||
|
@ -228,7 +230,9 @@ void XWL55_WLE5_53L0X_ResetId(uint8_t DevNo, int state)
|
|||
break;
|
||||
|
||||
case XNUCLEO53L0X_RIGHT:
|
||||
#if defined(STM32WL55xx)
|
||||
HAL_GPIO_WritePin(TOF_R_XSHUT_GPIO_Port, TOF_R_XSHUT_Pin, ((state == 1)?GPIO_PIN_SET:GPIO_PIN_RESET));
|
||||
#endif
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -133,7 +133,7 @@ int sts_tof_vl53l0x_DetectSensors(void)
|
|||
|
||||
for (i=0; i < MAX_TOF_COUNT; i++) {
|
||||
XWL55_WLE5_53L0X_ResetId(i,0);
|
||||
XWL55_WLE5_53L0X_SetIntrStateId(1,i);
|
||||
//XWL55_WLE5_53L0X_SetIntrStateId(0,i);
|
||||
}
|
||||
|
||||
/* detect all sensors (even on-board)*/
|
||||
|
@ -179,7 +179,7 @@ int sts_tof_vl53l0x_DetectSensors(void)
|
|||
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);
|
||||
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);
|
||||
|
||||
}
|
||||
else{
|
||||
|
@ -221,7 +221,7 @@ void sts_tof_vl53l0x_SetupSingleShot(RangingConfig_e rangingConfig)
|
|||
|
||||
if( VL53L0XDevs[i].Present){
|
||||
|
||||
//APP_LOG(TS_OFF, VLEVEL_H, "\r\n ###### Starting Range #%u sensor \r\n",i);
|
||||
APP_LOG(TS_OFF, VLEVEL_L, "\r\n ###### Starting Range #%u sensor \r\n",i);
|
||||
|
||||
status=VL53L0X_StaticInit(&VL53L0XDevs[i]);
|
||||
if( status ){
|
||||
|
@ -343,7 +343,7 @@ void STS_TOF_VL53L0X_Range_Process(void)
|
|||
if ((nDevMask ==0) || (nSensorPresent ==0))
|
||||
{
|
||||
nSensorPresent = sts_tof_vl53l0x_DetectSensors(); // confirm sensor online
|
||||
APP_LOG(TS_OFF, VLEVEL_H, "\r\n %u pcs sensor(s) online \r\n", nSensorPresent);
|
||||
APP_LOG(TS_OFF, VLEVEL_L, "\r\n %u pcs sensor(s) online \r\n", nSensorPresent);
|
||||
}
|
||||
|
||||
if (nSensorPresent > 0)
|
||||
|
@ -366,7 +366,8 @@ void STS_TOF_VL53L0X_Range_Process(void)
|
|||
sensor_data_ready |= 1;
|
||||
} else
|
||||
{
|
||||
HandleError(ERR_DEMO_RANGE_ONE);
|
||||
//HandleError(ERR_DEMO_RANGE_ONE);
|
||||
APP_LOG(TS_OFF, VLEVEL_L,"\r\n#%u sensor ERR code = %04u\r\n",i, ERR_DEMO_RANGE_ONE);
|
||||
}
|
||||
// ########## two conditions
|
||||
// ########## 1) return status ==0,
|
||||
|
@ -377,7 +378,7 @@ void STS_TOF_VL53L0X_Range_Process(void)
|
|||
HAL_Delay(30);
|
||||
} // for i < MAX_TOF_COUNT
|
||||
|
||||
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",
|
||||
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",
|
||||
(int)sts_tof_distance_data[0],(int)sts_tof_distance_data[1],(int)sts_tof_distance_data[2]);
|
||||
} // nSensorPresent >0
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue