]> git.ipfire.org Git - people/ms/u-boot.git/blame - include/bcd.h
Convert CONFIG_BOOTCOUNT_ENV to Kconfig
[people/ms/u-boot.git] / include / bcd.h
CommitLineData
758c037a
SR
1/* Permission is hereby granted to copy, modify and redistribute this code
2 * in terms of the GNU Library General Public License, Version 2 or later,
3 * at your option.
4 */
5
e84aba13
AT
6/* inline functions to translate to/from binary and binary-coded decimal
7 * (frequently found in RTC chips).
758c037a
SR
8 */
9
10#ifndef _BCD_H
11#define _BCD_H
12
be47aa65 13static inline unsigned int bcd2bin(unsigned int val)
e84aba13 14{
be47aa65 15 return ((val) & 0x0f) + ((val & 0xff) >> 4) * 10;
e84aba13
AT
16}
17
be47aa65 18static inline unsigned int bin2bcd(unsigned int val)
e84aba13
AT
19{
20 return (((val / 10) << 4) | (val % 10));
21}
758c037a
SR
22
23#endif /* _BCD_H */