motorcontroldemo_035/Vsrc/V_UserMemory.c
2019-08-15 18:38:50 +03:00

138 lines
3.5 KiB
C

/*!
Copyright 2017 ÀÎ "ÍÈÈÝÒ" è ÎÎÎ "ÍÏÔ ÂÅÊÒÎÐ"
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_UserMemory.c
\brief Îá¸ðòêà äëÿ I2C ïàìÿòè
\author Ëàøêåâè÷ Ì.Ì., Øïàê Ä.Ì.
\version v 1.0 10/08/2019
*/
/** \addtogroup TUserMemory */
/*@{*/
#include "V_UserMemory.h"
#include "DSP.h"
#include "V_i2cMem.h"
//!Èíèöèàëèçàöèÿ
//!Èíèöèàëèçàöèÿ USERMEMORY
//! \memberof TUserMemory
void USERMEMORY_Init(TUserMemory *p)
{
i2cMem.init(&i2cMem);
}
//! Ïðîâåðêà, íå íóæíî ëè ñìåíèòü ñòðàíèöó
//! Ïðîâåðÿåò òåêóùèé àäðåñ íà ôëåøêå, ñ êîòîðûì ðàáîòàåò ïîëüçîâàòåëü. Åñëè àäðåñ âûøåë èç òåêóùåé ñòðàíèöû, ñòðàíèöà çàïèñûâàåòñÿ íà ôëåø è ÷èòàåòñÿ â RAM íîâûé
//! \memberof TUserMemory
void USERMEMORY_UpdateCurrentPage(TUserMemory *p, Uint16 spiaddr)
{
}
//! Çàïèñü â ïàìÿòü
//!Ìåäëåííàÿ ôóíêöèÿ, çàïèñûâàþùàÿ íà flash çàäàííûå äàííûå.
//!Ðàáîòàåò ñ çàêåøèðîâàííûìè â îïåðàòèâêå äàííûìè, à ôèçè÷åñê ïèøåò íà ôëåø òîëüêî åñëè àäðåñ âûëåç çà ãðàíèöû òåêóùåé ñòðàíèöû
//! Àäðåñ âî ôëåøå spiaddr, àäðåñ 16òè ðàçðÿäíûõ äàííûõ ïîëüçîâàòåëÿ startaddr, ðàçìåð data_length. Âñå â áàéòàõ
//! Ïðè âûïîëåíèè îïåðàöèè startaddr èíêðåìåíòèðóåòñÿ, à spiaddr íåò
//! \memberof TUserMemory
void USERMEMORY_Write(TUserMemory *p)
{
i2cMem.DSPstartaddr = p->MCUStartAddr;
i2cMem.MEMstartaddr = p->MemStartAddr;
i2cMem.data_length = p->data_length;
i2cMem.write(&i2cMem);
p->receivedCode = i2cMem.LastErr;
}
//! ×òåíèå èç ïàìÿòè
//!Ìåäëåííàÿ ôóíêöèÿ, ñ÷èòûâàþùàÿ èç flash çàäàííûå äàííûå. Ïîäðîáíîñòè ñì. TUserMemory.
//! Àäðåñ âî ôëåøå spiaddr, àäðåñ àäðåñ 16òè ðàçðÿäíûõ äàííûõ ïîëüçîâàòåëÿ startaddr, ðàçìåð data_length. Âñå â áàéòàõ.
//! Ïðè âûïîëåíèè îïåðàöèè startaddr èíêðåìåíòèðóåòñÿ, à spiaddr íåò
//! \memberof TUserMemory
void USERMEMORY_Read(TUserMemory *p)
{
i2cMem.DSPstartaddr = p->MCUStartAddr;
i2cMem.MEMstartaddr = p->MemStartAddr;
i2cMem.data_length = p->data_length;
i2cMem.read(&i2cMem);
p->receivedCode = i2cMem.LastErr;
}
//! Çàïèñûâàåò ñòðàíèöó äàííûå íà ôëåøêó èç êåøà (èç îïåðàòèâêè îäíó ñòðàíèöó)
//! \memberof TUserMemory
void USERMEMORY_WriteFromCache(TUserMemory *p, int16 pageNum)
{
}
//! ×èòàåò ñòðàíèöó äàííûõ èç ôëåøà â êåø (â îïåðàòèâêó)
//! \memberof TUserMemory
void USERMEMORY_ReadToCache(TUserMemory *p, int16 pageNum)
{
}
//! Ñòåðåòü âñþ ôëåøêó (áóäóò FF)
//! \memberof TUserMemory
void USERMEMORY_Full_Erase(TUserMemory *p){
i2cMem.clearMem(&i2cMem);
}
//! Ñáðîñèòü êåø èç îïåðàòèâêè íà ôëåøêó
//! \memberof TUserMemory
void USERMEMORY_Flush(TUserMemory *p){
}
//! Ìåäëåííûé ôîíîâûé ïîñòîÿííûé ðàñ÷åò - íóæåí ïîêà äëÿ ñèñòåìàòè÷åñêîãî ñáðîñà êåøà íà ôëåøêó ïî âðåìåíè
//! \memberof TUserMemory
void USERMEMORY_slow_calc(TUserMemory *p){
// }
}
//! Ìèëëèñåêóíäíûé ðàñ÷åò - íóæåí ïîêà äëÿ ñèñòåìàòè÷åñêîãî ñáðîñà êåøà íà ôëåøêó ïî âðåìåíè
//! \memberof TUserMemory
void USERMEMORY_ms_calc(TUserMemory *p){
}
/*@}*/