onewire 1-wire ds18x20 ds2450 multi-channel

Dependents:   ibutton

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers onewire.h Source File

onewire.h

Go to the documentation of this file.
00001 /**
00002 * @file onewire.h
00003 * @brief library 1-Wire(www.maxim-ic.com)
00004 * @author Maciej Rajtar (Published 10 May 2010 www.mbed.org)
00005 * @author Frederic BLANC (Published 01/03/2012 www.mbed.org)
00006 */
00007 
00008 #ifndef _onewire_
00009 #define _onewire_
00010 #include "DS2450.h"
00011 #include "DS18X20.h"
00012 #include "crc8.h"
00013 #include "crc16.h"
00014 //#define DEBUG 1
00015 //#define DEBUG_L1 1
00016 #define ONEWIRE_PIN  p21
00017 
00018 #define MAXSENSORS 8
00019 #define MAXBUS 4
00020 // rom-code size including CRC
00021 #define OW_ROMCODE_SIZE 8
00022 
00023 #define OW_OK          0x00
00024 #define OW_ERROR       0x01
00025 #define OW_START_FAIL  0x02
00026 #define OW_ERROR_CRC   0x03
00027 #define OW_ERROR_BAD_ID 0x04
00028 #define OW_BUSY          0x05
00029 
00030 #define OW_MATCH_ROM    0x55
00031 #define OW_SKIP_ROM     0xCC
00032 #define OW_SEARCH_ROM   0xF0
00033 #define OW_READ_ROM     0x33
00034 #define OW_CONDITIONAL_SEARCH     0xEC
00035 #define OW_OVERDRIVE_SKIP_ROM     0x3C
00036 #define OW_OVERDRIVE_MATCH_ROM    0x69
00037 
00038 #define OW_SHORT_CIRCUIT   0xFF
00039 #define OW_SEARCH_FIRST    0xFF        // start new search
00040 #define OW_PRESENCE_ERR    0x01
00041 #define OW_DATA_ERR        0xFE
00042 #define OW_LAST_DEVICE     0x00        // last device found
00043 //            0x01 ... 0x40: continue searching
00044 
00045 #include <string>
00046 string ow_show_id( uint8_t id[]); 
00047 
00048 uint8_t search_sensors(uint8_t *nSensors,uint8_t id[][OW_ROMCODE_SIZE] );
00049 uint8_t search_sensors(uint8_t n,uint8_t *nSensors,uint8_t gSensorIDs[][MAXSENSORS][OW_ROMCODE_SIZE] );
00050 uint8_t ow_PullUp(void);
00051 uint8_t ow_PullUp(uint8_t n);
00052 
00053 
00054 uint8_t ow_test_pin (void);
00055 uint8_t ow_test_pin (uint8_t n);
00056 uint8_t ow_reset(void);
00057 uint8_t ow_reset(uint8_t n);
00058 uint8_t ow_rom_search( uint8_t diff, uint8_t id[] );
00059 uint8_t ow_rom_search(uint8_t n, uint8_t diff, uint8_t id[] );
00060 uint8_t ow_command( uint8_t command, uint8_t id[] );
00061 uint8_t ow_command(uint8_t n, uint8_t command, uint8_t id[] );
00062 uint8_t ow_find_sensor(uint8_t *diff, uint8_t id[]);
00063 uint8_t ow_find_sensor(uint8_t n,uint8_t *diff, uint8_t id[]);
00064 uint8_t ow_parasite_enable(void);
00065 uint8_t ow_parasite_enable(uint8_t n);
00066 uint8_t ow_parasite_disable(void);
00067 uint8_t ow_parasite_disable(uint8_t n);
00068 uint8_t ow_bit_io( uint8_t b );
00069 uint8_t ow_bit_io(uint8_t n, uint8_t b);
00070 uint8_t ow_byte_wr( uint8_t b );
00071 uint8_t ow_byte_wr(uint8_t n, uint8_t b );
00072 uint8_t ow_byte_rd( void );
00073 uint8_t ow_byte_rd( uint8_t n);
00074 
00075 
00076 #endif