├── .gitmodules ├── LICENSE ├── Makefile ├── README.md ├── basic-schematic.png ├── bootloader ├── Makefile ├── README.md ├── addresses.ld ├── image.elf-0x00000.bin ├── include │ ├── c_types.h │ ├── eagle_soc.h │ ├── esp8266_auxrom.h │ ├── ets_sys.h │ ├── gpio.h │ ├── uart_dev.h │ └── uart_register.h ├── linkerscript.ld ├── main.c ├── romlib.c ├── startup.s ├── top │ ├── Makefile │ └── test_messages.c └── usb_config.h ├── common.h ├── count.txt ├── espusb-wemos-d1-mini-standalone-600x.jpg ├── espusb-wemos-d1-mini.jpg ├── hardware ├── usb_8285 │ ├── README.md │ ├── usb_8285-cache.lib │ ├── usb_8285.kicad_pcb │ ├── usb_8285.pro │ └── usb_8285.sch └── usb_8285_tiny │ ├── README.txt │ ├── usb_8285-revA │ ├── usb_8285_tiny-B.Cu.gbl │ ├── usb_8285_tiny-B.Mask.gbs │ ├── usb_8285_tiny-B.SilkS.gbo │ ├── usb_8285_tiny-Edge.Cuts.gm1 │ ├── usb_8285_tiny-F.Cu.gtl │ ├── usb_8285_tiny-F.Mask.gts │ ├── usb_8285_tiny-F.Paste.gtp │ ├── usb_8285_tiny-F.SilkS.gto │ └── usb_8285_tiny.drl │ ├── usb_8285_tiny-cache.lib │ ├── usb_8285_tiny.kicad_pcb │ ├── usb_8285_tiny.net │ ├── usb_8285_tiny.pro │ └── usb_8285_tiny.sch ├── schematic.png ├── table ├── Makefile ├── crc16.pl ├── crc5.pl └── table.c ├── top ├── Makefile └── controltest.c ├── usb_notes.txt ├── user.cfg ├── user ├── custom_commands.c ├── slc_register.h ├── usb.c ├── usb.h ├── usb_asm_1bit.S ├── usb_config.h ├── usb_table_1bit.h └── user_main.c └── web ├── Makefile ├── execute_reflash.c ├── md5.c ├── md5.h ├── mfsmaker.c ├── page ├── index.html ├── jquery-2.1.4.min.js.gz ├── main.js └── menuinterface.js └── pushtodev.c /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "esp82xx"] 2 | path = esp82xx 3 | url = https://github.com/cnlohr/esp82xx.git 4 | 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | esp82xx/LICENSE -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | include user.cfg 2 | -include esp82xx/common.mf 3 | -include esp82xx/main.mf 4 | 5 | CFLAGS += 6 | SRCS += user/usb_asm_1bit.S \ 7 | user/usb.c 8 | 9 | usbburn : $(FW_FILE1) $(FW_FILE2) 10 | web/execute_reflash USB $(FW_FILE1) $(FW_FILE2) 11 | 12 | #Useful git commands 13 | ifndef TARGET 14 | # Fetch submodule if the user forgot to clone with `--recursive` 15 | GETSUBMODS = all burn burnweb netweb netburn clean cleanall purge 16 | .PHONY : $(GETSUBMODS) 17 | $(GETSUBMODS) : 18 | $(warning Submodule esp82xx was not fetched. Trying it now.) 19 | git submodule update --init --recursive 20 | $(info Re-unning make...) 21 | make $@ $(MFLAGS) $(MAKEOVERRIDES) 22 | endif 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ESP8266 USB Software Driver 2 | 3 | I wanted to have USB on the ESP8266, and a while ago I saw on the ESP32 flier, it read: "Rich Peripherals" ... "Sorry, no USB!" I thought to myself, that is ridiculous. Of course there's USB. 4 | 5 | So, it was born. This is a software USB stack running on the ESP8266/ESP8285. It requires only one external resistor, between D- and 3.3V. 6 | 7 | ## Limitations 8 | 9 | - You cannot use SDKs newer than 1.5.X. (As of dec-02-2016, 1.5.4 is the latest SDK that has been verified to be compatible.) 10 | - All ESP SDK 2.0 SDKs are incompatible. 11 | - By default, the chip expects D- on GPIO 4 and D+ on GPIO 5 - but any GPIO pair may be used. It is important to note that both D- and D+ MUST be adjacent. 12 | - This project only operates with low-speed USB (1.5 MBit/s) 13 | ideal for making peripherals, not for fake network devices and usb-serial bridges. 14 | That said - you can still write "control" messages that communicate with the ESP8266. 15 | Control messages are a great way to encapsulate your data since they handle all the framing and describing what function you wish to pass data for. 16 | 17 | ## Resources 18 | - [Getting started guide](https://github.com/cnlohr/espusb/wiki/Getting-Started-Guide) 19 | - [Forum for discussion of development](http://www.esp8266.com/espusb) 20 | 21 | 22 | ## Examples 23 | 24 | This project contains an example that simulates a usb keyboard and mouse. It also provides a web interface to actually remote control these virtual devices. 25 | 26 | ## How to use 27 | For a complete guide that includes information on how to install the toolchain or set up a docker container, go here: [Getting started guide](https://github.com/cnlohr/espusb/wiki/Getting-Started-Guide) 28 | If you already have an environment with the toolchain, then here is what you wanna do: 29 | 30 | ### Software 31 | 32 | - Install libusb and recursively clone this repo: 33 | 34 | ``` bash 35 | sudo apt-get install libusb-1.0-0-dev 36 | git clone --recursive https://github.com/cnlohr/espusb 37 | cd espusb 38 | ``` 39 | 40 | - `user.cfg` contains some settings that you might have to change to get it working. 41 | 42 | - Building/flashing the main binary 43 | 44 | ``` bash 45 | make ESP_ROOT=~/esp8266/esp-open-sdk/ burn 46 | ``` 47 | 48 | - Building/flashing the web interface (for the example mentioned above) 49 | 50 | ``` bash 51 | make ESP_ROOT=~/esp8266/esp-open-sdk/ burnweb 52 | ``` 53 | 54 | For more advanced building/flashing methods just run `make` without any parameters. 55 | 56 | ### Hardware 57 | 58 | ![basic-schematic](basic-schematic.png) 59 | 60 | ### Wemos D1 Mini 61 | 62 | The Wemos D1 mini is a breadboard friendly ESP board. 63 | 64 | You would need to flash the espusb firmware through the USB-serial connection beforehand, and then 65 | wire the GND, 5V, 3.3V, D1, D2 pins to the USB following the wiring instructions. Here is 66 | a picture of a setup with one breadboard: 67 | 68 | ![EspUSB on the Wemos D1 Mini](espusb-wemos-d1-mini-standalone-600x.jpg) 69 | 70 | ## Advanced information 71 | 72 | ### Hardware 73 | 74 | ![Schematic](schematic.png) 75 | 76 | NOTE: GPIO12/14 do not need to be connected to ground. GPIO15 may be connected via a pull-down resistor. For stability, a pull-up on GPIO2 is recommended. 77 | 78 | Also, checkout the hardware/ folder. It has kicad designs for my tiny board. Though they are for the ESP8285, the same pin configuration may be used to run on the ESP8266. 79 | 80 | ### Memory Usage 81 | 82 | This is typical memory usage for a two-endpoint (in addition to EP0) device. 83 | 84 | In summary: 85 | 86 | Total SRAM: 232 bytes + Descriptors (~317 bytes) 87 | 88 | Total Flash/IRAM (Only iram, tables and usb_init can be stuck in slow flash): 1422 bytes 89 | 90 | More details: 91 | 92 | SRAM: 93 | 94 | ``` 95 | 0000007c D usb_ramtable 96 | 0000006c B usb_internal_state 97 | ``` 98 | IRAM: 99 | 100 | You must write: usb_handle_custom_control - the demos here hook it up to the command engine which allows self flashing on 1MB+ parts. 101 | 102 | C functions: 103 | ``` 104 | 0000002a T usb_pid_handle_ack 105 | 0000014f T usb_pid_handle_data 106 | 00000022 T usb_pid_handle_out 107 | 000000e9 T usb_pid_handle_in 108 | 00000002 T usb_pid_handle_sof 109 | 00000039 T usb_pid_handle_setup 110 | ``` 111 | From/To (in ASM): 112 | ``` 113 | 40100f20 t usb_asm_start 114 | 401011ef t usb_asm_end 115 | Total length of ASM: 2cf 116 | ``` 117 | 118 | -------------------------------------------------------------------------------- /basic-schematic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/me-no-dev/espusb/e8650363233c4eeff3903f00222ea718ba8b819d/basic-schematic.png -------------------------------------------------------------------------------- /bootloader/Makefile: -------------------------------------------------------------------------------- 1 | TARGET_OUT = image.elf 2 | FW_1 = image.elf-0x10000.bin 3 | FW_2 = image.elf-0x00000.bin 4 | 5 | all : $(TARGET_OUT) 6 | 7 | ESPTOOL:=~/esp8266/esptool/esptool.py 8 | ESPTOOLOPTS:=-b 1000000 9 | GCC_FOLDER:=~/esp8266/esp-open-sdk/xtensa-lx106-elf 10 | PREFIX:=$(GCC_FOLDER)/bin/xtensa-lx106-elf- 11 | OBJDUMP:=$(PREFIX)objdump 12 | OBJCOPY:=$(PREFIX)objcopy 13 | GCC:=$(PREFIX)gcc 14 | CFLAGS:=-mlongcalls -Os -Iinclude -nostdlib -DMAIN_MHZ=80 -I. -I../esp82xx/include -I.. -I../user -DNOSDK 15 | LDFLAGS:=-T linkerscript.ld -T addresses.ld 16 | 17 | FOLDERPREFIX:=$(GCC_FOLDER)/bin 18 | GCC_FOLDER:=~/esp8266/esp-open-sdk/xtensa-lx106-elf 19 | ESPTOOL_PY:=~/esp8266/esptool/esptool.py 20 | PORT:=/dev/ttyUSB0 21 | 22 | SRCS:=romlib.c main.c startup.s ../user/usb.c ../user/usb_asm_1bit.S 23 | 24 | $(TARGET_OUT) : $(SRCS) 25 | $(GCC) $(CFLAGS) $^ $(LDFLAGS) -o $@ 26 | nm -S -n $(TARGET_OUT) > image.map 27 | $(PREFIX)objdump -S $@ > image.lst 28 | PATH=$(FOLDERPREFIX):$$PATH;$(ESPTOOL_PY) elf2image $(TARGET_OUT) #-ff 80m -fm dio 29 | 30 | burn : $(FW_FILE_1) $(FW_FILE_2) 31 | ($(ESPTOOL_PY) --port $(PORT) write_flash 0x00000 image.elf-0x00000.bin)||(true) 32 | 33 | 34 | clean : 35 | rm -rf $(TARGET_OUT) image.map image.lst $(FW_1) $(FW_2) 36 | 37 | -------------------------------------------------------------------------------- /bootloader/README.md: -------------------------------------------------------------------------------- 1 | # espusb bootloader 2 | 3 | THIS IS A WORK IN PROGRESS. It is NOT YET A BOOTLOADER, just a really small USB thinger. 4 | 5 | But, it's totes a SDK-less implementation that works with USB! 6 | 7 | Ok, it's a little bigger than I was initially hoping, at 2.5kB, but, it seems to work pretty solid. It's much better than when you have the wifis and everything else going. 8 | 9 | Right now, it just accepts control messages of length of ~2090 bytes (2048 plus a little bit) back and forth. Check out the "main" function for more info about how it works. You also get to keep the bRequest, wIndex, and other details so you don't need to weigh down the code with a protocol ontop of the control requests. I've tried sending/receiving as quickly as I could and I seem to get around 30kB/sec down at the same time as 30kB/sec up, or 60kB/sec in one direction. 10 | 11 | Detection that there is a computer seems to happen in .1 to .3 seconds, so that's good. 12 | 13 | I am still trying to figure out a good way to merge the interfaces... Take a look at main and see if you want something a little different? 14 | 15 | -------------------------------------------------------------------------------- /bootloader/image.elf-0x00000.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/me-no-dev/espusb/e8650363233c4eeff3903f00222ea718ba8b819d/bootloader/image.elf-0x00000.bin -------------------------------------------------------------------------------- /bootloader/include/c_types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 - 2011 Espressif System 3 | * 4 | */ 5 | 6 | #ifndef _C_TYPES_H_ 7 | #define _C_TYPES_H_ 8 | 9 | 10 | #include 11 | 12 | typedef unsigned char uint8; 13 | typedef unsigned char u8; 14 | typedef signed char sint8; 15 | typedef signed char int8; 16 | typedef signed char s8; 17 | typedef unsigned short uint16; 18 | typedef unsigned short u16; 19 | typedef signed short sint16; 20 | typedef signed short s16; 21 | typedef unsigned int uint32; 22 | typedef unsigned int u_int; 23 | typedef unsigned int u32; 24 | typedef signed int sint32; 25 | typedef signed int s32; 26 | typedef int int32; 27 | typedef signed long long sint64; 28 | typedef unsigned long long uint64; 29 | typedef unsigned long long u64; 30 | typedef float real32; 31 | typedef double real64; 32 | 33 | #define __le16 u16 34 | 35 | typedef unsigned int size_t; 36 | 37 | #define __packed __attribute__((packed)) 38 | 39 | #define LOCAL static 40 | 41 | #ifndef NULL 42 | #define NULL (void *)0 43 | #endif /* NULL */ 44 | 45 | /* probably should not put STATUS here */ 46 | typedef enum { 47 | OK = 0, 48 | FAIL, 49 | PENDING, 50 | BUSY, 51 | CANCEL, 52 | } STATUS; 53 | 54 | #define BIT(nr) (1UL << (nr)) 55 | 56 | #define REG_SET_BIT(_r, _b) (*(volatile uint32_t*)(_r) |= (_b)) 57 | #define REG_CLR_BIT(_r, _b) (*(volatile uint32_t*)(_r) &= ~(_b)) 58 | 59 | #define DMEM_ATTR __attribute__((section(".bss"))) 60 | #define SHMEM_ATTR 61 | 62 | #ifdef ICACHE_FLASH 63 | #define ICACHE_FLASH_ATTR __attribute__((section(".irom0.text"))) 64 | #define ICACHE_RODATA_ATTR __attribute__((section(".irom.text"))) 65 | #else 66 | #define ICACHE_FLASH_ATTR 67 | #define ICACHE_RODATA_ATTR 68 | #endif /* ICACHE_FLASH */ 69 | 70 | #define STORE_ATTR __attribute__((aligned(4))) 71 | 72 | #ifndef __cplusplus 73 | typedef unsigned char bool; 74 | #define BOOL bool 75 | #define true (1) 76 | #define false (0) 77 | #define TRUE true 78 | #define FALSE false 79 | 80 | 81 | #endif /* !__cplusplus */ 82 | 83 | #endif /* _C_TYPES_H_ */ 84 | 85 | -------------------------------------------------------------------------------- /bootloader/include/eagle_soc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Espressif System 2010 - 2012 3 | * 4 | */ 5 | 6 | #ifndef _EAGLE_SOC_H_ 7 | #define _EAGLE_SOC_H_ 8 | 9 | //Register Bits{{ 10 | #define BIT31 0x80000000 11 | #define BIT30 0x40000000 12 | #define BIT29 0x20000000 13 | #define BIT28 0x10000000 14 | #define BIT27 0x08000000 15 | #define BIT26 0x04000000 16 | #define BIT25 0x02000000 17 | #define BIT24 0x01000000 18 | #define BIT23 0x00800000 19 | #define BIT22 0x00400000 20 | #define BIT21 0x00200000 21 | #define BIT20 0x00100000 22 | #define BIT19 0x00080000 23 | #define BIT18 0x00040000 24 | #define BIT17 0x00020000 25 | #define BIT16 0x00010000 26 | #define BIT15 0x00008000 27 | #define BIT14 0x00004000 28 | #define BIT13 0x00002000 29 | #define BIT12 0x00001000 30 | #define BIT11 0x00000800 31 | #define BIT10 0x00000400 32 | #define BIT9 0x00000200 33 | #define BIT8 0x00000100 34 | #define BIT7 0x00000080 35 | #define BIT6 0x00000040 36 | #define BIT5 0x00000020 37 | #define BIT4 0x00000010 38 | #define BIT3 0x00000008 39 | #define BIT2 0x00000004 40 | #define BIT1 0x00000002 41 | #define BIT0 0x00000001 42 | //}} 43 | 44 | //Registers Operation {{ 45 | #define ETS_UNCACHED_ADDR(addr) (addr) 46 | #define ETS_CACHED_ADDR(addr) (addr) 47 | 48 | 49 | #define READ_PERI_REG(addr) (*((volatile uint32_t *)ETS_UNCACHED_ADDR(addr))) 50 | #define WRITE_PERI_REG(addr, val) (*((volatile uint32_t *)ETS_UNCACHED_ADDR(addr))) = (uint32_t)(val) 51 | #define CLEAR_PERI_REG_MASK(reg, mask) WRITE_PERI_REG((reg), (READ_PERI_REG(reg)&(~(mask)))) 52 | #define SET_PERI_REG_MASK(reg, mask) WRITE_PERI_REG((reg), (READ_PERI_REG(reg)|(mask))) 53 | #define GET_PERI_REG_BITS(reg, hipos,lowpos) ((READ_PERI_REG(reg)>>(lowpos))&((1<<((hipos)-(lowpos)+1))-1)) 54 | #define SET_PERI_REG_BITS(reg,bit_map,value,shift) (WRITE_PERI_REG((reg),(READ_PERI_REG(reg)&(~((bit_map)<<(shift))))|((value)<<(shift)) )) 55 | //}} 56 | 57 | //Periheral Clock {{ 58 | #define APB_CLK_FREQ 80*1000000 //unit: Hz 59 | #define UART_CLK_FREQ APB_CLK_FREQ 60 | #define TIMER_CLK_FREQ (APB_CLK_FREQ>>8) //divided by 256 61 | //}} 62 | 63 | //Peripheral device base address define{{ 64 | #define PERIPHS_DPORT_BASEADDR 0x3ff00000 65 | #define PERIPHS_GPIO_BASEADDR 0x60000300 66 | #define PERIPHS_TIMER_BASEDDR 0x60000600 67 | #define PERIPHS_RTC_BASEADDR 0x60000700 68 | #define PERIPHS_IO_MUX 0x60000800 69 | //}} 70 | 71 | //Interrupt remap control registers define{{ 72 | #define EDGE_INT_ENABLE_REG (PERIPHS_DPORT_BASEADDR+0x04) 73 | #define TM1_EDGE_INT_ENABLE() SET_PERI_REG_MASK(EDGE_INT_ENABLE_REG, BIT1) 74 | #define TM1_EDGE_INT_DISABLE() CLEAR_PERI_REG_MASK(EDGE_INT_ENABLE_REG, BIT1) 75 | //}} 76 | 77 | //GPIO reg {{ 78 | #define GPIO_REG_READ(reg) READ_PERI_REG(PERIPHS_GPIO_BASEADDR + reg) 79 | #define GPIO_REG_WRITE(reg, val) WRITE_PERI_REG(PERIPHS_GPIO_BASEADDR + reg, val) 80 | #define GPIO_OUT_ADDRESS 0x00 81 | #define GPIO_OUT_W1TS_ADDRESS 0x04 82 | #define GPIO_OUT_W1TC_ADDRESS 0x08 83 | 84 | #define GPIO_ENABLE_ADDRESS 0x0c 85 | #define GPIO_ENABLE_W1TS_ADDRESS 0x10 86 | #define GPIO_ENABLE_W1TC_ADDRESS 0x14 87 | #define GPIO_OUT_W1TC_DATA_MASK 0x0000ffff 88 | 89 | #define GPIO_IN_ADDRESS 0x18 90 | 91 | #define GPIO_STATUS_ADDRESS 0x1c 92 | #define GPIO_STATUS_W1TS_ADDRESS 0x20 93 | #define GPIO_STATUS_W1TC_ADDRESS 0x24 94 | #define GPIO_STATUS_INTERRUPT_MASK 0x0000ffff 95 | 96 | #define GPIO_RTC_CALIB_SYNC PERIPHS_GPIO_BASEADDR+0x6c 97 | #define RTC_CALIB_START BIT31 //first write to zero, then to one to start 98 | #define RTC_PERIOD_NUM_MASK 0x3ff //max 8ms 99 | #define GPIO_RTC_CALIB_VALUE PERIPHS_GPIO_BASEADDR+0x70 100 | #define RTC_CALIB_RDY_S 31 //after measure, flag to one, when start from zero to one, turn to zero 101 | #define RTC_CALIB_VALUE_MASK 0xfffff 102 | 103 | #define GPIO_PIN0_ADDRESS 0x28 104 | 105 | #define GPIO_ID_PIN0 0 106 | #define GPIO_ID_PIN(n) (GPIO_ID_PIN0+(n)) 107 | #define GPIO_LAST_REGISTER_ID GPIO_ID_PIN(15) 108 | #define GPIO_ID_NONE 0xffffffff 109 | 110 | #define GPIO_PIN_COUNT 16 111 | 112 | #define GPIO_PIN_CONFIG_MSB 12 113 | #define GPIO_PIN_CONFIG_LSB 11 114 | #define GPIO_PIN_CONFIG_MASK 0x00001800 115 | #define GPIO_PIN_CONFIG_GET(x) (((x) & GPIO_PIN_CONFIG_MASK) >> GPIO_PIN_CONFIG_LSB) 116 | #define GPIO_PIN_CONFIG_SET(x) (((x) << GPIO_PIN_CONFIG_LSB) & GPIO_PIN_CONFIG_MASK) 117 | 118 | #define GPIO_WAKEUP_ENABLE 1 119 | #define GPIO_WAKEUP_DISABLE (~GPIO_WAKEUP_ENABLE) 120 | #define GPIO_PIN_WAKEUP_ENABLE_MSB 10 121 | #define GPIO_PIN_WAKEUP_ENABLE_LSB 10 122 | #define GPIO_PIN_WAKEUP_ENABLE_MASK 0x00000400 123 | #define GPIO_PIN_WAKEUP_ENABLE_GET(x) (((x) & GPIO_PIN_WAKEUP_ENABLE_MASK) >> GPIO_PIN_WAKEUP_ENABLE_LSB) 124 | #define GPIO_PIN_WAKEUP_ENABLE_SET(x) (((x) << GPIO_PIN_WAKEUP_ENABLE_LSB) & GPIO_PIN_WAKEUP_ENABLE_MASK) 125 | 126 | #define GPIO_PIN_INT_TYPE_MASK 0x380 127 | #define GPIO_PIN_INT_TYPE_MSB 9 128 | #define GPIO_PIN_INT_TYPE_LSB 7 129 | #define GPIO_PIN_INT_TYPE_GET(x) (((x) & GPIO_PIN_INT_TYPE_MASK) >> GPIO_PIN_INT_TYPE_LSB) 130 | #define GPIO_PIN_INT_TYPE_SET(x) (((x) << GPIO_PIN_INT_TYPE_LSB) & GPIO_PIN_INT_TYPE_MASK) 131 | 132 | #define GPIO_PAD_DRIVER_ENABLE 1 133 | #define GPIO_PAD_DRIVER_DISABLE (~GPIO_PAD_DRIVER_ENABLE) 134 | #define GPIO_PIN_PAD_DRIVER_MSB 2 135 | #define GPIO_PIN_PAD_DRIVER_LSB 2 136 | #define GPIO_PIN_PAD_DRIVER_MASK 0x00000004 137 | #define GPIO_PIN_PAD_DRIVER_GET(x) (((x) & GPIO_PIN_PAD_DRIVER_MASK) >> GPIO_PIN_PAD_DRIVER_LSB) 138 | #define GPIO_PIN_PAD_DRIVER_SET(x) (((x) << GPIO_PIN_PAD_DRIVER_LSB) & GPIO_PIN_PAD_DRIVER_MASK) 139 | 140 | #define GPIO_AS_PIN_SOURCE 0 141 | #define SIGMA_AS_PIN_SOURCE (~GPIO_AS_PIN_SOURCE) 142 | #define GPIO_PIN_SOURCE_MSB 0 143 | #define GPIO_PIN_SOURCE_LSB 0 144 | #define GPIO_PIN_SOURCE_MASK 0x00000001 145 | #define GPIO_PIN_SOURCE_GET(x) (((x) & GPIO_PIN_SOURCE_MASK) >> GPIO_PIN_SOURCE_LSB) 146 | #define GPIO_PIN_SOURCE_SET(x) (((x) << GPIO_PIN_SOURCE_LSB) & GPIO_PIN_SOURCE_MASK) 147 | // }} 148 | 149 | // TIMER reg {{ 150 | #define RTC_REG_READ(addr) READ_PERI_REG(PERIPHS_TIMER_BASEDDR + addr) 151 | #define RTC_REG_WRITE(addr, val) WRITE_PERI_REG(PERIPHS_TIMER_BASEDDR + addr, val) 152 | #define RTC_CLR_REG_MASK(reg, mask) CLEAR_PERI_REG_MASK(PERIPHS_TIMER_BASEDDR +reg, mask) 153 | /* Returns the current time according to the timer timer. */ 154 | #define NOW() RTC_REG_READ(FRC2_COUNT_ADDRESS) 155 | 156 | //load initial_value to timer1 157 | #define FRC1_LOAD_ADDRESS 0x00 158 | 159 | //timer1's counter value(count from initial_value to 0) 160 | #define FRC1_COUNT_ADDRESS 0x04 161 | 162 | #define FRC1_CTRL_ADDRESS 0x08 163 | 164 | //clear timer1's interrupt when write this address 165 | #define FRC1_INT_ADDRESS 0x0c 166 | #define FRC1_INT_CLR_MASK 0x00000001 167 | 168 | //timer2's counter value(count from initial_value to 0) 169 | #define FRC2_COUNT_ADDRESS 0x24 170 | // }} 171 | 172 | //RTC reg {{ 173 | #define REG_RTC_BASE PERIPHS_RTC_BASEADDR 174 | 175 | #define RTC_GPIO_OUT (REG_RTC_BASE + 0x068) 176 | #define RTC_GPIO_ENABLE (REG_RTC_BASE + 0x074) 177 | #define RTC_GPIO_IN_DATA (REG_RTC_BASE + 0x08C) 178 | #define RTC_GPIO_CONF (REG_RTC_BASE + 0x090) 179 | #define PAD_XPD_DCDC_CONF (REG_RTC_BASE + 0x0A0) 180 | //}} 181 | 182 | //PIN Mux reg {{ 183 | #define PERIPHS_IO_MUX_FUNC 0x13 184 | #define PERIPHS_IO_MUX_FUNC_S 4 185 | #define PERIPHS_IO_MUX_PULLUP BIT7 186 | #define PERIPHS_IO_MUX_PULLUP2 BIT6 187 | #define PERIPHS_IO_MUX_SLEEP_PULLUP BIT3 188 | #define PERIPHS_IO_MUX_SLEEP_PULLUP2 BIT2 189 | #define PERIPHS_IO_MUX_SLEEP_OE BIT1 190 | #define PERIPHS_IO_MUX_OE BIT0 191 | 192 | #define PERIPHS_IO_MUX_CONF_U (PERIPHS_IO_MUX + 0x00) 193 | #define SPI0_CLK_EQU_SYS_CLK BIT8 194 | #define SPI1_CLK_EQU_SYS_CLK BIT9 195 | #define PERIPHS_IO_MUX_MTDI_U (PERIPHS_IO_MUX + 0x04) 196 | #define FUNC_GPIO12 3 197 | #define PERIPHS_IO_MUX_MTCK_U (PERIPHS_IO_MUX + 0x08) 198 | #define FUNC_GPIO13 3 199 | #define PERIPHS_IO_MUX_MTMS_U (PERIPHS_IO_MUX + 0x0C) 200 | #define FUNC_GPIO14 3 201 | #define PERIPHS_IO_MUX_MTDO_U (PERIPHS_IO_MUX + 0x10) 202 | #define FUNC_GPIO15 3 203 | #define FUNC_U0RTS 4 204 | #define PERIPHS_IO_MUX_U0RXD_U (PERIPHS_IO_MUX + 0x14) 205 | #define FUNC_GPIO3 3 206 | #define PERIPHS_IO_MUX_U0TXD_U (PERIPHS_IO_MUX + 0x18) 207 | #define FUNC_U0TXD 0 208 | #define FUNC_GPIO1 3 209 | #define PERIPHS_IO_MUX_SD_CLK_U (PERIPHS_IO_MUX + 0x1c) 210 | #define FUNC_SDCLK 0 211 | #define FUNC_SPICLK 1 212 | #define PERIPHS_IO_MUX_SD_DATA0_U (PERIPHS_IO_MUX + 0x20) 213 | #define FUNC_SDDATA0 0 214 | #define FUNC_SPIQ 1 215 | #define FUNC_U1TXD 4 216 | #define PERIPHS_IO_MUX_SD_DATA1_U (PERIPHS_IO_MUX + 0x24) 217 | #define FUNC_SDDATA1 0 218 | #define FUNC_SPID 1 219 | #define FUNC_U1RXD 4 220 | #define FUNC_SDDATA1_U1RXD 7 221 | #define PERIPHS_IO_MUX_SD_DATA2_U (PERIPHS_IO_MUX + 0x28) 222 | #define FUNC_SDDATA2 0 223 | #define FUNC_SPIHD 1 224 | #define FUNC_GPIO9 3 225 | #define PERIPHS_IO_MUX_SD_DATA3_U (PERIPHS_IO_MUX + 0x2c) 226 | #define FUNC_SDDATA3 0 227 | #define FUNC_SPIWP 1 228 | #define FUNC_GPIO10 3 229 | #define PERIPHS_IO_MUX_SD_CMD_U (PERIPHS_IO_MUX + 0x30) 230 | #define FUNC_SDCMD 0 231 | #define FUNC_SPICS0 1 232 | #define PERIPHS_IO_MUX_GPIO0_U (PERIPHS_IO_MUX + 0x34) 233 | #define FUNC_GPIO0 0 234 | #define PERIPHS_IO_MUX_GPIO2_U (PERIPHS_IO_MUX + 0x38) 235 | #define FUNC_GPIO2 0 236 | #define FUNC_U1TXD_BK 2 237 | #define FUNC_U0TXD_BK 4 238 | #define PERIPHS_IO_MUX_GPIO4_U (PERIPHS_IO_MUX + 0x3C) 239 | #define FUNC_GPIO4 0 240 | #define PERIPHS_IO_MUX_GPIO5_U (PERIPHS_IO_MUX + 0x40) 241 | #define FUNC_GPIO5 0 242 | 243 | #define PIN_PULLUP_DIS(PIN_NAME) CLEAR_PERI_REG_MASK(PIN_NAME, PERIPHS_IO_MUX_PULLUP) 244 | #define PIN_PULLUP_EN(PIN_NAME) SET_PERI_REG_MASK(PIN_NAME, PERIPHS_IO_MUX_PULLUP) 245 | 246 | #define PIN_FUNC_SELECT(PIN_NAME, FUNC) do { \ 247 | WRITE_PERI_REG(PIN_NAME, \ 248 | READ_PERI_REG(PIN_NAME) \ 249 | & (~(PERIPHS_IO_MUX_FUNC< 5 | 6 | void ets_delay_us( uint32_t us ); 7 | 8 | ////////////////////////////////////////////////////////////////////////////////////////////////////// 9 | 10 | #define PIN_OUT ( *((uint32_t*)0x60000300) ) 11 | #define PIN_OUT_SET ( *((uint32_t*)0x60000304) ) 12 | #define PIN_OUT_CLEAR ( *((uint32_t*)0x60000308) ) 13 | #define PIN_DIR ( *((uint32_t*)0x6000030C) ) 14 | #define PIN_DIR_OUTPUT ( *((uint32_t*)0x60000310) ) 15 | #define PIN_DIR_INPUT ( *((uint32_t*)0x60000314) ) 16 | #define PIN_IN ( *((volatile uint32_t*)0x60000318) ) 17 | #define _BV(x) ((1)<<(x)) 18 | 19 | ///////////////////////////////////////////////////////////////////////////////////////////////////// 20 | 21 | void gpio_init(void); 22 | void ets_putc( char c ); 23 | void uart_div_modify( int uart, int divisor ); 24 | #define putc ets_putc 25 | #define printf ets_uart_printf 26 | 27 | //Part of the romlib 28 | void romlib_init(); 29 | 30 | #endif 31 | 32 | -------------------------------------------------------------------------------- /bootloader/include/ets_sys.h: -------------------------------------------------------------------------------- 1 | /* 2 | * copyright (c) 2008 - 2011 Espressif System 3 | * 4 | * Define user specified Event signals and Task priorities here 5 | * 6 | */ 7 | 8 | #ifndef _ETS_SYS_H 9 | #define _ETS_SYS_H 10 | 11 | #include "c_types.h" 12 | #include "eagle_soc.h" 13 | 14 | typedef uint32_t ETSSignal; 15 | typedef uint32_t ETSParam; 16 | 17 | typedef struct ETSEventTag ETSEvent; 18 | 19 | struct ETSEventTag { 20 | ETSSignal sig; 21 | ETSParam par; 22 | }; 23 | 24 | typedef void (*ETSTask)(ETSEvent *e); 25 | 26 | /* timer related */ 27 | typedef uint32_t ETSHandle; 28 | typedef void ETSTimerFunc(void *timer_arg); 29 | 30 | typedef struct _ETSTIMER_ { 31 | struct _ETSTIMER_ *timer_next; 32 | uint32_t timer_expire; 33 | uint32_t timer_period; 34 | ETSTimerFunc *timer_func; 35 | void *timer_arg; 36 | } ETSTimer; 37 | 38 | /* interrupt related */ 39 | #define ETS_SDIO_INUM 1 40 | #define ETS_SPI_INUM 2 41 | #define ETS_GPIO_INUM 4 42 | #define ETS_UART_INUM 5 43 | #define ETS_UART1_INUM 5 44 | #define ETS_FRC_TIMER1_INUM 9 /* use edge*/ 45 | 46 | #define ETS_INTR_LOCK() \ 47 | ets_intr_lock() 48 | 49 | #define ETS_INTR_UNLOCK() \ 50 | ets_intr_unlock() 51 | 52 | #define ETS_FRC_TIMER1_INTR_ATTACH(func, arg) \ 53 | ets_isr_attach(ETS_FRC_TIMER1_INUM, (func), (void *)(arg)) 54 | 55 | #define ETS_FRC_TIMER1_NMI_INTR_ATTACH(func) \ 56 | NmiTimSetFunc(func) 57 | 58 | #define ETS_SDIO_INTR_ATTACH(func, arg)\ 59 | ets_isr_attach(ETS_SDIO_INUM, (func), (void *)(arg)) 60 | 61 | #define ETS_GPIO_INTR_ATTACH(func, arg) \ 62 | ets_isr_attach(ETS_GPIO_INUM, (func), (void *)(arg)) 63 | 64 | #define ETS_UART_INTR_ATTACH(func, arg) \ 65 | ets_isr_attach(ETS_UART_INUM, (func), (void *)(arg)) 66 | 67 | #define ETS_SPI_INTR_ATTACH(func, arg) \ 68 | ets_isr_attach(ETS_SPI_INUM, (func), (void *)(arg)) 69 | 70 | #define ETS_INTR_ENABLE(inum) \ 71 | ets_isr_unmask((1<= GPIO_ID_PIN0) && (reg_id <= GPIO_ID_PIN(GPIO_PIN_COUNT-1))) 13 | 14 | #define GPIO_REGID_TO_PINIDX(reg_id) ((reg_id) - GPIO_ID_PIN0) 15 | 16 | typedef enum { 17 | GPIO_PIN_INTR_DISABLE = 0, 18 | GPIO_PIN_INTR_POSEDGE = 1, 19 | GPIO_PIN_INTR_NEGEDGE = 2, 20 | GPIO_PIN_INTR_ANYEDGE = 3, 21 | GPIO_PIN_INTR_LOLEVEL = 4, 22 | GPIO_PIN_INTR_HILEVEL = 5 23 | } GPIO_INT_TYPE; 24 | 25 | #define GPIO_OUTPUT_SET(gpio_no, bit_value) \ 26 | gpio_output_set((bit_value)<>gpio_no)&BIT0) 29 | 30 | /* GPIO interrupt handler, registered through gpio_intr_handler_register */ 31 | typedef void (* gpio_intr_handler_fn_t)(uint32 intr_mask, void *arg); 32 | 33 | 34 | /* 35 | * Initialize GPIO. This includes reading the GPIO Configuration DataSet 36 | * to initialize "output enables" and pin configurations for each gpio pin. 37 | * Must be called once during startup. 38 | */ 39 | void gpio_init(void); 40 | 41 | /* 42 | * Change GPIO pin output by setting, clearing, or disabling pins. 43 | * In general, it is expected that a bit will be set in at most one 44 | * of these masks. If a bit is clear in all masks, the output state 45 | * remains unchanged. 46 | * 47 | * There is no particular ordering guaranteed; so if the order of 48 | * writes is significant, calling code should divide a single call 49 | * into multiple calls. 50 | */ 51 | void gpio_output_set(uint32 set_mask, 52 | uint32 clear_mask, 53 | uint32 enable_mask, 54 | uint32 disable_mask); 55 | 56 | /* 57 | * Sample the value of GPIO input pins and returns a bitmask. 58 | */ 59 | uint32 gpio_input_get(void); 60 | 61 | /* 62 | * Set the specified GPIO register to the specified value. 63 | * This is a very general and powerful interface that is not 64 | * expected to be used during normal operation. It is intended 65 | * mainly for debug, or for unusual requirements. 66 | */ 67 | void gpio_register_set(uint32 reg_id, uint32 value); 68 | 69 | /* Get the current value of the specified GPIO register. */ 70 | uint32 gpio_register_get(uint32 reg_id); 71 | 72 | /* 73 | * Register an application-specific interrupt handler for GPIO pin 74 | * interrupts. Once the interrupt handler is called, it will not 75 | * be called again until after a call to gpio_intr_ack. Any GPIO 76 | * interrupts that occur during the interim are masked. 77 | * 78 | * The application-specific handler is called with a mask of 79 | * pending GPIO interrupts. After processing pin interrupts, the 80 | * application-specific handler may wish to use gpio_intr_pending 81 | * to check for any additional pending interrupts before it returns. 82 | */ 83 | void gpio_intr_handler_register(gpio_intr_handler_fn_t fn, void *arg); 84 | 85 | /* Determine which GPIO interrupts are pending. */ 86 | uint32 gpio_intr_pending(void); 87 | 88 | /* 89 | * Acknowledge GPIO interrupts. 90 | * Intended to be called from the gpio_intr_handler_fn. 91 | */ 92 | void gpio_intr_ack(uint32 ack_mask); 93 | 94 | void gpio_pin_wakeup_enable(uint32 i, GPIO_INT_TYPE intr_state); 95 | 96 | void gpio_pin_wakeup_disable(); 97 | 98 | void gpio_pin_intr_state_set(uint32 i, GPIO_INT_TYPE intr_state); 99 | 100 | #endif // _GPIO_H_ 101 | -------------------------------------------------------------------------------- /bootloader/include/uart_dev.h: -------------------------------------------------------------------------------- 1 | #ifndef _UART_DEV_H 2 | #define _UART_DEV_H 3 | 4 | #include "uart_register.h" 5 | #include "eagle_soc.h" 6 | #include "c_types.h" 7 | 8 | #define RX_BUFF_SIZE 256 9 | #define TX_BUFF_SIZE 100 10 | #define UART0 0 11 | #define UART1 1 12 | 13 | typedef enum { 14 | FIVE_BITS = 0x0, 15 | SIX_BITS = 0x1, 16 | SEVEN_BITS = 0x2, 17 | EIGHT_BITS = 0x3 18 | } UartBitsNum4Char; 19 | 20 | typedef enum { 21 | ONE_STOP_BIT = 0, 22 | ONE_HALF_STOP_BIT = BIT2, 23 | TWO_STOP_BIT = BIT2 24 | } UartStopBitsNum; 25 | 26 | typedef enum { 27 | NONE_BITS = 0, 28 | ODD_BITS = 0, 29 | EVEN_BITS = BIT4 30 | } UartParityMode; 31 | 32 | typedef enum { 33 | STICK_PARITY_DIS = 0, 34 | STICK_PARITY_EN = BIT3 | BIT5 35 | } UartExistParity; 36 | 37 | typedef enum { 38 | BIT_RATE_9600 = 9600, 39 | BIT_RATE_19200 = 19200, 40 | BIT_RATE_38400 = 38400, 41 | BIT_RATE_57600 = 57600, 42 | BIT_RATE_74880 = 74880, 43 | BIT_RATE_115200 = 115200, 44 | BIT_RATE_230400 = 230400, 45 | BIT_RATE_460800 = 460800, 46 | BIT_RATE_921600 = 921600 47 | } UartBautRate; 48 | 49 | typedef enum { 50 | NONE_CTRL, 51 | HARDWARE_CTRL, 52 | XON_XOFF_CTRL 53 | } UartFlowCtrl; 54 | 55 | typedef enum { 56 | EMPTY, 57 | UNDER_WRITE, 58 | WRITE_OVER 59 | } RcvMsgBuffState; 60 | 61 | typedef struct { 62 | uint32 RcvBuffSize; 63 | uint8 *pRcvMsgBuff; 64 | uint8 *pWritePos; 65 | uint8 *pReadPos; 66 | uint8 TrigLvl; //JLU: may need to pad 67 | RcvMsgBuffState BuffState; 68 | } RcvMsgBuff; 69 | 70 | typedef struct { 71 | uint32 TrxBuffSize; 72 | uint8 *pTrxBuff; 73 | } TrxMsgBuff; 74 | 75 | typedef enum { 76 | BAUD_RATE_DET, 77 | WAIT_SYNC_FRM, 78 | SRCH_MSG_HEAD, 79 | RCV_MSG_BODY, 80 | RCV_ESC_CHAR, 81 | } RcvMsgState; 82 | 83 | typedef struct { 84 | UartBautRate baut_rate; 85 | UartBitsNum4Char data_bits; 86 | UartExistParity exist_parity; 87 | UartParityMode parity; // chip size in byte 88 | UartStopBitsNum stop_bits; 89 | UartFlowCtrl flow_ctrl; 90 | RcvMsgBuff rcv_buff; 91 | TrxMsgBuff trx_buff; 92 | RcvMsgState rcv_state; 93 | int received; 94 | int buff_uart_no; //indicate which uart use tx/rx buffer 95 | } UartDevice; 96 | 97 | #endif 98 | 99 | -------------------------------------------------------------------------------- /bootloader/include/uart_register.h: -------------------------------------------------------------------------------- 1 | //Generated at 2012-07-03 18:44:06 2 | /* 3 | * Copyright (c) 2010 - 2011 Espressif System 4 | * 5 | */ 6 | 7 | #ifndef UART_REGISTER_H_INCLUDED 8 | #define UART_REGISTER_H_INCLUDED 9 | #define REG_UART_BASE( i ) (0x60000000+(i)*0xf00) 10 | //version value:32'h062000 11 | 12 | #define UART_FIFO( i ) (REG_UART_BASE( i ) + 0x0) 13 | #define UART_RXFIFO_RD_BYTE 0x000000FF 14 | #define UART_RXFIFO_RD_BYTE_S 0 15 | 16 | #define UART_INT_RAW( i ) (REG_UART_BASE( i ) + 0x4) 17 | #define UART_RXFIFO_TOUT_INT_RAW (BIT(8)) 18 | #define UART_BRK_DET_INT_RAW (BIT(7)) 19 | #define UART_CTS_CHG_INT_RAW (BIT(6)) 20 | #define UART_DSR_CHG_INT_RAW (BIT(5)) 21 | #define UART_RXFIFO_OVF_INT_RAW (BIT(4)) 22 | #define UART_FRM_ERR_INT_RAW (BIT(3)) 23 | #define UART_PARITY_ERR_INT_RAW (BIT(2)) 24 | #define UART_TXFIFO_EMPTY_INT_RAW (BIT(1)) 25 | #define UART_RXFIFO_FULL_INT_RAW (BIT(0)) 26 | 27 | #define UART_INT_ST( i ) (REG_UART_BASE( i ) + 0x8) 28 | #define UART_RXFIFO_TOUT_INT_ST (BIT(8)) 29 | #define UART_BRK_DET_INT_ST (BIT(7)) 30 | #define UART_CTS_CHG_INT_ST (BIT(6)) 31 | #define UART_DSR_CHG_INT_ST (BIT(5)) 32 | #define UART_RXFIFO_OVF_INT_ST (BIT(4)) 33 | #define UART_FRM_ERR_INT_ST (BIT(3)) 34 | #define UART_PARITY_ERR_INT_ST (BIT(2)) 35 | #define UART_TXFIFO_EMPTY_INT_ST (BIT(1)) 36 | #define UART_RXFIFO_FULL_INT_ST (BIT(0)) 37 | 38 | #define UART_INT_ENA( i ) (REG_UART_BASE( i ) + 0xC) 39 | #define UART_RXFIFO_TOUT_INT_ENA (BIT(8)) 40 | #define UART_BRK_DET_INT_ENA (BIT(7)) 41 | #define UART_CTS_CHG_INT_ENA (BIT(6)) 42 | #define UART_DSR_CHG_INT_ENA (BIT(5)) 43 | #define UART_RXFIFO_OVF_INT_ENA (BIT(4)) 44 | #define UART_FRM_ERR_INT_ENA (BIT(3)) 45 | #define UART_PARITY_ERR_INT_ENA (BIT(2)) 46 | #define UART_TXFIFO_EMPTY_INT_ENA (BIT(1)) 47 | #define UART_RXFIFO_FULL_INT_ENA (BIT(0)) 48 | 49 | #define UART_INT_CLR( i ) (REG_UART_BASE( i ) + 0x10) 50 | #define UART_RXFIFO_TOUT_INT_CLR (BIT(8)) 51 | #define UART_BRK_DET_INT_CLR (BIT(7)) 52 | #define UART_CTS_CHG_INT_CLR (BIT(6)) 53 | #define UART_DSR_CHG_INT_CLR (BIT(5)) 54 | #define UART_RXFIFO_OVF_INT_CLR (BIT(4)) 55 | #define UART_FRM_ERR_INT_CLR (BIT(3)) 56 | #define UART_PARITY_ERR_INT_CLR (BIT(2)) 57 | #define UART_TXFIFO_EMPTY_INT_CLR (BIT(1)) 58 | #define UART_RXFIFO_FULL_INT_CLR (BIT(0)) 59 | 60 | #define UART_CLKDIV( i ) (REG_UART_BASE( i ) + 0x14) 61 | #define UART_CLKDIV_CNT 0x000FFFFF 62 | #define UART_CLKDIV_S 0 63 | 64 | #define UART_AUTOBAUD( i ) (REG_UART_BASE( i ) + 0x18) 65 | #define UART_GLITCH_FILT 0x000000FF 66 | #define UART_GLITCH_FILT_S 8 67 | #define UART_AUTOBAUD_EN (BIT(0)) 68 | 69 | #define UART_STATUS( i ) (REG_UART_BASE( i ) + 0x1C) 70 | #define UART_TXD (BIT(31)) 71 | #define UART_RTSN (BIT(30)) 72 | #define UART_DTRN (BIT(29)) 73 | #define UART_TXFIFO_CNT 0x000000FF 74 | #define UART_TXFIFO_CNT_S 16 75 | #define UART_RXD (BIT(15)) 76 | #define UART_CTSN (BIT(14)) 77 | #define UART_DSRN (BIT(13)) 78 | #define UART_RXFIFO_CNT 0x000000FF 79 | #define UART_RXFIFO_CNT_S 0 80 | 81 | #define UART_CONF0( i ) (REG_UART_BASE( i ) + 0x20) 82 | #define UART_TXFIFO_RST (BIT(18)) 83 | #define UART_RXFIFO_RST (BIT(17)) 84 | #define UART_IRDA_EN (BIT(16)) 85 | #define UART_TX_FLOW_EN (BIT(15)) 86 | #define UART_LOOPBACK (BIT(14)) 87 | #define UART_IRDA_RX_INV (BIT(13)) 88 | #define UART_IRDA_TX_INV (BIT(12)) 89 | #define UART_IRDA_WCTL (BIT(11)) 90 | #define UART_IRDA_TX_EN (BIT(10)) 91 | #define UART_IRDA_DPLX (BIT(9)) 92 | #define UART_TXD_BRK (BIT(8)) 93 | #define UART_SW_DTR (BIT(7)) 94 | #define UART_SW_RTS (BIT(6)) 95 | #define UART_STOP_BIT_NUM 0x00000003 96 | #define UART_STOP_BIT_NUM_S 4 97 | #define UART_BIT_NUM 0x00000003 98 | #define UART_BIT_NUM_S 2 99 | #define UART_PARITY_EN (BIT(1)) 100 | #define UART_PARITY (BIT(0)) 101 | 102 | #define UART_CONF1( i ) (REG_UART_BASE( i ) + 0x24) 103 | #define UART_RX_TOUT_EN (BIT(31)) 104 | #define UART_RX_TOUT_THRHD 0x0000007F 105 | #define UART_RX_TOUT_THRHD_S 24 106 | #define UART_RX_FLOW_EN (BIT(23)) 107 | #define UART_RX_FLOW_THRHD 0x0000007F 108 | #define UART_RX_FLOW_THRHD_S 16 109 | #define UART_TXFIFO_EMPTY_THRHD 0x0000007F 110 | #define UART_TXFIFO_EMPTY_THRHD_S 8 111 | #define UART_RXFIFO_FULL_THRHD 0x0000007F 112 | #define UART_RXFIFO_FULL_THRHD_S 0 113 | 114 | #define UART_LOWPULSE( i ) (REG_UART_BASE( i ) + 0x28) 115 | #define UART_LOWPULSE_MIN_CNT 0x000FFFFF 116 | #define UART_LOWPULSE_MIN_CNT_S 0 117 | 118 | #define UART_HIGHPULSE( i ) (REG_UART_BASE( i ) + 0x2C) 119 | #define UART_HIGHPULSE_MIN_CNT 0x000FFFFF 120 | #define UART_HIGHPULSE_MIN_CNT_S 0 121 | 122 | #define UART_PULSE_NUM( i ) (REG_UART_BASE( i ) + 0x30) 123 | #define UART_PULSE_NUM_CNT 0x0003FF 124 | #define UART_PULSE_NUM_CNT_S 0 125 | 126 | #define UART_DATE( i ) (REG_UART_BASE( i ) + 0x78) 127 | #define UART_ID( i ) (REG_UART_BASE( i ) + 0x7C) 128 | #endif // UART_REGISTER_H_INCLUDED 129 | 130 | -------------------------------------------------------------------------------- /bootloader/linkerscript.ld: -------------------------------------------------------------------------------- 1 | /* This linker script generated from xt-genldscripts.tpp for LSP . */ 2 | /* Linker Script for ld -N */ 3 | MEMORY 4 | { 5 | dport0_0_seg : org = 0x3FF00000, len = 0x10 6 | dram0_0_seg : org = 0x3FFE8000, len = 0x14000 7 | iram1_0_seg : org = 0x40100000, len = 0x8000 8 | irom0_0_seg : org = 0x40210000, len = 0x5C000 /*Dumb: We won't be using this, but it must remain for the sake of esptool*/ 9 | } 10 | 11 | PHDRS 12 | { 13 | dport0_0_phdr PT_LOAD; 14 | dram0_0_phdr PT_LOAD; 15 | dram0_0_bss_phdr PT_LOAD; 16 | iram1_0_phdr PT_LOAD; 17 | irom0_0_phdr PT_LOAD; 18 | } 19 | 20 | 21 | /* Default entry point: */ 22 | ENTRY(call_user_start) 23 | EXTERN(_DebugExceptionVector) 24 | EXTERN(_DoubleExceptionVector) 25 | EXTERN(_KernelExceptionVector) 26 | EXTERN(_NMIExceptionVector) 27 | EXTERN(_UserExceptionVector) 28 | PROVIDE(_memmap_vecbase_reset = 0x40000000); 29 | /* Various memory-map dependent cache attribute settings: */ 30 | _memmap_cacheattr_wb_base = 0x00000110; 31 | _memmap_cacheattr_wt_base = 0x00000110; 32 | _memmap_cacheattr_bp_base = 0x00000220; 33 | _memmap_cacheattr_unused_mask = 0xFFFFF00F; 34 | _memmap_cacheattr_wb_trapnull = 0x2222211F; 35 | _memmap_cacheattr_wba_trapnull = 0x2222211F; 36 | _memmap_cacheattr_wbna_trapnull = 0x2222211F; 37 | _memmap_cacheattr_wt_trapnull = 0x2222211F; 38 | _memmap_cacheattr_bp_trapnull = 0x2222222F; 39 | _memmap_cacheattr_wb_strict = 0xFFFFF11F; 40 | _memmap_cacheattr_wt_strict = 0xFFFFF11F; 41 | _memmap_cacheattr_bp_strict = 0xFFFFF22F; 42 | _memmap_cacheattr_wb_allvalid = 0x22222112; 43 | _memmap_cacheattr_wt_allvalid = 0x22222112; 44 | _memmap_cacheattr_bp_allvalid = 0x22222222; 45 | PROVIDE(_memmap_cacheattr_reset = _memmap_cacheattr_wb_trapnull); 46 | 47 | SECTIONS 48 | { 49 | 50 | .dport0.rodata : ALIGN(4) 51 | { 52 | _dport0_rodata_start = ABSOLUTE(.); 53 | *(.dport0.rodata) 54 | *(.dport.rodata) 55 | _dport0_rodata_end = ABSOLUTE(.); 56 | } >dport0_0_seg :dport0_0_phdr 57 | 58 | .dport0.literal : ALIGN(4) 59 | { 60 | _dport0_literal_start = ABSOLUTE(.); 61 | *(.dport0.literal) 62 | *(.dport.literal) 63 | _dport0_literal_end = ABSOLUTE(.); 64 | } >dport0_0_seg :dport0_0_phdr 65 | 66 | .dport0.data : ALIGN(4) 67 | { 68 | _dport0_data_start = ABSOLUTE(.); 69 | *(.dport0.data) 70 | *(.dport.data) 71 | _dport0_data_end = ABSOLUTE(.); 72 | } >dport0_0_seg :dport0_0_phdr 73 | 74 | .data : ALIGN(4) 75 | { 76 | _data_start = ABSOLUTE(.); 77 | *(.data) 78 | *(.data.*) 79 | *(.gnu.linkonce.d.*) 80 | *(.data1) 81 | *(.sdata) 82 | *(.sdata.*) 83 | *(.gnu.linkonce.s.*) 84 | *(.sdata2) 85 | *(.sdata2.*) 86 | *(.gnu.linkonce.s2.*) 87 | *(.jcr) 88 | _data_end = ABSOLUTE(.); 89 | } >dram0_0_seg :dram0_0_phdr 90 | 91 | .rodata : ALIGN(4) 92 | { 93 | _rodata_start = ABSOLUTE(.); 94 | *(.sdk.version) 95 | *(.rodata) 96 | *(.rodata.*) 97 | *(.gnu.linkonce.r.*) 98 | *(.rodata1) 99 | __XT_EXCEPTION_TABLE__ = ABSOLUTE(.); 100 | *(.xt_except_table) 101 | *(.gcc_except_table) 102 | *(.gnu.linkonce.e.*) 103 | *(.gnu.version_r) 104 | *(.eh_frame) 105 | /* C++ constructor and destructor tables, properly ordered: */ 106 | KEEP (*crtbegin.o(.ctors)) 107 | KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors)) 108 | KEEP (*(SORT(.ctors.*))) 109 | KEEP (*(.ctors)) 110 | KEEP (*crtbegin.o(.dtors)) 111 | KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors)) 112 | KEEP (*(SORT(.dtors.*))) 113 | KEEP (*(.dtors)) 114 | /* C++ exception handlers table: */ 115 | __XT_EXCEPTION_DESCS__ = ABSOLUTE(.); 116 | *(.xt_except_desc) 117 | *(.gnu.linkonce.h.*) 118 | __XT_EXCEPTION_DESCS_END__ = ABSOLUTE(.); 119 | *(.xt_except_desc_end) 120 | *(.dynamic) 121 | *(.gnu.version_d) 122 | . = ALIGN(4); /* this table MUST be 4-byte aligned */ 123 | _bss_table_start = ABSOLUTE(.); 124 | LONG(_bss_start) 125 | LONG(_bss_end) 126 | _bss_table_end = ABSOLUTE(.); 127 | _rodata_end = ABSOLUTE(.); 128 | } >dram0_0_seg :dram0_0_phdr 129 | 130 | .bss ALIGN(8) (NOLOAD) : ALIGN(4) 131 | { 132 | . = ALIGN (8); 133 | _bss_start = ABSOLUTE(.); 134 | *(.dynsbss) 135 | *(.sbss) 136 | *(.sbss.*) 137 | *(.gnu.linkonce.sb.*) 138 | *(.scommon) 139 | *(.sbss2) 140 | *(.sbss2.*) 141 | *(.gnu.linkonce.sb2.*) 142 | *(.dynbss) 143 | *(.bss) 144 | *(.bss.*) 145 | *(.gnu.linkonce.b.*) 146 | *(COMMON) 147 | . = ALIGN (8); 148 | _bss_end = ABSOLUTE(.); 149 | _heap_start = ABSOLUTE(.); 150 | /* _stack_sentry = ALIGN(0x8); */ 151 | } >dram0_0_seg :dram0_0_bss_phdr 152 | /* __stack = 0x3ffc8000; */ 153 | 154 | .irom0.text : ALIGN(4) 155 | { 156 | _irom0_text_start = ABSOLUTE(.); 157 | 158 | *libmbedtls.a:(.literal .text .literal.* .text.*) 159 | 160 | *(.irom0.literal .irom.literal .irom.text.literal .irom0.text .irom.text) 161 | _irom0_text_end = ABSOLUTE(.); 162 | } >irom0_0_seg :irom0_0_phdr 163 | 164 | .text : ALIGN(4) 165 | { 166 | _stext = .; 167 | _text_start = ABSOLUTE(.); 168 | *(.UserEnter.text) 169 | . = ALIGN(16); 170 | *(.DebugExceptionVector.text) 171 | . = ALIGN(16); 172 | *(.NMIExceptionVector.text) 173 | . = ALIGN(16); 174 | *(.KernelExceptionVector.text) 175 | LONG(0) 176 | LONG(0) 177 | LONG(0) 178 | LONG(0) 179 | . = ALIGN(16); 180 | *(.UserExceptionVector.text) 181 | LONG(0) 182 | LONG(0) 183 | LONG(0) 184 | LONG(0) 185 | . = ALIGN(16); 186 | *(.DoubleExceptionVector.text) 187 | LONG(0) 188 | LONG(0) 189 | LONG(0) 190 | LONG(0) 191 | . = ALIGN (16); 192 | *(.entry.text) 193 | *(.init.literal) 194 | *(.init) 195 | *(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*) 196 | *(.fini.literal) 197 | *(.fini) 198 | *(.gnu.version) 199 | _text_end = ABSOLUTE(.); 200 | _etext = .; 201 | } >iram1_0_seg :iram1_0_phdr 202 | 203 | .lit4 : ALIGN(4) 204 | { 205 | _lit4_start = ABSOLUTE(.); 206 | *(*.lit4) 207 | *(.lit4.*) 208 | *(.gnu.linkonce.lit4.*) 209 | _lit4_end = ABSOLUTE(.); 210 | } >iram1_0_seg :iram1_0_phdr 211 | } 212 | 213 | -------------------------------------------------------------------------------- /bootloader/main.c: -------------------------------------------------------------------------------- 1 | #include "c_types.h" 2 | #include "esp8266_auxrom.h" 3 | #include "esp8266_rom.h" 4 | #include "eagle_soc.h" 5 | #include "ets_sys.h" 6 | #include "gpio.h" 7 | #include 8 | 9 | #define CUSTOM_BUFFERSIZE 2100 10 | 11 | uint8_t usb_custom_acc[CUSTOM_BUFFERSIZE]; 12 | uint8_t usb_custom_ret[CUSTOM_BUFFERSIZE]; 13 | 14 | 15 | //This might look a little odd, but, keep in mind that the xtensa architecture can 16 | //access class-like variables much faster than it can access globals. 17 | struct USBControlStruct 18 | { 19 | uint8_t * acc; 20 | short acc_index; 21 | short acc_value; 22 | uint8_t acc_request; 23 | int length_acc; 24 | 25 | uint8_t * ret; 26 | int length_ret; 27 | int ret_done; 28 | } cctrl; 29 | 30 | 31 | //This function is called-back from within the USB stack whenever a control message is begun. 32 | //This code must execute VERY quickly. So, no copying things or doddling around. All of that must 33 | //be done in the main thread. 34 | void usb_handle_custom_control( int bmRequestType, int bRequest, int wLength, struct usb_internal_state_struct * ist ) 35 | { 36 | struct usb_urb * s = (struct usb_urb *)ist->usb_buffer; 37 | struct usb_endpoint * e = ist->ce; 38 | struct USBControlStruct * cc = &cctrl; 39 | 40 | if( bmRequestType == 0x80 ) 41 | { 42 | if( bRequest == 0xa0) //US TO HOST "in" 43 | { 44 | if( cc->length_ret ) 45 | { 46 | e->ptr_in = cc->ret; 47 | e->size_in = cc->length_ret; 48 | e->transfer_in_done_ptr == &cc->ret_done; 49 | if( wLength < e->size_in ) e->size_in = wLength; 50 | cc->length_ret = 0; 51 | } 52 | } 53 | } 54 | 55 | if( bmRequestType == 0x00 ) 56 | { 57 | if( bRequest >= 0xa0 && bRequest < 0xc0 && cc->length_acc == 0 ) //HOST TO US "out" Only permit if we've already cleared out the message. 58 | { 59 | cc->acc_request = bRequest; 60 | cc->acc_value = s->wValue; 61 | cc->acc_index = s->wIndex; 62 | e->ptr_out = cc->acc; 63 | e->max_size_out = CUSTOM_BUFFERSIZE; 64 | if( e->max_size_out > wLength ) e->max_size_out = wLength; 65 | e->got_size_out = 0; 66 | e->transfer_done_ptr = &cc->length_acc; 67 | } 68 | else 69 | { 70 | e->ptr_out = 0; 71 | e->max_size_out = 0; 72 | } 73 | 74 | } 75 | 76 | } 77 | 78 | 79 | 80 | int main() 81 | { 82 | int i = 0; 83 | struct USBControlStruct * cc = &cctrl; 84 | romlib_init(); 85 | 86 | cc->acc = usb_custom_acc; 87 | cc->ret = usb_custom_ret; 88 | cc->ret_done = 1; 89 | 90 | //PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO2_U,FUNC_GPIO2); 91 | //PIN_DIR_OUTPUT = _BV(2); //Enable GPIO2 light off. 92 | 93 | printf( "Initializing USB\n" ); 94 | usb_init(); 95 | 96 | while(1) 97 | { 98 | //Data comes in on user_control, and updates user_control_length_acc 99 | //You can return data by putting it in user_control and setting user_control_length_ret 100 | //To determine if you are connected, check usb_internal_state.there_is_a_host 101 | 102 | 103 | if( cc->length_acc && cc->ret_done ) //XXX Todo: Make sure our response was received. 104 | { 105 | switch( cc->acc_request ) 106 | { 107 | case 0xa0: //Echo 108 | ets_memcpy( cc->ret, cc->acc, cc->length_acc ); 109 | cc->ret = usb_custom_ret; 110 | cc->length_ret = cc->length_acc; 111 | cc->length_acc = 0; //Clear out the incoming data once done processing. 112 | printf( "/%d MSG:%s %d %02x:%04x:%04x\n", cc->length_acc, cc->acc, usb_internal_state.there_is_a_host,cc->acc_request,cc->acc_value,cc->acc_index ); 113 | break; 114 | case 0xa1: //Read RAM. 115 | cc->ret = (uint8_t*)((cc->acc_value<<16) | cc->acc_index); 116 | cc->length_ret = cc->length_acc; 117 | cc->length_acc = 0; 118 | break; 119 | case 0xa2: //Read FLASH 120 | { 121 | int toread = (cc->acc_value>>8)*16; 122 | int addy = (((cc->acc_value & 0x0f)<<16) | cc->acc_index)*4; 123 | cc->ret = usb_custom_ret; 124 | SPIRead( addy, (uint32_t*)cc->ret, toread ); 125 | cc->length_ret = toread; 126 | cc->length_acc = 0; 127 | break; 128 | } 129 | case 0xa3: //Write FLASH 130 | { 131 | int addy = (((cc->acc_value & 0x0f)<<16) | cc->acc_index)*4; 132 | cc->ret = usb_custom_ret; 133 | SPIWrite( addy, (uint32_t*)cc->acc, cc->length_acc & 0xfffc ); 134 | cc->length_ret = 1; 135 | cc->length_acc = 0; 136 | break; 137 | } 138 | case 0xa4: //Erase FLASH Block 139 | { 140 | int addy = (((cc->acc_value & 0x0f)<<16) | cc->acc_index)*4; 141 | cc->ret = usb_custom_ret; 142 | SPIEraseBlock( cc->acc_value ); 143 | cc->length_ret = 1; 144 | cc->length_acc = 0; 145 | break; 146 | } 147 | 148 | 149 | 150 | } 151 | 152 | 153 | } 154 | 155 | //Don't know why. Without this, it breaks. 156 | ets_delay_us( 1 ); 157 | i++; 158 | 159 | //If there is no host connected, and it's been 1/2 second, bail. 160 | if( i == 400000 && !usb_internal_state.there_is_a_host ) 161 | { 162 | printf( "No host (Should do normal boot)\n" ); 163 | } 164 | } 165 | } 166 | 167 | -------------------------------------------------------------------------------- /bootloader/romlib.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #define UART0 0 7 | 8 | extern UartDevice UartDev; 9 | 10 | #define sys_const_crystal_26m_en 48 // soc_param0: 0: 40MHz, 1: 26MHz, 2: 24MHz 11 | 12 | //Thanks, https://github.com/pvvx/esp8266web/blob/2e25559bc489487747205db2ef171d48326b32d4/app/sdklib/system/app_main.c 13 | void set_pll(void) 14 | { 15 | if(rom_i2c_readReg(103,4,1) != 136) { // 8: 40MHz, 136: 26MHz 16 | //if(get_sys_const(sys_const_crystal_26m_en) == 1) { // soc_param0: 0: 40MHz, 1: 26MHz, 2: 24MHz 17 | // set 80MHz PLL CPU 18 | rom_i2c_writeReg(103,4,1,136); 19 | rom_i2c_writeReg(103,4,2,145); 20 | //} 21 | } 22 | } 23 | 24 | extern uint32_t _bss_start; 25 | extern uint32_t _bss_end; 26 | 27 | void romlib_init() 28 | { 29 | uint32_t *addr; 30 | 31 | ets_update_cpu_frequency( MAIN_MHZ ); 32 | rom_rfpll_reset(); //Reset PLL. 33 | set_pll(); //Set PLL to 80 MHz. 34 | 35 | for (addr = &_bss_start; addr < &_bss_end; addr++) 36 | *addr = 0; 37 | 38 | PIN_PULLUP_DIS(PERIPHS_IO_MUX_U0TXD_U); 39 | PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0TXD_U, FUNC_U0TXD); 40 | uart_div_modify(UART0, (MAIN_MHZ*1000000)/115200); 41 | 42 | //Is this needed? 43 | gpio_init(); 44 | } 45 | 46 | -------------------------------------------------------------------------------- /bootloader/startup.s: -------------------------------------------------------------------------------- 1 | 2 | .global call_user_start 3 | 4 | call_user_start: 5 | call0 main 6 | 7 | /* 8 | .global my_change_bbpll160 9 | _br1: 10 | .long 0 11 | 12 | my_change_bbpll160: 13 | addi a1, a1, -16 14 | 15 | addi a1, a1, -16 16 | s32i.n a0, a1, 0 17 | // l32r a0, _br0 18 | // callx0 a0 19 | // l32r a0, _br1 //pm_set_sleep_cycles 20 | // l8ui a3, a0, 78 21 | l8ui a0, a0, 178 22 | beqz.n a3, 3695 23 | 24 | 3682: 051066 bnei a0, 1, _ja0 25 | 3685: 000005 call0 _ja1 26 | _ja1: 27 | 3688: 000246 j _ja2 28 | _ja0: 29 | 368b: 60cc bnez.n a0, 3695 30 | 368d: 041226 beqi a2, 1, 3695 31 | 3690: 128c beqz.n a2, 3695 32 | 3692: 000005 call0 3694 33 | _ja2: 34 | 3695: 0108 l32i.n a0, a1, 0 35 | 3697: 10c112 addi a1, a1, 16 36 | 369a: f00d ret.n 37 | 369c: 005d mov.n a5, a0 38 | 369e: 000000 ill 39 | 36a1: 000000 ill 40 | 36a4: 000a00 excw 41 | 36a7: 020060 excw 42 | 36aa: 006000 rsil a0, 0 43 | 36ad: 600006 j 1b6b1 44 | */ 45 | -------------------------------------------------------------------------------- /bootloader/top/Makefile: -------------------------------------------------------------------------------- 1 | all : test_messages 2 | 3 | test_messages : test_messages.c 4 | gcc -o $@ $^ -lusb-1.0 5 | -------------------------------------------------------------------------------- /bootloader/top/test_messages.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main() 6 | { 7 | struct libusb_device_handle *devh = NULL; 8 | 9 | if( libusb_init(NULL) < 0 ) 10 | { 11 | fprintf( stderr, "Error: Could not initialize libUSB\n" ); 12 | return -1; 13 | } 14 | 15 | 16 | devh = libusb_open_device_with_vid_pid( NULL, 0xabcd, 0x8266 ); 17 | if( !devh ) 18 | { 19 | fprintf( stderr, "Error: Cannot find USB device.\n" ); 20 | return -1; 21 | } 22 | 23 | int i, r1, r2; 24 | 25 | while(1) 26 | { 27 | uint8_t buffer[2100]; 28 | 29 | memset( buffer, 0, sizeof( buffer ) ); 30 | strcpy( buffer, "U" ); 31 | buffer[3] = 0xff; 32 | int len = 2090; 33 | 34 | int show_output = 1; 35 | #if 1 36 | r1 = libusb_control_transfer( devh, 37 | 0x00, //reqtype (0x80 = Device->PC, 0x00 = PC->Device) 38 | 0xA0, //request (Echo) 39 | 0x1234, //wValue 40 | 0x5678, //wIndex 41 | buffer, 42 | len, //wLength (more like max length) 43 | 100 ); 44 | show_output = 0; 45 | #elif 0 46 | r1 = libusb_control_transfer( devh, 47 | 0x00, //reqtype (0x80 = Device->PC, 0x00 = PC->Device) 48 | 0xA1, //Read RAM 49 | 0x3FFE, //MSB 50 | 0x0000, //LSB 51 | buffer, 52 | len, //wLength (more like max length) 53 | 100 ); 54 | #elif 0 55 | r1 = libusb_control_transfer( devh, 56 | 0x00, //reqtype (0x80 = Device->PC, 0x00 = PC->Device) 57 | 0xA2, //request (Read Flash) 58 | 0x0402, //wValue (MSB = # of 16-byte words to read, LSB = MSB of address x4) 59 | 0x0000, //lsb of address x4 60 | buffer, 61 | 1, //wLength (more like max length) 62 | 100 ); 63 | #elif 0 64 | r1 = libusb_control_transfer( devh, 65 | 0x00, //reqtype (0x80 = Device->PC, 0x00 = PC->Device) 66 | 0xA3, //request (Write Flash) 67 | 0x0002, //wValue (MSB = # of 16-byte words to read, LSB = MSB of address x4) 68 | 0x0000, //lsb of address x4 69 | buffer, 70 | len, //wLength (more like max length) 71 | 100 ); 72 | #else 0 73 | r1 = libusb_control_transfer( devh, 74 | 0x00, //reqtype (0x80 = Device->PC, 0x00 = PC->Device) 75 | 0xA4, //request (Erase Flash Block) 76 | 0x0008, //Block ID (wValue) 77 | 0x0000, // 78 | buffer, 79 | 1, //wLength (more like max length) 80 | 100 ); 81 | #endif 82 | memset( buffer, 0, sizeof( buffer ) ); 83 | 84 | r2 = libusb_control_transfer( devh, 85 | 0x80, //reqtype (0x80 = in, 0x00 = out) 86 | 0xA0, //request 87 | 0x0100, //wValue 88 | 0x0000, //wIndex 89 | buffer, //wLength (more like max length) 90 | sizeof( buffer ), 91 | 100 ); 92 | 93 | buffer[sizeof(buffer)-1] = 0; 94 | printf( "." ); 95 | fflush( stdout ); 96 | fprintf( stderr, "%d/%d/", r1, r2 ); 97 | if( show_output ) 98 | { 99 | for( i = 0; i < r2; i++ ) 100 | { 101 | fprintf( stderr, "%02x ", buffer[i] ); 102 | } 103 | } 104 | fprintf( stderr, "\n" ); 105 | if( r1 < 0 || r2 < 0 ) return -1; 106 | } 107 | 108 | return 0; 109 | } 110 | 111 | -------------------------------------------------------------------------------- /bootloader/usb_config.h: -------------------------------------------------------------------------------- 1 | #ifndef _USB_CONFIG_H 2 | #define _USB_CONFIG_H 3 | 4 | 5 | //Defines the number of endpoints for this device. (Always add one for EP0) 6 | #define ENDPOINTS 1 7 | 8 | //Defines a pin that is useful for debugging USB on a logic analyzer 9 | //#define DEBUGPIN 2 10 | 11 | //DPLUS and DMINUS are not actually used except for setting things up. 12 | #define DPLUS 5 13 | #define DMINUS 4 14 | 15 | //This is what's used in the assembly 16 | #define DMINUSBASE DMINUS //Must be D- first, then D+ second. 17 | 18 | #define PERIPHSDPLUS PERIPHS_IO_MUX_GPIO5_U 19 | #define PERIPHSDMINUS PERIPHS_IO_MUX_GPIO4_U 20 | #define FUNCDPLUS FUNC_GPIO5 21 | #define FUNCDMINUS FUNC_GPIO4 22 | 23 | #endif 24 | 25 | 26 | #ifdef INSTANCE_DESCRIPTORS 27 | //Taken from http://www.usbmadesimple.co.uk/ums_ms_desc_dev.htm 28 | static const uint8_t device_descriptor[] = { 29 | 18, //Length 30 | 1, //Type (Device) 31 | 0x10, 0x01, //Spec 32 | 0xff, //Device Class 33 | 0xff, //Device Subclass 34 | 0xff, //Device Protocol (000 = use config descriptor) 35 | 0x08, //Max packet size for EP0 (This has to be 8 because of the USB Low-Speed Standard) 36 | 0xcd, 0xab, //ID Vendor //TODO: register this in http://pid.codes/howto/ or somewhere. 37 | 0x66, 0x82, //ID Product 38 | 0x02, 0x00, //ID Rev 39 | 1, //Manufacturer string 40 | 2, //Product string 41 | 0, //Serial string 42 | 1, //Max number of configurations 43 | }; 44 | 45 | static const uint8_t config_descriptor[] = { 46 | // configuration descriptor, USB spec 9.6.3, page 264-266, Table 9-10 47 | 9, // bLength; 48 | 2, // bDescriptorType; 49 | 0x09, 0x00, // wTotalLength 50 | 51 | 0x00, // bNumInterfaces (Normally 1) 52 | 0x01, // bConfigurationValue 53 | 0x00, // iConfiguration 54 | 0xC0, // bmAttributes (was 0xa0) (add self-powered) 55 | 0x64, // bMaxPower (200mA) 56 | 57 | }; 58 | 59 | 60 | //Ever wonder how you have more than 6 keys down at the same time on a USB keyboard? It's easy. Enumerate two keyboards! 61 | 62 | 63 | #define STR_MANUFACTURER L"CNLohr" 64 | #define STR_PRODUCT L"BOOTLOADER" 65 | #define STR_SERIAL L"000" 66 | 67 | struct usb_string_descriptor_struct { 68 | uint8_t bLength; 69 | uint8_t bDescriptorType; 70 | uint16_t wString[]; 71 | }; 72 | const static struct usb_string_descriptor_struct string0 = { 73 | 4, 74 | 3, 75 | {0x0409} 76 | }; 77 | const static struct usb_string_descriptor_struct string1 = { 78 | sizeof(STR_MANUFACTURER), 79 | 3, 80 | STR_MANUFACTURER 81 | }; 82 | const static struct usb_string_descriptor_struct string2 = { 83 | sizeof(STR_PRODUCT), 84 | 3, 85 | STR_PRODUCT 86 | }; 87 | const static struct usb_string_descriptor_struct string3 = { 88 | sizeof(STR_SERIAL), 89 | 3, 90 | STR_SERIAL 91 | }; 92 | 93 | 94 | // This table defines which descriptor data is sent for each specific 95 | // request from the host (in wValue and wIndex). 96 | const static struct descriptor_list_struct { 97 | uint16_t wValue; 98 | uint16_t wIndex; 99 | const uint8_t *addr; 100 | uint8_t length; 101 | } descriptor_list[] = { 102 | {0x0100, 0x0000, device_descriptor, sizeof(device_descriptor)}, 103 | {0x0200, 0x0000, config_descriptor, sizeof(config_descriptor)}, 104 | {0x0300, 0x0000, (const uint8_t *)&string0, 4}, 105 | {0x0301, 0x0409, (const uint8_t *)&string1, sizeof(STR_MANUFACTURER)}, 106 | {0x0302, 0x0409, (const uint8_t *)&string2, sizeof(STR_PRODUCT)}, 107 | {0x0303, 0x0409, (const uint8_t *)&string3, sizeof(STR_SERIAL)} 108 | }; 109 | #define DESCRIPTOR_LIST_ENTRIES ((sizeof(descriptor_list))/(sizeof(struct descriptor_list_struct)) ) 110 | 111 | #endif 112 | 113 | 114 | -------------------------------------------------------------------------------- /common.h: -------------------------------------------------------------------------------- 1 | //Unused 2 | 3 | -------------------------------------------------------------------------------- /count.txt: -------------------------------------------------------------------------------- 1 | 881 2 | -------------------------------------------------------------------------------- /espusb-wemos-d1-mini-standalone-600x.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/me-no-dev/espusb/e8650363233c4eeff3903f00222ea718ba8b819d/espusb-wemos-d1-mini-standalone-600x.jpg -------------------------------------------------------------------------------- /espusb-wemos-d1-mini.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/me-no-dev/espusb/e8650363233c4eeff3903f00222ea718ba8b819d/espusb-wemos-d1-mini.jpg -------------------------------------------------------------------------------- /hardware/usb_8285/README.md: -------------------------------------------------------------------------------- 1 | This has been tested and works. There are some shortcomings. 2 | 3 | (1) The caps are too big and don't conveniently fit into the USB port. 4 | 5 | (2) It's about 2 mil too wide. 6 | 7 | -------------------------------------------------------------------------------- /hardware/usb_8285/usb_8285-cache.lib: -------------------------------------------------------------------------------- 1 | EESchema-LIBRARY Version 2.3 2 | #encoding utf-8 3 | # 4 | # +3.3V-RESCUE-usb_8285 5 | # 6 | DEF +3.3V-RESCUE-usb_8285 #PWR 0 0 Y Y 1 F P 7 | F0 "#PWR" 0 -40 30 H I C CNN 8 | F1 "+3.3V-RESCUE-usb_8285" 0 110 30 H V C CNN 9 | F2 "" 0 0 60 H V C CNN 10 | F3 "" 0 0 60 H V C CNN 11 | DRAW 12 | X +3.3V 1 0 0 0 U 30 30 0 0 W N 13 | C 0 60 20 0 1 0 N 14 | P 3 0 1 0 0 0 0 40 0 40 N 15 | ENDDRAW 16 | ENDDEF 17 | # 18 | # +5V 19 | # 20 | DEF +5V #PWR 0 0 Y Y 1 F P 21 | F0 "#PWR" 0 -150 50 H I C CNN 22 | F1 "+5V" 0 140 50 H V C CNN 23 | F2 "" 0 0 60 H V C CNN 24 | F3 "" 0 0 60 H V C CNN 25 | DRAW 26 | P 2 0 1 0 -30 50 0 100 N 27 | P 2 0 1 0 0 0 0 100 N 28 | P 2 0 1 0 0 100 30 50 N 29 | X +5V 1 0 0 0 U 50 50 1 1 W N 30 | ENDDRAW 31 | ENDDEF 32 | # 33 | # C-RESCUE-usb_8285 34 | # 35 | DEF C-RESCUE-usb_8285 C 0 10 N Y 1 F N 36 | F0 "C" 0 100 40 H V L CNN 37 | F1 "C-RESCUE-usb_8285" 6 -85 40 H V L CNN 38 | F2 "" 38 -150 30 H V C CNN 39 | F3 "" 0 0 60 H V C CNN 40 | $FPLIST 41 | SM* 42 | C? 43 | C1-1 44 | $ENDFPLIST 45 | DRAW 46 | P 2 0 1 20 -80 -30 80 -30 N 47 | P 2 0 1 20 -80 30 80 30 N 48 | X ~ 1 0 200 170 D 40 40 1 1 P 49 | X ~ 2 0 -200 170 U 40 40 1 1 P 50 | ENDDRAW 51 | ENDDEF 52 | # 53 | # CONN_1 54 | # 55 | DEF ~CONN_1 P 0 30 N N 1 F N 56 | F0 "P" 80 0 40 H V L CNN 57 | F1 "CONN_1" 0 55 30 H I C CNN 58 | F2 "" 0 0 60 H V C CNN 59 | F3 "" 0 0 60 H V C CNN 60 | DRAW 61 | C 0 0 31 0 1 0 N 62 | P 2 0 1 0 -30 0 -50 0 N 63 | X 1 1 -150 0 100 R 60 60 1 1 P 64 | ENDDRAW 65 | ENDDEF 66 | # 67 | # ESP8266EX 68 | # 69 | DEF ESP8266EX U 0 40 Y Y 1 F N 70 | F0 "U" -900 700 60 H V C CNN 71 | F1 "ESP8266EX" -850 600 60 H V C CNN 72 | F2 "" -900 700 60 H V C CNN 73 | F3 "" -900 700 60 H V C CNN 74 | DRAW 75 | S -850 500 700 -500 0 1 0 f 76 | X VddA 1 -1150 350 300 R 50 50 1 1 I 77 | X LNA/ANT 2 -1150 250 300 R 50 50 1 1 I 78 | X Vdd3P3 3 -1150 150 300 R 50 50 1 1 I 79 | X Vdd3P3 4 -1150 50 300 R 50 50 1 1 I 80 | X VddRCT 5 -1150 -50 300 R 50 50 1 1 I 81 | X TOUT 6 -1150 -150 300 R 50 50 1 1 I 82 | X CHIP_EN 7 -1150 -250 300 R 50 50 1 1 I 83 | X XPD_DCDC 8 -1150 -350 300 R 50 50 1 1 I 84 | X MTMS/GPIO14 9 -350 -800 300 U 50 50 1 1 I 85 | X MTDI/GPIO12 10 -250 -800 300 U 50 50 1 1 I 86 | X SD_CMD 20 1000 -50 300 L 50 50 1 1 I 87 | X VDDA 30 -150 800 300 D 50 50 1 1 I 88 | X VddPST 11 -150 -800 300 U 50 50 1 1 I 89 | X SD_CLK 21 1000 50 300 L 50 50 1 1 I 90 | X RES12K 31 -250 800 300 D 50 50 1 1 I 91 | X MTCK/GPIO13 12 -50 -800 300 U 50 50 1 1 I 92 | X SD_D0 22 1000 150 300 L 50 50 1 1 I 93 | X EXT_RSTB 32 -350 800 300 D 50 50 1 1 I 94 | X MTDO/GPIO15 13 50 -800 300 U 50 50 1 1 I 95 | X SD_D1 23 1000 250 300 L 50 50 1 1 I 96 | X GND 33 -450 800 300 D 50 50 1 1 I 97 | X GPIO2 14 150 -800 300 U 50 50 1 1 I 98 | X GP5/VD 24 1000 350 300 L 50 50 1 1 I 99 | X GPIO0 15 250 -800 300 U 50 50 1 1 I 100 | X URXD 25 350 800 300 D 50 50 1 1 I 101 | X GP4/VD 16 350 -800 300 U 50 50 1 1 I 102 | X UTXD 26 250 800 300 D 50 50 1 1 I 103 | X VddPST 17 1000 -350 300 L 50 50 1 1 I 104 | X XTAL_OUT 27 150 800 300 D 50 50 1 1 I 105 | X SD_D2 18 1000 -250 300 L 50 50 1 1 I 106 | X XTAL_IN 28 50 800 300 D 50 50 1 1 I 107 | X SD_D3 19 1000 -150 300 L 50 50 1 1 I 108 | X VDDD 29 -50 800 300 D 50 50 1 1 I 109 | ENDDRAW 110 | ENDDEF 111 | # 112 | # GND-RESCUE-usb_8285 113 | # 114 | DEF ~GND-RESCUE-usb_8285 #PWR 0 0 Y Y 1 F P 115 | F0 "#PWR" 0 0 30 H I C CNN 116 | F1 "GND-RESCUE-usb_8285" 0 -70 30 H I C CNN 117 | F2 "" 0 0 60 H V C CNN 118 | F3 "" 0 0 60 H V C CNN 119 | DRAW 120 | P 4 0 1 0 -50 0 0 -50 50 0 -50 0 N 121 | X GND 1 0 0 0 U 30 30 1 1 W N 122 | ENDDRAW 123 | ENDDEF 124 | # 125 | # MCP1824 126 | # 127 | DEF MCP1824 U 0 40 Y Y 1 F N 128 | F0 "U" -250 300 60 H V C CNN 129 | F1 "MCP1824" 100 -300 60 H V C CNN 130 | F2 "" 0 0 60 H I C CNN 131 | F3 "" 0 0 60 H I C CNN 132 | $FPLIST 133 | SOT23-5 134 | $ENDFPLIST 135 | DRAW 136 | S -300 200 300 -200 0 1 0 f 137 | X Vin 1 -600 100 300 R 50 50 1 1 I 138 | X GND 2 -600 0 300 R 50 50 1 1 I 139 | X ~SHDN 3 -600 -100 300 R 50 50 1 1 I 140 | X PWRGD 4 600 -100 300 L 50 50 1 1 O 141 | X OUT 5 600 100 300 L 50 50 1 1 O 142 | ENDDRAW 143 | ENDDEF 144 | # 145 | # R-RESCUE-usb_8285 146 | # 147 | DEF R-RESCUE-usb_8285 R 0 0 N Y 1 F N 148 | F0 "R" 80 0 40 V V C CNN 149 | F1 "R-RESCUE-usb_8285" 7 1 40 V V C CNN 150 | F2 "" -70 0 30 V V C CNN 151 | F3 "" 0 0 30 H V C CNN 152 | $FPLIST 153 | R? 154 | SM0603 155 | SM0805 156 | R?-* 157 | SM1206 158 | $ENDFPLIST 159 | DRAW 160 | S -40 150 40 -150 0 1 12 N 161 | X ~ 1 0 250 100 D 60 60 1 1 P 162 | X ~ 2 0 -250 100 U 60 60 1 1 P 163 | ENDDRAW 164 | ENDDEF 165 | # 166 | # XTAL4P 167 | # 168 | DEF XTAL4P X 0 40 N N 1 F N 169 | F0 "X" 0 150 60 H V C CNN 170 | F1 "XTAL4P" 0 -150 60 H V C CNN 171 | F2 "" 0 0 60 H I C CNN 172 | F3 "" 0 0 60 H I C CNN 173 | DRAW 174 | P 2 0 1 16 -100 100 -100 -100 N 175 | P 2 0 1 16 100 100 100 -100 N 176 | P 5 0 1 12 -50 50 50 50 50 -50 -50 -50 -50 50 f 177 | X 1 1 -300 0 200 R 40 40 1 1 P 178 | X 2 2 300 0 200 L 40 40 1 1 P 179 | X GND 3 -50 -300 300 U 50 50 1 1 P 180 | X GND 4 50 -300 300 U 50 50 1 1 P 181 | ENDDRAW 182 | ENDDEF 183 | # 184 | #End Library 185 | -------------------------------------------------------------------------------- /hardware/usb_8285_tiny/README.txt: -------------------------------------------------------------------------------- 1 | This has not yet been tested! 2 | -------------------------------------------------------------------------------- /hardware/usb_8285_tiny/usb_8285-revA/usb_8285_tiny-B.Cu.gbl: -------------------------------------------------------------------------------- 1 | G04 #@! TF.FileFunction,Copper,L2,Bot,Signal* 2 | %FSLAX46Y46*% 3 | G04 Gerber Fmt 4.6, Leading zero omitted, Abs format (unit mm)* 4 | G04 Created by KiCad (PCBNEW 4.0.3+e1-6302~38~ubuntu14.04.1-stable) date Wed Aug 31 10:57:53 2016* 5 | %MOMM*% 6 | %LPD*% 7 | G01* 8 | G04 APERTURE LIST* 9 | %ADD10C,0.150000*% 10 | %ADD11R,8.890000X1.270000*% 11 | %ADD12R,10.160000X1.270000*% 12 | %ADD13C,2.032000*% 13 | %ADD14C,0.635000*% 14 | %ADD15C,0.228600*% 15 | G04 APERTURE END LIST* 16 | D10* 17 | D11* 18 | X53340000Y-30784800D03* 19 | X53340000Y-32956500D03* 20 | D12* 21 | X53340000Y-28067000D03* 22 | X53340000Y-35687000D03* 23 | D13* 24 | X47574200Y-35864800D03* 25 | X47574200Y-28067000D03* 26 | D14* 27 | X53644800Y-29464000D03* 28 | X58521600Y-32054800D03* 29 | X51689000Y-29464000D03* 30 | X50063400Y-36753800D03* 31 | X50419000Y-35331400D03* 32 | X57607200Y-31140400D03* 33 | X58064400Y-34391600D03* 34 | X48971200Y-34264600D03* 35 | X50419000Y-28651200D03* 36 | X55219600Y-34137600D03* 37 | X48641000Y-28702000D03* 38 | X52882800Y-34340800D03* 39 | X54152800Y-27584400D03* 40 | X56896000Y-28803600D03* 41 | X57150000Y-37388800D03* 42 | X54610000Y-36880800D03* 43 | X52679600Y-26466800D03* 44 | X49085500Y-26479500D03* 45 | D15* 46 | X58318400Y-31851600D02* 47 | X58521600Y-32054800D01* 48 | X53644800Y-29464000D02* 49 | X57912000Y-29464000D01* 50 | X57912000Y-29464000D02* 51 | X58521600Y-30073600D01* 52 | X58521600Y-30073600D02* 53 | X58521600Y-32054800D01* 54 | X53644800Y-29464000D02* 55 | X51689000Y-29464000D01* 56 | X47574200Y-35864800D02* 57 | X47752000Y-35687000D01* 58 | X47752000Y-35687000D02* 59 | X53340000Y-35687000D01* 60 | X50101500Y-36576000D02* 61 | X50063400Y-36614100D01* 62 | X50063400Y-36614100D02* 63 | X50063400Y-36753800D01* 64 | X50419000Y-35331400D02* 65 | X52984400Y-35331400D01* 66 | X52984400Y-35331400D02* 67 | X53340000Y-35687000D01* 68 | X50977800Y-35687000D02* 69 | X53340000Y-35687000D01* 70 | X53314600Y-35712400D02* 71 | X53340000Y-35687000D01* 72 | X50101500Y-36576000D02* 73 | X50990500Y-35687000D01* 74 | X50990500Y-35687000D02* 75 | X53340000Y-35687000D01* 76 | X57607200Y-31140400D02* 77 | X57251600Y-30784800D01* 78 | X57251600Y-30784800D02* 79 | X53340000Y-30784800D01* 80 | X56654700Y-30784800D02* 81 | X53340000Y-30784800D01* 82 | X58064400Y-34391600D02* 83 | X56629300Y-32956500D01* 84 | X56629300Y-32956500D02* 85 | X53340000Y-32956500D01* 86 | X56769000Y-32956500D02* 87 | X53340000Y-32956500D01* 88 | X57594500Y-32956500D02* 89 | X53340000Y-32956500D01* 90 | X56515000Y-32956500D02* 91 | X53340000Y-32956500D01* 92 | X48539400Y-31826200D02* 93 | X48615600Y-31826200D01* 94 | X48615600Y-31826200D02* 95 | X48641000Y-31851600D01* 96 | X48641000Y-31851600D02* 97 | X56946800Y-31851600D01* 98 | X48971200Y-34264600D02* 99 | X48945295Y-34238695D01* 100 | X48945295Y-34238695D02* 101 | X48945295Y-34162007D01* 102 | X53340000Y-28067000D02* 103 | X49276000Y-28067000D01* 104 | X49276000Y-28067000D02* 105 | X48539400Y-28803600D01* 106 | X48539400Y-28803600D02* 107 | X48539400Y-31826200D01* 108 | X48539400Y-31826200D02* 109 | X48539400Y-33909000D01* 110 | X48539400Y-33909000D02* 111 | X48793400Y-34163000D01* 112 | X50419000Y-28651200D02* 113 | X51003200Y-28067000D01* 114 | X51003200Y-28067000D02* 115 | X53340000Y-28067000D01* 116 | X55219600Y-34137600D02* 117 | X56413400Y-34137600D01* 118 | X56413400Y-34137600D02* 119 | X56540400Y-34264600D01* 120 | X52882800Y-34340800D02* 121 | X55016400Y-34340800D01* 122 | X55016400Y-34340800D02* 123 | X55219600Y-34137600D01* 124 | X48641000Y-28702000D02* 125 | X50266600Y-28067000D01* 126 | X50266600Y-28067000D02* 127 | X53340000Y-28067000D01* 128 | X52679600Y-34137600D02* 129 | X52882800Y-34340800D01* 130 | X48793400Y-34163000D02* 131 | X48945295Y-34162007D01* 132 | X48945295Y-34162007D02* 133 | X52679600Y-34137600D01* 134 | X50012600Y-28067000D02* 135 | X53340000Y-28067000D01* 136 | X47599600Y-29006800D02* 137 | X46837600Y-28244800D01* 138 | X46837600Y-28244800D02* 139 | X53162200Y-28244800D01* 140 | X53162200Y-28244800D02* 141 | X53340000Y-28067000D01* 142 | X54152800Y-27584400D02* 143 | X53670200Y-28067000D01* 144 | X53670200Y-28067000D02* 145 | X53340000Y-28067000D01* 146 | X56896000Y-28803600D02* 147 | X56159400Y-28067000D01* 148 | X56159400Y-28067000D02* 149 | X53340000Y-28067000D01* 150 | X49911000Y-28067000D02* 151 | X53340000Y-28067000D01* 152 | X50482500Y-28194000D02* 153 | X50609500Y-28067000D01* 154 | X50609500Y-28067000D02* 155 | X53340000Y-28067000D01* 156 | X52959000Y-28067000D02* 157 | X52070000Y-28067000D01* 158 | X57150000Y-37388800D02* 159 | X56642000Y-36880800D01* 160 | X56642000Y-36880800D02* 161 | X54610000Y-36880800D01* 162 | X49174400Y-26466800D02* 163 | X49479200Y-26466800D01* 164 | X52679600Y-26466800D02* 165 | X49479200Y-26466800D01* 166 | X49174400Y-26466800D02* 167 | X49123600Y-26466800D01* 168 | M02* 169 | -------------------------------------------------------------------------------- /hardware/usb_8285_tiny/usb_8285-revA/usb_8285_tiny-B.Mask.gbs: -------------------------------------------------------------------------------- 1 | G04 #@! TF.FileFunction,Soldermask,Bot* 2 | %FSLAX46Y46*% 3 | G04 Gerber Fmt 4.6, Leading zero omitted, Abs format (unit mm)* 4 | G04 Created by KiCad (PCBNEW 4.0.3+e1-6302~38~ubuntu14.04.1-stable) date Wed Aug 31 10:57:53 2016* 5 | %MOMM*% 6 | %LPD*% 7 | G01* 8 | G04 APERTURE LIST* 9 | %ADD10C,0.150000*% 10 | %ADD11R,8.890000X1.270000*% 11 | %ADD12R,10.160000X1.270000*% 12 | %ADD13C,2.032000*% 13 | G04 APERTURE END LIST* 14 | D10* 15 | D11* 16 | X53340000Y-30784800D03* 17 | X53340000Y-32956500D03* 18 | D12* 19 | X53340000Y-28067000D03* 20 | X53340000Y-35687000D03* 21 | D13* 22 | X47574200Y-35864800D03* 23 | X47574200Y-28067000D03* 24 | M02* 25 | -------------------------------------------------------------------------------- /hardware/usb_8285_tiny/usb_8285-revA/usb_8285_tiny-B.SilkS.gbo: -------------------------------------------------------------------------------- 1 | G04 #@! TF.FileFunction,Legend,Bot* 2 | %FSLAX46Y46*% 3 | G04 Gerber Fmt 4.6, Leading zero omitted, Abs format (unit mm)* 4 | G04 Created by KiCad (PCBNEW 4.0.3+e1-6302~38~ubuntu14.04.1-stable) date Wed Aug 31 10:57:53 2016* 5 | %MOMM*% 6 | %LPD*% 7 | G01* 8 | G04 APERTURE LIST* 9 | %ADD10C,0.150000*% 10 | %ADD11C,0.228600*% 11 | %ADD12C,0.200000*% 12 | %ADD13C,0.152400*% 13 | G04 APERTURE END LIST* 14 | D10* 15 | D11* 16 | X57585428Y-29877657D02* 17 | X57890228Y-29442229D01* 18 | X58107943Y-29877657D02* 19 | X58107943Y-28963257D01* 20 | X57759600Y-28963257D01* 21 | X57672514Y-29006800D01* 22 | X57628971Y-29050343D01* 23 | X57585428Y-29137429D01* 24 | X57585428Y-29268057D01* 25 | X57628971Y-29355143D01* 26 | X57672514Y-29398686D01* 27 | X57759600Y-29442229D01* 28 | X58107943Y-29442229D01* 29 | X56845200Y-29834114D02* 30 | X56932286Y-29877657D01* 31 | X57106457Y-29877657D01* 32 | X57193543Y-29834114D01* 33 | X57237086Y-29747029D01* 34 | X57237086Y-29398686D01* 35 | X57193543Y-29311600D01* 36 | X57106457Y-29268057D01* 37 | X56932286Y-29268057D01* 38 | X56845200Y-29311600D01* 39 | X56801657Y-29398686D01* 40 | X56801657Y-29485771D01* 41 | X57237086Y-29572857D01* 42 | X56496857Y-29268057D02* 43 | X56279143Y-29877657D01* 44 | X56061429Y-29268057D01* 45 | X55059943Y-29616400D02* 46 | X54624514Y-29616400D01* 47 | X55147028Y-29877657D02* 48 | X54842228Y-28963257D01* 49 | X54537428Y-29877657D01* 50 | X56094085Y-34170257D02* 51 | X56094085Y-34779857D01* 52 | X56485971Y-34170257D02* 53 | X56485971Y-34649229D01* 54 | X56442428Y-34736314D01* 55 | X56355342Y-34779857D01* 56 | X56224714Y-34779857D01* 57 | X56137628Y-34736314D01* 58 | X56094085Y-34692771D01* 59 | X55702200Y-34736314D02* 60 | X55615114Y-34779857D01* 61 | X55440942Y-34779857D01* 62 | X55353857Y-34736314D01* 63 | X55310314Y-34649229D01* 64 | X55310314Y-34605686D01* 65 | X55353857Y-34518600D01* 66 | X55440942Y-34475057D01* 67 | X55571571Y-34475057D01* 68 | X55658657Y-34431514D01* 69 | X55702200Y-34344429D01* 70 | X55702200Y-34300886D01* 71 | X55658657Y-34213800D01* 72 | X55571571Y-34170257D01* 73 | X55440942Y-34170257D01* 74 | X55353857Y-34213800D01* 75 | X54918428Y-34779857D02* 76 | X54918428Y-33865457D01* 77 | X54918428Y-34213800D02* 78 | X54831342Y-34170257D01* 79 | X54657171Y-34170257D01* 80 | X54570085Y-34213800D01* 81 | X54526542Y-34257343D01* 82 | X54482999Y-34344429D01* 83 | X54482999Y-34605686D01* 84 | X54526542Y-34692771D01* 85 | X54570085Y-34736314D01* 86 | X54657171Y-34779857D01* 87 | X54831342Y-34779857D01* 88 | X54918428Y-34736314D01* 89 | X54308828Y-34866943D02* 90 | X53612142Y-34866943D01* 91 | X53263799Y-34257343D02* 92 | X53350885Y-34213800D01* 93 | X53394428Y-34170257D01* 94 | X53437971Y-34083171D01* 95 | X53437971Y-34039629D01* 96 | X53394428Y-33952543D01* 97 | X53350885Y-33909000D01* 98 | X53263799Y-33865457D01* 99 | X53089628Y-33865457D01* 100 | X53002542Y-33909000D01* 101 | X52958999Y-33952543D01* 102 | X52915456Y-34039629D01* 103 | X52915456Y-34083171D01* 104 | X52958999Y-34170257D01* 105 | X53002542Y-34213800D01* 106 | X53089628Y-34257343D01* 107 | X53263799Y-34257343D01* 108 | X53350885Y-34300886D01* 109 | X53394428Y-34344429D01* 110 | X53437971Y-34431514D01* 111 | X53437971Y-34605686D01* 112 | X53394428Y-34692771D01* 113 | X53350885Y-34736314D01* 114 | X53263799Y-34779857D01* 115 | X53089628Y-34779857D01* 116 | X53002542Y-34736314D01* 117 | X52958999Y-34692771D01* 118 | X52915456Y-34605686D01* 119 | X52915456Y-34431514D01* 120 | X52958999Y-34344429D01* 121 | X53002542Y-34300886D01* 122 | X53089628Y-34257343D01* 123 | X52567114Y-33952543D02* 124 | X52523571Y-33909000D01* 125 | X52436485Y-33865457D01* 126 | X52218771Y-33865457D01* 127 | X52131685Y-33909000D01* 128 | X52088142Y-33952543D01* 129 | X52044599Y-34039629D01* 130 | X52044599Y-34126714D01* 131 | X52088142Y-34257343D01* 132 | X52610656Y-34779857D01* 133 | X52044599Y-34779857D01* 134 | X51522085Y-34257343D02* 135 | X51609171Y-34213800D01* 136 | X51652714Y-34170257D01* 137 | X51696257Y-34083171D01* 138 | X51696257Y-34039629D01* 139 | X51652714Y-33952543D01* 140 | X51609171Y-33909000D01* 141 | X51522085Y-33865457D01* 142 | X51347914Y-33865457D01* 143 | X51260828Y-33909000D01* 144 | X51217285Y-33952543D01* 145 | X51173742Y-34039629D01* 146 | X51173742Y-34083171D01* 147 | X51217285Y-34170257D01* 148 | X51260828Y-34213800D01* 149 | X51347914Y-34257343D01* 150 | X51522085Y-34257343D01* 151 | X51609171Y-34300886D01* 152 | X51652714Y-34344429D01* 153 | X51696257Y-34431514D01* 154 | X51696257Y-34605686D01* 155 | X51652714Y-34692771D01* 156 | X51609171Y-34736314D01* 157 | X51522085Y-34779857D01* 158 | X51347914Y-34779857D01* 159 | X51260828Y-34736314D01* 160 | X51217285Y-34692771D01* 161 | X51173742Y-34605686D01* 162 | X51173742Y-34431514D01* 163 | X51217285Y-34344429D01* 164 | X51260828Y-34300886D01* 165 | X51347914Y-34257343D01* 166 | X50346428Y-33865457D02* 167 | X50781857Y-33865457D01* 168 | X50825400Y-34300886D01* 169 | X50781857Y-34257343D01* 170 | X50694771Y-34213800D01* 171 | X50477057Y-34213800D01* 172 | X50389971Y-34257343D01* 173 | X50346428Y-34300886D01* 174 | X50302885Y-34387971D01* 175 | X50302885Y-34605686D01* 176 | X50346428Y-34692771D01* 177 | X50389971Y-34736314D01* 178 | X50477057Y-34779857D01* 179 | X50694771Y-34779857D01* 180 | X50781857Y-34736314D01* 181 | X50825400Y-34692771D01* 182 | D12* 183 | X47509314Y-26424078D02* 184 | X47509314Y-26064867D01* 185 | X47150104Y-26783288D02* 186 | X47509314Y-26424078D01* 187 | X46431683Y-26783288D02* 188 | X47150104Y-26783288D01* 189 | X46790894Y-27142498D02* 190 | X46431683Y-26783288D01* 191 | X46790894Y-26424078D02* 192 | X46790894Y-27142498D01* 193 | X47150104Y-26064867D02* 194 | X46790894Y-26424078D01* 195 | X47509314Y-26064867D02* 196 | X47150104Y-26064867D01* 197 | D13* 198 | X58787574Y-30159235D02* 199 | X58025574Y-30159235D01* 200 | X58025574Y-30340663D01* 201 | X58061860Y-30449520D01* 202 | X58134431Y-30522092D01* 203 | X58207003Y-30558377D01* 204 | X58352146Y-30594663D01* 205 | X58461003Y-30594663D01* 206 | X58606146Y-30558377D01* 207 | X58678717Y-30522092D01* 208 | X58751289Y-30449520D01* 209 | X58787574Y-30340663D01* 210 | X58787574Y-30159235D01* 211 | X58497289Y-30921235D02* 212 | X58497289Y-31501806D01* 213 | X58787574Y-31211520D02* 214 | X58207003Y-31211520D01* 215 | X58787574Y-32186155D02* 216 | X58025574Y-32186155D01* 217 | X58025574Y-32367583D01* 218 | X58061860Y-32476440D01* 219 | X58134431Y-32549012D01* 220 | X58207003Y-32585297D01* 221 | X58352146Y-32621583D01* 222 | X58461003Y-32621583D01* 223 | X58606146Y-32585297D01* 224 | X58678717Y-32549012D01* 225 | X58751289Y-32476440D01* 226 | X58787574Y-32367583D01* 227 | X58787574Y-32186155D01* 228 | X58497289Y-32948155D02* 229 | X58497289Y-33528726D01* 230 | X58238572Y-26289000D02* 231 | X58311143Y-26252714D01* 232 | X58420000Y-26252714D01* 233 | X58528857Y-26289000D01* 234 | X58601429Y-26361571D01* 235 | X58637714Y-26434143D01* 236 | X58674000Y-26579286D01* 237 | X58674000Y-26688143D01* 238 | X58637714Y-26833286D01* 239 | X58601429Y-26905857D01* 240 | X58528857Y-26978429D01* 241 | X58420000Y-27014714D01* 242 | X58347429Y-27014714D01* 243 | X58238572Y-26978429D01* 244 | X58202286Y-26942143D01* 245 | X58202286Y-26688143D01* 246 | X58347429Y-26688143D01* 247 | X57875714Y-27014714D02* 248 | X57875714Y-26252714D01* 249 | X57440286Y-27014714D01* 250 | X57440286Y-26252714D01* 251 | X57077428Y-27014714D02* 252 | X57077428Y-26252714D01* 253 | X56896000Y-26252714D01* 254 | X56787143Y-26289000D01* 255 | X56714571Y-26361571D01* 256 | X56678286Y-26434143D01* 257 | X56642000Y-26579286D01* 258 | X56642000Y-26688143D01* 259 | X56678286Y-26833286D01* 260 | X56714571Y-26905857D01* 261 | X56787143Y-26978429D01* 262 | X56896000Y-27014714D01* 263 | X57077428Y-27014714D01* 264 | X57926514Y-37138429D02* 265 | X57345943Y-37138429D01* 266 | X57636229Y-37428714D02* 267 | X57636229Y-36848143D01* 268 | X56620228Y-36666714D02* 269 | X56983085Y-36666714D01* 270 | X57019371Y-37029571D01* 271 | X56983085Y-36993286D01* 272 | X56910514Y-36957000D01* 273 | X56729085Y-36957000D01* 274 | X56656514Y-36993286D01* 275 | X56620228Y-37029571D01* 276 | X56583943Y-37102143D01* 277 | X56583943Y-37283571D01* 278 | X56620228Y-37356143D01* 279 | X56656514Y-37392429D01* 280 | X56729085Y-37428714D01* 281 | X56910514Y-37428714D01* 282 | X56983085Y-37392429D01* 283 | X57019371Y-37356143D01* 284 | X56366229Y-36666714D02* 285 | X56112229Y-37428714D01* 286 | X55858229Y-36666714D01* 287 | X48383734Y-34296169D02* 288 | X47803163Y-34296169D01* 289 | X48093449Y-34586454D02* 290 | X48093449Y-34005883D01* 291 | X47077448Y-33824454D02* 292 | X47440305Y-33824454D01* 293 | X47476591Y-34187311D01* 294 | X47440305Y-34151026D01* 295 | X47367734Y-34114740D01* 296 | X47186305Y-34114740D01* 297 | X47113734Y-34151026D01* 298 | X47077448Y-34187311D01* 299 | X47041163Y-34259883D01* 300 | X47041163Y-34441311D01* 301 | X47077448Y-34513883D01* 302 | X47113734Y-34550169D01* 303 | X47186305Y-34586454D01* 304 | X47367734Y-34586454D01* 305 | X47440305Y-34550169D01* 306 | X47476591Y-34513883D01* 307 | X46823449Y-33824454D02* 308 | X46569449Y-34586454D01* 309 | X46315449Y-33824454D01* 310 | M02* 311 | -------------------------------------------------------------------------------- /hardware/usb_8285_tiny/usb_8285-revA/usb_8285_tiny-Edge.Cuts.gm1: -------------------------------------------------------------------------------- 1 | G04 #@! TF.FileFunction,Profile,NP* 2 | %FSLAX46Y46*% 3 | G04 Gerber Fmt 4.6, Leading zero omitted, Abs format (unit mm)* 4 | G04 Created by KiCad (PCBNEW 4.0.3+e1-6302~38~ubuntu14.04.1-stable) date Wed Aug 31 10:57:53 2016* 5 | %MOMM*% 6 | %LPD*% 7 | G01* 8 | G04 APERTURE LIST* 9 | %ADD10C,0.150000*% 10 | %ADD11C,0.100000*% 11 | G04 APERTURE END LIST* 12 | D10* 13 | D11* 14 | X59029600Y-37896800D02* 15 | X46304200Y-37896800D01* 16 | X46304200Y-25857200D02* 17 | X59029600Y-25857200D01* 18 | X59029600Y-25857200D02* 19 | X59029600Y-37896800D01* 20 | X46304200Y-37896800D02* 21 | X46304200Y-25857200D01* 22 | M02* 23 | -------------------------------------------------------------------------------- /hardware/usb_8285_tiny/usb_8285-revA/usb_8285_tiny-F.Cu.gtl: -------------------------------------------------------------------------------- 1 | G04 #@! TF.FileFunction,Copper,L1,Top,Signal* 2 | %FSLAX46Y46*% 3 | G04 Gerber Fmt 4.6, Leading zero omitted, Abs format (unit mm)* 4 | G04 Created by KiCad (PCBNEW 4.0.3+e1-6302~38~ubuntu14.04.1-stable) date Wed Aug 31 10:57:53 2016* 5 | %MOMM*% 6 | %LPD*% 7 | G01* 8 | G04 APERTURE LIST* 9 | %ADD10C,0.150000*% 10 | %ADD11R,1.400000X0.500000*% 11 | %ADD12R,1.143000X0.635000*% 12 | %ADD13R,0.254000X0.762000*% 13 | %ADD14R,0.762000X0.254000*% 14 | %ADD15R,2.999740X2.999740*% 15 | %ADD16R,0.700000X0.700000*% 16 | %ADD17C,2.032000*% 17 | %ADD18C,1.651000*% 18 | %ADD19R,0.762000X0.508000*% 19 | %ADD20C,1.280000*% 20 | %ADD21R,0.599440X0.398780*% 21 | %ADD22R,0.398780X0.599440*% 22 | %ADD23R,0.635000X1.143000*% 23 | %ADD24C,0.635000*% 24 | %ADD25C,0.228600*% 25 | G04 APERTURE END LIST* 26 | D10* 27 | D11* 28 | X47193200Y-30429400D03* 29 | X47193200Y-33629400D03* 30 | D12* 31 | X49631600Y-28625800D03* 32 | X49631600Y-30149800D03* 33 | D13* 34 | X52915820Y-30457140D03* 35 | X53416200Y-30457140D03* 36 | X53916580Y-30457140D03* 37 | X52415440Y-30457140D03* 38 | D14* 39 | X51666140Y-31206440D03* 40 | X51666140Y-31706820D03* 41 | X51666140Y-32207200D03* 42 | X51666140Y-32707580D03* 43 | X51666140Y-33205420D03* 44 | X51666140Y-33705800D03* 45 | X51666140Y-34206180D03* 46 | X51666140Y-34706560D03* 47 | D13* 48 | X55915560Y-35455860D03* 49 | X52415440Y-35455860D03* 50 | X52915820Y-35455860D03* 51 | X53416200Y-35455860D03* 52 | X53916580Y-35455860D03* 53 | X54414420Y-35455860D03* 54 | X54914800Y-35455860D03* 55 | X55415180Y-35455860D03* 56 | D14* 57 | X56664860Y-34706560D03* 58 | X56664860Y-34206180D03* 59 | X56664860Y-33705800D03* 60 | X56664860Y-33205420D03* 61 | X56664860Y-32707580D03* 62 | X56664860Y-32207200D03* 63 | X56664860Y-31706820D03* 64 | X56664860Y-31206440D03* 65 | D13* 66 | X55915560Y-30457140D03* 67 | X55415180Y-30457140D03* 68 | X54914800Y-30457140D03* 69 | X54414420Y-30457140D03* 70 | D15* 71 | X54165500Y-32956500D03* 72 | D16* 73 | X54724400Y-28692400D03* 74 | X56324400Y-27492400D03* 75 | X54724400Y-27492400D03* 76 | X56324400Y-28692400D03* 77 | D17* 78 | X50749200Y-27127200D03* 79 | X48437800Y-27127200D03* 80 | D18* 81 | X57962800Y-36830000D03* 82 | D19* 83 | X49504600Y-36944300D03* 84 | X49504600Y-35039300D03* 85 | X46964600Y-36944300D03* 86 | X49504600Y-35991800D03* 87 | X46964600Y-35039300D03* 88 | D20* 89 | X50368200Y-33223200D03* 90 | D21* 91 | X53644800Y-28592780D03* 92 | X53644800Y-27693620D03* 93 | X57404000Y-28541980D03* 94 | X57404000Y-27642820D03* 95 | D22* 96 | X52585620Y-36677600D03* 97 | X53484780Y-36677600D03* 98 | D21* 99 | X52578000Y-27693620D03* 100 | X52578000Y-28592780D03* 101 | D22* 102 | X56393080Y-36830000D03* 103 | X55493920Y-36830000D03* 104 | D21* 105 | X58064400Y-33571180D03* 106 | X58064400Y-32672020D03* 107 | D22* 108 | X51655980Y-36677600D03* 109 | X50756820Y-36677600D03* 110 | D23* 111 | X48539400Y-31292800D03* 112 | X50063400Y-31292800D03* 113 | D24* 114 | X53644800Y-29464000D03* 115 | X58521600Y-32054800D03* 116 | X51689000Y-29464000D03* 117 | X50063400Y-36753800D03* 118 | X50419000Y-35331400D03* 119 | X57607200Y-31140400D03* 120 | X58064400Y-34391600D03* 121 | X48971200Y-34264600D03* 122 | X50419000Y-28651200D03* 123 | X55219600Y-34137600D03* 124 | X48641000Y-28702000D03* 125 | X52882800Y-34340800D03* 126 | X54152800Y-27584400D03* 127 | X56896000Y-28803600D03* 128 | X57150000Y-37388800D03* 129 | X54610000Y-36880800D03* 130 | X52679600Y-26466800D03* 131 | X49085500Y-26479500D03* 132 | D25* 133 | X49631600Y-30149800D02* 134 | X49555400Y-30149800D01* 135 | X49555400Y-30149800D02* 136 | X49301400Y-30403800D01* 137 | X49301400Y-30403800D02* 138 | X49301400Y-32029400D01* 139 | X49301400Y-32029400D02* 140 | X49517300Y-32245300D01* 141 | X49517300Y-32245300D02* 142 | X49517300Y-32207200D01* 143 | X51666140Y-31206440D02* 144 | X51399440Y-31206440D01* 145 | X51399440Y-31206440D02* 146 | X50342800Y-30149800D01* 147 | X49631600Y-30149800D02* 148 | X50342800Y-30149800D01* 149 | X50342800Y-30149800D02* 150 | X51003200Y-30149800D01* 151 | X51003200Y-30149800D02* 152 | X51689000Y-29464000D01* 153 | X48437800Y-33731200D02* 154 | X48437800Y-33832800D01* 155 | X47929800Y-36017200D02* 156 | X47650400Y-36296600D01* 157 | X47650400Y-36296600D02* 158 | X47307500Y-36639500D01* 159 | X47929800Y-34340800D02* 160 | X47929800Y-36017200D01* 161 | X48437800Y-33832800D02* 162 | X47929800Y-34340800D01* 163 | X48564800Y-33604200D02* 164 | X48437800Y-33731200D01* 165 | X48437800Y-33731200D02* 166 | X48456850Y-33712150D01* 167 | X47307500Y-36639500D02* 168 | X47028100Y-36918900D01* 169 | X47028100Y-36918900D02* 170 | X46939200Y-36918900D01* 171 | X58115200Y-35102800D02* 172 | X57505600Y-35712400D01* 173 | X58724800Y-34696400D02* 174 | X58318400Y-35102800D01* 175 | X58318400Y-35102800D02* 176 | X58115200Y-35102800D01* 177 | X58724800Y-34340800D02* 178 | X58724800Y-34696400D01* 179 | X56393080Y-36062920D02* 180 | X56393080Y-36830000D01* 181 | X56743600Y-35712400D02* 182 | X56393080Y-36062920D01* 183 | X57505600Y-35712400D02* 184 | X56743600Y-35712400D01* 185 | X56393080Y-36824920D02* 186 | X56393080Y-36830000D01* 187 | X51666140Y-32207200D02* 188 | X49517300Y-32207200D01* 189 | X49517300Y-32207200D02* 190 | X49555400Y-32207200D01* 191 | X51666140Y-32707580D02* 192 | X51666140Y-32207200D01* 193 | X47307500Y-36639500D02* 194 | X47358300Y-36639500D01* 195 | X48260000Y-37541200D02* 196 | X53644800Y-37541200D01* 197 | X47358300Y-36639500D02* 198 | X48260000Y-37541200D01* 199 | X53484780Y-36677600D02* 200 | X53484780Y-37193220D01* 201 | X53484780Y-37193220D02* 202 | X53416200Y-37261800D01* 203 | X53416200Y-35455860D02* 204 | X53416200Y-37261800D01* 205 | X53416200Y-37261800D02* 206 | X53416200Y-37312600D01* 207 | X53416200Y-37312600D02* 208 | X53644800Y-37541200D01* 209 | X56393080Y-37332920D02* 210 | X56393080Y-36830000D01* 211 | X56184800Y-37541200D02* 212 | X56393080Y-37332920D01* 213 | X53644800Y-37541200D02* 214 | X56184800Y-37541200D01* 215 | X51666140Y-34206180D02* 216 | X50850800Y-34206180D01* 217 | X53916580Y-30457140D02* 218 | X53916580Y-29735780D01* 219 | X53916580Y-29735780D02* 220 | X53644800Y-29464000D01* 221 | X53416200Y-30457140D02* 222 | X53416200Y-29692600D01* 223 | X53416200Y-29692600D02* 224 | X53644800Y-29464000D01* 225 | X52415440Y-30457140D02* 226 | X52425600Y-30446980D01* 227 | X52425600Y-30446980D02* 228 | X52425600Y-30200600D01* 229 | X52425600Y-30200600D02* 230 | X51689000Y-29464000D01* 231 | X58420000Y-32773620D02* 232 | X58420000Y-32156400D01* 233 | X58420000Y-32156400D02* 234 | X58521600Y-32054800D01* 235 | X58064400Y-32773620D02* 236 | X58420000Y-32773620D01* 237 | X58420000Y-32773620D02* 238 | X58681620Y-32773620D01* 239 | X58681620Y-32773620D02* 240 | X58724800Y-32816800D01* 241 | X58724800Y-32816800D02* 242 | X58724800Y-34340800D01* 243 | X58724800Y-34340800D02* 244 | X58724800Y-34290000D01* 245 | X56664860Y-34706560D02* 246 | X57177940Y-34706560D01* 247 | X57467500Y-32893000D02* 248 | X57409080Y-32951420D01* 249 | X57536080Y-32824420D02* 250 | X57912000Y-32824420D01* 251 | X57467500Y-32893000D02* 252 | X57536080Y-32824420D01* 253 | X57404000Y-32956500D02* 254 | X57409080Y-32951420D01* 255 | X57404000Y-34480500D02* 256 | X57404000Y-32956500D01* 257 | X57177940Y-34706560D02* 258 | X57404000Y-34480500D01* 259 | X49326800Y-33604200D02* 260 | X49326800Y-32435800D01* 261 | X49326800Y-32435800D02* 262 | X49555400Y-32207200D01* 263 | X49326800Y-33604200D02* 264 | X48564800Y-33604200D01* 265 | X49987200Y-34206180D02* 266 | X49928780Y-34206180D01* 267 | X49928780Y-34206180D02* 268 | X49326800Y-33604200D01* 269 | X50850800Y-34206180D02* 270 | X49987200Y-34206180D01* 271 | X49987200Y-34206180D02* 272 | X50012600Y-34206180D01* 273 | X50012600Y-34206180D02* 274 | X50055780Y-34206180D01* 275 | X50850800Y-34206180D02* 276 | X50868580Y-34206180D01* 277 | X50444400Y-36639500D02* 278 | X50330100Y-36753800D01* 279 | X50330100Y-36753800D02* 280 | X50063400Y-36753800D01* 281 | X50063400Y-36753800D02* 282 | X49644300Y-36753800D01* 283 | X49644300Y-36753800D02* 284 | X49479200Y-36918900D01* 285 | X49479200Y-35013900D02* 286 | X49796700Y-35331400D01* 287 | X49796700Y-35331400D02* 288 | X50419000Y-35331400D01* 289 | X50858420Y-36639500D02* 290 | X50444400Y-36639500D01* 291 | X50444400Y-36639500D02* 292 | X50165000Y-36639500D01* 293 | X50165000Y-36639500D02* 294 | X50101500Y-36576000D01* 295 | X56664860Y-31206440D02* 296 | X57541160Y-31206440D01* 297 | X57541160Y-31206440D02* 298 | X57607200Y-31140400D01* 299 | X55915560Y-35455860D02* 300 | X55984140Y-35455860D01* 301 | X55984140Y-35455860D02* 302 | X56235600Y-35204400D01* 303 | X56235600Y-35204400D02* 304 | X57353200Y-35204400D01* 305 | X57353200Y-35204400D02* 306 | X58064400Y-34493200D01* 307 | X58064400Y-34493200D02* 308 | X58064400Y-34391600D01* 309 | X58102500Y-33660080D02* 310 | X58102500Y-34353500D01* 311 | X58102500Y-34353500D02* 312 | X58064400Y-34391600D01* 313 | X48590200Y-34899600D02* 314 | X48590200Y-34645600D01* 315 | X48590200Y-34645600D02* 316 | X48971200Y-34264600D01* 317 | X49631600Y-28625800D02* 318 | X50393600Y-28625800D01* 319 | X50393600Y-28625800D02* 320 | X50419000Y-28651200D01* 321 | X49555400Y-28727400D02* 322 | X48666400Y-28727400D01* 323 | X48666400Y-28727400D02* 324 | X48641000Y-28702000D01* 325 | X48742600Y-28600400D02* 326 | X49428400Y-28600400D01* 327 | X49428400Y-28600400D02* 328 | X49555400Y-28727400D01* 329 | X55219600Y-34137600D02* 330 | X54165500Y-33083500D01* 331 | X54165500Y-33083500D02* 332 | X54165500Y-32956500D01* 333 | X48590200Y-34899600D02* 334 | X48577500Y-34912300D01* 335 | X48577500Y-34912300D02* 336 | X48539400Y-34950400D01* 337 | X48539400Y-34950400D02* 338 | X48539400Y-35712400D01* 339 | X48539400Y-35712400D02* 340 | X48793400Y-35966400D01* 341 | X48793400Y-35966400D02* 342 | X49479200Y-35966400D01* 343 | X49479200Y-35966400D02* 344 | X49504600Y-35991800D01* 345 | X49504600Y-35991800D02* 346 | X51155600Y-35991800D01* 347 | X51155600Y-35991800D02* 348 | X51460400Y-35687000D01* 349 | X48488600Y-28854400D02* 350 | X48742600Y-28600400D01* 351 | X48742600Y-28600400D02* 352 | X48641000Y-28702000D01* 353 | X52882800Y-34340800D02* 354 | X54165500Y-33058100D01* 355 | X54165500Y-33058100D02* 356 | X54165500Y-32956500D01* 357 | X52527200Y-37033200D02* 358 | X52527200Y-36736020D01* 359 | X52527200Y-36736020D02* 360 | X52585620Y-36677600D01* 361 | X52585620Y-36677600D02* 362 | X52585620Y-36482020D01* 363 | X52585620Y-36482020D02* 364 | X52324000Y-36220400D01* 365 | X52534820Y-37033200D02* 366 | X52527200Y-37033200D01* 367 | X52527200Y-37033200D02* 368 | X52151280Y-37033200D01* 369 | X52151280Y-37033200D02* 370 | X51757580Y-36639500D01* 371 | X54203600Y-27441600D02* 372 | X54203600Y-27533600D01* 373 | X54203600Y-27533600D02* 374 | X54152800Y-27584400D01* 375 | X53644800Y-27693620D02* 376 | X52578000Y-27693620D01* 377 | X54724400Y-27441600D02* 378 | X54203600Y-27441600D01* 379 | X54203600Y-27441600D02* 380 | X53896820Y-27441600D01* 381 | X53896820Y-27441600D02* 382 | X53644800Y-27693620D01* 383 | X56324400Y-28641600D02* 384 | X56734000Y-28641600D01* 385 | X56734000Y-28641600D02* 386 | X56896000Y-28803600D01* 387 | X51460400Y-35687000D02* 388 | X52184300Y-35687000D01* 389 | X52184300Y-35687000D02* 390 | X52415440Y-35455860D01* 391 | X54414420Y-35455860D02* 392 | X54414420Y-33205420D01* 393 | X54414420Y-33205420D02* 394 | X54165500Y-32956500D01* 395 | X52915820Y-35455860D02* 396 | X52915820Y-34206180D01* 397 | X52915820Y-34206180D02* 398 | X54165500Y-32956500D01* 399 | X52415440Y-35455860D02* 400 | X52915820Y-35455860D01* 401 | X51996340Y-36400740D02* 402 | X52143660Y-36400740D01* 403 | X52143660Y-36400740D02* 404 | X52324000Y-36220400D01* 405 | X52324000Y-36220400D02* 406 | X52415440Y-36128960D01* 407 | X52415440Y-36128960D02* 408 | X52415440Y-35455860D01* 409 | X51757580Y-36639500D02* 410 | X51996340Y-36400740D01* 411 | X57353200Y-28491180D02* 412 | X56474820Y-28491180D01* 413 | X56474820Y-28491180D02* 414 | X56324400Y-28641600D01* 415 | X51460400Y-35687000D02* 416 | X51523900Y-35687000D01* 417 | X53995320Y-32964120D02* 418 | X53746400Y-32715200D01* 419 | X48539400Y-31292800D02* 420 | X48539400Y-31089600D01* 421 | X48539400Y-31089600D02* 422 | X47879200Y-30429400D01* 423 | X47879200Y-30429400D02* 424 | X47193200Y-30429400D01* 425 | X47320400Y-30454800D02* 426 | X46736000Y-30454800D01* 427 | X57962800Y-36830000D02* 428 | X57708800Y-36830000D01* 429 | X57708800Y-36830000D02* 430 | X57150000Y-37388800D01* 431 | X55493920Y-36830000D02* 432 | X55415180Y-36751260D01* 433 | X55415180Y-36751260D02* 434 | X55415180Y-35455860D01* 435 | X55493920Y-36830000D02* 436 | X54660800Y-36830000D01* 437 | X54660800Y-36830000D02* 438 | X54610000Y-36880800D01* 439 | X51666140Y-33705800D02* 440 | X50927000Y-33705800D01* 441 | X50927000Y-33705800D02* 442 | X50444400Y-33223200D01* 443 | X52915820Y-30457140D02* 444 | X52915820Y-28930600D01* 445 | X52915820Y-28930600D02* 446 | X52578000Y-28592780D01* 447 | X58166000Y-27228800D02* 448 | X57708800Y-26771600D01* 449 | X53797200Y-26771600D02* 450 | X53848000Y-26771600D01* 451 | X57658000Y-29667200D02* 452 | X58166000Y-29159200D01* 453 | X58166000Y-29159200D02* 454 | X58166000Y-27228800D01* 455 | X55415180Y-30457140D02* 456 | X55415180Y-29878020D01* 457 | X55626000Y-29667200D02* 458 | X57150000Y-29667200D01* 459 | X55415180Y-29878020D02* 460 | X55626000Y-29667200D01* 461 | X57150000Y-29667200D02* 462 | X57658000Y-29667200D01* 463 | X57658000Y-26771600D02* 464 | X53848000Y-26771600D01* 465 | X53441600Y-27127200D02* 466 | X50647600Y-27127200D01* 467 | X53441600Y-27127200D02* 468 | X53797200Y-26771600D01* 469 | X57708800Y-26771600D02* 470 | X57658000Y-26771600D01* 471 | X50647600Y-27127200D02* 472 | X50622200Y-27127200D01* 473 | X50622200Y-27127200D02* 474 | X50609500Y-27114500D01* 475 | X57985660Y-30457140D02* 476 | X58623200Y-29819600D01* 477 | X58623200Y-26517600D02* 478 | X58369200Y-26263600D01* 479 | X53086000Y-26466800D02* 480 | X52679600Y-26466800D01* 481 | X58318400Y-26263600D02* 482 | X53289200Y-26263600D01* 483 | X58623200Y-29718000D02* 484 | X58623200Y-26619200D01* 485 | X57985660Y-30457140D02* 486 | X55915560Y-30457140D01* 487 | X53289200Y-26263600D02* 488 | X53086000Y-26466800D01* 489 | X58369200Y-26263600D02* 490 | X58318400Y-26263600D01* 491 | X58623200Y-26619200D02* 492 | X58623200Y-26517600D01* 493 | X58623200Y-29819600D02* 494 | X58623200Y-29718000D01* 495 | X54414420Y-30457140D02* 496 | X54414420Y-28951580D01* 497 | X54414420Y-28951580D02* 498 | X54724400Y-28641600D01* 499 | X53644800Y-28592780D02* 500 | X53693620Y-28641600D01* 501 | X53693620Y-28641600D02* 502 | X54724400Y-28641600D01* 503 | X56324400Y-27441600D02* 504 | X57202780Y-27441600D01* 505 | X57202780Y-27441600D02* 506 | X57353200Y-27592020D01* 507 | X54914800Y-30457140D02* 508 | X54914800Y-29718000D01* 509 | X55768800Y-27441600D02* 510 | X56324400Y-27441600D01* 511 | X55524400Y-27686000D02* 512 | X55768800Y-27441600D01* 513 | X55524400Y-29108400D02* 514 | X55524400Y-27686000D01* 515 | X54914800Y-29718000D02* 516 | X55524400Y-29108400D01* 517 | X51666140Y-31706820D02* 518 | X50368200Y-31706820D01* 519 | X50368200Y-31706820D02* 520 | X50208180Y-31546800D01* 521 | M02* 522 | -------------------------------------------------------------------------------- /hardware/usb_8285_tiny/usb_8285-revA/usb_8285_tiny-F.Mask.gts: -------------------------------------------------------------------------------- 1 | G04 #@! TF.FileFunction,Soldermask,Top* 2 | %FSLAX46Y46*% 3 | G04 Gerber Fmt 4.6, Leading zero omitted, Abs format (unit mm)* 4 | G04 Created by KiCad (PCBNEW 4.0.3+e1-6302~38~ubuntu14.04.1-stable) date Wed Aug 31 10:57:53 2016* 5 | %MOMM*% 6 | %LPD*% 7 | G01* 8 | G04 APERTURE LIST* 9 | %ADD10C,0.150000*% 10 | %ADD11R,1.400000X0.500000*% 11 | %ADD12R,1.143000X0.635000*% 12 | %ADD13R,0.254000X0.762000*% 13 | %ADD14R,0.762000X0.254000*% 14 | %ADD15R,2.999740X2.999740*% 15 | %ADD16R,0.700000X0.700000*% 16 | %ADD17C,2.032000*% 17 | %ADD18C,1.651000*% 18 | %ADD19R,0.762000X0.508000*% 19 | %ADD20C,1.280000*% 20 | %ADD21R,0.599440X0.398780*% 21 | %ADD22R,0.398780X0.599440*% 22 | %ADD23R,0.635000X1.143000*% 23 | G04 APERTURE END LIST* 24 | D10* 25 | D11* 26 | X47193200Y-30429400D03* 27 | X47193200Y-33629400D03* 28 | D12* 29 | X49631600Y-28625800D03* 30 | X49631600Y-30149800D03* 31 | D13* 32 | X52915820Y-30457140D03* 33 | X53416200Y-30457140D03* 34 | X53916580Y-30457140D03* 35 | X52415440Y-30457140D03* 36 | D14* 37 | X51666140Y-31206440D03* 38 | X51666140Y-31706820D03* 39 | X51666140Y-32207200D03* 40 | X51666140Y-32707580D03* 41 | X51666140Y-33205420D03* 42 | X51666140Y-33705800D03* 43 | X51666140Y-34206180D03* 44 | X51666140Y-34706560D03* 45 | D13* 46 | X55915560Y-35455860D03* 47 | X52415440Y-35455860D03* 48 | X52915820Y-35455860D03* 49 | X53416200Y-35455860D03* 50 | X53916580Y-35455860D03* 51 | X54414420Y-35455860D03* 52 | X54914800Y-35455860D03* 53 | X55415180Y-35455860D03* 54 | D14* 55 | X56664860Y-34706560D03* 56 | X56664860Y-34206180D03* 57 | X56664860Y-33705800D03* 58 | X56664860Y-33205420D03* 59 | X56664860Y-32707580D03* 60 | X56664860Y-32207200D03* 61 | X56664860Y-31706820D03* 62 | X56664860Y-31206440D03* 63 | D13* 64 | X55915560Y-30457140D03* 65 | X55415180Y-30457140D03* 66 | X54914800Y-30457140D03* 67 | X54414420Y-30457140D03* 68 | D15* 69 | X54165500Y-32956500D03* 70 | D16* 71 | X54724400Y-28692400D03* 72 | X56324400Y-27492400D03* 73 | X54724400Y-27492400D03* 74 | X56324400Y-28692400D03* 75 | D17* 76 | X50749200Y-27127200D03* 77 | X48437800Y-27127200D03* 78 | D18* 79 | X57962800Y-36830000D03* 80 | D19* 81 | X49504600Y-36944300D03* 82 | X49504600Y-35039300D03* 83 | X46964600Y-36944300D03* 84 | X49504600Y-35991800D03* 85 | X46964600Y-35039300D03* 86 | D20* 87 | X50368200Y-33223200D03* 88 | D21* 89 | X53644800Y-28592780D03* 90 | X53644800Y-27693620D03* 91 | X57404000Y-28541980D03* 92 | X57404000Y-27642820D03* 93 | D22* 94 | X52585620Y-36677600D03* 95 | X53484780Y-36677600D03* 96 | D21* 97 | X52578000Y-27693620D03* 98 | X52578000Y-28592780D03* 99 | D22* 100 | X56393080Y-36830000D03* 101 | X55493920Y-36830000D03* 102 | D21* 103 | X58064400Y-33571180D03* 104 | X58064400Y-32672020D03* 105 | D22* 106 | X51655980Y-36677600D03* 107 | X50756820Y-36677600D03* 108 | D23* 109 | X48539400Y-31292800D03* 110 | X50063400Y-31292800D03* 111 | M02* 112 | -------------------------------------------------------------------------------- /hardware/usb_8285_tiny/usb_8285-revA/usb_8285_tiny-F.Paste.gtp: -------------------------------------------------------------------------------- 1 | G04 #@! TF.FileFunction,Paste,Top* 2 | %FSLAX46Y46*% 3 | G04 Gerber Fmt 4.6, Leading zero omitted, Abs format (unit mm)* 4 | G04 Created by KiCad (PCBNEW 4.0.3+e1-6302~38~ubuntu14.04.1-stable) date Wed Aug 31 10:57:53 2016* 5 | %MOMM*% 6 | %LPD*% 7 | G01* 8 | G04 APERTURE LIST* 9 | %ADD10C,0.150000*% 10 | %ADD11R,1.400000X0.500000*% 11 | %ADD12R,1.143000X0.635000*% 12 | %ADD13R,0.254000X0.762000*% 13 | %ADD14R,0.762000X0.254000*% 14 | %ADD15R,2.999740X2.999740*% 15 | %ADD16R,0.700000X0.700000*% 16 | %ADD17C,2.032000*% 17 | %ADD18C,1.651000*% 18 | %ADD19R,0.762000X0.508000*% 19 | %ADD20C,1.280000*% 20 | %ADD21R,0.599440X0.398780*% 21 | %ADD22R,0.398780X0.599440*% 22 | %ADD23R,0.635000X1.143000*% 23 | G04 APERTURE END LIST* 24 | D10* 25 | D11* 26 | X47193200Y-30429400D03* 27 | X47193200Y-33629400D03* 28 | D12* 29 | X49631600Y-28625800D03* 30 | X49631600Y-30149800D03* 31 | D13* 32 | X52915820Y-30457140D03* 33 | X53416200Y-30457140D03* 34 | X53916580Y-30457140D03* 35 | X52415440Y-30457140D03* 36 | D14* 37 | X51666140Y-31206440D03* 38 | X51666140Y-31706820D03* 39 | X51666140Y-32207200D03* 40 | X51666140Y-32707580D03* 41 | X51666140Y-33205420D03* 42 | X51666140Y-33705800D03* 43 | X51666140Y-34206180D03* 44 | X51666140Y-34706560D03* 45 | D13* 46 | X55915560Y-35455860D03* 47 | X52415440Y-35455860D03* 48 | X52915820Y-35455860D03* 49 | X53416200Y-35455860D03* 50 | X53916580Y-35455860D03* 51 | X54414420Y-35455860D03* 52 | X54914800Y-35455860D03* 53 | X55415180Y-35455860D03* 54 | D14* 55 | X56664860Y-34706560D03* 56 | X56664860Y-34206180D03* 57 | X56664860Y-33705800D03* 58 | X56664860Y-33205420D03* 59 | X56664860Y-32707580D03* 60 | X56664860Y-32207200D03* 61 | X56664860Y-31706820D03* 62 | X56664860Y-31206440D03* 63 | D13* 64 | X55915560Y-30457140D03* 65 | X55415180Y-30457140D03* 66 | X54914800Y-30457140D03* 67 | X54414420Y-30457140D03* 68 | D15* 69 | X54165500Y-32956500D03* 70 | D16* 71 | X54724400Y-28692400D03* 72 | X56324400Y-27492400D03* 73 | X54724400Y-27492400D03* 74 | X56324400Y-28692400D03* 75 | D17* 76 | X50749200Y-27127200D03* 77 | X48437800Y-27127200D03* 78 | D18* 79 | X57962800Y-36830000D03* 80 | D19* 81 | X49504600Y-36944300D03* 82 | X49504600Y-35039300D03* 83 | X46964600Y-36944300D03* 84 | X49504600Y-35991800D03* 85 | X46964600Y-35039300D03* 86 | D20* 87 | X50368200Y-33223200D03* 88 | D21* 89 | X53644800Y-28592780D03* 90 | X53644800Y-27693620D03* 91 | X57404000Y-28541980D03* 92 | X57404000Y-27642820D03* 93 | D22* 94 | X52585620Y-36677600D03* 95 | X53484780Y-36677600D03* 96 | D21* 97 | X52578000Y-27693620D03* 98 | X52578000Y-28592780D03* 99 | D22* 100 | X56393080Y-36830000D03* 101 | X55493920Y-36830000D03* 102 | D21* 103 | X58064400Y-33571180D03* 104 | X58064400Y-32672020D03* 105 | D22* 106 | X51655980Y-36677600D03* 107 | X50756820Y-36677600D03* 108 | D23* 109 | X48539400Y-31292800D03* 110 | X50063400Y-31292800D03* 111 | M02* 112 | -------------------------------------------------------------------------------- /hardware/usb_8285_tiny/usb_8285-revA/usb_8285_tiny.drl: -------------------------------------------------------------------------------- 1 | M48 2 | ;DRILL file {KiCad 4.0.3+e1-6302~38~ubuntu14.04.1-stable} date Wed Aug 31 10:58:06 2016 3 | ;FORMAT={-:-/ absolute / inch / decimal} 4 | FMAT,2 5 | INCH,TZ 6 | T1C0.014 7 | % 8 | G90 9 | G05 10 | M72 11 | T1 12 | X1.915Y-1.13 13 | X1.928Y-1.349 14 | X1.9325Y-1.0425 15 | X1.971Y-1.447 16 | X1.985Y-1.128 17 | X1.985Y-1.391 18 | X2.035Y-1.16 19 | X2.074Y-1.042 20 | X2.082Y-1.352 21 | X2.112Y-1.16 22 | X2.132Y-1.086 23 | X2.15Y-1.452 24 | X2.174Y-1.344 25 | X2.24Y-1.134 26 | X2.25Y-1.472 27 | X2.268Y-1.226 28 | X2.286Y-1.354 29 | X2.304Y-1.262 30 | T0 31 | M30 32 | -------------------------------------------------------------------------------- /hardware/usb_8285_tiny/usb_8285_tiny-cache.lib: -------------------------------------------------------------------------------- 1 | EESchema-LIBRARY Version 2.3 2 | #encoding utf-8 3 | # 4 | # +3.3V-RESCUE-usb_8285 5 | # 6 | DEF +3.3V-RESCUE-usb_8285 #PWR 0 0 Y Y 1 F P 7 | F0 "#PWR" 0 -40 30 H I C CNN 8 | F1 "+3.3V-RESCUE-usb_8285" 0 110 30 H V C CNN 9 | F2 "" 0 0 60 H V C CNN 10 | F3 "" 0 0 60 H V C CNN 11 | DRAW 12 | X +3.3V 1 0 0 0 U 30 30 0 0 W N 13 | C 0 60 20 0 1 0 N 14 | P 3 0 1 0 0 0 0 40 0 40 N 15 | ENDDRAW 16 | ENDDEF 17 | # 18 | # +5V 19 | # 20 | DEF +5V #PWR 0 0 Y Y 1 F P 21 | F0 "#PWR" 0 -150 50 H I C CNN 22 | F1 "+5V" 0 140 50 H V C CNN 23 | F2 "" 0 0 60 H V C CNN 24 | F3 "" 0 0 60 H V C CNN 25 | DRAW 26 | P 2 0 1 0 -30 50 0 100 N 27 | P 2 0 1 0 0 0 0 100 N 28 | P 2 0 1 0 0 100 30 50 N 29 | X +5V 1 0 0 0 U 50 50 1 1 W N 30 | ENDDRAW 31 | ENDDEF 32 | # 33 | # C-RESCUE-usb_8285 34 | # 35 | DEF C-RESCUE-usb_8285 C 0 10 N Y 1 F N 36 | F0 "C" 0 100 40 H V L CNN 37 | F1 "C-RESCUE-usb_8285" 6 -85 40 H V L CNN 38 | F2 "" 38 -150 30 H V C CNN 39 | F3 "" 0 0 60 H V C CNN 40 | $FPLIST 41 | SM* 42 | C? 43 | C1-1 44 | $ENDFPLIST 45 | DRAW 46 | P 2 0 1 20 -80 -30 80 -30 N 47 | P 2 0 1 20 -80 30 80 30 N 48 | X ~ 1 0 200 170 D 40 40 1 1 P 49 | X ~ 2 0 -200 170 U 40 40 1 1 P 50 | ENDDRAW 51 | ENDDEF 52 | # 53 | # CONN_1 54 | # 55 | DEF ~CONN_1 P 0 30 N N 1 F N 56 | F0 "P" 80 0 40 H V L CNN 57 | F1 "CONN_1" 0 55 30 H I C CNN 58 | F2 "" 0 0 60 H V C CNN 59 | F3 "" 0 0 60 H V C CNN 60 | DRAW 61 | C 0 0 31 0 1 0 N 62 | P 2 0 1 0 -30 0 -50 0 N 63 | X 1 1 -150 0 100 R 60 60 1 1 P 64 | ENDDRAW 65 | ENDDEF 66 | # 67 | # ESP8266EX 68 | # 69 | DEF ESP8266EX U 0 40 Y Y 1 F N 70 | F0 "U" -900 700 60 H V C CNN 71 | F1 "ESP8266EX" -850 600 60 H V C CNN 72 | F2 "" -900 700 60 H V C CNN 73 | F3 "" -900 700 60 H V C CNN 74 | DRAW 75 | S -850 500 700 -500 0 1 0 f 76 | X VddA 1 -1150 350 300 R 50 50 1 1 I 77 | X LNA/ANT 2 -1150 250 300 R 50 50 1 1 I 78 | X Vdd3P3 3 -1150 150 300 R 50 50 1 1 I 79 | X Vdd3P3 4 -1150 50 300 R 50 50 1 1 I 80 | X VddRCT 5 -1150 -50 300 R 50 50 1 1 I 81 | X TOUT 6 -1150 -150 300 R 50 50 1 1 I 82 | X CHIP_EN 7 -1150 -250 300 R 50 50 1 1 I 83 | X XPD_DCDC 8 -1150 -350 300 R 50 50 1 1 I 84 | X MTMS/GPIO14 9 -350 -800 300 U 50 50 1 1 I 85 | X MTDI/GPIO12 10 -250 -800 300 U 50 50 1 1 I 86 | X SD_CMD 20 1000 -50 300 L 50 50 1 1 I 87 | X VDDA 30 -150 800 300 D 50 50 1 1 I 88 | X VddPST 11 -150 -800 300 U 50 50 1 1 I 89 | X SD_CLK 21 1000 50 300 L 50 50 1 1 I 90 | X RES12K 31 -250 800 300 D 50 50 1 1 I 91 | X MTCK/GPIO13 12 -50 -800 300 U 50 50 1 1 I 92 | X SD_D0 22 1000 150 300 L 50 50 1 1 I 93 | X EXT_RSTB 32 -350 800 300 D 50 50 1 1 I 94 | X MTDO/GPIO15 13 50 -800 300 U 50 50 1 1 I 95 | X SD_D1 23 1000 250 300 L 50 50 1 1 I 96 | X GND 33 -450 800 300 D 50 50 1 1 I 97 | X GPIO2 14 150 -800 300 U 50 50 1 1 I 98 | X GP5/VD 24 1000 350 300 L 50 50 1 1 I 99 | X GPIO0 15 250 -800 300 U 50 50 1 1 I 100 | X URXD 25 350 800 300 D 50 50 1 1 I 101 | X GP4/VD 16 350 -800 300 U 50 50 1 1 I 102 | X UTXD 26 250 800 300 D 50 50 1 1 I 103 | X VddPST 17 1000 -350 300 L 50 50 1 1 I 104 | X XTAL_OUT 27 150 800 300 D 50 50 1 1 I 105 | X SD_D2 18 1000 -250 300 L 50 50 1 1 I 106 | X XTAL_IN 28 50 800 300 D 50 50 1 1 I 107 | X SD_D3 19 1000 -150 300 L 50 50 1 1 I 108 | X VDDD 29 -50 800 300 D 50 50 1 1 I 109 | ENDDRAW 110 | ENDDEF 111 | # 112 | # GND-RESCUE-usb_8285 113 | # 114 | DEF ~GND-RESCUE-usb_8285 #PWR 0 0 Y Y 1 F P 115 | F0 "#PWR" 0 0 30 H I C CNN 116 | F1 "GND-RESCUE-usb_8285" 0 -70 30 H I C CNN 117 | F2 "" 0 0 60 H V C CNN 118 | F3 "" 0 0 60 H V C CNN 119 | DRAW 120 | P 4 0 1 0 -50 0 0 -50 50 0 -50 0 N 121 | X GND 1 0 0 0 U 30 30 1 1 W N 122 | ENDDRAW 123 | ENDDEF 124 | # 125 | # MCP1824 126 | # 127 | DEF MCP1824 U 0 40 Y Y 1 F N 128 | F0 "U" -250 300 60 H V C CNN 129 | F1 "MCP1824" 100 -300 60 H V C CNN 130 | F2 "" 0 0 60 H I C CNN 131 | F3 "" 0 0 60 H I C CNN 132 | $FPLIST 133 | SOT23-5 134 | $ENDFPLIST 135 | DRAW 136 | S -300 200 300 -200 0 1 0 f 137 | X Vin 1 -600 100 300 R 50 50 1 1 I 138 | X GND 2 -600 0 300 R 50 50 1 1 I 139 | X ~SHDN 3 -600 -100 300 R 50 50 1 1 I 140 | X PWRGD 4 600 -100 300 L 50 50 1 1 O 141 | X OUT 5 600 100 300 L 50 50 1 1 O 142 | ENDDRAW 143 | ENDDEF 144 | # 145 | # R-RESCUE-usb_8285 146 | # 147 | DEF R-RESCUE-usb_8285 R 0 0 N Y 1 F N 148 | F0 "R" 80 0 40 V V C CNN 149 | F1 "R-RESCUE-usb_8285" 7 1 40 V V C CNN 150 | F2 "" -70 0 30 V V C CNN 151 | F3 "" 0 0 30 H V C CNN 152 | $FPLIST 153 | R? 154 | SM0603 155 | SM0805 156 | R?-* 157 | SM1206 158 | $ENDFPLIST 159 | DRAW 160 | S -40 150 40 -150 0 1 12 N 161 | X ~ 1 0 250 100 D 60 60 1 1 P 162 | X ~ 2 0 -250 100 U 60 60 1 1 P 163 | ENDDRAW 164 | ENDDEF 165 | # 166 | # XTAL4P 167 | # 168 | DEF XTAL4P X 0 40 N N 1 F N 169 | F0 "X" 0 150 60 H V C CNN 170 | F1 "XTAL4P" 0 -150 60 H V C CNN 171 | F2 "" 0 0 60 H I C CNN 172 | F3 "" 0 0 60 H I C CNN 173 | DRAW 174 | P 2 0 1 16 -100 100 -100 -100 N 175 | P 2 0 1 16 100 100 100 -100 N 176 | P 5 0 1 12 -50 50 50 50 50 -50 -50 -50 -50 50 f 177 | X 1 1 -300 0 200 R 40 40 1 1 P 178 | X 2 2 300 0 200 L 40 40 1 1 P 179 | X GND 3 -50 -300 300 U 50 50 1 1 P 180 | X GND 4 50 -300 300 U 50 50 1 1 P 181 | ENDDRAW 182 | ENDDEF 183 | # 184 | #End Library 185 | -------------------------------------------------------------------------------- /hardware/usb_8285_tiny/usb_8285_tiny.net: -------------------------------------------------------------------------------- 1 | (export (version D) 2 | (design 3 | (source /home/cnlohr/git/espusb/hardware/usb_8285_tiny/usb_8285_tiny.sch) 4 | (date "Wed 31 Aug 2016 12:08:30 AM EDT") 5 | (tool "Eeschema 4.0.3+e1-6302~38~ubuntu14.04.1-stable") 6 | (sheet (number 1) (name /) (tstamps /) 7 | (title_block 8 | (title noname.sch) 9 | (company) 10 | (rev -) 11 | (date "15 aug 2016") 12 | (source usb_8285_tiny.sch) 13 | (comment (number 1) (value "")) 14 | (comment (number 2) (value "")) 15 | (comment (number 3) (value "")) 16 | (comment (number 4) (value ""))))) 17 | (components 18 | (comp (ref U1) 19 | (value 8285) 20 | (footprint QFN32) 21 | (libsource (lib esp8266ex) (part ESP8266EX)) 22 | (sheetpath (names /) (tstamps /)) 23 | (tstamp 57A25A2C)) 24 | (comp (ref R1) 25 | (value 12k) 26 | (footprint SM0402) 27 | (libsource (lib usb_8285_tiny-cache) (part R-RESCUE-usb_8285)) 28 | (sheetpath (names /) (tstamps /)) 29 | (tstamp 57A25A68)) 30 | (comp (ref M3) 31 | (value 5.6p) 32 | (footprint SM0603) 33 | (libsource (lib usb_8285_tiny-cache) (part C-RESCUE-usb_8285)) 34 | (sheetpath (names /) (tstamps /)) 35 | (tstamp 57A25A83)) 36 | (comp (ref X1) 37 | (value 26M) 38 | (footprint XTAL4TINY) 39 | (libsource (lib crystal-4p) (part XTAL4P)) 40 | (sheetpath (names /) (tstamps /)) 41 | (tstamp 57A25AC8)) 42 | (comp (ref M1) 43 | (value 5.6p) 44 | (footprint SM0402) 45 | (libsource (lib usb_8285_tiny-cache) (part C-RESCUE-usb_8285)) 46 | (sheetpath (names /) (tstamps /)) 47 | (tstamp 57A25B1A)) 48 | (comp (ref M2) 49 | (value 5.6p) 50 | (footprint SM0402) 51 | (libsource (lib usb_8285_tiny-cache) (part C-RESCUE-usb_8285)) 52 | (sheetpath (names /) (tstamps /)) 53 | (tstamp 57A25B20)) 54 | (comp (ref C4) 55 | (value 10u) 56 | (footprint SM0603) 57 | (libsource (lib usb_8285_tiny-cache) (part C-RESCUE-usb_8285)) 58 | (sheetpath (names /) (tstamps /)) 59 | (tstamp 57A25EB1)) 60 | (comp (ref C5) 61 | (value .1u) 62 | (footprint SM0402) 63 | (libsource (lib usb_8285_tiny-cache) (part C-RESCUE-usb_8285)) 64 | (sheetpath (names /) (tstamps /)) 65 | (tstamp 57A25EB7)) 66 | (comp (ref P3) 67 | (value D+) 68 | (footprint .1SMTPIN) 69 | (libsource (lib 5050RGB) (part CONN_1)) 70 | (sheetpath (names /) (tstamps /)) 71 | (tstamp 57A262F1)) 72 | (comp (ref P8) 73 | (value D-) 74 | (footprint .1SMTPIN) 75 | (libsource (lib 5050RGB) (part CONN_1)) 76 | (sheetpath (names /) (tstamps /)) 77 | (tstamp 57A262FE)) 78 | (comp (ref P4) 79 | (value +5V) 80 | (footprint .1SMTPIN) 81 | (libsource (lib 5050RGB) (part CONN_1)) 82 | (sheetpath (names /) (tstamps /)) 83 | (tstamp 57A26363)) 84 | (comp (ref P6) 85 | (value GND) 86 | (footprint .1SMTPIN) 87 | (libsource (lib 5050RGB) (part CONN_1)) 88 | (sheetpath (names /) (tstamps /)) 89 | (tstamp 57A2636F)) 90 | (comp (ref P1) 91 | (value UTX) 92 | (footprint .1SMTPIN) 93 | (libsource (lib 5050RGB) (part CONN_1)) 94 | (sheetpath (names /) (tstamps /)) 95 | (tstamp 57A263B8)) 96 | (comp (ref P2) 97 | (value URX) 98 | (footprint .1SMTPIN) 99 | (libsource (lib 5050RGB) (part CONN_1)) 100 | (sheetpath (names /) (tstamps /)) 101 | (tstamp 57A263D1)) 102 | (comp (ref P9) 103 | (value G0) 104 | (footprint .1SMTPIN) 105 | (libsource (lib 5050RGB) (part CONN_1)) 106 | (sheetpath (names /) (tstamps /)) 107 | (tstamp 57A263E3)) 108 | (comp (ref R2) 109 | (value 12k) 110 | (footprint SM0402) 111 | (libsource (lib usb_8285_tiny-cache) (part R-RESCUE-usb_8285)) 112 | (sheetpath (names /) (tstamps /)) 113 | (tstamp 57A26418)) 114 | (comp (ref P5) 115 | (value +5V) 116 | (footprint .1SMTPIN) 117 | (libsource (lib 5050RGB) (part CONN_1)) 118 | (sheetpath (names /) (tstamps /)) 119 | (tstamp 57A26476)) 120 | (comp (ref P7) 121 | (value GND) 122 | (footprint .1SMTPIN) 123 | (libsource (lib 5050RGB) (part CONN_1)) 124 | (sheetpath (names /) (tstamps /)) 125 | (tstamp 57A2647C)) 126 | (comp (ref U2) 127 | (value 1824) 128 | (footprint SOT23-5) 129 | (libsource (lib mcp1824_ct) (part MCP1824)) 130 | (sheetpath (names /) (tstamps /)) 131 | (tstamp 57A264E5)) 132 | (comp (ref C6) 133 | (value 1u) 134 | (footprint SM0402) 135 | (libsource (lib usb_8285_tiny-cache) (part C-RESCUE-usb_8285)) 136 | (sheetpath (names /) (tstamps /)) 137 | (tstamp 57A26510)) 138 | (comp (ref A1) 139 | (value ANT) 140 | (footprint SM1206) 141 | (fields 142 | (field (name Digikey) 1292-1035-1-ND) 143 | (field (name Cost10) .521)) 144 | (libsource (lib usb_8285_tiny-cache) (part R-RESCUE-usb_8285)) 145 | (sheetpath (names /) (tstamps /)) 146 | (tstamp 57A8E837)) 147 | (comp (ref R5) 148 | (value 1.5k) 149 | (footprint SM0402) 150 | (libsource (lib usb_8285_tiny-cache) (part R-RESCUE-usb_8285)) 151 | (sheetpath (names /) (tstamps /)) 152 | (tstamp 57A8F67C)) 153 | (comp (ref P10) 154 | (value ADC) 155 | (footprint .1SMTPIN) 156 | (libsource (lib 5050RGB) (part CONN_1)) 157 | (sheetpath (names /) (tstamps /)) 158 | (tstamp 57B2119E))) 159 | (libparts 160 | (libpart (lib usb_8285_tiny-cache) (part C-RESCUE-usb_8285) 161 | (footprints 162 | (fp SM*) 163 | (fp C?) 164 | (fp C1-1)) 165 | (fields 166 | (field (name Reference) C) 167 | (field (name Value) C-RESCUE-usb_8285)) 168 | (pins 169 | (pin (num 1) (name ~) (type passive)) 170 | (pin (num 2) (name ~) (type passive)))) 171 | (libpart (lib 5050RGB) (part CONN_1) 172 | (fields 173 | (field (name Reference) P) 174 | (field (name Value) CONN_1)) 175 | (pins 176 | (pin (num 1) (name 1) (type passive)))) 177 | (libpart (lib esp8266ex) (part ESP8266EX) 178 | (fields 179 | (field (name Reference) U) 180 | (field (name Value) ESP8266EX)) 181 | (pins 182 | (pin (num 1) (name VddA) (type input)) 183 | (pin (num 2) (name LNA/ANT) (type input)) 184 | (pin (num 3) (name Vdd3P3) (type input)) 185 | (pin (num 4) (name Vdd3P3) (type input)) 186 | (pin (num 5) (name VddRCT) (type input)) 187 | (pin (num 6) (name TOUT) (type input)) 188 | (pin (num 7) (name CHIP_EN) (type input)) 189 | (pin (num 8) (name XPD_DCDC) (type input)) 190 | (pin (num 9) (name MTMS/GPIO14) (type input)) 191 | (pin (num 10) (name MTDI/GPIO12) (type input)) 192 | (pin (num 11) (name VddPST) (type input)) 193 | (pin (num 12) (name MTCK/GPIO13) (type input)) 194 | (pin (num 13) (name MTDO/GPIO15) (type input)) 195 | (pin (num 14) (name GPIO2) (type input)) 196 | (pin (num 15) (name GPIO0) (type input)) 197 | (pin (num 16) (name GP4/VD) (type input)) 198 | (pin (num 17) (name VddPST) (type input)) 199 | (pin (num 18) (name SD_D2) (type input)) 200 | (pin (num 19) (name SD_D3) (type input)) 201 | (pin (num 20) (name SD_CMD) (type input)) 202 | (pin (num 21) (name SD_CLK) (type input)) 203 | (pin (num 22) (name SD_D0) (type input)) 204 | (pin (num 23) (name SD_D1) (type input)) 205 | (pin (num 24) (name GP5/VD) (type input)) 206 | (pin (num 25) (name URXD) (type input)) 207 | (pin (num 26) (name UTXD) (type input)) 208 | (pin (num 27) (name XTAL_OUT) (type input)) 209 | (pin (num 28) (name XTAL_IN) (type input)) 210 | (pin (num 29) (name VDDD) (type input)) 211 | (pin (num 30) (name VDDA) (type input)) 212 | (pin (num 31) (name RES12K) (type input)) 213 | (pin (num 32) (name EXT_RSTB) (type input)) 214 | (pin (num 33) (name GND) (type input)))) 215 | (libpart (lib mcp1824_ct) (part MCP1824) 216 | (footprints 217 | (fp SOT23-5)) 218 | (fields 219 | (field (name Reference) U) 220 | (field (name Value) MCP1824)) 221 | (pins 222 | (pin (num 1) (name Vin) (type input)) 223 | (pin (num 2) (name GND) (type input)) 224 | (pin (num 3) (name ~SHDN) (type input)) 225 | (pin (num 4) (name PWRGD) (type output)) 226 | (pin (num 5) (name OUT) (type output)))) 227 | (libpart (lib usb_8285_tiny-cache) (part R-RESCUE-usb_8285) 228 | (footprints 229 | (fp R?) 230 | (fp SM0603) 231 | (fp SM0805) 232 | (fp R?-*) 233 | (fp SM1206)) 234 | (fields 235 | (field (name Reference) R) 236 | (field (name Value) R-RESCUE-usb_8285)) 237 | (pins 238 | (pin (num 1) (name ~) (type passive)) 239 | (pin (num 2) (name ~) (type passive)))) 240 | (libpart (lib crystal-4p) (part XTAL4P) 241 | (fields 242 | (field (name Reference) X) 243 | (field (name Value) XTAL4P)) 244 | (pins 245 | (pin (num 1) (name 1) (type passive)) 246 | (pin (num 2) (name 2) (type passive)) 247 | (pin (num 3) (name GND) (type passive)) 248 | (pin (num 4) (name GND) (type passive))))) 249 | (libraries 250 | (library (logical 5050RGB) 251 | (uri /home/cnlohr/electrical/kicad/5050RGB.lib)) 252 | (library (logical usb_8285_tiny-cache) 253 | (uri /home/cnlohr/git/espusb/hardware/usb_8285_tiny/usb_8285_tiny-cache.lib)) 254 | (library (logical mcp1824_ct) 255 | (uri /home/cnlohr/electrical/kicad/mcp1824_ct.lib)) 256 | (library (logical esp8266ex) 257 | (uri /home/cnlohr/electrical/kicad/esp8266ex.lib)) 258 | (library (logical crystal-4p) 259 | (uri /home/cnlohr/electrical/kicad/crystal-4p.lib))) 260 | (nets 261 | (net (code 1) (name +5V) 262 | (node (ref U2) (pin 3)) 263 | (node (ref U2) (pin 1)) 264 | (node (ref C6) (pin 2)) 265 | (node (ref P4) (pin 1)) 266 | (node (ref P5) (pin 1))) 267 | (net (code 2) (name +3.3V) 268 | (node (ref U1) (pin 17)) 269 | (node (ref U1) (pin 7)) 270 | (node (ref R5) (pin 2)) 271 | (node (ref U1) (pin 4)) 272 | (node (ref U1) (pin 3)) 273 | (node (ref U1) (pin 30)) 274 | (node (ref R2) (pin 1)) 275 | (node (ref U1) (pin 29)) 276 | (node (ref U1) (pin 1)) 277 | (node (ref U1) (pin 32)) 278 | (node (ref C4) (pin 2)) 279 | (node (ref U1) (pin 11)) 280 | (node (ref C5) (pin 2)) 281 | (node (ref U2) (pin 5))) 282 | (net (code 3) (name "Net-(P9-Pad1)") 283 | (node (ref U1) (pin 15)) 284 | (node (ref R2) (pin 2)) 285 | (node (ref P9) (pin 1))) 286 | (net (code 4) (name GND) 287 | (node (ref M2) (pin 1)) 288 | (node (ref M1) (pin 2)) 289 | (node (ref X1) (pin 4)) 290 | (node (ref X1) (pin 3)) 291 | (node (ref R1) (pin 1)) 292 | (node (ref U1) (pin 9)) 293 | (node (ref U1) (pin 10)) 294 | (node (ref U1) (pin 13)) 295 | (node (ref U1) (pin 33)) 296 | (node (ref P6) (pin 1)) 297 | (node (ref C5) (pin 1)) 298 | (node (ref C6) (pin 1)) 299 | (node (ref C4) (pin 1)) 300 | (node (ref P7) (pin 1)) 301 | (node (ref U2) (pin 2))) 302 | (net (code 5) (name "Net-(P10-Pad1)") 303 | (node (ref U1) (pin 6)) 304 | (node (ref P10) (pin 1))) 305 | (net (code 6) (name "Net-(A1-Pad1)") 306 | (node (ref A1) (pin 1)) 307 | (node (ref M3) (pin 1))) 308 | (net (code 7) (name "Net-(A1-Pad2)") 309 | (node (ref A1) (pin 2))) 310 | (net (code 8) (name /D-) 311 | (node (ref P8) (pin 1)) 312 | (node (ref R5) (pin 1)) 313 | (node (ref U1) (pin 16))) 314 | (net (code 9) (name /D+) 315 | (node (ref P3) (pin 1)) 316 | (node (ref U1) (pin 24))) 317 | (net (code 10) (name /RX) 318 | (node (ref U1) (pin 25)) 319 | (node (ref P2) (pin 1))) 320 | (net (code 11) (name /TX) 321 | (node (ref P1) (pin 1)) 322 | (node (ref U1) (pin 26))) 323 | (net (code 12) (name "Net-(U2-Pad4)") 324 | (node (ref U2) (pin 4))) 325 | (net (code 13) (name "Net-(U1-Pad18)") 326 | (node (ref U1) (pin 18))) 327 | (net (code 14) (name "Net-(U1-Pad19)") 328 | (node (ref U1) (pin 19))) 329 | (net (code 15) (name "Net-(U1-Pad14)") 330 | (node (ref U1) (pin 14))) 331 | (net (code 16) (name "Net-(R1-Pad2)") 332 | (node (ref R1) (pin 2)) 333 | (node (ref U1) (pin 31))) 334 | (net (code 17) (name "Net-(U1-Pad5)") 335 | (node (ref U1) (pin 5))) 336 | (net (code 18) (name "Net-(U1-Pad8)") 337 | (node (ref U1) (pin 8))) 338 | (net (code 19) (name "Net-(U1-Pad20)") 339 | (node (ref U1) (pin 20))) 340 | (net (code 20) (name "Net-(U1-Pad21)") 341 | (node (ref U1) (pin 21))) 342 | (net (code 21) (name "Net-(U1-Pad12)") 343 | (node (ref U1) (pin 12))) 344 | (net (code 22) (name "Net-(U1-Pad22)") 345 | (node (ref U1) (pin 22))) 346 | (net (code 23) (name "Net-(U1-Pad23)") 347 | (node (ref U1) (pin 23))) 348 | (net (code 24) (name "Net-(M1-Pad1)") 349 | (node (ref X1) (pin 1)) 350 | (node (ref U1) (pin 28)) 351 | (node (ref M1) (pin 1))) 352 | (net (code 25) (name "Net-(M2-Pad2)") 353 | (node (ref U1) (pin 27)) 354 | (node (ref X1) (pin 2)) 355 | (node (ref M2) (pin 2))) 356 | (net (code 26) (name "Net-(M3-Pad2)") 357 | (node (ref U1) (pin 2)) 358 | (node (ref M3) (pin 2))))) -------------------------------------------------------------------------------- /schematic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/me-no-dev/espusb/e8650363233c4eeff3903f00222ea718ba8b819d/schematic.png -------------------------------------------------------------------------------- /table/Makefile: -------------------------------------------------------------------------------- 1 | all : table 2 | 3 | table : table.c 4 | gcc -o $@ $^ 5 | ./table 6 | 7 | clean : 8 | rm -rf *.o *~ table 9 | -------------------------------------------------------------------------------- /table/crc16.pl: -------------------------------------------------------------------------------- 1 | #! /usr/bin/perl 2 | ## usage: 3 | ## crc16 nrzstream 4 | ## nrz stream is sent in left to right order 5 | ## generated crc should also be sent out in left to right order 6 | sub xor16 { 7 | local(@x) = @_[0..15]; 8 | local(@y) = @_[16..31]; 9 | local(@results16) = (); 10 | for($j=0;$j<16;$j++) 11 | { 12 | if (shift(@x) eq shift(@y)) { push(@results16, '0'); } 13 | else { push(@results16, '1'); } 14 | } 15 | return(@results16[0..15]); 16 | } 17 | { 18 | local($st_data) = $ARGV[0]; 19 | local(@G) = 20 | ('1','0','0','0','0','0','0','0','0','0','0','0','0','1','0','1'); 21 | local(@hold) = 22 | ('1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1'); 23 | local(@data) = split (//,$st_data); 24 | if (scalar(@data) > 0) 25 | { 26 | loop16: while (scalar(@data) > 0) 27 | { 28 | $nextb=shift(@data); 29 | if (($nextb ne "0") && ($nextb ne "1")) {next loop16} ## comment character 30 | if ($nextb eq shift(@hold)) {push(@hold, '0')} 31 | else 32 | { push(@hold, '0'); @hold = &xor16(@hold,@G); } 33 | } 34 | } 35 | # print (@hold); print "\n"; 36 | ## invert shift reg to generate CRC field 37 | for ($i=0;$i<=$#hold;$i++) {if (@hold[$i] eq "1") {print("0")} else { 38 | print("1")} } 39 | print "\n"; 40 | } 41 | -------------------------------------------------------------------------------- /table/crc5.pl: -------------------------------------------------------------------------------- 1 | #! /usr/bin/perl 2 | ## crc5 nrzstream 3 | ## e.g. crc5 1000111 4 | ## nrz stream is sent in left to right order 5 | ## generated crc should also be sent out in left to right order 6 | sub xor5 { 7 | local(@x) = @_[0..4]; 8 | local(@y) = @_[5..9]; 9 | local(@results5) = (); 10 | for($j=0;$j<5;$j++) 11 | { 12 | if (shift(@x) eq shift(@y)) { push(@results5, '0'); } 13 | else { push(@results5, '1'); } 14 | } 15 | return(@results5[0..4]); 16 | } 17 | { 18 | local($st_data) = $ARGV[0]; 19 | local(@G) = ('0','0','1','0','1'); 20 | local(@data) = split (//,$st_data); 21 | local(@hold) = ('1','1','1','1','1'); 22 | if (scalar(@data) > 0) 23 | { 24 | loop5: while (scalar(@data) > 0) 25 | { 26 | 27 | $nextb=shift(@data); 28 | if (($nextb ne "0") && ($nextb ne "1")) {next loop5} ## comment 29 | if ($nextb eq shift(@hold)) {push(@hold, '0')} 30 | else 31 | { push(@hold, '0'); @hold = &xor5(@hold,@G); } 32 | ## print (@hold); print "\n"; 33 | } 34 | } 35 | ## print (@hold); print "\n"; 36 | ## invert shift reg contents to generate crc field 37 | for ($i=0;$i<=$#hold;$i++) {if (@hold[$i] eq "1") {print("0")} else { 38 | print("1")} } 39 | print "\n"; 40 | } 41 | -------------------------------------------------------------------------------- /table/table.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | //NOTES: I have a hunch a table is best for this, though, we might have plenty of free time 5 | //If that's the case, this should just be a test of the bit logic. 6 | 7 | //#define DPLUSFIRST 8 | //if so, 1's place = D+ bit 9 | // 2's place = D- bit 10 | 11 | 12 | //Example from wikipedia 13 | //uint8_t input_stream[] = { 1, 1, 2, 2, 2, 1, 1, 2, 0, 0, 1 }; 14 | //uint8_t input_stream[] = { 1, 1, 2, 2, 2, 2, 2, 2, 2, 1, 1, 2, 0, 0, 1 }; 15 | //uint8_t input_stream[] = { 1, 2, 1, 2, 1, 2, 1, 1, 1, 2, 2, 2, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 0, 0, }; 16 | 17 | //"Setup" 18 | //uint8_t input_stream[] = { 1, 2, 1, 2, 1, 2, 1, 2, 2, 2, 1, 1, 1, 2, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 2, 1, 2, 1, 0, 0, }; 19 | 20 | //"Data" after "setup" 21 | #if 0 22 | uint8_t input_stream[] = { 1, 2, 1, 2, 1, 2, 1, 2, 2, 2, 2, 1, 2, 1, 2, 2, 2, 1, 2, 1, 2, 1, 2, 1, 1, 2, 2, 2, 1 ,2, 1, 2, 23 | 1, 2, 1, 2, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 2, 1, 2, 24 | 1, 2, 1, 2, 1, 2, 1, 1, 2, 2, 2, 2, 1, 1, 1, 2, 1, 1, 2, 2, 1, 2, 2, 0, 0,}; 25 | #endif 26 | 27 | //"In" 28 | #if 0 29 | uint8_t input_stream[] = { 30 | 1, 2, 1, 2, 1, 2, 1, 2, 2, 2, 1, 2, 2, 1, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1,2, 1, 2, 1, 2, 1, 2, 1, 2, 2, 1, 2, 1, 0, 0 }; 31 | #endif 32 | 33 | //Us trying to send a byte 34 | uint8_t input_stream[] = { 1, 2, 1, 2, 1, 2, 2, 2, 2, 1, 1, 2, 35 | 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 36 | 2, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1 ,0,0 }; 37 | 38 | //Table bits: 39 | // LSB: D+ 40 | // D- 41 | // last_state 42 | // ones_count[0] 43 | // ones_count[1] 44 | // ones_count[2] 45 | 46 | 47 | //Return value: 48 | // 0th bit: value (1 if end of packet, 0 if bad) 49 | // 1st bit: emit bit? 50 | // 51 | // 7th bit: exit 52 | 53 | 54 | uint8_t state; 55 | 56 | #define TABLESIZE 64 57 | uint8_t table[TABLESIZE]; 58 | 59 | void Init() 60 | { 61 | int c = 0; 62 | for( c = 0; c < TABLESIZE; c++ ) 63 | { 64 | #ifdef DPLUSFIRST 65 | int dp = (c&1)?1:0; 66 | int dm = (c&2)?1:0; 67 | #else 68 | int dp = (c&2)?1:0; 69 | int dm = (c&1)?1:0; 70 | #endif 71 | int last_state = (c&4)?1:0; 72 | int ones_count = c>>3; 73 | 74 | int value = 0; 75 | int emit = 0; 76 | int err = 0; 77 | int exval = 0; 78 | 79 | //Found preamble. 80 | if( dm == 0 && dp == 0 ) 81 | { 82 | emit = 0; 83 | value = (ones_count != 7)?1:0; //End-of-packet. (unless we are in the preamble)ss 84 | exval = 1; 85 | last_state = 0; 86 | ones_count = 0; 87 | } 88 | else if( dm == 1 && dp == 1 ) 89 | { 90 | emit = 0; 91 | value = 0; 92 | exval = 1; 93 | last_state = 0; 94 | ones_count = 0; 95 | } 96 | //Finding preamble. 97 | else if( ones_count == 7 ) 98 | { 99 | if( last_state == dp ) 100 | { 101 | //End of preamble. 102 | if( dp == 1 ) 103 | { 104 | //Good 105 | ones_count = 0; 106 | } 107 | else 108 | { 109 | exval = 1; 110 | //Bad 111 | } 112 | } 113 | last_state = dp; 114 | } 115 | else if( dp != last_state ) //State transition (would emit 0) 116 | { 117 | if( ones_count == 6 ) //This is a bit stuffed 118 | { 119 | ones_count = 0; 120 | emit = 0; 121 | value = 0; 122 | } 123 | else 124 | { 125 | ones_count = 0; 126 | emit = 1; 127 | value = 0; 128 | } 129 | last_state = dp; 130 | } 131 | else if( dp == last_state ) 132 | { 133 | if( ones_count == 6 ) //This is an error case. 134 | { 135 | ones_count = 0; 136 | exval = 1; 137 | } 138 | else 139 | { 140 | emit = 1; 141 | value = 1; 142 | ones_count++; 143 | } 144 | last_state = dp; 145 | } 146 | else 147 | { 148 | fprintf( stderr, "Fault. This is an unexpected case.\n" ); 149 | } 150 | 151 | table[c] = value | (emit<<1) | (last_state<<2) | (ones_count<<3) | (exval<<7); 152 | } 153 | } 154 | 155 | int RunState( int i ) 156 | { 157 | return table[i]; 158 | } 159 | 160 | int main() 161 | { 162 | int i; 163 | Init(); 164 | 165 | uint8_t c = 0x38;// | 0x4; //7 Count, was 1. 166 | 167 | uint8_t outbuff[32]; 168 | int outplace = 0; 169 | int outbitplace = 0; 170 | uint8_t outbyte = 0; 171 | 172 | uint32_t crc16=0xffff;//0xffff; 173 | //#define POLY 0x8005 174 | #define POLY 0xA001 175 | #define CHECKGOOD 0xB001 176 | //#define POLY 0xC002 177 | 178 | #define CHECK5GOOD 0x06 179 | #define CRC5POLY 0x14 180 | uint16_t crc5=0x1f; 181 | 182 | 183 | for( i = 0; i < sizeof( input_stream ); i++ ) 184 | { 185 | #ifdef DPLUSFIRST 186 | c |= input_stream[i]; 187 | #else 188 | int bit1 = (input_stream[i]&2)?1:0; 189 | int bit2 = (input_stream[i]&1)?2:0; 190 | c |= bit1|bit2; 191 | #endif 192 | printf( "C IN: (%d) %02x / ", input_stream[i], c ); 193 | c = RunState( c ); 194 | printf( "%02x - ", c ); 195 | if( c & 2 ) { 196 | if( c&1 ) 197 | outbyte |= 1<>=1; 241 | } 242 | printf( "%08x\n", crc16 ); 243 | } 244 | #else 245 | //Another way to calculate CRC 246 | 247 | //01001000 10000000 11001100 11110100 248 | outbuff[1] = 0b00010010; 249 | outbuff[2] = 0b10000000; 250 | outbuff[3] = 0b11001100; 251 | outbuff[4] = 0b11110100; 252 | outplace = 5; 253 | 254 | for( i = 1; i < outplace; i++ ) 255 | { 256 | int byte = outbuff[i]; 257 | 258 | //crc16^=byte; 259 | 260 | int k; 261 | for( k = 0; k < 8; k++ ) 262 | { 263 | if( (crc16 ^ (byte>>k)) & 0x01 ) 264 | { 265 | crc16>>=1; 266 | crc16^=POLY; 267 | } 268 | else 269 | { 270 | crc16>>=1; 271 | } 272 | } 273 | printf( "%08x\n", crc16 ); 274 | } 275 | #endif 276 | 277 | FILE * f = fopen( "../user/usb_table_1bit.h", "w" ); 278 | fprintf( f, "#define NEED_CONSTANTS\n\n" ); 279 | fprintf( f, "#include \"usb.h\"\n\n" ); 280 | 281 | fprintf( f, "#define TABLE_OFFSET 36\n\n" ); 282 | 283 | fprintf( f, "#define GPIO_BASE_OFFSET 0\n" ); 284 | fprintf( f, "#define LOOP_COUNT_OFFSET 8\n" ); 285 | fprintf( f, "#define ANDING_MASK_OFFSET 12\n" ); 286 | fprintf( f, "#define RUNNING_TIMEOUT_OFFSET 16\n" ); 287 | fprintf( f, "#define USB_INTERNAL_STATE_OFFSET 20\n" ); 288 | fprintf( f, "#define CRC16_INIT_OFFSET 24\n" ); 289 | fprintf( f, "#define CRC16_POLY_OFFSET 28\n" ); 290 | fprintf( f, "#define CRC16_CHECK_OFFSET 32\n" ); 291 | fprintf( f, "#define CRC5_INITIAL 0x1f\n" ); 292 | fprintf( f, "#define CRC5_POLY 0x14\n" ); 293 | fprintf( f, "#define CRC5_CHECK 0x06\n" ); 294 | 295 | fprintf( f, "#ifndef _INASM_\n\n" ); 296 | fprintf( f, "uint32_t usb_ramtable[%d] __attribute__((aligned(16))) = {\n", (60 + TABLESIZE)/4 ); 297 | fprintf( f, "\tGPIO_BASE_REG, // Base reg for all GPIO (Offset 0)\n" ); 298 | fprintf( f, "\t0, // Reserved (For debug) (Offset 1)\n" ); 299 | fprintf( f, "\t100, // Loop Count (Offset 2)\n" ); 300 | fprintf( f, "\t0x3c, // Anding mask for table (Offset 3)\n" ); 301 | fprintf( f, "\t136, //Timeout (in bits) (Offset 4)\n" ); 302 | fprintf( f, "\t(uint32_t)&usb_internal_state, //State (Offset 5)\n" ); 303 | fprintf( f, "\t0xffff, //Initial value for CRC (Offset 6)\n"); 304 | fprintf( f, "\t0xA001, //CRC Poly (Offset 7)\n"); 305 | fprintf( f, "\t0xB001, //CRC Check (Offset 8)\n"); 306 | 307 | for( i = 0; i < TABLESIZE/4; i++ ) 308 | { 309 | uint32_t outval = table[i*4] | (table[i*4+1]<<8) | (table[i*4+2]<<16) | (table[i*4+3]<<24); 310 | if( i % 4 == 0 ) fprintf( f, "\n\t" ); 311 | fprintf( f, "0x%08x, ", outval ); 312 | } 313 | fprintf( f, "};\n" ); 314 | fprintf( f, "#endif\n" ); 315 | fclose( f ); 316 | 317 | } 318 | 319 | -------------------------------------------------------------------------------- /top/Makefile: -------------------------------------------------------------------------------- 1 | all : controltest 2 | 3 | controltest : controltest.o 4 | gcc -o $@ $^ -lusb-1.0 5 | 6 | clean : 7 | rm -rf *.o *~ controltest 8 | -------------------------------------------------------------------------------- /top/controltest.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | struct libusb_device_handle *devh = NULL; 10 | 11 | int doexit = 0; 12 | 13 | void sigexit( int sig ) 14 | { 15 | doexit = 1; 16 | } 17 | 18 | //#define DOTTER 19 | #define DATASIZE 32 20 | 21 | int main() 22 | { 23 | int frame = 0, i, r; 24 | 25 | if( libusb_init(NULL) < 0 ) 26 | { 27 | fprintf( stderr, "Error: Could not initialize libUSB\n" ); 28 | return -1; 29 | } 30 | 31 | devh = libusb_open_device_with_vid_pid( NULL, 0xabcd, 0x8266 ); 32 | 33 | if( !devh ) 34 | { 35 | fprintf( stderr, "Error: Cannot find device.\n" ); 36 | return -1; 37 | } 38 | 39 | libusb_detach_kernel_driver( devh, 0 ); 40 | 41 | if( (r=libusb_claim_interface(devh, 0)) < 0 ) 42 | { 43 | fprintf(stderr, "usb_claim_interface error %d\n", r); 44 | return -1; 45 | } 46 | 47 | printf( "Interface ok!\n" ); 48 | 49 | signal( SIGINT, sigexit ); 50 | signal( SIGTERM, sigexit ); 51 | signal( SIGQUIT, sigexit ); 52 | 53 | while( !doexit ) 54 | { 55 | unsigned char rbuffer[DATASIZE]; 56 | 57 | // if( libusb_handle_events(NULL) < 0 ) 58 | // { 59 | // doexit = 1; 60 | // } 61 | // 62 | 63 | //int LIBUSB_CALL libusb_control_transfer(libusb_device_handle *dev_handle, 64 | // uint8_t request_type, uint8_t bRequest, uint16_t wValue, uint16_t wIndex, 65 | // unsigned char *data, uint16_t wLength, unsigned int timeout); 66 | 67 | #ifdef NUMERINGTEST 68 | memset( rbuffer, 0, DATASIZE ); 69 | for( i = 0; i < DATASIZE; i++ ) 70 | { 71 | rbuffer[i] = i + frame; 72 | } 73 | int outsize = DATASIZE; 74 | #else 75 | sprintf( rbuffer, "EHe%04x", frame ); 76 | int outsize = strlen( rbuffer ); 77 | #endif 78 | 79 | 80 | int r1 = libusb_control_transfer( devh, 81 | 0x00, //reqtype (0x80 = Device->PC, 0x00 = PC->Device) 82 | 0xA6, //request 83 | 0x0100, //wValue 84 | 0x0000, //wIndex 85 | rbuffer, 86 | outsize, //wLength (more like max length) 87 | 1000 ); 88 | 89 | 90 | usleep( 1000 ); 91 | 92 | int r2 = libusb_control_transfer( devh, 93 | 0x80, //reqtype (0x80 = in, 0x00 = out) 94 | 0xA7, //request 95 | 0x0100, //wValue 96 | 0x0000, //wIndex 97 | rbuffer, //wLength (more like max length) 98 | DATASIZE, 99 | 1000 ); 100 | 101 | if( r2 > 0 ) { frame++; } 102 | 103 | if( r1 < -1 && r2 < -1 ) 104 | { 105 | break; 106 | } 107 | #ifdef DOTTER 108 | if( r2 >= 0 ) 109 | { 110 | printf( "." ); 111 | fflush( stdout ); 112 | } 113 | else 114 | { 115 | fprintf( stderr, "Error: %d\n", r ); 116 | } 117 | 118 | #else 119 | 120 | printf( "%d %d ", r1, r2 ); 121 | for( i = 0; i < r2; i++ ) 122 | printf( " %02x ", rbuffer[i] ); 123 | printf( "\n" ); 124 | 125 | #endif 126 | 127 | 128 | usleep(1000); 129 | } 130 | 131 | libusb_release_interface( devh, 0 ); 132 | libusb_attach_kernel_driver( devh, 0 ); 133 | libusb_close( devh ); 134 | libusb_exit( NULL ); 135 | printf( "Exit ok.\n" ); 136 | return -1; 137 | 138 | } 139 | 140 | -------------------------------------------------------------------------------- /usb_notes.txt: -------------------------------------------------------------------------------- 1 | 2 | //ESP8266 instruction timing guide: 3 | // 4 | // nop : 1 5 | // add, addi, or, extui : 2 (Sort of) 6 | // movi: 1 7 | // l32r: 7 (Sort of) 8 | // l32i.n: 1 (Seems to be always) 9 | // 10 | // 1 Clock cycle: 11 | // add.n a10, a10, a11 12 | // 13 | // 2 Clock Cycles: 14 | // add.n a10, a10, a11 15 | // add.n a10, a10, a11 16 | // 17 | // 2 Clock Cycles: 18 | // add.n a10, a10, a11 19 | // extui a10, a10, 24, 3 20 | // 21 | // 7 Clocks: 22 | // l32r a10, 4010027c <_DoubleExceptionVector+0x20c> 23 | // 24 | // Also 7 Clocks: 25 | // addi.n a10, a10, -1 26 | // l32r a10, 4010027c <_DoubleExceptionVector+0x20c> 27 | // 28 | // 9 Clocks: 29 | // addi.n a10, a10, -1 30 | // addi.n a11, a11, -1 31 | // l32r a11, 4010027c <_DoubleExceptionVector+0x20c> 32 | // 33 | // 14 Clocks 34 | // l32r a10, 4010027c <_DoubleExceptionVector+0x20c> 35 | // l32r a11, 40100280 <_DoubleExceptionVector+0x210> 36 | // 37 | // 1 Clocks 38 | // l32i.n a10, a2, 0 39 | // 40 | // 2 Clocks 41 | // add.n a10, a10, a11 42 | // l32i.n a10, a2, 0 43 | // 44 | // 3 Clocks (Second operation depends on first) 45 | // l32i.n a10, a2, 0 46 | // (Nop or no nop, still 3 cycles) 47 | // add.n a10, a10, a11 48 | // 49 | // 50 | // 2 Clocks (Second operation does not depend on first) 51 | // l32i.n a10, a2, 0 52 | // add.n a11, a11, a11 53 | // 54 | // 3 Clocks (@a2 == 0) (Branch not taken) 55 | // l32i.n a10, a2, 0 56 | // nop.n 57 | // bgeui a10, 5, 40100b60 58 | // 59 | // 5 Clocks (@a2 == 6) (Branch taken) Branching takes 2 additional instructions 60 | // l32i.n a10, a2, 0 61 | // nop.n 62 | // bgeui a10, 5, 40100b60 63 | // 64 | // 65 | // Big note: with regular jumps and comparative jumps, if the target's address ends with 11 (binary), then it will take one extra cycle. 66 | // 67 | // 68 | // 3 Clocks 69 | // j end 70 | // ... 71 | // end: 72 | // 73 | // 4 Clocks: (Branch not taken) 74 | // l32i a10, a2, 0 75 | // bgeui a10, 6, 40100b58 76 | // addi a10, a10, 1 77 | // 78 | // 4 Clocks: (Branch not taken) 79 | // l32i a10, a2, 0 80 | // extui a10, a10, 23, 1 81 | // bgeui a10, 6, 40100b58 82 | // 83 | // 6 Clocks: (Branch Taken) 84 | // l32i a10, a2, 0 85 | // (Free to do unrelated instruction here) 86 | // extui a10, a10, 1, 4 87 | // bgeui a10, 6, 40100b58 88 | // 89 | // 90 | // Function Calls: 91 | // 92 | // 93 | // 5 Clocks: No function call. 94 | // nop.n 95 | // nop.n 96 | // j 40100b58 97 | // my_func: 98 | // ret.n 99 | // end: 100 | // 101 | // 10 Clocks: Include function call 102 | // call0 40100b54 103 | // j 40100b56 104 | // : 105 | // ret.n 106 | // end: 107 | // 108 | // 10 Clocks: Include function call, and an instruction in the beginning 109 | // call0 40100b54 110 | // j 40100b58 111 | // : 112 | // nop.n 113 | // ret.n 114 | // : 115 | // 116 | // 12 Clocks: (WHYYYYYYY WHY Jump from 10 to 12??) 117 | // : 118 | // call0 40100b54 119 | // j 40100b5a 120 | // : 121 | // nop.n 122 | // nop.n 123 | // ret.n 124 | // 125 | // 13 Clocks: 126 | //: 127 | // call0 40100b54 128 | // j 40100b5e 129 | // : 130 | // addi a1, a1, -16 131 | // nop.n 132 | // addi a1, a1, 16 133 | // ret.n 134 | // 135 | // 15 Clocks: 136 | // : 137 | // call0 40100b54 138 | // j 40100b62 139 | // : 140 | // addi a1, a1, -16 141 | // s32i.n a0, a1, 0 142 | // nop.n 143 | // l32i.n a0, a1, 0 144 | // addi a1, a1, 16 145 | // ret.n 146 | // : 147 | // 148 | // 149 | // 21 Clocks: 150 | // : 151 | // call0 40100b54 152 | // j 40100b6e 153 | // : 154 | // addi a1, a1, -16 155 | // s32i.n a0, a1, 0 156 | // s32i.n a2, a1, 4 157 | // s32i.n a3, a1, 8 158 | // s32i.n a4, a1, 12 159 | // nop.n 160 | // l32i.n a4, a1, 12 161 | // l32i.n a3, a1, 8 162 | // l32i.n a2, a1, 4 163 | // l32i.n a0, a1, 0 164 | // addi a1, a1, 16 165 | // ret.n 166 | // : 167 | // 168 | // For the following, we will be replacing 'nop' with the following: 169 | // 170 | // This takes 1 clock... 171 | // nop 172 | // 173 | // These take 20 Clocks... WHYYYY?Y??YY? 174 | // l32r a2, 40100280 <_DoubleExceptionVector+0x210> (These are actually movi a2, (some constant)) 175 | // l32r a3, 40100270 <_DoubleExceptionVector+0x200> 176 | // l32r a4, 40100284 <_DoubleExceptionVector+0x214> 177 | // 178 | // 14 Clocks: 179 | // l32r a2, 40100280 <_DoubleExceptionVector+0x210> 180 | // l32r a3, 40100270 <_DoubleExceptionVector+0x200> 181 | // 182 | // 7 Clocks: 183 | // l32r a3, 40100270 <_DoubleExceptionVector+0x200> 184 | // 185 | // These take 25 Clocks... Ok... this is getting weird. 186 | // l32r a0, 40100280 <_DoubleExceptionVector+0x210> (These are actually movi a2, (some constant)) 187 | // l32r a2, 40100280 <_DoubleExceptionVector+0x210> 188 | // l32r a3, 40100270 <_DoubleExceptionVector+0x200> 189 | // l32r a4, 40100284 <_DoubleExceptionVector+0x214> 190 | // 191 | // 33 Clock... WAT?? 192 | // l32r a0, 40100280 <_DoubleExceptionVector+0x210> 193 | // l32r a2, 40100280 <_DoubleExceptionVector+0x210> 194 | // l32r a4, 40100280 <_DoubleExceptionVector+0x210> 195 | // l32r a0, 40100280 <_DoubleExceptionVector+0x210> 196 | // l32r a2, 40100280 <_DoubleExceptionVector+0x210> 197 | // 198 | // 9 Clocks: (If you want to cleaverly pull data out of a table) 199 | // l32r a0, 40100160 <_DoubleExceptionVector+0xf0> 200 | // (ONE Optional nop here) 201 | // sskipper32i.n a1, a0, 0 202 | // 203 | // 204 | // BIG NOTE About jumping. If the instruction you are jumping to ends in a 11 as the last two bits, it will take ONE extra cycle to complete. 205 | // JUMPS TAKE ONE EXTRA CYCLE WHEN 11 is last two bits: CONFIRMED. This lets us place 3 instructions in and it will still take just as long! 206 | // 207 | // Whenever reading with any kind of load, the next instruction CANNOT use the data that was loaded. 208 | 209 | // 210 | // mul16u a, b, c <<1 cycle, always. 211 | // 212 | // 213 | 214 | 215 | /* 216 | this is 5 cycles... Multiplies take two cycles to complete, but only one to issue. 217 | mul16u a7, a5, a6 218 | bbsi a7, 0, skipper 219 | _nop.n 220 | _nop 221 | skipper: 222 | 223 | ...ALSO 5 224 | 225 | mul16u a7, a5, a6 226 | nop 227 | bbsi a7, 0, skipper 228 | _nop.n 229 | _nop 230 | skipper: 231 | 232 | ... ALSO 5 233 | mul16u a7, a5, a6 234 | mul16u a5, a5, a6 235 | bbsi a7, 0, skipper 236 | _nop.n 237 | _nop.n 238 | skipper: 239 | 240 | ...BUT if we use one multiply in another multiply it stalls. (6 cycles) 241 | mul16u a7, a5, a6 242 | mul16u a7, a5, a7 243 | bbsi a7, 0, skipper 244 | _nop.n 245 | _nop.n 246 | skipper: 247 | */ 248 | 249 | 250 | /* 251 | Calling... 252 | 253 | .align 4 254 | my_test_call: 255 | ret 256 | 257 | elsewhere.. 258 | _call0 my_test_call 259 | 260 | //IF the last two bits of the address the CALL line is on are: 261 | // 00 = 7 cycles 262 | // 01 = 6 cycles 263 | // 10 = 6 cycles 264 | // 11 = 7 cycles 265 | 266 | */ 267 | 268 | 269 | /* 270 | Revisiting l32 271 | //A4 = some place within iram, aligned. Unaligned reads will crash regardless of if they're from iram or dram. 272 | 273 | 274 | //7, 8 cycles (Or +1 if there is a dependency) 275 | // 276 | // If l32r's address ends in: 277 | // 00: 7 cycles 278 | // 01: 7 cycles 279 | // 10: 8 cycles 280 | // 11: 8 cycles 281 | _l32r a6, my_test_data 282 | add a6, a7, a7 283 | 284 | //l32i behaves exactly the same!!! Btw! Can only load from an address that ends in 00. 285 | 286 | 287 | You can't seem to l8ui from iram. It seems to always crash. 288 | 289 | //A4 = some place within dram 290 | 291 | //2 Cycles 292 | _l32i.n a6, a4, 0 293 | add a7, a7, a7 294 | 295 | //3 Cycles 296 | _l32i.n a7, a4, 0 297 | add a7, a7, a7 298 | 299 | 300 | //2 Cycles (If a4 is aligned or not, regardless) 301 | _l8i.n a6, a4, 0 302 | add a7, a7, a7 (3 cycles if the dependency exists) 303 | 304 | 305 | */ 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | //////////////////////////////////////////////////// 314 | 315 | 316 | #if 0 317 | 318 | 319 | //NOTES: We are hooked up to USB by GPIO12: D-? (White), GPIO14: D-, GPIO5 EXTDEBUG 320 | 321 | #define STDPLUS "12" 322 | #define STDMINUS "14" 323 | 324 | #define GPSET __asm__ __volatile__ ("movi a2, 0x60000304\nmovi a4, 0x60000308\nmovi.n a3, 32\n"); //GPIO5 325 | #define LOW __asm__ __volatile__ ("s32i.n a3, a4, 0"); //One instruction. 326 | #define HIGH __asm__ __volatile__ ("s32i.n a3, a2, 0"); 327 | 328 | #define LOWS __asm__ __volatile__ ("s32i.n a14, a13, 0":::"a3"); 329 | #define HIGHS __asm__ __volatile__ ("s32i.n a14, a12, 0":::"a3"); 330 | 331 | //Detailed analysis of some useful stuff and performance tweaking: http://naberius.de/2015/05/14/esp8266-gpio-output-performance/ 332 | //Reverse engineerd boot room can be helpful, too: http://cholla.mmto.org/esp8266/bootrom/boot.txt 333 | 334 | //The folowing performs this code: 335 | // uint32_t gpio_status = GPIO_REG_READ(GPIO_STATUS_ADDRESS); 336 | // GPIO_REG_WRITE(GPIO_STATUS_W1TC_ADDRESS, gpio_status); //clear interrupt status 337 | // 338 | //GPIO Base Register(PERIPHS_GPIO_BASEADDR): 0x60000300 + GPIO Status Register: 0x1c = 0x6000031c 339 | //GPIO_STATUS_W1TC_ADDRESS = 0x24 340 | #define ACKNOWLEDGE_INTERRUPT __asm__ __volatile__ ("movi a2, 0x6000031c \n l32i.n a3, a2, 0 \n movi a2, 0x60000324 \n s32i.n a3, a2, 0"); 341 | 342 | // ETS_INTR_DISABLE(ETS_GPIO_INUM) ETS_GPIO_INUM=4, 343 | //#define ETS_INTR_ENABLE(inum) \ 344 | // ets_isr_unmask((1< 356 | * jump if bit in register set: bbsi a2, 14, 40100379 357 | 358 | * movi a2, 0x60000304 < move the address of 359 | * movi.n a3, 4096 < set the value 360 | * s32i.n a3, a4, 0 < Update it in memory 361 | */ 362 | 363 | //XXX Careful: Note the "int" to let things wrap. 364 | static inline int __attribute__((always_inline)) get_ccount(void) 365 | { 366 | unsigned r; 367 | asm volatile ("rsr %0, ccount" : "=r"(r)); 368 | return r; 369 | } 370 | 371 | //static inline unsigned __attribute__((always_inline)) wait_bit() 372 | #define wait_bit \ 373 | { \ 374 | bittime+=53; \ 375 | while( bittime > get_ccount() ); \ 376 | } 377 | 378 | #define WBV (((*pins)&_BV(DPLUS))?1:0) 379 | 380 | 381 | //Plan of attack: 382 | //1: Spin at beginning waiting for a bit transition. 383 | //2: Start "wait bit"ting every 53 cycles. 384 | 385 | 386 | #define TIMEOUT 0xff 387 | 388 | void gpio_intr(void) 389 | { 390 | register unsigned to asm ("a9"); //timeout 391 | register int bittime asm ("a10"); 392 | volatile register uint32_t * pins asm ("a11"); 393 | 394 | //Variables used for debugging. 395 | volatile register uint32_t * pin_out_set asm ("a12"); 396 | volatile register uint32_t * pin_out_clr asm ("a13"); 397 | volatile register int psel asm("a14"); 398 | 399 | uint32_t bits[16]; 400 | unsigned i, j; 401 | 402 | //Initialize common-use variables 403 | __asm__ __volatile__("\n\ 404 | movi a11, "STR_PIN_IN"\n\ 405 | movi a12, "STR_PIN_OUT_SET"\n\ 406 | movi a13, "STR_PIN_OUT_CLEAR"\n\ 407 | movi a14, %0\n\ 408 | " : : "M"(1< 28 | PAGE_HEADING = $(PAGE_TITLE) 29 | PAGE_INFO =

