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