bootloader.h
Go to the documentation of this file.
00001 #pragma once
00002 #include <cstdint>
00003 
00004 // Header
00005 struct bootloader
00006 {
00007   constexpr bootloader(
00008     uint8_t target,
00009     uint8_t cmd)
00010     : header(0xFF)
00011     , target(target)
00012     , cmd(cmd)
00013   {
00014   }
00015 
00016   uint8_t header;
00017   uint8_t target;
00018   uint8_t cmd;
00019 } __attribute__((packed));
00020 
00021 // GET_INFO
00022 struct bootloaderGetInfoRequest
00023 {
00024   bootloaderGetInfoRequest(
00025     uint8_t target)
00026     : header(target, 0x10)
00027   {
00028   }
00029 
00030   bootloader header;
00031 } __attribute__((packed));
00032 
00033 struct bootloaderGetInfoResponse
00034 {
00035   bootloaderGetInfoRequest request;
00036   uint16_t pageSize;
00037   uint16_t nBuffPage;
00038   uint16_t nFlashPage;
00039   uint16_t flashStart;
00040   uint8_t reserved[12];
00041   uint8_t version;
00042 } __attribute__((packed));
00043 
00044 // GET_MAPPING
00045 
00046 // LOAD_BUFFER
00047 
00048 struct bootloaderLoadBufferRequest
00049 {
00050   bootloaderLoadBufferRequest(
00051     uint8_t target,
00052     uint16_t page,
00053     uint16_t address)
00054     : header(target, 0x14)
00055     , page(page)
00056     , address(address)
00057   {
00058   }
00059 
00060   bootloader header;
00061   uint16_t page;
00062   uint16_t address;
00063   uint8_t data[25];
00064 } __attribute__((packed));
00065 
00066 // READ_BUFFER
00067 
00068 struct bootloaderReadBufferRequest
00069 {
00070   bootloaderReadBufferRequest(
00071     uint8_t target,
00072     uint16_t page,
00073     uint16_t address)
00074     : header(target, 0x15)
00075     , page(page)
00076     , address(address)
00077   {
00078   }
00079 
00080   bootloader header;
00081   uint16_t page;
00082   uint16_t address;
00083 } __attribute__((packed));
00084 
00085 struct bootloaderReadBufferResponse
00086 {
00087   bootloaderReadBufferRequest request;
00088   uint8_t data[25];
00089 } __attribute__((packed));
00090 
00091 // WRITE_FLASH
00092 
00093 struct bootloaderWriteFlashRequest
00094 {
00095   bootloaderWriteFlashRequest(
00096     uint8_t target,
00097     uint16_t bufferPage,
00098     uint16_t flashPage,
00099     uint16_t nPages)
00100     : header(target, 0x18)
00101     , bufferPage(bufferPage)
00102     , flashPage(flashPage)
00103     , nPages(nPages)
00104   {
00105   }
00106 
00107   bootloader header;
00108   uint16_t bufferPage;
00109   uint16_t flashPage;
00110   uint16_t nPages;
00111 } __attribute__((packed));
00112 
00113 struct bootloaderWriteFlashResponse
00114 {
00115   bootloader header;
00116   uint8_t done;
00117   uint8_t error;
00118 } __attribute__((packed));
00119 
00120 // FLASH_STATUS
00121 
00122 struct bootloaderFlashStatusRequest
00123 {
00124   bootloaderFlashStatusRequest(
00125     uint8_t target)
00126     : header(target, 0x19)
00127   {
00128   }
00129 
00130   bootloader header;
00131 } __attribute__((packed));
00132 
00133 struct bootloaderFlashStatusResponse
00134 {
00135   bootloaderFlashStatusRequest request;
00136   uint8_t done;
00137   uint8_t error;
00138 } __attribute__((packed));
00139 
00140 // READ_FLASH
00141 
00142 struct bootloaderReadFlashRequest
00143 {
00144   bootloaderReadFlashRequest(
00145     uint8_t target,
00146     uint16_t page,
00147     uint16_t address)
00148     : header(target, 0x1C)
00149     , page(page)
00150     , address(address)
00151   {
00152   }
00153 
00154   bootloader header;
00155   uint16_t page;
00156   uint16_t address;
00157 } __attribute__((packed));
00158 
00159 struct bootloaderReadFlashResponse
00160 {
00161   bootloaderReadFlashRequest request;
00162   uint8_t data[25];
00163 } __attribute__((packed));
00164 
00165 // RESET_INIT
00166 
00167 struct bootloaderResetInitRequest
00168 {
00169   bootloaderResetInitRequest(
00170     uint8_t target)
00171     : header(target, 0xFF)
00172   {
00173   }
00174 
00175   bootloader header;
00176 } __attribute__((packed));
00177 
00178 struct bootloaderResetInitResponse
00179 {
00180   bootloaderResetInitRequest request;
00181   uint8_t addr[5];
00182 } __attribute__((packed));
00183 
00184 // RESET
00185 
00186 struct bootloaderResetRequest
00187 {
00188   bootloaderResetRequest(
00189     uint8_t target)
00190     : header(target, 0xF0)
00191   {
00192   }
00193 
00194   bootloader header;
00195   uint8_t bootToFirmware; //0=boot to bootloader; otherwise: boot to firmware
00196 } __attribute__((packed));
00197 
00198 /* no response sent */
00199 
00200 // ALLOFF
00201 
00202 struct bootloaderAllOffRequest
00203 {
00204   bootloaderAllOffRequest(
00205     uint8_t target)
00206     : header(target, 0x01)
00207   {
00208   }
00209 
00210   bootloader header;
00211 } __attribute__((packed));
00212 
00213 /* no response sent */
00214 
00215 // SYSOFF
00216 
00217 struct bootloaderSysOffRequest
00218 {
00219   bootloaderSysOffRequest(
00220     uint8_t target)
00221     : header(target, 0x02)
00222   {
00223   }
00224 
00225   bootloader header;
00226 } __attribute__((packed));
00227 
00228 /* no response sent */
00229 
00230 // SYSON
00231 
00232 struct bootloaderSysOnRequest
00233 {
00234   bootloaderSysOnRequest(
00235     uint8_t target)
00236     : header(target, 0x03)
00237   {
00238   }
00239 
00240   bootloader header;
00241 } __attribute__((packed));
00242 
00243 /* no response sent */
00244 
00245 // GETVBAT
00246 
00247 struct bootloaderGetVBatRequest
00248 {
00249   bootloaderGetVBatRequest(
00250     uint8_t target)
00251     : header(target, 0x04)
00252   {
00253   }
00254 
00255   bootloader header;
00256 } __attribute__((packed));
00257 
00258 struct bootloaderGetVBatResponse
00259 {
00260   bootloaderGetVBatRequest request;
00261   float vbat;
00262 } __attribute__((packed));


crazyflie_cpp
Author(s): Wolfgang Hoenig
autogenerated on Sun Oct 8 2017 02:47:59