1
0
mirror of https://github.com/mist-devel/mist-firmware.git synced 2026-04-27 12:49:41 +00:00

Send Ethernet config not just when the adapter is plugged in

This commit is contained in:
Gyorgy Szombathelyi
2020-11-18 21:26:42 +01:00
parent d95b38d98c
commit 1f3a4209ba
3 changed files with 26 additions and 8 deletions

14
tos.c
View File

@@ -1,5 +1,6 @@
#include "stdio.h"
#include "string.h"
#include "stdbool.h"
#include "hardware.h"
#include "menu.h"
@@ -15,6 +16,8 @@
#define CONFIG_FILENAME "MIST CFG"
extern bool eth_present;
typedef struct {
unsigned long system_ctrl; // system control word
char tos_img[12];
@@ -783,8 +786,14 @@ void tos_upload(char *name) {
// let cpu run (release reset)
config.system_ctrl &= ~TOS_CONTROL_CPU_RESET;
mist_set_control(config.system_ctrl);
// send ethernet config, too
if (eth_present)
config.system_ctrl |= TOS_CONTROL_ETHERNET;
else
config.system_ctrl &= ~TOS_CONTROL_ETHERNET;
mist_set_control(config.system_ctrl);
}
void tos_upload_mist2(char *name) {
@@ -1335,9 +1344,6 @@ void tos_config_load(char slot) {
memcpy(&config, sector_buffer, sizeof(tos_config_t));
}
}
// ethernet is auto detected later
config.system_ctrl &= ~TOS_CONTROL_ETHERNET;
}
// save configuration

View File

@@ -25,7 +25,7 @@ static uint16_t rx_cnt;
static unsigned char tx_buf[4+MAX_FRAMELEN];
static uint16_t tx_cnt, tx_offset;
static bool eth_present = 0;
bool eth_present = 0;
// currently only AX88772 is supported as that's the only
// device i have
@@ -332,7 +332,7 @@ static uint8_t usb_asix_init(usb_device_t *dev) {
return USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED;
// reset status
info->qNextIrqPollTime = info->qNextBulkPollTime = 0;
info->qNextIrqPollTime = info->qNextBulkPollTime = info->qNextMACSendTime = 0;
info->bPollEnable = false;
info->linkDetected = false;
@@ -532,6 +532,17 @@ static uint8_t usb_asix_poll(usb_device_t *dev) {
if (!info->bPollEnable)
return 0;
// poll for MAC address and send it to the FPGA in every 2 secs
if (info->qNextMACSendTime <= timer_get_msec()) {
if ((rcode = asix_read_cmd(dev, AX_CMD_READ_NODE_ID,
0, 0, ETH_ALEN, info->mac)) != 0) {
return rcode;
}
user_io_eth_send_mac(info->mac);
info->qNextMACSendTime = timer_get_msec() + 2000;
}
// poll interrupt endpoint
if (info->qNextIrqPollTime <= timer_get_msec()) {
uint16_t read = info->ep[info->ep_int_idx].maxPktSize;

View File

@@ -8,13 +8,14 @@
typedef struct {
ep_t ep[3];
uint16_t phy_id;
uint32_t qNextIrqPollTime; // next irq poll time
uint32_t qNextIrqPollTime; // next irq poll time
uint8_t ep_int_idx; // index of interrupt ep
uint8_t int_poll_ms; // poll interval in ms
bool bPollEnable;
bool linkDetected;
uint8_t mac[ETH_ALEN];
uint32_t qNextBulkPollTime; // next bulk poll time
uint32_t qNextBulkPollTime; // next bulk poll time
uint32_t qNextMACSendTime; // next MAC send time
} usb_asix_info_t;
// interface to usb core