添加获取清除雨量指令,获取光照指令

This commit is contained in:
95384 2025-01-15 11:06:29 +08:00
parent d92e4d08a7
commit 52d3ef0d0c
7 changed files with 83 additions and 3 deletions

View File

@ -4,6 +4,7 @@
#include "timer.h" #include "timer.h"
#include "gpio.h" #include "gpio.h"
#include "inflash.h" #include "inflash.h"
#include "rain.h"
extern UART_HandleTypeDef huart1; extern UART_HandleTypeDef huart1;
extern UART_HandleTypeDef huart3; extern UART_HandleTypeDef huart3;
@ -352,7 +353,7 @@ void init_ec801_uart()
* @retval None * @retval None
*/ */
void init_rain_uart() void init_rain_uart()
{ {
HAL_GPIO_WritePin(GPIO_RAIN_PWR_CTRL_GPIO_Port, GPIO_RAIN_PWR_CTRL_Pin, GPIO_PIN_SET); rainLightPowerOn();
g_rain_uart_handle = uart_dev_init(RAIN_RS485_UART_INDEX, rain_in_buff, sizeof(rain_in_buff)); g_rain_uart_handle = uart_dev_init(RAIN_RS485_UART_INDEX, rain_in_buff, sizeof(rain_in_buff));
} }

View File

@ -33,6 +33,7 @@ void task_shell_term_main_loop(void const * argument);
#include "inflash.h" #include "inflash.h"
#include "hp203b.h" #include "hp203b.h"
#include "encrypt.h" #include "encrypt.h"
#include "rain.h"
/* USER CODE END Includes */ /* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/ /* Private typedef -----------------------------------------------------------*/

View File

@ -167,7 +167,7 @@ void Flash_EnableReadProtection(void)
/* USER CODE BEGIN 2 */ /* USER CODE BEGIN 2 */
init_term_uart(); init_term_uart();
init_rs485_uart(); init_rs485_uart();
init_rain_uart();uart_dev_write(g_rain_uart_handle, "Hello", 5); init_rain_uart();
// init_ec801_uart(); // init_ec801_uart();
term_printf("Micro Climate Station Sensor.\r\n"); term_printf("Micro Climate Station Sensor.\r\n");
term_printf("Version 1.0.0 Build: %s %s\r\n",__DATE__,__TIME__); term_printf("Version 1.0.0 Build: %s %s\r\n",__DATE__,__TIME__);

41
Drivers/RainLight/rain.c Normal file
View File

@ -0,0 +1,41 @@
#include "rain.h"
#include "gpio.h"
#include "uart_dev.h"
//开电
void rainLightPowerOn(void)
{
HAL_GPIO_WritePin(GPIO_RAIN_PWR_CTRL_GPIO_Port, GPIO_RAIN_PWR_CTRL_Pin, GPIO_PIN_SET);
}
//关电
void rainLightPowerOff(void)
{
HAL_GPIO_WritePin(GPIO_RAIN_PWR_CTRL_GPIO_Port, GPIO_RAIN_PWR_CTRL_Pin, GPIO_PIN_RESET);
}
//获取雨量指令,返回的雨量是十倍,两个字节
void getRainData(void)
{
uint8_t getRainDataCmd[] = {0x01, 0x03, 0x00, 0x00, 0x00, 0x01, 0x84, 0x0A};
uart_dev_write(g_rain_uart_handle, getRainDataCmd, sizeof(getRainDataCmd));
}
//清空雨量指令
void clearRainData(void)
{
uint8_t getRainDataCmd[] = {0x01, 0x06, 0x00, 0x00, 0x00, 0x5A, 0x09, 0xF1};
uart_dev_write(g_rain_uart_handle, getRainDataCmd, sizeof(getRainDataCmd));
}
//获取光照指令,返回一倍光照,四个字节
void getLightData(void)
{
uint8_t getRainDataCmd[] = {0x01, 0x03, 0x00, 0x02, 0x00, 0x02, 0x65, 0xCB};
uart_dev_write(g_rain_uart_handle, getRainDataCmd, sizeof(getRainDataCmd));
}
void readProcessRainData(device_handle device)
{
}

18
Drivers/RainLight/rain.h Normal file
View File

@ -0,0 +1,18 @@
#ifndef __RAIN_H__
#define __RAIN_H__
#ifdef __cplusplus
extern "C" {
#endif
void rainLightPowerOn(void); //开雨量光照电源
void rainLightPowerOff(void); //关雨量光照电源
void getRainData(void); //获取雨量指令
void clearRainData(void); //清空雨量电源
void getLightData(void); //获取光照数据
#ifdef __cplusplus
}
#endif
#endif /*___RAIN_H__ */

View File

@ -374,6 +374,7 @@
<state>$PROJ_DIR$\..\tools</state> <state>$PROJ_DIR$\..\tools</state>
<state>$PROJ_DIR$\..\App\Inc</state> <state>$PROJ_DIR$\..\App\Inc</state>
<state>$PROJ_DIR$\..\Drivers\HP203B</state> <state>$PROJ_DIR$\..\Drivers\HP203B</state>
<state>$PROJ_DIR$\..\Drivers\RainLight</state>
</option> </option>
<option> <option>
<name>CCStdIncCheck</name> <name>CCStdIncCheck</name>
@ -2365,6 +2366,15 @@
<name>$PROJ_DIR$\..\Drivers\HP203B\hp203b.h</name> <name>$PROJ_DIR$\..\Drivers\HP203B\hp203b.h</name>
</file> </file>
</group> </group>
<group>
<name>RainLight</name>
<file>
<name>$PROJ_DIR$\..\Drivers\RainLight\rain.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\Drivers\RainLight\rain.h</name>
</file>
</group>
<group> <group>
<name>RingQueue</name> <name>RingQueue</name>
<file> <file>

View File

@ -2994,6 +2994,15 @@
<name>$PROJ_DIR$\..\Drivers\HP203B\hp203b.h</name> <name>$PROJ_DIR$\..\Drivers\HP203B\hp203b.h</name>
</file> </file>
</group> </group>
<group>
<name>RainLight</name>
<file>
<name>$PROJ_DIR$\..\Drivers\RainLight\rain.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\Drivers\RainLight\rain.h</name>
</file>
</group>
<group> <group>
<name>RingQueue</name> <name>RingQueue</name>
<file> <file>