1 /* 2 OW -- One-Wire filesystem 3 version 0.4 7/2/2003 4 5 Written 2003 Paul H Alfille 6 Fuse code based on "fusexmp" {GPL} by Miklos Szeredi, mszeredi@inf.bme.hu 7 Serial code based on "xt" {GPL} by David Querbach, www.realtime.bc.ca 8 in turn based on "miniterm" by Sven Goldt, goldt@math.tu.berlin.de 9 GPL license 10 This program is free software; you can redistribute it and/or 11 modify it under the terms of the GNU General Public License 12 as published by the Free Software Foundation; either version 2 13 of the License, or (at your option) any later version. 14 15 This program is distributed in the hope that it will be useful, 16 but WITHOUT ANY WARRANTY; without even the implied warranty of 17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 GNU General Public License for more details. 19 20 Other portions based on Dallas Semiconductor Public Domain Kit, 21 --------------------------------------------------------------------------- 22 Copyright (C) 2000 Dallas Semiconductor Corporation, All Rights Reserved. 23 Permission is hereby granted, free of charge, to any person obtaining a 24 copy of this software and associated documentation files (the "Software"), 25 to deal in the Software without restriction, including without limitation 26 the rights to use, copy, modify, merge, publish, distribute, sublicense, 27 and/or sell copies of the Software, and to permit persons to whom the 28 Software is furnished to do so, subject to the following conditions: 29 The above copyright notice and this permission notice shall be included 30 in all copies or substantial portions of the Software. 31 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 32 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 33 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 34 IN NO EVENT SHALL DALLAS SEMICONDUCTOR BE LIABLE FOR ANY CLAIM, DAMAGES 35 OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 36 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 37 OTHER DEALINGS IN THE SOFTWARE. 38 Except as contained in this notice, the name of Dallas Semiconductor 39 shall not be used except as stated in the Dallas Semiconductor 40 Branding Policy. 41 --------------------------------------------------------------------------- 42 */ 43 44 #ifndef OW_BUS_ROUTINES_H /* tedious wrapper */ 45 #define OW_BUS_ROUTINES_H 46 47 48 /* -------------------------------------------- */ 49 /* Interface-specific routines ---------------- */ 50 struct interface_routines { 51 /* Detect if adapter is present, and open -- usually called outside of this routine */ 52 GOOD_OR_BAD (*detect) (struct port_in * pin); 53 /* reset the interface -- actually the 1-wire bus */ 54 RESET_TYPE (*reset) (const struct parsedname * pn); 55 /* Bulk of search routine, after set ups for first or alarm or family */ 56 enum search_status (*next_both) (struct device_search * ds, const struct parsedname * pn); 57 /* Send a byte with bus power to follow */ 58 GOOD_OR_BAD (*PowerByte) (const BYTE data, BYTE * resp, const UINT delay, const struct parsedname * pn); 59 /* Send a bit with bus power to follow */ 60 GOOD_OR_BAD (*PowerBit) (const BYTE data, BYTE * resp, const UINT delay, const struct parsedname * pn); 61 /* Send a 12V 480msec pulse to program EEPROM */ 62 GOOD_OR_BAD (*ProgramPulse) (const struct parsedname * pn); 63 /* send and recieve data -- byte at a time */ 64 GOOD_OR_BAD (*sendback_data) (const BYTE * data, BYTE * resp, const size_t len, const struct parsedname * pn); 65 /* send and recieve data -- byte at a time */ 66 GOOD_OR_BAD (*select_and_sendback) (const BYTE * data, BYTE * resp, const size_t len, const struct parsedname * pn); 67 /* send and recieve data -- bit at a time */ 68 GOOD_OR_BAD (*sendback_bits) (const BYTE * databits, BYTE * respbits, const size_t len, const struct parsedname * pn); 69 /* select a device */ 70 GOOD_OR_BAD (*select) (const struct parsedname * pn); 71 /* Set configuration parameters */ 72 GOOD_OR_BAD (*set_config) (void * p, const struct parsedname * pn); 73 /* Get configuration parameters */ 74 GOOD_OR_BAD (*get_config) (void * p, const struct parsedname * pn); 75 /* reconnect with a balky device */ 76 GOOD_OR_BAD (*reconnect) (const struct parsedname * pn); 77 /* Close the connection (port) */ 78 void (*close) (struct connection_in * in); 79 /* Verify a slave is actually on the bus, and address */ 80 GOOD_OR_BAD (*verify) (const struct parsedname * pn ); 81 /* capabilities flags */ 82 UINT flags; 83 }; 84 85 #define NO_DETECT_ROUTINE NULL 86 #define NO_RESET_ROUTINE NULL 87 #define NO_NEXT_BOTH_ROUTINE NULL 88 #define NO_POWERBYTE_ROUTINE NULL 89 #define NO_POWERBIT_ROUTINE NULL 90 #define NO_PROGRAMPULSE_ROUTINE NULL 91 #define NO_SENDBACKDATA_ROUTINE NULL 92 #define NO_SELECTANDSENDBACK_ROUTINE NULL 93 #define NO_SENDBACKBITS_ROUTINE NULL 94 #define NO_SELECT_ROUTINE NULL 95 #define NO_SET_CONFIG_ROUTINE NULL 96 #define NO_GET_CONFIG_ROUTINE NULL 97 #define NO_RECONNECT_ROUTINE NULL 98 #define NO_CLOSE_ROUTINE NULL 99 #define NO_VERIFY_ROUTINE NULL 100 101 /* placed in iroutines.flags */ 102 103 // Adapter is usable 104 #define ADAP_FLAG_default 0x00000000 105 106 // Adapter supports overdrive mode 107 #define ADAP_FLAG_overdrive 0x00000001 108 109 // Adapter doesn't support the DS2409 microlan hub 110 #define ADAP_FLAG_no2409path 0x00000010 111 112 // Adapter doesn't need DS2404 delay (i.e. not a local device) 113 #define ADAP_FLAG_no2404delay 0x00000020 114 115 // Adapter gets a directory all at once rather than one at a time 116 #define ADAP_FLAG_dirgulp 0x00000100 117 118 // Adapter benefits from coalescing reads and writes into a longer string 119 #define ADAP_FLAG_bundle 0x00001000 120 121 // Adapter automatically performs a reset before read/writes 122 #define ADAP_FLAG_dir_auto_reset 0x00002000 123 124 // Adapter doesn't support "presence" -- use the last dirblob instead. 125 #define ADAP_FLAG_presence_from_dirblob 0x00004000 126 127 // Adapter allows power-byte not to block other channels 128 #define ADAP_FLAG_unlock_during_delay 0x00010000 129 130 131 // Adapter is a sham. 132 #define ADAP_FLAG_sham 0x00008000 133 134 #define AdapterSupports2409(pn) (((pn)->selected_connection->iroutines.flags&ADAP_FLAG_no2409path)==0) 135 136 GOOD_OR_BAD BUS_detect( struct port_in * pin ) ; 137 138 RESET_TYPE BUS_reset(const struct parsedname *pn); 139 140 GOOD_OR_BAD BUS_select(const struct parsedname *pn); 141 GOOD_OR_BAD BUS_select_and_sendback(const BYTE * data, BYTE * resp, const size_t len, const struct parsedname *pn); 142 143 GOOD_OR_BAD BUS_sendback_bits( const BYTE * databits, BYTE * respbits, const size_t len, const struct parsedname * pn ); 144 GOOD_OR_BAD BUS_sendback_data(const BYTE * data, BYTE * resp, const size_t len, const struct parsedname *pn); 145 GOOD_OR_BAD BUS_sendback_cmd(const BYTE * cmd, BYTE * resp, const size_t len, const struct parsedname *pn); 146 GOOD_OR_BAD BUS_send_data(const BYTE * data, const size_t len, const struct parsedname *pn); 147 GOOD_OR_BAD BUS_send_bits(const BYTE * data, const size_t len, const struct parsedname *pn); 148 GOOD_OR_BAD BUS_readin_data(BYTE * data, const size_t len, const struct parsedname *pn); 149 GOOD_OR_BAD BUS_readin_bits(BYTE * data, const size_t len, const struct parsedname *pn); 150 151 GOOD_OR_BAD BUS_verify(BYTE search, const struct parsedname *pn); 152 GOOD_OR_BAD BUS_compare_bits(const BYTE * data1, const BYTE * data2, const size_t len); 153 154 GOOD_OR_BAD BUS_Set_Config(void * param, const struct parsedname *pn); 155 GOOD_OR_BAD BUS_Get_Config(void * param, const struct parsedname *pn); 156 157 GOOD_OR_BAD BUS_PowerBit(const BYTE data, BYTE * resp, UINT delay, const struct parsedname *pn); 158 GOOD_OR_BAD BUS_PowerByte(const BYTE data, BYTE * resp, UINT delay, const struct parsedname *pn); 159 GOOD_OR_BAD BUS_ProgramPulse(const struct parsedname *pn); 160 161 void BUS_close( struct connection_in * in ); 162 163 #endif /* OW_BUS_ROUTINES_H */ 164