Psi Swarm robot library version 0.9

Dependents:   PsiSwarm_V9_Blank

Fork of PsiSwarmV9 by James Hilder

Committer:
richardredpath
Date:
Mon Jul 08 10:50:40 2019 +0000
Revision:
20:2b6ebe60929d
Parent:
19:3e3b03d80ea3
Fixed deprecated warnings for callbacks throughout the library

Who changed what in which revision?

UserRevisionLine numberNew 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 19:3e3b03d80ea3 39 #define FD_FIRMWARE_VERSION_LITTLE 2
jah128 19:3e3b03d80ea3 40 #define FD_HAS_COMPASS 0
jah128 19:3e3b03d80ea3 41 #define FD_HAS_SIDE_IR 1
jah128 19:3e3b03d80ea3 42 #define FD_HAS_BASE_IR 1
jah128 19:3e3b03d80ea3 43 #define FD_HAS_BASE_COLOUR 1
jah128 19:3e3b03d80ea3 44 #define FD_HAS_TOP_COLOUR 0
jah128 19:3e3b03d80ea3 45 #define FD_HAS_ENCODERS 0
jah128 19:3e3b03d80ea3 46 #define FD_HAS_AUDIO_PIC 0
jah128 19:3e3b03d80ea3 47 #define FD_HAS_ULTRASONIC 0
jah128 19:3e3b03d80ea3 48 #define FD_HAS_TEMPERATURE 1
jah128 19:3e3b03d80ea3 49 #define FD_HAS_RECHARGING 1
jah128 19:3e3b03d80ea3 50 #define FD_HAS_433_RADIO 0
jah128 17:bf614e28668f 51
jah128 17:bf614e28668f 52
jah128 8:6c92789d5f87 53 /** Eprom Class
jah128 0:d6269d17c8cf 54 * Functions for accessing the 64Kb EPROM chip and reading the reserved firmware block
jah128 0:d6269d17c8cf 55 *
jah128 0:d6269d17c8cf 56 * Example:
jah128 0:d6269d17c8cf 57 * @code
jah128 0:d6269d17c8cf 58 * #include "psiswarm.h"
jah128 8:6c92789d5f87 59 *
jah128 0:d6269d17c8cf 60 * int main() {
jah128 0:d6269d17c8cf 61 * init();
jah128 8:6c92789d5f87 62 * eprom.write_eeprom_byte(0,0xDD); //Writes byte 0xDD in EPROM address 0
jah128 8:6c92789d5f87 63 * char c = eprom.read_eeprom_byte(0); //c will hold 0xDD
jah128 0:d6269d17c8cf 64 * //Valid address range is from 0 to 65279
jah128 0:d6269d17c8cf 65 * }
jah128 0:d6269d17c8cf 66 * @endcode
jah128 0:d6269d17c8cf 67 */
jah128 8:6c92789d5f87 68 class Eprom
jah128 8:6c92789d5f87 69 {
jah128 8:6c92789d5f87 70
jah128 8:6c92789d5f87 71 public:
jah128 0:d6269d17c8cf 72
jah128 8:6c92789d5f87 73 /** Write a single byte to the EPROM
jah128 8:6c92789d5f87 74 *
jah128 8:6c92789d5f87 75 * @param address The address to store the data, range 0-65279
jah128 8:6c92789d5f87 76 * @param data The character to store
jah128 8:6c92789d5f87 77 */
jah128 8:6c92789d5f87 78 void write_eeprom_byte ( int address, char data );
jah128 0:d6269d17c8cf 79
jah128 8:6c92789d5f87 80 /** Read a single byte from the EPROM
jah128 8:6c92789d5f87 81 *
jah128 8:6c92789d5f87 82 * @param address The address to read from, range 0-65279
jah128 8:6c92789d5f87 83 * @return The character stored at address
jah128 8:6c92789d5f87 84 */
jah128 8:6c92789d5f87 85 char read_eeprom_byte ( int address );
jah128 0:d6269d17c8cf 86
jah128 8:6c92789d5f87 87 /** Read the next byte from the EPROM, to be called after read_eeprom_byte
jah128 8:6c92789d5f87 88 *
jah128 8:6c92789d5f87 89 * @return The character stored at address after the previous one read from
jah128 8:6c92789d5f87 90 */
jah128 8:6c92789d5f87 91 char read_next_eeprom_byte ( void );
jah128 0:d6269d17c8cf 92
jah128 8:6c92789d5f87 93 /** Read the data stored in the reserved firmware area of the EPROM
jah128 8:6c92789d5f87 94 *
jah128 8:6c92789d5f87 95 * @return 1 if a valid firmware is read, 0 otherwise
jah128 8:6c92789d5f87 96 */
jah128 8:6c92789d5f87 97 char read_firmware ( void );
jah128 17:bf614e28668f 98
jah128 17:bf614e28668f 99 /** Update the firmware to include features from the current software version
jah128 17:bf614e28668f 100 *
jah128 17:bf614e28668f 101 */
jah128 17:bf614e28668f 102 void update_firmware( void );
jah128 17:bf614e28668f 103
jah128 17:bf614e28668f 104 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 105 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 18:9204f74069b4 106 char _has_temperature, char _has_recharging, char _has_433_radio, char _motor_calibration_set, char _base_ir_calibration_set, char _base_colour_calibration_set, short _boot_count);
jah128 0:d6269d17c8cf 107
jah128 17:bf614e28668f 108
jah128 17:bf614e28668f 109 void write_string(char value);
jah128 17:bf614e28668f 110
jah128 17:bf614e28668f 111 void write_firmware_byte ( int address, char data );
jah128 17:bf614e28668f 112 char read_firmware_byte ( int address );
jah128 17:bf614e28668f 113
jah128 19:3e3b03d80ea3 114 void firmware_writer(void);
jah128 19:3e3b03d80ea3 115 const char * IF_get_state(char value);
jah128 17:bf614e28668f 116 void IF_write_base_ir_calibration_values(short white_values[5], short black_values[5]);
jah128 17:bf614e28668f 117 void IF_write_base_colour_calibration_values(int white_values[4], int black_values[4]);
jah128 18:9204f74069b4 118 void IF_write_motor_calibration_values(float left_motor_calibration_value, int left_motor_offset, float right_motor_calibration_value, int right_motor_offset);
jah128 8:6c92789d5f87 119 };
jah128 8:6c92789d5f87 120
jah128 8:6c92789d5f87 121 #endif