Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4c313d7e9a | |||
| 1a24f57025 | |||
| 501c6f5b95 | |||
| 26bd041b02 | |||
| effcee1cbb | |||
| 3e68e40b32 | |||
| fd12bd513e | |||
| a04fe393d7 | |||
| 43f5329f63 | |||
| 14ba98bb08 | |||
| ab64f0d9c0 | |||
| dcffb5d5da | |||
| d5430fc77b | |||
| 3b0666e53b | |||
| 0fe4438133 | |||
| a65651dde8 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -2,3 +2,5 @@
|
|||||||
.DS_Store
|
.DS_Store
|
||||||
build
|
build
|
||||||
sdkconfig.old
|
sdkconfig.old
|
||||||
|
desktop.ini
|
||||||
|
.PVS-Studio
|
||||||
10
README.md
10
README.md
@@ -1,6 +1,12 @@
|
|||||||
# ATE0004
|
# Honeywell Retractable Landing Light CMM 33-42-07 P/N 45-0351-X Motor Test Box
|
||||||
|
|
||||||
Honeywell Retractable Landing Light CMM 33-42-07 P/N 45-0351-X Motor Test Box.
|
## Tested on
|
||||||
|
|
||||||
|
1. [ESP32 ESP-IDF v5.5.1](https://docs.espressif.com/projects/esp-idf/en/v5.5.1/esp32/index.html)
|
||||||
|
|
||||||
|
## SAST Tools
|
||||||
|
|
||||||
|
[PVS-Studio](https://pvs-studio.com/pvs-studio/?utm_source=website&utm_medium=github&utm_campaign=open_source) - static analyzer for C, C++, C#, and Java code.
|
||||||
|
|
||||||
## Build and flash
|
## Build and flash
|
||||||
|
|
||||||
|
|||||||
Submodule components/zh_pcf8574 updated: 157aa7f49b...de9ece9c0d
BIN
doc/ATE0004 Руководство по эксплуатации.docx
Normal file
BIN
doc/ATE0004 Руководство по эксплуатации.docx
Normal file
Binary file not shown.
136
main/ate0004.c
136
main/ate0004.c
@@ -1,37 +1,37 @@
|
|||||||
#include "ate0004.h"
|
#include "ate0004.h"
|
||||||
|
|
||||||
static i2c_master_bus_handle_t i2c_bus_handle = NULL;
|
static i2c_master_bus_handle_t _i2c_bus_handle = NULL;
|
||||||
static httpd_handle_t webserver_handle = NULL;
|
static httpd_handle_t _webserver_handle = NULL;
|
||||||
|
|
||||||
static zh_pcf8574_handle_t button_handle = {0};
|
static zh_pcf8574_handle_t _button_handle = {0};
|
||||||
static zh_pcf8574_handle_t led_handle = {0};
|
static zh_pcf8574_handle_t _led_handle = {0};
|
||||||
static zh_pcf8574_handle_t relay_handle = {0};
|
static zh_pcf8574_handle_t _relay_handle = {0};
|
||||||
|
|
||||||
static bool is_ts = true;
|
static bool _is_ts_enabled = true;
|
||||||
static bool is_ret = false;
|
static bool _is_ret_enabled = false;
|
||||||
static bool is_ext = false;
|
static bool _is_ext_enabled = false;
|
||||||
|
|
||||||
static void zh_wifi_softap_init(void);
|
static void _zh_wifi_softap_init(void);
|
||||||
static void zh_webserver_init(void);
|
static void _zh_webserver_init(void);
|
||||||
static void zh_gpio_init(void);
|
static void _zh_gpio_init(void);
|
||||||
static void zh_io_expander_init(void);
|
static void _zh_pcf8574_init(void);
|
||||||
static void zh_pcf8574_event_handler(void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data);
|
static void _zh_pcf8574_event_handler(void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data);
|
||||||
|
|
||||||
void app_main(void)
|
void app_main(void)
|
||||||
{
|
{
|
||||||
nvs_flash_init();
|
nvs_flash_init();
|
||||||
esp_event_loop_create_default();
|
esp_event_loop_create_default();
|
||||||
zh_wifi_softap_init();
|
_zh_wifi_softap_init();
|
||||||
zh_webserver_init();
|
_zh_webserver_init();
|
||||||
zh_gpio_init();
|
_zh_gpio_init();
|
||||||
gpio_set_level(TRIAC_GPIO, LOW);
|
gpio_set_level(TRIAC_GPIO, LOW);
|
||||||
zh_io_expander_init();
|
_zh_pcf8574_init();
|
||||||
zh_pcf8574_write_gpio(&led_handle, TS_LED_GREEN, LED_ON);
|
zh_pcf8574_write_gpio(&_led_handle, TS_LED_GREEN, LED_ON);
|
||||||
zh_pcf8574_write_gpio(&led_handle, RET_LED_BLUE, LED_ON);
|
zh_pcf8574_write_gpio(&_led_handle, RET_LED_BLUE, LED_ON);
|
||||||
zh_pcf8574_write_gpio(&led_handle, EXT_LED_BLUE, LED_ON);
|
zh_pcf8574_write_gpio(&_led_handle, EXT_LED_BLUE, LED_ON);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void zh_wifi_softap_init(void)
|
static void _zh_wifi_softap_init(void)
|
||||||
{
|
{
|
||||||
esp_netif_init();
|
esp_netif_init();
|
||||||
esp_netif_create_default_wifi_ap();
|
esp_netif_create_default_wifi_ap();
|
||||||
@@ -41,7 +41,7 @@ static void zh_wifi_softap_init(void)
|
|||||||
.ap = {
|
.ap = {
|
||||||
.ssid = WIFI_SSID,
|
.ssid = WIFI_SSID,
|
||||||
.password = WIFI_PASS,
|
.password = WIFI_PASS,
|
||||||
.max_connection = 4,
|
.max_connection = MAX_STA_CONNECTION,
|
||||||
.authmode = WIFI_AUTH_WPA2_PSK,
|
.authmode = WIFI_AUTH_WPA2_PSK,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -50,14 +50,14 @@ static void zh_wifi_softap_init(void)
|
|||||||
esp_wifi_start();
|
esp_wifi_start();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void zh_webserver_init(void)
|
static void _zh_webserver_init(void)
|
||||||
{
|
{
|
||||||
httpd_config_t config = HTTPD_DEFAULT_CONFIG();
|
httpd_config_t config = HTTPD_DEFAULT_CONFIG();
|
||||||
httpd_start(&webserver_handle, &config);
|
httpd_start(&_webserver_handle, &config);
|
||||||
zh_ota_server_init(webserver_handle);
|
zh_ota_server_init(_webserver_handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void zh_gpio_init(void)
|
static void _zh_gpio_init(void)
|
||||||
{
|
{
|
||||||
gpio_config_t triac_pin_config = {
|
gpio_config_t triac_pin_config = {
|
||||||
.intr_type = GPIO_INTR_DISABLE,
|
.intr_type = GPIO_INTR_DISABLE,
|
||||||
@@ -69,7 +69,7 @@ static void zh_gpio_init(void)
|
|||||||
gpio_config(&triac_pin_config);
|
gpio_config(&triac_pin_config);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void zh_io_expander_init(void)
|
static void _zh_pcf8574_init(void)
|
||||||
{
|
{
|
||||||
i2c_master_bus_config_t i2c_bus_config = {
|
i2c_master_bus_config_t i2c_bus_config = {
|
||||||
.clk_source = I2C_CLK_SRC_DEFAULT,
|
.clk_source = I2C_CLK_SRC_DEFAULT,
|
||||||
@@ -77,96 +77,96 @@ static void zh_io_expander_init(void)
|
|||||||
.sda_io_num = GPIO_NUM_21,
|
.sda_io_num = GPIO_NUM_21,
|
||||||
.glitch_ignore_cnt = 7,
|
.glitch_ignore_cnt = 7,
|
||||||
};
|
};
|
||||||
i2c_new_master_bus(&i2c_bus_config, &i2c_bus_handle);
|
i2c_new_master_bus(&i2c_bus_config, &_i2c_bus_handle);
|
||||||
esp_event_handler_instance_register(ZH_PCF8574, ESP_EVENT_ANY_ID, &zh_pcf8574_event_handler, NULL, NULL);
|
esp_event_handler_instance_register(ZH_PCF8574, ESP_EVENT_ANY_ID, &_zh_pcf8574_event_handler, NULL, NULL);
|
||||||
zh_pcf8574_init_config_t config = ZH_PCF8574_INIT_CONFIG_DEFAULT();
|
zh_pcf8574_init_config_t config = ZH_PCF8574_INIT_CONFIG_DEFAULT();
|
||||||
config.i2c_handle = i2c_bus_handle;
|
config.i2c_handle = _i2c_bus_handle;
|
||||||
config.i2c_address = LED_I2C_ADDRESS;
|
config.i2c_address = LED_I2C_ADDRESS;
|
||||||
zh_pcf8574_init(&config, &led_handle);
|
zh_pcf8574_init(&config, &_led_handle);
|
||||||
config.i2c_address = RELAY_I2C_ADDRESS;
|
config.i2c_address = RELAY_I2C_ADDRESS;
|
||||||
zh_pcf8574_init(&config, &relay_handle);
|
zh_pcf8574_init(&config, &_relay_handle);
|
||||||
config.i2c_address = BUTTON_I2C_ADDRESS;
|
config.i2c_address = BUTTON_I2C_ADDRESS;
|
||||||
config.p0_gpio_work_mode = true;
|
config.p0_gpio_work_mode = true;
|
||||||
config.p1_gpio_work_mode = true;
|
config.p1_gpio_work_mode = true;
|
||||||
config.p2_gpio_work_mode = true;
|
config.p2_gpio_work_mode = true;
|
||||||
config.interrupt_gpio = GPIO_NUM_17;
|
config.interrupt_gpio = GPIO_NUM_17;
|
||||||
zh_pcf8574_init(&config, &button_handle);
|
zh_pcf8574_init(&config, &_button_handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void zh_pcf8574_event_handler(void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data)
|
static void _zh_pcf8574_event_handler(void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data)
|
||||||
{
|
{
|
||||||
zh_pcf8574_event_on_isr_t *event = event_data;
|
zh_pcf8574_event_on_isr_t *event = event_data;
|
||||||
switch (event->gpio_number)
|
switch (event->gpio_number)
|
||||||
{
|
{
|
||||||
case TS_BUTTON:
|
case TS_BUTTON:
|
||||||
if (event->gpio_level == LOW && is_ret == false && is_ext == false)
|
if (event->gpio_level == LOW && _is_ret_enabled == false && _is_ext_enabled == false)
|
||||||
{
|
{
|
||||||
if (is_ts == true)
|
if (_is_ts_enabled == true)
|
||||||
{
|
{
|
||||||
zh_pcf8574_write_gpio(&led_handle, TS_LED_RED, LED_ON);
|
zh_pcf8574_write_gpio(&_led_handle, TS_LED_RED, LED_ON);
|
||||||
zh_pcf8574_write_gpio(&led_handle, TS_LED_GREEN, LED_OFF);
|
zh_pcf8574_write_gpio(&_led_handle, TS_LED_GREEN, LED_OFF);
|
||||||
zh_pcf8574_write_gpio(&relay_handle, TS_RELAY, RELAY_ON);
|
zh_pcf8574_write_gpio(&_relay_handle, TS_RELAY, RELAY_ON);
|
||||||
is_ts = false;
|
_is_ts_enabled = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
zh_pcf8574_write_gpio(&led_handle, TS_LED_RED, LED_OFF);
|
zh_pcf8574_write_gpio(&_led_handle, TS_LED_RED, LED_OFF);
|
||||||
zh_pcf8574_write_gpio(&led_handle, TS_LED_GREEN, LED_ON);
|
zh_pcf8574_write_gpio(&_led_handle, TS_LED_GREEN, LED_ON);
|
||||||
zh_pcf8574_write_gpio(&relay_handle, TS_RELAY, RELAY_OFF);
|
zh_pcf8574_write_gpio(&_relay_handle, TS_RELAY, RELAY_OFF);
|
||||||
is_ts = true;
|
_is_ts_enabled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case RET_BUTTON:
|
case RET_BUTTON:
|
||||||
if (is_ext == true)
|
if (_is_ext_enabled == true)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (event->gpio_level == LOW)
|
if (event->gpio_level == LOW)
|
||||||
{
|
{
|
||||||
is_ret = true;
|
_is_ret_enabled = true;
|
||||||
zh_pcf8574_write_gpio(&led_handle, RET_LED_BLUE, LED_OFF);
|
zh_pcf8574_write_gpio(&_led_handle, RET_LED_BLUE, LED_OFF);
|
||||||
zh_pcf8574_write_gpio(&led_handle, RET_LED_GREEN, LED_ON);
|
zh_pcf8574_write_gpio(&_led_handle, RET_LED_GREEN, LED_ON);
|
||||||
zh_pcf8574_write_gpio(&relay_handle, RET_RELAY, RELAY_ON);
|
zh_pcf8574_write_gpio(&_relay_handle, RET_RELAY, RELAY_ON);
|
||||||
zh_pcf8574_write_gpio(&relay_handle, GROUND_RELAY, RELAY_ON);
|
zh_pcf8574_write_gpio(&_relay_handle, GROUND_RELAY, RELAY_ON);
|
||||||
vTaskDelay(20 / portTICK_PERIOD_MS);
|
vTaskDelay(20 / portTICK_PERIOD_MS);
|
||||||
gpio_set_level(TRIAC_GPIO, HIGH);
|
gpio_set_level(TRIAC_GPIO, HIGH);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gpio_set_level(TRIAC_GPIO, LOW);
|
gpio_set_level(TRIAC_GPIO, LOW);
|
||||||
vTaskDelay(1 / portTICK_PERIOD_MS);
|
vTaskDelay(5 / portTICK_PERIOD_MS);
|
||||||
zh_pcf8574_write_gpio(&led_handle, RET_LED_BLUE, LED_ON);
|
zh_pcf8574_write_gpio(&_led_handle, RET_LED_BLUE, LED_ON);
|
||||||
zh_pcf8574_write_gpio(&led_handle, RET_LED_GREEN, LED_OFF);
|
zh_pcf8574_write_gpio(&_led_handle, RET_LED_GREEN, LED_OFF);
|
||||||
zh_pcf8574_write_gpio(&relay_handle, RET_RELAY, RELAY_OFF);
|
zh_pcf8574_write_gpio(&_relay_handle, RET_RELAY, RELAY_OFF);
|
||||||
zh_pcf8574_write_gpio(&relay_handle, GROUND_RELAY, RELAY_OFF);
|
zh_pcf8574_write_gpio(&_relay_handle, GROUND_RELAY, RELAY_OFF);
|
||||||
is_ret = false;
|
_is_ret_enabled = false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case EXT_BUTTON:
|
case EXT_BUTTON:
|
||||||
if (is_ret == true)
|
if (_is_ret_enabled == true)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (event->gpio_level == LOW)
|
if (event->gpio_level == LOW)
|
||||||
{
|
{
|
||||||
is_ext = true;
|
_is_ext_enabled = true;
|
||||||
zh_pcf8574_write_gpio(&led_handle, EXT_LED_BLUE, LED_OFF);
|
zh_pcf8574_write_gpio(&_led_handle, EXT_LED_BLUE, LED_OFF);
|
||||||
zh_pcf8574_write_gpio(&led_handle, EXT_LED_GREEN, LED_ON);
|
zh_pcf8574_write_gpio(&_led_handle, EXT_LED_GREEN, LED_ON);
|
||||||
zh_pcf8574_write_gpio(&relay_handle, EXT_RELAY, RELAY_ON);
|
zh_pcf8574_write_gpio(&_relay_handle, EXT_RELAY, RELAY_ON);
|
||||||
zh_pcf8574_write_gpio(&relay_handle, GROUND_RELAY, RELAY_ON);
|
zh_pcf8574_write_gpio(&_relay_handle, GROUND_RELAY, RELAY_ON);
|
||||||
vTaskDelay(20 / portTICK_PERIOD_MS);
|
vTaskDelay(20 / portTICK_PERIOD_MS);
|
||||||
gpio_set_level(TRIAC_GPIO, HIGH);
|
gpio_set_level(TRIAC_GPIO, HIGH);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gpio_set_level(TRIAC_GPIO, LOW);
|
gpio_set_level(TRIAC_GPIO, LOW);
|
||||||
vTaskDelay(1 / portTICK_PERIOD_MS);
|
vTaskDelay(5 / portTICK_PERIOD_MS);
|
||||||
zh_pcf8574_write_gpio(&led_handle, EXT_LED_BLUE, LED_ON);
|
zh_pcf8574_write_gpio(&_led_handle, EXT_LED_BLUE, LED_ON);
|
||||||
zh_pcf8574_write_gpio(&led_handle, EXT_LED_GREEN, LED_OFF);
|
zh_pcf8574_write_gpio(&_led_handle, EXT_LED_GREEN, LED_OFF);
|
||||||
zh_pcf8574_write_gpio(&relay_handle, EXT_RELAY, RELAY_OFF);
|
zh_pcf8574_write_gpio(&_relay_handle, EXT_RELAY, RELAY_OFF);
|
||||||
zh_pcf8574_write_gpio(&relay_handle, GROUND_RELAY, RELAY_OFF);
|
zh_pcf8574_write_gpio(&_relay_handle, GROUND_RELAY, RELAY_OFF);
|
||||||
is_ext = false;
|
_is_ext_enabled = false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -1,3 +1,7 @@
|
|||||||
|
/**
|
||||||
|
* @file ate0004.h
|
||||||
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "zh_pcf8574.h"
|
#include "zh_pcf8574.h"
|
||||||
|
|||||||
Binary file not shown.
BIN
pcb/PCB.jpeg
Normal file
BIN
pcb/PCB.jpeg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.0 MiB |
@@ -676,7 +676,7 @@ CONFIG_DAC_DMA_AUTO_16BIT_ALIGN=y
|
|||||||
# ESP-Driver:GPIO Configurations
|
# ESP-Driver:GPIO Configurations
|
||||||
#
|
#
|
||||||
# CONFIG_GPIO_ESP32_SUPPORT_SWITCH_SLP_PULL is not set
|
# CONFIG_GPIO_ESP32_SUPPORT_SWITCH_SLP_PULL is not set
|
||||||
# CONFIG_GPIO_CTRL_FUNC_IN_IRAM is not set
|
CONFIG_GPIO_CTRL_FUNC_IN_IRAM=y
|
||||||
# end of ESP-Driver:GPIO Configurations
|
# end of ESP-Driver:GPIO Configurations
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|||||||
Reference in New Issue
Block a user