diff --git a/drivers/clock_control/clock_control_litex.h b/drivers/clock_control/clock_control_litex.h index 8a1b25de400..1263705989e 100644 --- a/drivers/clock_control/clock_control_litex.h +++ b/drivers/clock_control/clock_control_litex.h @@ -7,11 +7,11 @@ #ifndef LITEX_MMCM_H #define LITEX_MMCM_H +#include #include /* Common values */ -#define PICOS_IN_SEC 1000000000000 -#define BITS_PER_BYTE 8 +#define PICOS_IN_SEC 1000000000000 /* MMCM specific numbers */ #define CLKOUT_MAX 7 diff --git a/drivers/fpga/fpga_ice40.c b/drivers/fpga/fpga_ice40.c index eabda03db55..9a5d6aa87aa 100644 --- a/drivers/fpga/fpga_ice40.c +++ b/drivers/fpga/fpga_ice40.c @@ -19,6 +19,7 @@ #include #include #include +#include /* * Note: When loading a bitstream, the iCE40 has a 'quirk' in that the CS @@ -50,18 +51,6 @@ #define FPGA_ICE40_LOAD_MODE_SPI 0 #define FPGA_ICE40_LOAD_MODE_GPIO 1 -#ifndef BITS_PER_NIBBLE -#define BITS_PER_NIBBLE 4 -#endif - -#ifndef BITS_PER_BYTE -#define BITS_PER_BYTE 8 -#endif - -#ifndef NIBBLES_PER_BYTE -#define NIBBLES_PER_BYTE (BITS_PER_BYTE / BITS_PER_NIBBLE) -#endif - /* * Values in Hz, intentionally to be comparable with the spi-max-frequency * property from DT bindings in spi-device.yaml. diff --git a/include/zephyr/sys/util.h b/include/zephyr/sys/util.h index 6fba21dc16a..c0c69b31433 100644 --- a/include/zephyr/sys/util.h +++ b/include/zephyr/sys/util.h @@ -57,6 +57,15 @@ extern "C" { # error Missing required predefined macros for BITS_PER_LONG calculation #endif +/** Number of bits in a byte. */ +#define BITS_PER_BYTE (__CHAR_BIT__) + +/** Number of bits in a nibble. */ +#define BITS_PER_NIBBLE (__CHAR_BIT__ / 2) + +/** Number of nibbles in a byte. */ +#define NIBBLES_PER_BYTE (BITS_PER_BYTE / BITS_PER_NIBBLE) + /** Number of bits in a long int. */ #define BITS_PER_LONG (__CHAR_BIT__ * __SIZEOF_LONG__) diff --git a/subsys/shell/modules/devmem_service.c b/subsys/shell/modules/devmem_service.c index e1ebaee7ef3..c2c37215d3a 100644 --- a/subsys/shell/modules/devmem_service.c +++ b/subsys/shell/modules/devmem_service.c @@ -18,6 +18,7 @@ #include #include #include +#include #ifndef CONFIG_NATIVE_LIBC extern void getopt_init(void); @@ -39,10 +40,6 @@ static bool littleendian; #define CHAR_CAN 0x18 #define CHAR_DC1 0x11 -#ifndef BITS_PER_BYTE -#define BITS_PER_BYTE 8 -#endif - static int memory_dump(const struct shell *sh, mem_addr_t phys_addr, size_t size, uint8_t width) { uint32_t value;