Cypress Semiconductor SL811HS Uživatelský manuál Strana 21

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 43
  • Tabulka s obsahem
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 20
Cypress Semiconductor Corporation
SL811HS and SL811HST: Application Notes
©2001 Cypress Semiconductor Corporation. All rights reserved. The information
and specifications contained in this document are subject to change without
notice.
Date: 07/26/01
Revision: 1.21
Page: 21
Program Sample 2: Write Buffer Function
void SL11BufWrite(short addr, BYTE *s, short c)void SL11BufWrite(short addr, BYTE *s, short c)
{{
if(c<=0) return; if(c<=0) return;
outportb(SL11_ADDR,addr); outportb(SL11_ADDR,addr);
while (c while (c----) outportb(SL) outportb(SL11_ADDR+1,*s++);11_ADDR+1,*s++);
}}
4.1.2 Single Read Operation
Reading a byte from the SL811HS involves an address write cycle, followed by a read cycle.
First, as in a data write, the application writes a register address into the SL811HS's Address
Pointer Register. The data is then read from the chip in a read cycle.
The function to read an SL811HS register is shown below:
Program Sample 3: Single Read Function
BYTE SL11Read(BYTE a)BYTE SL11Read(BYTE a)
{ {
outportb(SL11_ADDR,a); outportb(SL11_ADDR,a);
return (inportb(SL11_AD return (inportb(SL11_ADDR+1));DR+1));
}}
The Read Buffer function reads a block of data of a specific length from the buffer, which is
located by the pointer “addr.”
Program Sample 4: Read Buffer Function
void SL11BufRead(short addr, BYTE *s, short cvoid SL11BufRead(short addr, BYTE *s, short c))
{{
if( c <= 0) return; if( c <= 0) return;
outportb(SL11_ADDR, addr); outportb(SL11_ADDR, addr);
while (c while (c----) *s++ = (BYTE)inportb(SL11_ADDR+1);) *s++ = (BYTE)inportb(SL11_ADDR+1);
}}
4.1.3 Memory Test
The Memory test verifies read/write operation of the SL811HS internal memory.
Program Sample 5: Memory Test
int SL11HMemTest()int SL11HMemTest()
{ {
int errors = 0, i; int errors = 0, i;
for (i = EP0Buf; i < cMemEnd; i++) // addr = data for (i = EP0Buf; i < cMemEnd; i++) // addr = data
SL11Write((BYTE)i, (BYTE)i); SL11Write((BYTE)i, (BYTE)i);
Zobrazit stránku 20
1 2 ... 16 17 18 19 20 21 22 23 24 25 26 ... 42 43

Komentáře k této Příručce

Žádné komentáře