AVRly - AVR Development Resources
main.c
Go to the documentation of this file.
1/******************************************************************************
2 @copyright Copyright © 2022 by Jason Duffy.
3
4 Permission is hereby granted, free of charge, to any person obtaining a copy
5 of this software and associated documentation files (the "Software"), to deal
6 in the Software without restriction, including without limitation the rights
7 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 copies of the Software, and to permit persons to whom the Software is
9 furnished to do so, subject to the following conditions:
10
11 The above copyright notice and this permission notice shall be included in all
12 copies or substantial portions of the Software.
13
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 SOFTWARE.
21******************************************************************************/
22
23/**
24 * @file main.c
25 * @ingroup log_system
26 * @author Jason Duffy
27 * @date 1st March 2022
28 * @brief Main routine for log_system example application.
29 * @bug No known bugs.
30 */
31
32#include <util/delay.h>
33#include "log_system.h"
34
35#define DELAY_TIME 1000
36#define INCREMENT_VAL 1
37
38
39/**
40 * Instantiation of log_system config object.
41 */
43{
44 .p_system_tag = "Main",
45 .file_log_level = DEBUG,
46};
47
48/**
49 * Example variable to be output to log_system.
50 */
51uint8_t example_variable = 59;
52
53
54/**
55 * Main routine for example application.
56 */
57int main()
58{
59 // Setup
61 log_message(&main_log, INFO, "Hello, World!");
62 _delay_ms(DELAY_TIME);
63
64 // Loop forever
65 while(1)
66 {
67 /*
68 * This message is NOT printed, as the level is above that specified in
69 * main_log.file_log_level
70 */
71 log_message(&main_log, VERBOSE_DEBUG, "Verbose Debug Message.");
72 _delay_ms(DELAY_TIME);
73
74 // This message IS printed.
75 log_message_with_bin_val(&main_log, DEBUG,
76 "The binary format value of example_variable is: ",
78
79 // As is this one.
80 log_message_with_dec_val(&main_log, DEBUG,
81 "The decimal format value of example_variable is: ",
83
84 // And this one.
85 log_message_with_hex_val(&main_log, DEBUG,
86 "The hexadecimal format value of example_variable is: ",
88
89 // Edit variable value.
90 example_variable += INCREMENT_VAL;
91 _delay_ms(DELAY_TIME);
92 }
93
94 return 0;
95}
void init_log_system(void)
Initialisation routine - call this function once at startup before using other functions.
Definition: log_system.c:46
int main()
Main routine to be executed on the MCU.
Definition: main.c:45
uint8_t example_variable
Example variable to be output to log_system.
Definition: main.c:51
log_system_config_t main_log
Instantiation of log_system config object.
Definition: main.c:42
Driver file providing logging functionality over USART, to print debug messages and values to a temin...
Config object, to be instantiated in each file the log system is to be used, then pass it's address i...
Definition: log_system.h:59