Compare commits
12 Commits
1cfde391c1
...
dev
| Author | SHA1 | Date | |
|---|---|---|---|
| 32ece68fd8 | |||
| de603287ac | |||
| c12bc7e7c3 | |||
| f79f902802 | |||
| 19e7d56398 | |||
| 278ea5f874 | |||
| b0475776dc | |||
| 064e6bbe4f | |||
| edf5044b28 | |||
| 642631ac8f | |||
| ae9860aec7 | |||
| 724fda0889 |
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
.vscode
|
||||
.DS_Store
|
||||
build
|
||||
sdkconfig.old
|
||||
6
.gitmodules
vendored
Normal file
6
.gitmodules
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
[submodule "components/zh_pcf8574"]
|
||||
path = components/zh_pcf8574
|
||||
url = http://git.zh.com.ru/alexey.zholtikov/zh_pcf8574
|
||||
[submodule "components/zh_vector"]
|
||||
path = components/zh_vector
|
||||
url = http://git.zh.com.ru/alexey.zholtikov/zh_vector
|
||||
Binary file not shown.
Binary file not shown.
3
CMakeLists.txt
Executable file
3
CMakeLists.txt
Executable file
@@ -0,0 +1,3 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
project(ate0004)
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
cad/ATE0004.007.000 СБ _ KLS5-254.a3d
Normal file
BIN
cad/ATE0004.007.000 СБ _ KLS5-254.a3d
Normal file
Binary file not shown.
Binary file not shown.
1
components/zh_pcf8574
Submodule
1
components/zh_pcf8574
Submodule
Submodule components/zh_pcf8574 added at 157aa7f49b
1
components/zh_vector
Submodule
1
components/zh_vector
Submodule
Submodule components/zh_vector added at b487617d3a
BIN
ds/ADP3338.pdf
BIN
ds/ADP3338.pdf
Binary file not shown.
Binary file not shown.
BIN
ds/PCA9306.pdf
BIN
ds/PCA9306.pdf
Binary file not shown.
BIN
ds/T491.pdf
BIN
ds/T491.pdf
Binary file not shown.
1
main/CMakeLists.txt
Executable file
1
main/CMakeLists.txt
Executable file
@@ -0,0 +1 @@
|
||||
idf_component_register(SRCS "ate0004.c" INCLUDE_DIRS "" REQUIRES zh_pcf8574)
|
||||
134
main/ate0004.c
Executable file
134
main/ate0004.c
Executable file
@@ -0,0 +1,134 @@
|
||||
#include "ate0004.h"
|
||||
|
||||
static i2c_master_bus_handle_t i2c_bus_handle = NULL;
|
||||
|
||||
static zh_pcf8574_handle_t button_handle = {0};
|
||||
static zh_pcf8574_handle_t led_handle = {0};
|
||||
static zh_pcf8574_handle_t relay_handle = {0};
|
||||
|
||||
static bool is_ts = true;
|
||||
static bool is_ret = false;
|
||||
static bool is_ext = false;
|
||||
|
||||
void zh_pcf8574_event_handler(void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data);
|
||||
|
||||
void app_main(void)
|
||||
{
|
||||
esp_log_level_set("zh_pcf8574", ESP_LOG_ERROR);
|
||||
esp_log_level_set("zh_vector", ESP_LOG_ERROR);
|
||||
gpio_config_t triac_pin_config = {
|
||||
.intr_type = GPIO_INTR_DISABLE,
|
||||
.mode = GPIO_MODE_OUTPUT,
|
||||
.pin_bit_mask = (1ULL << TRIAC_GPIO),
|
||||
.pull_down_en = GPIO_PULLDOWN_DISABLE,
|
||||
.pull_up_en = GPIO_PULLUP_DISABLE,
|
||||
};
|
||||
gpio_config(&triac_pin_config);
|
||||
gpio_set_level(TRIAC_GPIO, LOW);
|
||||
i2c_master_bus_config_t i2c_bus_config = {
|
||||
.clk_source = I2C_CLK_SRC_DEFAULT,
|
||||
.scl_io_num = GPIO_NUM_22,
|
||||
.sda_io_num = GPIO_NUM_21,
|
||||
.glitch_ignore_cnt = 7,
|
||||
};
|
||||
i2c_new_master_bus(&i2c_bus_config, &i2c_bus_handle);
|
||||
esp_event_loop_create_default();
|
||||
esp_event_handler_instance_register(ZH_PCF8574, ESP_EVENT_ANY_ID, &zh_pcf8574_event_handler, NULL, NULL);
|
||||
zh_pcf8574_init_config_t pcf8574_init_config = ZH_PCF8574_INIT_CONFIG_DEFAULT();
|
||||
pcf8574_init_config.i2c_handle = i2c_bus_handle;
|
||||
pcf8574_init_config.i2c_address = LED_I2C_ADDRESS;
|
||||
zh_pcf8574_init(&pcf8574_init_config, &led_handle);
|
||||
pcf8574_init_config.i2c_address = RELAY_I2C_ADDRESS;
|
||||
zh_pcf8574_init(&pcf8574_init_config, &relay_handle);
|
||||
pcf8574_init_config.i2c_address = BUTTON_I2C_ADDRESS;
|
||||
pcf8574_init_config.p0_gpio_work_mode = true;
|
||||
pcf8574_init_config.p1_gpio_work_mode = true;
|
||||
pcf8574_init_config.p2_gpio_work_mode = true;
|
||||
pcf8574_init_config.interrupt_gpio = GPIO_NUM_17;
|
||||
zh_pcf8574_init(&pcf8574_init_config, &button_handle);
|
||||
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, EXT_LED_BLUE, LED_ON);
|
||||
}
|
||||
|
||||
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;
|
||||
switch (event->gpio_number)
|
||||
{
|
||||
case TS_BUTTON:
|
||||
if (event->gpio_level == LOW && is_ret == false && is_ext == false)
|
||||
{
|
||||
if (is_ts == true)
|
||||
{
|
||||
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(&relay_handle, TS_RELAY, RELAY_OFF);
|
||||
is_ts = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
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(&relay_handle, TS_RELAY, RELAY_ON);
|
||||
is_ts = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case RET_BUTTON:
|
||||
if (is_ext == true)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (event->gpio_level == LOW)
|
||||
{
|
||||
is_ret = true;
|
||||
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(&relay_handle, RET_RELAY, RELAY_ON);
|
||||
zh_pcf8574_write_gpio(&relay_handle, GROUND_RELAY, RELAY_ON);
|
||||
vTaskDelay(20 / portTICK_PERIOD_MS);
|
||||
gpio_set_level(TRIAC_GPIO, HIGH);
|
||||
}
|
||||
else
|
||||
{
|
||||
gpio_set_level(TRIAC_GPIO, LOW);
|
||||
vTaskDelay(1 / portTICK_PERIOD_MS);
|
||||
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(&relay_handle, RET_RELAY, RELAY_OFF);
|
||||
zh_pcf8574_write_gpio(&relay_handle, GROUND_RELAY, RELAY_OFF);
|
||||
is_ret = false;
|
||||
}
|
||||
break;
|
||||
case EXT_BUTTON:
|
||||
if (is_ret == true)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (event->gpio_level == LOW)
|
||||
{
|
||||
is_ext = true;
|
||||
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(&relay_handle, EXT_RELAY, RELAY_ON);
|
||||
zh_pcf8574_write_gpio(&relay_handle, GROUND_RELAY, RELAY_ON);
|
||||
vTaskDelay(20 / portTICK_PERIOD_MS);
|
||||
gpio_set_level(TRIAC_GPIO, HIGH);
|
||||
}
|
||||
else
|
||||
{
|
||||
gpio_set_level(TRIAC_GPIO, LOW);
|
||||
vTaskDelay(1 / portTICK_PERIOD_MS);
|
||||
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(&relay_handle, EXT_RELAY, RELAY_OFF);
|
||||
zh_pcf8574_write_gpio(&relay_handle, GROUND_RELAY, RELAY_OFF);
|
||||
is_ext = false;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
printf("Interrupt happened on device address 0x%02X on GPIO number %d at level %d.\n", event->i2c_address, event->gpio_number, event->gpio_level);
|
||||
}
|
||||
43
main/ate0004.h
Normal file
43
main/ate0004.h
Normal file
@@ -0,0 +1,43 @@
|
||||
#pragma once
|
||||
|
||||
#include "zh_pcf8574.h"
|
||||
|
||||
#define HIGH true
|
||||
#define LOW false
|
||||
|
||||
#define LED_OFF LOW
|
||||
#define LED_ON HIGH
|
||||
|
||||
#define RELAY_OFF LOW
|
||||
#define RELAY_ON HIGH
|
||||
|
||||
#define TRIAC_GPIO GPIO_NUM_4
|
||||
|
||||
#define BUTTON_I2C_ADDRESS 0x22 // U7.
|
||||
#define LED_I2C_ADDRESS 0x21 // U6.
|
||||
#define RELAY_I2C_ADDRESS 0x20 // U5.
|
||||
|
||||
#define GROUND_RELAY 0x00 // Relay K1. RL1 pin on U5.
|
||||
#define TS_RELAY 0x04 // Relay K4. RL4 pin on U5.
|
||||
#define RET_RELAY 0x03 // Relay K3. RL3 pin on U5.
|
||||
#define EXT_RELAY 0x02 // Relay K2. RL2 pin on U5.
|
||||
|
||||
#define TS_BUTTON 0x00 // Connector BT1. B1-0 on U7.
|
||||
#define RET_BUTTON 0x01 // Connector BT2. B2-1 on U7.
|
||||
#define EXT_BUTTON 0x02 // Connector BT3. B3-2 on U7.
|
||||
|
||||
#define TS_LED_RED 0x00 // Connector LE1. 2 PIN. L1-0 pin on U6.
|
||||
#define TS_LED_GREEN 0x01 // Connector LE1. 1 PIN. L1-1 pin on U6.
|
||||
#define RET_LED_BLUE 0x02 // Connector LE2. 2 PIN. L2-2 pin on U6.
|
||||
#define RET_LED_GREEN 0x03 // Connector LE2. 1 PIN. L2-3 pin on U6.
|
||||
#define EXT_LED_BLUE 0x04 // Connector LE3. 2 PIN. L3-4 pin on U6.
|
||||
#define EXT_LED_GREEN 0x05 // Connector LE3. 1 PIN. L3-5 pin on U6.
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
pcb/BOM_ATE0004.000.001_v.1.xlsx
Normal file
BIN
pcb/BOM_ATE0004.000.001_v.1.xlsx
Normal file
Binary file not shown.
BIN
pcb/Gerber_ATE0004.000.001_v.1.zip
Normal file
BIN
pcb/Gerber_ATE0004.000.001_v.1.zip
Normal file
Binary file not shown.
File diff suppressed because it is too large
Load Diff
1
version.txt
Normal file
1
version.txt
Normal file
@@ -0,0 +1 @@
|
||||
1.0.0
|
||||
Reference in New Issue
Block a user