Skip to content

Commit 5083a2f

Browse files
committed
sw: Improve docs
1 parent 443678f commit 5083a2f

File tree

4 files changed

+104
-10
lines changed

4 files changed

+104
-10
lines changed

sw/n64_cic/include/n64_cic.h

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,41 @@
1010
#include <stdbool.h>
1111
#include <stdint.h>
1212

13-
// Callback will be called when the CIC receives a reset command.
14-
// This happens when the users presses the physical Reset button.
13+
/**
14+
* @brief Callback function type for CIC reset
15+
*
16+
* This callback will be called when the CIC receives a reset command.
17+
* This happens when the user presses the physical Reset button.
18+
*/
1519
typedef void (*cic_reset_cb_t)(void);
1620

21+
/**
22+
* @brief Reset the parameters of the N64 CIC
23+
*/
1724
void n64_cic_reset_parameters(void);
25+
26+
/**
27+
* @brief Set the parameters of the N64 CIC
28+
*
29+
* @param args The parameters to set
30+
*/
1831
void n64_cic_set_parameters(uint32_t * args);
32+
33+
/**
34+
* @brief Enable or disable DD mode in the N64 CIC
35+
*
36+
* @param enabled Whether to enable or disable DD mode
37+
*/
1938
void n64_cic_set_dd_mode(bool enabled);
39+
40+
/**
41+
* @brief Initialize the N64 CIC hardware
42+
*/
2043
void n64_cic_hw_init(void);
44+
45+
/**
46+
* @brief Run the N64 CIC task
47+
*
48+
* @param cic_reset_cb The callback to call when the CIC receives a reset command
49+
*/
2150
void n64_cic_task(cic_reset_cb_t cic_reset_cb);

sw/picocart64_shared/include/pc64_rand.h

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,38 @@
88

99
#include <stdint.h>
1010

11+
/**
12+
* Generate a random 32-bit integer.
13+
*
14+
* This function generates a random 32-bit integer using a linear congruential generator.
15+
*
16+
* @return A random 32-bit integer.
17+
*/
1118
uint32_t pc64_rand32(void);
19+
20+
/**
21+
* Generate a random 16-bit integer.
22+
*
23+
* This function generates a random 16-bit integer by calling pc64_rand32 and truncating the result.
24+
*
25+
* @return A random 16-bit integer.
26+
*/
1227
uint16_t pc64_rand16(void);
28+
29+
/**
30+
* Generate a random 8-bit integer.
31+
*
32+
* This function generates a random 8-bit integer by calling pc64_rand32 and truncating the result.
33+
*
34+
* @return A random 8-bit integer.
35+
*/
1336
uint8_t pc64_rand8(void);
37+
38+
/**
39+
* Seed the random number generator.
40+
*
41+
* This function sets the seed used by the random number generator.
42+
*
43+
* @param new_seed The new seed.
44+
*/
1445
void pc64_rand_seed(uint32_t new_seed);

sw/picocart64_v1/n64_pi_task.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,12 @@
66

77
#pragma once
88

9+
/**
10+
* @file n64_pi_task.h
11+
* @brief Header file for the N64 PI task
12+
*/
13+
14+
/**
15+
* @brief Executes the N64 PI task.
16+
*/
917
void n64_pi_run(void);

sw/picocart64_v1/utils.h

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,54 @@
88

99
#include <stdint.h>
1010

11+
/// @brief Macro to get the size of an array
1112
#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
1213

14+
/**
15+
* @brief Swap the lower and upper 16 bits of a 32-bit value
16+
*
17+
* @param value The 32-bit value to swap
18+
* @return The 32-bit value with the lower and upper 16 bits swapped
19+
*
20+
* Example: 0x11223344 => 0x33441122
21+
*/
1322
static inline uint32_t swap16(uint32_t value)
1423
{
15-
// 0x11223344 => 0x33441122
1624
return (value << 16) | (value >> 16);
1725
}
1826

27+
/**
28+
* @brief Swap the lower and upper 8 bits of a 16-bit value
29+
*
30+
* @param value The 16-bit value to swap
31+
* @return The 16-bit value with the lower and upper 8 bits swapped
32+
*
33+
* Example: 0x1122 => 0x2211
34+
*/
1935
static inline uint16_t swap8(uint16_t value)
2036
{
21-
// 0x1122 => 0x2211
2237
return (value << 8) | (value >> 8);
2338
}
2439

40+
/**
41+
* @brief Handler for assertion failures
42+
*
43+
* @param file The file where the assertion failed
44+
* @param line The line number where the assertion failed
45+
* @param statement The assertion statement that failed
46+
*/
2547
void assert_handler(char *file, int line, char *statement);
2648

49+
/**
50+
* @brief Macro for assertions
51+
*
52+
* @param _stmt The assertion statement
53+
*
54+
* If the assertion statement is false, the assert_handler is called with the file, line, and statement.
55+
*/
2756
#define ASSERT(_stmt) do \
2857
{ \
29-
if (!(_stmt)) { \
30-
assert_handler(__FILE__, __LINE__, #_stmt); \
31-
} \
58+
if (!(_stmt)) { \
59+
assert_handler(__FILE__, __LINE__, #_stmt); \
60+
} \
3261
} while (0)
33-
34-
#define LIKELY(x) __builtin_expect ((x), 1)
35-
#define UNLIKELY(x) __builtin_expect ((x), 0)

0 commit comments

Comments
 (0)