PIC24 Support Libraries
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
Pages
util
dataXfer_echo.c
Go to the documentation of this file.
1
/*
2
* "Copyright (c) 2008 Robert B. Reese, Bryan A. Jones, J. W. Bruce ("AUTHORS")"
3
* All rights reserved.
4
* (R. Reese, reese_AT_ece.msstate.edu, Mississippi State University)
5
* (B. A. Jones, bjones_AT_ece.msstate.edu, Mississippi State University)
6
* (J. W. Bruce, jwbruce_AT_ece.msstate.edu, Mississippi State University)
7
*
8
* Permission to use, copy, modify, and distribute this software and its
9
* documentation for any purpose, without fee, and without written agreement is
10
* hereby granted, provided that the above copyright notice, the following
11
* two paragraphs and the authors appear in all copies of this software.
12
*
13
* IN NO EVENT SHALL THE "AUTHORS" BE LIABLE TO ANY PARTY FOR
14
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
15
* OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE "AUTHORS"
16
* HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
17
*
18
* THE "AUTHORS" SPECIFICALLY DISCLAIMS ANY WARRANTIES,
19
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
20
* AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
21
* ON AN "AS IS" BASIS, AND THE "AUTHORS" HAS NO OBLIGATION TO
22
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
23
*
24
* Please maintain this header in its entirety when copying/modifying
25
* these files.
26
*
27
*
28
*/
29
30
#include "
pic24_all.h
"
31
#include "
dataXfer.h
"
32
33
/** \file
34
* Demonstrates an echo program which includes usage of the
35
* \ref dataXfer "data transfer protocol" .
36
*/
37
38
/// Indexes of all the variables to be transferred.
39
enum
{ U16_NUMCHARS_NDX, C_NDX };
40
41
/// Number of characters to print on each line.
42
#define CHARS_PER_LINE 10
43
44
int
main
(
void
) {
45
char
c;
46
uint16_t
u16_numChars = 0;
47
48
// Initialize
49
configBasic
(HELLO_MSG);
50
initDataXfer
();
51
52
// All variables received by the PIC must be specified.
53
// Params: Index Variable PC can change Format Description
54
SPECIFY_VAR
(U16_NUMCHARS_NDX, u16_numChars,
TRUE
,
"%hu"
,
"Number of characters received"
);
55
SPECIFY_VAR
(C_NDX, c,
FALSE
,
"%c"
,
"Character entered"
);
56
57
while
(1) {
58
// For debug support, send the index and char received.
59
sendVar
(U16_NUMCHARS_NDX);
60
sendVar
(C_NDX);
61
62
// Echo a character
63
c =
inCharXfer
();
64
outChar
(c);
65
66
// Add a CR every \ref CHARS_PER_LINE
67
if
((++u16_numChars %
CHARS_PER_LINE
) == 0)
68
outChar
(
'\n'
);
69
}
70
}
Generated by
1.8.4