//This file is super trashy and was kind of my first whack at this. //It should probably get cleaned up. #include #define _INASM_ #include "usb_table_1bit.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, a11, GPIO_OFFSET_SET #define DEBUG_LOW _s32i.n a13, a11, GPIO_OFFSET_CLEAR //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 //Useful information: http://www.usbmadesimple.co.uk/ums_3.htm #define SIZE_OF_BUFFER 24 .global gpio_intr gpio_intr: _addi a1, a1, -68 _s32i.n a0, a1, 0 _s32i.n a2, a1, 4 // Working reg _s32i.n a3, a1, 8 // Running CRC _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 // The current byte ready to be written out. _s32i.n a8, a1, 28 // Buffer Output Offset _s32i.n a9, a1, 32 // Timing _s32i.n a10, a1, 36 // Timing-off-by-three (For doing the 53/54 dance) _s32i.n a11, a1, 40 // GPIO_BASE _s32i.n a12, a1, 44 // CRC Polynomial _s32i.n a13, a1, 48 // Debug Output Pin _s32i.n a14, a1, 52 // Main Ramtable _s32i.n a15, a1, 56 // Loop Amount DISABLE_INTERRUPTS_LCL //Uses stack space 60 and 64 movi a14, usb_ramtable //This is actually very slow. usb_reinstate: //Come back up here if we are expecting more data. //These are for debug. _movi.n a13, 1< 512 s8i the running byte srli the running byte increment table out place */ //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