park here... not good to decode

This commit is contained in:
Yunhorn 2025-02-25 20:45:49 +08:00
parent 79e2ee456b
commit 903076acfd
7 changed files with 106 additions and 26 deletions

View File

@ -48,6 +48,7 @@ void STS_RF_Send_Multi_Times(uint8_t *rf_payload, uint8_t rf_length, uint8_t mt)
void STS_RF_Send_Button_Multi_Times(uint8_t *rf_payload, uint8_t one_button, uint8_t rf_length, uint8_t mt); void STS_RF_Send_Button_Multi_Times(uint8_t *rf_payload, uint8_t one_button, uint8_t rf_length, uint8_t mt);
void STS_RF_Send_AddressBit_and_CmdBit(uint8_t *rf_payload, uint8_t rf_length); void STS_RF_Send_AddressBit_and_CmdBit(uint8_t *rf_payload, uint8_t rf_length);
void EV1527Reset(void);
void EV1527Decode(uint32_t v);
#endif #endif

View File

@ -76,7 +76,7 @@ void EV1527_Init(void)
// 配置上拉输入 // 配置上拉输入
GPIO_InitStruct.Pin = DATA_433_PIN; GPIO_InitStruct.Pin = DATA_433_PIN;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
//GPIO_InitStruct.Pull = GPIO_PULLUP; GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
HAL_GPIO_Init(DATA_433_GPIO_PORT, &GPIO_InitStruct); HAL_GPIO_Init(DATA_433_GPIO_PORT, &GPIO_InitStruct);
} }
@ -423,7 +423,7 @@ extern uint8_t rf_data[4];
#define BIT0_LOW_US 1100 #define BIT0_LOW_US 1100
#endif #endif
#if 0 // RC_PROJECTOR #if 1 // RC_PROJECTOR
#define BIT1_HIGH_US 1000 // duty cycle = #define BIT1_HIGH_US 1000 // duty cycle =
#define BIT1_LOW_US 500 // #define BIT1_LOW_US 500 //
#define BIT0_HIGH_US 250 #define BIT0_HIGH_US 250
@ -432,7 +432,7 @@ extern uint8_t rf_data[4];
#define ENDING_HIGH_US 200 #define ENDING_HIGH_US 200
#endif #endif
#if 1 // SOS BUTTON #if 0 // SOS BUTTON
#define BIT1_HIGH_US 800 // duty cycle = #define BIT1_HIGH_US 800 // duty cycle =
#define BIT1_LOW_US 300 // #define BIT1_LOW_US 300 //
#define BIT0_HIGH_US 300 #define BIT0_HIGH_US 300

View File

@ -123,10 +123,10 @@ void MX_GPIO_Init(void)
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
HAL_GPIO_Init(RF_Send_GPIO_Port, &GPIO_InitStruct); HAL_GPIO_Init(RF_Send_GPIO_Port, &GPIO_InitStruct);
#if 0 #if 1
GPIO_InitStruct.Pin = RF_Receive_GPIO_Pin; GPIO_InitStruct.Pin = RF_Receive_GPIO_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING; GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING; //GPIO_MODE_INPUT; //GPIO_MODE_IT_RISING_FALLING;
GPIO_InitStruct.Pull = GPIO_PULLDOWN; GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
HAL_GPIO_Init(RF_Receive_GPIO_Port, &GPIO_InitStruct); HAL_GPIO_Init(RF_Receive_GPIO_Port, &GPIO_InitStruct);
#endif #endif
@ -190,7 +190,7 @@ void MX_GPIO_Init(void)
HAL_NVIC_EnableIRQ(EXTI4_IRQn); HAL_NVIC_EnableIRQ(EXTI4_IRQn);
HAL_NVIC_SetPriority(EXTI9_5_IRQn, 0, 0); HAL_NVIC_SetPriority(EXTI9_5_IRQn, 2, 0);
HAL_NVIC_EnableIRQ(EXTI9_5_IRQn); HAL_NVIC_EnableIRQ(EXTI9_5_IRQn);
HAL_NVIC_SetPriority(EXTI15_10_IRQn, 2, 0); HAL_NVIC_SetPriority(EXTI15_10_IRQn, 2, 0);

View File

