Psi Swarm robot library version 0.9
Fork of PsiSwarmV9 by
eprom.h@17:bf614e28668f, 2017-06-04 (annotated)
- Committer:
- jah128
- Date:
- Sun Jun 04 13:11:09 2017 +0000
- Revision:
- 17:bf614e28668f
- Parent:
- 14:2f1ad77d281e
- Child:
- 18:9204f74069b4
Updated calibration menus, fixed some bugs in demo, create new store_line_position routine using calibrated values
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 | 14:2f1ad77d281e | 3 | * Copyright 2017 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 | 14:2f1ad77d281e | 16 | * PsiSwarm Library Version: 0.9 |
jah128 | 0:d6269d17c8cf | 17 | * |
jah128 | 14:2f1ad77d281e | 18 | * June 2017 |
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 | 17:bf614e28668f | 26 | |
jah128 | 17:bf614e28668f | 27 | //FIRMWARE DEFAULTS |
jah128 | 17:bf614e28668f | 28 | //Batch number (0-255), Serial number (1 - 255) |
jah128 | 17:bf614e28668f | 29 | #define FD_BATCH_NUMBER 3 |
jah128 | 17:bf614e28668f | 30 | #define FD_SERIAL_NUMBER 1 |
jah128 | 17:bf614e28668f | 31 | #define FD_CREATE_DAY 01 |
jah128 | 17:bf614e28668f | 32 | #define FD_CREATE_MONTH 06 |
jah128 | 17:bf614e28668f | 33 | #define FD_CREATE_YEAR 17 |
jah128 | 17:bf614e28668f | 34 | #define FD_PCB_VERSION_BIG 1 |
jah128 | 17:bf614e28668f | 35 | #define FD_PCB_VERSION_LITTLE 6 |
jah128 | 17:bf614e28668f | 36 | |
jah128 | 17:bf614e28668f | 37 | //Firmware Version (eg 1.1) |
jah128 | 17:bf614e28668f | 38 | #define FD_FIRMWARE_VERSION_BIG 1 |
jah128 | 17:bf614e28668f | 39 | #define FD_FIRMWARE_VERSION_LITTLE 1 |
jah128 | 17:bf614e28668f | 40 | |
jah128 | 17:bf614e28668f | 41 | |
jah128 | 8:6c92789d5f87 | 42 | /** Eprom Class |
jah128 | 0:d6269d17c8cf | 43 | * Functions for accessing the 64Kb EPROM chip and reading the reserved firmware block |
jah128 | 0:d6269d17c8cf | 44 | * |
jah128 | 0:d6269d17c8cf | 45 | * Example: |
jah128 | 0:d6269d17c8cf | 46 | * @code |
jah128 | 0:d6269d17c8cf | 47 | * #include "psiswarm.h" |
jah128 | 8:6c92789d5f87 | 48 | * |
jah128 | 0:d6269d17c8cf | 49 | * int main() { |
jah128 | 0:d6269d17c8cf | 50 | * init(); |
jah128 | 8:6c92789d5f87 | 51 | * eprom.write_eeprom_byte(0,0xDD); //Writes byte 0xDD in EPROM address 0 |
jah128 | 8:6c92789d5f87 | 52 | * char c = eprom.read_eeprom_byte(0); //c will hold 0xDD |
jah128 | 0:d6269d17c8cf | 53 | * //Valid address range is from 0 to 65279 |
jah128 | 0:d6269d17c8cf | 54 | * } |
jah128 | 0:d6269d17c8cf | 55 | * @endcode |
jah128 | 0:d6269d17c8cf | 56 | */ |
jah128 | 8:6c92789d5f87 | 57 | class Eprom |
jah128 | 8:6c92789d5f87 | 58 | { |
jah128 | 8:6c92789d5f87 | 59 | |
jah128 | 8:6c92789d5f87 | 60 | public: |
jah128 | 0:d6269d17c8cf | 61 | |
jah128 | 8:6c92789d5f87 | 62 | /** Write a single byte to the EPROM |
jah128 | 8:6c92789d5f87 | 63 | * |
jah128 | 8:6c92789d5f87 | 64 | * @param address The address to store the data, range 0-65279 |
jah128 | 8:6c92789d5f87 | 65 | * @param data The character to store |
jah128 | 8:6c92789d5f87 | 66 | */ |
jah128 | 8:6c92789d5f87 | 67 | void write_eeprom_byte ( int address, char data ); |
jah128 | 0:d6269d17c8cf | 68 | |
jah128 | 8:6c92789d5f87 | 69 | /** Read a single byte from the EPROM |
jah128 | 8:6c92789d5f87 | 70 | * |
jah128 | 8:6c92789d5f87 | 71 | * @param address The address to read from, range 0-65279 |
jah128 | 8:6c92789d5f87 | 72 | * @return The character stored at address |
jah128 | 8:6c92789d5f87 | 73 | */ |
jah128 | 8:6c92789d5f87 | 74 | char read_eeprom_byte ( int address ); |
jah128 | 0:d6269d17c8cf | 75 | |
jah128 | 8:6c92789d5f87 | 76 | /** Read the next byte from the EPROM, to be called after read_eeprom_byte |
jah128 | 8:6c92789d5f87 | 77 | * |
jah128 | 8:6c92789d5f87 | 78 | * @return The character stored at address after the previous one read from |
jah128 | 8:6c92789d5f87 | 79 | */ |
jah128 | 8:6c92789d5f87 | 80 | char read_next_eeprom_byte ( void ); |
jah128 | 0:d6269d17c8cf | 81 | |
jah128 | 8:6c92789d5f87 | 82 | /** Read the data stored in the reserved firmware area of the EPROM |
jah128 | 8:6c92789d5f87 | 83 | * |
jah128 | 8:6c92789d5f87 | 84 | * @return 1 if a valid firmware is read, 0 otherwise |
jah128 | 8:6c92789d5f87 | 85 | */ |
jah128 | 8:6c92789d5f87 | 86 | char read_firmware ( void ); |
jah128 | 17:bf614e28668f | 87 | |
jah128 | 17:bf614e28668f | 88 | /** Update the firmware to include features from the current software version |
jah128 | 17:bf614e28668f | 89 | * |
jah128 | 17:bf614e28668f | 90 | */ |
jah128 | 17:bf614e28668f | 91 | void update_firmware( void ); |
jah128 | 17:bf614e28668f | 92 | |
jah128 | 17:bf614e28668f | 93 | void write_firmware(char _flash_count, char _create_day, char _create_month, char _create_year, char _batch_number, char _serial_number, char _pcb_version_big, char _pcb_version_little, char _firmware_version_big, |
jah128 | 17:bf614e28668f | 94 | char _firmware_version_little, char _has_compass, char _has_side_ir, char _has_base_ir, char _has_base_colour_sensor, char _has_top_colour_sensor, char _has_encoders, char _has_audio_pic, char _has_ultrasonic, |
jah128 | 17:bf614e28668f | 95 | char _has_temperature, char _has_recharging, char _has_433_radio, char _motor_calibration_set, char _base_ir_calibration_set, char _base_colour_calibration_set); |
jah128 | 0:d6269d17c8cf | 96 | |
jah128 | 17:bf614e28668f | 97 | |
jah128 | 17:bf614e28668f | 98 | void write_string(char value); |
jah128 | 17:bf614e28668f | 99 | |
jah128 | 17:bf614e28668f | 100 | void write_firmware_byte ( int address, char data ); |
jah128 | 17:bf614e28668f | 101 | char read_firmware_byte ( int address ); |
jah128 | 17:bf614e28668f | 102 | |
jah128 | 17:bf614e28668f | 103 | void IF_write_base_ir_calibration_values(short white_values[5], short black_values[5]); |
jah128 | 17:bf614e28668f | 104 | void IF_write_base_colour_calibration_values(int white_values[4], int black_values[4]); |
jah128 | 8:6c92789d5f87 | 105 | }; |
jah128 | 8:6c92789d5f87 | 106 | |
jah128 | 8:6c92789d5f87 | 107 | #endif |