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

Common utility module public API. More...

#include <stdint.h>
#include <stdbool.h>
Include dependency graph for common.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define BCD_TO_DEC(BCD)
 Converts a BCD-encoded byte to its decimal equivalent.
#define DEC_TO_BCD(DEC)
 Converts a decimal value to its BCD-encoded byte equivalent.
#define DELAY(ms)
 Blocking delay using the system tick counter.

Enumerations

enum  PIN_STATUS_te { LOW , HIGH }
 Represents the logical level of a GPIO pin. More...
enum  EN_STATUS_te { DISABLE , ENABLE }
 Represents an enabled or disabled state. More...
enum  VERTICAL_DIR_te { DOWN , UP }
 Represents a vertical movement direction. More...

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

Common utility module public API.

Author
github.com/Baksi675

This module provides general-purpose utility functions and type definitions shared across all other modules, including:

  • String manipulation (copy, compare, tokenize, convert)
  • Numeric conversion (integer, double, hex to/from string)
  • Bit extraction from byte arrays
  • Common type definitions (pin state, enable state, direction)
  • Convenience macros (BCD conversion, blocking delay)
Version
0.1
Date
2026-01-22

Definition in file common.h.