1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2026-01-01 01:41:18 +01:00

Merge pull request #13530 from benpicco/core/util

sys: add units.h for helper macros
This commit is contained in:
Alexandre Abadie 2020-06-03 16:24:04 +02:00 committed by GitHub
commit a770bf0f89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -0,0 +1,56 @@
/*
* Copyright (C) 2020 ML!PA Consulting GmbH
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @ingroup core_macros
* @{
*
* @file
* @brief Unit helper macros
*
* @author Benjamin Valentin <benjamin.valentin@ml-pa.com>
*/
#ifndef MACROS_UNITS_H
#define MACROS_UNITS_H
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief A macro to return the bytes in x KiB
*/
#define KiB(x) ((unsigned long long)(x) << 10)
/**
* @brief A macro to return the bytes in x MiB
*/
#define MiB(x) (KiB(x) << 10)
/**
* @brief A macro to return the bytes in x GiB
*/
#define GiB(x) (MiB(x) << 10)
/**
* @brief A macro to return the Hz in x kHz
*/
#define KHZ(x) ((x) * 1000ULL)
/**
* @brief A macro to return the Hz in x MHz
*/
#define MHZ(x) (KHZ(x) * 1000ULL)
#ifdef __cplusplus
}
#endif
#endif /* MACROS_UNITS_H */
/** @} */