#include #define _INASM_ #include "usb_table.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 a13, a12, 0 #define DEBUG_LOW s32i.n a13, a12, 4 //(PIN_OUT_CLEAR - PIN_OUT_SET) //Long versions of the commands to help with byte-alignment? Maybe? #define DEBUG_HIGH_L .byte 0xd2; .byte 0x6c; .byte 0x00 #define DEBUG_LOW_L .byte 0xd2; .byte 0x6c; .byte 0x01 #define NOP_L .byte 0xf0; .byte 0x20; .byte 0x00 //4010113f: 1cd9 1.n a13, a12, 4 //40101141: 0cd9 s32i.n a13, a12, 0 //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, 52 s32i.n a2, a1, 48 s32i.n a3, a1, 44 s32i.n a8, a1, 24 s32i.n a9, a1, 20 s32i.n a10, a1, 16 s32i.n a11, a1, 12 s32i.n a12, a1, 8 //debug pin address s32i.n a13, a1, 4 //debug pin s32i.n a14, a1, 0 //usb_ramtable movi a14, usb_ramtable //This is actually very slow. movi a13, 1< 12 cycles) //Both //49 = 2314 / 50 = 2362 (DBL+DBH = 24 cycles movi a3, 50 slli a3, a3, 1 nop rsr a9, ccount nop retry: DEBUG_HIGH nop; nop; nop; nop; nop; nop; // nop; nop; nop; nop; nop; nop; //Just checking: Yep! This is 6 cycles. add a11, a14, a3 l8ui a2, a11, GPIO_STATUS_OFFSET nop; bbsi a2, 0, skipper nop; nop; skipper: DEBUG_LOW nop; nop; nop; nop; nop; nop; nop; nop; nop; nop; nop; nop; DEBUG_HIGH nop; nop; nop; nop; nop; nop; nop; nop; nop; nop; nop; nop; DEBUG_LOW nop; nop; nop; nop; nop; nop; nop; nop; nop; nop; nop; nop; DEBUG_HIGH nop; nop; nop; nop; nop; nop; nop; nop; nop; nop; nop; nop DEBUG_LOW nop; nop; nop; nop; nop; nop; nop; nop; nop; nop; addi a3, a3, -1 bnez a3, retry rsr a11, ccount l32i.n a14, a1, 20 l32i.n a13, a1, 16 l32i.n a12, a1, 12 l32i.n a3, a1, 8 l32i.n a2, a1, 4 l32i.n a0, a1, 0 addi a1, a1, 24 ret.n