102 #if defined(__PIC24H__) || defined(__PIC24F__) || defined(__dsPIC33F__) || defined(__PIC24FK__) || defined(__PIC24E__) || defined(__dsPIC33E__) 103 #define MICROCONTROLLER 121 #if defined(__cplusplus) 124 # define NULL nullptr 145 # define ASSERT(placeholder) (void)0 147 # define ASSERT(x) if (!(x)) throw #x 154 # define ASSERT(msg, expr) (void)0 156 # define ASSERTM(msg, expr) if (! (expr)) throw msg ": " #expr 161 #else // #if defined(__cplusplus) 173 # define ASSERT(placeholder) (void)0 176 # define ASSERT(x) assert(x) 182 # define ASSERTM(msg, expr) ASSERT(expr) 185 # define BOOL unsigned char 192 #ifndef MICROCONTROLLER 205 #define CMD_TOKEN ((char) 0xAA) 209 #define ESCAPED_CMD ((char) 0xFC) 213 #define CMD_LONG_VAR ((char) 0xFD) 217 #define CMD_SEND_ONLY ((char) 0xFE) 221 #define CMD_SEND_RECEIVE_VAR ((char) 0xFF) 225 #define VAR_SIZE_BITS 2 228 #define VAR_SIZE_MASK ((1 << VAR_SIZE_BITS) - 1) 232 #define SHORT_VAR_MAX_LEN (1 << VAR_SIZE_BITS) 319 #if !defined(MICROCONTROLLER) || defined(__DOXYGEN__) 331 #define MAX_NUM_XFER_VARS ((1 << (8 - VAR_SIZE_BITS)) - 1) 335 #define NUM_XFER_VARS 62 336 #if NUM_XFER_VARS > MAX_NUM_XFER_VARS 337 # error "Too many transfer variables; there must be MAX_NUM_XFER_VARS or fewer." 358 #define CHAR_RECEIVED_INDEX 0xFF 412 #define NUM_ERROR_CODES (ERR_MICROCONTROLLER_VAR_SPEC + 1) 431 #if !defined(MICROCONTROLLER) || defined(__DOXYGEN__) 461 #if !defined(MICROCONTROLLER) || defined(__DOXYGEN__)
The machine is waiting for an additional character; c_outChar is not valid.
void resetReceiveMachine()
RECEIVE_ERROR notifyOfTimeout()
The machine is waiting for another character; c_outChar is not valid.
Reading the variable index for a long var command.
unsigned int uint
An abbreviation for an unsigned integer.
A repeated command was received; c_outChar contains the command.
void clearReceiveStruct()
A character was received; c_outChar contains the character.
Reading the variable length for a long/specification command.
uint8_t au8_xferVarWriteable[NUM_XFER_VARS/8+((NUM_XFER_VARS % 8) > 0)]
void clearReceiveMachineError()
BOOL isReceiveMachineChar()
RECEIVE_ERROR getReceiveMachineError()
char * psz_desc
Description of this variable. PC only.
Reading data bytes in from a command.
const char * getReceiveErrorString()
Returns an error string matching the last error code.
char getReceiveMachineOutChar()
BOOL isVarWriteable(uint u_index)
BOOL isReceiveMachineData()
uint getVarIndex(char c_cmd)
At the start of the machine.
XFER_VAR xferVar[NUM_XFER_VARS]
A table to hold the state of transfer variables.
BOOL isReceiveMachineSpec()
uint getVarLength(char c_cmd)
uint getReceiveMachineIndex()
char * psz_format
printf format string to use in displaying the variable. PC only.
The microcontroller is sent a variable specification.
void assignBit(uint u_index, BOOL b_bitVal)
RECEIVE_STATE getReceiveMachineState()
The state machine produced no output, but is waiting for additional input.
CMD_OUTPUT stepCommandFindMachine(char c_inChar, char *c_outChar)
The destination variable is read-only.
Reading the variable index for a specification command.
A command was received; c_outChar contains the command.
Waiting for a command or escaped CMD_TOKEN.
void resetCommandFindMachine()
RECEIVE_ERROR stepReceiveMachine(char c_inChar)
BOOL getReceiveMachineIsSpec()
unsigned char uint8_t
An abbreviation for an 8-bit unsigned integer.
uint8_t u8_size
Size of data in bytes - 1: 0 = 1 byte, etc.
The machine is in its starting state.