tests with fixed hw
This commit is contained in:
@ -3,4 +3,4 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
project(ethernet_basic)
|
||||
project(network_tester)
|
||||
|
||||
2
Makefile
2
Makefile
@ -3,7 +3,7 @@
|
||||
# project subdirectory.
|
||||
#
|
||||
|
||||
PROJECT_NAME := ethernet_basic
|
||||
PROJECT_NAME := network_tester
|
||||
|
||||
include $(IDF_PATH)/make/project.mk
|
||||
|
||||
|
||||
114
main/main.c
114
main/main.c
@ -35,6 +35,11 @@ static const char *TAG = "eth_tester";
|
||||
#define SIGNAL_PAR_OFFSET 24
|
||||
#define SIGNAL_MASK 0x00FFFFFF
|
||||
|
||||
#define BUTTON_TOP_R 14
|
||||
#define BUTTON_TOP_L 15
|
||||
#define BUTTON_BOT_L 2
|
||||
#define BUTTON_BOT_R 5
|
||||
|
||||
#define LINE_STATUS_MAIN 0
|
||||
|
||||
#define LINE_ID_ADDR 2
|
||||
@ -52,7 +57,7 @@ esp_ip4_addr_t ip_addr;
|
||||
esp_ip4_addr_t ip_snm;
|
||||
esp_ip4_addr_t ip_gw;
|
||||
esp_netif_t *eth_netif;
|
||||
esp_ping_handle_t ping;
|
||||
//esp_ping_handle_t ping;
|
||||
|
||||
int dns_resolv = -1;
|
||||
|
||||
@ -93,28 +98,28 @@ static void check_resolution(void *arg)
|
||||
}
|
||||
|
||||
//TODO: Implement ping https://github.com/espressif/esp-idf/blob/master/examples/protocols/icmp_echo/main/echo_example_main.c
|
||||
static void start_icmp_ping()
|
||||
{
|
||||
esp_ping_config_t config = ESP_PING_DEFAULT_CONFIG();
|
||||
// static void start_icmp_ping()
|
||||
// {
|
||||
// esp_ping_config_t config = ESP_PING_DEFAULT_CONFIG();
|
||||
|
||||
config.timeout_ms = 1000;
|
||||
config.interval_ms = 1000;
|
||||
config.count = 16;
|
||||
// config.timeout_ms = 1000;
|
||||
// config.interval_ms = 1000;
|
||||
// config.count = 16;
|
||||
|
||||
config.target_addr = target_addr;
|
||||
// config.target_addr = target_addr;
|
||||
|
||||
/* set callback functions */
|
||||
esp_ping_callbacks_t cbs = {
|
||||
.on_ping_success = cmd_ping_on_ping_success,
|
||||
.on_ping_timeout = cmd_ping_on_ping_timeout,
|
||||
.on_ping_end = cmd_ping_on_ping_end,
|
||||
.cb_args = NULL
|
||||
};
|
||||
esp_ping_new_session(&config, &cbs, &ping);
|
||||
esp_ping_start(ping);
|
||||
// /* set callback functions */
|
||||
// esp_ping_callbacks_t cbs = {
|
||||
// .on_ping_success = cmd_ping_on_ping_success,
|
||||
// .on_ping_timeout = cmd_ping_on_ping_timeout,
|
||||
// .on_ping_end = cmd_ping_on_ping_end,
|
||||
// .cb_args = NULL
|
||||
// };
|
||||
// esp_ping_new_session(&config, &cbs, &ping);
|
||||
// esp_ping_start(ping);
|
||||
|
||||
return 0;
|
||||
}
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
static void refresh_display()
|
||||
{
|
||||
@ -191,6 +196,11 @@ static void refresh_display()
|
||||
ssd1306_display_text(&display, LINE_STATUS_FLAGS3, "LNK", 3, eth, 9);
|
||||
ssd1306_display_text(&display, LINE_STATUS_FLAGS3, "DHCP", 4, addr, 4);
|
||||
ssd1306_display_text(&display, LINE_STATUS_FLAGS3, "DNS", 3, dns, 0);
|
||||
|
||||
ssd1306_display_text(&display, 0, " ", 1, gpio_get_level(BUTTON_TOP_L), 14);
|
||||
ssd1306_display_text(&display, 0, " ", 1, gpio_get_level(BUTTON_TOP_R), 15);
|
||||
ssd1306_display_text(&display, 1, " ", 1, gpio_get_level(BUTTON_BOT_L), 14);
|
||||
ssd1306_display_text(&display, 1, " ", 1, gpio_get_level(BUTTON_BOT_R), 15);
|
||||
}
|
||||
|
||||
/** Event handler for Ethernet events */
|
||||
@ -289,13 +299,37 @@ static void task_signals(void* arg)
|
||||
}
|
||||
|
||||
if (sig == SIGNAL_BUTTON) {
|
||||
//ESP_LOGI(TAG, "Button pressed: %d", par);
|
||||
ESP_LOGI(TAG, "Button pressed: %d", par);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void configure_single_pin(gpio_num_t pin, gpio_int_type_t intr_type, gpio_mode_t mode, int8_t pull) {
|
||||
|
||||
//zero-initialize the config structure.
|
||||
gpio_config_t io_conf = {};
|
||||
|
||||
//interrupt of rising edge
|
||||
io_conf.intr_type = intr_type;
|
||||
//bit mask of the pins, here 34 + front buttons
|
||||
io_conf.pin_bit_mask = 1ULL<<pin;
|
||||
|
||||
// pull down
|
||||
io_conf.pull_down_en = (pull < 0);
|
||||
|
||||
// pull down
|
||||
io_conf.pull_up_en = (pull > 0);
|
||||
//set as input mode
|
||||
io_conf.mode = mode;
|
||||
|
||||
gpio_reset_pin(pin);
|
||||
|
||||
ESP_ERROR_CHECK(gpio_config(&io_conf));
|
||||
|
||||
}
|
||||
|
||||
#define PIN_PHY_POWER 12
|
||||
void app_main(void)
|
||||
{
|
||||
@ -426,44 +460,28 @@ void app_main(void)
|
||||
|
||||
// gpio setup
|
||||
|
||||
// onboard button
|
||||
configure_single_pin(34, GPIO_INTR_POSEDGE, GPIO_MODE_INPUT, 0);
|
||||
|
||||
//front buttons
|
||||
|
||||
//zero-initialize the config structure.
|
||||
gpio_config_t io_conf = {};
|
||||
|
||||
//interrupt of rising edge
|
||||
io_conf.intr_type = GPIO_INTR_NEGEDGE;
|
||||
//bit mask of the pins, here 34 + front buttons
|
||||
io_conf.pin_bit_mask = 1ULL<<34;
|
||||
|
||||
for (int i = 0; i < ex_button_count; i++) {
|
||||
io_conf.pin_bit_mask = io_conf.pin_bit_mask | (1ULL<<ex_buttons[i]);
|
||||
configure_single_pin(ex_buttons[i], GPIO_INTR_POSEDGE, GPIO_MODE_INPUT, 1);
|
||||
}
|
||||
|
||||
uint8_t *bit_mask;
|
||||
bit_mask = (uint8_t*)&io_conf.pin_bit_mask;
|
||||
ESP_LOGI(TAG, "pin_bit_mask: %02x %02x %02x %02x %02x %02x %02x %02x", bit_mask[7], bit_mask[6], bit_mask[5], bit_mask[4], bit_mask[3], bit_mask[2], bit_mask[1], bit_mask[0]);
|
||||
|
||||
// pull down
|
||||
io_conf.pull_down_en = 1;
|
||||
//set as input mode
|
||||
io_conf.mode = GPIO_MODE_INPUT;
|
||||
|
||||
ESP_ERROR_CHECK(gpio_config(&io_conf));
|
||||
|
||||
// setup interrupts for buttons
|
||||
ESP_ERROR_CHECK(gpio_set_intr_type(34, GPIO_INTR_POSEDGE));
|
||||
|
||||
for (int i = 0; i < ex_button_count; i++) {
|
||||
ESP_ERROR_CHECK(gpio_set_intr_type(ex_buttons[i], GPIO_INTR_NEGEDGE));
|
||||
ESP_ERROR_CHECK(gpio_set_intr_type(ex_buttons[i], GPIO_INTR_POSEDGE));
|
||||
}
|
||||
|
||||
// interrut for shutdown/deep sleep
|
||||
// interrupt for shutdown/deep sleep
|
||||
ESP_ERROR_CHECK(gpio_install_isr_service(ESP_INTR_FLAG_LOWMED));
|
||||
ESP_ERROR_CHECK(gpio_isr_handler_add(34, isr_shutdown, NULL));
|
||||
|
||||
// interrupts for front buttons
|
||||
for (int i = 0; i < ex_button_count; i++) {
|
||||
uint32_t btn = ex_buttons + i;
|
||||
uint32_t *btn = ex_buttons + i;
|
||||
ESP_ERROR_CHECK(gpio_isr_handler_add(ex_buttons[i], isr_button, (void*)btn));
|
||||
ESP_LOGI(TAG, "Installed ISR on pin %d", ex_buttons[i]);
|
||||
}
|
||||
@ -483,8 +501,10 @@ void app_main(void)
|
||||
refresh_display();
|
||||
vTaskDelay(350 / portTICK_RATE_MS);
|
||||
|
||||
for (int i = 0; i < ex_button_count; i++) {
|
||||
//ESP_LOGI(TAG, "Button status (%d): %d", ex_buttons[i], gpio_get_level(ex_buttons[i]));
|
||||
}
|
||||
// ESP_LOGI(TAG, "Button status: %d %d %d %d",
|
||||
// gpio_get_level(ex_buttons[0]),
|
||||
// gpio_get_level(ex_buttons[1]),
|
||||
// gpio_get_level(ex_buttons[2]),
|
||||
// gpio_get_level(ex_buttons[3]));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user