ME11C Sample Code in Maxim Integrated Team

Dependencies:   BMI160 max32630hsp3 MemoryLCD USBDevice

Fork of Host_Software_MAX32664GWEC_SpO2_HR-_EXTE by Seyhmus Cacina

Committer:
seyhmuscacina
Date:
Mon Mar 25 07:56:34 2019 +0000
Revision:
2:3b5d2467e6c7
Parent:
0:b259fd1a88f5
Fork the repository

Who changed what in which revision?

UserRevisionLine numberNew contents of line
seyhmus.cacina 0:b259fd1a88f5 1 /*
seyhmus.cacina 0:b259fd1a88f5 2 * bootldrInterface.h
seyhmus.cacina 0:b259fd1a88f5 3 *
seyhmus.cacina 0:b259fd1a88f5 4 * Created on: Feb 7, 2019
seyhmus.cacina 0:b259fd1a88f5 5 * Author: Yagmur.Gok
seyhmus.cacina 0:b259fd1a88f5 6 */
seyhmus.cacina 0:b259fd1a88f5 7
seyhmus.cacina 0:b259fd1a88f5 8 #ifndef SOURCE_CMDUI_BOOTLDRINTERFACE_H_
seyhmus.cacina 0:b259fd1a88f5 9 #define SOURCE_CMDUI_BOOTLDRINTERFACE_H_
seyhmus.cacina 0:b259fd1a88f5 10
seyhmus.cacina 0:b259fd1a88f5 11 typedef int (*cmdExecFunc)( const char*); // typedef void (*cmdExecFunc)( const void*);
seyhmus.cacina 0:b259fd1a88f5 12
seyhmus.cacina 0:b259fd1a88f5 13 typedef struct {
seyhmus.cacina 0:b259fd1a88f5 14 char const* cmdStr;
seyhmus.cacina 0:b259fd1a88f5 15 cmdExecFunc execute;
seyhmus.cacina 0:b259fd1a88f5 16 char const *help;
seyhmus.cacina 0:b259fd1a88f5 17 }cmd_interface_tb;
seyhmus.cacina 0:b259fd1a88f5 18
seyhmus.cacina 0:b259fd1a88f5 19 #define FLASH_ERR_GENERAL -1
seyhmus.cacina 0:b259fd1a88f5 20 #define FLASH_ERR_CHECKSUM -2
seyhmus.cacina 0:b259fd1a88f5 21 #define FLASH_ERR_AUTH -3
seyhmus.cacina 0:b259fd1a88f5 22
seyhmus.cacina 0:b259fd1a88f5 23 /**
seyhmus.cacina 0:b259fd1a88f5 24 * @brief sets the SENSOR HUB to Bootloader Mode for Firmware update. Prints status info on command console
seyhmus.cacina 0:b259fd1a88f5 25 *
seyhmus.cacina 0:b259fd1a88f5 26 * @param[in] null_arg : NULL string, just to match the form of command table function pointer type
seyhmus.cacina 0:b259fd1a88f5 27 *
seyhmus.cacina 0:b259fd1a88f5 28 * @return status info, 0x00 on success.
seyhmus.cacina 0:b259fd1a88f5 29 **/
seyhmus.cacina 0:b259fd1a88f5 30 int SH_BOOTLDR_enter_blmode(const char *null_arg);
seyhmus.cacina 0:b259fd1a88f5 31
seyhmus.cacina 0:b259fd1a88f5 32 /**
seyhmus.cacina 0:b259fd1a88f5 33 * @brief exits the SENSOR HUB from Bootloader Mode to Application Mode. Prints status info on command console
seyhmus.cacina 0:b259fd1a88f5 34 *
seyhmus.cacina 0:b259fd1a88f5 35 * @param[in] null_arg : NULL string, just to match the form of command table function pointer type
seyhmus.cacina 0:b259fd1a88f5 36 *
seyhmus.cacina 0:b259fd1a88f5 37 * @return status info, 0x00 on success.
seyhmus.cacina 0:b259fd1a88f5 38 **/
seyhmus.cacina 0:b259fd1a88f5 39 int SH_BOOTLDR_exit_blmode(const char *null_arg);
seyhmus.cacina 0:b259fd1a88f5 40
seyhmus.cacina 0:b259fd1a88f5 41 /**
seyhmus.cacina 0:b259fd1a88f5 42 * @brief gets the page size of bootloader within SENSOR HUB. Prints status info and page size value on command console
seyhmus.cacina 0:b259fd1a88f5 43 *
seyhmus.cacina 0:b259fd1a88f5 44 * @param[in] null_arg : NULL string, just to match the form of command table function pointer type
seyhmus.cacina 0:b259fd1a88f5 45 *
seyhmus.cacina 0:b259fd1a88f5 46 * @return status info, 0x00 on success.
seyhmus.cacina 0:b259fd1a88f5 47 **/
seyhmus.cacina 0:b259fd1a88f5 48 int SH_BOOTLDR_get_pagesz(const char *null_arg);
seyhmus.cacina 0:b259fd1a88f5 49
seyhmus.cacina 0:b259fd1a88f5 50 /**
seyhmus.cacina 0:b259fd1a88f5 51 * @brief sets the totatl page count for MSBL file to be uploaded to SENSOR HUB. Prints status info on command console
seyhmus.cacina 0:b259fd1a88f5 52 *
seyhmus.cacina 0:b259fd1a88f5 53 * @param[in] arg : byte string including command followed by page size value extracted from header of MSBL file in DECIMAL format!
seyhmus.cacina 0:b259fd1a88f5 54 * "num_pages 24"
seyhmus.cacina 0:b259fd1a88f5 55 *
seyhmus.cacina 0:b259fd1a88f5 56 * @return status info, 0x00 on success.
seyhmus.cacina 0:b259fd1a88f5 57 **/
seyhmus.cacina 0:b259fd1a88f5 58 int SH_BOOTLDR_set_pagecount(const char *arg);
seyhmus.cacina 0:b259fd1a88f5 59
seyhmus.cacina 0:b259fd1a88f5 60 /**
seyhmus.cacina 0:b259fd1a88f5 61 * @brief sets the IV vector of MSBL file to be uploaded to SENSOR HUB. Prints status info on command console
seyhmus.cacina 0:b259fd1a88f5 62 * IV vector is 22 bytes of data extracted from header of MSBL file.
seyhmus.cacina 0:b259fd1a88f5 63 *
seyhmus.cacina 0:b259fd1a88f5 64 * @param[in] arg : byte string including command followed by 22 byte IV value in HEXADECIMAL format! do no preceed IV bytes wirh 0x !!!!
seyhmus.cacina 0:b259fd1a88f5 65 "set_iv 1234567891234567891234"
seyhmus.cacina 0:b259fd1a88f5 66 *
seyhmus.cacina 0:b259fd1a88f5 67 * @return status info, 0x00 on success.
seyhmus.cacina 0:b259fd1a88f5 68 **/
seyhmus.cacina 0:b259fd1a88f5 69 int SH_BOOTLDR_set_iv(const char *arg);
seyhmus.cacina 0:b259fd1a88f5 70
seyhmus.cacina 0:b259fd1a88f5 71 /**
seyhmus.cacina 0:b259fd1a88f5 72 * @brief sets the Authentication vector of MSBL file to be uploaded to SENSOR HUB. Prints status info on command console
seyhmus.cacina 0:b259fd1a88f5 73 * Authentication vector is 36 bytes of data extracted from header of MSBL file.
seyhmus.cacina 0:b259fd1a88f5 74 *
seyhmus.cacina 0:b259fd1a88f5 75 * @param[in] arg : byte string including command followed by 22 byte IV value in HEXADECIMAL format! do no preceed IV bytes wirh 0x !!!!
seyhmus.cacina 0:b259fd1a88f5 76 "set_auth 12345678912345678912345678912345"
seyhmus.cacina 0:b259fd1a88f5 77 *
seyhmus.cacina 0:b259fd1a88f5 78 * @return status info, 0x00 on success.
seyhmus.cacina 0:b259fd1a88f5 79 **/
seyhmus.cacina 0:b259fd1a88f5 80 int SH_BOOTLDR_set_authentication(const char *arg);
seyhmus.cacina 0:b259fd1a88f5 81
seyhmus.cacina 0:b259fd1a88f5 82 /**
seyhmus.cacina 0:b259fd1a88f5 83 * @brief erases application code of SENSOR HUB. Prints status info on command console
seyhmus.cacina 0:b259fd1a88f5 84 *
seyhmus.cacina 0:b259fd1a88f5 85 * @param[in] null_arg : NULL string, just to match the form of command table function pointer type
seyhmus.cacina 0:b259fd1a88f5 86 *
seyhmus.cacina 0:b259fd1a88f5 87 * @return status info, 0x00 on success.
seyhmus.cacina 0:b259fd1a88f5 88 **/
seyhmus.cacina 0:b259fd1a88f5 89 int SH_BOOTLDR_eraseflash(const char *null_arg);
seyhmus.cacina 0:b259fd1a88f5 90
seyhmus.cacina 0:b259fd1a88f5 91 /**
seyhmus.cacina 0:b259fd1a88f5 92 * @brief puts the SENSOR HUB to the state of waiting for MSBL application code pages from serial command interface.
seyhmus.cacina 0:b259fd1a88f5 93 * Prints status info on command console upon flashing of every page.
seyhmus.cacina 0:b259fd1a88f5 94 *
seyhmus.cacina 0:b259fd1a88f5 95 * @param[in] null_arg : NULL string, just to match the form of command table function pointer type
seyhmus.cacina 0:b259fd1a88f5 96 *
seyhmus.cacina 0:b259fd1a88f5 97 * @return status info, 0x00 on success.
seyhmus.cacina 0:b259fd1a88f5 98 **/
seyhmus.cacina 0:b259fd1a88f5 99 int SH_BOOTLDR_flash(const char *null_arg);
seyhmus.cacina 0:b259fd1a88f5 100
seyhmus.cacina 0:b259fd1a88f5 101 /**
seyhmus.cacina 0:b259fd1a88f5 102 * @brief sets the SENSOR HUB to the bootloader state where application image pages are first stored into HOST ram and will be flashed
seyhmus.cacina 0:b259fd1a88f5 103 * at once. Prints status info on command console.
seyhmus.cacina 0:b259fd1a88f5 104 *
seyhmus.cacina 0:b259fd1a88f5 105 * @param[in] arg : byte string including command followed by 1 byte omage on ram flag in DECIMAL format
seyhmus.cacina 0:b259fd1a88f5 106 * "image_on_ram 0/1" 0: for classic mode where pages are downloaded form PC over serial command console and
seyhmus.cacina 0:b259fd1a88f5 107 * flashed to SENSOR HUB 1 by 1. 1: for image on ram mode.
seyhmus.cacina 0:b259fd1a88f5 108 *
seyhmus.cacina 0:b259fd1a88f5 109 * @return status info, 0x00 on success.
seyhmus.cacina 0:b259fd1a88f5 110 **/
seyhmus.cacina 0:b259fd1a88f5 111 int SH_BOOTLOADER_image_on_ram( const char *arg );
seyhmus.cacina 0:b259fd1a88f5 112
seyhmus.cacina 0:b259fd1a88f5 113 /**
seyhmus.cacina 0:b259fd1a88f5 114 * @brief flashes pages in HOST Ram to Sensor Hub.
seyhmus.cacina 0:b259fd1a88f5 115 * USE ONLY IN IMAGE_ON_RAM MODE !!!!
seyhmus.cacina 0:b259fd1a88f5 116 *
seyhmus.cacina 0:b259fd1a88f5 117 * @param[in] null_arg : NULL string, just to match the form of command table function pointer type
seyhmus.cacina 0:b259fd1a88f5 118 *
seyhmus.cacina 0:b259fd1a88f5 119 * @return status info, 0x00 on success.
seyhmus.cacina 0:b259fd1a88f5 120 **/
seyhmus.cacina 0:b259fd1a88f5 121 int SH_BOOTLDR_flash_appimage_from_ram(const char *null_arg);
seyhmus.cacina 0:b259fd1a88f5 122
seyhmus.cacina 0:b259fd1a88f5 123 /**
seyhmus.cacina 0:b259fd1a88f5 124 * @brief set the delay factor multipler for Bootloader wait durations in commands and between flashing of pages
seyhmus.cacina 0:b259fd1a88f5 125 *
seyhmus.cacina 0:b259fd1a88f5 126 * @param[in] arg : byte string including command followed by delay factor in DECIMAL format
seyhmus.cacina 0:b259fd1a88f5 127 * "set_cfg host cdf 1" to "set_cfg host cdf 4" practical range. 1 is default.
seyhmus.cacina 0:b259fd1a88f5 128 *
seyhmus.cacina 0:b259fd1a88f5 129 * @return status info, 0x00 on success.
seyhmus.cacina 0:b259fd1a88f5 130 **/
seyhmus.cacina 0:b259fd1a88f5 131 int SH_BOOTLDR_set_host_bootcmds_delay_factor( const char *arg);
seyhmus.cacina 0:b259fd1a88f5 132
seyhmus.cacina 0:b259fd1a88f5 133 /**
seyhmus.cacina 0:b259fd1a88f5 134 * @brief get the delay factor multipler for Bootloader wait durations in commands and between flashing of pages.
seyhmus.cacina 0:b259fd1a88f5 135 * Prints delay factor multipler value on command console.
seyhmus.cacina 0:b259fd1a88f5 136 *
seyhmus.cacina 0:b259fd1a88f5 137 * @param[in] null_arg : NULL string, just to match the form of command table function pointer type
seyhmus.cacina 0:b259fd1a88f5 138 *
seyhmus.cacina 0:b259fd1a88f5 139 * @return status info, 0x00 on success.
seyhmus.cacina 0:b259fd1a88f5 140 **/
seyhmus.cacina 0:b259fd1a88f5 141 int SH_BOOTLDR_get_host_bootcmds_delay_factor( const char *null_arg);
seyhmus.cacina 0:b259fd1a88f5 142
seyhmus.cacina 0:b259fd1a88f5 143 /**
seyhmus.cacina 0:b259fd1a88f5 144 * @brief sets the resetting method of SENSOR HUB between command based and GPIO based resets. Default is GPIO based reset.ie 1.
seyhmus.cacina 0:b259fd1a88f5 145 *
seyhmus.cacina 0:b259fd1a88f5 146 * @param[in] arg : byte string including command followed by ebl mode in DECIMAL format
seyhmus.cacina 0:b259fd1a88f5 147 * "set_cfg host ebl 1/0" . 0 for command based reset; 1 for GPIO based reset which is default and preferred option.
seyhmus.cacina 0:b259fd1a88f5 148 *
seyhmus.cacina 0:b259fd1a88f5 149 * @return status info, 0x00 on success.
seyhmus.cacina 0:b259fd1a88f5 150 **/
seyhmus.cacina 0:b259fd1a88f5 151 int SH_BOOTLDR_set_host_ebl_mode(const char *arg);
seyhmus.cacina 0:b259fd1a88f5 152
seyhmus.cacina 0:b259fd1a88f5 153 /**
seyhmus.cacina 0:b259fd1a88f5 154 * @brief gets the resetting method of SENSOR HUB between command based and GPIO based resets.
seyhmus.cacina 0:b259fd1a88f5 155 * Prints delay factor multipler value on command console.
seyhmus.cacina 0:b259fd1a88f5 156 *
seyhmus.cacina 0:b259fd1a88f5 157 * @param[in] null_arg : NULL string, just to match the form of command table function pointer type
seyhmus.cacina 0:b259fd1a88f5 158 *
seyhmus.cacina 0:b259fd1a88f5 159 * @return status info, 0x00 on success.
seyhmus.cacina 0:b259fd1a88f5 160 **/
seyhmus.cacina 0:b259fd1a88f5 161 int SH_BOOTLDR_get_host_ebl_mode(const char *null_arg);
seyhmus.cacina 0:b259fd1a88f5 162
seyhmus.cacina 0:b259fd1a88f5 163 /**
seyhmus.cacina 0:b259fd1a88f5 164 * @brief gets the struct keeping state information about bootloading steps required at HOST side.
seyhmus.cacina 0:b259fd1a88f5 165 * Prints struct data fields and state flags; ie. is_iv_set? page_size acquired from hub etc.
seyhmus.cacina 0:b259fd1a88f5 166 * If all steps are not done, flashing operation do not take place and informs user on command
seyhmus.cacina 0:b259fd1a88f5 167 * console
seyhmus.cacina 0:b259fd1a88f5 168 *
seyhmus.cacina 0:b259fd1a88f5 169 * @param[in] null_arg : NULL string, just to match the form of command table function pointer type
seyhmus.cacina 0:b259fd1a88f5 170 *
seyhmus.cacina 0:b259fd1a88f5 171 * @return status info, 0x00 on success.
seyhmus.cacina 0:b259fd1a88f5 172 **/
seyhmus.cacina 0:b259fd1a88f5 173 int BOOTLDR_get_host_bootloader_state(const char *null_arg);
seyhmus.cacina 0:b259fd1a88f5 174
seyhmus.cacina 0:b259fd1a88f5 175
seyhmus.cacina 0:b259fd1a88f5 176 #define NUMCMDSBOOTLDRAPI (15)
seyhmus.cacina 0:b259fd1a88f5 177
seyhmus.cacina 0:b259fd1a88f5 178 const cmd_interface_tb CMDTABLEBOOTLDR[] = {
seyhmus.cacina 0:b259fd1a88f5 179
seyhmus.cacina 0:b259fd1a88f5 180 { "bootldr" , SH_BOOTLDR_enter_blmode , "resets and puts sensor hub to bootloader mode " },
seyhmus.cacina 0:b259fd1a88f5 181 { "exit" , SH_BOOTLDR_exit_blmode , "exits sensor hub from bootloader mode to app mode" },
seyhmus.cacina 0:b259fd1a88f5 182 { "page_size" , SH_BOOTLDR_get_pagesz , "returns sensor hub bootloader page size for app data pages" },
seyhmus.cacina 0:b259fd1a88f5 183 { "num_pages" , SH_BOOTLDR_set_pagecount , "sets sensor hub bootloader app image pages, uasge: num_pages PAGES" },
seyhmus.cacina 0:b259fd1a88f5 184 { "set_iv" , SH_BOOTLDR_set_iv , "sets sensor hub bootloader initial vector bytes, usage: set_iv XXXXXXXXXXX (11 hex chrs)" },
seyhmus.cacina 0:b259fd1a88f5 185 { "set_auth" , SH_BOOTLDR_set_authentication , "sets sensor hub bootloader authentication bytes, usage: set_iv XXXXXXXXXXXXXXXX (16 hex chrs)" },
seyhmus.cacina 0:b259fd1a88f5 186 { "erase" , SH_BOOTLDR_eraseflash , "erases sesn hub application flash memory" },
seyhmus.cacina 0:b259fd1a88f5 187 { "image_on_ram" , SH_BOOTLOADER_image_on_ram , "selects pagBypage download-flash / block download-flash options" },
seyhmus.cacina 0:b259fd1a88f5 188 { "flash" , SH_BOOTLDR_flash , "flash image to hub/dowload pages from PC based on image_on_ram selection" },
seyhmus.cacina 0:b259fd1a88f5 189 { "image_flash" , SH_BOOTLDR_flash_appimage_from_ram , "flashes app image in ram to sensor hub, call after flash cmd in image_on_ram mode" },
seyhmus.cacina 0:b259fd1a88f5 190 { "set_cfg host cdf" , SH_BOOTLDR_set_host_bootcmds_delay_factor , "sets delay factor for bootoader cmd waits default 1, usage: set_cfg host cdf FACTOR" },
seyhmus.cacina 0:b259fd1a88f5 191 { "set_cfg host ebl" , SH_BOOTLDR_set_host_ebl_mode , "sets GPIO/CMD reset for reset hub to bootoader mode. default GPIO, usage: set_cfg host ebl 1/0, 1 for GPIO" },
seyhmus.cacina 0:b259fd1a88f5 192 { "get_cfg host cdf" , SH_BOOTLDR_get_host_bootcmds_delay_factor , "sets delay factor for bootoader cmd waits default 1, usage: set_cfg host cdf FACTOR" },
seyhmus.cacina 0:b259fd1a88f5 193 { "get_cfg host ebl" , SH_BOOTLDR_get_host_ebl_mode , "sets GPIO/CMD reset for reset hub to bootoader mode. default GPIO, usage: set_cfg host ebl 1/0, 1 for GPIO" },
seyhmus.cacina 0:b259fd1a88f5 194 { "get_host_boot_state_info" , BOOTLDR_get_host_bootloader_state , "gets boot state keeping struct of host" },
seyhmus.cacina 0:b259fd1a88f5 195
seyhmus.cacina 0:b259fd1a88f5 196
seyhmus.cacina 0:b259fd1a88f5 197 };
seyhmus.cacina 0:b259fd1a88f5 198
seyhmus.cacina 0:b259fd1a88f5 199 #endif /* SOURCE_CMDUI_BOOTLDRINTERFACE_H_ */
seyhmus.cacina 0:b259fd1a88f5 200