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/

getVersion.cpp

Committer:
wbeaumont
Date:
2019-09-10
Revision:
7:b091a268b726
Parent:
4:8cbf46e5e3e5

File content as of revision 7:b091a268b726:

#include "getVersion.h"

#define GETVERSION_SRC_VER  "0.22"


/*
 *  info see  getversion.h 
 * (C) Wim Beaumont Universiteit Antwerpen 2017
 *   ver 0.20
 *   ver 0.21 removed redefining NULL
 *   ver 0.22 removed some double spaces in output
*/

#ifdef MBED 
#include "mbed.h"
#else 
#include  <stdlib.h> 
#include  <stdio.h> 
#endif 

#include "dev_interface_def.h"



getVersion::getVersion(const char* ver_h,const char* ver_s, const char* time,const char* date) {
        sver=ver_s; hver=ver_h; ctime=time;cdate=date;
        sprintf(infostr,"HDR ver: %s, SRC ver: %s",sver,hver);
        
        } ;

getVersion::getVersion(){sver=0; hver=0; ctime=0;cdate=0;
            sprintf(infostr,"HDR ver: %s, SRC ver: %s",GETVERSION_HDR_VER,GETVERSION_SRC_VER);
};     


void getVersion::dev_interface_def_version( char* resultstring){
    sprintf( resultstring,"dev_interface_def version: %s", DEV_INTERFACE_DEF_VER);
}

void getVersion::get_dec_version( unsigned short  hexversion , unsigned char & version, unsigned char& subversion) {
        subversion =(unsigned short)(  hexversion & 0xFF);
        hexversion=hexversion >> 8; 
        version =(unsigned char)(  hexversion & 0xFF);
    }



unsigned short  getVersion::get_hex_version_nr(const char * vers){    
    float verf = strtof(vers,NULL);
    unsigned short version=(unsigned short) verf;
    verf=verf-version;
    version = version<<8;
    verf=verf*100;
    unsigned char  sub=(unsigned char)verf;
    version=version| sub;
    return version;
}   






unsigned short getVersion::getHdrVersion(){ 
    if( hver == NULL) return  get_hex_version_nr(GETVERSION_HDR_VER);
    else return get_hex_version_nr(hver);
    }

    unsigned short getVersion::getSrcVersion(){
          if( sver == NULL) return  get_hex_version_nr(GETVERSION_SRC_VER);
    else return get_hex_version_nr(sver);
 }


unsigned short getVersion::getCompileTime(){
    if ( ctime == NULL ) return 0;
    else return 0;
}
    

unsigned short getVersion::getCompileDate(){
    if ( cdate == NULL ) return 0;
    else return 0;
}

unsigned short getVersion::getCompileYear(){
    
    if ( cdate == NULL ) return 0;
    else return 0;
}

char* getVersion::getversioninfo(){
    return infostr;
}