|
@@ -14,6 +14,24 @@
|
|
|
#include <esp_task_wdt.h>
|
|
|
#include <esp_mac.h>
|
|
|
#include <USB.h>
|
|
|
+#include <HardwareSerial.h>
|
|
|
+
|
|
|
+static void Read_Echo(Stream &from)
|
|
|
+{
|
|
|
+ int byte;
|
|
|
+
|
|
|
+ while ((byte = from.read()) >= 0)
|
|
|
+ from.write(byte);
|
|
|
+}
|
|
|
+
|
|
|
+static void onrx_usb(void *foo, const char *bar, int baz, void *quux)
|
|
|
+{
|
|
|
+ Read_Echo(Serial);
|
|
|
+}
|
|
|
+static void onrx_uart(void)
|
|
|
+{
|
|
|
+ Read_Echo(Serial0);
|
|
|
+}
|
|
|
|
|
|
#define PIN_USB_PWR_EN 7
|
|
|
#define PIN_USB_PWR_SINK 8
|
|
@@ -48,6 +66,9 @@ uint8_t max80_board_version;
|
|
|
|
|
|
static void init_hw()
|
|
|
{
|
|
|
+ Serial0.begin(115200);
|
|
|
+ Serial0.onReceive(onrx_uart, false);
|
|
|
+
|
|
|
// Start out with disabled shared I/O pins
|
|
|
for (int i = 1; i <= 18; i++)
|
|
|
pinMode(i, INPUT);
|
|
@@ -76,6 +97,9 @@ static void init_hw()
|
|
|
|
|
|
pinMode(PIN_USB_PWR_EN, OUTPUT);
|
|
|
digitalWrite(PIN_USB_PWR_EN, 0);
|
|
|
+ delayMicroseconds(50);
|
|
|
+
|
|
|
+ Serial.onEvent(ARDUINO_USB_CDC_RX_EVENT, onrx_usb);
|
|
|
|
|
|
// Configure LEDs
|
|
|
led_init();
|
|
@@ -92,15 +116,21 @@ void setup() {
|
|
|
const char *fwdate = __DATE__ " " __TIME__;
|
|
|
printf("[START] MAX80 firmware compiled on %s\n", fwdate);
|
|
|
init_hw();
|
|
|
+ Serial.println("MAX80 start");
|
|
|
fpga_service_init();
|
|
|
+ Serial.println("0.2");
|
|
|
init_config();
|
|
|
+ Serial.println("0.3");
|
|
|
setenv_cond("status.max80.fw.date", fwdate);
|
|
|
fpga_service_enable(true);
|
|
|
+ Serial.println("0.4");
|
|
|
SetupWiFi();
|
|
|
+ Serial.println("0.5");
|
|
|
printf("[RDY]\n");
|
|
|
dump_config();
|
|
|
led_set(LED_BLUE, LED_ON); // Software ready
|
|
|
|
|
|
+ Serial.println("0.5");
|
|
|
printf("Total heap: %d\n"
|
|
|
"Free heap: %d\n"
|
|
|
"Total PSRAM: %d\n"
|
|
@@ -145,12 +175,17 @@ static void dump_tasks(void)
|
|
|
}
|
|
|
|
|
|
void loop() {
|
|
|
- printf("loop task: %s\n", pcTaskGetName(xTaskGetCurrentTaskHandle()));
|
|
|
- printf("idle task: %s\n", pcTaskGetName(xTaskGetIdleTaskHandle()));
|
|
|
+ static int x = 0;
|
|
|
+
|
|
|
+ if (0) {
|
|
|
+ printf("loop task: %s\n", pcTaskGetName(xTaskGetCurrentTaskHandle()));
|
|
|
+ printf("idle task: %s\n", pcTaskGetName(xTaskGetIdleTaskHandle()));
|
|
|
|
|
|
- dump_tasks();
|
|
|
+ dump_tasks();
|
|
|
|
|
|
- putchar('\n');
|
|
|
+ putchar('\n');
|
|
|
+ }
|
|
|
|
|
|
- vTaskDelay(120 * configTICK_RATE_HZ);
|
|
|
+ Serial.println(++x);
|
|
|
+ vTaskDelay(2 * configTICK_RATE_HZ);
|
|
|
}
|