aboutsummaryrefslogtreecommitdiff
path: root/SrcShared/Hardware/EmRegsVZVisorEdge.cpp
blob: 2717990fa4cbed1b089cf1c7a204e8863b436178 (plain)
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
/* -*- mode: C++; tab-width: 4 -*- */
/* ===================================================================== *\
	Copyright (c) 2001 Palm, Inc. or its subsidiaries.
	All rights reserved.

	This file is part of the Palm OS Emulator.

	This program is free software; you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation; either version 2 of the License, or
	(at your option) any later version.
\* ===================================================================== */

#include "EmCommon.h"
#include "EmRegsEZVisor.h"
#include "EmRegsVZVisorEdge.h"
#include "EmRegsVZPrv.h"


// Implementation of register-handling for Visor Edge.  Visor Edge is derived
// from Visor Platinum with the following differences:  
//  - key setup is identical to Visor Prism
//  - "LCD Enable On" pin is in a different location
//  - backlight pin is active high and in different place


/************************************************************************
 * Port B Bit settings
 ************************************************************************/
#define	hwrVisorEdgePortBLCDVccOff		0x08	// (L) LCD Vcc 
#define	hwrVisorEdgePortBLCDAdjOn		0x40	// (H) LCD Contrast Voltage


/************************************************************************
 * Port C Bit settings
 ************************************************************************/


/************************************************************************
 * Port D Bit settings
 ************************************************************************/
#define hwrVisorEdgePortDKbdCol0On		0x01 	// (H) Keyboard Column 0
#define hwrVisorEdgePortDKbdCol1On		0x02 	// (H) Keyboard Column 1
#define hwrVisorEdgePortDKbdCol2On		0x04 	// (H) Keyboard Column 2

#define hwrVisorEdgePortDExtPowerOn     0x08    // (H) External power indicator
									
#define hwrVisorEdgePortDDock1IrqOff	0x10 	// (L) Dock1 interrupt
#define hwrVisorEdgePortDSlotIrqOff		0x20 	// (L) Slot Interrupt
#define hwrVisorEdgePortDUsbIrqOff		0x40 	// (L) USB Interrupt
#define hwrVisorEdgePortDCardInstIrqOff	0x80 	// (L) Card Installed Interrupt

#define	hwrVisorEdgePortDKeyBits		0x07 	// (H) All Keyboard Columns


/************************************************************************
 * Port E Bit settings
 ************************************************************************/
#define	hwrVisorEdgePortESerialTxD		0x20	// ( ) Serial transmit line
#define hwrVisorEdgePortESlotResetOff	0x40 	// (L) Slot reset
#define hwrVisorEdgePortEDock2Off		0x80 	// (L) Dock2 input


/************************************************************************
 * Port F Bit settings
 ************************************************************************/
#define	hwrVisorEdgePortFContrast		0x01	// ( ) LCD Contrast PWM output
#define hwrVisorEdgePortFIREnableOff	0x04	// (L) Shutdown IR
#define hwrVisorEdgePortFUsbCsOff		0x80	// (L) USB chip select


/************************************************************************
 * Port G Bit settings
 ************************************************************************/
#define hwrVisorEdgePortGUnused0			0x01	// ( ) unused GPIO (after reset)
#define hwrVisorEdgePortGUsbSuspend			0x02	// (X) USB Suspend bit - Output low for active
													//                     - Input for suspend
#define	hwrVisorEdgePortGPowerFailIrqOff	0x04	// (L) Power Fail IRQ
#define hwrVisorEdgePortGKbdRow0 			0x08	// (H) Keyboard Row 0	
#define hwrVisorEdgePortGKbdRow1 			0x10	// (H) Keyboard Row 1	
#define hwrVisorEdgePortGAdcCsOff			0x20	// (L) A/D Select


/************************************************************************
 * Port J Bit settings
 ************************************************************************/
