onewire 1-wire ds18x20 ds2450 multi-channel
onewire.h@0:8c4e1841eb30, 2012-03-02 (annotated)
- Committer:
- fblanc
- Date:
- Fri Mar 02 08:29:49 2012 +0000
- Revision:
- 0:8c4e1841eb30
v1.1 onewire multi-channel
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
fblanc | 0:8c4e1841eb30 | 1 | /** |
fblanc | 0:8c4e1841eb30 | 2 | * @file onewire.h |
fblanc | 0:8c4e1841eb30 | 3 | * @brief library 1-Wire(www.maxim-ic.com) |
fblanc | 0:8c4e1841eb30 | 4 | * @author Maciej Rajtar (Published 10 May 2010 www.mbed.org) |
fblanc | 0:8c4e1841eb30 | 5 | * @author Frederic BLANC (Published 01/03/2012 www.mbed.org) |
fblanc | 0:8c4e1841eb30 | 6 | */ |
fblanc | 0:8c4e1841eb30 | 7 | |
fblanc | 0:8c4e1841eb30 | 8 | #ifndef _onewire_ |
fblanc | 0:8c4e1841eb30 | 9 | #define _onewire_ |
fblanc | 0:8c4e1841eb30 | 10 | #include "DS2450.h" |
fblanc | 0:8c4e1841eb30 | 11 | #include "DS18X20.h" |
fblanc | 0:8c4e1841eb30 | 12 | #include "crc8.h" |
fblanc | 0:8c4e1841eb30 | 13 | #include "crc16.h" |
fblanc | 0:8c4e1841eb30 | 14 | //#define DEBUG 1 |
fblanc | 0:8c4e1841eb30 | 15 | //#define DEBUG_L1 1 |
fblanc | 0:8c4e1841eb30 | 16 | #define ONEWIRE_PIN p21 |
fblanc | 0:8c4e1841eb30 | 17 | |
fblanc | 0:8c4e1841eb30 | 18 | #define MAXSENSORS 8 |
fblanc | 0:8c4e1841eb30 | 19 | #define MAXBUS 4 |
fblanc | 0:8c4e1841eb30 | 20 | // rom-code size including CRC |
fblanc | 0:8c4e1841eb30 | 21 | #define OW_ROMCODE_SIZE 8 |
fblanc | 0:8c4e1841eb30 | 22 | |
fblanc | 0:8c4e1841eb30 | 23 | #define OW_OK 0x00 |
fblanc | 0:8c4e1841eb30 | 24 | #define OW_ERROR 0x01 |
fblanc | 0:8c4e1841eb30 | 25 | #define OW_START_FAIL 0x02 |
fblanc | 0:8c4e1841eb30 | 26 | #define OW_ERROR_CRC 0x03 |
fblanc | 0:8c4e1841eb30 | 27 | #define OW_ERROR_BAD_ID 0x04 |
fblanc | 0:8c4e1841eb30 | 28 | #define OW_BUSY 0x05 |
fblanc | 0:8c4e1841eb30 | 29 | |
fblanc | 0:8c4e1841eb30 | 30 | #define OW_MATCH_ROM 0x55 |
fblanc | 0:8c4e1841eb30 | 31 | #define OW_SKIP_ROM 0xCC |
fblanc | 0:8c4e1841eb30 | 32 | #define OW_SEARCH_ROM 0xF0 |
fblanc | 0:8c4e1841eb30 | 33 | #define OW_READ_ROM 0x33 |
fblanc | 0:8c4e1841eb30 | 34 | #define OW_CONDITIONAL_SEARCH 0xEC |
fblanc | 0:8c4e1841eb30 | 35 | #define OW_OVERDRIVE_SKIP_ROM 0x3C |
fblanc | 0:8c4e1841eb30 | 36 | #define OW_OVERDRIVE_MATCH_ROM 0x69 |
fblanc | 0:8c4e1841eb30 | 37 | |
fblanc | 0:8c4e1841eb30 | 38 | #define OW_SHORT_CIRCUIT 0xFF |
fblanc | 0:8c4e1841eb30 | 39 | #define OW_SEARCH_FIRST 0xFF // start new search |
fblanc | 0:8c4e1841eb30 | 40 | #define OW_PRESENCE_ERR 0x01 |
fblanc | 0:8c4e1841eb30 | 41 | #define OW_DATA_ERR 0xFE |
fblanc | 0:8c4e1841eb30 | 42 | #define OW_LAST_DEVICE 0x00 // last device found |
fblanc | 0:8c4e1841eb30 | 43 | // 0x01 ... 0x40: continue searching |
fblanc | 0:8c4e1841eb30 | 44 | |
fblanc | 0:8c4e1841eb30 | 45 | #include <string> |
fblanc | 0:8c4e1841eb30 | 46 | string ow_show_id( uint8_t id[]); |
fblanc | 0:8c4e1841eb30 | 47 | |
fblanc | 0:8c4e1841eb30 | 48 | uint8_t search_sensors(uint8_t *nSensors,uint8_t id[][OW_ROMCODE_SIZE] ); |
fblanc | 0:8c4e1841eb30 | 49 | uint8_t search_sensors(uint8_t n,uint8_t *nSensors,uint8_t gSensorIDs[][MAXSENSORS][OW_ROMCODE_SIZE] ); |
fblanc | 0:8c4e1841eb30 | 50 | uint8_t ow_PullUp(void); |
fblanc | 0:8c4e1841eb30 | 51 | uint8_t ow_PullUp(uint8_t n); |
fblanc | 0:8c4e1841eb30 | 52 | |
fblanc | 0:8c4e1841eb30 | 53 | |
fblanc | 0:8c4e1841eb30 | 54 | uint8_t ow_test_pin (void); |
fblanc | 0:8c4e1841eb30 | 55 | uint8_t ow_test_pin (uint8_t n); |
fblanc | 0:8c4e1841eb30 | 56 | uint8_t ow_reset(void); |
fblanc | 0:8c4e1841eb30 | 57 | uint8_t ow_reset(uint8_t n); |
fblanc | 0:8c4e1841eb30 | 58 | uint8_t ow_rom_search( uint8_t diff, uint8_t id[] ); |
fblanc | 0:8c4e1841eb30 | 59 | uint8_t ow_rom_search(uint8_t n, uint8_t diff, uint8_t id[] ); |
fblanc | 0:8c4e1841eb30 | 60 | uint8_t ow_command( uint8_t command, uint8_t id[] ); |
fblanc | 0:8c4e1841eb30 | 61 | uint8_t ow_command(uint8_t n, uint8_t command, uint8_t id[] ); |
fblanc | 0:8c4e1841eb30 | 62 | uint8_t ow_find_sensor(uint8_t *diff, uint8_t id[]); |
fblanc | 0:8c4e1841eb30 | 63 | uint8_t ow_find_sensor(uint8_t n,uint8_t *diff, uint8_t id[]); |
fblanc | 0:8c4e1841eb30 | 64 | uint8_t ow_parasite_enable(void); |
fblanc | 0:8c4e1841eb30 | 65 | uint8_t ow_parasite_enable(uint8_t n); |
fblanc | 0:8c4e1841eb30 | 66 | uint8_t ow_parasite_disable(void); |
fblanc | 0:8c4e1841eb30 | 67 | uint8_t ow_parasite_disable(uint8_t n); |
fblanc | 0:8c4e1841eb30 | 68 | uint8_t ow_bit_io( uint8_t b ); |
fblanc | 0:8c4e1841eb30 | 69 | uint8_t ow_bit_io(uint8_t n, uint8_t b); |
fblanc | 0:8c4e1841eb30 | 70 | uint8_t ow_byte_wr( uint8_t b ); |
fblanc | 0:8c4e1841eb30 | 71 | uint8_t ow_byte_wr(uint8_t n, uint8_t b ); |
fblanc | 0:8c4e1841eb30 | 72 | uint8_t ow_byte_rd( void ); |
fblanc | 0:8c4e1841eb30 | 73 | uint8_t ow_byte_rd( uint8_t n); |
fblanc | 0:8c4e1841eb30 | 74 | |
fblanc | 0:8c4e1841eb30 | 75 | |
fblanc | 0:8c4e1841eb30 | 76 | #endif |