📄 e2prom_1.asm
字号:
;------------------------------------------------------------------------------
; FILENAME: E2PROM_1.asm
; VERSION: Rev A, 2002 JUL 25
;------------------------------------------------------------------------------
; DESCRIPTION:
; Routines in this file perform E2PROM_1 User Module Read and
; Write operations.
;
; They provide a layer of abstraction on top of the E2PROMLIB.asm routines
; to allow instancing of the EEPROM devices. Together the E2PROM and
; E2PROMLIB algorithms emulate a byte-wise EEPROM device on a block oriented
; flash architecture.
;------------------------------------------------------------------------------
; Copyright (c) Cypress MicroSystems 2000-2002. All rights reserved.
;------------------------------------------------------------------------------
export E2PROM_1_bE2Write
export _E2PROM_1_bE2Write
export E2PROM_1_E2Read
export _E2PROM_1_E2Read
export E2PROM_1_RESERVED
;--------------------------------
; Includes
;--------------------------------
include "E2PROM_1.inc"
;-----------------------------------------------------------------
; Allocate the E2PROM_1 EEPROM device in Flash memory
; This will allow the linker to perform memory collision
; checking and the EEPROM device will be displayed in the
; map file.
; Note that this memory region can also be accessed from "C".
;-----------------------------------------------------------------
AREA E2PROM_1_AREA (ROM,ABS)
ORG E2PROM_1_START_ADDR
_E2PROM_1_RESERVED::
E2PROM_1_RESERVED:: blkb 40h
AREA text (ROM,REL)
;------------------------------------------------------------------------------
; FUNCTION NAME: E2Write
;
; DESCRIPTION:
; Writes the specified E2PROM data at the wAddr and wByteCount from RAM into
; Flash into the defined E2PROM.
;
; On entry - NOTE two entry points!!!
; X must point to calling arguments in the following offset from X:
; wAddr: 5 2-bytes
; pbData: 3 2-bytes
; wByteCount: 1 2-bytes
; cTemperature: 0 1-byte
;
; Prototype in C is:
;
; #pragma fastcall E2Write
; void E2PROM_1_bE2Write( WORD wAddr, BYTE * pbData, WORD wByteCount,
; CHAR cTermperature );
;
; (!!!note that C places arguments Right-to-Left onto the stack!!!)
;
; Easiest method to call from assembly is as follows:
; push X
; mov X, SP
; push <cTemperature>
; push <wByteCount>
; push <wByteCount+1>
; push <0> ; MSB of pbDataDest is always 0
; push <pbDataDest>
; push <wAddr>
; push <wAddr+1>
; call E2PROM_1_bE2Write
; add SP, -E2_RD_ARG_STACK_FRAME_SIZE
; pop X
;
; where <> refers to any addressing mode or number of instructions to
; place the referenced data on the stack frame.
;
; Other method is to create a stack frame using the defined equates and
; load them into the stack frame using [X+E2_WR_ARG_*] offset addressing mode.
;
; ARGUMENTS:
;
; wAddr: WORD - relative OFFSET in defined E2PROM to write data
; pbData: BYTE * - pointer to the RAM buffer of data to write
; wByteCount: WORD - number of bytes to write into E2PROM
; cTemperature: CHAR - temperature in degrees celsius
;
; RETURNS: NOERROR, FAILURE, or STACKOVERFLOW
;
; SIDE EFFECTS: If a partial block is to be saved to flash, then a 64 byte buffer
; is temporary allocated.
;
; PROCEDURE:
; 1) Place the Starting Block ID into the accumulator
; 2) Jump to the bE2Write algorithm in the E2PROMLIB
;------------------------------------------------------------------------------
;------------------
; Assembly Entry
;------------------
E2PROM_1_bE2Write::
mov A, E2PROM_1_START_BLOCK
ljmp bE2Write
;------------------
; 'C' Entry
;------------------
_E2PROM_1_bE2Write::
mov A, E2PROM_1_START_BLOCK
ljmp _bE2Write
;-----------------------------------------------------------------------------
; FUNCTION NAME: E2Read
;
; DESCRIPTION:
; Reads the specified E2PROM data at offset=wAddr for wByteCount bytes and
; places the data read into the RAM buffer pbDataDest.
;
; On entry - NOTE two entry points!!!
; X must point to calling arguments in the following offset from X:
; wByteCount 0 2-bytes
; pbDataDest 2 2-bytes
; wAddr: 4 2-bytes
;
; Prototype in C is:
;
; #pragma fastcall E2Read
; void E2PROM_1_E2Read( WORD wAddr, BYTE * pbDataDest, WORD wByteCount );
;
; (!!!note that C places arguments Right-to-Left onto the stack!!!)
;
; Easiest method to call from assembly is as follows:
; push X
; mov X, SP
; push <wByteCount>
; push <wByteCount+1>
; push <0> ; MSB of pbDataDest is always 0
; push <pbDataDest>
; push <wAddr>
; push <wAddr+1>
; call E2PROM_1_E2Read
; add SP, -E2_RD_ARG_STACK_FRAME_SIZE
; pop X
;
; where <> refers to any addressing mode or number of instructions to
; place the referenced data on the stack frame.
;
; Other method is to create a stack frame using the defined equates and
; load them into the stack frame using [X+E2_RD_ARG_*] offset addressing mode.
;
; ARGUMENTS:
;
; bFirstBlockId BYTE - first block ID of E2PROM device
; wAddr: WORD - relative OFFSET in defined E2PROM to read data
; pbDataDest: BYTE * - pointer to the RAM buffer to place read data
; wByteCount: WORD - number of bytes to read from E2PROM
;
; RETURNS: NONE.
;
; SIDE EFFECTS: NONE.
;
; PROCEDURE:
; 1) Place the Starting Block ID into the accumulator
; 2) Jump to the bE2Write algorithm in the E2PROMLIB
;-----------------------------------------------------------------------------
;------------------
; Assembly Entry
;------------------
E2PROM_1_E2Read::
mov A, E2PROM_1_START_BLOCK
ljmp E2Read
;------------------
; 'C' Entry
;------------------
_E2PROM_1_E2Read::
mov A, E2PROM_1_START_BLOCK
ljmp _E2Read
; End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -