shearwater_common.h (3339B)
1 /* 2 * libdivecomputer 3 * 4 * Copyright (C) 2013 Jef Driesen 5 * 6 * This library is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Lesser General Public 8 * License as published by the Free Software Foundation; either 9 * version 2.1 of the License, or (at your option) any later version. 10 * 11 * This library is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public 17 * License along with this library; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 19 * MA 02110-1301 USA 20 */ 21 22 #ifndef SHEARWATER_COMMON_H 23 #define SHEARWATER_COMMON_H 24 25 #include <libdivecomputer/iostream.h> 26 27 #include "device-private.h" 28 29 #ifdef __cplusplus 30 extern "C" { 31 #endif /* __cplusplus */ 32 33 #define WDBI_TIME_PACKET_SIZE 7 34 35 #define ID_SERIAL 0x8010 36 #define ID_FIRMWARE 0x8011 37 #define ID_LOGUPLOAD 0x8021 38 #define ID_HARDWARE 0x8050 39 40 #define ID_MODEL 0x8060 41 42 #define ID_TIME_LOCAL 0x9030 43 #define ID_TIME_UTC 0x9031 44 #define ID_TIME_OFFSET 0x9032 45 #define ID_TIME_DST 0x9033 46 47 #define PREDATOR 2 48 #define PETREL 3 49 /* PETREL2: Petrel 2 hardware reports ID_MODEL=PETREL (3); there is no 50 * distinct Product-Version value for it. FWID-based sub-model distinction 51 * is exposed via devinfo.hw_id on live download. */ 52 #define PETREL2 PETREL 53 #define NERD 4 54 #define PERDIX 5 55 #define PERDIXAI 6 56 #define NERD2 7 57 #define TERIC 8 58 #define PEREGRINE 9 59 #define PETREL3 10 60 #define PERDIX2 11 61 #define TERN 12 62 #define PEREGRINE_TX 13 63 #define PERDIX3 14 64 65 #define NSTEPS 10000 66 #define STEP(i,n) ((NSTEPS * (i) + (n) / 2) / (n)) 67 68 typedef struct shearwater_common_device_t { 69 dc_device_t base; 70 dc_iostream_t *iostream; 71 unsigned int protocol; 72 } shearwater_common_device_t; 73 74 dc_status_t 75 shearwater_common_setup (shearwater_common_device_t *device, dc_context_t *context, dc_iostream_t *iostream, unsigned int model); 76 77 dc_status_t 78 shearwater_common_transfer (shearwater_common_device_t *device, const unsigned char input[], unsigned int isize, unsigned char output[], unsigned int osize, unsigned int *actual); 79 80 dc_status_t 81 shearwater_common_download (shearwater_common_device_t *device, dc_buffer_t *buffer, unsigned int address, unsigned int size, unsigned int compression, dc_event_progress_t *progress); 82 83 dc_status_t 84 shearwater_common_rdbi (shearwater_common_device_t *device, unsigned int id, unsigned char data[], unsigned int size, unsigned int *actual); 85 86 dc_status_t 87 shearwater_common_wdbi (shearwater_common_device_t *device, unsigned int id, const unsigned char data[], unsigned int size); 88 89 dc_status_t 90 shearwater_common_timesync_local (shearwater_common_device_t *device, const dc_datetime_t *datetime); 91 92 dc_status_t 93 shearwater_common_timesync_utc (shearwater_common_device_t *device, const dc_datetime_t *datetime); 94 95 dc_status_t shearwater_common_can_wdbi (shearwater_common_device_t *device, dc_buffer_t *buffer, unsigned int id); 96 97 dc_status_t shearwater_common_device_timesync(dc_device_t *abstract, const dc_datetime_t *datetime); 98 99 #ifdef __cplusplus 100 } 101 #endif /* __cplusplus */ 102 #endif /* SHEARWATER_COMMON_H */