summaryrefslogtreecommitdiff
path: root/nfclib/trf79x0_hw_example.h
blob: c73e8823a773fe1310ed50cc7a1f1e3ed9c53df1 (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
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
//*****************************************************************************
//
// trf79x0_hw_example.h - Hardware Pin configuration for TRF79x0 ATB on
// Tiva C Series Snowflake Class silicon. Tailored for DK-tm4c129x, but will
// work for any board with a Snowflake chip with RF Headers.
//
// Copyright (c) 2014 Texas Instruments Incorporated.  All rights reserved.
// Software License Agreement
// 
// Texas Instruments (TI) is supplying this software for use solely and
// exclusively on TI's microcontroller products. The software is owned by
// TI and/or its suppliers, and is protected under applicable copyright
// laws. You may not combine this software with "viral" open-source
// software in order to form a larger program.
// 
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
// DAMAGES, FOR ANY REASON WHATSOEVER.
// 
// This is part of revision 2.1.0.12573 of the Tiva Firmware Development Package.
//
//*****************************************************************************

#ifndef __TRF79X0_HW_H__
#define __TRF79X0_HW_H__

//*****************************************************************************
//
// Enable the TRF79x0 that will be used with the TM4C129X board
// Enabled = 1, Disabled = 0
//
//*****************************************************************************
#define RF_DAUGHTER_TRF7960         0
#define RF_DAUGHTER_TRF7970         1

//*****************************************************************************
//
// Check for correct definition of RF_DAUGTHER_TRF79X0
//
//*****************************************************************************
#if (RF_DAUGHTER_TRF7960 && RF_DAUGHTER_TRF7970)
#error "Only one TRF79X0 can be defined at the same time."
#elif (!(RF_DAUGHTER_TRF7960 || RF_DAUGHTER_TRF7970))
#error "Define the TRF79X0 to be used, none currently defined."
#endif

//*****************************************************************************
//
// Pin definitions for the DK-TM4C129X development board connections to the
// BoosterPack board.
//
//*****************************************************************************

//*****************************************************************************
//
//! \addtogroup nfc_hw NFC Hardware Definitions
//! @{
//! This section covers the definitions that control which hardware is used to
//! communicate with the TRF79x0 EM module.  These defines configure which SSI
//! peripheral is used as well as which pins are assigned to the other
//! connections to the TRF79x0 EM module.  The \b TRF79X0_SSI_* defines are
//! used to specify the SSI peripheral that is used by the application.  The
//! remaining defines specify the pins used by the NFC APIs.  The TRF79x0
//! EM module requires the following signal connections: CLK, RX, TX, CS, ASKOK,
//! EN, EN2, IRQ, MOD.  To configure these signals, three defines must be set
//! for each. For example, for the CS signal, the \ref TRF79X0_CS_BASE,
//! \ref TRF79X0_CS_PERIPH and \ref TRF79X0_CS_PIN defines must be set.
//!
//! \b Example:  CS pin is on GPIO port E pin 1.
//! \verbatim
//!
//! #define TRF79X0_CS_BASE         GPIO_PORTA_BASE
//! #define TRF79X0_CS_PERIPH       SYSCTL_PERIPH_GPIOA
//! #define TRF79X0_CS_PIN          GPIO_PIN_4
//! \endverbatim
//!
//*****************************************************************************

//*****************************************************************************
//
//! The clock rate of the SSI clock specified in Hz.
//!
//! \b Example: 2-MHz SSI data clock.
//!
//! <tt>\#define SSI_CLK_RATE        2000000</tt>
//!
//*****************************************************************************
#define SSI_CLK_RATE            2000000
#define SSI_CLKS_PER_MS         (SSI_CLK_RATE / 1000)
#define STATUS_READS_PER_MS     (SSI_CLKS_PER_MS / 16)
#define SSI_NO_DATA              0

//*****************************************************************************
//
//! Specifies the SSI peripheral for the SSI port that is connected to the
//! TRF79x0 EM board.  The value should be set to SYSCTL_PERIPH_SSIn, where n is
//! the number of the SSI port being used.
//!
//! \b Example: Uses SSI0 peripheral
//!
//! <tt>\#define TRF79X0_SSI_PERIPH      SYSCTL_PERIPH_SSI0</tt>
//!
//*****************************************************************************
#define TRF79X0_SSI_PERIPH      SYSCTL_PERIPH_SSI0

//*****************************************************************************
//
//! Specifies the SSI @a base address for the SSI port that is connected to the
//! TRF79x0 EM board.  The value should be set to SYSCTL_PERIPH_SSIn, where n is
//! the number of the SSI port being used.
//!
//! \b Example: Uses SSI0 peripheral
//!
//! <tt>\#define TRF79X0_SSI_BASE        SSI0_BASE</tt>
//!
//*****************************************************************************
#define TRF79X0_SSI_BASE        SSI0_BASE

//*****************************************************************************
//
// GPIO pin deffinitions for TRF79x0 SSI signals
//
//*****************************************************************************

//
//! Specifies the @a base address of the GPIO port that is connected to the SSI
//! Clock signal on the TRF79x0 EM board.
//!
//! \b Example: The SSI peripheral CLK signal is on GPIO port A.
//!
//! <tt>\#define TRF79X0_CLK_BASE        GPIO_PORTA_BASE</tt>
//
#define TRF79X0_CLK_BASE        GPIO_PORTA_BASE

//
//! Specifies the @a peripheral for the GPIO port that is connected to the SSI
//! Clock signal on the TRF79x0 EM board.
//!
//! \b Example: The SSI peripheral CLK signal is on GPIO port A.
//!
//! <tt>\#define TRF79X0_CLK_PERIPH      SYSCTL_PERIPH_GPIOA</tt>
//
#define TRF79X0_CLK_PERIPH      SYSCTL_PERIPH_GPIOA

//
//! Specifies the GPIO pin that is connected to the SSI
//! Clock signal on the TRF79x0 EM board.
//!
//! \b Example: The SSI peripheral CLK signal is on GPIO pin 2.
//!
//! <tt>\#define TRF79X0_CLK_PIN         GPIO_PIN_2</tt>
//
#define TRF79X0_CLK_PIN         GPIO_PIN_2

//
//! Specifies the GPIO pin that is connected to
//! the SSI Clock signal on the TRF79x0 EM board.
//!
//! \b Example: The SSI Clock signal is on GPIO port A pin 2.
//!
//! <tt>\#define TRF79X0_CLK_CONFIG      GPIO_PA2_SSI0CLK</tt>
//
#define TRF79X0_CLK_CONFIG      GPIO_PA2_SSI0CLK

//
//! Specifies the @a base address of the GPIO port that is connected to the SSI
//! TX signal on the TRF79x0 EM board.
//!
//! \b Example: The SSI peripheral TX signal is on GPIO port A.
//!
//! <tt>\#define TRF79X0_TX_BASE         GPIO_PORTA_BASE</tt>
//
#define TRF79X0_TX_BASE         GPIO_PORTA_BASE

//
//! Specifies the @a peripheral for the GPIO port that is connected to the SSI
//! TX signal on the TRF79x0 EM board.
//!
//! \b Example: The SSI peripheral TX signal is on GPIO port A.
//!
//! <tt>\#define TRF79X0_TX_PERIPH       SYSCTL_PERIPH_GPIOA</tt>
//
#define TRF79X0_TX_PERIPH       SYSCTL_PERIPH_GPIOA

//
//! Specifies the GPIO pin that is connected to the SSI
//! TX signal on the TRF79x0 EM board.
//!
//! \b Example: The SSI peripheral TX signal is on GPIO pin 4.
//!
//! <tt>\#define TRF79X0_TX_PIN          GPIO_PIN_4</tt>
//
#define TRF79X0_TX_PIN          GPIO_PIN_4

//
//! Specifies the GPIO pin that is connected to
//! the SSITX (DAT0) signal on the TRF79x0 EM board.
//!
//! \b Example: The SSI 1 TX signal is on GPIO port A pin 4.
//!
//! <tt>\#define TRF79X0_TX_CONFIG       GPIO_PA4_SSI0XDAT0</tt>
//
#define TRF79X0_TX_CONFIG       GPIO_PA4_SSI0XDAT0

//
//! Specifies the @a base address of the GPIO port that is connected to the SSI
//! RX signal on the TRF79x0 EM board.
//!
//! \b Example: The SSI peripheral RX signal is on GPIO port A.
//!
//! <tt>\#define TRF79X0_RX_BASE         GPIO_PORTA_BASE</tt>
//
#define TRF79X0_RX_BASE         GPIO_PORTA_BASE

//
//! Specifies the @a peripheral for the GPIO port that is connected to the SSI
//! RX signal on the TRF79x0 EM board.
//!
//! \b Example: The SSI peripheral RX signal is on GPIO port A.
//!
//! <tt>\#define TRF79X0_RX_PERIPH       SYSCTL_PERIPH_GPIOA</tt>
//
#define TRF79X0_RX_PERIPH       SYSCTL_PERIPH_GPIOA

//
//! Specifies the GPIO pin that is connected to the SSI
//! RX signal on the TRF79x0 EM board.
//!
//! \b Example: The SSI peripheral RX signal is on GPIO pin 5.
//!
//! <tt>\#define TRF79X0_RX_PIN          GPIO_PIN_5</tt>
//
#define TRF79X0_RX_PIN          GPIO_PIN_5

//
//! Specifies the GPIO pin that is connected to
//! the SSIRX (DAT1) signal on the TRF79x0 EM board.
//!
//! \b Example: The SSI 1 RX signal is on GPIO port A pin 5.
//!
//! <tt>\#define TRF79X0_RX_CONFIG       GPIO_PA5_SSI0XDAT1</tt>
//
#define TRF79X0_RX_CONFIG       GPIO_PA5_SSI0XDAT1

//*****************************************************************************
//
// Hardware connection definitions for the TRF79x0 board.
//
//*****************************************************************************

//
//! Specifies the @a base address of the GPIO port that is connected to the SSI
//! CS signal on the TRF79x0 EM board.
//!
//! \b Example: The SSI CS signal is on GPIO port A.
//!
//! <tt>\#define TRF79X0_CS_BASE         GPIO_PORTA_BASE</tt>
//
#define TRF79X0_CS_BASE         GPIO_PORTA_BASE

//
//! Specifies the @a peripheral for the GPIO port that is connected to the SSI
//! CS signal on the TRF79x0 EM board.
//!
//! \b Example: The SSI CS signal is on GPIO port A.
//!
//! <tt>\#define TRF79X0_CS_PERIPH       SYSCTL_PERIPH_GPIOA</tt>
//
#define TRF79X0_CS_PERIPH       SYSCTL_PERIPH_GPIOA

//
//! Specifies the GPIO pin that is connected to the SSI
//! CS signal on the TRF79x0 EM board.
//!
//! \b Example: The SSI peripheral CS signal is on GPIO pin 4.
//!
//! <tt>\#define TRF79X0_CS_PIN          GPIO_PIN_4</tt>
//
#define TRF79X0_CS_PIN          GPIO_PIN_3

//
//! Specifies the @a base address of the GPIO port that is connected to the EN
//! signal on the TRF79x0 EM board.
//!
//! \b Example: The EN signal is on GPIO port D.
//!
//! <tt>\#define TRF79X0_EN_BASE         GPIO_PORTD_BASE</tt>
//
#define TRF79X0_EN_BASE         GPIO_PORTD_BASE

//
//! Specifies the @a peripheral for the GPIO port that is connected to the EN
//! signal on the TRF79x0 EM board.
//!
//! \b Example: The EN signal is on GPIO port D.
//!
//! <tt>\#define TRF79X0_EN_PERIPH       SYSCTL_PERIPH_GPIOD</tt>
//
#define TRF79X0_EN_PERIPH       SYSCTL_PERIPH_GPIOD

//
//! Specifies the GPIO pin that is connected to the EN pin on the
//! TRF79x0 EM board.
//!
//! \b Example: The EN signal is on GPIO pin 2.
//!
//! <tt>\#define TRF79X0_EN_PIN          GPIO_PIN_2</tt>
//
#define TRF79X0_EN_PIN          GPIO_PIN_2

//
//! Specifies the @a base address of the GPIO port that is connected to the EN2
//! signal on the TRF79x0 EM board.
//!
//! \b Example: The EN2 signal is on GPIO port D.
//!
//! <tt>\#define TRF79X0_EN2_BASE        GPIO_PORTD_BASE</tt>
//
#define TRF79X0_EN2_BASE        GPIO_PORTD_BASE

//
//! Specifies the @a peripheral for the GPIO port that is connected to the EN2
//! signal on the TRF79x0 EM board.
//!
//! \b Example: The EN2 signal is on GPIO port D.
//!
//! <tt>\#define TRF79X0_EN2_PERIPH      SYSCTL_PERIPH_GPIOD</tt>
//
#define TRF79X0_EN2_PERIPH      SYSCTL_PERIPH_GPIOD

//
//! Specifies the GPIO pin that is connected to the EN2 signal on the
//! TRF79x0 EM board.
//!
//! \b Example: The EN2 signal is on GPIO pin 3.
//!
//! <tt>\#define TRF79X0_EN2_PIN         GPIO_PIN_3</tt>
//
#define TRF79X0_EN2_PIN         GPIO_PIN_3

//
//! Specifies the @a base address of the GPIO port that is connected to the
//! ASKOK signal on the TRF79x0 EM board.
//!
//! \b Example: The ASKOK signal is on GPIO port J.
//!
//! <tt>\#define TRF79X0_ASKOK_BASE      GPIO_PORTJ_BASE</tt>
//
#define TRF79X0_ASKOK_BASE      GPIO_PORTJ_BASE

//
//! Specifies the @a peripheral for the GPIO port that is connected to the ASKOK
//! signal on the TRF79x0 EM board.
//!
//! \b Example: The ASKOK signal is on GPIO port J.
//!
//! <tt>\#define TRF79X0_ASKOK_PERIPH    SYSCTL_PERIPH_GPIOJ</tt>
//
#define TRF79X0_ASKOK_PERIPH    SYSCTL_PERIPH_GPIOJ

//
//! Specifies the GPIO pin that is connected to the ASKOK signal on
//! the TRF79x0 EM board.
//!
//! \b Example: The ASKOK signal is on GPIO pin 5.
//!
//! <tt>\#define TRF79X0_ASKOK_PIN       GPIO_PIN_5</tt>
//
#define TRF79X0_ASKOK_PIN       GPIO_PIN_5

//
//! Specifies the @a base address of the GPIO port that is connected to the MOD
//! signal on the TRF79x0 EM board.
//!
//! \b Example: The MOD signal is on GPIO port J.
//!
//! <tt>\#define TRF79X0_MOD_BASE        GPIO_PORTJ_BASE</tt>
//
#define TRF79X0_MOD_BASE        GPIO_PORTJ_BASE

//
//! Specifies the @a peripheral for the GPIO port that is connected to the MOD
//! signal on the TRF79x0 EM board.
//!
//! \b Example: The MOD signal is on GPIO port J.
//!
//! <tt>\#define TRF79X0_MOD_PERIPH      SYSCTL_PERIPH_GPIOJ</tt>
//
#define TRF79X0_MOD_PERIPH      SYSCTL_PERIPH_GPIOJ

//
//! Specifies the GPIO pin that is connected to the MOD signal on the
//! TRF79x0 EM board.
//!
//! \b Example: The MOD signal is on GPIO pin 4.
//!
//! <tt>\#define TRF79X0_MOD_PIN         GPIO_PIN_4</tt>
//
#define TRF79X0_MOD_PIN         GPIO_PIN_4

//
//! Specifies the @a base address of the GPIO port that is connected to the IRQ
//! signal on the TRF79x0 EM board.
//!
//! \b Example: The IRQ signal is on GPIO port J.
//!
//! <tt>\#define TRF79X0_IRQ_BASE        GPIO_PORTJ_BASE</tt>
//
#define TRF79X0_IRQ_BASE        GPIO_PORTJ_BASE

//
//! Specifies the @a peripheral for the GPIO port that is connected to the IRQ
//! signal on the TRF79x0 EM board.
//!
//! \b Example: The IRQ signal is on GPIO port J.
//!
//! <tt>\#define TRF79X0_IRQ_PERIPH      SYSCTL_PERIPH_GPIOJ</tt>
//
#define TRF79X0_IRQ_PERIPH      SYSCTL_PERIPH_GPIOJ

//
//! Specifies the GPIO pin that is connected to the IRQ signal on the
//! TRF79x0 EM board.
//!
//! \b Example: The IRQ signal is on GPIO pin 1.
//!
//! <tt>\#define TRF79X0_IRQ_PIN         GPIO_PIN_1</tt>
//
#define TRF79X0_IRQ_PIN         GPIO_PIN_1

//
//! Specifies GPIO interrupt that is tied to the GPIO port that the IRQ signal
//! is connected to TRF79x0 EM board.
//!
//! \b Example: SSI GPIO interrupt is on GPIO port C.
//!
//! <tt>\#define TRF79X0_IRQ_INT         INT_GPIOC</tt>
//
#define TRF79X0_IRQ_INT         INT_GPIOJ

//
//  Uses Blue LED part of RGB tricolor LED (arbitrary color choice)
//
#define ENABLE_LED_PERIPHERAL SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOQ);
#define SET_LED_DIRECTION GPIOPinTypeGPIOOutput(GPIO_PORTQ_BASE, GPIO_PIN_4 );
#define TURN_ON_LED  GPIOPinWrite(GPIO_PORTQ_BASE, GPIO_PIN_4, GPIO_PIN_4);
#define TURN_OFF_LED GPIOPinWrite(GPIO_PORTQ_BASE, GPIO_PIN_4, 0);

//*****************************************************************************
//
// Optional LED Defines, useful for boards that have tricolor LED's
//
//*****************************************************************************
#define BOARD_HAS_TRICOLOR_LED              1

#define ENABLE_LED_TRICOLOR_RED_PERIPH      SysCtlPeripheralEnable(SYSCTL_PERIPH_GPION);
#define SET_LED_TRICOLOR_RED_DIRECTION      GPIOPinTypeGPIOOutput(GPIO_PORTN_BASE, GPIO_PIN_5 );
#define TURN_ON_LED_TRICOLOR_RED            GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_5, GPIO_PIN_5);
#define TURN_OFF_LED_TRICOLOR_RED           GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_5, 0);

#define ENABLE_LED_TRICOLOR_BLUE_PERIPH     SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOQ);
#define SET_LED_TRICOLOR_BLUE_DIRECTION     GPIOPinTypeGPIOOutput(GPIO_PORTQ_BASE, GPIO_PIN_4 );
#define TURN_ON_LED_TRICOLOR_BLUE           GPIOPinWrite(GPIO_PORTQ_BASE, GPIO_PIN_4, GPIO_PIN_4);
#define TURN_OFF_LED_TRICOLOR_BLUE          GPIOPinWrite(GPIO_PORTQ_BASE, GPIO_PIN_4, 0);

#define ENABLE_LED_TRICOLOR_GREEN_PERIPH    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOQ);
#define SET_LED_TRICOLOR_GREEN_DIRECTION    GPIOPinTypeGPIOOutput(GPIO_PORTQ_BASE, GPIO_PIN_7 );
#define TURN_ON_LED_TRICOLOR_GREEN          GPIOPinWrite(GPIO_PORTQ_BASE, GPIO_PIN_7, GPIO_PIN_7);
#define TURN_OFF_LED_TRICOLOR_GREEN         GPIOPinWrite(GPIO_PORTQ_BASE, GPIO_PIN_7, 0);

//*****************************************************************************
//
// Macro for IRQ signal from TRF79x0 -> Board
// left in this format for cross platform compatibility.
//
//*****************************************************************************
#define IRQ_IS_SET()        GPIOPinRead(TRF79X0_IRQ_BASE, TRF79X0_IRQ_PIN)

//*****************************************************************************
//
// Close the Doxygen group.
//! @}
//
//*****************************************************************************

#endif // __TRF79X0_HW_H__