44 extern "C" { |
44 extern "C" { |
45 #endif |
45 #endif |
46 |
46 |
47 |
47 |
48 // ROM commands |
48 // ROM commands |
49 #define OWB_ROM_SEARCH 0xF0 |
49 #define OWB_ROM_SEARCH 0xF0 ///< Command ROM search |
50 #define OWB_ROM_READ 0x33 |
50 #define OWB_ROM_READ 0x33 ///< ROM read |
51 #define OWB_ROM_MATCH 0x55 |
51 #define OWB_ROM_MATCH 0x55 ///< ROM address match |
52 #define OWB_ROM_SKIP 0xCC |
52 #define OWB_ROM_SKIP 0xCC ///< Skip device |
53 #define OWB_ROM_SEARCH_ALARM 0xEC |
53 #define OWB_ROM_SEARCH_ALARM 0xEC ///< Search device with alarm set |
54 |
54 |
55 #define OWB_ROM_CODE_STRING_LENGTH (17) ///< Typical length of OneWire bus ROM ID as ASCII hex string, including null terminator |
55 #define OWB_ROM_CODE_STRING_LENGTH (17) ///< Typical length of OneWire bus ROM ID as ASCII hex string, including null terminator |
56 |
56 |
57 struct owb_driver; |
57 struct owb_driver; |
58 |
58 |
98 int last_discrepancy; |
98 int last_discrepancy; |
99 int last_family_discrepancy; |
99 int last_family_discrepancy; |
100 int last_device_flag; |
100 int last_device_flag; |
101 } OneWireBus_SearchState; |
101 } OneWireBus_SearchState; |
102 |
102 |
|
103 /** |
|
104 * @brief Status codes |
|
105 */ |
103 typedef enum |
106 typedef enum |
104 { |
107 { |
105 OWB_STATUS_OK, |
108 OWB_STATUS_OK, ///< Ok |
106 OWB_STATUS_NOT_INITIALIZED, |
109 OWB_STATUS_NOT_INITIALIZED, ///< Init error |
107 OWB_STATUS_PARAMETER_NULL, |
110 OWB_STATUS_PARAMETER_NULL, ///< NULL parameter |
108 OWB_STATUS_DEVICE_NOT_RESPONDING, |
111 OWB_STATUS_DEVICE_NOT_RESPONDING, ///< Device does not respond |
109 OWB_STATUS_CRC_FAILED, |
112 OWB_STATUS_CRC_FAILED, ///< CRC error |
110 OWB_STATUS_TOO_MANY_BITS, |
113 OWB_STATUS_TOO_MANY_BITS, ///< Too many bits |
111 OWB_STATUS_HW_ERROR |
114 OWB_STATUS_HW_ERROR ///< Hardware error |
112 } owb_status; |
115 } owb_status; |
113 |
116 |
114 /** NOTE: Driver assumes that (*init) was called prior to any other methods */ |
117 /** NOTE: Driver assumes that (*init) was called prior to any other methods */ |
115 struct owb_driver |
118 struct owb_driver |
116 { |
119 { |
131 const typeof( ((type *)0)->member ) *__mptr = (ptr); \ |
134 const typeof( ((type *)0)->member ) *__mptr = (ptr); \ |
132 (type *)( (char *)__mptr - offsetof(type,member) );}) |
135 (type *)( (char *)__mptr - offsetof(type,member) );}) |
133 |
136 |
134 /** |
137 /** |
135 * @brief call to release resources after completing use of the OneWireBus |
138 * @brief call to release resources after completing use of the OneWireBus |
|
139 * @param[in] bus Pointer to initialised bus instance. |
|
140 * @return status |
136 */ |
141 */ |
137 owb_status owb_uninitialize(OneWireBus * bus); |
142 owb_status owb_uninitialize(OneWireBus * bus); |
138 |
143 |
139 /** |
144 /** |
140 * @brief Enable or disable use of CRC checks on device communications. |
145 * @brief Enable or disable use of CRC checks on device communications. |
162 owb_status owb_verify_rom(const OneWireBus * bus, OneWireBus_ROMCode rom_code, bool* is_present); |
167 owb_status owb_verify_rom(const OneWireBus * bus, OneWireBus_ROMCode rom_code, bool* is_present); |
163 |
168 |
164 /** |
169 /** |
165 * @brief Reset the 1-Wire bus. |
170 * @brief Reset the 1-Wire bus. |
166 * @param[in] bus Pointer to initialised bus instance. |
171 * @param[in] bus Pointer to initialised bus instance. |
167 * @param[out] is_present set to true if at least one device is present on the bus |
172 * @param[out] a_device_present set to true if at least one device is present on the bus |
168 * @return status |
173 * @return status |
169 */ |
174 */ |
170 owb_status owb_reset(const OneWireBus * bus, bool* a_device_present); |
175 owb_status owb_reset(const OneWireBus * bus, bool* a_device_present); |
171 |
176 |
172 /** |
177 /** |