1 /* 2 * Copyright (c) 2023 Juan Manuel Cruz <jcruz@fi.uba.ar> <jcruz@frba.utn.edu.ar>. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * 3. Neither the name of the copyright holder nor the names of its 16 * contributors may be used to endorse or promote products derived from 17 * this software without specific prior written permission. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 22 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 23 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 28 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 29 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 * POSSIBILITY OF SUCH DAMAGE. 31 * 32 * @file : app.h 33 * @date : Set 26, 2023 34 * @author : Juan Manuel Cruz <jcruz@fi.uba.ar> <jcruz@frba.utn.edu.ar> 35 * @version v1.0.0 36 */ 37 38 /* C Preprocessors (https://www.geeksforgeeks.org/) */ 39 /* 40 * Conditional Compilation in C directives is a type of directive that helps to 41 * compile a specific portion of the program or to skip the compilation of some 42 * specific part of the program based on some conditions. There are the 43 * following preprocessor directives that are used to insert conditional code: 44 * #if Directive 45 * #ifdef Directive 46 * #ifndef Directive 47 * #else Directive 48 * #elif Directive 49 * #endif Directive 50 */ 51 #ifndef APP_INC_APP_H_ 52 #define APP_INC_APP_H_ 53 54 /********************** CPP guard ********************************************/ 55 #ifdef __cplusplus 56 extern "C" { 57 #endif 58 59 /********************** inclusions *******************************************/ 60 61 /********************** macros ***********************************************/ 62 63 /* C typedef (https://www.geeksforgeeks.org/) */ 64 /* 65 * The typedef is a keyword that is used to provide existing data types with a 66 * new name. The C typedef keyword is used to redefine the name of already 67 * existing data types. 68 * When names of datatypes become difficult to use in programs, typedef is 69 * used with user-defined datatypes, which behave similarly to defining an 70 * alias for commands. 71 */ 72 73 /* Enumeration (or enum) in C (https://www.geeksforgeeks.org/) */ 74 /* 75 * Enumeration (or enum) is a user defined data type in C. It is mainly used to 76 * assign names to integral constants, the names make a program easy to read 77 * and maintain. 78 */ 79 //typedef enum {TEST_0, TEST_1, TEST_2} test_x_t; 80 #define TEST_0 (0) 81 #define TEST_1 (1) 82 #define TEST_2 (2) 83 84 #define TEST_X (TEST_0) 85 86 /********************** typedef **********************************************/ 87 88 /********************** external data declaration ****************************/ 89 90 /* Memory Layout of C Programs (https://www.geeksforgeeks.org/) */ 91 /* Storage Classes in C (https://www.geeksforgeeks.org/) */ 92 /* C Variables (https://www.geeksforgeeks.org/) */ 93 /* Global Variables in C (https://www.geeksforgeeks.org/) */ 94 /* Extern Keyword in C (https://www.geeksforgeeks.org/) */ 95 /* 96 * A variable declared outside any function or a block of code is called a 97 * global variable. Global variables are frequently used to permanently store 98 * data in a defined scope where they can be accessed and manipulated. 99 * 100 * Global variables do not stay limited to a specific function, which means 101 * that one can use any given function to access and modify the global 102 * variables. The initialization of these variables occurs automatically to 0 103 * during the time of declaration. Also, we generally write the global 104 * variables before the main() function. 105 * 106 * extern keyword in C applies to C variables (data objects) and C functions. 107 * Basically, the extern keyword extends the visibility of the C variables and 108 * C functions. That’s probably the reason why it was named extern. 109 */ 110 extern uint32_t g_app_cnt; 111 extern uint32_t g_app_runtime_us; 112 113 extern volatile uint32_t g_app_tick_cnt; 114 115 /********************** external functions declaration ***********************/ 116 117 /* Memory Layout of C Programs (https://www.geeksforgeeks.org/) */ 118 /* Storage Classes in C (https://www.geeksforgeeks.org/) */ 119 /* C Functions (https://www.geeksforgeeks.org/) */ 120 /* 121 * In a function declaration, we must provide the function name, its return 122 * type, and the number and type of its parameters. A function declaration 123 * tells the compiler that there is a function with the given name defined 124 * somewhere else in the program. 125 */ 126 void app_init(void); 127 void app_update(void); 128 129 /********************** End of CPP guard *************************************/ 130 #ifdef __cplusplus 131 } 132 #endif 133 134 #endif /* APP_INC_APP_H_ */ 135 136 /********************** end of file ******************************************/
