diff options
author | Takamichi Horikawa <takamichiho@gmail.com> | 2016-11-26 20:57:57 +0900 |
---|---|---|
committer | Takamichi Horikawa <takamichiho@gmail.com> | 2016-11-26 20:57:57 +0900 |
commit | 6fd10cdacb5cbe47a4fc339c20a733d4a9a384a1 (patch) | |
tree | c7f479a70c350dca0b73d76078e46db41d9c4133 /fmdriver/fmdriver_common.h |
initial
Diffstat (limited to 'fmdriver/fmdriver_common.h')
-rw-r--r-- | fmdriver/fmdriver_common.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/fmdriver/fmdriver_common.h b/fmdriver/fmdriver_common.h new file mode 100644 index 0000000..cd804b8 --- /dev/null +++ b/fmdriver/fmdriver_common.h @@ -0,0 +1,19 @@ +#ifndef MYON_FMDRIVER_COMMON_H_INCLUDED +#define MYON_FMDRIVER_COMMON_H_INCLUDED + +static inline uint16_t read16le(const uint8_t *ptr) { + return (unsigned)ptr[0] | (((unsigned)ptr[1])<<8); +} + +static inline int16_t u8s16(uint8_t v) { + return (v & 0x80) ? ((int16_t)v)-0x100 : v; +} + +static inline int16_t u16s16(uint16_t v) { + return (v & 0x8000) ? ((int32_t)v)-0x10000 : v; +} + +#include <stdio.h> +#define FMDRIVER_DEBUG(...) fprintf(stderr, __VA_ARGS__) + +#endif // MYON_FMDRIVER_COMMON_H_INCLUDED |