#include <Ram.h>
Public Member Functions | |
unsigned char | getRamStatusRegister () |
void | init () |
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) |
Private Member Functions | |
void | disableRAMChip () |
void | enableRAMChip () |
Private Attributes | |
I2c | i2c |
Definition at line 14 of file Ram.h.
void Ram::disableRAMChip | ( | ) | [private] |
void Ram::enableRAMChip | ( | ) | [private] |
unsigned char Ram::getRamStatusRegister | ( | ) |
Funktion liefert das RAM Statusregister zurück
Definition at line 96 of file Ram.c.
00096 { 00097 /* 00098 unsigned char _sr = 0x00; 00099 00100 // SPI Schnittstelle aktivieren 00101 spi.enableSPI(); 00102 00103 // RAM Chip aktivieren 00104 this->enableRAMChip(); 00105 00106 // Kommando schicken 00107 spi.writeData(RAM_RDSR); 00108 00109 // Antwort auslesen 00110 _sr = spi.readData(); 00111 00112 // RAM Chip wieder deaktivieren 00113 this->disableRAMChip(); 00114 00115 // SPI wieder disabeln 00116 spi.disableSPI(); 00117 00118 return _sr;*/ 00119 }
void Ram::init | ( | void | ) |
initialize the memory module
Definition at line 63 of file Ram.c.
References i2c, and I2c::init().
Referenced by StateSpace::init().
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 }
void Ram::setRamStatusRegister | ( | unsigned char | _sr | ) |
Funktion setzt das RAM Statusregister auf _sr
Definition at line 122 of file Ram.c.
00122 { 00123 00124 // // SPI Schnittstelle aktivieren 00125 // spi.enableSPI(); 00126 // 00127 // // Write-Enable Kommando schicken 00128 // this->enableRAMChip(); 00129 // spi.writeData(RAM_WREN); 00130 // this->disableRAMChip(); 00131 // 00132 // // Write-Status-Register Kommando schicken 00133 // this->enableRAMChip(); 00134 // spi.writeData(RAM_WRSR); 00135 // spi.writeData(_sr); 00136 // this->disableRAMChip(); 00137 // 00138 // // SPI wieder disabeln 00139 // spi.disableSPI(); 00140 }
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 }