This are general defs and base class interfaces. ( DACInterface, I2CInterface) to be used with I2C devices

Dependents:   MCP23009tst AT30TSE752TST MCP4728setaddrProg mbedSerialInterface_talkback2 ... more

The DevInterfaces class is used for a more general support of a number of I2C devices.

For the moment this is MCP4728 Quad DAC.

The idea is to write a libs for the I2C devices (and perhaps later SPI , ... devices) not restricted to a certain hardware platform.

So there is the I2CInterface. This is a ( not pure) virtual class. A pointer to this class is used for the I2C device lib (like the MCP4728 class https://developer.mbed.org/users/wbeaumont/code/MCP4728/ ) to communicate with the I2C interface. The I2C interface is kept simple as possible. So it has to be applied for "tested environments". I2C Bus timeouts etc. are hard to debug with such a simple interface. This kind of interface is also not suitable for optimal performance. The user has to take care of issues of blocking devices, parallel processes etc. This can be dealt with in the implementation of the I2CInterface class

The aim of this project is to generate code for these devices on different platforms without doing the painstaking work of looking up all the register details.

There is an implementation of the I2CInterface for the MBED , tested with the FRDM-KL05Z platform. https://developer.mbed.org/users/wbeaumont/code/I2Cinterfaces/

A very simple application on a MBED can be found in https://developer.mbed.org/users/wbeaumont/code/MCP4728test/

Committer:
wbeaumont
Date:
Tue Sep 10 11:20:07 2019 +0000
Revision:
7:b091a268b726
to make it compatible for other platforms see; https://github.com/wimbeaumont/peripheral_dev_tst; ( mbed os5  based)  but this still works for mbed os2

Who changed what in which revision?

UserRevisionLine numberNew contents of line
wbeaumont 7:b091a268b726 1 #ifndef __DEVERRORREPORTER__
wbeaumont 7:b091a268b726 2 #define __DEVERRORREPORTER__
wbeaumont 7:b091a268b726 3
wbeaumont 7:b091a268b726 4 //#include "getVersion.h"
wbeaumont 7:b091a268b726 5
wbeaumont 7:b091a268b726 6 #define DEVERRORREPORTER_HDR_VER "2.00"
wbeaumont 7:b091a268b726 7
wbeaumont 7:b091a268b726 8
wbeaumont 7:b091a268b726 9 /*
wbeaumont 7:b091a268b726 10 * This is a the Error reporter it stores the last errors etc.
wbeaumont 7:b091a268b726 11 * No getVersion support for the moment.
wbeaumont 7:b091a268b726 12 * This file make part of the PeriperalDevice package see repository
wbeaumont 7:b091a268b726 13 * https://github.com/wimbeaumont/PeripheralDevices
wbeaumont 7:b091a268b726 14 * For more info see the README.md in the top of repository
wbeaumont 7:b091a268b726 15 *
wbeaumont 7:b091a268b726 16 * ver 0:10 initial
wbeaumont 7:b091a268b726 17 * ver 0.20 needed static before const
wbeaumont 7:b091a268b726 18 * ver 0.30 device error int
wbeaumont 7:b091a268b726 19 * (C) Wim Beaumont Universiteit Antwerpen 2019
wbeaumont 7:b091a268b726 20 *
wbeaumont 7:b091a268b726 21 * License see
wbeaumont 7:b091a268b726 22 * https://github.com/wimbeaumont/PeripheralDevices/blob/master/LICENSE
wbeaumont 7:b091a268b726 23 */
wbeaumont 7:b091a268b726 24
wbeaumont 7:b091a268b726 25
wbeaumont 7:b091a268b726 26 class DevErrorReporter {
wbeaumont 7:b091a268b726 27
wbeaumont 7:b091a268b726 28 protected :
wbeaumont 7:b091a268b726 29 static const int notsupportederrno = -1999;
wbeaumont 7:b091a268b726 30 bool ack; // last ack status
wbeaumont 7:b091a268b726 31 bool notsupported;
wbeaumont 7:b091a268b726 32 int comerr; // reported Deverr
wbeaumont 7:b091a268b726 33 bool devinit; // if the device is initialized
wbeaumont 7:b091a268b726 34 bool setnotsupported(void) { comerr=notsupportederrno; notsupported=true;return comerr;}
wbeaumont 7:b091a268b726 35 int deverr;
wbeaumont 7:b091a268b726 36 DevErrorReporter(void){
wbeaumont 7:b091a268b726 37 ack=false;comerr=0; devinit=false; notsupported=false;
wbeaumont 7:b091a268b726 38 }
wbeaumont 7:b091a268b726 39 public:
wbeaumont 7:b091a268b726 40
wbeaumont 7:b091a268b726 41 // status info
wbeaumont 7:b091a268b726 42 virtual bool getLastAckStatus(void) { return ack; }
wbeaumont 7:b091a268b726 43 virtual bool getDeviceInitStatus(void) { return devinit; }
wbeaumont 7:b091a268b726 44 virtual int getLastComError(void) {return comerr;}
wbeaumont 7:b091a268b726 45 virtual bool getNotSupported(void) {return notsupported;}
wbeaumont 7:b091a268b726 46 virtual int getDeviceError(void) { return deverr; }
wbeaumont 7:b091a268b726 47
wbeaumont 7:b091a268b726 48
wbeaumont 7:b091a268b726 49 };
wbeaumont 7:b091a268b726 50 #endif