#define hwrVisorEdgePortJUnused0		0x01	// (X) unused GPIO
#define hwrVisorEdgePortJUnused1		0x02	// (X) unused GPIO
#define hwrVisorEdgePortJUnused2		0x04	// (X) unused GPIO
#define hwrVisorEdgePortJUnused3		0x08	// (X) unused GPIO
#define hwrVisorEdgePortJSerial2RxD		0x10	// ( ) Serial (UART2) recieve line
#define hwrVisorEdgePortJSerial2TxD		0x20	// ( ) Serial (UART2) transmit line
#define hwrVisorEdgePortJSerial2Rts		0x40	// ( ) Serial (UART2) RTS
#define hwrVisorEdgePortJSerial2Cts		0x80	// ( ) Serial (UART2) CTS


/************************************************************************
 * Port K Bit settings
 ************************************************************************/
#define hwrVisorEdgePortKUnused0        0x01    // (X) unused GPIO
#define hwrVisorEdgePortKKbdRow2        0x02    // (H) Keyboard Row 2
#define hwrVisorEdgePortKUnused2        0x04    // (X) unused GPIO
#define hwrVisorEdgePortKUnused3        0x08    // (X) unused GPIO

#define	hwrVisorEdgePortKLedOn			0x10	// (L) Turn on LED
#define hwrVisorEdgePortKLCDEnableOn	0x20	// (L) Shutdown IR
#define hwrVisorEdgePortKBacklightOn	0x40	// (H) Backlight on/off
#define	hwrVisorEdgePortKUsbResetOff	0x80	// (L) USB reset


/************************************************************************
 * Port M Bit settings
 ************************************************************************/

#define hwrVisorEdgePortMChargerOff			0x01    // (L) Assert (drive low) to enable 
													//     charger. Deassert for 1ms
													//     to restart charger
#define hwrVisorEdgePortMChargerOn			0x04    // (H) Assert (drive high) to enable 
													//     charger. Deassert for 1ms
													//     to restart charger


// ---------------------------------------------------------------------------
//		¥ EmRegsVZVisorEdge::GetLCDScreenOn
// ---------------------------------------------------------------------------

Bool EmRegsVZVisorEdge::GetLCDScreenOn (void)
{
	return (READ_REGISTER (portKData) & hwrVisorEdgePortKLCDEnableOn) != 0;
}


// ---------------------------------------------------------------------------
//		¥ EmRegsVZVisorEdge::GetLCDBacklightOn
// ---------------------------------------------------------------------------

Bool EmRegsVZVisorEdge::GetLCDBacklightOn (void)
{
	return (READ_REGISTER (portKData) & hwrVisorEdgePortKBacklightOn) != 0;
}


// ---------------------------------------------------------------------------
//		¥ EmRegsVZVisorEdge::GetKeyInfo
// ---------------------------------------------------------------------------

void EmRegsVZVisorEdge::GetKeyInfo (int* numRows, int* numCols,
									uint16* keyMap, Bool* rows)
{
	*numRows = kNumButtonRows;
	*numCols = kNumButtonCols;

	memcpy (keyMap, kVisorButtonMap, sizeof (kVisorButtonMap));

	// Determine what row is being asked for.

	UInt8	portKDir	= READ_REGISTER (portKDir);
	UInt8	portKData	= READ_REGISTER (portKData);

	UInt8	portGDir	= READ_REGISTER (portGDir);
	UInt8	portGData	= READ_REGISTER (portGData);

	rows[0]	= (portGDir & hwrVisorEdgePortGKbdRow0)   != 0 && (portGData & hwrVisorEdgePortGKbdRow0) == 0;
	rows[1]	= (portGDir & hwrVisorEdgePortGKbdRow1)   != 0 && (portGData & hwrVisorEdgePortGKbdRow1) == 0;
	rows[2]	= (portKDir & hwrVisorEdgePortKKbdRow2)   != 0 && (portKData & hwrVisorEdgePortKKbdRow2) == 0;
}