P2 #8

Merged
sundp merged 18 commits from P2 into master 2024-09-20 14:41:45 +08:00
6 changed files with 36 additions and 10 deletions
Showing only changes of commit 48c0a9f33d - Show all commits

View File

@ -60,17 +60,22 @@ void Error_Handler(void);
#define RTC_N_PREDIV_S 10
#define RTC_PREDIV_S ((1<<RTC_N_PREDIV_S)-1)
#define RTC_PREDIV_A ((1<<(15-RTC_N_PREDIV_S))-1)
#if defined(STM32WL55xx)
#define LED1_Pin GPIO_PIN_15
#define LED1_GPIO_Port GPIOB
#endif
#define LED2_Pin GPIO_PIN_9
#define LED2_GPIO_Port GPIOB
#define BUT1_Pin GPIO_PIN_0
#define BUT1_GPIO_Port GPIOA
#define BUT1_EXTI_IRQn EXTI0_IRQn
#define PROB2_Pin GPIO_PIN_13
#define PROB2_GPIO_Port GPIOB
#define PROB1_Pin GPIO_PIN_12
#define PROB1_GPIO_Port GPIOB
#define BUT3_Pin GPIO_PIN_6
#define BUT3_GPIO_Port GPIOC
#define BUT3_EXTI_IRQn EXTI9_5_IRQn
@ -89,6 +94,24 @@ void Error_Handler(void);
#define BUT1_GPIO_Port GPIOA
#define BUT1_EXTI_IRQn EXTI0_IRQn
#define LED1_Pin GPIO_PIN_2
#define LED1_GPIO_Port GPIOB
#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)
#define LED1_STATE HAL_GPIO_ReadPin(LED1_GPIO_Port, LED1_Pin)
#define LED1_TOGGLE HAL_GPIO_TogglePin(LED1_GPIO_Port, LED1_Pin)
#define MEMS_POWER_Pin GPIO_PIN_4 // PMU_ENABLE
#define MEMS_POWER_GPIO_Port GPIOB // PMU_ENABLE
#define MEMS_RESET_Pin GPIO_PIN_4
#define MEMS_RESET_GPIO_Port GPIOB
#define PME_ON HAL_GPIO_WritePin(MEMS_POWER_GPIO_Port, MEMS_POWER_Pin, GPIO_PIN_SET )
#define PME_OFF HAL_GPIO_WritePin(MEMS_POWER_GPIO_Port, MEMS_POWER_Pin, GPIO_PIN_RESET )
#define VL53LX 1
#ifdef VL53LX

View File

