#include "dataXferImpl.h"
Go to the source code of this file.
Defines | |
#define | RECEIVE_TIMEOUT (FCY * 1/20 * 0.1) |
#define | OUT_CHAR(c) outChar(c); |
#define | SPECIFY_VAR(u_varIndex, data, isWriteable, format, desc) specifyVar(u_varIndex, &data, sizeof(data), isWriteable, format, #data, desc) |
Functions | |
void | xferOutChar (char c) |
void | outChar (uint8 c) |
A system-dependent macro to output one character. | |
void | initDataXfer () |
void | specifyVar (uint u_varIndex, void *pv_data, uint u_size, BOOL b_isWriteable, char *psz_format, char *psz_name, char *psz_desc) |
void | sendVar (uint u_varIndex) |
int | formatVar (uint u_varIndex, char *psz_buf) |
uint | receiveVar (char *c) |
char | inCharXfer () |
Definition in file dataXfer.h.
#define RECEIVE_TIMEOUT (FCY * 1/20 * 0.1) |
Number of for loop iterations which equal a timeout for the PIC. # loops = instructions/sec * loops/instruction * seconds
Definition at line 46 of file dataXfer.h.
#define SPECIFY_VAR | ( | u_varIndex, | |||
data, | |||||
isWriteable, | |||||
format, | |||||
desc | ) | specifyVar(u_varIndex, &data, sizeof(data), isWriteable, format, #data, desc) |
For simplicity, define a macro that specifies a variable with default names. For example, SEND_VAR(1, u8_c);
u_varIndex | A value from 0-NUM_XFER_VARS, unique for each var | |
data | A pointer to the data to be sent | |
isWriteable | True if the PC is allowed to change this variable; false otherwise. This does *NOT* restrict the PIC to read-only access to this variable. | |
format | printf format string to use in displaying the variable | |
desc | Description of this variable. |
Definition at line 104 of file dataXfer.h.
int formatVar | ( | uint | u_varIndex, | |
char * | psz_buf | |||
) |
Return a string with the data stored in the given variable formatted using the format string contained in the variable. Limitation: current, use of a string (s format) will probably crash the program. PC only.
u_varIndex | The index of the variable to send; must be from 0 to NUM_XFER_VARS. | |
psz_buf | Buffer large enough to contain the formatted string. |
Definition at line 116 of file dataXfer.c.
char inCharXfer | ( | ) |
Receive a character, while transparently processing any variables sent by the PC. Variables are assigned, but this simple interface does not report these assignments to its caller. This provides a simple wrapper around receiveVar, which also reports on received variables. uC only.
void initDataXfer | ( | ) |
Initialize the data transfer system. This must be called before calling any of the data transfer functions in the library.
Definition at line 9 of file dataXfer.c.
void outChar | ( | uint8 | u8_c | ) |
A system-dependent macro to output one character.
Write a character to the serial port. This function blocks until a character is written. The UART used is determined by the __C30_UART variable, which defaults to 1.
u8_c | Character to write |
Definition at line 54 of file pic24_serial.c.
uint receiveVar | ( | char * | c | ) |
Receive a character or a variable. Any errors that occur are reported via outString. uC only.
c | Pointer to space for storing the received character, if a character was received (see return value). |
void sendVar | ( | uint | u_varIndex | ) |
Send an already-specified variable;
u_varIndex | The index of the variable to send; must be from 0 to NUM_XFER_VARS. |
Definition at line 73 of file dataXfer.c.
void specifyVar | ( | uint | u_varIndex, | |
void * | pv_data, | |||
uint | u_size, | |||
BOOL | b_isWriteable, | |||
char * | psz_format, | |||
char * | psz_name, | |||
char * | psz_desc | |||
) |
Specify a variable to be sent or received.
u_varIndex | A value from 0-NUM_XFER_VARS, unique for each var | |
pv_data | A pointer to the data to be sent | |
u_size | Size of the data in bytes; must be from 1 to 256. | |
b_isWriteable | True if the PC is allowed to change this variable; false otherwise. This does *NOT* restrict the PIC to read-only access to this variable. | |
psz_format | printf format string to use in displaying the Variable. | |
psz_name | Name of this variable, typically the same as used in the code | |
psz_desc | Description of this variable. |
Definition at line 25 of file dataXfer.c.
void xferOutChar | ( | char | c | ) |
Send one character to the uC, escaping if necessary.
c | Character to send. |
Definition at line 18 of file dataXfer.c.