Common Update: Better Doxygen Style

This commit is contained in:
bit-cyber-fh
2024-03-28 00:00:59 +08:00
parent 9b416114a1
commit bab91e13df
43 changed files with 1800 additions and 1195 deletions
+56 -21
View File
@@ -1,15 +1,30 @@
/******************************************************************************/
/*****************************************************************************/
/**
* @file util.c
* @author FanHao ([email protected])
* @brief Utility functions implementation file
* @version 0.0
* @date 2023-05-06
*
* @copyright Copyright(c) 2024 Beijing Institute of Technology.\n
* Lab of Communication and Network
*
******************************************************************************/
/***************************** Include Files **********************************/
/******************************************************************************/
/**
* @addtogroup Utility
* @{
*/
#include <string.h>
#include <stdlib.h>
// #include <arm_acle.h>
#include "util.h"
#include "error.h"
/******************************************************************************/
/************************** Functions Implementation **************************/
/******************************************************************************/
#ifdef __BITSWAP_TABLE
static uint8_t byte_flipLR[256] =
{
@@ -48,17 +63,26 @@ static uint8_t byte_flipLR[256] =
};
#endif
/**
* @brief Write a 32bit word to specific memory address
*/
inline void IO_Out32(uintptr_t addr, uint32_t value)
{
volatile uint32_t *localAddr = (volatile uint32_t *)addr;
*localAddr = value;
}
/**
* @brief Read a 32bit word from specific memory address
*/
inline uint32_t IO_In32(uintptr_t addr)
{
return *(volatile uint32_t *)addr;
}
/**
* @brief Swap a byte word bit-wise
*/
uint8_t byte_bit_swap(uint8_t byte)
{
#ifdef __BITSWAP_TABLE
@@ -68,6 +92,9 @@ uint8_t byte_bit_swap(uint8_t byte)
#endif
}
/**
* @brief Swap 32bit word bit-wise
*/
uint32_t word_bit_swap(uint32_t word)
{
#ifdef __BITSWAP_TABLE
@@ -85,6 +112,9 @@ uint32_t word_bit_swap(uint32_t word)
#endif
}
/**
* @brief Count ones in an 32bit word
*/
uint32_t count_ones(uint32_t word)
{
#ifdef __GNUC__
@@ -101,13 +131,16 @@ uint32_t count_ones(uint32_t word)
#endif
}
/**
* @brief Convert fix ;oint number to float number
*/
double fix2double(int32_t val, uint8_t frac_bits)
{
return (((double)val) / (BIT(frac_bits)));
}
/**
* Find first set bit in word.
* @brief Find first set bit in word.
*/
uint32_t find_first_set_bit(uint32_t word)
{
@@ -136,7 +169,7 @@ uint32_t find_first_set_bit(uint32_t word)
}
/**
* Find last set bit in word.
* @brief Find last set bit in word.
*/
uint32_t find_last_set_bit(uint32_t word)
{
@@ -166,7 +199,7 @@ uint32_t find_last_set_bit(uint32_t word)
}
/**
* Locate the closest element in an array.
* @brief Locate the closest element in an array.
*/
uint32_t find_closest(int32_t val,
const int32_t *array,
@@ -189,7 +222,7 @@ uint32_t find_closest(int32_t val,
}
/**
* Shift the value and apply the specified mask.
* @brief Shift the value and apply the specified mask.
*/
uint32_t field_prep(uint32_t mask, uint32_t val)
{
@@ -197,7 +230,7 @@ uint32_t field_prep(uint32_t mask, uint32_t val)
}
/**
* Get a field specified by a mask from a word.
* @brief Get a field specified by a mask from a word.
*/
uint32_t field_get(uint32_t mask, uint32_t word)
{
@@ -205,7 +238,7 @@ uint32_t field_get(uint32_t mask, uint32_t word)
}
/**
* Log base 2 of the given number.
* @brief Log base 2 of the given number.
*/
int32_t log_base_2(uint32_t x)
{
@@ -213,7 +246,7 @@ int32_t log_base_2(uint32_t x)
}
/**
* Find greatest common divisor of the given two numbers.
* @brief Find greatest common divisor of the given two numbers.
*/
uint32_t greatest_common_divisor(uint32_t a,
uint32_t b)
@@ -232,7 +265,7 @@ uint32_t greatest_common_divisor(uint32_t a,
}
/**
* Calculate best rational approximation for a given fraction.
* @brief Calculate best rational approximation for a given fraction.
*/
void rational_best_approximation(uint32_t given_numerator,
uint32_t given_denominator,
@@ -257,7 +290,7 @@ void rational_best_approximation(uint32_t given_numerator,
}
/**
* Calculate the number of set bits.
* @brief Calculate the number of set bits.
*/
uint32_t hweight8(uint32_t word)
{
@@ -274,7 +307,7 @@ uint32_t hweight8(uint32_t word)
}
/**
* Calculate the quotient and the remainder of an integer division.
* @brief Calculate the quotient and the remainder of an integer division.
*/
uint64_t do_div(uint64_t *n,
uint64_t base)
@@ -288,7 +321,7 @@ uint64_t do_div(uint64_t *n,
}
/**
* Unsigned 64bit divide with 64bit divisor and remainder
* @brief Unsigned 64bit divide with 64bit divisor and remainder
*/
uint64_t div64_u64_rem(uint64_t dividend, uint64_t divisor, uint64_t *remainder)
{
@@ -298,7 +331,7 @@ uint64_t div64_u64_rem(uint64_t dividend, uint64_t divisor, uint64_t *remainder)
}
/**
* Unsigned 64bit divide with 32bit divisor with remainder
* @brief Unsigned 64bit divide with 32bit divisor with remainder
*/
uint64_t div_u64_rem(uint64_t dividend, uint32_t divisor, uint32_t *remainder)
{
@@ -308,7 +341,7 @@ uint64_t div_u64_rem(uint64_t dividend, uint32_t divisor, uint32_t *remainder)
}
/**
* Signed 64bit divide with 32bit divisor with remainder
* @brief Signed 64bit divide with 32bit divisor with remainder
*/
int64_t div_s64_rem(int64_t dividend, int32_t divisor, int32_t *remainder)
{
@@ -317,7 +350,7 @@ int64_t div_s64_rem(int64_t dividend, int32_t divisor, int32_t *remainder)
}
/**
* Unsigned 64bit divide with 32bit divisor
* @brief Unsigned 64bit divide with 32bit divisor
*/
uint64_t div_u64(uint64_t dividend, uint32_t divisor)
{
@@ -327,7 +360,7 @@ uint64_t div_u64(uint64_t dividend, uint32_t divisor)
}
/**
* Signed 64bit divide with 32bit divisor
* @brief Signed 64bit divide with 32bit divisor
*/
int64_t div_s64(int64_t dividend, int32_t divisor)
{
@@ -336,7 +369,7 @@ int64_t div_s64(int64_t dividend, int32_t divisor)
}
/**
* Converts from string to int32_t
* @brief Converts from string to int32_t
* @param *str
* @return int32_t
*/
@@ -352,7 +385,7 @@ int32_t str_to_int32(const char *str)
}
/**
* Converts from string to uint32_t
* @brief Converts from string to uint32_t
* @param *str
* @return uint32_t
*/
@@ -366,3 +399,5 @@ uint32_t srt_to_uint32(const char *str)
else
return value;
}
/** @} */