}
if ( _msg[pos] == '=' )
{
- if (_eType == TYPE_FLOAT)
- {
- Float32_t result;
- result = atof((const char *)(_msg+1+pos));
- m_Params->writeValue(nv,result);
- }
- else
- {
- parse_num(_msg+1+pos,len - 1 - pos,val);
- m_Params->writeValue(nv,val);
- }
+ writeParameter(nv,_eType,static_cast<const Uint8_t *>(_msg + 1 + pos),len - 1 - pos);
m_L2->setTxMsg((const uint8_t *)"OK\r\n",4);
} else if (_msg[pos] == '?')
{
}
}
+///
+void CommunicationHandler::readParameter(const Uint8_t paramId)
+{
+}
+/**
+ * Read eeprom and send it back to ...
+ */
+void CommunicationHandler::readEeprom(const Uint16_t _address)
+{
+}
+///
+void CommunicationHandler::writeParameter(const Uint8_t paramId
+ ,eParameterType _eType
+ ,const Uint8_t *_buf
+ ,Uint8_t len)
+{
+ if (_eType == TYPE_FLOAT)
+ {
+ Float32_t result;
+ result = atof((const char *)(_buf));
+ m_Params->writeValue(paramId,result);
+ }
+ else
+ {
+ Uint32_t val;
+ parse_num(_buf,len,val);
+ m_Params->writeValue(paramId,val);
+ }
+}
+
void
CommunicationHandler::parse_num(const Uint8_t *_msg,const Uint8_t len,Uint32_t &_out)
{
virtual void run();
private:
void parse_msg(const Uint8_t *_msg,const Uint8_t len,eParameterType _eT);
- ///
+ /// Not this is needed
void parse_num(const Uint8_t *_msg,const Uint8_t len, Uint32_t &_out);
+ ///
+ void readParameter(const Uint8_t paramId);
+ /**
+ * Read eeprom and send it back to ...
+ */
+ void readEeprom(const Uint16_t _address);
+ ///
+ void writeParameter(const Uint8_t paramId
+ ,eParameterType _eType
+ ,const Uint8_t *_buf
+ ,Uint8_t len);
private:
IProtocolLayer2 *m_L2;
IParameterHandler *m_Params;
*_dest = EEDR;
}
+
+void
+AvrEeprom::write(const Uint16_t _addr,Uint8_t _dest)
+{
+}
+
/// Interesting that eeprom is written page wise
void
AvrEeprom::writePage(const Uint8_t pageCount,const Uint8_t _Offset,const Uint8_t byteCount,Uint8_t *_data)
virtual void read( const Uint16_t _addr
, const Uint16_t _len
, Uint8_t *_dest);
+
+ /// write Byte Eeprom
+ virtual void write( const Uint16_t _addr
+ , Uint8_t _dest);
/// Interesting that eeprom is written page wise
virtual void writePage( const Uint8_t pageCount
/// Initialize
virtual void init() = 0;
/// Is eeprom busy, might be of interest, as eeprom access is performed through
- /// SPI
+ /// SPI or I2C
virtual Bool_t isBusy() = 0;
/// read values from Eeprom
virtual void read(const Uint16_t _addr,const Uint16_t _len,Uint8_t *_dest);
/// Interesting that eeprom is written page wise
- virtual void writePage(const Uint8_t pageCount,const Uint8_t _Offset,const Uint8_t byteCount,Uint8_t *_data);
+ virtual void writePage(const Uint8_t pageCount
+ ,const Uint8_t _Offset
+ ,const Uint8_t byteCount
+ ,Uint8_t *_data);
};
#endif
public:
typedef Uint8_t Error_t;
II2C() {};
-
virtual Error_t write(const Uint8_t argAddress,Uint8_t *argData, Uint8_t argLen) = 0;
virtual Error_t read(const Uint8_t argAddress,Uint8_t *argData ,Uint8_t argLen) = 0;
+ /*
+ * This works well for DS32 but not EEprom So, maybe I'll get ride of this method
+ * Also for PN532 it's not really what I need
+ */
virtual Error_t read( const Uint8_t argAddress
, const Uint8_t regAddr
, Uint8_t *argData
LiquidCrystal.cpp
PN532Interface_I2C.cpp
PN532.cpp
+ Eeprom24C32_64.cpp
)
--- /dev/null
+#include <Utils/StdTypes.h>
+
+#include "Abstract/II2C.h"
+#include "Abstract/IEEprom.h"
+#include "Drivers/Eeprom24C32_64.h"
+
+EEprom24C32::EEprom24C32(II2C *argI2C,Uint8_t argAddr )
+ : m_I2C(argI2C) , m_I2CAddress(argAddr)
+{
+}
+
+
+void
+EEprom24C32::init()
+{
+}
+/// Is eeprom busy, might be of interest, as eeprom access is performed through
+/// SPI or I2C
+Bool_t
+EEprom24C32::isBusy()
+{
+ return false;
+}
+
+/// read values from Eeprom
+void
+EEprom24C32::read(const Uint16_t _addr,const Uint16_t _len,Uint8_t *_dest)
+{
+ Uint8_t _Buff[2];
+ _Buff[0] = static_cast<Uint8_t>(_addr>>8);
+ _Buff[1] = static_cast<Uint8_t>(_addr & 0x00FF);
+ m_I2C->write(m_I2CAddress,_Buff,2);
+ m_I2C->read(m_I2CAddress,_dest,_len);
+}
+
+/// Interesting that eeprom is written page wise
+void
+EEprom24C32::writePage(const Uint8_t pageCount,const Uint8_t _Offset,const Uint8_t byteCount,Uint8_t *_data)
+{
+ Uint8_t _Buff[32 + 2];
+ // Compute Address
+ Uint16_t _addr = pageCount * 32 + _Offset;
+ _Buff[0] = static_cast<Uint8_t>(_addr>>8);
+ _Buff[1] = static_cast<Uint8_t>(_addr & 0x00FF);
+ for (Uint8_t i = 0 ; i < byteCount ; ++i)
+ _Buff[i+2] = _data[i];
+ m_I2C->write(m_I2CAddress,_Buff,2+byteCount);
+}
+
--- /dev/null
+#ifndef __EEPROM24C32_H__
+#define __EEPROM24C32_H__
+
+class EEprom24C32 : public IEeprom
+{
+ public:
+ EEprom24C32(II2C *argI2C,Uint8_t argAddr = 0xA0);
+
+ virtual void init() ;
+ /// Is eeprom busy, might be of interest, as eeprom access is performed through
+ /// SPI or I2C
+ virtual Bool_t isBusy();
+ /// read values from Eeprom
+ virtual void read( const Uint16_t _addr
+ , const Uint16_t _len
+ , Uint8_t *_dest );
+ /// write Byte Eeprom
+ virtual void write( const Uint16_t _addr
+ , Uint8_t _dest);
+
+ /// Interesting that eeprom is written page wise
+ virtual void writePage( const Uint8_t pageCount
+ , const Uint8_t _Offset
+ , const Uint8_t byteCount
+ , Uint8_t *_data);
+ private:
+ II2C *m_I2C;
+ Uint8_t m_I2CAddress;
+};
+
+#endif
+++ /dev/null
-Commande ECHO activ\82e.
+++ /dev/null
-Commande ECHO activ\82e.