1 /* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later */ 2 #ifndef LIBPLDM_BCD_H 3 #define LIBPLDM_BCD_H 4 5 #include <stdint.h> 6 7 #ifdef __cplusplus 8 extern "C" { 9 #endif 10 11 /** @brief Convert bcd number(uint8_t) to decimal 12 * @param[in] bcd - bcd number 13 * @return the decimal number 14 */ 15 uint8_t pldm_bcd_bcd2dec8(uint8_t bcd); 16 17 /** @brief Convert decimal number(uint8_t) to bcd 18 * @param[in] dec - decimal number 19 * @return the bcd number 20 */ 21 uint8_t pldm_bcd_dec2bcd8(uint8_t dec); 22 23 /** @brief Convert bcd number(uint16_t) to decimal 24 * @param[in] bcd - bcd number 25 * @return the decimal number 26 */ 27 uint16_t pldm_bcd_bcd2dec16(uint16_t bcd); 28 29 /** @brief Convert decimal number(uint16_t) to bcd 30 * @param[in] dec - decimal number 31 * @return the bcd number 32 */ 33 uint16_t pldm_bcd_dec2bcd16(uint16_t dec); 34 35 /** @brief Convert bcd number(uint32_t) to decimal 36 * @param[in] bcd - bcd number 37 * @return the decimal number 38 */ 39 uint32_t pldm_bcd_bcd2dec32(uint32_t bcd); 40 41 /** @brief Convert decimal number(uint32_t) to bcd 42 * @param[in] dec - decimal number 43 * @return the bcd number 44 */ 45 uint32_t pldm_bcd_dec2bcd32(uint32_t dec); 46 47 #ifdef __cplusplus 48 } 49 #endif 50 51 #endif 52