#include #define _INASM_ #include "usb.h" #define PIN_OUT 0x60000300 #define PIN_OUT_SET 0x60000304 #define PIN_OUT_CLEAR 0x60000308 #define PIN_DIR 0x6000030C #define PIN_DIR_OUTPUT 0x60000310 #define PIN_DIR_INPUT 0x60000314 #define PIN_IN 0x60000318 #define _BV(x) ((1)<<(x)) #define DEBUG_HIGH s32i.n a14, a12, 0 #define DEBUG_LOW s32i.n a14, a13, 0 #define GPIO_STATUS_W1TC 0x60000324 #define GPIO_STATUS 0x6000031C //Detailed analysis of some useful stuff and performance tweaking: http://naberius.de/2015/05/14/esp8266-gpio-output-performance/ //Reverse engineerd boot room can be helpful, too: http://cholla.mmto.org/esp8266/bootrom/boot.txt //USB Protocol read from wikipedia: https://en.wikipedia.org/wiki/USB #define SIZE_OF_BUFFER 24 .global usb_buffer #define usb_buffer_end (usb_buffer + SIZE_OF_BUFFER) .global usb_buff_data .global gpio_intr gpio_intr: addi a1, a1, -60 //Must be 4 higher than highest pusher s32i.n a0, a1, 56 s32i.n a2, a1, 52 s32i.n a3, a1, 48 s32i.n a9, a1, 24 s32i.n a10, a1, 20 s32i.n a11, a1, 16 s32i.n a12, a1, 12 s32i.n a12, a1, 8 s32i.n a13, a1, 4 s32i.n a14, a1, 0 movi a11, PIN_IN movi a12, PIN_OUT_SET movi a13, PIN_OUT_CLEAR movi a14, 32 movi a2, 16 //GPIO Interrupt movi a0, _xtos_ints_off callx0 a0 DEBUG_HIGH DEBUG_HIGH DEBUG_HIGH DEBUG_HIGH /* movi a9, 1023 #timeout find_high: l32i.n a2, a11, 0 bbsi a2, DPLUS, done_high addi.n a9, a9, -1 bnez a9, find_high j end_gpio_intr DEBUG_LOW //TODO: Make a mode that waits for data to finish out, despite there being an error. movi a0, usb_buff_data movi a2, 0xffffffff s32i a0, a2, 0 end_intr_with_extra_vars: l32i.n a4, a1, 44 l32i.n a5, a1, 40 l32i.n a6, a1, 36 l32i.n a7, a1, 32 l32i.n a8, a1, 28 end_gpio_intr: */ DEBUG_LOW //Acknowledge interrupt movi a2, GPIO_STATUS l32i.n a3, a2, 0 movi a2, GPIO_STATUS_W1TC s32i.n a3, a2, 0 movi.n a2, 16 movi a0, _xtos_ints_on callx0 a0 l32i.n a0, a1, 56 l32i.n a2, a1, 52 l32i.n a3, a1, 48 l32i.n a9, a1, 24 l32i.n a10, a1, 20 l32i.n a11, a1, 16 l32i.n a12, a1, 12 l32i.n a12, a1, 8 l32i.n a13, a1, 4 l32i.n a14, a1, 0 addi a1, a1, 60 ret.n ill .global my_table .global my_func my_func: addi a1, a1, -16 s32i.n a0, a1, 0 s32i.n a2, a1, 4 s32i.n a3, a1, 8 s32i.n a4, a1, 12 movi a0, my_table nop.n nop.n s32i.n a1, a0, 0 l32i.n a4, a1, 12 l32i.n a3, a1, 8 l32i.n a2, a1, 4 l32i.n a0, a1, 0 addi a1, a1, 16 ret.n