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.
PCF8591.cpp
00001 //********************** 00002 // PCF8591.cpp for mbed 00003 // 00004 // PCF8591 lcd(P0_5,P0_4); 00005 // or 00006 // I2C i2c(P0_5,P0_4); 00007 // PCF8591 lcd(i2c); 00008 // 00009 // (C)Copyright 2014 All rights reserved by Y.Onodera 00010 // http://einstlab.web.fc2.com 00011 //********************** 00012 00013 #include "mbed.h" 00014 #include "PCF8591.h" 00015 00016 PCF8591::PCF8591 (PinName sda, PinName scl) : _i2c(sda, scl) { 00017 } 00018 PCF8591::PCF8591 (I2C& p_i2c) : _i2c(p_i2c) { 00019 } 00020 00021 void PCF8591::put(unsigned char a, unsigned char b) 00022 { 00023 buf[0]=a; 00024 buf[1]=b; 00025 _i2c.write(PCF8591_ADDR, buf, 2); 00026 } 00027 00028 unsigned char PCF8591::get(unsigned char a) 00029 { 00030 buf[0] = a; 00031 _i2c.write(PCF8591_ADDR, buf, 1, true); // no stop, repeated 00032 _i2c.read( PCF8591_ADDR, buf, 1); 00033 return buf[0]; 00034 } 00035 00036
Generated on Thu Jul 14 2022 02:52:35 by
1.7.2