1 |
786 |
skrzyp |
#ifndef USBS_I386_SORO12_INL
|
2 |
|
|
#define USBS_I386_SORO12_INL
|
3 |
|
|
//==========================================================================
|
4 |
|
|
//
|
5 |
|
|
// usbS_i386_sorod12.inl
|
6 |
|
|
//
|
7 |
|
|
// Hardware specific parts for the SoRo D12 PC 104 USB card.
|
8 |
|
|
//
|
9 |
|
|
//==========================================================================
|
10 |
|
|
// ####ECOSGPLCOPYRIGHTBEGIN####
|
11 |
|
|
// -------------------------------------------
|
12 |
|
|
// This file is part of eCos, the Embedded Configurable Operating System.
|
13 |
|
|
// Copyright (C) 2006 Free Software Foundation, Inc.
|
14 |
|
|
//
|
15 |
|
|
// eCos is free software; you can redistribute it and/or modify it under
|
16 |
|
|
// the terms of the GNU General Public License as published by the Free
|
17 |
|
|
// Software Foundation; either version 2 or (at your option) any later
|
18 |
|
|
// version.
|
19 |
|
|
//
|
20 |
|
|
// eCos is distributed in the hope that it will be useful, but WITHOUT
|
21 |
|
|
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
22 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
23 |
|
|
// for more details.
|
24 |
|
|
//
|
25 |
|
|
// You should have received a copy of the GNU General Public License
|
26 |
|
|
// along with eCos; if not, write to the Free Software Foundation, Inc.,
|
27 |
|
|
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
28 |
|
|
//
|
29 |
|
|
// As a special exception, if other files instantiate templates or use
|
30 |
|
|
// macros or inline functions from this file, or you compile this file
|
31 |
|
|
// and link it with other works to produce a work based on this file,
|
32 |
|
|
// this file does not by itself cause the resulting work to be covered by
|
33 |
|
|
// the GNU General Public License. However the source code for this file
|
34 |
|
|
// must still be made available in accordance with section (3) of the GNU
|
35 |
|
|
// General Public License v2.
|
36 |
|
|
//
|
37 |
|
|
// This exception does not invalidate any other reasons why a work based
|
38 |
|
|
// on this file might be covered by the GNU General Public License.
|
39 |
|
|
// -------------------------------------------
|
40 |
|
|
// ####ECOSGPLCOPYRIGHTEND####
|
41 |
|
|
//==========================================================================
|
42 |
|
|
//#####DESCRIPTIONBEGIN####
|
43 |
|
|
//
|
44 |
|
|
// Author(s): Frank M. Pagliughi (fmp), ASL
|
45 |
|
|
// Date: 2004-05-22
|
46 |
|
|
//
|
47 |
|
|
// This code is a hardware specific device driver for the SoRo Systems
|
48 |
|
|
// USB-D12-104, a PC/104 (ISA) Full-Speed USB slave board, which turns
|
49 |
|
|
// a PC/104 stack into a USB slave device. The board contains a
|
50 |
|
|
// Philips PDIUSBD12 Peripheral Controller Chip mapped into the PC's
|
51 |
|
|
// I/O space, with jumper-selectable I/O base address, IRQ, and DMA
|
52 |
|
|
// settings. The eCos config tool is used to adjust settings for this
|
53 |
|
|
// driver to match the physical jumper settings. The chip could run in
|
54 |
|
|
// polled mode without an IRQ, but this wouldn't be a great idea other
|
55 |
|
|
// than maybe a debug environment.
|
56 |
|
|
|
57 |
|
|
// ------------------------------------------------------------------------
|
58 |
|
|
// Data-Only I/O
|
59 |
|
|
// ------------------------------------------------------------------------
|
60 |
|
|
//
|
61 |
|
|
|
62 |
|
|
#include
|
63 |
|
|
|
64 |
|
|
// These routines read or write 8 bit values to the data area.
|
65 |
|
|
|
66 |
|
|
static inline byte d12_read_data_byte(d12_addr_type base_addr)
|
67 |
|
|
{
|
68 |
|
|
#if defined(CYGSEM_DEVS_USB_I386_SOROD12_IO_MAPPED)
|
69 |
|
|
byte val;
|
70 |
|
|
HAL_READ_UINT8((unsigned) base_addr, val);
|
71 |
|
|
return val;
|
72 |
|
|
#else
|
73 |
|
|
return *base_addr;
|
74 |
|
|
#endif
|
75 |
|
|
}
|
76 |
|
|
|
77 |
|
|
static inline void d12_write_data_byte(d12_addr_type base_addr, byte val)
|
78 |
|
|
{
|
79 |
|
|
#if defined(CYGSEM_DEVS_USB_I386_SOROD12_IO_MAPPED)
|
80 |
|
|
HAL_WRITE_UINT8((unsigned) base_addr, val);
|
81 |
|
|
#else
|
82 |
|
|
*base_addr = val;
|
83 |
|
|
#endif
|
84 |
|
|
}
|
85 |
|
|
|
86 |
|
|
// This routine writes a command to the device.
|
87 |
|
|
|
88 |
|
|
static inline void d12_write_cmd(d12_addr_type base_addr, byte cmd)
|
89 |
|
|
{
|
90 |
|
|
#if defined(CYGSEM_DEVS_USB_I386_SOROD12_IO_MAPPED)
|
91 |
|
|
HAL_WRITE_UINT8((unsigned) base_addr+1, cmd);
|
92 |
|
|
#else
|
93 |
|
|
*(base_addr+1) = cmd;
|
94 |
|
|
#endif
|
95 |
|
|
}
|
96 |
|
|
|
97 |
|
|
// ------------------------------------------------------------------------
|
98 |
|
|
// Reads 'n' bytes from the data address of the D12 and places them into
|
99 |
|
|
// the buf[] array. Buf can be NULL, in which case the specified number of
|
100 |
|
|
// bytes are read and discarded.
|
101 |
|
|
|
102 |
|
|
static uint8 d12_read_data(d12_addr_type base_addr, byte *buf, uint8 n)
|
103 |
|
|
{
|
104 |
|
|
uint8 i;
|
105 |
|
|
|
106 |
|
|
if (buf) {
|
107 |
|
|
for (i=0; i
|
108 |
|
|
buf[i] = d12_read_data_byte(base_addr);
|
109 |
|
|
}
|
110 |
|
|
else {
|
111 |
|
|
for (i=0; i
|
112 |
|
|
d12_read_data_byte(base_addr);
|
113 |
|
|
n = 0;
|
114 |
|
|
}
|
115 |
|
|
|
116 |
|
|
return n;
|
117 |
|
|
}
|
118 |
|
|
|
119 |
|
|
// ------------------------------------------------------------------------
|
120 |
|
|
// Writes 'n' bytes out the data reg of the chip
|
121 |
|
|
|
122 |
|
|
static void d12_write_data(d12_addr_type base_addr, const byte *buf, uint8 n)
|
123 |
|
|
{
|
124 |
|
|
uint8 i;
|
125 |
|
|
|
126 |
|
|
for (i=0; i
|
127 |
|
|
d12_write_data_byte(base_addr, buf[i]);
|
128 |
|
|
}
|
129 |
|
|
|
130 |
|
|
#endif // USBS_I386_SORO12_INL
|