blob: ebb6e02d60d3d575addea309f2abc31e11e2d7dd [file] [log] [blame]
Angel Pons32859fc2020-04-02 23:48:27 +02001/* SPDX-License-Identifier: GPL-2.0-only */
2/* This file is part of the coreboot project. */
Marc Jones3cc685f2014-12-29 21:31:44 -07003
4#ifndef _BCD_H_
5#define _BCD_H_
6
7#include <stdint.h>
8
9static inline uint8_t bcd2bin(uint8_t val)
10{
11 return ((val >> 4) & 0xf) * 10 + (val & 0xf);
12}
13
14static inline uint8_t bin2bcd(uint8_t val)
15{
16 return ((val / 10) << 4) | (val % 10);
17}
18
19#endif /* _BCD_H_ */