motorcontroldemo_035/Vinclude/V_i2cMem.h
2019-08-16 11:38:16 +03:00

60 lines
1.8 KiB
C

/*!
Copyright 2019 ÀÎ "ÍÈÈÝÒ" è ÎÎÎ "ÍÏÔ ÂÅÊÒÎÐ"
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
\file v_i2cMem.h
\brief Äðàéâåð äëÿ ðàáîòû ñ ìèêðîñõåìîé ôëåø ïàìÿòè 24LC256 ïî
èíòåðôåéñó I2C
\author ÎÎÎ "ÍÏÔ Âåêòîð". http://motorcontrol.ru
\version v 1.0 10/08/2019
\addtogroup v_i2cMem
@{
*/
#ifndef INCLUDE_V_I2CMEM_H_
#define INCLUDE_V_I2CMEM_H_
#define EEPROM_MEM_LENGTH 32768 // Ðàçìåð ïàìÿòè â áàéòàõ (256 êáèò)
struct SI2cMem;
typedef volatile struct SI2cMem TI2cMem;
struct SI2cMem {
Uint16 MEMstartaddr; //! Àäðåñ íà flash
Uint16 data_length; //! Äëèíà äàííûõ â áàéòàõ
Uint16 *DSPstartaddr; //! Àäðåñ íà ìàññèâ ñ äàííûìè â êîíòðîëëåðå
Uint16 LastErr; //! Êîä îøèáêè (åñëè âîçíèêëà)
void (*init)(TI2cMem*);
void (*write)(TI2cMem*);
void (*read)(TI2cMem*);
void (*clearMem)(TI2cMem*);
};
void I2CMEM_Init(TI2cMem*);
void I2CMEM_Write(TI2cMem*);
void I2CMEM_Read(TI2cMem*);
void I2CMEM_Clear(TI2cMem*);
//!Èíèöèàëèçàòîð ïî óìîë÷àíèþ
#define I2CMEM_DEFAULTS { .init = I2CMEM_Init, \
.write = I2CMEM_Write,\
.read = I2CMEM_Read,\
.clearMem = I2CMEM_Clear,\
}
extern TI2cMem i2cMem;
#endif /* INCLUDE_V_I2CMEM_H_ */