proto.h
Go to the documentation of this file.00001 #ifndef _PROTO_H_
00002 #define _PROTO_H_
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #include <stdint.h>
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058 #define IONKBD_START 0xC0
00059 #define IONKBD_ESC 0xDB
00060 #define IONKBD_ESC_START 0xDC
00061 #define IONKBD_ESC_ESC 0xDD
00062
00063 #define IONKBD_REQ_GET_STATUS 0x04
00064 #define IONKBD_REQ_SET_POWER 0x06
00065 #define IONKBD_REQ_SET_MODE 0x07
00066 #define IONKBD_REQ_GET_VERSION 0x08
00067 #define IONKBD_REQ_GET_BATTERY 0x0A
00068 #define IONKBD_REQ_ERASE_FLASH 0x0E
00069 #define IONKBD_REQ_PROGRAM_FLASH 0x0F
00070 #define IONKBD_REQ_READ_FLASH 0x10
00071 #define IONKBD_REQ_FLASH_GASGAUGE 0x13
00072 #define IONKBD_REQ_GET_GG_VERSION 0x14
00073 #define IONKBD_REQ_GET_DEVICETYPE 0x19
00074
00075 #define IONKBD_REQ_ERASE_FLASH_BOOT 0x1F
00076 #define IONKBD_REQ_PROGRAM_FLASH_BOOT 0x20
00077 #define IONKBD_REQ_READ_FLASH_BOOT 0x21
00078
00079 #define IONKBD_RESP_STATUS 0x40
00080 #define IONKBD_RESP_VERSION 0x41
00081 #define IONKBD_RESP_BATTERY 0x43
00082 #define IONKBD_RESP_ERASE 0x45
00083 #define IONKBD_RESP_FLASH 0x46
00084 #define IONKBD_RESP_READ 0x47
00085 #define IONKBD_RESP_GASGAUGE 0x4A
00086 #define IONKBD_RESP_GG_VERSION 0x4B
00087 #define IONKBD_RESP_DEVICETYPE 0x4E
00088
00089 #define GASGAUGE_INIT 0x00
00090 #define GASGAUGE_START 0x01
00091 #define GASGAUGE_SAVE_SETTINGS 0x02
00092 #define GASGAUGE_ERASE 0x03
00093 #define GASGAUGE_SETUP_ROW 0x04
00094 #define GASGAUGE_PROGRAM_ROW 0x05
00095 #define GASGAUGE_RESTORE_SETTINGS 0x06
00096 #define GASGAUGE_STOP 0x07
00097
00098 #define DR1000_APPL_ADDR_MIN 0x1800
00099 #define DR1000_APPL_ADDR_MAX 0xE000
00100
00101 #define DR800_APPL_ADDR_MIN 0xC000
00102 #define DR800_APPL_ADDR_MAX 0xE7FF
00103
00104 #define DR800_BOOT_ADDR_MIN 0xE800
00105 #define DR800_BOOT_ADDR_MAX 0xFFFF
00106
00107 #define DEVICETYPE_ADDR 0x1040
00108
00109 #define MODE_BOOT 0
00110 #define MODE_APP 1
00111
00112
00113
00114
00115
00116
00117
00118 void fatalnum(int num, char *message, ...);
00119 void fatal(char *message, ...);
00120 void warning(char *message, ...);
00121
00122
00123 void ionkbd_send_packet(uint8_t cmd, uint8_t length, uint8_t *data);
00124 int ionkbd_get_response(uint8_t *command, uint8_t *length, uint8_t *data);
00125 int ionkbd_send_request(uint8_t cmd, uint8_t length, uint8_t *data,
00126 uint8_t *rcmd, uint8_t *rlen, uint8_t *rdata);
00127
00128 int sector_erase(int mode, uint16_t addr);
00129 void micro_erase(int mode, uint16_t start, uint16_t end);
00130 int chunk_program(int mode, uint16_t addr, uint8_t len, uint8_t *chunk);
00131 int dr1000_micro_program_application(char* filename);
00132 int dr800_micro_program_application(char* filename);
00133 int dr800_micro_program_bootloader(char* filename);
00134
00135
00136 int micro_read_devicetype(int mode);
00137 int micro_write_devicetype(int mode, int devtype);
00138
00139
00140 int micro_check_battery_charge(uint16_t min_level);
00141 int micro_get_versions(uint16_t *bootloader, uint16_t *application);
00142 void micro_enter_mode(uint8_t boot);
00143 int micro_get_mode();
00144 void micro_get_devicetype(uint8_t *type);
00145
00146
00147 int gasgauge_get_versions(uint16_t *firmware, uint16_t *hardware);
00148 int gasgauge_flash(char *filename);
00149
00150
00151 void port_open(char* name, int flags, int speed);
00152
00153
00154 #endif