one wire driver

Dependents:   09_PT1000 10_PT1000 11_PT1000

Revision:
1:0950824b1ca3
Parent:
0:c57706d25cf0
Child:
2:e9048135901b
--- a/DS2482.h	Sat Apr 27 18:56:53 2013 +0000
+++ b/DS2482.h	Sat May 04 10:11:42 2013 +0000
@@ -9,7 +9,8 @@
 
     #include "mbed.h"
 
-    #define OW_MASTER_START 1
+    #define OW_MASTER_START 0
+    #define OW_MASTER_DEBUG 0
     
     // constants/macros/typdefs
     #define OW_I2C_DEVICE      0x30    // < Change this to the address of your 1-Wire master  
@@ -23,7 +24,7 @@
     #define I2C_READ 1
     #define I2C_WRITE 0
     
-    #define POLL_LIMIT 200
+    #define POLL_LIMIT 100
 
     // Maximale Anzahl der Bausteine am Bus
     #define OW_MAX_DEVICES 16
@@ -52,8 +53,8 @@
     #define OW_CMD_READ_POWER_SUPPLY 0xB4 // Command Signal power supply mode
 
     // Error codes
-    #define OW_RESET_ERROR BIT0
-    #define OW_CRC_ERROR BIT1
+    #define OW_RESET_ERROR      0x01
+    #define OW_CRC_ERROR        0x02
     
     // DS2482 command defines
     #define DS2482_CMD_DRST     0xF0    //< DS2482 Device Reset
@@ -139,7 +140,10 @@
     {
 
       public:
-      
+        
+        // global vars
+        tOW ow;
+         
         /** Create an instance of the PCF8574 connected to specfied I2C pins, with the specified address.
         *
         * @param sda The I2C data pin
@@ -149,9 +153,12 @@
         
         DS2482(PinName sda, PinName scl, int address);
         
-        uint8_t crc_calc(uint8_t x);
         //-----------------------------------------------------------------------------
         // functions
+      
+        // crc buffer
+        uint8_t crc_calc(uint8_t x);
+        uint8_t crc_calc_buffer(uint8_t* pbuffer,uint8_t count);
     
         uint8_t detect(void);
         int reset(void);
@@ -177,24 +184,20 @@
         uint8_t OWLevel(uint8_t new_level);
         uint8_t OWReadBitPower(uint8_t applyPowerResponse);
         uint8_t OWWriteBytePower(uint8_t sendbyte);
-    
-/*    
+       
         void DS18XX_Read_Address(void);
-        void DS2482_start_conversion(void);
+        void start_conversion(void);
  
-
-*/       
       protected:
-/*      
-        BOOL ow_read_rom(void);
-        BOOL ow_read_scratchpad(void);
-        BOOL ow_read_scratchpad_ds2438(uint8_t page);
-        BOOL ow_write_scratchpad_ds18x20 (uint8_t th, uint8_t tl);
-        BOOL ow_write_scratchpad_ds2438 (uint8_t th, uint8_t tl);
-        BOOL ow_write_eeprom_ds18x20 (void);
-        BOOL ow_write_eeprom_ds2438 (void);
+ 
+        bool ow_read_rom(void);
+        bool ow_read_scratchpad(void);
+        bool ow_read_scratchpad_ds2438(uint8_t page);
+        bool ow_write_scratchpad_ds18x20 (uint8_t th, uint8_t tl);
+        bool ow_write_scratchpad_ds2438 (uint8_t th, uint8_t tl);
+        bool ow_write_eeprom_ds18x20 (void);
+        bool ow_write_eeprom_ds2438 (void);
         void ow_read_address (void);
-*/
         //-----------------------------------------------------------------------------
         // vars
         
@@ -203,7 +206,7 @@
         uint8_t crc_value;
                
         // Search state
-        tOW ow;                                         // Variablen in einem Block ablegen
+                                        // Variablen in einem Block ablegen
         uint8_t ow_scratchpad[OW_SCRATCHPAD_BYTES];     // Scratchpad memory
         uint8_t ow_rom_code[OW_ROM_CODE_BYTES];         // Temporary ROM code
         uint8_t ow_flags;
@@ -216,6 +219,8 @@
         uint8_t c1WS, cSPU, cPPM, cAPU;
         uint8_t short_detected;
         
+
+        
 }; // end class
 
 #endif