Page 131 - Programming Microcontrollers in C
P. 131

116    Chapter 2  Advanced C Topics

                          If one is found, the data stored in the original block are copied to the
                          new block and the proper space is allocated. The pointer returned in
                          this case will not be the same as that passed.


            Miscellaneous Functions

                              C provides several sets of miscellaneous functions that are very
                          useful. As mentioned earlier, the input/output functions that are
                          prototyped in stdio.h are not parts of the language, but instead
                          are separate functions. The miscellaneous functions are prototyped
                          is several different header files. Many of these functions are macros,
                          and if they are, the macro definitions are contained in the header file.
                              Following is a list of several header files specified by the ANSI
                          Standard. With each header file is a list of functions or function pro­
                          totypes contained within these files. You should look to the
                          documentation for your compiler to get the detailed descriptions of
                          each of these files.
                              As mentioned earlier, these files are there, tested, work and are
                          probably as robust and reliable as any code written. They do what
                          they are supposed to, and they are free. It makes little sense to re­
                          write these programs just to satisfy an ego trip. I have seen shop
                          coding standards that did not allow the use of standard library files
                          because the programmers could not examine the source code. Such a
                          standard is absolutely silly. If you do not trust the compiler to pro­
                          vide safe, satisfactory library code, you should not trust the compiler
                          to generate any code. Therefore, you are using the wrong compiler.
                          Get a compiler that meets your standard.
                              Most embedded programs that employ microcontrollers do not
                          have standard connections to input/output devices. For example, there
                          is rarely a terminal or a keyboard attached to an embedded system.
                          More likely you would expect to find a numeric, or special, keypad
                          and an LCD special purpose output display. None of the standard i/o
                          programs can connect with such devices. In such cases, it will be
                          your responsibility as the programmer to write drivers to interface
                          with these devices. Also, you will rarely see disk files in your em­
                          bedded product. Therefore, you will rarely need to include the header
                          file stdio.h in a microcontroller program.
   126   127   128   129   130   131   132   133   134   135   136