O5_JP #47

Merged
sundp merged 7 commits from O5_JP into master 2024-10-31 12:56:48 +08:00
6 changed files with 105 additions and 11 deletions
Showing only changes of commit 2551f86d85 - Show all commits

View File

@ -31,7 +31,7 @@ extern "C" {
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "yunhorn_sts_prd_conf.h"
/* USER CODE END Includes */
/* Exported types ------------------------------------------------------------*/
@ -75,10 +75,12 @@ void Error_Handler(void);
#define PROB1_Pin GPIO_PIN_12
#define PROB1_GPIO_Port GPIOB
#if defined(STM32WL55xx)
#define BUT3_Pin GPIO_PIN_6
#define BUT3_GPIO_Port GPIOC
#define BUT3_EXTI_IRQn EXTI9_5_IRQn
#endif
#if defined(STM32WLE5xx)
#define BUT2_Pin GPIO_PIN_1
#define BUT2_GPIO_Port GPIOA
#define BUT2_EXTI_IRQn EXTI1_IRQn
@ -94,8 +96,35 @@ void Error_Handler(void);
#define BUT1_GPIO_Port GPIOA
#define BUT1_EXTI_IRQn EXTI0_IRQn
#define BUT2_Pin GPIO_PIN_1
#define BUT2_GPIO_Port GPIOA
#define BUT2_EXTI_IRQn EXTI1_IRQn
#ifdef STS_O5
// STS_O5 GPIO PORT PIN DEFINATION SINGLE BOARD
/* --------------------------------------------------*/
/* | HALL-2 (PA-10) [VCC-GPIO-PB-4]| */
/* | | */
/* | HALL-1 (PA-0) [VCC-GPIO-PB3] | */
/* | | */
/* |------------------------------------------------ */
#define HALL1_Pin GPIO_PIN_0
#define HALL1_GPIO_Port GPIOA
#define HALL1_EXTI_IRQn EXTI0_IRQn
#define HALL2_Pin GPIO_PIN_10
#define HALL2_GPIO_Port GPIOA
#define HALL2_EXTI_IRQn EXTI15_10_IRQn
#define HALL1_STATE HAL_GPIO_ReadPin(HALL1_GPIO_Port, HALL1_Pin)
#define HALL2_STATE HAL_GPIO_ReadPin(HALL2_GPIO_Port, HALL2_Pin)
#endif
#define LED1_Pin GPIO_PIN_2
#define LED1_GPIO_Port GPIOB
#endif
#define BUT1_State HAL_GPIO_ReadPin(BUT1_GPIO_Port, BUT1_Pin)
#define BUT2_State HAL_GPIO_ReadPin(BUT2_GPIO_Port, BUT2_Pin)
#define LED1_ON HAL_GPIO_WritePin(LED1_GPIO_Port, LED1_Pin, GPIO_PIN_SET )
#define LED1_OFF HAL_GPIO_WritePin(LED1_GPIO_Port, LED1_Pin, GPIO_PIN_RESET)

View File

@ -63,12 +63,26 @@ void MX_GPIO_Init(void)
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
#ifdef STS_O5
GPIO_InitStruct.Pin = HALL1_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING;
GPIO_InitStruct.Pull = GPIO_PULLUP;
HAL_GPIO_Init(HALL1_GPIO_Port, &GPIO_InitStruct);
GPIO_InitStruct.Pin = HALL2_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING;
GPIO_InitStruct.Pull = GPIO_PULLUP;
HAL_GPIO_Init(HALL2_GPIO_Port, &GPIO_InitStruct);
#else
/*Configure GPIO pins : PAPin PAPin */
GPIO_InitStruct.Pin = BUT1_Pin|BUT2_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING;
GPIO_InitStruct.Pull = GPIO_PULLUP;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
#endif
#if defined(STM32WL55xx)
/*Configure GPIO pins : PBPin PBPin */
GPIO_InitStruct.Pin = PROB2_Pin|PROB1_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
@ -81,7 +95,7 @@ void MX_GPIO_Init(void)
GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING;
GPIO_InitStruct.Pull = GPIO_PULLUP;
HAL_GPIO_Init(BUT3_GPIO_Port, &GPIO_InitStruct);
#endif
#ifndef L8
/* STS-PME PB-4 */
/*Configure GPIO pins : PBPin PBPin PBPin */
@ -171,6 +185,15 @@ void MX_GPIO_Init(void)
HAL_NVIC_SetPriority(EXTI9_5_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(EXTI9_5_IRQn);
#ifdef STS_O5
HAL_NVIC_SetPriority(HALL1_EXTI_IRQn, 10, 0);
HAL_NVIC_EnableIRQ(HALL1_EXTI_IRQn);
HAL_NVIC_SetPriority(HALL2_EXTI_IRQn, 10, 0);
HAL_NVIC_EnableIRQ(HALL2_EXTI_IRQn);
#endif
#ifdef L8
HAL_NVIC_SetPriority(TOF_INT_EXTI_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(TOF_INT_EXTI_IRQn);

View File

@ -227,7 +227,7 @@ void EXTI0_IRQHandler(void)
/* USER CODE BEGIN EXTI0_IRQn 0 */
/* USER CODE END EXTI0_IRQn 0 */
HAL_GPIO_EXTI_IRQHandler(BUT1_Pin);
HAL_GPIO_EXTI_IRQHandler(HALL1_Pin);
/* USER CODE BEGIN EXTI0_IRQn 1 */
/* USER CODE END EXTI0_IRQn 1 */
@ -374,7 +374,9 @@ void EXTI9_5_IRQHandler(void)
/* USER CODE END EXTI9_5_IRQn 0 */
#ifndef RM2
#ifdef STM32WL55xx
HAL_GPIO_EXTI_IRQHandler(BUT3_Pin);
#endif
#elif defined(RM2)&&(defined(VL53L0)||defined(VL53LX))
HAL_GPIO_EXTI_IRQHandler(TOF_INT_EXTI_PIN);
#endif
@ -392,7 +394,9 @@ void EXTI15_10_IRQHandler(void)
/* USER CODE BEGIN EXTI15_10_IRQn 0 */
/* USER CODE END EXTI15_10_IRQn 0 */
#ifdef STS_O5
HAL_GPIO_EXTI_IRQHandler(HALL2_Pin);
#endif
#if defined(L8)||defined(STS_P2)||defined(STS_R1D)||defined(STS_R5)
HAL_GPIO_EXTI_IRQHandler(TOF_INT_EXTI_PIN);
#endif

View File

@ -553,22 +553,58 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
switch (GPIO_Pin)
{
#ifdef STS_O5
case HALL1_Pin:
if (0 == HALL1_STATE)
{
HAL_Delay(20);
//if (0 == HALL1_STATE) APP_LOG(TS_OFF, VLEVEL_M, "\r\n Button 1 state == 0 \r\n");
} else if (1 == HALL1_STATE)
{
HAL_Delay(20);
//if (1 == HALL1_STATE) APP_LOG(TS_OFF, VLEVEL_M, "\r\n Button 1 state ==1 \r\n");
}
HAL_Delay(100);
__HAL_GPIO_EXTI_CLEAR_IT(GPIO_Pin);
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
break;
case HALL2_Pin:
if (0 == HALL2_STATE)
{
HAL_Delay(20);
APP_LOG(TS_OFF, VLEVEL_M, "\r\n Button 2 state == 0 \r\n");
} else
{
HAL_Delay(20);
APP_LOG(TS_OFF, VLEVEL_M, "\r\n Button 2 state ==1 \r\n");
}
HAL_Delay(100);
__HAL_GPIO_EXTI_CLEAR_IT(GPIO_Pin);
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
break;
#else
case BUT1_Pin:
/* Note: when "EventType == TX_ON_TIMER" this GPIO is not initialized */
//if (EventType == TX_ON_EVENT)
if (EventType == TX_ON_EVENT)
{
APP_LOG(TS_OFF, VLEVEL_M, "\r\n Button 0 pressed \r\n");
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
}
break;
#endif
#ifndef STS_R4
case BUT2_Pin:
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaStopJoinEvent), CFG_SEQ_Prio_0);
break;
#endif
#ifdef STM32WL55xx
case BUT3_Pin:
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaStoreContextEvent), CFG_SEQ_Prio_0);
break;
#endif
#if (defined(VL53L0)||defined(VL53LX)||defined(L8))
case TOF_INT_EXTI_PIN:
ToF_EventDetected = 1;
@ -921,7 +957,7 @@ static void SendTxData(void)
#ifdef STS_O5
AppData.Buffer[i++] = 1;
AppData.Buffer[i++] = (uint8_t)(oo_data.state_sensor1_on_off)&0xff;
AppData.Buffer[i++] = (uint8_t)(oo_data.state_sensor1_on_off);
#endif
#ifdef VL53L0 //VL53L0
@ -1461,6 +1497,8 @@ static void OnYunhornSTSHeartBeatTimerEvent(void *context)
appHeartBeatDataPort = YUNHORN_STS_R4_LORA_APP_HTBT_PORT;
#elif defined(STS_T6)
appHeartBeatDataPort = YUNHORN_STS_T6_LORA_APP_HTBT_PORT;
#elif defined(STS_O5)
appHeartBeatDataPort = YUNHORN_STS_O5_LORA_APP_HTBT_PORT;
#endif
appHeartBeatBufferSize = 2;

View File

@ -583,8 +583,8 @@ void STS_M1_sensor_read(sts_r_sensor_data_t *sts_m_sensor_data)
void STS_O5_SENSOR_Read(STS_OO_SensorDataTypeDef *oo_data)
{
oo_data->state_sensor1_on_off = sts_reed_hall_result;
oo_data->state_sensor1_on_off = HALL1_STATE;;
oo_data->state_sensor2_on_off = HALL2_STATE;
sensor_data_ready = 1;
}