13 changed files with 287 additions and 38 deletions
-
2app_protocols/transmit_disfection_protocol
-
2usrc/app/dmapp.cpp
-
23usrc/app/ext_ch_selector_app.cpp
-
37usrc/app/ext_ch_selector_app.hpp
-
69usrc/app/exth2o2_sensor.cpp
-
45usrc/app/exth2o2_sensor.hpp
-
8usrc/app_main.cpp
-
47usrc/board/public_board.cpp
-
12usrc/board_base/app_share/blower_controller.hpp
-
53usrc/board_base/baseboard/h2o2_ext_board.cpp
-
11usrc/board_base/baseboard/h2o2_ext_board.hpp
-
3usrc/board_base/board_base.hpp
-
13usrc/project_configs.h
@ -1 +1 @@ |
|||
Subproject commit 38ea8db7c4b148c6f21b03b1099a82258ed8cd3f |
|||
Subproject commit bbda34d9edff33e1da63790fe4320fedd2595e30 |
@ -0,0 +1,23 @@ |
|||
#include "ext_ch_selector_app.hpp"
|
|||
|
|||
using namespace iflytop; |
|||
using namespace transmit_disfection_protocol; |
|||
#define TAG "ExtChSelector"
|
|||
ExtChSelector* ExtChSelector::ins() { |
|||
static ExtChSelector instance; |
|||
return &instance; |
|||
} |
|||
void ExtChSelector::initialize() { |
|||
ctrl0.initAsOutput(PinNull, kxs_gpio_nopull, false, false); |
|||
ctrl1.initAsOutput(PinNull, kxs_gpio_nopull, false, false); |
|||
ctrl2.initAsOutput(PinNull, kxs_gpio_nopull, false, false); |
|||
|
|||
REG_LAMADA_FN(kfn_ext_ch_selector_set_ch, [&](ProcessContext* cxt) { |
|||
int ch = GET_PARAM(0); |
|||
ZLOGI(TAG, "ext_ch_selector_set_ch : %d", ch); |
|||
if (ch == kext_ch_disinfection) { |
|||
} else if (ch == kext_ch_degradation) { |
|||
} else if (ch == kext_ch_dehumidification) { |
|||
} |
|||
}); |
|||
} |
@ -0,0 +1,37 @@ |
|||
#pragma once
|
|||
#include "board/public_board.hpp"
|
|||
#include "board_base/board_base.hpp"
|
|||
|
|||
/**
|
|||
* @brief |
|||
* |
|||
* |
|||
* 小空间和大空间硬件一样 |
|||
* |
|||
* 管道式-液路控制板 |
|||
* 相比于大空间消毒机,不同的点: |
|||
* 1.增加比例阀控制 |
|||
* 2.空压机通道控制 |
|||
* 管道式-功率板 |
|||
* 相比于大空间消毒机,不同的点: |
|||
* 1. 风机改成鼓风机(可控风速) |
|||
* |
|||
* 拉杆箱- |
|||
* |
|||
*/ |
|||
|
|||
namespace iflytop { |
|||
using namespace transmit_disfection_protocol; |
|||
|
|||
class ExtChSelector { |
|||
public: |
|||
ZGPIO ctrl0; |
|||
ZGPIO ctrl1; |
|||
ZGPIO ctrl2; |
|||
|
|||
public: |
|||
static ExtChSelector* ins(); |
|||
|
|||
void initialize(); |
|||
}; |
|||
} // namespace iflytop
|
@ -0,0 +1,69 @@ |
|||
#include "exth2o2_sensor.hpp"
|
|||
|
|||
using namespace iflytop; |
|||
using namespace transmit_disfection_protocol; |
|||
#define TAG "ExtH2O2Sensor"
|
|||
|
|||
static osThreadId H2O2SensorMonitorThreadId; |
|||
static osThreadId AlarmLightThreadId; |
|||
|
|||
static void c_onAlarmLightThread(void const* argument) { ExtH2O2Sensor::ins()->onAlarmLightThread(); } |
|||
static void c_onH2O2MonitorThread(void const* argument) { ExtH2O2Sensor::ins()->onH2O2MonitorThread(); } |
|||
|
|||
ExtH2O2Sensor* ExtH2O2Sensor::ins() { |
|||
static ExtH2O2Sensor instance; |
|||
return &instance; |
|||
} |
|||
void ExtH2O2Sensor::initialize() { |
|||
LargeSpaceDmPowerCtrlBoardHal::HUART3_INIT(19200, UART_STOPBITS_2); |
|||
H2O2ExtBoard::HADC1_INIT(); |
|||
|
|||
h2o2Sensor.initialize(&huart2, &hadc1, ADC_CHANNEL_10); |
|||
|
|||
m_alarmLightR.initAsOutput(PD7, kxs_gpio_pullup, true, false); |
|||
m_alarmLightG.initAsOutput(PD9, kxs_gpio_pullup, true, false); |
|||
m_alarmLightY.initAsOutput(PD8, kxs_gpio_pullup, true, false); |
|||
id_from_machine.initAsInput(PE8, kxs_gpio_nopull, kxs_gpio_no_irq, false); |
|||
|
|||
BIND_FN(H2O2SensorDriver, &h2o2Sensor, fn_h2o2_sensor_read_calibration_date); |
|||
BIND_FN(H2O2SensorDriver, &h2o2Sensor, fn_h2o2_sensor_read_sub_ic_errorcode); |
|||
BIND_FN(H2O2SensorDriver, &h2o2Sensor, fn_h2o2_sensor_read_sub_ic_reg); |
|||
|
|||
osThreadDef(H2O2SensorMonitor, c_onH2O2MonitorThread, osPriorityNormal, 0, 1024); |
|||
H2O2SensorMonitorThreadId = osThreadCreate(osThread(H2O2SensorMonitor), NULL); |
|||
|
|||
osThreadDef(AlarmLightThread, c_onAlarmLightThread, osPriorityNormal, 0, 1024); |
|||
AlarmLightThreadId = osThreadCreate(osThread(AlarmLightThread), NULL); |
|||
} |
|||
void ExtH2O2Sensor::setAlarmLight(light_state_t state) { m_alarmLightState = state; } |
|||
|
|||
void ExtH2O2Sensor::setAlarmLight(bool r, bool g, bool y) { |
|||
m_alarmLightR.write(r); |
|||
m_alarmLightG.write(g); |
|||
m_alarmLightY.write(y); |
|||
} |
|||
void ExtH2O2Sensor::onAlarmLightThread() { |
|||
while (1) { |
|||
osDelay(500); |
|||
if (m_alarmLightState == kdisconnected) { |
|||
static bool state; |
|||
setAlarmLight(false, state, false); |
|||
state = !state; |
|||
} else if (m_alarmLightState == kconnected) { |
|||
setAlarmLight(false, true, false); |
|||
} else if (m_alarmLightState == kerror) { |
|||
setAlarmLight(true, false, false); |
|||
} |
|||
} |
|||
} |
|||
|
|||
void ExtH2O2Sensor::onH2O2MonitorThread() { |
|||
while (1) { |
|||
if (h2o2Sensor.h2o2_sensor_read_sub_ic_errorcode() != 0) { |
|||
ZLOGI(TAG, "H2O2 sensor sub ic error"); |
|||
setAlarmLight(kerror); |
|||
} else { |
|||
setAlarmLight(kconnected); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,45 @@ |
|||
#pragma once
|
|||
#include "board/public_board.hpp"
|
|||
#include "board_base/board_base.hpp"
|
|||
|
|||
/**
|
|||
* @brief |
|||
* |
|||
* |
|||
*/ |
|||
|
|||
namespace iflytop { |
|||
using namespace transmit_disfection_protocol; |
|||
|
|||
class ExtH2O2Sensor { |
|||
public: |
|||
typedef enum { |
|||
kdisconnected, |
|||
kconnected, |
|||
kerror, |
|||
} light_state_t; |
|||
|
|||
public: |
|||
H2O2SensorDriver h2o2Sensor; |
|||
|
|||
ZGPIO m_alarmLightR; |
|||
ZGPIO m_alarmLightG; |
|||
ZGPIO m_alarmLightY; |
|||
|
|||
ZGPIO id_from_machine; // 消毒机上的开关
|
|||
light_state_t m_alarmLightState = kdisconnected; |
|||
|
|||
public: |
|||
static ExtH2O2Sensor* ins(); |
|||
|
|||
void initialize(); |
|||
|
|||
private: |
|||
void setAlarmLight(bool r, bool g, bool y); |
|||
void setAlarmLight(light_state_t state); |
|||
|
|||
public: |
|||
void onAlarmLightThread(); |
|||
void onH2O2MonitorThread(); |
|||
}; |
|||
} // namespace iflytop
|
@ -0,0 +1,53 @@ |
|||
#include "h2o2_ext_board.hpp"
|
|||
|
|||
#include "base/appdep.hpp"
|
|||
|
|||
using namespace iflytop; |
|||
|
|||
void H2O2ExtBoard::HADC1_INIT() { |
|||
static bool inited = false; |
|||
if (inited) return; |
|||
inited = true; |
|||
|
|||
__HAL_RCC_ADC1_CLK_ENABLE(); |
|||
__HAL_RCC_GPIOC_CLK_ENABLE(); |
|||
|
|||
ADC_ChannelConfTypeDef sConfig = {0}; |
|||
GPIO_InitTypeDef GPIO_InitStruct = {0}; |
|||
|
|||
hadc1.Instance = ADC1; |
|||
hadc1.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV2; |
|||
hadc1.Init.Resolution = ADC_RESOLUTION_12B; |
|||
hadc1.Init.ScanConvMode = DISABLE; |
|||
hadc1.Init.ContinuousConvMode = DISABLE; |
|||
hadc1.Init.DiscontinuousConvMode = DISABLE; |
|||
hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE; |
|||
hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START; |
|||
hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT; |
|||
hadc1.Init.NbrOfConversion = 1; |
|||
hadc1.Init.DMAContinuousRequests = DISABLE; |
|||
hadc1.Init.EOCSelection = ADC_EOC_SINGLE_CONV; |
|||
if (HAL_ADC_Init(&hadc1) != HAL_OK) { |
|||
Error_Handler(); |
|||
} |
|||
|
|||
/**ADC1 GPIO Configuration
|
|||
PC0 ------> ADC1_IN10 |
|||
PC1 ------> ADC1_IN11 |
|||
*/ |
|||
GPIO_InitStruct.Pin = GPIO_PIN_0 | GPIO_PIN_1; |
|||
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; |
|||
GPIO_InitStruct.Pull = GPIO_NOPULL; |
|||
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); |
|||
|
|||
/* ADC1 interrupt Init */ |
|||
HAL_NVIC_SetPriority(ADC_IRQn, 5, 0); |
|||
HAL_NVIC_EnableIRQ(ADC_IRQn); |
|||
|
|||
sConfig.Channel = ADC_CHANNEL_0; |
|||
sConfig.Rank = 1; |
|||
sConfig.SamplingTime = ADC_SAMPLETIME_3CYCLES; |
|||
if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK) { |
|||
Error_Handler(); |
|||
} |
|||
} |
@ -0,0 +1,11 @@ |
|||
#pragma once
|
|||
|
|||
#include "base/appdep.hpp"
|
|||
|
|||
|
|||
namespace iflytop { |
|||
class H2O2ExtBoard { |
|||
public: |
|||
static void HADC1_INIT(); |
|||
}; |
|||
} // namespace iflytop
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue