添加获取清除雨量指令,获取光照指令
This commit is contained in:
parent
d92e4d08a7
commit
52d3ef0d0c
|
@ -4,6 +4,7 @@
|
|||
#include "timer.h"
|
||||
#include "gpio.h"
|
||||
#include "inflash.h"
|
||||
#include "rain.h"
|
||||
|
||||
extern UART_HandleTypeDef huart1;
|
||||
extern UART_HandleTypeDef huart3;
|
||||
|
@ -352,7 +353,7 @@ void init_ec801_uart()
|
|||
* @retval None
|
||||
*/
|
||||
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));
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ void task_shell_term_main_loop(void const * argument);
|
|||
#include "inflash.h"
|
||||
#include "hp203b.h"
|
||||
#include "encrypt.h"
|
||||
#include "rain.h"
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
|
|
|
@ -167,7 +167,7 @@ void Flash_EnableReadProtection(void)
|
|||
/* USER CODE BEGIN 2 */
|
||||
init_term_uart();
|
||||
init_rs485_uart();
|
||||
init_rain_uart();uart_dev_write(g_rain_uart_handle, "Hello", 5);
|
||||
init_rain_uart();
|
||||
// init_ec801_uart();
|
||||
term_printf("Micro Climate Station Sensor.\r\n");
|
||||
term_printf("Version 1.0.0 Build: %s %s\r\n",__DATE__,__TIME__);
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
||||
}
|
|
@ -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__ */
|
||||
|
|
@ -374,6 +374,7 @@
|
|||
<state>$PROJ_DIR$\..\tools</state>
|
||||
<state>$PROJ_DIR$\..\App\Inc</state>
|
||||
<state>$PROJ_DIR$\..\Drivers\HP203B</state>
|
||||
<state>$PROJ_DIR$\..\Drivers\RainLight</state>
|
||||
</option>
|
||||
<option>
|
||||
<name>CCStdIncCheck</name>
|
||||
|
@ -2365,6 +2366,15 @@
|
|||
<name>$PROJ_DIR$\..\Drivers\HP203B\hp203b.h</name>
|
||||
</file>
|
||||
</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>
|
||||
<name>RingQueue</name>
|
||||
<file>
|
||||
|
|
|
@ -2994,6 +2994,15 @@
|
|||
<name>$PROJ_DIR$\..\Drivers\HP203B\hp203b.h</name>
|
||||
</file>
|
||||
</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>
|
||||
<name>RingQueue</name>
|
||||
<file>
|
||||
|
|
Loading…
Reference in New Issue