GPS Device
Loading...
Searching...
No Matches
Common Macros

Convenience macros used across the project. More...

Collaboration diagram for Common Macros:

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.

Detailed Description

Convenience macros used across the project.

Macro Definition Documentation

◆ BCD_TO_DEC

#define BCD_TO_DEC ( BCD)
Value:
(((BCD) >> 4) * 10 + ((BCD) & 0x0F))

Converts a BCD-encoded byte to its decimal equivalent.

Parameters
BCDA byte where the upper nibble holds the tens digit and the lower nibble holds the units digit.

Definition at line 47 of file common.h.

◆ DEC_TO_BCD

#define DEC_TO_BCD ( DEC)
Value:
(((DEC / 10) << 4) | (DEC % 10))

Converts a decimal value to its BCD-encoded byte equivalent.

Parameters
DECA decimal integer value (0–99).

Definition at line 54 of file common.h.

◆ DELAY

#define DELAY ( ms)
Value:
do { \
uint32_t delay_start_time = systick_get_ms(); \
while ((systick_get_ms() - delay_start_time) < (ms)) { \
} \
} while (0)
uint32_t systick_get_ms(void)
Returns the number of milliseconds elapsed since SysTick was initialized.

Blocking delay using the system tick counter.

Spins until ms milliseconds have elapsed since the macro was entered. Requires systick_get_ms() to be available in scope.

Parameters
msNumber of milliseconds to wait.

Definition at line 65 of file common.h.

65#define DELAY(ms) \
66 do { \
67 uint32_t delay_start_time = systick_get_ms(); \
68 while ((systick_get_ms() - delay_start_time) < (ms)) { \
69 } \
70 } while (0)