-
Notifications
You must be signed in to change notification settings - Fork 2
/
cs8900.c
98 lines (85 loc) · 2.64 KB
/
cs8900.c
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#include <exec/types.h>
#include "cs8900.h"
/*****************************************************************************
*
* peek
*
*****************************************************************************/
UBYTE peek (ULONG addr) {
ULONG *ptr;
ULONG value;
// Dummy read
ptr = (ULONG *)0x40000000;
value = *ptr;
ptr = (ULONG *)addr;
value = (*ptr) >> ((addr & 0x03) << 3);
return value;
}
/*****************************************************************************
*
* poke
*
*****************************************************************************/
void poke (ULONG addr, UBYTE value) {
UBYTE *ptr;
UBYTE dummy;
// Dummy read
ptr = (UBYTE *)0x40000000;
dummy = *ptr;
ptr = (BYTE *) addr;
*ptr = value;
}
/*****************************************************************************
*
* ppPeek
*
*****************************************************************************/
UWORD ppPeek (UWORD pport) {
UWORD value;
poke (0x4400000a, (UBYTE)(pport));
poke (0x4400000b, (UBYTE)(pport >> 8));
// value = ((UWORD)(peek (0x4400000c)) << 8) + peek (0x4400000d);
value = ((UWORD)(peek (0x4400000c))) + ((UWORD)(peek (0x4400000d)) << 8);
return value;
}
/*****************************************************************************
*
* ppPoke
*
*****************************************************************************/
void ppPoke (UWORD pport, UWORD value) {
poke (0x4400000a, (UBYTE)(pport));
poke (0x4400000b, (UBYTE)(pport >> 8));
poke (0x4400000c, value & 0xff);
poke (0x4400000d, (value >> 8) & 0xff);
}
/*****************************************************************************
*
* WordToTxDataPort0
*
*****************************************************************************/
void WordToTxDataPort0 (UWORD value) {
poke (0x44000000, (value >> 8) & 0xff);
poke (0x44000001, value & 0xff);
}
/*****************************************************************************
*
* LongToTxDataPort0
*
*****************************************************************************/
void LongToTxDataPort0 (ULONG value) {
poke (0x44000000, (value >> 24) & 0xff);
poke (0x44000001, (value >> 16) & 0xff);
poke (0x44000000, (value >> 8) & 0xff);
poke (0x44000001, value & 0xff);
}
/*****************************************************************************
*
* CS8900_Configure
*
*****************************************************************************/
void CS8900_Configure () {
ppPoke (PP_RxCTL, PP_RxCTL_Promiscuous | PP_RxCTL_RxOK);
ppPoke (PP_TestCTL, 0x4000);
ppPoke (PP_LineCTL, PP_LineCTL_Rx | PP_LineCTL_Tx);
}