CommonPIC32

docs/wiki/Examples

150:82a63936a118
2019-06-11 Paul Boddie Added initial library documentation.
     1 = Examples =     2      3 To investigate various kinds of applications and to demonstrate techniques     4 discovered and employed, a collection of examples has been provided:     5      6  * [[/demo|Demo]]     7  * [[VGA Output Examples]]     8      9 == Common Example Characteristics ==    10     11 Each example provides the following resources:    12     13  `devconfig.h`:: device configuration details    14  `Makefile`:: a build configuration for the example    15  `main.c`:: the example main program    16  `main.h`:: definitions for the main program    17     18 === Device Configuration ===    19     20 The `devconfig.h` file is intended to provide configuration settings related    21 to the device configuration and oscillator (clock) frequency. The following    22 definitions are employed:    23     24  `DEVCFG1_CONFIG`:: the value with which the `DEVCFG1` register will be    25                     programmed, this typically being constructed using symbols    26                     defining values for various register fields    27     28  `DEVCFG2_CONFIG`:: the value with which the `DEVCFG2` register will be    29                     programmed    30     31  `FPB`:: the peripheral clock frequency, whose value will be a consequence of    32          the above register settings    33     34 === Build Configuration ===    35     36 The `Makefile` is concerned with defining source and program (target) files,    37 build artefacts, configuration flags, employing the common definitions and    38 rules found in the `mk` directory located at the top level of the CommonPIC32    39 distribution.    40     41 === Main Program ===    42     43 The `main.c` and `main.h` files are concerned with providing a `main` function    44 with the following signature:    45     46 {{{    47 void main(void);    48 }}}    49     50 Since the `mk/common.mk` definitions file used by the build configuration    51 provides access to various library files, the first tasks performed by the    52 `main` function are likely to involve initialisation using various    53 `init_`-prefixed functions.    54     55 Other necessary functions are those handling exceptions and interrupts, having    56 the following signatures:    57     58 {{{    59 void exception_handler(void);    60 void interrupt_handler(void);    61 }}}    62     63 These functions are called by the low-level library functionality when CPU    64 exceptions and interrupts occur.