-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathhw_ssi.h
544 lines (499 loc) · 25.4 KB
/
hw_ssi.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
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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
/******************************************************************************
* Filename: hw_ssi_h
* Revised: 2017-01-31 09:37:48 +0100 (Tue, 31 Jan 2017)
* Revision: 48345
*
* Copyright (c) 2015 - 2017, Texas Instruments Incorporated
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1) Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2) Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3) Neither the name of the ORGANIZATION nor the names of its contributors may
* be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
******************************************************************************/
#ifndef __HW_SSI_H__
#define __HW_SSI_H__
//*****************************************************************************
//
// This section defines the register offsets of
// SSI component
//
//*****************************************************************************
// Control 0
#define SSI_O_CR0 0x00000000
// Control 1
#define SSI_O_CR1 0x00000004
// Data
#define SSI_O_DR 0x00000008
// Status
#define SSI_O_SR 0x0000000C
// Clock Prescale
#define SSI_O_CPSR 0x00000010
// Interrupt Mask Set and Clear
#define SSI_O_IMSC 0x00000014
// Raw Interrupt Status
#define SSI_O_RIS 0x00000018
// Masked Interrupt Status
#define SSI_O_MIS 0x0000001C
// Interrupt Clear
#define SSI_O_ICR 0x00000020
// DMA Control
#define SSI_O_DMACR 0x00000024
//*****************************************************************************
//
// Register: SSI_O_CR0
//
//*****************************************************************************
// Field: [15:8] SCR
//
// Serial clock rate:
// This is used to generate the transmit and receive bit rate of the SSI. The
// bit rate is
// (SSI's clock frequency)/((SCR+1)*CPSR.CPSDVSR).
// SCR is a value from 0-255.
#define SSI_CR0_SCR_W 8
#define SSI_CR0_SCR_M 0x0000FF00
#define SSI_CR0_SCR_S 8
// Field: [7] SPH
//
// CLKOUT phase (Motorola SPI frame format only)
// This bit selects the clock edge that captures data and enables it to change
// state. It
// has the most impact on the first bit transmitted by either permitting or not
// permitting a clock transition before the first data capture edge.
// ENUMs:
// 2ND_CLK_EDGE Data is captured on the second clock edge
// transition.
// 1ST_CLK_EDGE Data is captured on the first clock edge
// transition.
#define SSI_CR0_SPH 0x00000080
#define SSI_CR0_SPH_BITN 7
#define SSI_CR0_SPH_M 0x00000080
#define SSI_CR0_SPH_S 7
#define SSI_CR0_SPH_2ND_CLK_EDGE 0x00000080
#define SSI_CR0_SPH_1ST_CLK_EDGE 0x00000000
// Field: [6] SPO
//
// CLKOUT polarity (Motorola SPI frame format only)
// ENUMs:
// HIGH SSI produces a steady state HIGH value on the
// CLKOUT pin when data is not being transferred.
// LOW SSI produces a steady state LOW value on the
// CLKOUT pin when data is
// not being transferred.
#define SSI_CR0_SPO 0x00000040
#define SSI_CR0_SPO_BITN 6
#define SSI_CR0_SPO_M 0x00000040
#define SSI_CR0_SPO_S 6
#define SSI_CR0_SPO_HIGH 0x00000040
#define SSI_CR0_SPO_LOW 0x00000000
// Field: [5:4] FRF
//
// Frame format.
// The supported frame formats are Motorola SPI, TI synchronous serial and
// National Microwire.
// Value 0'b11 is reserved and shall not be used.
// ENUMs:
// NATIONAL_MICROWIRE National Microwire frame format
// TI_SYNC_SERIAL TI synchronous serial frame format
// MOTOROLA_SPI Motorola SPI frame format
#define SSI_CR0_FRF_W 2
#define SSI_CR0_FRF_M 0x00000030
#define SSI_CR0_FRF_S 4
#define SSI_CR0_FRF_NATIONAL_MICROWIRE 0x00000020
#define SSI_CR0_FRF_TI_SYNC_SERIAL 0x00000010
#define SSI_CR0_FRF_MOTOROLA_SPI 0x00000000
// Field: [3:0] DSS
//
// Data Size Select.
// Values 0b0000, 0b0001, 0b0010 are reserved and shall not be used.
// ENUMs:
// 16_BIT 16-bit data
// 15_BIT 15-bit data
// 14_BIT 14-bit data
// 13_BIT 13-bit data
// 12_BIT 12-bit data
// 11_BIT 11-bit data
// 10_BIT 10-bit data
// 9_BIT 9-bit data
// 8_BIT 8-bit data
// 7_BIT 7-bit data
// 6_BIT 6-bit data
// 5_BIT 5-bit data
// 4_BIT 4-bit data
#define SSI_CR0_DSS_W 4
#define SSI_CR0_DSS_M 0x0000000F
#define SSI_CR0_DSS_S 0
#define SSI_CR0_DSS_16_BIT 0x0000000F
#define SSI_CR0_DSS_15_BIT 0x0000000E
#define SSI_CR0_DSS_14_BIT 0x0000000D
#define SSI_CR0_DSS_13_BIT 0x0000000C
#define SSI_CR0_DSS_12_BIT 0x0000000B
#define SSI_CR0_DSS_11_BIT 0x0000000A
#define SSI_CR0_DSS_10_BIT 0x00000009
#define SSI_CR0_DSS_9_BIT 0x00000008
#define SSI_CR0_DSS_8_BIT 0x00000007
#define SSI_CR0_DSS_7_BIT 0x00000006
#define SSI_CR0_DSS_6_BIT 0x00000005
#define SSI_CR0_DSS_5_BIT 0x00000004
#define SSI_CR0_DSS_4_BIT 0x00000003
//*****************************************************************************
//
// Register: SSI_O_CR1
//
//*****************************************************************************
// Field: [3] SOD
//
// Slave-mode output disabled
// This bit is relevant only in the slave mode, MS=1. In multiple-slave
// systems, it is possible for an SSI master to broadcast a message to all
// slaves in the system while ensuring that only one slave drives data onto its
// serial output line. In such systems the RXD lines from multiple slaves could
// be tied together. To operate in such systems, this bitfield can be set if
// the SSI slave is not supposed to drive the TXD line:
//
// 0: SSI can drive the TXD output in slave mode.
// 1: SSI cannot drive the TXD output in slave mode.
#define SSI_CR1_SOD 0x00000008
#define SSI_CR1_SOD_BITN 3
#define SSI_CR1_SOD_M 0x00000008
#define SSI_CR1_SOD_S 3
// Field: [2] MS
//
// Master or slave mode select. This bit can be modified only when SSI is
// disabled, SSE=0.
// ENUMs:
// SLAVE Device configured as slave
// MASTER Device configured as master
#define SSI_CR1_MS 0x00000004
#define SSI_CR1_MS_BITN 2
#define SSI_CR1_MS_M 0x00000004
#define SSI_CR1_MS_S 2
#define SSI_CR1_MS_SLAVE 0x00000004
#define SSI_CR1_MS_MASTER 0x00000000
// Field: [1] SSE
//
// Synchronous serial interface enable.
// ENUMs:
// SSI_ENABLED Operation enabled
// SSI_DISABLED Operation disabled
#define SSI_CR1_SSE 0x00000002
#define SSI_CR1_SSE_BITN 1
#define SSI_CR1_SSE_M 0x00000002
#define SSI_CR1_SSE_S 1
#define SSI_CR1_SSE_SSI_ENABLED 0x00000002
#define SSI_CR1_SSE_SSI_DISABLED 0x00000000
// Field: [0] LBM
//
// Loop back mode:
//
// 0: Normal serial port operation enabled.
// 1: Output of transmit serial shifter is connected to input of receive serial
// shifter internally.
#define SSI_CR1_LBM 0x00000001
#define SSI_CR1_LBM_BITN 0
#define SSI_CR1_LBM_M 0x00000001
#define SSI_CR1_LBM_S 0
//*****************************************************************************
//
// Register: SSI_O_DR
//
//*****************************************************************************
// Field: [15:0] DATA
//
// Transmit/receive data
// The values read from this field or written to this field must be
// right-justified when SSI is programmed for a data size that is less than 16
// bits (CR0.DSS != 0b1111). Unused bits at the top are ignored by transmit
// logic. The receive logic automatically right-justifies.
#define SSI_DR_DATA_W 16
#define SSI_DR_DATA_M 0x0000FFFF
#define SSI_DR_DATA_S 0
//*****************************************************************************
//
// Register: SSI_O_SR
//
//*****************************************************************************
// Field: [4] BSY
//
// Serial interface busy:
//
// 0: SSI is idle
// 1: SSI is currently transmitting and/or receiving a frame or the transmit
// FIFO is not empty.
#define SSI_SR_BSY 0x00000010
#define SSI_SR_BSY_BITN 4
#define SSI_SR_BSY_M 0x00000010
#define SSI_SR_BSY_S 4
// Field: [3] RFF
//
// Receive FIFO full:
//
// 0: Receive FIFO is not full.
// 1: Receive FIFO is full.
#define SSI_SR_RFF 0x00000008
#define SSI_SR_RFF_BITN 3
#define SSI_SR_RFF_M 0x00000008
#define SSI_SR_RFF_S 3
// Field: [2] RNE
//
// Receive FIFO not empty
//
// 0: Receive FIFO is empty.
// 1: Receive FIFO is not empty.
#define SSI_SR_RNE 0x00000004
#define SSI_SR_RNE_BITN 2
#define SSI_SR_RNE_M 0x00000004
#define SSI_SR_RNE_S 2
// Field: [1] TNF
//
// Transmit FIFO not full:
//
// 0: Transmit FIFO is full.
// 1: Transmit FIFO is not full.
#define SSI_SR_TNF 0x00000002
#define SSI_SR_TNF_BITN 1
#define SSI_SR_TNF_M 0x00000002
#define SSI_SR_TNF_S 1
// Field: [0] TFE
//
// Transmit FIFO empty:
//
// 0: Transmit FIFO is not empty.
// 1: Transmit FIFO is empty.
#define SSI_SR_TFE 0x00000001
#define SSI_SR_TFE_BITN 0
#define SSI_SR_TFE_M 0x00000001
#define SSI_SR_TFE_S 0
//*****************************************************************************
//
// Register: SSI_O_CPSR
//
//*****************************************************************************
// Field: [7:0] CPSDVSR
//
// Clock prescale divisor:
// This field specifies the division factor by which the input system clock to
// SSI must be internally divided before further use.
// The value programmed into this field must be an even non-zero number
// (2-254). The least significant bit of the programmed number is hard-coded to
// zero. If an odd number is written to this register, data read back from
// this register has the least significant bit as zero.
#define SSI_CPSR_CPSDVSR_W 8
#define SSI_CPSR_CPSDVSR_M 0x000000FF
#define SSI_CPSR_CPSDVSR_S 0
//*****************************************************************************
//
// Register: SSI_O_IMSC
//
//*****************************************************************************
// Field: [3] TXIM
//
// Transmit FIFO interrupt mask:
// A read returns the current mask for transmit FIFO interrupt. On a write of
// 1, the mask for transmit FIFO interrupt is set which means the interrupt
// state will be reflected in MIS.TXMIS. A write of 0 clears the mask which
// means MIS.TXMIS will not reflect the interrupt.
#define SSI_IMSC_TXIM 0x00000008
#define SSI_IMSC_TXIM_BITN 3
#define SSI_IMSC_TXIM_M 0x00000008
#define SSI_IMSC_TXIM_S 3
// Field: [2] RXIM
//
// Receive FIFO interrupt mask:
// A read returns the current mask for receive FIFO interrupt. On a write of 1,
// the mask for receive FIFO interrupt is set which means the interrupt state
// will be reflected in MIS.RXMIS. A write of 0 clears the mask which means
// MIS.RXMIS will not reflect the interrupt.
#define SSI_IMSC_RXIM 0x00000004
#define SSI_IMSC_RXIM_BITN 2
#define SSI_IMSC_RXIM_M 0x00000004
#define SSI_IMSC_RXIM_S 2
// Field: [1] RTIM
//
// Receive timeout interrupt mask:
// A read returns the current mask for receive timeout interrupt. On a write of
// 1, the mask for receive timeout interrupt is set which means the interrupt
// state will be reflected in MIS.RTMIS. A write of 0 clears the mask which
// means MIS.RTMIS will not reflect the interrupt.
#define SSI_IMSC_RTIM 0x00000002
#define SSI_IMSC_RTIM_BITN 1
#define SSI_IMSC_RTIM_M 0x00000002
#define SSI_IMSC_RTIM_S 1
// Field: [0] RORIM
//
// Receive overrun interrupt mask:
// A read returns the current mask for receive overrun interrupt. On a write of
// 1, the mask for receive overrun interrupt is set which means the interrupt
// state will be reflected in MIS.RORMIS. A write of 0 clears the mask which
// means MIS.RORMIS will not reflect the interrupt.
#define SSI_IMSC_RORIM 0x00000001
#define SSI_IMSC_RORIM_BITN 0
#define SSI_IMSC_RORIM_M 0x00000001
#define SSI_IMSC_RORIM_S 0
//*****************************************************************************
//
// Register: SSI_O_RIS
//
//*****************************************************************************
// Field: [3] TXRIS
//
// Raw transmit FIFO interrupt status:
// The transmit interrupt is asserted when there are four or fewer valid
// entries in the transmit FIFO. The transmit interrupt is not qualified with
// the SSI enable signal. Therefore one of the following ways can be used:
// - data can be written to the transmit FIFO prior to enabling the SSI and
// the
// interrupts.
// - SSI and interrupts can be enabled so that data can be written to the
// transmit FIFO by an interrupt service routine.
#define SSI_RIS_TXRIS 0x00000008
#define SSI_RIS_TXRIS_BITN 3
#define SSI_RIS_TXRIS_M 0x00000008
#define SSI_RIS_TXRIS_S 3
// Field: [2] RXRIS
//
// Raw interrupt state of receive FIFO interrupt:
// The receive interrupt is asserted when there are four or more valid entries
// in the receive FIFO.
#define SSI_RIS_RXRIS 0x00000004
#define SSI_RIS_RXRIS_BITN 2
#define SSI_RIS_RXRIS_M 0x00000004
#define SSI_RIS_RXRIS_S 2
// Field: [1] RTRIS
//
// Raw interrupt state of receive timeout interrupt:
// The receive timeout interrupt is asserted when the receive FIFO is not empty
// and SSI has remained idle for a fixed 32 bit period. This mechanism can be
// used to notify the user that data is still present in the receive FIFO and
// requires servicing. This interrupt is deasserted if the receive FIFO becomes
// empty by subsequent reads, or if new data is received on RXD.
// It can also be cleared by writing to ICR.RTIC.
#define SSI_RIS_RTRIS 0x00000002
#define SSI_RIS_RTRIS_BITN 1
#define SSI_RIS_RTRIS_M 0x00000002
#define SSI_RIS_RTRIS_S 1
// Field: [0] RORRIS
//
// Raw interrupt state of receive overrun interrupt:
// The receive overrun interrupt is asserted when the FIFO is already full and
// an additional data frame is received, causing an overrun of the FIFO. Data
// is over-written in the
// receive shift register, but not the FIFO so the FIFO contents stay valid.
// It can also be cleared by writing to ICR.RORIC.
#define SSI_RIS_RORRIS 0x00000001
#define SSI_RIS_RORRIS_BITN 0
#define SSI_RIS_RORRIS_M 0x00000001
#define SSI_RIS_RORRIS_S 0
//*****************************************************************************
//
// Register: SSI_O_MIS
//
//*****************************************************************************
// Field: [3] TXMIS
//
// Masked interrupt state of transmit FIFO interrupt:
// This field returns the masked interrupt state of transmit FIFO interrupt
// which is the AND product of raw interrupt state RIS.TXRIS and the mask
// setting IMSC.TXIM.
#define SSI_MIS_TXMIS 0x00000008
#define SSI_MIS_TXMIS_BITN 3
#define SSI_MIS_TXMIS_M 0x00000008
#define SSI_MIS_TXMIS_S 3
// Field: [2] RXMIS
//
// Masked interrupt state of receive FIFO interrupt:
// This field returns the masked interrupt state of receive FIFO interrupt
// which is the AND product of raw interrupt state RIS.RXRIS and the mask
// setting IMSC.RXIM.
#define SSI_MIS_RXMIS 0x00000004
#define SSI_MIS_RXMIS_BITN 2
#define SSI_MIS_RXMIS_M 0x00000004
#define SSI_MIS_RXMIS_S 2
// Field: [1] RTMIS
//
// Masked interrupt state of receive timeout interrupt:
// This field returns the masked interrupt state of receive timeout interrupt
// which is the AND product of raw interrupt state RIS.RTRIS and the mask
// setting IMSC.RTIM.
#define SSI_MIS_RTMIS 0x00000002
#define SSI_MIS_RTMIS_BITN 1
#define SSI_MIS_RTMIS_M 0x00000002
#define SSI_MIS_RTMIS_S 1
// Field: [0] RORMIS
//
// Masked interrupt state of receive overrun interrupt:
// This field returns the masked interrupt state of receive overrun interrupt
// which is the AND product of raw interrupt state RIS.RORRIS and the mask
// setting IMSC.RORIM.
#define SSI_MIS_RORMIS 0x00000001
#define SSI_MIS_RORMIS_BITN 0
#define SSI_MIS_RORMIS_M 0x00000001
#define SSI_MIS_RORMIS_S 0
//*****************************************************************************
//
// Register: SSI_O_ICR
//
//*****************************************************************************
// Field: [1] RTIC
//
// Clear the receive timeout interrupt:
// Writing 1 to this field clears the timeout interrupt (RIS.RTRIS). Writing 0
// has no effect.
#define SSI_ICR_RTIC 0x00000002
#define SSI_ICR_RTIC_BITN 1
#define SSI_ICR_RTIC_M 0x00000002
#define SSI_ICR_RTIC_S 1
// Field: [0] RORIC
//
// Clear the receive overrun interrupt:
// Writing 1 to this field clears the overrun error interrupt (RIS.RORRIS).
// Writing 0 has no effect.
#define SSI_ICR_RORIC 0x00000001
#define SSI_ICR_RORIC_BITN 0
#define SSI_ICR_RORIC_M 0x00000001
#define SSI_ICR_RORIC_S 0
//*****************************************************************************
//
// Register: SSI_O_DMACR
//
//*****************************************************************************
// Field: [1] TXDMAE
//
// Transmit DMA enable. If this bit is set to 1, DMA for the transmit FIFO is
// enabled.
#define SSI_DMACR_TXDMAE 0x00000002
#define SSI_DMACR_TXDMAE_BITN 1
#define SSI_DMACR_TXDMAE_M 0x00000002
#define SSI_DMACR_TXDMAE_S 1
// Field: [0] RXDMAE
//
// Receive DMA enable. If this bit is set to 1, DMA for the receive FIFO is
// enabled.
#define SSI_DMACR_RXDMAE 0x00000001
#define SSI_DMACR_RXDMAE_BITN 0
#define SSI_DMACR_RXDMAE_M 0x00000001
#define SSI_DMACR_RXDMAE_S 0
#endif // __SSI__