GPS Device
Loading...
Searching...
No Matches
common.c File Reference

A module that contains code common to all other modules. More...

#include <stdbool.h>
#include "common.h"
Include dependency graph for common.c:

Go to the source code of this file.

Functions

uint32_t get_str_len (char const *str)
 Returns the length of a string, excluding the null terminator.
void int_to_str (int num, char *str)
 Converts an integer to its decimal string representation.
int str_to_int (const char *str)
 Converts a decimal string to an integer.
void double_to_str (double num, char *str, int8_t frac_digits)
 Converts a double to a decimal string with a fixed number of fractional digits.
void hex_byte_to_str (uint8_t byte, char *str)
 Converts a single byte to a two-character uppercase hexadecimal string.
void str_set (char *target_str, char const *host_str, uint32_t host_str_len, uint32_t pos)
 Overwrites a region of a target string with the contents of a source string.
int32_t get_pow (int32_t base, int32_t exponent)
 Computes an integer power.
void arr_cmprs (char *arr, uint8_t len)
 Compresses an array by removing null bytes and shifting remaining elements left.
bool str_cmp (const char *str1, const char *str2)
 Compares two null-terminated strings for equality.
uint8_t ascii_hex_to_byte (char high, char low)
 Converts two ASCII hex characters into a single byte value.
int str_tokenize (char *str, const char *separator, uint16_t max_tokens, char **tokens, uint16_t *num_tokens)
 Splits a string into tokens separated by a given delimiter.
bool str_to_bool (char const *str)
 Converts a string representation of a boolean to a bool value.
int str_cpy (char *str_to, const char *str_from, uint32_t len)
 Copies a null-terminated string into a destination buffer.
int txt_cpy (char *txt_to, const char *txt_from, uint32_t len)
 Copies a fixed-length block of text into a destination buffer.
bool is_pow (uint32_t num)
 Checks whether a number is a power of two.
uint32_t extract_bits (const uint8_t *data, uint16_t start_bit, uint8_t num_bits)
 Extracts a range of bits from a big-endian byte array.

Detailed Description

A module that contains code common to all other modules.

Author
github.com/Baksi675
Version
0.1
Date
2025-09-09

Definition in file common.c.