SparkFun Toolkit  v1.0.5-6-g34ffa30
Core Functionality Library
Loading...
Searching...
No Matches
sfTkII2C.h
Go to the documentation of this file.
1
14#pragma once
15
16#include "sfTkIBus.h"
17
24const uint8_t ksfTkBusTypeI2C = 0x01;
25
26class sfTkII2C : public sfTkIBus
27{
28 public:
29 // set the address to No address and stop flag to true
33 sfTkII2C() : _address{kNoAddress}, _stop{true}
34 {
35 }
41 sfTkII2C(uint8_t addr) : _address{addr}
42 {
43 }
44
51 virtual sfTkError_t ping() = 0;
52
59 virtual void setAddress(uint8_t devAddr)
60 {
61 _address = devAddr;
62 }
63
70 virtual uint8_t address(void)
71 {
72 return _address;
73 }
74
80 virtual void setStop(bool stop)
81 {
82 _stop = stop;
83 }
84
91 virtual bool stop(void)
92 {
93 return _stop;
94 }
95
99 static constexpr uint8_t kNoAddress = 0;
100
101 virtual uint8_t type(void)
102 {
103 return ksfTkBusTypeI2C;
104 }
105
106 private:
107 uint8_t _address;
108 bool _stop;
109};
110
111//};
Interface that defines the communication bus for the SparkFun Electronics Toolkit.
Definition: sfTkIBus.h:73
Definition: sfTkII2C.h:27
virtual sfTkError_t ping()=0
A simple ping of the device at the set address.
virtual void setAddress(uint8_t devAddr)
setter for the I2C address
Definition: sfTkII2C.h:59
sfTkII2C()
Constructor for the I2C bus.
Definition: sfTkII2C.h:33
virtual uint8_t address(void)
getter for the I2C address
Definition: sfTkII2C.h:70
virtual bool stop(void)
getter for I2C stops message (vs restarts)
Definition: sfTkII2C.h:91
virtual void setStop(bool stop)
setter for I2C stop message (vs restarts)
Definition: sfTkII2C.h:80
sfTkII2C(uint8_t addr)
Constructor for the I2C bus with an address passed in.
Definition: sfTkII2C.h:41
static constexpr uint8_t kNoAddress
kNoAddress is a constant to indicate no address has been set
Definition: sfTkII2C.h:99
virtual uint8_t type(void)
Get the type of the object.
Definition: sfTkII2C.h:101
int32_t sfTkError_t
Definition: sfTkError.h:35
Header file for the SparkFun Toolkit Device Bus Interface Definition.
const uint8_t ksfTkBusTypeI2C
Interface that defines the I2C communication bus for the SparkFun Electronics Toolkit.
Definition: sfTkII2C.h:24