⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mcohw_nvol_sim.c

📁 CanOpen的源代码
💻 C
字号:
/**************************************************************************
MODULE:    MCOHW_NVOL_SIM
CONTAINS:  Simulation of non-volatile memory, here in regular RAM
COPYRIGHT: Embedded Systems Academy, Inc. 2002-2007.
           All rights reserved. www.microcanopen.com
           This software was written in accordance to the guidelines at
           www.esacademy.com/software/softwarestyleguide.pdf
DISCLAIM:  Read and understand our disclaimer before using this code!
           www.esacademy.com/disclaim.htm
LICENSE:   THIS IS THE EDUCATIONAL VERSION OF MICROCANOPEN
           See file license_educational.txt or
           www.microcanopen.com/license_educational.txt
           A commercial MicroCANopen license is available at
           www.CANopenStore.com
VERSION:   3.30, ESA 30-JAN-07
           $LastChangedDate: 2007-01-12 12:53:59 -0800 (Wed, 12 Jan 2007) $
           $LastChangedRevision: 48 $
***************************************************************************/ 

#include "mcohw.h"

// In this simulation just grab a few bytes of RAM
#define NVOL_STORE_START 4
#define NVOL_STORE_SIZE 8

// Simulated non-volatile memory, here: regular RAM
//UNSIGNED8 mNVOL[NVOL_STORE_START+NVOL_STORE_SIZE];
static UNSIGNED8 *mNVOL; // DEBUG/TEST: here grabbing some free RAM

/**************************************************************************
DOES:    Initializes access to non-volatile memory.
**************************************************************************/
void NVOL_Init (
  void
  )
{
}


/**************************************************************************
DOES:    Reads a data byte from non-volatile memory
NOTE:    The address is relative, an offset to NVOL_STORE_START
RETURNS: The data read from memory
**************************************************************************/
UNSIGNED8 NVOL_ReadByte (
  UNSIGNED16 address // location of byte in NVOL memory
  )
{
  mNVOL = (UNSIGNED8 *) 0x3F8; // DEBUG/TEST: here grabbing some free RAM
  address += NVOL_STORE_START;

  // Protect from illegal address access
  if ((address >= NVOL_STORE_START) && (address < NVOL_STORE_START+NVOL_STORE_SIZE))
  {
    return mNVOL[address];
  }
  return 0;
}


/**************************************************************************
DOES:    Writes a data byte to non-volatile memory
NOTE:    The address is relative, an offset to NVOL_STORE_START
RETURNS: nothing
**************************************************************************/
void NVOL_WriteByte (
  UNSIGNED16 address, // location of byte in NVOL memory
  UNSIGNED8 dat
  )
{
  mNVOL = (UNSIGNED8 *) 0x3F8L; // DEBUG/TEST: here grabbing some free RAM
  address += NVOL_STORE_START;

  // Protect from illegal address access
  if ((address >= NVOL_STORE_START) && (address < NVOL_STORE_START+NVOL_STORE_SIZE))
  {
    mNVOL[address] = dat;
  }
}

/*----------------------- END OF FILE ----------------------------------*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -