User Tools

Site Tools


arduino_lib_dp1wbasic

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
arduino_lib_dp1wbasic [2012/02/28 03:03]
admin created
arduino_lib_dp1wbasic [2016/09/01 14:17] (current)
Line 1: Line 1:
 Documentation **[[arduino_code|Arduino base program code]]** Documentation **[[arduino_code|Arduino base program code]]**
-====== ​DpI2CLEDStatus ​library ======+====== ​Dp1WBasic  ​library ======
 ===== Description ===== ===== Description =====
-DpI2CLEDStatus ​Arduino library provide function for using +Dp1WBasic ​Arduino library provide function for gething 
-signaling LED on daince.nrt Status LED board with PCF8574A.+data form 1-Wire bus. 
 + 
 +Most part of code come from original OneWire library http://​www.arduino.cc/​playground/​Learning/​OneWire !
  
 Source code is provided as is, without any warranty. Source code is provided as is, without any warranty.
  
-Distributed ​under CC BY v 3.0+Distributetd ​under CC BY v 3.0
 ==== Functions ==== ==== Functions ====
 <​code>​ <​code>​
-// On inicialization ​define pin position ​for LEDs +#define ​NORMAL_SEARCH ​  ​0xF0 
-DpI2CLEDStatus(byte Addrbyte pR1=1, byte pG1=0, byte pB1=2byte pL1=3, byte pR2=5byte pG2=4byte pB2=6, byte pL2=7);+#define ALARM_SEARCH ​   0xEC 
 + 
 +Dp1WBasic( uint8_t ​pin); 
 + 
 +// Perform a 1-Wire reset cycle. Returns 1 if a device responds 
 +// with a presence pulse. ​ Returns 0 if there is no device or the 
 +// bus is shorted or otherwise held low for more than 250uS 
 +uint8_t reset(void); 
 + 
 +// Issue a 1-Wire rom select commandyou do the reset first. 
 +void select( uint8_t rom[8]); 
 + 
 +// Issue a 1-Wire rom skip commandto address all on bus. 
 +void skip(void);​ 
 + 
 +// Write a byte. If '​power'​ is one then the wire is held high at 
 +// the end for parasitically powered devices. You are responsible 
 +// for eventually depowering it by calling depower() or doing 
 +// another read or write. 
 +void write(uint8_t v, uint8_t power = 0); 
 + 
 +void write_bytes(const uint8_t *bufuint16_t countbool power 0); 
 + 
 +// Read a byte
 +uint8_t read(void);​ 
 + 
 +void read_bytes(uint8_t *bufuint16_t count); 
 + 
 +// Write a bit. The bus is always left powered at the endsee 
 +// note in write() about that. 
 +void write_bit(uint8_t v); 
 + 
 +// Read a bit. 
 +uint8_t read_bit(void);​ 
 + 
 +// Stop forcing power onto the bus. You only need to do this if 
 +// you used the '​power'​ flag to write() or used a write_bit() call 
 +// and aren't about to do another read or write. You would rather 
 +// not leave this powered if you don't have to, just in case 
 +// someone shorts your bus. 
 +void depower(void);​ 
 + 
 +// Clear the search state so that if will start from the beginning again. 
 +void reset_search();​ 
 + 
 +// Look for the next device. Returns 1 if a new address has been 
 +// returned. A zero might mean that the bus is shorted, there are 
 +// no devices, or you have already retrieved all of them.  It 
 +// might be a good idea to check the CRC to make sure you didn'​t 
 +// get garbage. ​ The order is deterministic. You will always get 
 +// the same devices in the same order. 
 +uint8_t search(uint8_t *newAddr, byte searchType ​NORMAL_SEARCH);
  
-// Set all LEDs off +// Compute a Dallas Semiconductor 8 bit CRC, these are used in the 
-void setAllOff();+// ROM and scratchpad registers. 
 +static uint8_t crc8uint8_t *addr, uint8_t len);
  
-// Set RGB LED 1  +// Compute the 1-Wire CRC16 and compare it against the received CRC. 
-// 1 Red On 0 Red off +//           
-// 1 Green On 0 Green Off +// @param input Array of bytes to checksum. 
-// 1 Blue On 0 Blue Off +// @param len - How many bytes to use. 
-void setRGBLED1(byte Rbyte Gbyte B);+// @param inverted_crc ​The two CRC16 bytes in the received data. 
 +//                       This should just point into the received data, 
 +//                       *not* at a 16-bit integer. 
 +// @return True, iff the CRC matches. 
 +static bool check_crc16(uint8_t* inputuint16_t lenuint8_t* inverted_crc);
  
-// Set RGB LED 2  +// Compute a Dallas Semiconductor 16 bit CRC.  This is required to check 
-// 1 Red On / 0 Red off +// the integrity of data received from many 1-Wire devices. ​ Note that the 
-// G - Green On 0 Green Off +// CRC computed here is *not* what you'll get from the 1-Wire network, 
-// B - Blue On / 0 Blue Off +// for two reasons: 
-void setRGBLED2(byte R, byte G, byte B)+//   ​1) The CRC is transmitted bitwise inverted. 
-    ​ +//   2) Depending on the endian-ness of your processor, the binary 
-// Set LED 1 +//      ​representation of the two-byte return value may have a different 
-// Status ​1 On 0 Off +//      ​byte order than the two bytes you get from 1-Wire. 
-void setLED1(byte Status); +// @param input - Array of bytes to checksum. 
-    ​ +// @param len How many bytes to use. 
-// Set LED 2 +// @return The CRC16, as defined by Dallas Semiconductor. 
-// Status ​1 On 0 Off +static uint16_t crc16(uint8_t* input, uint16_t len);
-void setLED2(byte Status);+
 </​code>​ </​code>​
  
Line 44: Line 101:
 ===== Version ===== ===== Version =====
 ==== Actual ==== ==== Actual ====
-  * **{{:​source_code:​arduino:​library:​dpi2cledstatus:dpi2cledstatus-1.0.0.tar.gz|dpi2cledstatus-1.0.0.tar.gz}}** +  * **{{:​source_code:​arduino:​library:​dp1wbasic:dp1wbasic-1.0.0.tar.gz|dp1wbasic-1.0.0.tar.gz}}** 
-  * **{{:​source_code:​arduino:​library:​dpi2cledstatus:dpi2cledstatus-1.0.0.zip|dpi2cledstatus-1.0.0.zip}}**+  * **{{:​source_code:​arduino:​library:​dp1wbasic:dp1wbasic-1.0.0.zip|dp1wbasic-1.0.0.zip}}**
 ==== History ==== ==== History ====
 === V 1.0.0 , 10.02.2012 === === V 1.0.0 , 10.02.2012 ===
-  * **{{:​source_code:​arduino:​library:​dpi2cledstatus:dpi2cledstatus-1.0.0.tar.gz|dpi2cledstatus-1.0.0.tar.gz}}** +  * **{{:​source_code:​arduino:​library:​dp1wbasic:dp1wbasic-1.0.0.tar.gz|dp1wbasic-1.0.0.tar.gz}}** 
-  * **{{:​source_code:​arduino:​library:​dpi2cledstatus:dpi2cledstatus-1.0.0.zip|dpi2cledstatus-1.0.0.zip}}**+  * **{{:​source_code:​arduino:​library:​dp1wbasic:dp1wbasic-1.0.0.zip|dp1wbasic-1.0.0.zip}}**
arduino_lib_dp1wbasic.txt · Last modified: 2016/09/01 14:17 (external edit)