Tuan PM / Mbed 2 deprecated esptool

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers esptool.h Source File

esptool.h

00001 #ifndef _ESPTOOL_H_
00002 #define _ESPTOOL_H_
00003 #include "mbed.h"
00004 #define ESP_FLASH_BEGIN  0x02
00005 #define ESP_FLASH_DATA   0x03
00006 #define ESP_FLASH_END    0x04
00007 #define ESP_MEM_BEGIN    0x05
00008 #define ESP_MEM_END      0x06
00009 #define ESP_MEM_DATA     0x07
00010 #define ESP_SYNC         0x08
00011 #define ESP_WRITE_REG    0x09
00012 #define ESP_READ_REG     0x0a
00013 
00014 //# Maximum block sized for RAM and Flash writes, respectively.
00015 #define ESP_RAM_BLOCK    0x1800
00016 #define ESP_FLASH_BLOCK  0x400
00017 
00018 //# Default baudrate. The ROM auto-bauds, so we can use more or less whatever we want.
00019 #define ESP_ROM_BAUD     115200
00020 
00021 //# First byte of the application image
00022 #define ESP_IMAGE_MAGIC  0xe9
00023 
00024 //# Initial state for the checksum routine
00025 #define ESP_CHECKSUM_MAGIC  0xef
00026 
00027 //# OTP ROM addresses
00028 #define ESP_OTP_MAC0     0x3ff00050
00029 #define ESP_OTP_MAC1     0x3ff00054
00030 
00031 //# Sflash stub: an assembly routine to read from spi flash and send to host
00032 #define SFLASH_STUB "\x80\x3c\x00\x40\x1c\x4b\x00\x40\x21\x11\x00\x40\x00\x80" \
00033                     "\xfe\x3f\xc1\xfb\xff\xd1\xf8\xff\x2d\x0d\x31\xfd\xff\x41\xf7\xff\x4a" \
00034                     "\xdd\x51\xf9\xff\xc0\x05\x00\x21\xf9\xff\x31\xf3\xff\x41\xf5\xff\xc0" \
00035                     "\x04\x00\x0b\xcc\x56\xec\xfd\x06\xff\xff\x00\x00"
00036 class ESPTOOL {
00037     
00038 public:
00039     ESPTOOL(Serial& serial, PinName pinEnable, PinName pinProgram)
00040 private:
00041     Serial& _serial;
00042     DigitalOut _pinEn, _pinPro;
00043     uint8_t read();
00044     void read(uint8_t *data, uint32_t len);
00045     void write(uint8_t *data, uint32_t len);
00046 }
00047 #endif