3.24_433_RX版本:封装RF433模块,完成开机进入TX/RX模式并在开发板验证成功
This commit is contained in:
123
Core/Src/e32_hal.c
Normal file
123
Core/Src/e32_hal.c
Normal file
@ -0,0 +1,123 @@
|
||||
#include "e32_hal.h"
|
||||
|
||||
/**
|
||||
* <20>뵥Ƭ<EBB5A5><C6AC>ƽ̨<C6BD>й<EFBFBD>
|
||||
*/
|
||||
#include "main.h"
|
||||
#include "gpio.h"
|
||||
#include "usart.h"
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD>ڷ<EFBFBD><DAB7>ͽӿ<CDBD>
|
||||
*
|
||||
* @param buffer <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* @param length <20><><EFBFBD>ͳ<EFBFBD><CDB3><EFBFBD>
|
||||
*/
|
||||
void e32_hal_uart_tx( uint8_t *buffer , uint16_t length )
|
||||
{
|
||||
HAL_UART_Transmit( &huart1, buffer, length, 0xFFFF);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ģ<><C4A3>æ״̬<D7B4>ȴ<EFBFBD>
|
||||
*/
|
||||
void e32_hal_aux_wait(void)
|
||||
{
|
||||
if( HAL_GPIO_ReadPin( AUX_GPIO_Port , AUX_Pin ) == GPIO_PIN_RESET )
|
||||
{
|
||||
/* <20>ȵ<EFBFBD>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD> AUX<55><58><EFBFBD>ŵ<EFBFBD>Ϊæ<CEAA><C3A6><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD> */
|
||||
while( HAL_GPIO_ReadPin( AUX_GPIO_Port , AUX_Pin ) == GPIO_PIN_RESET )
|
||||
{
|
||||
///@todo <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>
|
||||
}
|
||||
|
||||
/* <20><><EFBFBD>Ǽ<EFBFBD><C7BC><EFBFBD><EFBFBD>ԣ<EFBFBD>AUX<55><58><EFBFBD>к<EFBFBD><D0BA><EFBFBD><EFBFBD>Ե<EFBFBD>1~2ms */
|
||||
HAL_Delay(2);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ģ<>鸴λ
|
||||
*/
|
||||
void e32_hal_reset(void)
|
||||
{
|
||||
HAL_GPIO_WritePin( RESET_GPIO_Port, RESET_Pin, GPIO_PIN_RESET );
|
||||
|
||||
HAL_Delay(1);
|
||||
|
||||
HAL_GPIO_WritePin( RESET_GPIO_Port, RESET_Pin, GPIO_PIN_SET );
|
||||
|
||||
#if E32_USE_GPIO_AUX
|
||||
/* ע<><D7A2> Ӳ<><D3B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>AUX<55><58><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD>ƽ<EFBFBD><C6BD><EFBFBD><EFBFBD>Ҫ<EFBFBD>ȴ<EFBFBD>һ<EFBFBD><D2BB>ʱ<EFBFBD><CAB1><EFBFBD>ٿ<EFBFBD>ʼAUX<55><58><EFBFBD><EFBFBD> */
|
||||
HAL_Delay(10);
|
||||
|
||||
e32_hal_aux_wait();
|
||||
#else
|
||||
// /* E32-V2 (V8.1) <20>汾<EFBFBD><E6B1BE><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>ϳ<EFBFBD>
|
||||
// <20><><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8>AT+FWCODE=?<3F><>ȡ<EFBFBD>汾<EFBFBD><E6B1BE>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7> 7393-x-xx */
|
||||
// e32_delay_ms(1200);
|
||||
|
||||
/* E32-V2 (V8.2) <20>汾
|
||||
<20><><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8>AT+FWCODE=?<3F><>ȡ<EFBFBD>汾<EFBFBD><E6B1BE>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7> 7459-x-xx */
|
||||
e32_delay_ms(30);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ģ<><C4A3>ģʽ<C4A3>л<EFBFBD>
|
||||
*
|
||||
* @param mode <20><><EFBFBD><EFBFBD>ģʽ
|
||||
*/
|
||||
void e32_hal_work_mode( work_mode_t mode)
|
||||
{
|
||||
|
||||
#if E32_USE_GPIO_AUX
|
||||
e32_hal_aux_wait();
|
||||
#endif
|
||||
|
||||
switch(mode)
|
||||
{
|
||||
/* ģʽ0<CABD><30> һ<><D2BB>ģʽ (M0=0 M1=0) */
|
||||
case WORK_MODE_TRANSPARENT:
|
||||
HAL_GPIO_WritePin( M0_GPIO_Port, M0_Pin, GPIO_PIN_RESET );
|
||||
HAL_GPIO_WritePin( M1_GPIO_Port, M1_Pin, GPIO_PIN_RESET );
|
||||
break;
|
||||
|
||||
/* ģʽ1<CABD><31> <20><><EFBFBD><EFBFBD>ģʽ (M0=1 M1=0) */
|
||||
case WORK_MODE_WAKE_ON_RADIO_MASTER:
|
||||
HAL_GPIO_WritePin( M0_GPIO_Port, M0_Pin, GPIO_PIN_SET );
|
||||
HAL_GPIO_WritePin( M1_GPIO_Port, M1_Pin, GPIO_PIN_RESET );
|
||||
break;
|
||||
|
||||
/* ģʽ2<CABD><32> ʡ<><CAA1>ģʽ (M0=0 M1=1) */
|
||||
case WORK_MODE_WAKE_ON_RADIO_SLAVE:
|
||||
HAL_GPIO_WritePin( M0_GPIO_Port, M0_Pin, GPIO_PIN_RESET );
|
||||
HAL_GPIO_WritePin( M1_GPIO_Port, M1_Pin, GPIO_PIN_SET );
|
||||
break;
|
||||
|
||||
/* ģʽ3<CABD><33> <20><><EFBFBD><EFBFBD>ģʽ (M0=1 M1=1) */
|
||||
case WORK_MODE_CONFIG_AND_SLEEP:
|
||||
HAL_GPIO_WritePin( M0_GPIO_Port, M0_Pin, GPIO_PIN_SET );
|
||||
HAL_GPIO_WritePin( M1_GPIO_Port, M1_Pin, GPIO_PIN_SET );
|
||||
break;
|
||||
|
||||
default:
|
||||
while(1); //ģʽ<C4A3><CABD><EFBFBD><EFBFBD>
|
||||
}
|
||||
|
||||
#if E32_USE_GPIO_AUX
|
||||
/* <20><><EFBFBD><EFBFBD><EFBFBD>л<EFBFBD><D0BB><EFBFBD> ģ<><C4A3><EFBFBD><EFBFBD>ʱAUX<55><58><EFBFBD>Ų<EFBFBD><C5B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD>ƽ<EFBFBD><C6BD><EFBFBD><EFBFBD>Ҫ<EFBFBD>Ե<EFBFBD><D4B5>ٽ<EFBFBD><D9BD>м<EFBFBD><D0BC><EFBFBD> */
|
||||
HAL_Delay(5);
|
||||
e32_hal_aux_wait();
|
||||
#else
|
||||
|
||||
/* <20><><EFBFBD>ﱣ<EFBFBD><EFB1A3>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>ȷ<EFBFBD><C8B7>ģʽ<C4A3>л<EFBFBD><D0BB><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD> */
|
||||
e32_delay_ms(50);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user