@ -38,7 +38,8 @@
/* USER CODE BEGIN Includes */
#include "app_tof_pin_conf.h"
#include "app_tof_peoplecount.h"
#include "yunhorn_sts_prd_conf.h"
#include "yunhorn_sts_sensors.h"
/* USER CODE END Includes */
/* External variables ---------------------------------------------------------*/
@ -537,7 +538,7 @@ static void OnRxData(LmHandlerAppData_t *appData, LmHandlerRxParams_t *params)
outbuf[i++] = (uint8_t) sts_mtmcode2;
outbuf[i++] = (uint8_t) sts_version;
outbuf[i++] = (uint8_t) (0x41+ deviceClass); //translate to 'A','B','C'
STS_SENSOR_Upload_Message(LORAWAN_USER_APP_CTRL_REPLY_PORT, i, (uint8_t *)outbuf);
STS_SENSOR_Upload_Message(YUNHORN_STS_USER_APP_CTRL_REPLY_PORT, i, (uint8_t *)outbuf);
break;
case LORAWAN_USER_APP_PORT:
if (appData->BufferSize == 1)
@ -555,7 +556,7 @@ static void OnRxData(LmHandlerAppData_t *appData, LmHandlerRxParams_t *params)
}
}
break;
case LORAWAN_USER_APP_CTRL_PORT:
case YUNHORN_STS_USER_APP_CTRL_PORT:
if (appData->BufferSize != 1)
{
if (appData->BufferSize < 128) {
@ -594,7 +595,7 @@ void STS_SENSOR_Upload_Message(uint8_t appDataPort, uint8_t appBufferSize, uint8
}
AppData.Port = appDataPort;
AppData.BufferSize = (sts_service_mask >1?0:appBufferSize);
AppData.BufferSize = appBufferSize;
if ((JoinLedTimer.IsRunning) && (LmHandlerJoinStatus() == LORAMAC_HANDLER_SET))
{

View File

@ -57,7 +57,7 @@ extern "C" {
* LoRaWAN User application port
* @note do not use 224. It is reserved for certification
*/
#define LORAWAN_USER_APP_PORT 2
#define LORAWAN_USER_APP_PORT 106
/*!
* LoRaWAN Switch class application port

View File

@ -487,6 +487,7 @@ void STS_O5_SENSOR_Read(STS_OO_SensorDataTypeDef *oo_data)
void USER_APP_Parse_CMD_P(uint8_t *parse_buffer, uint8_t parse_buffer_size)
{
uint8_t pbuf[128]={0x0}, i=0, pbuf_size=parse_buffer_size&0x7F;
uint8_t invalid_flag = 1;
UTIL_MEM_cpy_8((void*)pbuf,(void*)parse_buffer, pbuf_size); /* 127 BYTES MAX */
if (((char)pbuf[CFG_CMD1] == 'P') && (pbuf_size >= 3)) // BEGIN OF PARAMETER CONFIG
@ -503,7 +504,7 @@ void USER_APP_Parse_CMD_P(uint8_t *parse_buffer, uint8_t parse_buffer_size)
case '0': //default sensor head or MEMS component
case '1': //first sensor head or MEMS component
mems_ver = (uint8_t)(pbuf[CFG_CMD3]-0x30);
uint8_t mems_ver = (uint8_t)(pbuf[CFG_CMD3]-0x30);
uint8_t j=0;
if (mems_ver == sts_version)

View File

@ -47,8 +47,9 @@ volatile uint8_t ToF_EventDetected = 0;
/* Private function prototypes -----------------------------------------------*/
uint8_t sts_vl53lx_ranging(uint16_t *ranged_distance, uint8_t range_mode, uint16_t distance_threshold_mm,
uint16_t inter_measurement_ms, uint16_t macro_timing,uint16_t roi_width, uint16_t sigma_mm, uint16_t signal_kcps);
uint8_t sts_vl53lx_ranging(uint8_t vl_model, uint8_t range_mode, uint16_t distance_threshold_mm, uint16_t inter_measurement_ms, uint16_t macro_timing,uint16_t roi_width, uint16_t sigma_mm, uint16_t signal_kcps);
uint8_t IsInterruptDetected(uint16_t dev);
void STS_TOF_VL53LX_Range_Process(uint8_t range_mode, uint16_t *range_distance);
@ -117,11 +118,11 @@ uint8_t IsInterruptDetected(uint16_t dev)
void STS_TOF_VL53LX_Range_Process(uint8_t range_mode, uint16_t *range_distance)
{
uint8_t vl53lx_model = STS_TOF_VL53L1X;
//uint8_t vl53lx_model = STS_TOF_VL53L1X;
//uint8_t range_mode = STS_TOF_SHORT_RANGE;
uint16_t i_distance_measured = 0;
uint16_t i_distance_threshold_mm = 800;
uint16_t i_inter_measurement_ms, i_macro_timing;
uint16_t i_inter_measurement_ms=100, i_macro_timing=33;
uint16_t i_roi_width=16, i_sigma_mm=30, i_signal_kcps=2000;
switch (range_mode)

View File

@ -27,7 +27,7 @@
#endif
/* Includes ------------------------------------------------------------------*/
#include "main.h"
/* Exported defines ----------------------------------------------------------*/
/* Exported functions --------------------------------------------------------*/