/**************************************************************************************
** sram.h
*/
#ifndef _SRAM_H
#define _SRAM_H

#define SRAM_DATA_DDR  DDRC
#define SRAM_DATA_IN   PINC
#define SRAM_DATAPORT  PORTC

#define SRAM_CNTL_DDR  DDRD
#define SRAM_CNTLPORT  PORTD

#define SRAM_SHIFT_CL   BIT3    // CP shift clock von P > N
#define SRAM_SHIFT_OE   BIT2    // OE output enable Positiv
#define SRAM_SHIFT_DA   BIT4    // D  shift input   Positiv

#define SRAM_MEM_WR     BIT5    // WE  Write          Negativ
#define SRAM_MEM_OE     BIT6    // OE  output enable  Negativ
#define SRAM_MEM_CE     BIT7    // CE1 enable         Negativ

#define SRAM_WRITE_ERROR  0b00010000        //  Fehler bei write loop
#define SRAM_READ_ERROR   0b00100000        //  Fehler bei read loop
#define SRAM_TEST_OK      0b00000001        //  Speicher ok

typedef struct
{
   unsigned char flag;
   unsigned char soll;
   unsigned char ist;
   unsigned int  adr;
#if TEST_SRAM
   unsigned int  ticks_write;
   unsigned int  ticks_read;
#endif
} S_SRAM;

void sram_init(void);

#if TEST_SRAM

                            // Speichertest
unsigned char sram_testmem( S_SRAM *, volatile unsigned int *);
#else
unsigned char sram_testmem( S_SRAM *);
#endif

                            // read von adresse das Datum
unsigned char sram_read( unsigned int );

                            // write datum an adresse
void sram_write( unsigned int, unsigned char );


#endif //_SRAM_H