Welcome to the usb demo Web-based GUI.

30 | -------------------------------------------------------------------------------- /user/custom_commands.c: -------------------------------------------------------------------------------- 1 | //Copyright 2015 <>< Charles Lohr, see LICENSE file. 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | extern uint8_t last_leds[512*3]; 8 | extern int last_led_count; 9 | uint8_t my_ep1[4]; 10 | uint8_t my_ep2[8]; 11 | 12 | int keybt; 13 | int keymod; 14 | int keypress; 15 | 16 | int ICACHE_FLASH_ATTR CustomCommand(char * buffer, int retsize, char *pusrdata, unsigned short len) 17 | { 18 | char * buffend = buffer; 19 | switch( pusrdata[1] ) 20 | { 21 | case 'C': case 'c': //Custom command test 22 | { 23 | buffend += ets_sprintf( buffend, "CC" ); 24 | return buffend-buffer; 25 | } 26 | case 'K': case 'k': //Keyboard 27 | { 28 | paramcount = 0; 29 | keymod = ParamCaptureAndAdvanceInt( ); 30 | keybt = ParamCaptureAndAdvanceInt( ); 31 | if( paramcount != 2 ) break; 32 | keypress = 1; 33 | buffend += ets_sprintf( buffend, "CK" ); 34 | return buffend-buffer; 35 | } 36 | case 'M': case 'm': //Mouse 37 | { 38 | //CM[Mouse Button]\t[x]\t[y]; 39 | int b = ParamCaptureAndAdvanceInt( ); 40 | int dx = ParamCaptureAndAdvanceInt( ); 41 | int dy = ParamCaptureAndAdvanceInt( ); 42 | if( paramcount != 3 ) break; 43 | 44 | struct usb_internal_state_struct * uis = &usb_internal_state; 45 | struct usb_endpoint * e1 = &uis->eps[1]; 46 | struct usb_endpoint * e2 = &uis->eps[2]; 47 | 48 | //First see if we've alredy sent this, if so, zero the ep data. 49 | if( e1->send == 0 ) 50 | { 51 | my_ep1[1] = 0; 52 | my_ep1[2] = 0; 53 | } 54 | 55 | my_ep1[0] = b; 56 | my_ep1[1] += dx; 57 | my_ep1[2] += dy; 58 | 59 | e1->ptr_in = my_ep1; 60 | e1->place_in = 0; 61 | e1->size_in = sizeof( my_ep1 ); 62 | e1->send = 1; 63 | 64 | buffend += ets_sprintf( buffend, "CM" ); 65 | return buffend-buffer; 66 | } 67 | 68 | 69 | 70 | } 71 | return -1; 72 | } 73 | -------------------------------------------------------------------------------- /user/slc_register.h: -------------------------------------------------------------------------------- 1 | //Generated at 2012-10-23 19:55:03 2 | /* 3 | * Copyright (c) 2010 - 2011 Espressif System 4 | * 5 | */ 6 | 7 | #ifndef SLC_REGISTER_H_ 8 | #define SLC_REGISTER_H_ 9 | 10 | #define REG_SLC_BASE 0x60000B00 11 | //version value:32'h091700 12 | 13 | #define SLC_CONF0 (REG_SLC_BASE + 0x0) 14 | #ifndef ESP_MAC_5 15 | #define SLC_MODE 0x00000003 16 | #define SLC_MODE_S 12 17 | #endif 18 | #define SLC_DATA_BURST_EN (BIT(9)) 19 | #define SLC_DSCR_BURST_EN (BIT(8)) 20 | #define SLC_RX_NO_RESTART_CLR (BIT(7)) 21 | #define SLC_RX_AUTO_WRBACK (BIT(6)) 22 | #define SLC_RX_LOOP_TEST (BIT(5)) 23 | #define SLC_TX_LOOP_TEST (BIT(4)) 24 | #define SLC_AHBM_RST (BIT(3)) 25 | #define SLC_AHBM_FIFO_RST (BIT(2)) 26 | #define SLC_RXLINK_RST (BIT(1)) 27 | #define SLC_TXLINK_RST (BIT(0)) 28 | 29 | #define SLC_INT_RAW (REG_SLC_BASE + 0x4) 30 | #define SLC_TX_DSCR_EMPTY_INT_RAW (BIT(21)) 31 | #define SLC_RX_DSCR_ERR_INT_RAW (BIT(20)) 32 | #define SLC_TX_DSCR_ERR_INT_RAW (BIT(19)) 33 | #define SLC_TOHOST_INT_RAW (BIT(18)) 34 | #define SLC_RX_EOF_INT_RAW (BIT(17)) 35 | #define SLC_RX_DONE_INT_RAW (BIT(16)) 36 | #define SLC_TX_EOF_INT_RAW (BIT(15)) 37 | #define SLC_TX_DONE_INT_RAW (BIT(14)) 38 | #define SLC_TOKEN1_1TO0_INT_RAW (BIT(13)) 39 | #define SLC_TOKEN0_1TO0_INT_RAW (BIT(12)) 40 | #define SLC_TX_OVF_INT_RAW (BIT(11)) 41 | #define SLC_RX_UDF_INT_RAW (BIT(10)) 42 | #define SLC_TX_START_INT_RAW (BIT(9)) 43 | #define SLC_RX_START_INT_RAW (BIT(8)) 44 | #define SLC_FRHOST_BIT7_INT_RAW (BIT(7)) 45 | #define SLC_FRHOST_BIT6_INT_RAW (BIT(6)) 46 | #define SLC_FRHOST_BIT5_INT_RAW (BIT(5)) 47 | #define SLC_FRHOST_BIT4_INT_RAW (BIT(4)) 48 | #define SLC_FRHOST_BIT3_INT_RAW (BIT(3)) 49 | #define SLC_FRHOST_BIT2_INT_RAW (BIT(2)) 50 | #define SLC_FRHOST_BIT1_INT_RAW (BIT(1)) 51 | #define SLC_FRHOST_BIT0_INT_RAW (BIT(0)) 52 | 53 | #define SLC_INT_STATUS (REG_SLC_BASE + 0x8) 54 | #define SLC_TX_DSCR_EMPTY_INT_ST (BIT(21)) 55 | #define SLC_RX_DSCR_ERR_INT_ST (BIT(20)) 56 | #define SLC_TX_DSCR_ERR_INT_ST (BIT(19)) 57 | #define SLC_TOHOST_INT_ST (BIT(18)) 58 | #define SLC_RX_EOF_INT_ST (BIT(17)) 59 | #define SLC_RX_DONE_INT_ST (BIT(16)) 60 | #define SLC_TX_EOF_INT_ST (BIT(15)) 61 | #define SLC_TX_DONE_INT_ST (BIT(14)) 62 | #define SLC_TOKEN1_1TO0_INT_ST (BIT(13)) 63 | #define SLC_TOKEN0_1TO0_INT_ST (BIT(12)) 64 | #define SLC_TX_OVF_INT_ST (BIT(11)) 65 | #define SLC_RX_UDF_INT_ST (BIT(10)) 66 | #define SLC_TX_START_INT_ST (BIT(9)) 67 | #define SLC_RX_START_INT_ST (BIT(8)) 68 | #define SLC_FRHOST_BIT7_INT_ST (BIT(7)) 69 | #define SLC_FRHOST_BIT6_INT_ST (BIT(6)) 70 | #define SLC_FRHOST_BIT5_INT_ST (BIT(5)) 71 | #define SLC_FRHOST_BIT4_INT_ST (BIT(4)) 72 | #define SLC_FRHOST_BIT3_INT_ST (BIT(3)) 73 | #define SLC_FRHOST_BIT2_INT_ST (BIT(2)) 74 | #define SLC_FRHOST_BIT1_INT_ST (BIT(1)) 75 | #define SLC_FRHOST_BIT0_INT_ST (BIT(0)) 76 | 77 | #define SLC_INT_ENA (REG_SLC_BASE + 0xC) 78 | #define SLC_TX_DSCR_EMPTY_INT_ENA (BIT(21)) 79 | #define SLC_RX_DSCR_ERR_INT_ENA (BIT(20)) 80 | #define SLC_TX_DSCR_ERR_INT_ENA (BIT(19)) 81 | #define SLC_TOHOST_INT_ENA (BIT(18)) 82 | #define SLC_RX_EOF_INT_ENA (BIT(17)) 83 | #define SLC_RX_DONE_INT_ENA (BIT(16)) 84 | #define SLC_TX_EOF_INT_ENA (BIT(15)) 85 | #define SLC_TX_DONE_INT_ENA (BIT(14)) 86 | #define SLC_TOKEN1_1TO0_INT_ENA (BIT(13)) 87 | #define SLC_TOKEN0_1TO0_INT_ENA (BIT(12)) 88 | #define SLC_TX_OVF_INT_ENA (BIT(11)) 89 | #define SLC_RX_UDF_INT_ENA (BIT(10)) 90 | #define SLC_TX_START_INT_ENA (BIT(9)) 91 | #define SLC_RX_START_INT_ENA (BIT(8)) 92 | #define SLC_FRHOST_BIT7_INT_ENA (BIT(7)) 93 | #define SLC_FRHOST_BIT6_INT_ENA (BIT(6)) 94 | #define SLC_FRHOST_BIT5_INT_ENA (BIT(5)) 95 | #define SLC_FRHOST_BIT4_INT_ENA (BIT(4)) 96 | #define SLC_FRHOST_BIT3_INT_ENA (BIT(3)) 97 | #define SLC_FRHOST_BIT2_INT_ENA (BIT(2)) 98 | #define SLC_FRHOST_BIT1_INT_ENA (BIT(1)) 99 | #define SLC_FRHOST_BIT0_INT_ENA (BIT(0)) 100 | 101 | #define SLC_FRHOST_BIT_INT_ENA_ALL 0xff 102 | 103 | #define SLC_INT_CLR (REG_SLC_BASE + 0x10) 104 | #define SLC_TX_DSCR_EMPTY_INT_CLR (BIT(21)) 105 | #define SLC_RX_DSCR_ERR_INT_CLR (BIT(20)) 106 | #define SLC_TX_DSCR_ERR_INT_CLR (BIT(19)) 107 | #define SLC_TOHOST_INT_CLR (BIT(18)) 108 | #define SLC_RX_EOF_INT_CLR (BIT(17)) 109 | #define SLC_RX_DONE_INT_CLR (BIT(16)) 110 | #define SLC_TX_EOF_INT_CLR (BIT(15)) 111 | #define SLC_TX_DONE_INT_CLR (BIT(14)) 112 | #define SLC_TOKEN1_1TO0_INT_CLR (BIT(13)) 113 | #define SLC_TOKEN0_1TO0_INT_CLR (BIT(12)) 114 | #define SLC_TX_OVF_INT_CLR (BIT(11)) 115 | #define SLC_RX_UDF_INT_CLR (BIT(10)) 116 | #define SLC_TX_START_INT_CLR (BIT(9)) 117 | #define SLC_RX_START_INT_CLR (BIT(8)) 118 | #define SLC_FRHOST_BIT7_INT_CLR (BIT(7)) 119 | #define SLC_FRHOST_BIT6_INT_CLR (BIT(6)) 120 | #define SLC_FRHOST_BIT5_INT_CLR (BIT(5)) 121 | #define SLC_FRHOST_BIT4_INT_CLR (BIT(4)) 122 | #define SLC_FRHOST_BIT3_INT_CLR (BIT(3)) 123 | #define SLC_FRHOST_BIT2_INT_CLR (BIT(2)) 124 | #define SLC_FRHOST_BIT1_INT_CLR (BIT(1)) 125 | #define SLC_FRHOST_BIT0_INT_CLR (BIT(0)) 126 | 127 | #define SLC_RX_STATUS (REG_SLC_BASE + 0x14) 128 | #define SLC_RX_EMPTY (BIT(1)) 129 | #define SLC_RX_FULL (BIT(0)) 130 | 131 | #define SLC_RX_FIFO_PUSH (REG_SLC_BASE + 0x18) 132 | #define SLC_RXFIFO_PUSH (BIT(16)) 133 | #define SLC_RXFIFO_WDATA 0x000001FF 134 | #define SLC_RXFIFO_WDATA_S 0 135 | 136 | #define SLC_TX_STATUS (REG_SLC_BASE + 0x1C) 137 | #define SLC_TX_EMPTY (BIT(1)) 138 | #define SLC_TX_FULL (BIT(0)) 139 | 140 | #define SLC_TX_FIFO_POP (REG_SLC_BASE + 0x20) 141 | #define SLC_TXFIFO_POP (BIT(16)) 142 | #define SLC_TXFIFO_RDATA 0x000007FF 143 | #define SLC_TXFIFO_RDATA_S 0 144 | 145 | #define SLC_RX_LINK (REG_SLC_BASE + 0x24) 146 | #define SLC_RXLINK_PARK (BIT(31)) 147 | #define SLC_RXLINK_RESTART (BIT(30)) 148 | #define SLC_RXLINK_START (BIT(29)) 149 | #define SLC_RXLINK_STOP (BIT(28)) 150 | #define SLC_RXLINK_DESCADDR_MASK 0x000FFFFF 151 | #define SLC_RXLINK_ADDR_S 0 152 | 153 | #define SLC_TX_LINK (REG_SLC_BASE + 0x28) 154 | #define SLC_TXLINK_PARK (BIT(31)) 155 | #define SLC_TXLINK_RESTART (BIT(30)) 156 | #define SLC_TXLINK_START (BIT(29)) 157 | #define SLC_TXLINK_STOP (BIT(28)) 158 | #define SLC_TXLINK_DESCADDR_MASK 0x000FFFFF 159 | #define SLC_TXLINK_ADDR_S 0 160 | 161 | #define SLC_INTVEC_TOHOST (REG_SLC_BASE + 0x2C) 162 | #define SLC_TOHOST_INTVEC 0x000000FF 163 | #define SLC_TOHOST_INTVEC_S 0 164 | 165 | #define SLC_TOKEN0 (REG_SLC_BASE + 0x30) 166 | #define SLC_TOKEN0_MASK 0x00000FFF 167 | #define SLC_TOKEN0_S 16 168 | #define SLC_TOKEN0_LOCAL_INC_MORE (BIT(14)) 169 | #define SLC_TOKEN0_LOCAL_INC (BIT(13)) 170 | #define SLC_TOKEN0_LOCAL_WR (BIT(12)) 171 | #define SLC_TOKEN0_LOCAL_WDATA_MASK 0x00000FFF 172 | #define SLC_TOKEN0_LOCAL_WDATA_S 0 173 | 174 | #define SLC_TOKEN1 (REG_SLC_BASE + 0x34) 175 | #define SLC_TOKEN1_MASK 0x00000FFF 176 | #define SLC_TOKEN1_S 16 177 | #define SLC_TOKEN1_LOCAL_INC_MORE (BIT(14)) 178 | #define SLC_TOKEN1_LOCAL_INC (BIT(13)) 179 | #define SLC_TOKEN1_LOCAL_WR (BIT(12)) 180 | #define SLC_TOKEN1_LOCAL_WDATA 0x00000FFF 181 | #define SLC_TOKEN1_LOCAL_WDATA_S 0 182 | 183 | #define SLC_CONF1 (REG_SLC_BASE + 0x38) 184 | #define SLC_STATE0 (REG_SLC_BASE + 0x3C) 185 | #define SLC_STATE1 (REG_SLC_BASE + 0x40) 186 | 187 | #define SLC_BRIDGE_CONF (REG_SLC_BASE + 0x44) 188 | #ifndef ESP_MAC_5 189 | #define SLC_TX_PUSH_IDLE_NUM 0x0000FFFF 190 | #define SLC_TX_PUSH_IDLE_NUM_S 16 191 | #define SLC_TX_DUMMY_MODE (BIT(12)) 192 | #endif 193 | #define SLC_FIFO_MAP_ENA 0x0000000F 194 | #define SLC_FIFO_MAP_ENA_S 8 195 | #define SLC_TXEOF_ENA 0x0000003F 196 | #define SLC_TXEOF_ENA_S 0 197 | 198 | #define SLC_RX_EOF_DES_ADDR (REG_SLC_BASE + 0x48) 199 | #define SLC_TX_EOF_DES_ADDR (REG_SLC_BASE + 0x4C) 200 | #define SLC_FROM_HOST_LAST_DESC SLC_TX_EOF_DES_ADDR 201 | #define SLC_TO_HOST_LAST_DESC SLC_RX_EOF_DES_ADDR 202 | 203 | #define SLC_RX_EOF_BFR_DES_ADDR (REG_SLC_BASE + 0x50) 204 | #define SLC_AHB_TEST (REG_SLC_BASE + 0x54) 205 | #define SLC_AHB_TESTADDR 0x00000003 206 | #define SLC_AHB_TESTADDR_S 4 207 | #define SLC_AHB_TESTMODE 0x00000007 208 | #define SLC_AHB_TESTMODE_S 0 209 | 210 | #define SLC_SDIO_ST (REG_SLC_BASE + 0x58) 211 | #define SLC_BUS_ST 0x00000007 212 | #define SLC_BUS_ST_S 12 213 | #define SLC_SDIO_WAKEUP (BIT(8)) 214 | #define SLC_FUNC_ST 0x0000000F 215 | #define SLC_FUNC_ST_S 4 216 | #define SLC_CMD_ST 0x00000007 217 | #define SLC_CMD_ST_S 0 218 | 219 | #define SLC_RX_DSCR_CONF (REG_SLC_BASE + 0x5C) 220 | #ifdef ESP_MAC_5 221 | #define SLC_INFOR_NO_REPLACE (BIT(9)) 222 | #define SLC_TOKEN_NO_REPLACE (BIT(8)) 223 | #define SLC_POP_IDLE_CNT 0x000000FF 224 | #else 225 | #define SLC_RX_FILL_EN (BIT(20)) 226 | #define SLC_RX_EOF_MODE (BIT(19)) 227 | #define SLC_RX_FILL_MODE (BIT(18)) 228 | #define SLC_INFOR_NO_REPLACE (BIT(17)) 229 | #define SLC_TOKEN_NO_REPLACE (BIT(16)) 230 | #define SLC_POP_IDLE_CNT 0x0000FFFF 231 | #endif 232 | #define SLC_POP_IDLE_CNT_S 0 233 | 234 | #define SLC_TXLINK_DSCR (REG_SLC_BASE + 0x60) 235 | #define SLC_TXLINK_DSCR_BF0 (REG_SLC_BASE + 0x64) 236 | #define SLC_TXLINK_DSCR_BF1 (REG_SLC_BASE + 0x68) 237 | #define SLC_RXLINK_DSCR (REG_SLC_BASE + 0x6C) 238 | #define SLC_RXLINK_DSCR_BF0 (REG_SLC_BASE + 0x70) 239 | #define SLC_RXLINK_DSCR_BF1 (REG_SLC_BASE + 0x74) 240 | #define SLC_DATE (REG_SLC_BASE + 0x78) 241 | #define SLC_ID (REG_SLC_BASE + 0x7C) 242 | 243 | #define SLC_HOST_CONF_W0 (REG_SLC_BASE + 0x80 + 0x14) 244 | #define SLC_HOST_CONF_W1 (REG_SLC_BASE + 0x80 + 0x18) 245 | #define SLC_HOST_CONF_W2 (REG_SLC_BASE + 0x80 + 0x20) 246 | #define SLC_HOST_CONF_W3 (REG_SLC_BASE + 0x80 + 0x24) 247 | #define SLC_HOST_CONF_W4 (REG_SLC_BASE + 0x80 + 0x28) 248 | 249 | #define SLC_HOST_INTR_ST (REG_SLC_BASE + 0x80 + 0x1c) 250 | #define SLC_HOST_INTR_CLR (REG_SLC_BASE + 0x80 + 0x30) 251 | #define SLC_HOST_INTR_SOF_BIT (BIT(12)) 252 | 253 | #define SLC_HOST_INTR_ENA (REG_SLC_BASE + 0x80 + 0x34) 254 | #define SLC_RX_NEW_PACKET_INT_ENA (BIT23) 255 | #define SLC_HOST_TOHOST_BIT0_INT_ENA (BIT0) 256 | #define SLC_HOST_CONF_W5 (REG_SLC_BASE + 0x80 + 0x3C) 257 | #define SLC_HOST_INTR_RAW (REG_SLC_BASE + 0x80 + 0x8) 258 | #define SLC_HOST_INTR_ENA_BIT (BIT(23)) 259 | //[15:12]: 0x3ff9xxxx -- 0b01 from_host 260 | // 0x3ffaxxxx -- 0b10 general 261 | // 0x3ffbxxxx -- 0b11 to_host 262 | #define SLC_DATA_ADDR_CLEAR_MASK (~(0xf<<12)) 263 | #define SLC_FROM_HOST_ADDR_MASK (0x1<<12) 264 | #define SLC_TO_HOST_ADDR_MASK (0x3<<12) 265 | 266 | #define SLC_SET_FROM_HOST_ADDR_MASK(v) do { \ 267 | (v) &= SLC_DATA_ADDR_CLEAR_MASK; \ 268 | (v) |= SLC_FROM_HOST_ADDR_MASK; \ 269 | } while(0); 270 | 271 | #define SLC_SET_TO_HOST_ADDR_MASK(v) do { \ 272 | (v) &= SLC_DATA_ADDR_CLEAR_MASK; \ 273 | (v) |= SLC_TO_HOST_ADDR_MASK; \ 274 | } while(0); 275 | 276 | 277 | #define SLC_TX_DESC_DEBUG_REG 0x3ff0002c //[15:0] set to 0xcccc 278 | 279 | 280 | #endif // SLC_REGISTER_H_INCLUDED 281 | 282 | -------------------------------------------------------------------------------- /user/usb.c: -------------------------------------------------------------------------------- 1 | #define NEED_CONSTANTS 2 | 3 | #include "usb.h" 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "usb_table_1bit.h" 9 | 10 | struct usb_internal_state_struct usb_internal_state __attribute__((aligned(4))); 11 | 12 | #define ENDPOINT0_SIZE 8 //Fixed for USB 1.1, Low Speed. 13 | 14 | #define INSTANCE_DESCRIPTORS 15 | #include 16 | 17 | //Received a setup for a specific endpoint. 18 | void usb_pid_handle_setup( uint32_t this_token, struct usb_internal_state_struct * ist ) 19 | { 20 | uint8_t addr = (this_token>>8) & 0x7f; 21 | uint8_t endp = (this_token>>15) & 0xf; 22 | 23 | ist->there_is_a_host = 1; 24 | 25 | if( endp >= ENDPOINTS ) goto end; 26 | if( addr != 0 && addr != ist->my_address ) goto end; 27 | 28 | struct usb_endpoint * e = ist->ce = &ist->eps[endp]; 29 | e->toggle_out = 0; 30 | e->toggle_in = 1; 31 | e->ptr_in = 0; 32 | e->send = 0; 33 | ist->setup_request = 1; 34 | end: 35 | __asm__ __volatile__( "movi a0, usb_reinstate" ); //After this token, we are immediately expecting another grouping. This short-circuits the 'return'. 36 | } 37 | 38 | void usb_pid_handle_sof( uint32_t this_token, struct usb_internal_state_struct * ist ) 39 | { 40 | } 41 | 42 | void usb_pid_handle_in( uint32_t this_token, struct usb_internal_state_struct * ist ) 43 | { 44 | uint8_t addr = (this_token>>8) & 0x7f; 45 | uint8_t endp = (this_token>>15) & 0xf; 46 | 47 | //If we get an "in" token, we have to strike any accept buffers. 48 | 49 | if( endp >= ENDPOINTS ) return; 50 | if( addr != 0 && addr != ist->my_address ) return; 51 | 52 | struct usb_endpoint * e = ist->ce = &ist->eps[endp]; 53 | 54 | e->got_size_out = 0; //Cancel any out transaction 55 | 56 | 57 | int tosend = 0; 58 | uint8_t sendnow[12]; 59 | sendnow[0] = 0x80; 60 | 61 | if( e->send && e->ptr_in ) 62 | { 63 | tosend = e->size_in - e->place_in; 64 | 65 | if( tosend > 8 ) tosend = 8; 66 | } 67 | 68 | if( e->toggle_in ) 69 | { 70 | sendnow[1] = 0b01001011; //DATA1 71 | } 72 | else 73 | { 74 | sendnow[1] = 0b11000011; //DATA0 75 | } 76 | 77 | if( tosend == 0 || !e->send || !e->ptr_in || e->ptr_in == EMPTY_SEND_BUFFER ) //Tricky: Empty packet. 78 | { 79 | 80 | //Tricky: Control messages are not allowed to send NAKs. We /have/ to send an empty packet for them if no more data is available. 81 | //With endpoints, proper, it's okay to send NAKs. 82 | 83 | if( endp == 0 ) 84 | { 85 | sendnow[2] = 0; 86 | sendnow[3] = 0; //CRC = 0 87 | usb_send_data( sendnow, 4, 2 ); //Force a CRC 88 | e->ptr_in = 0; 89 | } 90 | else 91 | { 92 | sendnow[1] = 0x5a; //Empty data (NAK) 93 | usb_send_data( sendnow, 2, 2 ); 94 | } 95 | } 96 | else 97 | { 98 | ets_memcpy( sendnow+2, e->ptr_in + e->place_in, tosend ); 99 | usb_send_data( sendnow, tosend+2, 0 ); 100 | e->advance_in = tosend; 101 | } 102 | return; 103 | } 104 | 105 | void usb_pid_handle_out( uint32_t this_token, struct usb_internal_state_struct * ist ) 106 | { 107 | //We need to handle this here because we could have an interrupt in the middle of a control or bulk transfer. 108 | //This will correctly swap back the endpoint. 109 | uint8_t addr = (this_token>>8) & 0x7f; 110 | uint8_t endp = (this_token>>15) & 0xf; 111 | if( endp >= ENDPOINTS ) return; 112 | if( addr != 0 && addr != ist->my_address ) return; 113 | struct usb_endpoint * e = ist->ce = &ist->eps[endp]; 114 | 115 | __asm__ __volatile__( "movi a0, usb_reinstate" ); //After this token, we are immediately expecting another grouping. This short-circuits the 'return'. 116 | } 117 | 118 | void usb_pid_handle_data( uint32_t this_token, struct usb_internal_state_struct * ist, uint32_t which_data ) 119 | { 120 | //Received data from host. 121 | 122 | struct usb_endpoint * e = ist->ce; 123 | 124 | if( e == 0 ) return; 125 | 126 | if( e->toggle_out != which_data ) 127 | { 128 | goto just_ack; 129 | } 130 | 131 | e->toggle_out = !e->toggle_out; 132 | 133 | if( ist->setup_request ) 134 | { 135 | ist->setup_request = 0; 136 | struct usb_urb * s = (struct usb_urb *)ist->usb_buffer; 137 | 138 | //Send just a data packet. 139 | e->ptr_in = EMPTY_SEND_BUFFER; 140 | e->place_in = 0; 141 | e->size_in = 0; 142 | e->send = 1; 143 | 144 | if( s->bmRequestType & 0x80 ) 145 | { 146 | if( s->bRequest == 0x06 ) //Get Request 147 | { 148 | int i; 149 | const struct descriptor_list_struct * dl; 150 | for( i = 0; i < DESCRIPTOR_LIST_ENTRIES; i++ ) 151 | { 152 | dl = &descriptor_list[i]; 153 | if( dl->wIndex == s->wIndex && dl->wValue == s->wValue ) 154 | break; 155 | } 156 | 157 | if( i == DESCRIPTOR_LIST_ENTRIES ) 158 | { 159 | //??? Somehow fail? Is 'nak' the right thing? I don't know what to do here. 160 | goto just_ack; 161 | } 162 | 163 | e->ptr_in = dl->addr; 164 | e->size_in = dl->length; 165 | if( s->wLength < e->size_in ) e->size_in = s->wLength; 166 | } 167 | usb_handle_custom_control( s->bmRequestType, s->bRequest, s->wLength, ist ); 168 | } 169 | else if( s->bmRequestType == 0x00 ) 170 | { 171 | if( s->bRequest == 0x05 ) //Set address. 172 | { 173 | ist->my_address = s->wValue; 174 | } 175 | if( s->bRequest == 0x09 ) //Set configuration. 176 | { 177 | //s->wValue; has the index. We don't really care about this. 178 | } 179 | usb_handle_custom_control( s->bmRequestType, s->bRequest, s->wLength, ist ); 180 | } 181 | } 182 | else if( e->ptr_out ) 183 | { 184 | //Read into that buffer. 185 | int acc = ist->packet_size-3; //packet_size includes CRC and PID, need just data size. 186 | int place = e->got_size_out; 187 | 188 | if( place + acc > e->max_size_out ) 189 | { 190 | acc = e->max_size_out - place; 191 | } 192 | 193 | ets_memcpy( e->ptr_out + e->got_size_out, ist->usb_buffer+1, acc ); //First byte of USB buffer is token. 194 | e->got_size_out += acc; 195 | if( e->got_size_out == e->max_size_out && e->transfer_done_ptr ) { 196 | e->ptr_out = 0; 197 | *e->transfer_done_ptr = e->got_size_out; 198 | e->transfer_done_ptr = 0; 199 | } 200 | } 201 | 202 | 203 | just_ack: 204 | { 205 | //Got the right data. Acknowledge. 206 | uint8_t sendword[2] = { 0x80, 0xD2 }; 207 | usb_send_data( sendword, 2, 2 ); 208 | } 209 | } 210 | 211 | void usb_pid_handle_ack( uint32_t this_token, struct usb_internal_state_struct * ist ) 212 | { 213 | struct usb_endpoint * e = ist->ce; 214 | if( !e ) return; 215 | 216 | 217 | 218 | e->toggle_in = !e->toggle_in; 219 | e->place_in += e->advance_in; 220 | e->advance_in = 0; 221 | if( e->place_in == e->size_in ) 222 | { 223 | e->send = 0; 224 | if( e->transfer_in_done_ptr ) (*e->transfer_in_done_ptr) = 1; 225 | e->transfer_in_done_ptr = 0; 226 | } 227 | } 228 | 229 | 230 | void ICACHE_FLASH_ATTR usb_init() 231 | { 232 | ETS_GPIO_INTR_DISABLE(); //Close the GPIO interrupt 233 | 234 | PIN_FUNC_SELECT(PERIPHSDPLUS,FUNCDPLUS); //D- (needs pullup) 235 | PIN_FUNC_SELECT(PERIPHSDMINUS,FUNCDMINUS); //D+ 236 | 237 | PIN_DIR_INPUT = _BV(DMINUS)|_BV(DPLUS); 238 | PIN_PULLUP_EN( PERIPHSDMINUS ); 239 | PIN_PULLUP_DIS( PERIPHSDPLUS ); 240 | 241 | GPIO_REG_WRITE(GPIO_STATUS_W1TC_ADDRESS, BIT(0)); 242 | ETS_GPIO_INTR_ATTACH(gpio_intr,NULL); //Attach the gpio interrupt. 243 | gpio_pin_intr_state_set(GPIO_ID_PIN(DPLUS),GPIO_PIN_INTR_POSEDGE); //Rising Edge Trigger. 244 | 245 | //Forcibly disconnect from bus. 246 | volatile uint32_t * gp = (volatile uint32_t*)GPIO_BASE_REG; 247 | gp[GPIO_OFFSET_CLEAR/4] = _BV(DPLUS) | _BV(DMINUS); 248 | gp[GPIO_OFFSET_DIR_OUT/4] = _BV(DPLUS) | _BV(DMINUS); 249 | ets_delay_us( 10000 ); 250 | gp[GPIO_OFFSET_DIR_IN/4] = _BV(DPLUS) | _BV(DMINUS); 251 | 252 | ETS_GPIO_INTR_ENABLE(); 253 | } 254 | 255 | -------------------------------------------------------------------------------- /user/usb.h: -------------------------------------------------------------------------------- 1 | #ifndef _USB_H 2 | #define _USB_H 3 | 4 | #include 5 | 6 | #define USB_LOW_SPEED 7 | 8 | #define USB_BUFFERSIZE 12 //Must be big enough to hold PID + DATA + CRC + EOF 9 | 10 | #define USB_OFFSET_BUFFER 0 11 | #define USB_OFFSET_DSTATUS (USB_BUFFERSIZE) 12 | #define USB_OFFSET_PACKET_SIZE (USB_OFFSET_DSTATUS) 13 | #define USB_OFFSET_LAST_TOKEN (USB_OFFSET_DSTATUS+4) 14 | #define USB_OFFSET_DEBUG (USB_OFFSET_DSTATUS+8) 15 | 16 | #ifndef _INASM_ 17 | #include 18 | 19 | #define EMPTY_SEND_BUFFER (uint8_t*)1 20 | 21 | struct usb_endpoint 22 | { 23 | const uint8_t * ptr_in; // Pointer to "IN" data (US->PC) 24 | uint16_t size_in; // Total size of the structure pointed to by ptr_in 25 | uint16_t advance_in; // How much data was sent this packet? (How much to advance in ack) 26 | uint16_t place_in; // Where in the ptr_in we are currently pointing. 27 | uint8_t toggle_in; // DATA0 or DATA1? 28 | uint8_t send; // Sets back to 0 when done sending. 29 | int * transfer_in_done_ptr; 30 | 31 | uint8_t * ptr_out; 32 | int * transfer_done_ptr; //Written to # of bytes received when a datagram is done. 33 | uint16_t max_size_out; 34 | uint16_t got_size_out; 35 | uint8_t toggle_out; //Out PC->US 36 | }; 37 | 38 | struct usb_internal_state_struct 39 | { 40 | //This data is modified by the super low-level code. 41 | 42 | uint8_t usb_buffer[USB_BUFFERSIZE]; 43 | 44 | uint32_t packet_size; //Of data currently in usb_buffer 45 | uint32_t last_token; 46 | uint32_t debug; 47 | 48 | struct usb_endpoint * ce; //Current endpoint (set by IN/OUT PIDs) 49 | struct usb_endpoint eps[ENDPOINTS]; 50 | 51 | //Things past here are addressable by C. 52 | 53 | uint32_t my_address; //For the current address set up by the setup portion of USB. 54 | uint32_t setup_request; //1 if needing setup packet. 55 | uint32_t there_is_a_host; //1 if there is a host at all, i.e. enumeration attempts have begun. 56 | }; 57 | 58 | extern struct usb_internal_state_struct usb_internal_state __attribute__((aligned(4))); 59 | 60 | //Functions that must be supplied by user. 61 | void usb_handle_custom_control( int bmRequestType, int bRequest, int wLength, struct usb_internal_state_struct * ist ); 62 | 63 | //Functions within this suite 64 | void ICACHE_FLASH_ATTR usb_init(); 65 | 66 | //This function is provided in assembly. 67 | extern void gpio_intr(); 68 | 69 | //poly_function = 0 to include CRC. 70 | //poly_function = 2 to exclude CRC. 71 | //This function is provided in assembly 72 | extern void usb_send_data( uint8_t * data, uint32_t length, uint32_t poly_function ); 73 | 74 | void usb_pid_handle_setup( uint32_t this_token, struct usb_internal_state_struct * ist ); 75 | void usb_pid_handle_sof( uint32_t this_token, struct usb_internal_state_struct * ist ); 76 | void usb_pid_handle_in( uint32_t this_token, struct usb_internal_state_struct * ist ); 77 | void usb_pid_handle_out( uint32_t this_token, struct usb_internal_state_struct * ist ); 78 | void usb_pid_handle_data( uint32_t this_token, struct usb_internal_state_struct * ist, uint32_t which_data ); 79 | void usb_pid_handle_ack( uint32_t this_token, struct usb_internal_state_struct * ist ); 80 | 81 | extern uint32_t usb_reinstate; 82 | 83 | #else 84 | 85 | .global usb_send_data; 86 | .global usb_internal_state; 87 | .global usb_reinstate; 88 | .global usb_pid_handle_setup 89 | .global usb_pid_handle_sof 90 | .global usb_pid_handle_in 91 | .global usb_pid_handle_out 92 | .global usb_pid_handle_data 93 | .global usb_pid_handle_ack 94 | #endif 95 | 96 | 97 | 98 | #define _BV(x) ((1)<<(x)) 99 | 100 | #if defined( _INASM_ ) || defined( NEED_CONSTANTS ) 101 | 102 | #define GPIO_BASE_REG 0x60000300 103 | #define GPIO_OFFSET_OUT 0x00 104 | #define GPIO_OFFSET_SET 0x04 105 | #define GPIO_OFFSET_CLEAR 0x08 106 | #define GPIO_OFFSET_DIR 0x0c 107 | #define GPIO_OFFSET_DIR_OUT 0x10 108 | #define GPIO_OFFSET_DIR_IN 0x14 109 | #define GPIO_OFFSET_INPUT 0x18 110 | 111 | #define GPIO_OFFSET_GPIO_STATUS 0x1c 112 | #define GPIO_OFFSET_GPIO_STATUS_W1TC 0x24 113 | 114 | #endif 115 | 116 | 117 | #if defined( _INASM_ ) 118 | 119 | .global usb_ramtable 120 | 121 | #else 122 | 123 | 124 | //Detailed analysis of some useful stuff and performance tweaking: http://naberius.de/2015/05/14/esp8266-gpio-output-performance/ 125 | //Reverse engineerd boot room can be helpful, too: http://cholla.mmto.org/esp8266/bootrom/boot.txt 126 | //USB Protocol read from wikipedia: https://en.wikipedia.org/wiki/USB 127 | // Neat stuff: http://www.usbmadesimple.co.uk/ums_3.htm 128 | // Neat stuff: http://www.beyondlogic.org/usbnutshell/usb1.shtml 129 | 130 | struct usb_urb 131 | { 132 | uint8_t pktp; 133 | uint8_t bmRequestType; 134 | uint8_t bRequest; 135 | uint16_t wValue; 136 | uint16_t wIndex; 137 | uint16_t wLength; 138 | } __attribute__((packed)); 139 | 140 | #endif 141 | 142 | #endif 143 | 144 | -------------------------------------------------------------------------------- /user/usb_asm_1bit.S: -------------------------------------------------------------------------------- 1 | /* 2 | (C) 2016 <>< Charles Lohr, Under the Espressif modified MIT license. 3 | 4 | This is the assembly file that drives the low level bits for the ESP8266. 5 | Global symbols used in this file: 6 | * usb_ramtable = Created by table (in the tabler) folder. Must be loaded into dram to work. 7 | 8 | Global functions that must be implemented elsewhere. 9 | * usb_pid_handle_setup 10 | * usb_pid_handle_sof 11 | * usb_pid_handle_in 12 | * usb_pid_handle_out 13 | * usb_pid_handle_data 14 | 15 | Provided symbols include: 16 | * gpio_intr = Interrupt to be called on the rising edge of D-. 17 | * usb_send_data = Send a USB packet back to the host. 18 | */ 19 | 20 | #include 21 | 22 | #define _INASM_ 23 | #include "usb_table_1bit.h" 24 | 25 | 26 | #ifdef DEBUGPIN 27 | #define DEBUG_HIGH _s32i.n a13, a11, GPIO_OFFSET_SET 28 | #define DEBUG_LOW _s32i.n a13, a11, GPIO_OFFSET_CLEAR 29 | #else 30 | #define DEBUG_HIGH 31 | #define DEBUG_LOW 32 | #endif 33 | 34 | // 8 works, 9 is spotty at best. 35 | // -26 works, 27 is spotty at best. 36 | // Optimal spot: -9 37 | #define PHASE_DELAY -9 38 | #define DELAY_ONE_USB_BIT call0 util_wait_usb_ccount 39 | 40 | //We handle advancing the timer by one tick in here. 41 | //Because 80 MHz does not divide evenly into 1.5 MHz, we have to advance by 42 | //53 ticks, 53 ticks, then 54 ticks. we use a10 to keep track of which bit we're on. 43 | //a15 is the actual time (in ccount (clock counts)) that we're at. And, a6 is a trash 44 | //variable. Don't expect it to stick around. 45 | .align 4 46 | usb_asm_start: 47 | 48 | util_wait_usb_ccount: 49 | _addi a15, a15, 53 //Advance 53 ticks 50 | _addi.n a10, a10, 1 51 | _blti a10, 3, delayer_ccount //See if we need to add another tick 52 | _addi.n a15, a15, 1 //If so, add the tick and clear out the no-tick counter 53 | _movi.n a10, 0 54 | delayer_ccount: 55 | _rsr a6, ccount 56 | _sub a6, a6, a15 57 | _bbsi a6, 31, delayer_ccount 58 | _ret.n 59 | 60 | 61 | //############################################################################################ 62 | //############################################################################################ 63 | //############################################################################################ 64 | //############################################################################################ 65 | 66 | 67 | //Detailed analysis of some useful stuff and performance tweaking: http://naberius.de/2015/05/14/esp8266-gpio-output-performance/ 68 | //Reverse engineerd boot room can be helpful, too: http://cholla.mmto.org/esp8266/bootrom/boot.txt 69 | //USB Protocol read from wikipedia: https://en.wikipedia.org/wiki/USB 70 | //Useful information: http://www.usbmadesimple.co.uk/ums_3.htm 71 | 72 | 73 | #define SIZE_OF_BUFFER 24 74 | 75 | .global gpio_intr 76 | .align 4 77 | gpio_intr: 78 | _addi a1, a1, -68 79 | _s32i.n a0, a1, 0 // Working reg 80 | _s32i.n a2, a1, 4 // Running byte 81 | _s32i.n a3, a1, 8 // Running CRC 82 | _s32i.n a4, a1, 12 // Anding mask 83 | _s32i.n a5, a1, 16 // Status Word (for table) 84 | _s32i.n a6, a1, 20 // A Working register) 85 | _s32i.n a7, a1, 24 // The current byte ready to be written out. 86 | _s32i.n a8, a1, 28 // Buffer Output Offset 87 | _s32i.n a9, a1, 32 // Loop Amount 88 | _s32i.n a10, a1, 36 // Timing-off-by-three (For doing the 53/54 dance) (used in util_wait_usb_ccount) 89 | _s32i.n a11, a1, 40 // GPIO_BASE 90 | _s32i.n a12, a1, 44 // CRC Polynomial 91 | _s32i.n a13, a1, 48 // Debug Output Pin 92 | _s32i.n a14, a1, 52 // Main Ramtable 93 | _s32i.n a15, a1, 56 // Timing (used in util_wait_usb_ccount) 94 | 95 | //Disable Interrupts 96 | rsil a0, 15; //I don't think this is needed. 97 | s32i a0, a1, 60; 98 | rsr a0, SAR; 99 | s32i a0, a1, 64; 100 | 101 | //Load the table. 102 | movi a14, usb_ramtable //This is actually very slow. 103 | 104 | 105 | usb_reinstate: //Come back up here if we are expecting more data. 106 | 107 | //These are for debug. 108 | #ifdef DEBUGPIN 109 | _movi.n a13, 1<< Charles Lohr, see LICENSE file. 2 | 3 | #include "mem.h" 4 | #include "c_types.h" 5 | #include "user_interface.h" 6 | #include "ets_sys.h" 7 | #include "uart.h" 8 | #include "osapi.h" 9 | #include "espconn.h" 10 | #include "commonservices.h" 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #define PORT 7777 18 | 19 | #define procTaskPrio 0 20 | #define procTaskQueueLen 1 21 | 22 | static volatile os_timer_t some_timer; 23 | 24 | 25 | //int ICACHE_FLASH_ATTR StartMDNS(); 26 | 27 | void user_rf_pre_init(void) 28 | { 29 | //nothing. 30 | } 31 | 32 | char * strcat( char * dest, char * src ) 33 | { 34 | return strcat(dest, src ); 35 | } 36 | 37 | //Tasks that happen all the time. 38 | 39 | os_event_t procTaskQueue[procTaskQueueLen]; 40 | 41 | 42 | //Awkward example with use of control messages to get data to/from device. 43 | uint8_t user_control[144]; //Enough for FW######## ### [128 bytes of data] [null] 44 | int user_control_length_acc; //From host to us. 45 | int user_control_length_ret; //From us to host. 46 | 47 | 48 | void usb_handle_custom_control( int bmRequestType, int bRequest, int wLength, struct usb_internal_state_struct * ist ) 49 | { 50 | struct usb_endpoint * e = ist->ce; 51 | 52 | if( bmRequestType == 0x80 ) 53 | { 54 | if( bRequest == 0xa7) //US TO HOST "in" 55 | { 56 | if( user_control_length_ret ) 57 | { 58 | e->ptr_in = user_control; 59 | e->size_in = user_control_length_ret; 60 | if( wLength < e->size_in ) e->size_in = wLength; 61 | user_control_length_ret = 0; 62 | } 63 | } 64 | } 65 | 66 | if( bmRequestType == 0x00 ) 67 | { 68 | if( bRequest == 0xa6 && user_control_length_acc == 0 ) //HOST TO US "out" 69 | { 70 | e->ptr_out = user_control; 71 | e->max_size_out = sizeof( user_control ); 72 | if( e->max_size_out > wLength ) e->max_size_out = wLength; 73 | e->got_size_out = 0; 74 | e->transfer_done_ptr = &user_control_length_acc; 75 | } 76 | 77 | } 78 | 79 | } 80 | 81 | uint8_t my_ep1[4]; 82 | uint8_t my_ep2[8]; 83 | extern uint32_t usb_ramtable[31]; 84 | 85 | extern int keybt; 86 | extern int keymod; 87 | extern int keypress; 88 | 89 | 90 | static void ICACHE_FLASH_ATTR procTask(os_event_t *events) 91 | { 92 | struct usb_internal_state_struct * uis = &usb_internal_state; 93 | struct usb_endpoint * e2 = &uis->eps[2]; 94 | 95 | e2->ptr_in = my_ep2; 96 | e2->place_in = 0; 97 | e2->size_in = sizeof( my_ep2 ); 98 | if( keypress && e2->send == 0 ) 99 | { 100 | my_ep2[0] = keymod; 101 | my_ep2[2] = keybt; 102 | e2->send = 1; 103 | keypress = 0; 104 | } 105 | 106 | CSTick( 0 ); 107 | 108 | if( user_control_length_acc ) 109 | { 110 | //printf( "\nGot: %s\n", usb_internal_state.user_control ); 111 | int r = issue_command( user_control, sizeof( user_control )-1, user_control, user_control_length_acc ); 112 | user_control_length_acc = 0; 113 | //printf( "%d/%s/%d\n", usb_internal_state.user_control_length_acc, usb_internal_state.user_control, r ); 114 | if( r >= 0 ) 115 | user_control_length_ret = r; 116 | } 117 | 118 | system_os_post(procTaskPrio, 0, 0 ); 119 | } 120 | 121 | 122 | //Timer event. 123 | static void ICACHE_FLASH_ATTR myTimer(void *arg) 124 | { 125 | #if 0 126 | struct usb_internal_state_struct * uis = &usb_internal_state; 127 | struct usb_endpoint * e1 = &uis->eps[1]; 128 | struct usb_endpoint * e2 = &uis->eps[2]; 129 | 130 | int i; 131 | 132 | //Send mouse and keyboard commands 133 | //my_ep1[0] ^= _BV(1); // _BV(x) ((1<<(x)) 134 | // my_ep1[1] = 1; //X offset 135 | // my_ep1[2] = 1; //Y offset 136 | //[0] == Button Bitmask ( _BV(0) == the Left button ) 137 | //[1] == The X offset 138 | //[2] == The Y offset 139 | //[3] == ? 140 | 141 | 142 | // my_ep2[2] ^= 8; //Keyboard 143 | 144 | printf( "%d\n", e1->send ); 145 | 146 | e1->ptr_in = my_ep1; 147 | e1->place_in = 0; 148 | e1->size_in = sizeof( my_ep1 ); 149 | e1->send = 1; 150 | 151 | e2->ptr_in = my_ep2; 152 | e2->place_in = 0; 153 | e2->size_in = sizeof( my_ep2 ); 154 | e2->send = 1; 155 | #endif 156 | 157 | CSTick( 1 ); 158 | } 159 | 160 | 161 | void ICACHE_FLASH_ATTR charrx( uint8_t c ) 162 | { 163 | //Called from UART. 164 | } 165 | 166 | 167 | volatile uint32_t my_table[] = { 0, (uint32_t)&PIN_IN, (uint32_t)&PIN_OUT_SET, (uint32_t)&PIN_OUT_CLEAR, 0xffff0000, 0x0000ffff }; 168 | 169 | 170 | 171 | #ifdef PROFILE 172 | int time_ccount(void) 173 | { 174 | unsigned r; 175 | 176 | /* volatile unsigned a = 0xabcdef01; 177 | asm volatile ("testp:"); 178 | a &= ~(1<<10); 179 | */ 180 | 181 | asm volatile ("\ 182 | \n\ 183 | \ 184 | intrs: \ 185 | call0 my_func\n\ 186 | j end\n\ 187 | \n\ 188 | end:\n\ 189 | \ 190 | \n\ 191 | sub %[out], a11, a9\n\ 192 | " : [out] "=r"(r) : : "a9", "a10", "a11" ); 193 | 194 | return r; //rsr a9, ccount //rsr a11, ccount 195 | // addi %[out], %[out], -1\n\ 196 | } 197 | #endif 198 | 199 | void user_rf_cal_sector_set() 200 | { 201 | } 202 | 203 | void ICACHE_FLASH_ATTR user_init(void) 204 | { 205 | uart_init(BIT_RATE_115200, BIT_RATE_115200); 206 | 207 | uart0_sendStr("\r\n\033c" ); //Clear screen 208 | uart0_sendStr("esp8266 test usb driver\r\n"); 209 | system_update_cpu_freq( 80 ); 210 | //#define PROFILE 211 | #ifdef PROFILE 212 | uint32_t k = 0x89abcdef; 213 | uint8_t * g = (uint8_t*)&k; 214 | system_update_cpu_freq(160); 215 | my_table[0] = 5; 216 | printf( "%02x %02x %02x %02x\n", g[0], g[1], g[2], g[3] ); 217 | uint32_t rr = time_ccount(); 218 | printf( ":::::%d / %02x / %d\n", rr, rr, my_table[0] ); 219 | system_restart(); 220 | while(1); 221 | #endif 222 | 223 | //Print reboot cause 224 | 225 | struct rst_info * r = system_get_rst_info(); 226 | printf( "Reason: %p\n", r->reason ); 227 | printf( "Exec : %p\n", r->exccause ); 228 | printf( "epc1 : %p\n", r->epc1 ); 229 | printf( "epc2 : %p\n", r->epc2 ); 230 | printf( "epc3 : %p\n", r->epc3 ); 231 | printf( "excvaddr:%p\n", r->excvaddr ); 232 | printf( "depc: %p\n", r->depc ); 233 | 234 | 235 | 236 | //Uncomment this to force a system restore. 237 | // system_restore(); 238 | 239 | CSSettingsLoad( 0 ); 240 | CSPreInit(); 241 | 242 | //Create additional socket, etc. here. 243 | 244 | CSInit(); 245 | 246 | //Set GPIO16 for INput 247 | WRITE_PERI_REG(PAD_XPD_DCDC_CONF, 248 | (READ_PERI_REG(PAD_XPD_DCDC_CONF) & 0xffffffbc) | (uint32)0x1); // mux configuration for XPD_DCDC and rtc_gpio0 connection 249 | 250 | WRITE_PERI_REG(RTC_GPIO_CONF, 251 | (READ_PERI_REG(RTC_GPIO_CONF) & (uint32)0xfffffffe) | (uint32)0x0); //mux configuration for out enable 252 | 253 | WRITE_PERI_REG(RTC_GPIO_ENABLE, 254 | READ_PERI_REG(RTC_GPIO_ENABLE) & (uint32)0xfffffffe); //out disable 255 | 256 | SetServiceName( "espusb" ); 257 | AddMDNSName( "esp82xx" ); 258 | AddMDNSName( "espusb" ); 259 | AddMDNSService( "_http._tcp", "An ESP8266 Webserver", 80 ); 260 | AddMDNSService( "_esp82xx._udp", "ESP8266 Backend", 7878 ); 261 | 262 | //Add a process 263 | system_os_task(procTask, procTaskPrio, procTaskQueue, procTaskQueueLen); 264 | 265 | //Timer example 266 | os_timer_disarm(&some_timer); 267 | os_timer_setfn(&some_timer, (os_timer_func_t *)myTimer, NULL); 268 | os_timer_arm(&some_timer, SLOWTICK_MS, 1); 269 | 270 | printf( "Boot Ok.\n" ); 271 | 272 | usb_init(); 273 | 274 | wifi_set_sleep_type(LIGHT_SLEEP_T); 275 | wifi_fpm_set_sleep_type(LIGHT_SLEEP_T); 276 | 277 | system_os_post(procTaskPrio, 0, 0 ); 278 | } 279 | 280 | 281 | //There is no code in this project that will cause reboots if interrupts are disabled. 282 | void EnterCritical() 283 | { 284 | } 285 | 286 | void ExitCritical() 287 | { 288 | } 289 | 290 | 291 | -------------------------------------------------------------------------------- /web/Makefile: -------------------------------------------------------------------------------- 1 | ../esp82xx/web/Makefile -------------------------------------------------------------------------------- /web/execute_reflash.c: -------------------------------------------------------------------------------- 1 | ../esp82xx/web/execute_reflash.c -------------------------------------------------------------------------------- /web/md5.c: -------------------------------------------------------------------------------- 1 | ../esp82xx/web/md5.c -------------------------------------------------------------------------------- /web/md5.h: -------------------------------------------------------------------------------- 1 | ../esp82xx/web/md5.h -------------------------------------------------------------------------------- /web/mfsmaker.c: -------------------------------------------------------------------------------- 1 | ../esp82xx/web/mfsmaker.c -------------------------------------------------------------------------------- /web/page/index.html: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | esp8266 USB controller 6 | 7 | 8 | 9 | 10 | 11 | 22 | 23 | 24 |

