AVRly - AVR Development Resources
filename.c
Go to the documentation of this file.
1/******************************************************************************
2 @copyright Copyright © 2022 by Your Name Here.
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 filename.c
25 * @ingroup anatomy
26 * @author Your Name Here.
27 * @date 15th March 2022
28 * @brief The brief description goes here, keep it relatively short and to the
29 * point.
30 * @details After the brief comes the detailed description. Add an explanation
31 * of the purpose and limitations of the module, along with any other notes
32 * that may be useful to others using it.
33 * @bug Known bugs are declared and described here.
34 * @see "See also" links go here https://www.doxygen.nl/manual/docblocks.html
35 */
36
37
38// Standard library header files are declared first, with angular brackets.
39#include <stdint.h>
40
41// System header files are declared next, also with angular brackets.
42// Define the path to search for these files in the Makefile.
43#include <util/delay.h>
44
45// Project specific includes come next, in quotation marks.
46// These files are located in the project directory.
47#include "pin_defines.h"
48
49// Include the header file for this module, with the same name but .h
50#include "filename.h"
51
52/**
53 * Next come #define statements/macros. Append integer values with a 'U' to
54 * make them unsigned, as the default type is signed integer.
55 */
56#define DECIMAL_MACRO 855U
57
58
59/**
60 * Try to keep the scope of variables limited to the file at least, though
61 * function level scope is usually better where possible.
62 */
63static uint16_t file_scope_variable = 0;
64
65
66// Private helper function declarations go here.
67void do_some_helpful_stuff(void);
68
69
70/*
71 * Note that in the C source files, I've switched back to regular C style comment
72 * blocks for public function definitions. This is so that Doxygen ignores them.
73 */
74void init_object(uint16_t value)
75{
76 OBJECT_DDR |= (1 << OBJECT_GPIO); // Set object gpio as output.
77
78 OBJECT_PORT |= (1 << OBJECT_GPIO); // Set level of OBJECT_GPIO high.
79
80 // Do some other stuff with the parameters
81}
82
83
84/*
85 * Get value and return it without exposing a private variable.
86 */
87uint16_t get_value(void)
88{
89 return file_scope_variable;
90}
91
92
93/**
94 * Helper function definitions come last, though their declarations are at the
95 * top of the file.
96 */
98{
99 // Body of function definition goes here.
100}
101
102
103/*** end of file ***/
#define OBJECT_PORT
Defines the AVR port we have wired our peripheral to.
Definition: pin_defines.h:43
#define OBJECT_GPIO
Defines the GPIO number the peripheral is wired to.
Definition: pin_defines.h:53
#define OBJECT_DDR
Defines the Data Direction Register for the GPIO connected to our peripheral.
Definition: pin_defines.h:48
uint16_t get_value(void)
Other public function declarations come afterwards.
Definition: filename.c:87
void init_object(uint16_t value)
This is a Javadoc autobrief style comment.
Definition: filename.c:74
void do_some_helpful_stuff(void)
Helper function definitions come last, though their declarations are at the top of the file.
Definition: filename.c:97
The brief description goes here, keep it relatively short and to the point.
Definitions for pin mapping (for CCS81 gas sensor)