-
Notifications
You must be signed in to change notification settings - Fork 0
/
JLib.h
58 lines (41 loc) · 1.74 KB
/
JLib.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
48
49
50
51
52
53
54
55
56
57
58
/*
Author: Jason Cronquist
*/
#ifndef JLib_h
#define JLib_h
#include <stdlib.h>
#include <string.h>
//#define LANDSCAPE
typedef struct {
char* value;
unsigned int length;
} String;
typedef enum {false, true} bool;
typedef void (*Function)(unsigned char);
#define ENABLE true
#define DISABLE false
#define BYTE unsigned char
#define HALF_WORD unsigned short
#define WORD unsigned int
#define BYTE_ADDRESS volatile unsigned char*
#define HALF_WORD_ADDRESS volatile unsigned short*
#define WORD_ADDRESS volatile unsigned int*
//SYNTAX:
// <action>_<allignment>(BYTE Alligned Address, offset, ... );
BYTE read_byte(BYTE_ADDRESS, unsigned short);
HALF_WORD read_halfWord(BYTE_ADDRESS, unsigned short);
WORD read_word(BYTE_ADDRESS, unsigned short);
void write_byte(BYTE_ADDRESS, unsigned short, BYTE);
void write_halfWord(BYTE_ADDRESS, unsigned short, HALF_WORD);
void write_word(BYTE_ADDRESS, unsigned short, WORD);
void setBit_word(BYTE_ADDRESS, unsigned short, unsigned char, bool);
void setBit_halfWord(BYTE_ADDRESS addr, volatile unsigned short offset, unsigned char bitNumber, bool enable);
BYTE getBit(BYTE_ADDRESS, unsigned short, unsigned char);
void readModWrite_byte(BYTE_ADDRESS, unsigned short, BYTE , bool);
void readModWrite_halfWord (BYTE_ADDRESS,unsigned short ,HALF_WORD ,bool);
void readModWrite_word(BYTE_ADDRESS, unsigned short, WORD , bool);
void clearModWriteRange_word(BYTE_ADDRESS, unsigned short, WORD, bool, unsigned char startBit, unsigned char size);
void selectiveClearAndWrite_word(BYTE_ADDRESS, unsigned short, WORD clear, WORD write);
void selectiveClearAndWrite_halfWord(BYTE_ADDRESS, unsigned short, HALF_WORD clear, HALF_WORD write);
void selectiveClearAndWrite_byte(BYTE_ADDRESS, unsigned short, BYTE clear, BYTE write);
#endif