Skip to content

Commit 483f772

Browse files
committed
Updated documentation
1 parent 1d36629 commit 483f772

File tree

2 files changed

+25
-12
lines changed

2 files changed

+25
-12
lines changed

software/EFM32HG-Embedded2-project/inc/documentation.h

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/***************************************************************************//**
22
* @file documentation.h
33
* @brief This file contains useful documentation about the project.
4-
* @version 3.0
4+
* @version 3.1
55
* @author Brecht Van Eeckhoudt
66
*
77
* ******************************************************************************
@@ -271,17 +271,25 @@
271271
*
272272
* The `volatile` type indicates to the compiler that the data is not normal memory,
273273
* and could change at unexpected times. Hardware registers are often volatile,
274-
* and so are variables which get changed in interrupts.
274+
* and so are variables which get changed in interrupts.@n
275+
* Volatile variables are stored in *RAM*.
275276
*
276-
* @subsection Extern
277+
* @subsection Static
277278
*
278-
* Declare the global variables in headers (and use the `extern` keyword there)
279-
* and actually define them in the appropriate source file.
279+
* @subsubsection VARIABLE Static variable
280280
*
281-
* @subsection Static
281+
* During compile time (this is why we can't use variable length array's) memory
282+
* gets reserved for this variable. The data itself gets put in the *data* segment
283+
* of the memory (regular variables are put in the *stack* segment).@n
284+
* It's best to keep the use of `static` variables to a minimum. One should ask
285+
* himself the question if it's necessary to keep the variable constantly in the
286+
* memory. If the answer is yes, a `static` variable is acceptable.@n
287+
* A **static variable inside a function** keeps its value between invocations.
288+
*
289+
* @subsubsection FUNCTION Static global function
282290
*
283-
* - **Static variable inside a function:** The variable keeps its value between invocations.
284-
* - **Static global variable or function:** The variable or function is only "seen" in the file it's declared in.
291+
* The function is only "seen" in the file it's declared in. This means `static`
292+
* can be used for methods the same way `private` is used for certain methods in C++.
285293
*
286294
* ******************************************************************************
287295
*

software/EFM32HG-Embedded2-project/lora/util_string.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,23 @@ bool HexToString(uint8_t * bin, uint8_t binsz, char **result ){
3838
char hex_str[] = "0123456789abcdef";
3939
uint8_t i;
4040

41-
// Hex to string/char aray: one value becomes two chars (*2)
41+
// ALLOCATE MEMORY
42+
// Hex to string/char array: one value becomes two chars (*2)
4243
// +1 because of NULL termination
44+
// "*result =" ~ Value at memory location gets changed
4345
if (!(*result = (char *)malloc(binsz * 2 + 1))){
44-
return (false);
46+
return (false); // Returned when NULL
4547
}
4648

47-
(*result)[binsz * 2] = 0;
49+
// Add NULL termination
50+
(*result)[binsz * 2] = 0; // Last memory location, "0" ~ '\0'
4851

52+
// CHECK MEMORY
4953
if (!binsz){
50-
return (false);
54+
return (false); // Returned when NULL
5155
}
5256

57+
// FILL WITH DATA
5358
for (i = 0; i < binsz; i++){
5459
(*result)[i * 2 + 0] = hex_str[(bin[i] >> 4) & 0x0F];
5560
(*result)[i * 2 + 1] = hex_str[(bin[i] ) & 0x0F];

0 commit comments

Comments
 (0)