forked library
Fork of Ser23K256 by
Revision 1:d8180cb9d9ab, committed 2014-08-28
- Comitter:
- k4zuki
- Date:
- Thu Aug 28 17:23:36 2014 +0000
- Parent:
- 0:d049f6422506
- Commit message:
- changed all definition by char to uint8_t
Changed in this revision
Ser23K256.cpp | Show annotated file Show diff for this revision Revisions of this file |
Ser23K256.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/Ser23K256.cpp Fri Mar 04 15:22:24 2011 +0000 +++ b/Ser23K256.cpp Thu Aug 28 17:23:36 2014 +0000 @@ -18,22 +18,22 @@ _ncs = 1; } -void Ser23K256::writeStatus(char status) { +void Ser23K256::writeStatus(uint8_t status) { select(); _spi.write(WRITE_STATUS); _spi.write(status); deselect(); } -char Ser23K256::readStatus() { +uint8_t Ser23K256::readStatus() { select(); _spi.write(READ_STATUS); - char result = (char) _spi.write(0); + uint8_t result = (uint8_t) _spi.write(0); deselect(); return result; } -void Ser23K256::prepareCommand(char command, int address) { +void Ser23K256::prepareCommand(uint8_t command, int address) { select(); _spi.write(command); _spi.write(address >> 8); @@ -42,17 +42,17 @@ // write or read a single byte -void Ser23K256::write(int address, char byte) { +void Ser23K256::write(int address, uint8_t byte) { prepareCommand(WRITE, address); _spi.write(byte); deselect(); } -char Ser23K256::read(int address) { +uint8_t Ser23K256::read(int address) { prepareCommand(READ, address); int result = _spi.write(0); deselect(); - return (char) result; + return (uint8_t) result; } // buffered write and read @@ -63,7 +63,7 @@ * at the start and return it to byte mode at the end. */ -void Ser23K256::write(int address, char * buffer, int count) { +void Ser23K256::write(int address, uint8_t * buffer, int count) { writeStatus(SEQUENTIAL_MODE); prepareCommand(WRITE, address); for (int i = 0; i < count; i++) { @@ -73,7 +73,7 @@ writeStatus(BYTE_MODE); } -void Ser23K256::read(int address, char * buffer, int count) { +void Ser23K256::read(int address, uint8_t * buffer, int count) { writeStatus(SEQUENTIAL_MODE); prepareCommand(READ, address); for (int i = 0; i < count; i++) {
--- a/Ser23K256.h Fri Mar 04 15:22:24 2011 +0000 +++ b/Ser23K256.h Thu Aug 28 17:23:36 2014 +0000 @@ -39,7 +39,7 @@ * Ser23K256 sram(spi,p14); * * int main() { -* char buff[50]; +* uint8_t buff[50]; * sram.write(0, 'h'); * sram.write(1, 'i'); * sram.write(2, '!'); @@ -75,32 +75,32 @@ Ser23K256(SPI& spi, PinName ncs); /** read a byte from SRAM * @param address The address to read from -* @return the character at that address +* @return the uint8_tacter at that address */ - char read(int address); + uint8_t read(int address); /** read multiple bytes from SRAM into a buffer * @param address The SRAM address to read from * @param buffer The buffer to read into (must be big enough!) * @param count The number of bytes to read */ - void read(int address, char * buffer, int count); + void read(int address, uint8_t * buffer, int count); /** write a byte to SRAM * @param address The address SRAM to write to * @param byte The byte to write there */ - void write(int address, char byte); + void write(int address, uint8_t byte); /** write multiple bytes to SRAM from a buffer * @param address The SRAM address write to * @param buffer The buffer to write from * @param count The number of bytes to write */ - void write(int address, char * buffer, int count); + void write(int address, uint8_t * buffer, int count); private: SPI& _spi; DigitalOut _ncs; - char readStatus(); - void writeStatus(char status); - void prepareCommand(char command, int address); + uint8_t readStatus(); + void writeStatus(uint8_t status); + void prepareCommand(uint8_t command, int address); void select(); void deselect(); };