1*758c037aSStefan Roese /* Permission is hereby granted to copy, modify and redistribute this code 2*758c037aSStefan Roese * in terms of the GNU Library General Public License, Version 2 or later, 3*758c037aSStefan Roese * at your option. 4*758c037aSStefan Roese */ 5*758c037aSStefan Roese 6*758c037aSStefan Roese /* macros to translate to/from binary and binary-coded decimal (frequently 7*758c037aSStefan Roese * found in RTC chips). 8*758c037aSStefan Roese */ 9*758c037aSStefan Roese 10*758c037aSStefan Roese #ifndef _BCD_H 11*758c037aSStefan Roese #define _BCD_H 12*758c037aSStefan Roese 13*758c037aSStefan Roese #define BCD2BIN(val) (((val) & 0x0f) + ((val)>>4)*10) 14*758c037aSStefan Roese #define BIN2BCD(val) ((((val)/10)<<4) + (val)%10) 15*758c037aSStefan Roese 16*758c037aSStefan Roese /* backwards compat */ 17*758c037aSStefan Roese #define BCD_TO_BIN(val) ((val)=BCD2BIN(val)) 18*758c037aSStefan Roese #define BIN_TO_BCD(val) ((val)=BIN2BCD(val)) 19*758c037aSStefan Roese 20*758c037aSStefan Roese #endif /* _BCD_H */ 21