1 |
158 |
chris |
/*
|
2 |
|
|
*-------------------------------------------------------------------
|
3 |
|
|
*
|
4 |
|
|
* QSM -- Queued Serial Module
|
5 |
|
|
*
|
6 |
|
|
* The QSM contains two serial interfaces: (a) the queued serial
|
7 |
|
|
* peripheral interface (QSPI) and the serial communication interface
|
8 |
|
|
* (SCI). The QSPI provides peripheral expansion and/or interprocessor
|
9 |
|
|
* communication through a full-duplex, synchronous, three-wire bus. A
|
10 |
|
|
* self contained RAM queue permits serial data transfers without CPU
|
11 |
|
|
* intervention and automatic continuous sampling. The SCI provides a
|
12 |
|
|
* standard non-return to zero mark/space format with wakeup functions
|
13 |
|
|
* to allow the CPU to run uninterrupted until woken
|
14 |
|
|
*
|
15 |
|
|
* For more information, refer to Motorola's "Modular Microcontroller
|
16 |
|
|
* Family Queued Serial Module Reference Manual" (Motorola document
|
17 |
|
|
* QSMRM/AD).
|
18 |
|
|
*
|
19 |
|
|
* This file has been created by John S. Gwynne for support of
|
20 |
|
|
* Motorola's 68332 MCU in the efi332 project.
|
21 |
|
|
*
|
22 |
|
|
* Redistribution and use in source and binary forms are permitted
|
23 |
|
|
* provided that the following conditions are met:
|
24 |
|
|
* 1. Redistribution of source code and documentation must retain
|
25 |
|
|
* the above authorship, this list of conditions and the
|
26 |
|
|
* following disclaimer.
|
27 |
|
|
* 2. The name of the author may not be used to endorse or promote
|
28 |
|
|
* products derived from this software without specific prior
|
29 |
|
|
* written permission.
|
30 |
|
|
*
|
31 |
|
|
* This software is provided "AS IS" without warranty of any kind,
|
32 |
|
|
* either expressed or implied, including, but not limited to, the
|
33 |
|
|
* implied warranties of merchantability, title and fitness for a
|
34 |
|
|
* particular purpose.
|
35 |
|
|
*
|
36 |
|
|
*------------------------------------------------------------------
|
37 |
|
|
*
|
38 |
208 |
chris |
* $Id: qsm.h,v 1.2 2001-09-27 11:59:28 chris Exp $
|
39 |
158 |
chris |
*/
|
40 |
|
|
|
41 |
|
|
#ifndef _QSM_H_
|
42 |
|
|
#define _QSM_H_
|
43 |
|
|
|
44 |
|
|
/* SAM-- shift and mask */
|
45 |
|
|
#undef SAM
|
46 |
|
|
#define SAM(a,b,c) ((a << b) & c)
|
47 |
|
|
|
48 |
|
|
|
49 |
|
|
/* QSM_CRB (QSM Control Register Block) base address of the QSM
|
50 |
|
|
control registers */
|
51 |
|
|
#if SIM_MM == 0
|
52 |
|
|
#define QSM_CRB 0x7ffc00
|
53 |
|
|
#else
|
54 |
|
|
#undef SIM_MM
|
55 |
|
|
#define SIM_MM 1
|
56 |
|
|
#define QSM_CRB 0xfffc00
|
57 |
|
|
#endif
|
58 |
|
|
|
59 |
|
|
|
60 |
|
|
#define QSMCR (volatile unsigned short int * const)(0x00 + QSM_CRB)
|
61 |
|
|
/* QSM Configuration Register */
|
62 |
|
|
#define STOP 0x8000 /* Stop Enable */
|
63 |
|
|
#define FRZ 0x6000 /* Freeze Control */
|
64 |
|
|
#define SUPV 0x0080 /* Supervisor/Unrestricted */
|
65 |
|
|
#define IARB 0x000f /* Inerrupt Arbitration */
|
66 |
|
|
|
67 |
|
|
|
68 |
|
|
#define QTEST (volatile unsigned short int * const)(0x02 + QSM_CRB)
|
69 |
|
|
/* QSM Test Register */
|
70 |
|
|
/* Used only for factor testing */
|
71 |
|
|
|
72 |
|
|
|
73 |
|
|
#define QILR (volatile unsigned char * const)(0x04 + QSM_CRB)
|
74 |
|
|
/* QSM Interrupt Level Register */
|
75 |
|
|
#define ILQSPI 0x38 /* Interrupt Level for QSPI */
|
76 |
|
|
#define ILSCI 0x07 /* Interrupt Level for SCI */
|
77 |
|
|
|
78 |
|
|
|
79 |
|
|
#define QIVR (volatile unsigned char * const)(0x05 + QSM_CRB)
|
80 |
|
|
/* QSM Interrupt Vector Register */
|
81 |
|
|
#define INTV 0xff /* Interrupt Vector Number */
|
82 |
|
|
|
83 |
|
|
|
84 |
|
|
#define SCCR0 (volatile unsigned short int * const)(0x08 + QSM_CRB)
|
85 |
|
|
/* SCI Control Register 0 */
|
86 |
|
|
#define SCBR 0x1fff /* SCI Baud Rate */
|
87 |
|
|
|
88 |
|
|
|
89 |
|
|
#define SCCR1 (volatile unsigned short int * const)(0x0a + QSM_CRB)
|
90 |
|
|
/* SCI Control Register 1 */
|
91 |
|
|
#define LOOPS 0x4000 /* Loop Mode */
|
92 |
|
|
#define WOMS 0x2000 /* Wired-OR Mode for SCI Pins */
|
93 |
|
|
#define ILT 0x1000 /* Idle-Line Detect Type */
|
94 |
|
|
#define PT 0x0800 /* Parity Type */
|
95 |
|
|
#define PE 0x0400 /* Parity Enable */
|
96 |
|
|
#define M 0x0200 /* Mode Select */
|
97 |
|
|
#define WAKE 0x0100 /* Wakeup by Address Mark */
|
98 |
|
|
#define TIE 0x0080 /* Transmit Complete Interrupt Enable */
|
99 |
|
|
#define TCIE 0x0040 /* Transmit Complete Interrupt Enable */
|
100 |
|
|
#define RIE 0x0020 /* Receiver Interrupt Enable */
|
101 |
|
|
#define ILIE 0x0010 /* Idle-Line Interrupt Enable */
|
102 |
|
|
#define TE 0x0008 /* Transmitter Enable */
|
103 |
|
|
#define RE 0x0004 /* Receiver Enable */
|
104 |
|
|
#define RWU 0x0002 /* Receiver Wakeup */
|
105 |
|
|
#define SBK 0x0001 /* Send Break */
|
106 |
|
|
|
107 |
|
|
|
108 |
|
|
#define SCSR (volatile unsigned short int * const)(0x0c + QSM_CRB)
|
109 |
|
|
/* SCI Status Register */
|
110 |
|
|
#define TDRE 0x0100 /* Transmit Data Register Empty */
|
111 |
|
|
#define TC 0x0080 /* Transmit Complete */
|
112 |
|
|
#define RDRF 0x0040 /* Receive Data Register Full */
|
113 |
|
|
#define RAF 0x0020 /* Receiver Active */
|
114 |
|
|
#define IDLE 0x0010 /* Idle-Line Detected */
|
115 |
|
|
#define OR 0x0008 /* Overrun Error */
|
116 |
|
|
#define NF 0x0004 /* Noise Error Flag */
|
117 |
|
|
#define FE 0x0002 /* Framing Error */
|
118 |
|
|
#define PF 0x0001 /* Parity Error */
|
119 |
|
|
|
120 |
|
|
|
121 |
|
|
#define SCDR (volatile unsigned short int * const)(0x0e + QSM_CRB)
|
122 |
|
|
/* SCI Data Register */
|
123 |
|
|
|
124 |
|
|
|
125 |
|
|
#define PORTQS (volatile unsigned char * const)(0x15 + QSM_CRB)
|
126 |
|
|
/* Port QS Data Register */
|
127 |
|
|
|
128 |
|
|
#define PQSPAR (volatile unsigned char * const)(0x16 + QSM_CRB)
|
129 |
|
|
/* PORT QS Pin Assignment Rgister */
|
130 |
|
|
/* Any bit cleared (zero) defines the corresponding pin to be an I/O
|
131 |
|
|
pin. Any bit set defines the corresponding pin to be a QSPI
|
132 |
|
|
signal. */
|
133 |
|
|
/* note: PQS2 is a digital I/O pin unless the SPI is enabled in which
|
134 |
|
|
case it becomes the SPI serial clock SCK. */
|
135 |
|
|
/* note: PQS7 is a digital I/O pin unless the SCI transmitter is
|
136 |
|
|
enabled in which case it becomes the SCI serial output TxD. */
|
137 |
|
|
#define QSMFun 0x0
|
138 |
|
|
#define QSMDis 0x1
|
139 |
|
|
/*
|
140 |
|
|
* PQSPAR Field | QSM Function | Discrete I/O pin
|
141 |
|
|
*------------------+--------------+------------------ */
|
142 |
|
|
#define PQSPA0 0 /* MISO | PQS0 */
|
143 |
|
|
#define PQSPA1 1 /* MOSI | PQS1 */
|
144 |
|
|
#define PQSPA2 2 /* SCK | PQS2 (see note)*/
|
145 |
|
|
#define PQSPA3 3 /* PCSO/!SS | PQS3 */
|
146 |
|
|
#define PQSPA4 4 /* PCS1 | PQS4 */
|
147 |
|
|
#define PQSPA5 5 /* PCS2 | PQS5 */
|
148 |
|
|
#define PQSPA6 6 /* PCS3 | PQS6 */
|
149 |
|
|
#define PQSPA7 7 /* TxD | PQS7 (see note)*/
|
150 |
|
|
|
151 |
|
|
|
152 |
|
|
#define DDRQS (volatile unsigned char * const)(0x17 + QSM_CRB)
|
153 |
|
|
/* PORT QS Data Direction Register */
|
154 |
|
|
/* Clearing a bit makes the corresponding pin an input; setting a bit
|
155 |
|
|
makes the pin an output. */
|
156 |
|
|
|
157 |
|
|
|
158 |
|
|
#define SPCR0 (volatile unsigned short int * const)(0x18 + QSM_CRB)
|
159 |
|
|
/* QSPI Control Register 0 */
|
160 |
|
|
#define MSTR 0x8000 /* Master/Slave Mode Select */
|
161 |
|
|
#define WOMQ 0x4000 /* Wired-OR Mode for QSPI Pins */
|
162 |
|
|
#define BITS 0x3c00 /* Bits Per Transfer */
|
163 |
|
|
#define CPOL 0x0200 /* Clock Polarity */
|
164 |
|
|
#define CPHA 0x0100 /* Clock Phase */
|
165 |
|
|
#define SPBR 0x00ff /* Serial Clock Baud Rate */
|
166 |
|
|
|
167 |
|
|
|
168 |
|
|
#define SPCR1 (volatile unsigned short int * const)(0x1a + QSM_CRB)
|
169 |
|
|
/* QSPI Control Register 1 */
|
170 |
|
|
#define SPE 0x8000 /* QSPI Enable */
|
171 |
|
|
#define DSCKL 0x7f00 /* Delay before SCK */
|
172 |
|
|
#define DTL 0x00ff /* Length of Delay after Transfer */
|
173 |
|
|
|
174 |
|
|
|
175 |
|
|
#define SPCR2 (volatile unsigned short int * const)(0x1c + QSM_CRB)
|
176 |
|
|
/* QSPI Control Register 2 */
|
177 |
|
|
#define SPIFIE 0x8000 /* SPI Finished Interrupt Enable */
|
178 |
|
|
#define WREN 0x4000 /* Wrap Enable */
|
179 |
|
|
#define WRTO 0x2000 /* Wrap To */
|
180 |
|
|
#define ENDQP 0x0f00 /* Ending Queue Pointer */
|
181 |
|
|
#define NEWQP 0x000f /* New Queue Pointer Value */
|
182 |
|
|
|
183 |
|
|
|
184 |
|
|
#define SPCR3 (volatile unsigned char * const)(0x1e + QSM_CRB)
|
185 |
|
|
/* QSPI Control Register 3 */
|
186 |
|
|
#define LOOPQ 0x0400 /* QSPI Loop Mode */
|
187 |
|
|
#define HMIE 0x0200 /* HALTA and MODF Interrupt Enable */
|
188 |
|
|
#define HALT 0x0100 /* Halt */
|
189 |
|
|
|
190 |
|
|
|
191 |
|
|
#define SPSR (volatile unsigned char * const)(0x1f + QSM_CRB)
|
192 |
|
|
/* QSPI Status Register */
|
193 |
|
|
#define SPIF 0x0080 /* QSPI Finished Flag */
|
194 |
|
|
#define MODF 0x0040 /* Mode Fault Flag */
|
195 |
|
|
#define HALTA 0x0020 /* Halt Acknowlwdge Flag */
|
196 |
|
|
#define CPTQP x0000f /* Completed Queue Pointer */
|
197 |
|
|
|
198 |
|
|
#define QSPIRR (volatile unsigned char * const)(0x100 + QSM_CRB)
|
199 |
|
|
/* QSPI Receive Data RAM */
|
200 |
|
|
#define QSPITR (volatile unsigned char * const)(0x120 + QSM_CRB)
|
201 |
|
|
/* QSPI Transmit Data RAM */
|
202 |
|
|
#define QSPIcR (volatile unsigned char * const)(0x140 + QSM_CRB)
|
203 |
|
|
/* QSPI Command RAM */
|
204 |
|
|
|
205 |
|
|
#endif /* _QSM_H_ */
|