esp8266 ESPUSB controller

25 |
26 | 27 | 28 | 29 | 30 | 31 | 39 | 40 | 87 | 88 | 89 | 93 | 94 | 95 | 96 | 97 | 98 | 99 |

Copyright (C) 2015-2016 <>< Charles Lohr, See LICENSE file for more info.

100 |
...
101 | 102 | 103 | 104 | 105 | -------------------------------------------------------------------------------- /web/page/jquery-2.1.4.min.js.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/me-no-dev/espusb/e8650363233c4eeff3903f00222ea718ba8b819d/web/page/jquery-2.1.4.min.js.gz -------------------------------------------------------------------------------- /web/page/main.js: -------------------------------------------------------------------------------- 1 | //Copyright (C) 2015 <>< Charles Lohr, see LICENSE file for more info. 2 | // 3 | //This particular file may be licensed under the MIT/x11, New BSD or ColorChord Licenses. 4 | 5 | function KickHID() 6 | { 7 | } 8 | 9 | var lastMouseX; 10 | var lastMouseY; 11 | var TimeLastUp, TimeLastDown; 12 | var ButtonsDown = 0; 13 | 14 | var UpTimeout; 15 | 16 | 17 | function HandleUpDown( button, down ) 18 | { 19 | var Mask = 1<?"; 67 | var usblookup = { 68 | 0x08 : 0x2A, // BACKSPACE 69 | 0x09 : 0x2B, // TAB 70 | 0x0C : 0x28, // also [enter] (may not be needed) 71 | 0x0D : 0x28, // ENTER 72 | 0x10 : 0xE1, // SHIFT 73 | 0x11 : 0xE0, // CTRL 74 | 0x12 : 0xE2, // ALT 75 | 0x14 : 0x39, // CAPS 76 | 0x1B : 0x29, 77 | 0x20 : 0x2C, 78 | 0xAD : 0x7F, // MUTE 79 | } 80 | var s1 = "abcdefghijklmnopqrstuvwxyz1234567890"; 81 | var s2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()"; 82 | for (var c = 0; c < 36; c++) { 83 | usblookup[s1[c].charCodeAt(0)] = c + 4; 84 | usblookup[s2[c].charCodeAt(0)] = c + 4; 85 | } 86 | var s1 = "-=[]\\ ;'`,./"; 87 | var s2 = "_+{}| :\"~<>?"; 88 | for (var c = 0; c < 12; c++) { 89 | if (c == 5) continue; // Skip over american-only hash-tilde, since that will mess with the non-american 3-hash and grave-tilde keys. 90 | usblookup[s1[c].charCodeAt(0)] = c + 0x2D; 91 | usblookup[s2[c].charCodeAt(0)] = c + 0x2D; 92 | } 93 | //TODO: This would mask regular ASCII 94 | //for (var c = 0; c < 12; c++) { // F1 .. F12 95 | // usblookup[c + 0x70] = c + 0x3A; 96 | //} 97 | //for (var c = 0; c < 12; c++) { // F13 .. F24 98 | // usblookup[c + /* TODO: Figure out keycode for F13 */] = c + 0x68; 99 | //} 100 | // TODO: Numpad 101 | 102 | function KeyModifiers() 103 | { 104 | var mod = 0; 105 | for( var i = 0; i < 4; i++ ) 106 | { 107 | if( $("#mod"+i).is(":checked") ) mod |= 1<= 0) modifier |= 2; 181 | let id = usblookup[char.charCodeAt(0)]; 182 | if (id === undefined) return; 183 | $("#typed").text(($("#typed").text() + char).slice(-50)); 184 | $("#codes").text(($("#codes").text() + " " + ("0"+id.toString(16)).slice(-2)).slice(-50)) 185 | keyops.push("CK" + modifier + "\t" + id); 186 | keyops.push("CK" + KeyboardModifiers + "\t0"); 187 | }); 188 | } 189 | 190 | function AttachMouseListener() 191 | { 192 | $("#MouseCap").on("touchstart", function(event) { 193 | event.preventDefault(); 194 | var e = event.originalEvent.changedTouches[0]; 195 | lastMouseX = e.clientX; 196 | lastMouseY = e.clientY; 197 | MouseUpDown( true ); 198 | }); 199 | 200 | $("#MouseCap").on("touchend", function(event) { 201 | event.preventDefault(); 202 | var e = event.originalEvent.changedTouches[0]; 203 | lastMouseX = e.clientX; 204 | lastMouseY = e.clientY; 205 | MouseUpDown( false ); 206 | }); 207 | 208 | $("#MouseCap").on("touchmove", function(event) { 209 | event.preventDefault(); 210 | var e = event.originalEvent.changedTouches[0]; 211 | DeltaMouse( e.clientX - lastMouseX, e.clientY - lastMouseY ); 212 | lastMouseX = e.clientX; 213 | lastMouseY = e.clientY; 214 | return false; 215 | }); 216 | 217 | //This is for desktop mice. 218 | for( var b = 0; b < 3; b++ ) 219 | { 220 | let ths = b; //Thank you, Mortiz from youtube live chat!!! 221 | $("#Mouse"+b).on("mouseup", function(event) { HandleUpDown( ths, 0 ); } ); 222 | $("#Mouse"+b).on("mousedown", function(event) { HandleUpDown( ths, 1 ); } ); 223 | $("#Mouse"+b).on("touchend", function(event) { HandleUpDown( ths, 0 ); } ); 224 | $("#Mouse"+b).on("touchstart", function(event) { HandleUpDown( ths, 1 ); } ); 225 | } 226 | 227 | console.log( "Attaching." ); 228 | } 229 | 230 | window.addEventListener("load", AttachMouseListener, false); 231 | 232 | -------------------------------------------------------------------------------- /web/pushtodev.c: -------------------------------------------------------------------------------- 1 | ../esp82xx/web/pushtodev.c --------------------------------------------------------------------------------