@ -58,9 +58,9 @@ uint32_t uwFrequency = 0;
#endif #endif
#if 1 #if 1
uint32_t capture_Buf[3]={0}; // counter volatile uint32_t capture_Buf[3]={0}; // counter
uint8_t capture_Cnt=0; // state volatile uint8_t capture_Cnt=0; // state
uint32_t high_time, low_time; // high level duration, low level duration volatile uint32_t high_time, low_time; // high level duration, low level duration
#endif #endif
//uint8_t rf_payload[3]={0xF8,0xCD,0x07}, rf_length=3; //uint8_t rf_payload[3]={0xF8,0xCD,0x07}, rf_length=3;
@ -165,14 +165,14 @@ int main(void)
MX_USART2_UART_Init(); MX_USART2_UART_Init();
MX_USART1_UART_Init(); // MX_USART1_UART_Init();
MX_TIM1_Init(); MX_TIM1_Init();
printf("start \r\n"); printf("start \r\n");
EV1527_Init(); // EV1527_Init();
EV1527Reset();
#if 0 #if 0
/*## Start the Input Capture in interrupt mode ##########################*/ /*## Start the Input Capture in interrupt mode ##########################*/
if (HAL_TIM_IC_Start_IT(&htim1, TIM_CHANNEL_2) != HAL_OK) if (HAL_TIM_IC_Start_IT(&htim1, TIM_CHANNEL_2) != HAL_OK)
@ -216,6 +216,8 @@ int main(void)
Error_Handler(); Error_Handler();
} }
#endif #endif
#if 1
/*## Start the Input Capture in interrupt mode ##########################*/ /*## Start the Input Capture in interrupt mode ##########################*/
if (HAL_TIM_IC_Start_IT(&htim1, TIM_CHANNEL_1) != HAL_OK) if (HAL_TIM_IC_Start_IT(&htim1, TIM_CHANNEL_1) != HAL_OK)
{ {
@ -223,25 +225,30 @@ int main(void)
Error_Handler(); Error_Handler();
} }
#endif
while(1) while(1)
{ {
#if 1
#if 0
switch(capture_Cnt) { switch(capture_Cnt) {
case 0: case 0:
capture_Cnt ++; capture_Cnt ++;
printf("cc: %ld ", capture_Cnt); //printf("cc: %ld \r\n", capture_Cnt);
TIM_SET_CAPTUREPOLARITY(&htim1, TIM_CHANNEL_2, TIM_INPUTCHANNELPOLARITY_RISING); //TIM_SET_CAPTUREPOLARITY(&htim1, TIM_CHANNEL_2, TIM_INPUTCHANNELPOLARITY_RISING);
__HAL_TIM_SET_CAPTUREPOLARITY(&htim1,TIM_CHANNEL_2,TIM_INPUTCHANNELPOLARITY_RISING);
HAL_TIM_IC_Start_IT(&htim1, TIM_CHANNEL_2); // or _HAL_TIM_ENABLE(&htim1); HAL_TIM_IC_Start_IT(&htim1, TIM_CHANNEL_2); // or _HAL_TIM_ENABLE(&htim1);
break; break;
case 3: case 3:
high_time = capture_Buf[1] - capture_Buf[0]; // high time high_time = capture_Buf[1] - capture_Buf[0]; // high time
printf("ht: %ld ", high_time); low_time = capture_Buf[2] - capture_Buf[1]; // low time
if (low_time/high_time > 2) printf("_");
if (high_time/low_time > 2) printf("+");
// HAL_UART_Transmit(&huart2, (uint8_t*)high_time, 1, 0xffff); // print high time // HAL_UART_Transmit(&huart2, (uint8_t*)high_time, 1, 0xffff); // print high time
HAL_Delay(1000); //delay 1 s //HAL_Delay(1000); //delay 1 s
//HAL_Delay_Us(1000000);
capture_Cnt = 0; // clear flag capture_Cnt = 0; // clear flag
break; break;
} }
@ -405,7 +412,8 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
case DATA_433_PIN: case DATA_433_PIN:
//printf("^"); //printf("^");
RF_Signal_Decode(); HAL_TIM_IC_CaptureCallback(&htim1);
//RF_Signal_Decode();
break; break;

View File

@ -74,6 +74,74 @@ void HAL_MspInit(void)
} }
/**
* @brief TIM_IC MSP Initialization
* This function configures the hardware resources used in this example
* @param htim_ic: TIM_IC handle pointer
* @retval None
*/
void HAL_TIM_IC_MspInit(TIM_HandleTypeDef* htim_ic)
{
GPIO_InitTypeDef GPIO_InitStruct = {0};
if(htim_ic->Instance==TIM1)
{
/* USER CODE BEGIN TIM1_MspInit 0 */
/* USER CODE END TIM1_MspInit 0 */
/* Peripheral clock enable */
__HAL_RCC_TIM1_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
/**TIM1 GPIO Configuration
PA9 ------> TIM1_CH2
*/
GPIO_InitStruct.Pin = GPIO_PIN_9;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF1_TIM1;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
/* TIM1 interrupt Init */
HAL_NVIC_SetPriority(TIM1_CC_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(TIM1_CC_IRQn);
/* USER CODE BEGIN TIM1_MspInit 1 */
/* USER CODE END TIM1_MspInit 1 */
}
}
/**
* @brief TIM_IC MSP De-Initialization
* This function freeze the hardware resources used in this example
* @param htim_ic: TIM_IC handle pointer
* @retval None
*/
void HAL_TIM_IC_MspDeInit(TIM_HandleTypeDef* htim_ic)
{
if(htim_ic->Instance==TIM1)
{
/* USER CODE BEGIN TIM1_MspDeInit 0 */
/* USER CODE END TIM1_MspDeInit 0 */
/* Peripheral clock disable */
__HAL_RCC_TIM1_CLK_DISABLE();
/**TIM1 GPIO Configuration
PA9 ------> TIM1_CH2
*/
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9);
/* TIM1 interrupt DeInit */
HAL_NVIC_DisableIRQ(TIM1_CC_IRQn);
/* USER CODE BEGIN TIM1_MspDeInit 1 */
/* USER CODE END TIM1_MspDeInit 1 */
}
}
/** /**
* @brief TIM_Base MSP Initialization * @brief TIM_Base MSP Initialization
* This function configures the hardware resources used in this example * This function configures the hardware resources used in this example

View File

@ -369,10 +369,10 @@ void EXTI9_5_IRQHandler(void)
__HAL_GPIO_EXTI_CLEAR_IT(RC_D5_Pin); __HAL_GPIO_EXTI_CLEAR_IT(RC_D5_Pin);
#endif #endif
HAL_GPIO_EXTI_IRQHandler(BUT3_Pin); //HAL_GPIO_EXTI_IRQHandler(BUT3_Pin);
HAL_GPIO_EXTI_IRQHandler(DATA_433_PIN); HAL_GPIO_EXTI_IRQHandler(DATA_433_PIN);
//__HAL_GPIO_EXTI_CLEAR_IT(DATA_433_PIN); __HAL_GPIO_EXTI_CLEAR_IT(DATA_433_PIN);
/* USER CODE BEGIN EXTI9_5_IRQn 1 */ /* USER CODE BEGIN EXTI9_5_IRQn 1 */
@ -459,13 +459,14 @@ void SUBGHZ_Radio_IRQHandler(void)
} }
/* USER CODE BEGIN 1 */ /* USER CODE BEGIN 1 */
#if 0
void TIM1_IRQHandler(void) void TIM1_IRQHandler(void)
{ {
TIM1_cnt++; TIM1_cnt++;
HAL_TIM_IRQHandler(&htim1); HAL_TIM_IRQHandler(&htim1);
} }
#if 0 #endif
#if 1
/** /**
* @brief This function handles TIM1 Capture Compare Interrupt. * @brief This function handles TIM1 Capture Compare Interrupt.
*/ */
@ -480,6 +481,8 @@ void TIM1_CC_IRQHandler(void)
/* USER CODE END TIM1_CC_IRQn 1 */ /* USER CODE END TIM1_CC_IRQn 1 */
} }
#endif #endif
#if 1
/** /**
* @brief This function handles TIM1 Capture Compare Interrupt. * @brief This function handles TIM1 Capture Compare Interrupt.
*/ */
@ -495,5 +498,5 @@ void TIM1_IC_IRQHandler(void)
/* USER CODE END TIM1_CC_IRQn 1 */ /* USER CODE END TIM1_CC_IRQn 1 */
} }
#endif
/* USER CODE END 1 */ /* USER CODE END 1 */