#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 //Don't use NOP_L use _nop //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< 512 s8i the running byte srli the running byte increment table out place */ #if 0 //This is my first set of test speed functions. Just for fun. //This lets you test out and see how long code takes to execute in ccount's. .global my_table .global my_func .align 16 my_func: _addi a1, a1, -48 _s32i.n a0, a1, 0 _s32i.n a2, a1, 4 _s32i.n a3, a1, 8 _s32i.n a4, a1, 12 // Anding mask _s32i.n a5, a1, 16 // Status Word (for table) _s32i.n a6, a1, 20 // Current Pins _s32i.n a7, a1, 24 _s32i.n a8, a1, 28 //a11 is free // Pins address _s32i.n a12, a1, 32 // Debug Pin offset (don't use) _s32i.n a13, a1, 36 // Debug Output Address _s32i.n a14, a1, 40 // Main Ramtable _s32i.n a15, a1, 44 // Loop Amount movi a14, usb_ramtable //This is actually very slow. _movi.n a13, 1< 12 cycles) //Both //49 = 2314 / 50 = 2362 (DBL+DBH = 24 cycles _movi.n a3, 50 _slli a3, a3, 1 _nop;_nop.n; _rsr a9, ccount _nop; retry: DEBUG_HIGH _l32i.n a11, a14, 0 _beqz a14, term //a11 was created. _add.n a11, a14, a3 // _l8ui a2, a15, TABLE_OFFSET _l8ui a2, a11, TABLE_OFFSET-4 _l8ui a2, a11, TABLE_OFFSET _add.n a11, a11, a11 //_nop.n; //WARNING: THIS IS NEEDED _bbsi a2, 0, skipper _nop; _nop; _nop; skipper: _nop.n; _nop.n; // _nop.n; _nop.n; _nop.n; _nop.n; _nop.n; _nop.n; // _nop.n; _nop.n; _nop.n; _nop.n; _nop.n; DEBUG_LOW _nop.n; _nop.n; _nop.n; _nop.n; _nop.n; _nop.n; _nop.n; _nop.n; _nop.n; _nop.n; _nop.n; DEBUG_HIGH _nop.n; _nop.n; _nop.n; _nop.n; _nop.n; _nop.n; _nop.n; _nop.n; _nop.n; _nop.n; _nop.n; DEBUG_LOW _nop.n; _nop.n; _nop.n; _nop.n; _nop.n; _nop.n; _nop.n; _nop.n; _nop.n; _nop.n; _nop.n; _nop.n; _nop.n; _nop.n;_nop.n; DEBUG_HIGH _nop.n; _nop.n; _nop.n; _nop.n; _nop.n; _nop.n; _nop.n; _nop.n; _nop.n; _nop.n; _nop.n; DEBUG_LOW _nop.n; _nop.n; _nop.n; _nop.n; _nop.n; _nop.n; _nop.n; _nop.n; _nop.n; _nop.n; _nop.n; _addi.n a3, a3, -1 _bnez a3, retry term: rsr a11, ccount l32i.n a15, a1, 24 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, 32 ret.n #endif