Ram Class Reference

#include <Ram.h>

Collaboration diagram for Ram:
Collaboration graph
[legend]

Public Member Functions

unsigned char getRamStatusRegister ()
 Ram ()
void readBytes (uint16_t _addr, unsigned char *_data, unsigned char _length)
void setRamStatusRegister (unsigned char _sr)
void writeBytes (uint16_t _addr, unsigned char *_data, unsigned char _length)
 ~Ram ()

Private Member Functions

void disableRAMChip ()
void enableRAMChip ()

Private Attributes

I2ci2c

Detailed Description

Definition at line 14 of file Ram.h.


Constructor & Destructor Documentation

Ram::Ram (  ) 

initialize the memory module

Definition at line 63 of file Ram.c.

References i2c.

00063          {
00064 
00065      //initialize SPI bus
00066      i2c = new I2c();
00067      
00068 }

Ram::~Ram (  ) 

destructor

Definition at line 72 of file Ram.c.

References i2c.

00072           {
00073      delete i2c;
00074 }


Member Function Documentation

void Ram::disableRAMChip (  )  [private]

Diese Funktion, setzt die Chip-Select Leitung auf high (inaktiv) und deaktiviert somit das RAM. Zusätzlich wird Write-protect ausgeschaltet.

Definition at line 93 of file Ram.c.

00093                          {
00094 
00095      // Chip-Select auf High
00096 //   PORTA |= ((1<<PA6));
00097 //   PORTA |= (1<<PA1) | (1<<PA0);
00098 }

void Ram::enableRAMChip (  )  [private]

Diese Funktion, setzt die Chip-Select Leitung auf low (aktiv) und aktiviert somit das RAM Zusätzlich wird Write-protect ausgeschaltet.

Definition at line 81 of file Ram.c.

00081                         {
00082 
00083      // Chip-Select auf Low
00084 //   PORTA &= ~((1<<PA6));
00085 //   PORTA |= (1<<PA1) | (1<<PA0);
00086 }

unsigned char Ram::getRamStatusRegister (  ) 

Funktion liefert das RAM Statusregister zurück

Definition at line 102 of file Ram.c.

00102                                         {
00103 /*
00104      unsigned char _sr = 0x00;
00105 
00106      // SPI Schnittstelle aktivieren
00107      spi.enableSPI();    
00108 
00109      // RAM Chip aktivieren 
00110      this->enableRAMChip();
00111 
00112      // Kommando schicken
00113      spi.writeData(RAM_RDSR);
00114      
00115      // Antwort auslesen
00116      _sr = spi.readData();
00117      
00118      // RAM Chip wieder deaktivieren
00119      this->disableRAMChip();
00120 
00121      // SPI wieder disabeln 
00122      spi.disableSPI();
00123 
00124      return _sr;*/
00125 }

void Ram::readBytes ( uint16_t  _addr,
unsigned char *  _data,
unsigned char  _length 
)

read a state from the memory

Definition at line 30 of file Ram.c.

References i2c, I2c::readByte(), I2c::readByteWithoutAck(), I2c::sendStart(), I2c::sendStop(), and I2c::writeByte().

Referenced by StateSpace::getState(), and StateSpace::ramtestReadBytes().

00030                                                                                {
00031 
00032 
00033      unsigned char *bytes;
00034      register unsigned char i=0;
00035      unsigned char slave = 0xA0;
00036 
00037      // send start-condition 
00038      i2c->sendStart();
00039      
00040      // FM24C512 specific addressing
00041      i2c->writeByte( slave ); 
00042           
00043      // send address
00044      bytes = (unsigned char*)&_addr;
00045      i2c->writeByte(bytes[0]);
00046      i2c->writeByte(bytes[1]);
00047      i2c->sendStart();
00048      i2c->writeByte(0xA1);
00049      
00050      // send data
00051      for (i=0; i<(_length-1); i++) {
00052           _data[i] = i2c->readByte();
00053      }
00054      _data[i] = i2c->readByteWithoutAck();
00055      
00056      
00057      // send stop condition
00058      i2c->sendStop();
00059 }

Here is the call graph for this function:

void Ram::setRamStatusRegister ( unsigned char  _sr  ) 

Funktion setzt das RAM Statusregister auf _sr

Definition at line 128 of file Ram.c.

00128                                                 {
00129 
00130 //   // SPI Schnittstelle aktivieren
00131 //   spi.enableSPI();
00132 // 
00133 //   // Write-Enable Kommando schicken
00134 //   this->enableRAMChip();
00135 //   spi.writeData(RAM_WREN);
00136 //   this->disableRAMChip();
00137 // 
00138 //   // Write-Status-Register Kommando schicken
00139 //   this->enableRAMChip();
00140 //   spi.writeData(RAM_WRSR);
00141 //   spi.writeData(_sr);
00142 //   this->disableRAMChip();
00143 // 
00144 //   // SPI wieder disabeln 
00145 //   spi.disableSPI();
00146 }

void Ram::writeBytes ( uint16_t  _addr,
unsigned char *  _data,
unsigned char  _length 
)

saves a state into the memory

Definition at line 4 of file Ram.c.

References i2c, I2c::sendStart(), I2c::sendStop(), and I2c::writeByte().

Referenced by StateSpace::ramtestSaveBytes(), and StateSpace::setState().

00004                                                                                 {
00005 
00006      unsigned char *bytes;
00007      register unsigned char i;
00008      unsigned char slave = 0xA0;
00009      
00010      // send start-condition 
00011      i2c->sendStart();
00012      
00013      // FM24C512 specific addressing
00014      i2c->writeByte( slave ); 
00015      
00016      bytes = (unsigned char*)&_addr;
00017      i2c->writeByte(bytes[0]);
00018      i2c->writeByte(bytes[1]);
00019      
00020      // send data
00021      for (i=0; i<_length; i++) {
00022           i2c->writeByte(_data[i]);
00023      }
00024      
00025      // send stop condition
00026      i2c->sendStop();
00027 }

Here is the call graph for this function:


Field Documentation

I2c* Ram::i2c [private]

Definition at line 31 of file Ram.h.

Referenced by Ram(), readBytes(), writeBytes(), and ~Ram().


The documentation for this class was generated from the following files:
Generated on Fri Oct 8 17:10:10 2010 for Crawling Robot Microcontroller Software by  doxygen 1.6.3