COSA
An Object-Oriented Platform for Arduino Programming
PCF8591.cpp
Go to the documentation of this file.
1 
21 #include "PCF8591.hh"
22 
23 bool
24 PCF8591::begin(uint8_t cntl)
25 {
26  m_cntl = cntl;
27  twi.acquire(this);
28  twi.write(m_cntl);
29  sample();
30  return (true);
31 }
32 
33 bool
34 PCF8591::convert(uint8_t value)
35 {
36  twi.acquire(this);
37  int count = twi.write(m_cntl, &value, 1);
38  twi.release();
39  return (count == (sizeof(m_cntl) + sizeof(value)));
40 }
TWI twi
Definition: TWI.cpp:27
bool begin(uint8_t cntl)
Definition: PCF8591.cpp:24
bool convert(uint8_t value)
Definition: PCF8591.cpp:34
void release()
Definition: TWI.cpp:58
int write(void *buf, size_t size)
Definition: TWI.hh:282
void acquire(TWI::Driver *dev)
Definition: TWI.cpp:36
uint8_t sample()
Definition: PCF8591.hh:99