Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
ds1621.h
00001 #ifndef DS1621_H 00002 #define DS1621_H 00003 //------------includes----------------- 00004 #include "mbed.h" 00005 //------------ 00006 /** 00007 * DS1621 simple control class, 00008 * 00009 * Example: 00010 * @code 00011 * // Continus temperature acquisition 00012 * #include "mbed.h" 00013 * #include "ds1621.h" 00014 * 00015 * DigitalOut myled1(LED1); 00016 * DigitalOut myled2(LED2); 00017 * DigitalOut myled3(LED3); 00018 * DigitalOut myled4(LED4); 00019 * 00020 * #define DS1621_ADDR 0 // I2c DS1621 address is 0x00 00021 * 00022 * Serial pc(USBTX, USBRX); // Declare usb (see screen /dev/ttyUSB0 on linux) 00023 * I2C i2c(p28, p27); // Declare I2C (pullup resistors 2.2k from p28 and p27 to +3.3v) 00024 * DS1621 ds(&i2c, DS1621_ADDR); // Declare ds1621 throught i2c interface 00025 * 00026 *int main() { 00027 * i2c.frequency(5000); //5khz 00028 * pc.printf("-----------------------\n\rMain\n\r"); 00029 * char count = 0; 00030 * float temp = 0.0; 00031 * ds.init(DS1621_ADDR); 00032 * while (1) { 00033 * myled1 = count & 0x01; 00034 * myled2 = count & 0x02; 00035 * myled3 = count & 0x04; 00036 * myled4 = count & 0x08; 00037 * count++; 00038 * temp = ds.read(DS1621_ADDR); 00039 * pc.printf("Measurment at start + %d seconds, Temperature=%3.1f\n\r",(count*5),temp); 00040 * wait(5.0); 00041 * } 00042 *} 00043 * @endcode 00044 */ 00045 //------------defines------------------ 00046 #define DS1621_Write 0x90 00047 #define DS1621_Read 0x91 00048 //------------class-------------------- 00049 class DS1621 { 00050 //-----------methodes ----------------- 00051 public: 00052 /** 00053 *@brief Constructor, initializes the ds1621 on I2C interface. 00054 *@param interface 00055 *@param address DS1621 i2c address on bus 00056 *@return none 00057 */ 00058 DS1621 (I2C* interface, uint8_t address); 00059 00060 /** 00061 *@brief Get temperature as float to the ds1621 00062 *@param address DS1621 i2c address on bus 00063 *@return current temperature as a float number in degrees Celsius 00064 */ 00065 float read(uint8_t address); 00066 00067 /** 00068 *@brief Initialize DS1621 00069 *@param address DS1621 i2c address on bus 00070 *@return none 00071 */ 00072 void init(uint8_t address); 00073 00074 public: 00075 bool dbx; // True activate debug message 00076 //---------- local variables ---------- 00077 private: 00078 I2C* i2c; // Communication interface 00079 //------------------------------------- 00080 }; 00081 #endif
Generated on Wed Jul 13 2022 20:17:39 by
 1.7.2
 1.7.2