C++ Library for the PsiSwarm Robot - Version 0.8
Dependents: PsiSwarm_V8_Blank_CPP Autonomia_RndmWlk
Fork of PsiSwarmV7_CPP by
eprom.h@8:6c92789d5f87, 2016-10-16 (annotated)
- Committer:
- jah128
- Date:
- Sun Oct 16 12:54:33 2016 +0000
- Revision:
- 8:6c92789d5f87
- Parent:
- 6:b340a527add9
Renamed to V8 [C++ version]; converted display, eprom and motor classes
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jah128 | 8:6c92789d5f87 | 1 | /* University of York Robotics Laboratory PsiSwarm Library: Eprom Functions Header File |
jah128 | 8:6c92789d5f87 | 2 | * |
jah128 | 6:b340a527add9 | 3 | * Copyright 2016 University of York |
jah128 | 6:b340a527add9 | 4 | * |
jah128 | 8:6c92789d5f87 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. |
jah128 | 6:b340a527add9 | 6 | * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 |
jah128 | 6:b340a527add9 | 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS |
jah128 | 8:6c92789d5f87 | 8 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
jah128 | 6:b340a527add9 | 9 | * See the License for the specific language governing permissions and limitations under the License. |
jah128 | 6:b340a527add9 | 10 | * |
jah128 | 0:d6269d17c8cf | 11 | * File: eprom.h |
jah128 | 0:d6269d17c8cf | 12 | * |
jah128 | 0:d6269d17c8cf | 13 | * (C) Dept. Electronics & Computer Science, University of York |
jah128 | 0:d6269d17c8cf | 14 | * James Hilder, Alan Millard, Alexander Horsfield, Homero Elizondo, Jon Timmis |
jah128 | 0:d6269d17c8cf | 15 | * |
jah128 | 8:6c92789d5f87 | 16 | * PsiSwarm Library Version: 0.8 |
jah128 | 0:d6269d17c8cf | 17 | * |
jah128 | 5:3cdd1a37cdd7 | 18 | * October 2016 |
jah128 | 0:d6269d17c8cf | 19 | * |
jah128 | 8:6c92789d5f87 | 20 | */ |
jah128 | 8:6c92789d5f87 | 21 | |
jah128 | 8:6c92789d5f87 | 22 | |
jah128 | 8:6c92789d5f87 | 23 | #ifndef EPROM_H |
jah128 | 8:6c92789d5f87 | 24 | #define EPROM_H |
jah128 | 8:6c92789d5f87 | 25 | |
jah128 | 8:6c92789d5f87 | 26 | /** Eprom Class |
jah128 | 0:d6269d17c8cf | 27 | * Functions for accessing the 64Kb EPROM chip and reading the reserved firmware block |
jah128 | 0:d6269d17c8cf | 28 | * |
jah128 | 0:d6269d17c8cf | 29 | * Example: |
jah128 | 0:d6269d17c8cf | 30 | * @code |
jah128 | 0:d6269d17c8cf | 31 | * #include "psiswarm.h" |
jah128 | 8:6c92789d5f87 | 32 | * |
jah128 | 0:d6269d17c8cf | 33 | * int main() { |
jah128 | 0:d6269d17c8cf | 34 | * init(); |
jah128 | 8:6c92789d5f87 | 35 | * eprom.write_eeprom_byte(0,0xDD); //Writes byte 0xDD in EPROM address 0 |
jah128 | 8:6c92789d5f87 | 36 | * char c = eprom.read_eeprom_byte(0); //c will hold 0xDD |
jah128 | 0:d6269d17c8cf | 37 | * //Valid address range is from 0 to 65279 |
jah128 | 0:d6269d17c8cf | 38 | * } |
jah128 | 0:d6269d17c8cf | 39 | * @endcode |
jah128 | 0:d6269d17c8cf | 40 | */ |
jah128 | 8:6c92789d5f87 | 41 | class Eprom |
jah128 | 8:6c92789d5f87 | 42 | { |
jah128 | 8:6c92789d5f87 | 43 | |
jah128 | 8:6c92789d5f87 | 44 | public: |
jah128 | 0:d6269d17c8cf | 45 | |
jah128 | 8:6c92789d5f87 | 46 | /** Write a single byte to the EPROM |
jah128 | 8:6c92789d5f87 | 47 | * |
jah128 | 8:6c92789d5f87 | 48 | * @param address The address to store the data, range 0-65279 |
jah128 | 8:6c92789d5f87 | 49 | * @param data The character to store |
jah128 | 8:6c92789d5f87 | 50 | */ |
jah128 | 8:6c92789d5f87 | 51 | void write_eeprom_byte ( int address, char data ); |
jah128 | 0:d6269d17c8cf | 52 | |
jah128 | 8:6c92789d5f87 | 53 | /** Read a single byte from the EPROM |
jah128 | 8:6c92789d5f87 | 54 | * |
jah128 | 8:6c92789d5f87 | 55 | * @param address The address to read from, range 0-65279 |
jah128 | 8:6c92789d5f87 | 56 | * @return The character stored at address |
jah128 | 8:6c92789d5f87 | 57 | */ |
jah128 | 8:6c92789d5f87 | 58 | char read_eeprom_byte ( int address ); |
jah128 | 0:d6269d17c8cf | 59 | |
jah128 | 8:6c92789d5f87 | 60 | /** Read the next byte from the EPROM, to be called after read_eeprom_byte |
jah128 | 8:6c92789d5f87 | 61 | * |
jah128 | 8:6c92789d5f87 | 62 | * @return The character stored at address after the previous one read from |
jah128 | 8:6c92789d5f87 | 63 | */ |
jah128 | 8:6c92789d5f87 | 64 | char read_next_eeprom_byte ( void ); |
jah128 | 0:d6269d17c8cf | 65 | |
jah128 | 8:6c92789d5f87 | 66 | /** Read the data stored in the reserved firmware area of the EPROM |
jah128 | 8:6c92789d5f87 | 67 | * |
jah128 | 8:6c92789d5f87 | 68 | * @return 1 if a valid firmware is read, 0 otherwise |
jah128 | 8:6c92789d5f87 | 69 | */ |
jah128 | 8:6c92789d5f87 | 70 | char read_firmware ( void ); |
jah128 | 0:d6269d17c8cf | 71 | |
jah128 | 8:6c92789d5f87 | 72 | }; |
jah128 | 8:6c92789d5f87 | 73 | |
jah128 | 8:6c92789d5f87 | 74 | #endif |