-
Notifications
You must be signed in to change notification settings - Fork 2
/
avrm.h
47 lines (37 loc) · 1.05 KB
/
avrm.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#ifndef __AVR_H__
#define __AVR_H__
#include <avr/io.h>
#include <stdio.h>
#include <util/delay.h>
// Type Definitions
///////////////////
// The bool type, with supporting TRUE and FALSE constants.
#define FALSE 0
#define TRUE 1
typedef _Bool bool;
// The byte type.
typedef unsigned char byte;
// General Functions
////////////////////
// printb
// Print out the given data in it's binary representation.
// Assumes little endian.
//
void printb(void const * const ptr, size_t const size);
// bcd_to_dec
// Convert a Binary Coded Digit into it's corresponding value.
// TODO: Add support for the sign bit, allowing output range to be (-99 - 99).
//
// data - The BCD value to convert into normal decimal form.
//
// Returns the decimal value (0 - 99).
byte bcd_to_dec(byte data);
// dec_to_bcd
// Convert a value into it's corresponding Binary Coded Digit.
// TODO: Add support for the sign bit, allowing input range to be (-99 - 99).
//
// data - The decimal value (0 - 99) to convert into BCD form.
//
// Returns the BCD value.
byte dec_to_bcd(byte data);
#endif