PIC24 Support Libraries
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
stdio_test.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 #include "pic24_all.h"
30 #include <stdio.h>
31 
32 /** \file
33  * This file demonstrates use of 'scanf' forms, requires inclusion of "pic24_stdio_uart.c".
34  */
35 
36 
37 
38 #define BUFSIZE 63
39 char sz_1[BUFSIZE+1];
40 
41 int main (void) {
42  int32_t i32_i;
43  uint32_t ui32_k;
44  double d_n;
45  float f_n;
46 
47  configBasic(HELLO_MSG);
48  printf ("This tests 'scanf' stdio; all entries must be terminated by a newline\n");
49  printf("Input a string (< 63 characters: ");
50  scanf("%s",sz_1); //get a string from the console
51  printf("\n");
52  printf("Entered: '%s' \n",sz_1);
53 
54  printf("Input an unsigned decimal number: ");
55  printf("\n");
56  scanf("%lu",&ui32_k);
57  printf("The number is: %lu\n",ui32_k);
58  printf("Input a signed decimal number: ");
59  printf("\n");
60  scanf("%ld",&i32_i);
61  printf("The number is: %ld\n",i32_i);
62 #if 1
63  printf("Input a floating point number (single precision): ");
64  scanf("%f",&f_n);
65  printf("The number is: %f\n",(double) f_n);
66 #endif
67 #if 1
68  printf("Input a floating point number (double precision): ");
69  scanf("%lf",&d_n);
70  printf("The number is: %lf\n",d_n);
71 #endif
72  printf ("This concludes the 'scanf' stdio test\n");
73  while (1) {
74  doHeartbeat();
75  }
76 }