ESP_Web_Update
This commit is contained in:
463
code/esp8266.c
463
code/esp8266.c
@@ -12,197 +12,350 @@
|
||||
#include "zf_driver_gpio.h"
|
||||
#include "zf_driver_delay.h"
|
||||
#include "status_led.h"
|
||||
|
||||
const uint8 ESP8266_syncPkt[44] = {0x00, 0x08, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x12, 0x20, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55};
|
||||
static uint8 syncPkt_index = 0;
|
||||
static uint8 esp8266_quit_download_judge_buffer[2] = {0};
|
||||
static uint8 esp8266_quit_download_judge_index = 0;
|
||||
static uint8 esp8266_quit_download_judge_flag = 0;
|
||||
static uint8 esp8266_init_flag = 0;
|
||||
uint8 esp8266_download_passthrough = 0;
|
||||
static uint8 esp8266_download_rst_flag = 0;
|
||||
|
||||
// static uint16 esp8266_uart_pass_tx_buff_index = 0;
|
||||
// static uint16 esp8266_uart_pass_rx_buff_index = 0;
|
||||
#include "vofa_client.h"
|
||||
#include "stdio.h"
|
||||
#include "string.h"
|
||||
|
||||
|
||||
void isr_uart0_rx_interrupt_hook_back(uint8 rev_data);
|
||||
static esp8266_mode_enum esp8266_mode = ESP8266_Mode_Invalid;
|
||||
static uint8 esp8266_get_config_pkt[7] = "CONFIG";
|
||||
uint8 esp8266_get_config_pkt_index = 0;
|
||||
esp8266_config_t esp8266_config;
|
||||
esp8266_status_t esp8266_status;
|
||||
|
||||
// // fifo_struct esp8266_rx_fifo;
|
||||
// #define EU_BUFFER_SIZE 1024
|
||||
// const uint8 ESP8266_syncPkt[44] = {0x00, 0x08, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x12, 0x20, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55};
|
||||
// const uint8 ESP8266_ackPkt[12] = {0xC0, 0x01, 0x08, 0x02, 0x00, 0x07, 0x07, 0x12, 0x20, 0x00, 0x00, 0xC0};
|
||||
// uint8 esp8266_ack_counter = 0;
|
||||
// uint8 esp8266_ack_flag = 0;
|
||||
// static uint8 syncPkt_index = 0;
|
||||
// static uint8 esp8266_quit_download_judge_buffer[2] = {0};
|
||||
// static uint8 esp8266_quit_download_judge_index = 0;
|
||||
// static uint8 esp8266_quit_download_judge_flag = 0;
|
||||
// uint8 esp8266_download_passthrough = 0;
|
||||
// static uint8 esp8266_download_rst_flag = 0;
|
||||
|
||||
// // static uint16 esp8266_uart_pass_tx_buff_index = 0;
|
||||
// // static uint16 esp8266_uart_pass_rx_buff_index = 0;
|
||||
|
||||
|
||||
// void isr_uart0_rx_interrupt_hook_back(uint8 rev_data);
|
||||
|
||||
// fifo_struct esp8266_rx_fifo;
|
||||
// #define EU_BUFFER_SIZE 64
|
||||
// uint8 esp8266_rx_buffer[EU_BUFFER_SIZE];
|
||||
// uint8 esp8266_rx_buffer_index = 0;
|
||||
|
||||
// // fifo_struct esp8266_tx_fifo;
|
||||
// fifo_struct esp8266_tx_fifo;
|
||||
// uint8 esp8266_tx_buffer[EU_BUFFER_SIZE];
|
||||
|
||||
void ESP8266_Init(void)
|
||||
{
|
||||
|
||||
uart_init(ESP8266_UART_CHANNEL, ESP8266_UART_BAUDRATE, ESP8266_UART_TX_PIN, ESP8266_UART_RX_PIN);
|
||||
uart_rx_interrupt(ESP8266_UART_CHANNEL, 1);
|
||||
// fifo_init(&esp8266_rx_fifo, FIFO_DATA_8BIT, esp8266_rx_buffer, sizeof(esp8266_rx_buffer));
|
||||
// fifo_init(&esp8266_rx_fifo, FIFO_DATA_8BIT, esp8266_rx_buffer, sizeof(esp8266_rx_buffer));
|
||||
// fifo_init(&esp8266_tx_fifo, FIFO_DATA_8BIT, esp8266_tx_buffer, sizeof(esp8266_tx_buffer));
|
||||
gpio_init(ESP8266_EN, GPO, 1, GPO_PUSH_PULL);
|
||||
gpio_init(ESP8266_RST, GPO, 1, GPO_PUSH_PULL);
|
||||
gpio_init(ESP8266_IO0, GPO, 1, GPO_PUSH_PULL);
|
||||
gpio_init(ESP8266_IO2, GPO, 1, GPO_PUSH_PULL);
|
||||
gpio_init(ESP8266_IO15, GPO, 0, GPO_PUSH_PULL);
|
||||
|
||||
esp8266_init_flag = 1;
|
||||
ESP8266_Set_Config((uint8 *)ESP8266_WIFI_SSID, (uint8 *)ESP8266_WIFI_PASSWORD, (uint8 *)ESP8266_WIFI_TARGET_IP, ESP8266_WIFI_TARGET_PORT);
|
||||
|
||||
esp8266_mode = ESP8266_Mode_Working;
|
||||
}
|
||||
|
||||
void ESP8266_Set_Config(uint8 *ssid, uint8 *password, uint8 *target_ip, uint16 target_port)
|
||||
{
|
||||
strcpy((char *)esp8266_config.ssid, (char *)ssid);
|
||||
strcpy((char *)esp8266_config.password, (char *)password);
|
||||
strcpy((char *)esp8266_config.target_ip, (char *)target_ip);
|
||||
esp8266_config.target_port = target_port;
|
||||
|
||||
sprintf((char *)esp8266_config.config_str,
|
||||
"{\"ip\":\"%s\",\"port\":%d,\"ssid\":\"%s\",\"password\":\"%s\"}\r\n",
|
||||
esp8266_config.target_ip,
|
||||
esp8266_config.target_port,
|
||||
esp8266_config.ssid,
|
||||
esp8266_config.password
|
||||
);
|
||||
}
|
||||
|
||||
void ESP8266_Into_Download_Mode(void)
|
||||
{
|
||||
gpio_set_level(ESP8266_IO0, 0);
|
||||
gpio_set_level(ESP8266_IO2, 1);
|
||||
gpio_set_level(ESP8266_IO15, 0);
|
||||
gpio_set_level(ESP8266_EN, 0);
|
||||
system_delay_ms(1);
|
||||
gpio_set_level(ESP8266_EN, 1);
|
||||
}
|
||||
|
||||
void ESP8266_Into_Change_Config_Mode(uint8 on)
|
||||
{
|
||||
if(esp8266_mode == ESP8266_Mode_Invalid)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(on)
|
||||
{
|
||||
esp8266_mode = ESP8266_Mode_Config;
|
||||
system_delay_ms(100);
|
||||
gpio_set_level(ESP8266_CONFIG_SEND_PIN, 0);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
gpio_set_level(ESP8266_CONFIG_SEND_PIN, 1);
|
||||
}
|
||||
}
|
||||
|
||||
void ESP8266_send_data_inner(uint8 *data, uint32 len)
|
||||
{
|
||||
if(esp8266_mode != ESP8266_Mode_Working && esp8266_mode != ESP8266_Mode_Invalid)
|
||||
{
|
||||
uart_write_buffer(ESP8266_UART_CHANNEL, data, len);
|
||||
}
|
||||
}
|
||||
|
||||
void ESP8266_send_data(uint8 *data, uint32 len)
|
||||
{
|
||||
if(esp8266_download_passthrough)
|
||||
if(esp8266_mode == ESP8266_Mode_Working)
|
||||
{
|
||||
return;
|
||||
}
|
||||
uart_write_buffer(ESP8266_UART_CHANNEL, data, len);
|
||||
}
|
||||
|
||||
void ESP8266_Main_Loop_Change_Mode(void)
|
||||
{
|
||||
if(esp8266_quit_download_judge_flag >= 4)
|
||||
{
|
||||
esp8266_download_passthrough = 0;
|
||||
esp8266_quit_download_judge_flag = 0;
|
||||
esp8266_download_rst_flag = 0;
|
||||
gpio_set_level(ESP8266_IO0, 1);
|
||||
gpio_set_level(ESP8266_IO2, 1);
|
||||
gpio_set_level(ESP8266_IO15, 0);
|
||||
gpio_set_level(ESP8266_EN, 0);
|
||||
// gpio_set_level(ESP8266_RST, 0);
|
||||
system_delay_ms(1);
|
||||
// gpio_set_level(ESP8266_RST, 1);
|
||||
gpio_set_level(ESP8266_EN, 1);
|
||||
OFF_LED(STATUS_LED_9);
|
||||
}
|
||||
if(esp8266_download_rst_flag >=3 && !esp8266_download_passthrough)
|
||||
{
|
||||
system_delay_ms(1);
|
||||
// gpio_set_level(ESP8266_RST, 1);
|
||||
gpio_set_level(ESP8266_EN, 1);
|
||||
esp8266_download_passthrough = 1;
|
||||
esp8266_download_rst_flag = 0;
|
||||
ON_LED(STATUS_LED_2);
|
||||
ON_LED(STATUS_LED_9);
|
||||
}
|
||||
}
|
||||
|
||||
void ESP8266_Judge_Quit_Download_Mode(uint8 rev_data)
|
||||
{
|
||||
if(esp8266_download_passthrough && !esp8266_quit_download_judge_flag)
|
||||
{
|
||||
|
||||
if(rev_data == 0xC0 && esp8266_quit_download_judge_buffer[0] != 0xC0)
|
||||
{
|
||||
esp8266_quit_download_judge_index = 0;
|
||||
}
|
||||
esp8266_quit_download_judge_buffer[esp8266_quit_download_judge_index++] = rev_data;
|
||||
if(esp8266_quit_download_judge_index >= 2 && esp8266_quit_download_judge_buffer[1] == 0x04)
|
||||
{
|
||||
esp8266_quit_download_judge_index = 0;
|
||||
esp8266_quit_download_judge_flag = 1;
|
||||
ON_LED(STATUS_LED_6);
|
||||
}
|
||||
}
|
||||
if(esp8266_quit_download_judge_flag == 1 && rev_data == 0xC0)
|
||||
{
|
||||
esp8266_quit_download_judge_flag = 2;
|
||||
ON_LED(STATUS_LED_7);
|
||||
}
|
||||
}
|
||||
|
||||
void ESP8266_Auto_Download_Uart_Hook(void)
|
||||
{
|
||||
uint8 rev_tmp;
|
||||
while(uart_query_byte(UART_0, &rev_tmp))
|
||||
{
|
||||
if((rev_tmp == ESP8266_syncPkt[syncPkt_index]) && (esp8266_download_passthrough == 0) && esp8266_init_flag)
|
||||
{
|
||||
Flash_LED(STATUS_LED_3);
|
||||
syncPkt_index++;
|
||||
if(syncPkt_index >= 44)
|
||||
{
|
||||
// if(!esp8266_download_rst_flag)
|
||||
// {
|
||||
gpio_set_level(ESP8266_IO0, 0);
|
||||
gpio_set_level(ESP8266_IO2, 1);
|
||||
gpio_set_level(ESP8266_IO15, 0);
|
||||
// gpio_set_level(ESP8266_RST, 0);
|
||||
gpio_set_level(ESP8266_EN, 0);
|
||||
esp8266_download_rst_flag++;
|
||||
ON_LED(STATUS_LED_1);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// gpio_set_level(ESP8266_RST, 1);
|
||||
// esp8266_download_passthrough = 1;
|
||||
// ON_LED(STATUS_LED_2);
|
||||
// }
|
||||
syncPkt_index = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
syncPkt_index = 0;
|
||||
}
|
||||
if(esp8266_download_passthrough == 0)
|
||||
{
|
||||
isr_uart0_rx_interrupt_hook_back(rev_tmp);
|
||||
}
|
||||
else
|
||||
{
|
||||
// esp8266_tx_buffer[esp8266_uart_pass_tx_buff_index++] = rev_tmp;
|
||||
// if(esp8266_uart_pass_tx_buff_index >= EU_BUFFER_SIZE)
|
||||
// {
|
||||
// uart_write_buffer(ESP8266_UART_CHANNEL, esp8266_tx_buffer, esp8266_uart_pass_tx_buff_index);
|
||||
// esp8266_uart_pass_tx_buff_index = 0;
|
||||
// }
|
||||
// if(rev_tmp == 0xC0)
|
||||
// {
|
||||
// uart_write_buffer(ESP8266_UART_CHANNEL, esp8266_tx_buffer, esp8266_uart_pass_tx_buff_index);
|
||||
// esp8266_uart_pass_tx_buff_index = 0;
|
||||
// }
|
||||
uart_write_byte(ESP8266_UART_CHANNEL, rev_tmp);
|
||||
// ON_LED(STATUS_LED_3);
|
||||
// ESP8266_Judge_Quit_Download_Mode(rev_tmp);
|
||||
}
|
||||
uart_write_buffer(ESP8266_UART_CHANNEL, data, len);
|
||||
}
|
||||
}
|
||||
|
||||
void ESP8266_Uart_Callback(void)
|
||||
{
|
||||
Flash_LED(STATUS_LED_9);
|
||||
uint8 rev_tmp;
|
||||
// ON_LED(STATUS_LED_4);
|
||||
while(uart_query_byte(ESP8266_UART_CHANNEL, &rev_tmp))
|
||||
{
|
||||
if(esp8266_download_passthrough)
|
||||
VOFA_Receiver_Callback(rev_tmp);
|
||||
if(rev_tmp == esp8266_get_config_pkt[esp8266_get_config_pkt_index])
|
||||
{
|
||||
// esp8266_rx_buffer[esp8266_uart_pass_rx_buff_index++] = rev_tmp;
|
||||
// if(esp8266_uart_pass_rx_buff_index >= EU_BUFFER_SIZE)
|
||||
// {
|
||||
// uart_write_buffer(UART_0, esp8266_rx_buffer, esp8266_uart_pass_rx_buff_index);
|
||||
// esp8266_uart_pass_rx_buff_index = 0;
|
||||
// }
|
||||
// if(rev_tmp == 0xC0)
|
||||
// {
|
||||
// uart_write_buffer(UART_0, esp8266_rx_buffer, esp8266_uart_pass_rx_buff_index);
|
||||
// esp8266_uart_pass_rx_buff_index = 0;
|
||||
// }
|
||||
uart_write_byte(UART_0, rev_tmp);
|
||||
// Flash_LED(STATUS_LED_5);
|
||||
if(esp8266_quit_download_judge_flag >= 2)
|
||||
esp8266_get_config_pkt_index++;
|
||||
if(esp8266_get_config_pkt_index >= 6)
|
||||
{
|
||||
if(rev_tmp == 0xC0)
|
||||
{
|
||||
ON_LED(STATUS_LED_8);
|
||||
esp8266_quit_download_judge_flag ++;
|
||||
}
|
||||
// <20>յ<EFBFBD><D5B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
Flash_LED(STATUS_LED_8);
|
||||
esp8266_get_config_pkt_index = 0;
|
||||
ESP8266_Into_Change_Config_Mode(0);
|
||||
esp8266_mode = ESP8266_Mode_Config;
|
||||
ESP8266_send_data_inner((uint8 *)esp8266_config.config_str, strlen((char *)esp8266_config.config_str));
|
||||
esp8266_mode = ESP8266_Mode_Working;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
isr_uart0_rx_interrupt_hook_back(rev_tmp);
|
||||
esp8266_get_config_pkt_index = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// void ESP8266_Init2(void)
|
||||
// {
|
||||
// uart_init(ESP8266_UART_CHANNEL, ESP8266_UART_BAUDRATE, ESP8266_UART_TX_PIN, ESP8266_UART_RX_PIN);
|
||||
// uart_rx_interrupt(ESP8266_UART_CHANNEL, 1);
|
||||
// }
|
||||
|
||||
|
||||
// void ESP8266_send_data(uint8 *data, uint32 len)
|
||||
// {
|
||||
// if(esp8266_download_passthrough)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
// uart_write_buffer(ESP8266_UART_CHANNEL, data, len);
|
||||
// }
|
||||
|
||||
// void ESP8266_Main_Loop_Change_Mode(void)
|
||||
// {
|
||||
// if(esp8266_quit_download_judge_flag >= 4)
|
||||
// {
|
||||
// esp8266_download_passthrough = 0;
|
||||
// esp8266_quit_download_judge_flag = 0;
|
||||
// esp8266_download_rst_flag = 0;
|
||||
// gpio_set_level(ESP8266_IO0, 1);
|
||||
// gpio_set_level(ESP8266_IO2, 1);
|
||||
// gpio_set_level(ESP8266_IO15, 0);
|
||||
// gpio_set_level(ESP8266_EN, 0);
|
||||
// // gpio_set_level(ESP8266_RST, 0);
|
||||
// system_delay_ms(1);
|
||||
// // gpio_set_level(ESP8266_RST, 1);
|
||||
// gpio_set_level(ESP8266_EN, 1);
|
||||
// OFF_LED(STATUS_LED_9);
|
||||
// }
|
||||
// if(esp8266_download_rst_flag >=3 && !esp8266_download_passthrough)
|
||||
// {
|
||||
// system_delay_ms(1);
|
||||
// // gpio_set_level(ESP8266_RST, 1);
|
||||
// gpio_set_level(ESP8266_EN, 1);
|
||||
// esp8266_download_passthrough = 1;
|
||||
// esp8266_download_rst_flag = 0;
|
||||
// ON_LED(STATUS_LED_2);
|
||||
// ON_LED(STATUS_LED_9);
|
||||
// }
|
||||
// }
|
||||
|
||||
// void ESP8266_Judge_Quit_Download_Mode(uint8 rev_data)
|
||||
// {
|
||||
// if(esp8266_download_passthrough && !esp8266_quit_download_judge_flag)
|
||||
// {
|
||||
|
||||
// if(rev_data == 0xC0 && esp8266_quit_download_judge_buffer[0] != 0xC0)
|
||||
// {
|
||||
// esp8266_quit_download_judge_index = 0;
|
||||
// }
|
||||
// esp8266_quit_download_judge_buffer[esp8266_quit_download_judge_index++] = rev_data;
|
||||
// if(esp8266_quit_download_judge_index >= 2 && esp8266_quit_download_judge_buffer[1] == 0x04)
|
||||
// {
|
||||
// esp8266_quit_download_judge_index = 0;
|
||||
// esp8266_quit_download_judge_flag = 1;
|
||||
// ON_LED(STATUS_LED_6);
|
||||
// }
|
||||
// }
|
||||
// if(esp8266_quit_download_judge_flag == 1 && rev_data == 0xC0)
|
||||
// {
|
||||
// esp8266_quit_download_judge_flag = 2;
|
||||
// ON_LED(STATUS_LED_7);
|
||||
// }
|
||||
// }
|
||||
|
||||
// void ESP8266_Auto_Download_Uart_Hook(void)
|
||||
// {
|
||||
// uint8 rev_tmp;
|
||||
// while(uart_query_byte(UART_0, &rev_tmp))
|
||||
// {
|
||||
// if((rev_tmp == ESP8266_syncPkt[syncPkt_index]) && (esp8266_download_passthrough == 0) && esp8266_init_flag)
|
||||
// {
|
||||
// Flash_LED(STATUS_LED_3);
|
||||
// syncPkt_index++;
|
||||
// if(syncPkt_index >= 44)
|
||||
// {
|
||||
// // if(!esp8266_download_rst_flag)
|
||||
// // {
|
||||
// gpio_set_level(ESP8266_IO0, 0);
|
||||
// gpio_set_level(ESP8266_IO2, 1);
|
||||
// gpio_set_level(ESP8266_IO15, 0);
|
||||
// // gpio_set_level(ESP8266_RST, 0);
|
||||
// gpio_set_level(ESP8266_EN, 0);
|
||||
// esp8266_download_rst_flag++;
|
||||
// ON_LED(STATUS_LED_1);
|
||||
// // }
|
||||
// // else
|
||||
// // {
|
||||
// // gpio_set_level(ESP8266_RST, 1);
|
||||
// // esp8266_download_passthrough = 1;
|
||||
// // ON_LED(STATUS_LED_2);
|
||||
// // }
|
||||
// syncPkt_index = 0;
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// syncPkt_index = 0;
|
||||
// }
|
||||
// if(esp8266_download_passthrough == 0)
|
||||
// {
|
||||
// isr_uart0_rx_interrupt_hook_back(rev_tmp);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// // esp8266_tx_buffer[esp8266_uart_pass_tx_buff_index++] = rev_tmp;
|
||||
// // if(esp8266_uart_pass_tx_buff_index >= EU_BUFFER_SIZE)
|
||||
// // {
|
||||
// // uart_write_buffer(ESP8266_UART_CHANNEL, esp8266_tx_buffer, esp8266_uart_pass_tx_buff_index);
|
||||
// // esp8266_uart_pass_tx_buff_index = 0;
|
||||
// // }
|
||||
// // if(rev_tmp == 0xC0)
|
||||
// // {
|
||||
// // uart_write_buffer(ESP8266_UART_CHANNEL, esp8266_tx_buffer, esp8266_uart_pass_tx_buff_index);
|
||||
// // esp8266_uart_pass_tx_buff_index = 0;
|
||||
// // }
|
||||
// uart_write_byte(ESP8266_UART_CHANNEL, rev_tmp);
|
||||
// // fifo_write_element(&esp8266_tx_fifo, rev_tmp);
|
||||
// // ON_LED(STATUS_LED_3);
|
||||
// // ESP8266_Judge_Quit_Download_Mode(rev_tmp);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// void ESP8266_Uart_Callback(void)
|
||||
// {
|
||||
// uint8 rev_tmp;
|
||||
// // ON_LED(STATUS_LED_4);
|
||||
// while(uart_query_byte(ESP8266_UART_CHANNEL, &rev_tmp))
|
||||
// {
|
||||
// if(esp8266_download_passthrough)
|
||||
// {
|
||||
// // if(rev_tmp == 0xC0)
|
||||
// // {
|
||||
// // if(esp8266_ack_flag == 0)
|
||||
// // {
|
||||
// // esp8266_ack_flag = 1;
|
||||
// // esp8266_ack_counter++;
|
||||
// // }
|
||||
// // else
|
||||
// // {
|
||||
// // esp8266_ack_flag = 0;
|
||||
// // }
|
||||
// // }
|
||||
// fifo_write_element(&esp8266_rx_fifo, rev_tmp);
|
||||
// // esp8266_rx_buffer[esp8266_uart_pass_rx_buff_index++] = rev_tmp;
|
||||
// // if(esp8266_uart_pass_rx_buff_index >= EU_BUFFER_SIZE)
|
||||
// // {
|
||||
// // uart_write_buffer(UART_0, esp8266_rx_buffer, esp8266_uart_pass_rx_buff_index);
|
||||
// // esp8266_uart_pass_rx_buff_index = 0;
|
||||
// // }
|
||||
// // if(rev_tmp == 0xC0)
|
||||
// // {
|
||||
// // uart_write_buffer(UART_0, esp8266_rx_buffer, esp8266_uart_pass_rx_buff_index);
|
||||
// // esp8266_uart_pass_rx_buff_index = 0;
|
||||
// // }
|
||||
// // uart_write_byte(UART_0, rev_tmp);
|
||||
// // Flash_LED(STATUS_LED_5);
|
||||
// // if(esp8266_quit_download_judge_flag >= 2)
|
||||
// // {
|
||||
// // if(rev_tmp == 0xC0)
|
||||
// // {
|
||||
// // ON_LED(STATUS_LED_8);
|
||||
// // esp8266_quit_download_judge_flag ++;
|
||||
// // }
|
||||
// // }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// void ESP8266_send_sync_packet(void)
|
||||
// {
|
||||
// uint8 rev_tmp;
|
||||
// while(fifo_read_element(&esp8266_tx_fifo, &rev_tmp, FIFO_READ_AND_CLEAN) == FIFO_SUCCESS)
|
||||
// {
|
||||
// uart_write_byte(ESP8266_UART_CHANNEL, rev_tmp);
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
// void ESP8266_send_ack_packet(void)
|
||||
// {
|
||||
// uint8 rev_tmp;
|
||||
// while(fifo_read_element(&esp8266_rx_fifo, &rev_tmp, FIFO_READ_AND_CLEAN) == FIFO_SUCCESS)
|
||||
// {
|
||||
// uart_write_byte(UART_0, rev_tmp);
|
||||
// }
|
||||
|
||||
// // if(esp8266_ack_counter)
|
||||
// // {
|
||||
// // uart_write_buffer(UART_0, (uint8 *)ESP8266_ackPkt, 12);
|
||||
// // esp8266_ack_counter--;
|
||||
// // }
|
||||
// }
|
||||
|
||||
|
||||
@@ -21,13 +21,48 @@
|
||||
#define ESP8266_UART_TX_PIN UART2_TX_P33_9
|
||||
#define ESP8266_UART_RX_PIN UART2_RX_P33_8
|
||||
|
||||
#define ESP8266_WIFI_SSID "601_IoT_WIFI"
|
||||
#define ESP8266_WIFI_PASSWORD "wuhcw64667_jsj"
|
||||
#define ESP8266_WIFI_TARGET_IP "192.168.1.111"
|
||||
#define ESP8266_WIFI_TARGET_PORT 1347
|
||||
|
||||
extern uint8 esp8266_download_passthrough;
|
||||
#define ESP8266_CONFIG_SEND_PIN ESP8266_IO0
|
||||
|
||||
|
||||
typedef enum{
|
||||
ESP8266_Mode_Invalid = 0,
|
||||
ESP8266_Mode_Per_Config,
|
||||
ESP8266_Mode_Config,
|
||||
ESP8266_Mode_Working,
|
||||
}esp8266_mode_enum;
|
||||
|
||||
typedef struct{
|
||||
uint8 ssid[64];
|
||||
uint8 password[128];
|
||||
uint8 target_ip[20];
|
||||
uint16 target_port;
|
||||
uint8 config_str[254];
|
||||
}esp8266_config_t;
|
||||
|
||||
typedef struct{
|
||||
uint8 ip[16];
|
||||
uint8 mac[18];
|
||||
}esp8266_status_t;
|
||||
|
||||
// extern uint8 esp8266_download_passthrough;
|
||||
|
||||
void ESP8266_Init(void);
|
||||
void ESP8266_send_data(uint8 *data, uint32 len);
|
||||
void ESP8266_Auto_Download_Uart_Hook(void);
|
||||
void ESP8266_Uart_Callback(void);
|
||||
void ESP8266_Main_Loop_Change_Mode(void);
|
||||
void ESP8266_send_data(uint8 *data, uint32 len);
|
||||
void ESP8266_Set_Config(uint8 *ssid, uint8 *password, uint8 *target_ip, uint16 target_port);
|
||||
void ESP8266_Into_Change_Config_Mode(uint8 on);
|
||||
// void ESP8266_Auto_Download_Uart_Hook(void);
|
||||
// void ESP8266_Uart_Callback(void);
|
||||
// void ESP8266_Main_Loop_Change_Mode(void);
|
||||
|
||||
// void ESP8266_send_ack_packet(void);
|
||||
|
||||
// void ESP8266_Init2(void);
|
||||
// void ESP8266_send_sync_packet(void);
|
||||
|
||||
#endif /* CODE_ESP8266_H_ */
|
||||
|
||||
BIN
esp8266/esp8266/build/esp8266.esp8266.generic/esp8266.ino.bin
Normal file
BIN
esp8266/esp8266/build/esp8266.esp8266.generic/esp8266.ino.bin
Normal file
Binary file not shown.
BIN
esp8266/esp8266/build/esp8266.esp8266.generic/esp8266.ino.elf
Normal file
BIN
esp8266/esp8266/build/esp8266.esp8266.generic/esp8266.ino.elf
Normal file
Binary file not shown.
30181
esp8266/esp8266/build/esp8266.esp8266.generic/esp8266.ino.map
Normal file
30181
esp8266/esp8266/build/esp8266.esp8266.generic/esp8266.ino.map
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,120 +1,236 @@
|
||||
#include <ESP8266WiFi.h>
|
||||
#include <ArduinoJson.h>
|
||||
#include "FS.h"
|
||||
#include <LittleFS.h>
|
||||
#include <ESP8266WebServer.h>
|
||||
#include <ESP8266mDNS.h>
|
||||
|
||||
|
||||
#ifndef STASSID
|
||||
#define STASSID "601_IoT_WIFI"
|
||||
#define STAPSK "wuhcw64667_jsj"
|
||||
#endif
|
||||
#define CONFIG_PIN 0
|
||||
|
||||
const char* ssid = STASSID;
|
||||
const char* password = STAPSK;
|
||||
typedef struct {
|
||||
char ip[20];
|
||||
uint16_t port;
|
||||
char ssid[64];
|
||||
char password[128];
|
||||
char is_info_valid;
|
||||
} Config;
|
||||
|
||||
const char* host = "192.168.1.111";
|
||||
const uint16_t port = 1347;
|
||||
|
||||
|
||||
WiFiClient client;
|
||||
|
||||
uint8_t uart_rx_buffer[1024];
|
||||
uint8_t uart_rx_buffer[512];
|
||||
size_t uart_rx_buffer_index = 0;
|
||||
|
||||
uint8_t uart_tx_buffer[1024];
|
||||
uint8_t uart_tx_buffer[512];
|
||||
size_t uart_tx_buffer_index = 0;
|
||||
|
||||
|
||||
uint8_t config_mode_counter = 0;
|
||||
uint8_t config_buffer[1024];
|
||||
size_t config_buffer_index = 0;
|
||||
|
||||
// static uint8_t test_buff[40960] = {0};
|
||||
|
||||
|
||||
void connectToServer() {
|
||||
// Serial.print("connecting to ");
|
||||
// Serial.print(host);
|
||||
// Serial.print(':');
|
||||
// Serial.println(port);
|
||||
|
||||
if (!client.connect(host, port)) {
|
||||
// Serial.println("connection failed");
|
||||
WiFiClient client;
|
||||
Config config;
|
||||
ESP8266WebServer server(80);
|
||||
const char* host = "300w-esp";
|
||||
const char* serverIndex = "<form method='POST' action='/update' enctype='multipart/form-data'><input type='file' name='update'><input type='submit' value='Update'></form>";
|
||||
|
||||
|
||||
|
||||
void connectToServer(Config *config) {
|
||||
if (!client.connect(config->ip, config->port)) {
|
||||
return;
|
||||
}
|
||||
client.keepAlive();
|
||||
client.setTimeout(1);
|
||||
// Serial.println("connected");
|
||||
}
|
||||
|
||||
bool parseConfig(const uint8_t* buffer, size_t length, Config *config) {
|
||||
StaticJsonDocument<1024> doc;
|
||||
auto error = deserializeJson(doc, buffer, length);
|
||||
if (error) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const char* serverIP = doc["ip"];
|
||||
const uint16_t serverPort = doc["port"];
|
||||
const char* wifiSSID = doc["ssid"];
|
||||
const char* wifiPassword = doc["password"];
|
||||
|
||||
if (serverIP == nullptr || serverPort == 0 || wifiSSID == nullptr || wifiPassword == nullptr) {
|
||||
return false;
|
||||
}
|
||||
strncpy(config->ip, serverIP, sizeof(config->ip) - 1);
|
||||
config->ip[sizeof(config->ip) - 1] = '\0';
|
||||
config->port = serverPort;
|
||||
strncpy(config->ssid, wifiSSID, sizeof(config->ssid) - 1);
|
||||
config->ssid[sizeof(config->ssid) - 1] = '\0';
|
||||
strncpy(config->password, wifiPassword, sizeof(config->password) - 1);
|
||||
config->password[sizeof(config->password) - 1] = '\0';
|
||||
config->is_info_valid = 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool loadConfig(Config *config) {
|
||||
File configFile = LittleFS.open("/config.json", "r");
|
||||
config->is_info_valid = 0;
|
||||
if (!configFile) {
|
||||
return false;
|
||||
}
|
||||
return parseConfig((const uint8_t*)configFile.readString().c_str(), configFile.size(), config);
|
||||
}
|
||||
|
||||
bool saveConfig(Config *config) {
|
||||
if (!config->is_info_valid) {
|
||||
return false;
|
||||
}
|
||||
StaticJsonDocument<1024> doc;
|
||||
doc["ip"] = config->ip;
|
||||
doc["port"] = config->port;
|
||||
doc["ssid"] = config->ssid;
|
||||
doc["password"] = config->password;
|
||||
|
||||
|
||||
File configFile = LittleFS.open("/config.json", "w");
|
||||
if (!configFile) {
|
||||
return false;
|
||||
}
|
||||
serializeJson(doc, configFile);
|
||||
Serial.println("OK");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool getConfigFromSerial(Config *config) {
|
||||
Serial.setTimeout(2000);
|
||||
Serial.println("CONFIG");
|
||||
size_t len = Serial.readBytesUntil('\n', config_buffer, sizeof(config_buffer));
|
||||
if (len > 0) {
|
||||
if (parseConfig(config_buffer, len, config)) {
|
||||
Serial.setTimeout(1);
|
||||
return saveConfig(config);
|
||||
}
|
||||
}
|
||||
Serial.setTimeout(1);
|
||||
return false;
|
||||
}
|
||||
|
||||
void setUpWebServer(){
|
||||
if(MDNS.isRunning()){
|
||||
MDNS.close();
|
||||
}
|
||||
// server.close();
|
||||
if (WiFi.waitForConnectResult() == WL_CONNECTED) {
|
||||
MDNS.begin(host);
|
||||
server.on("/", HTTP_GET, []() {
|
||||
server.sendHeader("Connection", "close");
|
||||
server.send(200, "text/html", serverIndex);
|
||||
});
|
||||
server.onNotFound([]() {
|
||||
server.sendHeader("Connection", "close");
|
||||
server.send(404, "text/html", "Page Not Found");
|
||||
});
|
||||
server.on(
|
||||
"/update", HTTP_POST, []() {
|
||||
server.sendHeader("Connection", "close");
|
||||
server.send(200, "text/plain", (Update.hasError()) ? "FAIL" : "OK");
|
||||
ESP.restart();
|
||||
},
|
||||
[]() {
|
||||
HTTPUpload& upload = server.upload();
|
||||
if (upload.status == UPLOAD_FILE_START) {
|
||||
Serial.setDebugOutput(true);
|
||||
WiFiUDP::stopAll();
|
||||
Serial.printf("Update: %s\n", upload.filename.c_str());
|
||||
uint32_t maxSketchSpace = (ESP.getFreeSketchSpace() - 0x1000) & 0xFFFFF000;
|
||||
if (!Update.begin(maxSketchSpace)) { // start with max available size
|
||||
Update.printError(Serial);
|
||||
}
|
||||
} else if (upload.status == UPLOAD_FILE_WRITE) {
|
||||
if (Update.write(upload.buf, upload.currentSize) != upload.currentSize) {
|
||||
Update.printError(Serial);
|
||||
}
|
||||
} else if (upload.status == UPLOAD_FILE_END) {
|
||||
if (Update.end(true)) { // true to set the size to the current progress
|
||||
Serial.printf("Update Success: %u\nRebooting...\n", upload.totalSize);
|
||||
} else {
|
||||
Update.printError(Serial);
|
||||
}
|
||||
Serial.setDebugOutput(false);
|
||||
}
|
||||
yield();
|
||||
});
|
||||
server.begin();
|
||||
MDNS.addService("http", "tcp", 80);
|
||||
|
||||
Serial.printf("Ready! Open http://%s.local in your browser\n", host);
|
||||
} else {
|
||||
Serial.println("WiFi Failed");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void setup() {
|
||||
LittleFS.begin();
|
||||
Serial.begin(115200);
|
||||
Serial.setTimeout(1);
|
||||
Serial.setRxBufferSize(1024);
|
||||
Serial.setRxBufferSize(512);
|
||||
loadConfig(&config);
|
||||
while (!config.is_info_valid) {
|
||||
|
||||
getConfigFromSerial(&config);
|
||||
delay(500);
|
||||
}
|
||||
WiFi.mode(WIFI_STA);
|
||||
WiFi.begin(ssid, password);
|
||||
WiFi.begin(config.ssid, config.password);
|
||||
while (WiFi.status() != WL_CONNECTED) {
|
||||
delay(500);
|
||||
// Serial.print(".");
|
||||
}
|
||||
// Serial.println(WiFi.localIP());
|
||||
connectToServer();
|
||||
connectToServer(&config);
|
||||
setUpWebServer();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void loop() {
|
||||
|
||||
// static bool wait = false;
|
||||
|
||||
// Serial.print("connecting to ");
|
||||
// Serial.print(host);
|
||||
// Serial.print(':');
|
||||
// Serial.println(port);
|
||||
|
||||
// Use WiFiClient class to create TCP connections
|
||||
|
||||
// This will send a string to the server
|
||||
// Serial.println("sending data to server");
|
||||
server.handleClient();
|
||||
MDNS.update();
|
||||
uart_rx_buffer_index = Serial.readBytes(uart_rx_buffer,64);
|
||||
if (client.connected()) {
|
||||
client.write(uart_rx_buffer,uart_rx_buffer_index);
|
||||
// while(1){
|
||||
// client.write(test_buff,40960);
|
||||
// }
|
||||
// while(Serial.available()) {
|
||||
// char ch = static_cast<char>(Serial.read());
|
||||
// client.print(ch);
|
||||
// }
|
||||
// client.println("hello from ESP8266");
|
||||
}
|
||||
else {
|
||||
connectToServer();
|
||||
connectToServer(&config);
|
||||
}
|
||||
|
||||
while (client.available()) {
|
||||
// char ch = static_cast<char>(client.read());
|
||||
// Serial.print(ch);
|
||||
uart_tx_buffer_index = client.read(uart_tx_buffer,32);
|
||||
Serial.write(uart_tx_buffer,uart_tx_buffer_index);
|
||||
}
|
||||
|
||||
// unsigned long timeout = millis();
|
||||
// while (client.available() == 0) {
|
||||
// if (millis() - timeout > 5000) {
|
||||
// // Serial.println(">>> Client Timeout !");
|
||||
// client.stop();
|
||||
// delay(1000);
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
|
||||
// Read all the lines of the reply from server and print them to Serial
|
||||
// Serial.println("receiving from remote server");
|
||||
// not testing 'client.connected()' since we do not need to send data here
|
||||
|
||||
|
||||
// Close the connection
|
||||
// Serial.println();
|
||||
// Serial.println("closing connection");
|
||||
// client.stop();
|
||||
|
||||
// if (wait) {
|
||||
// delay(300000); // execute once every 5 minutes, don't flood remote service
|
||||
// }
|
||||
// wait = true;
|
||||
config_mode_counter++;
|
||||
if (config_mode_counter >= 100) {
|
||||
config_mode_counter = 0;
|
||||
if(!digitalRead(CONFIG_PIN)) {
|
||||
uint8_t get_ok = getConfigFromSerial(&config);
|
||||
if(get_ok) {
|
||||
saveConfig(&config);
|
||||
WiFi.disconnect();
|
||||
WiFi.mode(WIFI_STA);
|
||||
WiFi.begin(config.ssid, config.password);
|
||||
while (WiFi.status() != WL_CONNECTED) {
|
||||
delay(500);
|
||||
// Serial.print(".");
|
||||
}
|
||||
// Serial.println(WiFi.localIP());
|
||||
connectToServer(&config);
|
||||
setUpWebServer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -63,17 +63,17 @@
|
||||
#else
|
||||
//====================================================Ӳ<><D3B2> SPI <20><><EFBFBD><EFBFBD>====================================================
|
||||
#define OLED_SPI_SPEED (30*1000*1000) // Ӳ<><D3B2> SPI <20><><EFBFBD><EFBFBD>
|
||||
#define OLED_SPI (SPI_2) // Ӳ<><D3B2> SPI <20><>
|
||||
#define OLED_D0_PIN (SPI2_SCLK_P15_3 ) // Ӳ<><D3B2> SPI SCK <20><><EFBFBD><EFBFBD>
|
||||
#define OLED_D1_PIN (SPI2_MOSI_P15_5) // Ӳ<><D3B2> SPI MOSI <20><><EFBFBD><EFBFBD>
|
||||
#define OLED_D1_PIN_IN (SPI2_MISO_P15_4) // Ӳ<><D3B2> SPI MISO <20><><EFBFBD><EFBFBD> OLEDû<44><C3BB>MISO<53><4F><EFBFBD>ţ<EFBFBD><C5A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȼ<EFBFBD><C8BB>Ҫ<EFBFBD><D2AA><EFBFBD>壬<EFBFBD><E5A3AC>spi<70>ij<EFBFBD>ʼ<EFBFBD><CABC>ʱ<EFBFBD><CAB1>Ҫʹ<D2AA><CAB9>
|
||||
#define OLED_SPI (SPI_0) // Ӳ<><D3B2> SPI <20><>
|
||||
#define OLED_D0_PIN (SPI0_SCLK_P20_13 ) // Ӳ<><D3B2> SPI SCK <20><><EFBFBD><EFBFBD>
|
||||
#define OLED_D1_PIN (SPI0_MOSI_P20_14) // Ӳ<><D3B2> SPI MOSI <20><><EFBFBD><EFBFBD>
|
||||
#define OLED_D1_PIN_IN (SPI0_MISO_P20_12) // Ӳ<><D3B2> SPI MISO <20><><EFBFBD><EFBFBD> OLEDû<44><C3BB>MISO<53><4F><EFBFBD>ţ<EFBFBD><C5A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȼ<EFBFBD><C8BB>Ҫ<EFBFBD><D2AA><EFBFBD>壬<EFBFBD><E5A3AC>spi<70>ij<EFBFBD>ʼ<EFBFBD><CABC>ʱ<EFBFBD><CAB1>Ҫʹ<D2AA><CAB9>
|
||||
//====================================================Ӳ<><D3B2> SPI <20><><EFBFBD><EFBFBD>====================================================
|
||||
#endif
|
||||
|
||||
|
||||
#define OLED_RES_PIN (P15_1) // Һ<><D2BA><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD>Ŷ<EFBFBD><C5B6><EFBFBD>
|
||||
#define OLED_DC_PIN (P15_0 ) // Һ<><D2BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD>Ŷ<EFBFBD><C5B6><EFBFBD>
|
||||
#define OLED_CS_PIN (P15_2 ) // CS Ƭѡ<C6AC><D1A1><EFBFBD><EFBFBD>
|
||||
#define OLED_RES_PIN (P20_12) // Һ<><D2BA><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD>Ŷ<EFBFBD><C5B6><EFBFBD>
|
||||
#define OLED_DC_PIN (P20_11) // Һ<><D2BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD>Ŷ<EFBFBD><C5B6><EFBFBD>
|
||||
#define OLED_CS_PIN (P20_10) // CS Ƭѡ<C6AC><D1A1><EFBFBD><EFBFBD>
|
||||
#define OLED_BRIGHTNESS (0x7f) // <20><><EFBFBD><EFBFBD>OLED<45><44><EFBFBD><EFBFBD> Խ<><D4BD>Խ<EFBFBD><D4BD> <20><>Χ0-0XFF
|
||||
#define OLED_DEFAULT_DISPLAY_DIR ( OLED_PORTAIT ) // Ĭ<>ϵ<EFBFBD><CFB5><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
|
||||
#define OLED_DEFAULT_DISPLAY_FONT (OLED_6X8_FONT ) // Ĭ<>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD><EFBFBD>ģʽ
|
||||
|
||||
@@ -49,7 +49,8 @@ int core0_main(void)
|
||||
Power_Ctrl_Init();
|
||||
ESP8266_Init();
|
||||
Status_LED_Init();
|
||||
|
||||
oled_init();
|
||||
oled_show_string(0, 0, "ESP8266 Test");
|
||||
|
||||
// ON_LED(STATUS_LED_7);
|
||||
// ON_LED(STATUS_LED_8);
|
||||
@@ -57,20 +58,25 @@ int core0_main(void)
|
||||
uint32 t = 0;
|
||||
uint8 dir = 0;
|
||||
|
||||
// Power_Out_Enable(&power_outs[0], 1);
|
||||
// Power_Out_Enable(&power_outs[1], 1);
|
||||
// Power_Out_Enable(&power_outs[2], 1);
|
||||
// Power_Out_Enable(&power_outs[3], 1);
|
||||
// Power_Out_Enable(&power_outs[4], 1);
|
||||
// Power_Out_Enable(&power_outs[5], 1);
|
||||
// Power_Out_Enable(&power_outs[6], 1);
|
||||
// Power_Out_Enable(&power_outs[7], 1);
|
||||
// Power_Out_Enable(&power_outs[0], 1);
|
||||
// Power_Out_Enable(&power_outs[1], 1);
|
||||
// Power_Out_Enable(&power_outs[2], 1);
|
||||
// Power_Out_Enable(&power_outs[3], 1);
|
||||
// Power_Out_Enable(&power_outs[4], 1);
|
||||
// Power_Out_Enable(&power_outs[5], 1);
|
||||
// Power_Out_Enable(&power_outs[6], 1);
|
||||
// Power_Out_Enable(&power_outs[7], 1);
|
||||
|
||||
// Power_Out_Set_PWM(&power_outs[4], 3000);
|
||||
// Power_Out_Set_PWM(&power_outs[5], 4000);
|
||||
// Power_Out_Set_PWM(&power_outs[6], 5000);
|
||||
// Power_Out_Set_PWM(&power_outs[7], 6000);
|
||||
|
||||
Power_Ctrl_Enable_Output(0, 1);
|
||||
Power_Ctrl_Enable_Output(1, 1);
|
||||
Power_Ctrl_Enable_Output(2, 1);
|
||||
Power_Ctrl_Enable_Output(3, 1);
|
||||
|
||||
Power_Ctrl_Enable_Output(4, 1);
|
||||
Power_Ctrl_Enable_Output(5, 1);
|
||||
Power_Ctrl_Enable_Output(6, 1);
|
||||
@@ -80,14 +86,10 @@ int core0_main(void)
|
||||
while (TRUE)
|
||||
{
|
||||
Flash_LED(STATUS_LED_10);
|
||||
ESP8266_Main_Loop_Change_Mode();
|
||||
// if(!esp8266_download_passthrough)
|
||||
// {
|
||||
Power_Vofa_Set();
|
||||
Power_Status_Upload();
|
||||
system_delay_ms(1);
|
||||
// }
|
||||
|
||||
Power_Vofa_Set();
|
||||
Power_Status_Upload();
|
||||
system_delay_ms(1);
|
||||
|
||||
|
||||
// system_delay_ms(1);
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
#include "zf_common_headfile.h"
|
||||
#pragma section all "cpu1_dsram"
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>#pragma section all restore<72><65><EFBFBD><EFBFBD>֮<EFBFBD><D6AE><EFBFBD><EFBFBD>ȫ<EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>CPU1<55><31>RAM<41><4D>
|
||||
|
||||
#include "esp8266.h"
|
||||
// **************************** <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ****************************
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǿ<EFBFBD>Դ<EFBFBD><D4B4><EFBFBD>չ<EFBFBD><D5B9><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֲ<EFBFBD><D6B2><EFBFBD>߲<EFBFBD><DFB2>Ը<EFBFBD><D4B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
@@ -58,7 +58,6 @@ void core1_main(void)
|
||||
// <20>˴<EFBFBD><CBB4><EFBFBD>д<EFBFBD><D0B4>Ҫѭ<D2AA><D1AD>ִ<EFBFBD>еĴ<D0B5><C4B4><EFBFBD>
|
||||
|
||||
|
||||
|
||||
// <20>˴<EFBFBD><CBB4><EFBFBD>д<EFBFBD><D0B4>Ҫѭ<D2AA><D1AD>ִ<EFBFBD>еĴ<D0B5><C4B4><EFBFBD>
|
||||
}
|
||||
}
|
||||
|
||||
21
user/isr.c
21
user/isr.c
@@ -180,8 +180,13 @@ IFX_INTERRUPT(uart0_tx_isr, 0, UART0_TX_INT_PRIO)
|
||||
IFX_INTERRUPT(uart0_rx_isr, 0, UART0_RX_INT_PRIO)
|
||||
{
|
||||
interrupt_global_enable(0); // <20><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>Ƕ<EFBFBD><C7B6>
|
||||
// VOFA_Receiver_Callback();
|
||||
ESP8266_Auto_Download_Uart_Hook();
|
||||
uint8 rev_tmp;
|
||||
while(uart_query_byte(VOFA_CLIENT_UART_PORT, &rev_tmp))
|
||||
{
|
||||
VOFA_Receiver_Callback(rev_tmp);
|
||||
}
|
||||
|
||||
// ESP8266_Auto_Download_Uart_Hook();
|
||||
// Flash_LED(STATUS_LED_8);
|
||||
// uint8 rev_tmp;
|
||||
// while(uart_query_byte(UART_0, &rev_tmp))
|
||||
@@ -194,19 +199,15 @@ IFX_INTERRUPT(uart0_rx_isr, 0, UART0_RX_INT_PRIO)
|
||||
#endif // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><DEB8><EFBFBD> DEBUG_UART_INDEX <20><><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>ŵ<EFBFBD><C5B5><EFBFBD>Ӧ<EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD>ж<EFBFBD>ȥ
|
||||
}
|
||||
|
||||
void isr_uart0_rx_interrupt_hook_back(uint8 rev_data)
|
||||
{
|
||||
VOFA_Receiver_Callback(rev_data);
|
||||
}
|
||||
// void isr_uart0_rx_interrupt_hook_back(uint8 rev_data)
|
||||
// {
|
||||
// VOFA_Receiver_Callback(rev_data);
|
||||
// }
|
||||
|
||||
// <20><><EFBFBD><EFBFBD>1Ĭ<31><C4AC><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD>ô<EFBFBD><C3B4><EFBFBD>
|
||||
IFX_INTERRUPT(uart1_tx_isr, 0, UART1_TX_INT_PRIO)
|
||||
{
|
||||
interrupt_global_enable(0); // <20><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>Ƕ<EFBFBD><C7B6>
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
IFX_INTERRUPT(uart1_rx_isr, 0, UART1_RX_INT_PRIO)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user