proto.h

Go to the documentation of this file.
00001 #ifndef _PROTO_H_
00002 #define _PROTO_H_
00003 
00004 /*
00005  * File Name: proto.h
00006  */
00007 
00008 /*
00009  * This file is part of kbdupgrade.
00010  *
00011  * kbdupgrade is free software: you can redistribute it and/or modify
00012  * it under the terms of the GNU General Public License as published by
00013  * the Free Software Foundation, either version 2 of the License, or
00014  * (at your option) any later version.
00015  *
00016  * kbdupgrade is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00019  * GNU General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU General Public License
00022  * along with this program. If not, see <http://www.gnu.org/licenses/>.
00023  */
00024 
00025 /**
00026  * Copyright (C) 2008 iRex Technologies B.V.
00027  * All rights reserved.
00028  */
00029  
00030 
00031 //----------------------------------------------------------------------------
00032 // Include Files
00033 //----------------------------------------------------------------------------
00034 
00035 // system include files, between < >
00036 #include <stdint.h>
00037 
00038 
00039 //----------------------------------------------------------------------------
00040 // Macro Definitions
00041 //---------------------------------------------------------------------------- 
00042 
00043 
00044 //----------------------------------------------------------------------------
00045 // Forward Declarations
00046 //----------------------------------------------------------------------------
00047 
00048 
00049 //----------------------------------------------------------------------------
00050 // Type Declarations
00051 //----------------------------------------------------------------------------
00052 
00053 
00054 //---------------------------------------------------------------------------
00055 // Global Constant
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 // Public Functions
00115 //============================================================================
00116 
00117 // Message printing
00118 void fatalnum(int num, char *message, ...);
00119 void fatal(char *message, ...);
00120 void warning(char *message, ...);
00121 
00122 // Basic packets
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 // Firmware programming
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 // Device type
00136 int micro_read_devicetype(int mode);
00137 int micro_write_devicetype(int mode, int devtype);
00138 
00139 // Version & mode
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 // Gasgauge
00147 int gasgauge_get_versions(uint16_t *firmware, uint16_t *hardware);
00148 int gasgauge_flash(char *filename);
00149 
00150 // Open serial connection
00151 void port_open(char* name, int flags, int speed);
00152 
00153 
00154 #endif
Generated by  doxygen 1.6.2-20100208