JLC test

Dependencies:   PinDetect libmDot mbed-rtos mbed

Committer:
tmulrooney
Date:
Sat Jan 30 17:02:23 2016 +0000
Revision:
2:376af6a70e8a
Parent:
1:96c429800568
using UART 2 - not working

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tmulrooney 1:96c429800568 1 /* ========================================
tmulrooney 1:96c429800568 2 * Filename: common.h
tmulrooney 1:96c429800568 3 *
tmulrooney 1:96c429800568 4 * Description: common defintions and structures
tmulrooney 1:96c429800568 5 *
tmulrooney 1:96c429800568 6 * Copyright J-Factor Embedded Technologies 2015
tmulrooney 1:96c429800568 7 * Copyright TJM Embedded Software 2015
tmulrooney 1:96c429800568 8 * All Rights Reserved
tmulrooney 1:96c429800568 9 * UNPUBLISHED, LICENSED SOFTWARE.
tmulrooney 1:96c429800568 10 *
tmulrooney 1:96c429800568 11 * CONFIDENTIAL AND PROPRIETARY INFORMATION
tmulrooney 1:96c429800568 12 * WHICH IS THE PROPERTY OF J-Factor Embedded Technologies.
tmulrooney 1:96c429800568 13 *
tmulrooney 1:96c429800568 14 * ========================================
tmulrooney 1:96c429800568 15 */
tmulrooney 1:96c429800568 16 /** \file
tmulrooney 1:96c429800568 17 * \brief contains constants and prototypes needed by other files.
tmulrooney 1:96c429800568 18 */
tmulrooney 1:96c429800568 19 #ifndef COMMON_H
tmulrooney 1:96c429800568 20 #define COMMON_H
tmulrooney 1:96c429800568 21
tmulrooney 1:96c429800568 22 #include <time.h>
tmulrooney 1:96c429800568 23 #include "mbed.h"
tmulrooney 1:96c429800568 24
tmulrooney 1:96c429800568 25 /* Project Defines */
tmulrooney 1:96c429800568 26 #define FALSE 0
tmulrooney 1:96c429800568 27 #define TRUE 1
tmulrooney 1:96c429800568 28 #define TRANSMIT_BUFFER_SIZE 80 //!< maximum number of characters to write to console
tmulrooney 1:96c429800568 29 #define LINE_SIZE 80 //!< maximum number of characters to read from console
tmulrooney 1:96c429800568 30 #define NUM_LINES 10 //!< number of command lines to save
tmulrooney 1:96c429800568 31
tmulrooney 1:96c429800568 32 /* version history */
tmulrooney 1:96c429800568 33 /*
tmulrooney 1:96c429800568 34 Version Author Date Description
tmulrooney 1:96c429800568 35 0.1 TJM 01/24/15 Initial Draft
tmulrooney 1:96c429800568 36 0.2 TJM 01/24/166 first with CLI interface
tmulrooney 1:96c429800568 37 */
tmulrooney 1:96c429800568 38
tmulrooney 1:96c429800568 39 #define VERSION_MAJOR 0
tmulrooney 1:96c429800568 40 #define VERSION_MINOR 2
tmulrooney 1:96c429800568 41 #define VERSION_DATE "01/26/16"
tmulrooney 1:96c429800568 42
tmulrooney 1:96c429800568 43 typedef unsigned char uint8;
tmulrooney 1:96c429800568 44 typedef signed char int8;
tmulrooney 1:96c429800568 45 typedef unsigned short uint16;
tmulrooney 1:96c429800568 46 typedef signed short int16;
tmulrooney 1:96c429800568 47 typedef unsigned long uint32;
tmulrooney 1:96c429800568 48 typedef signed long int32;
tmulrooney 1:96c429800568 49 typedef unsigned int uint;
tmulrooney 1:96c429800568 50
tmulrooney 1:96c429800568 51 /* parameter type */
tmulrooney 1:96c429800568 52 #define BINARY 0
tmulrooney 1:96c429800568 53 #define DIGITAL 1
tmulrooney 1:96c429800568 54 #define REGISTER 2
tmulrooney 1:96c429800568 55 #define ANALOG 3
tmulrooney 1:96c429800568 56
tmulrooney 1:96c429800568 57 /* command defintions */
tmulrooney 1:96c429800568 58 #define HELP 0
tmulrooney 1:96c429800568 59 #define VERSION 1
tmulrooney 1:96c429800568 60 #define READ 2
tmulrooney 1:96c429800568 61 #define READ_REG 3
tmulrooney 1:96c429800568 62 #define WRITE 4
tmulrooney 1:96c429800568 63 #define WRITE_REG 5
tmulrooney 1:96c429800568 64 #define INFO 6
tmulrooney 1:96c429800568 65 #define FIND 7
tmulrooney 1:96c429800568 66 #define RUN 8
tmulrooney 1:96c429800568 67 #define STOP 9
tmulrooney 1:96c429800568 68 #define DATE 10
tmulrooney 1:96c429800568 69 #define HVSTATE 11
tmulrooney 1:96c429800568 70
tmulrooney 1:96c429800568 71 /* mode */
tmulrooney 1:96c429800568 72 #define READONLY 0
tmulrooney 1:96c429800568 73 #define WRITEONLY 1
tmulrooney 1:96c429800568 74 #define READWRITE 2
tmulrooney 1:96c429800568 75
tmulrooney 1:96c429800568 76 #define MAX_REGISTER_DATA 128
tmulrooney 1:96c429800568 77
tmulrooney 1:96c429800568 78 /* parameter names */
tmulrooney 1:96c429800568 79 enum
tmulrooney 1:96c429800568 80 {
tmulrooney 1:96c429800568 81 spi,
tmulrooney 1:96c429800568 82 i2c,
tmulrooney 1:96c429800568 83 } ;
tmulrooney 1:96c429800568 84
tmulrooney 1:96c429800568 85 typedef uint8 (*Read)(void); //!< read function template to return 8 bit unsigned int
tmulrooney 1:96c429800568 86 typedef uint16 (*ReadRegLength)(uint16 regAddress, uint8 *regData, uint16 length); //!< read function template to return 8 bit unsigned int
tmulrooney 1:96c429800568 87 typedef void (*Write8)(uint8 value); //!< write function template to write 8 bit unsigned value
tmulrooney 1:96c429800568 88 typedef void (*WriteReg8)(uint16 regAddress, uint8 *regData); //!< write function template to write 8 bit unsigned value
tmulrooney 1:96c429800568 89 typedef void (*Write16)(uint16 value); //!< write function template to write 16 bit unsigned value
tmulrooney 1:96c429800568 90 typedef void (*WriteAnalog)(float fltValue); //!< write function template to write analog value
tmulrooney 1:96c429800568 91
tmulrooney 1:96c429800568 92 /* paramater structure */
tmulrooney 1:96c429800568 93 struct parameterInfo //!< paramter information structure
tmulrooney 1:96c429800568 94 {
tmulrooney 1:96c429800568 95 char *name; //!< paramter name
tmulrooney 1:96c429800568 96 char *port; //!< port location (if applicable) on device
tmulrooney 1:96c429800568 97 char *connector; //!< connector location (if applicable) on board
tmulrooney 1:96c429800568 98 char *description; //!< brief parameter function and use
tmulrooney 1:96c429800568 99 uint8 type; //!< binary, digital, or analog
tmulrooney 1:96c429800568 100 char *uints; //!< parameter units (if applicable)
tmulrooney 1:96c429800568 101 uint8 mode; //!< read only, write only, read write
tmulrooney 1:96c429800568 102 uint16 initialInt; //!< initial value if binary or digital
tmulrooney 1:96c429800568 103 uint16 minInt; //!< minimum value if binary or digital
tmulrooney 1:96c429800568 104 uint16 maxInt; //!< maximum value if binary or digital
tmulrooney 1:96c429800568 105 float initialFloat; //!< initial value if analog
tmulrooney 1:96c429800568 106 float minFloat; //!< minimum value if analog
tmulrooney 1:96c429800568 107 float maxFloat; //!< maximum value if analog
tmulrooney 1:96c429800568 108 Read ptrRead; //!< read function needed for this parameter (null if not needed)
tmulrooney 1:96c429800568 109 ReadRegLength ptrReadRegLength; //!< read function needed for this parameter (null if not needed)
tmulrooney 1:96c429800568 110 Write8 ptrWrite8; //!< 8 bit write function needed for this paramater (null if not needed)
tmulrooney 1:96c429800568 111 WriteReg8 ptrWriteReg8; //!< 8 bit write function needed for this paramater (null if not needed)
tmulrooney 1:96c429800568 112 Write16 ptrWrite16; //!< 16 bit write function needed for this paramater (null if not needed)
tmulrooney 1:96c429800568 113 WriteAnalog ptrWriteAnalog; //!< analog write function needed for this paramater (null if not needed)
tmulrooney 1:96c429800568 114 };
tmulrooney 1:96c429800568 115
tmulrooney 1:96c429800568 116
tmulrooney 1:96c429800568 117 /* function prototypes */
tmulrooney 1:96c429800568 118 void printVersion();
tmulrooney 1:96c429800568 119 uint8 getLine();
tmulrooney 1:96c429800568 120 void executeCmd();
tmulrooney 1:96c429800568 121 int8 getCmd();
tmulrooney 1:96c429800568 122 void setDate(char *str);
tmulrooney 1:96c429800568 123 void date(void);
tmulrooney 1:96c429800568 124 int8 getParameter(char *param);
tmulrooney 1:96c429800568 125 int8 findParameter(char *string);
tmulrooney 1:96c429800568 126 uint8 readParam(uint8 paramNum);
tmulrooney 1:96c429800568 127 void writeParam(uint8 paramNum,uint8 *value);
tmulrooney 1:96c429800568 128 float strtofloat (char *str);
tmulrooney 1:96c429800568 129 uint16 power(uint8 num, uint8 pow);
tmulrooney 1:96c429800568 130 void displayParameter(uint8 num);
tmulrooney 1:96c429800568 131 uint8 tolower(uint8 c);
tmulrooney 1:96c429800568 132 uint16 readSPIReg(uint16 regAddress, uint8 *regData, uint16 length);
tmulrooney 1:96c429800568 133 void writeSPIReg(uint16 regAddress, uint8 *regData);
tmulrooney 1:96c429800568 134 void SPIRead(uint16 addr, uint8 *data, int length);
tmulrooney 1:96c429800568 135 void SPIWrite(uint16 addr, uint8 *data, int length);
tmulrooney 1:96c429800568 136 uint16 readI2CReg(uint16 regAddress, uint8 *regData, uint16 length);
tmulrooney 1:96c429800568 137 void writeI2CReg(uint16 regAddress, uint8 *regData);
tmulrooney 1:96c429800568 138 void I2CRead(uint16 addr, uint8 *data, int length);
tmulrooney 1:96c429800568 139 void I2CWrite(uint16 addr, uint8 *data, int length);
tmulrooney 1:96c429800568 140
tmulrooney 1:96c429800568 141 /* externals */
tmulrooney 1:96c429800568 142 extern Serial pc;
tmulrooney 1:96c429800568 143 extern char* c_time_string;
tmulrooney 1:96c429800568 144 extern char time_string[];
tmulrooney 1:96c429800568 145 extern char TransmitBuffer[TRANSMIT_BUFFER_SIZE];
tmulrooney 1:96c429800568 146 extern time_t epoch;
tmulrooney 1:96c429800568 147 extern struct parameterInfo parameters[];
tmulrooney 1:96c429800568 148 extern uint16 bytesRead;
tmulrooney 1:96c429800568 149
tmulrooney 1:96c429800568 150 #endif
tmulrooney 1:96c429800568 151 /* [] END OF FILE */