Exploring BeagleBone  V1.0
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
BusDevice.h
Go to the documentation of this file.
1 /*
2  * BusDevice.h Created on: 23 May 2014
3  * Copyright (c) 2014 Derek Molloy (www.derekmolloy.ie)
4  * Made available for the book "Exploring BeagleBone"
5  * See: www.exploringbeaglebone.com
6  * Licensed under the EUPL V.1.1
7  *
8  * This Software is provided to You under the terms of the European
9  * Union Public License (the "EUPL") version 1.1 as published by the
10  * European Union. Any use of this Software, other than as authorized
11  * under this License is strictly prohibited (to the extent such use
12  * is covered by a right of the copyright holder of this Software).
13  *
14  * This Software is provided under the License on an "AS IS" basis and
15  * without warranties of any kind concerning the Software, including
16  * without limitation merchantability, fitness for a particular purpose,
17  * absence of defects or errors, accuracy, and non-infringement of
18  * intellectual property rights other than copyright. This disclaimer
19  * of warranty is an essential part of the License and a condition for
20  * the grant of any rights to this Software.
21  *
22  * For more details, see http://www.derekmolloy.ie/
23  */
24 
25 #ifndef BUSDEVICE_H_
26 #define BUSDEVICE_H_
27 
28 namespace exploringBB {
29 
37 class BusDevice {
38 protected:
39  unsigned int bus;
40  unsigned int device;
41  int file;
42 public:
43  BusDevice(unsigned int bus, unsigned int device);
44  virtual int open()=0;
45  virtual unsigned char readRegister(unsigned int registerAddress)=0;
46  virtual unsigned char* readRegisters(unsigned int number, unsigned int fromAddress=0)=0;
47  virtual int write(unsigned char value)=0;
48  virtual int writeRegister(unsigned int registerAddress, unsigned char value)=0;
49  virtual void debugDumpRegisters(unsigned int number = 0xff)=0;
50  virtual void close()=0;
51  virtual ~BusDevice();
52 };
53 
54 } /* namespace exploringBB */
55 
56 #endif /* BUSDEVICE_H_ */
virtual void debugDumpRegisters(unsigned int number=0xff)=0
int file
Definition: BusDevice.h:41
BusDevice(unsigned int bus, unsigned int device)
Definition: BusDevice.cpp:34
virtual unsigned char readRegister(unsigned int registerAddress)=0
virtual int write(unsigned char value)=0
unsigned int bus
Definition: BusDevice.h:39
virtual int open()=0
Definition: BusDevice.cpp:27
virtual void close()=0
This class is the parent of I2C and SPI devices, so that devices that use both SPI and I2C interfaces...
Definition: BusDevice.h:37
virtual ~BusDevice()
Definition: BusDevice.cpp:43
unsigned int device
Definition: BusDevice.h:40
virtual unsigned char * readRegisters(unsigned int number, unsigned int fromAddress=0)=0
virtual int writeRegister(unsigned int registerAddress, unsigned char value)=0