forked from DangerousPrototypes/Bus_Pirate
-
Notifications
You must be signed in to change notification settings - Fork 130
/
Copy pathconfiguration.h
514 lines (437 loc) · 15.9 KB
/
configuration.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
/*
* This file is part of the Bus Pirate project
* (http://code.google.com/p/the-bus-pirate/).
*
* Written and maintained by the Bus Pirate project.
*
* To the extent possible under law, the project has
* waived all copyright and related or neighboring rights to Bus Pirate. This
* work is published from United States.
*
* For details see: http://creativecommons.org/publicdomain/zero/1.0/.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#ifndef BP_CONFIGURATION_H
#define BP_CONFIGURATION_H
/* Hardware identification. */
#if defined(__PIC24FJ256GB106__)
/**
* The firmware is built for a Bus Pirate v4.
*/
#define BUSPIRATEV4
#elif defined(__PIC24FJ64GA002__)
/**
* The firmware is built for a Bus Pirate v3.
*/
#define BUSPIRATEV3
#endif /* __PIC24FJ256GB106__ || __PIC24FJ64GA002__ */
/* Feature inclusion/exclusion definitions. */
/**
* #define BP_ENABLE_1WIRE_SUPPORT
*
* Enable 1-Wire protocol support in the built firmware.
*
* @note BPv3 default firmware status: OPTIONAL
* @note BPv4 default firmware status: INCLUDED
*
* From https://en.wikipedia.org/wiki/1-Wire :
*
* 1-Wire is a device communications bus system designed by Dallas
* Semiconductor Corp. that provides low-speed data, signaling, and power over
* a single conductor. 1-Wire is similar in concept to I2C, but with lower
* data rates and longer range. It is typically used to communicate with small
* inexpensive devices such as digital thermometers and weather instruments. A
* network of 1-Wire devices with an associated master device is called a
* MicroLAN. One distinctive feature of the bus is the possibility of using
* only two wires: data and ground. To accomplish this, 1-Wire devices include
* an 800 pF capacitor to store charge, and to power the device during periods
* when the data line is active.
*/
/**
* #define BP_ENABLE_BASIC_SUPPORT
*
* Enable a cut-down BASIC interpreter to automate tasks in a more structured
* way than macros alone.
*
* @note BPv3 default firmware status: OPTIONAL
* @note BPv4 default firmware status: INCLUDED
*/
/**
* #define BP_ENABLE_DIO_SUPPORT
*
* Enable Direct I/O control over the hardware pins using the binary
* communication protocol.
*
* @note BPv3 default firmware status: OPTIONAL
* @note BPv4 default firmware status: INCLUDED
*/
/**
* #define BP_ENABLE_HD44780_SUPPORT
*
* Enable controlling a HD44780 LCD controller connected via an expansion board.
*
* @note BPv3 default firmware status: OPTIONAL
* @note BPv4 default firmware status: INCLUDED
*
* This module allows interaction with a HD44780-based expansion board like this
* one: http://dangerousprototypes.com/docs/Bus_Pirate_LCD_adapter_v2 or this
* one: http://dangerousprototypes.com/docs/Bus_Pirate_v4_LCD_adapter .
*/
/**
* #define BP_ENABLE_I2C_SUPPORT
*
* Enable I2C protocol support in the built firmware.
*
* @note BPv3 default firmware status: INCLUDED
* @note BPv3 default firmware status: INCLUDED
*
* From https://en.wikipedia.org/wiki/I%B2C :
*
* I2C (Inter-Integrated Circuit), pronounced I-squared-C, is a multi-master,
* multi-slave, single-ended, serial computer bus invented by Philips
* Semiconductor (now NXP Semiconductors). It is typically used for attaching
* lower-speed peripheral ICs to processors and microcontrollers in
* short-distance, intra-board communication. Alternatively I2C is spelled I2C
* (pronounced I-two-C) or IIC (pronounced I-I-C). Since October 10, 2006, no
* licensing fees are required to implement the I2C protocol. However, fees are
* still required to obtain I2C slave addresses allocated by NXP. Several
* competitors, such as Siemens AG (later Infineon Technologies AG, now Intel
* mobile communications), NEC, Texas Instruments, STMicroelectronics (formerly
* SGS-Thomson), Motorola (later Freescale, now merged with NXP), Nordic
* Semiconductor and Intersil, have introduced compatible I2C products to the
* market since the mid-1990s. SMBus, defined by Intel in 1995, is a subset of
* I2C that defines the protocol use more strictly. One purpose of SMBus is to
* promote robustness and interoperability. Accordingly, modern I2C systems
* incorporate some policies and rules from SMBus, sometimes supporting both
* I2C and SMBus, requiring only minimal reconfiguration either by commanding
* or output pin use.
*/
/**
* #define BP_ENABLE_PIC_SUPPORT
*
* Enable support for programming PIC microcontrollers by using the PIC
* programming software described at
* http://dangerousprototypes.com/docs/Pirate_PIC_Programmer
*
* @note BPv3 default firmware status: OPTIONAL
* @note BPv4 default firmware status: INCLUDED
*
* Current support is for PIC10, PIC12, PIC14, PIC16, and PIC18 MCU families.
*/
/**
* #define BP_ENABLE_PC_AT_KEYBOARD_SUPPORT
*
* Enable support for reading scancodes from a PC-AT keyboard bus.
*
* @note BPv3 default firmware status: OPTIONAL
* @note BPv4 default firmware status: INCLUDED
*/
/**
* #define BP_ENABLE_RAW_2WIRE_SUPPORT
*
* Enable support for controlling two I/O pins in an arbitrary way to implement
* custom binary protocols.
*
* @note BPv3 default firmware status: OPTIONAL
* @note BPv4 default firmware status: INCLUDED
*/
/**
* #define BP_ENABLE_RAW_3WIRE_SUPPORT
*
* Enable support for controlling three I/O pins in an arbitrary way to
* implement custom binary protocols.
*
* @note BPv3 default firmware status: OPTIONAL
* @note BPv4 default firmware status: INCLUDED
*/
/**
* #define BP_ENABLE_SPI_SUPPORT
*
* Enable SPI protocol support in the built firmware.
*
* @note BPv3 default firmware status: INCLUDED
* @note BPv3 default firmware status: INCLUDED
*
* From https://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus :
*
* The Serial Peripheral Interface (SPI) bus is a synchronous serial
* communication interface specification used for short distance communication,
* primarily in embedded systems. The interface was developed by Motorola and
* has become a de facto standard. Typical applications include Secure Digital
* cards and liquid crystal displays. SPI devices communicate in full duplex
* mode using a master-slave architecture with a single master. The master
* device originates the frame for reading and writing. Multiple slave devices
* are supported through selection with individual slave select (SS) lines.
* Sometimes SPI is called a four-wire serial bus, contrasting with three-,
* two-, and one-wire serial buses. The SPI may be accurately described as a
* synchronous serial interface, but it is different to the Synchronous Serial
* Interface (SSI) protocol, which is also a four-wire synchronous serial
* communication protocol, but employs differential signaling and provides
* only a single simplex communication channel.
*/
/**
* #define BP_ENABLE_UART_SUPPORT
*
* Enable UART I/O support in the built firmware.
*
* @note BPv3 default firmware status: INCLUDED
* @note BPv4 default firmware status: INCLUDED
*
* From https://en.wikipedia.org/wiki/UART :
*
* A universal asynchronous receiver/transmitter, abbreviated UART, is a
* computer hardware device that translates data between characters (usually
* bytes) in a computer and an asynchronous serial communication format that
* encapsulates those characters between start bits and stop bits. UARTs are
* commonly used in conjunction with communication standards such as TIA
* (formerly EIA) RS-232, RS-422 or RS-485. The universal designation
* indicates that the data format and transmission speeds are configurable.
* The electric signaling levels and methods (such as differential signaling
* etc.) are handled by a driver circuit external to the UART. A UART is
* usually an individual (or part of an) integrated circuit (IC) used for
* serial communications over a computer or peripheral device serial port.
* UARTs are now commonly included in microcontrollers. A dual UART, or DUART,
* combines two UARTs into a single chip. An octal UART or OCTART combines
* eight UARTs into one package, such as the Exar XR16L788 or the NXP SCC2698.
* A related device, the Universal Synchronous/Asynchronous
* Receiver/Transmitter (USART) also supports synchronous operation.
*/
/**
* #define BP_ENABLE_SUMP_SUPPORT
*
* Enables support for SUMP-compatible logic analyzer programs, using the
* Bus Pirate as a signal acquisition device.
*
* @note BPv3 default firmware status: INCLUDED
* @note BPv4 default firmware status: INCLUDED
*
* More information can be obtained at
* http://www.sump.org/projects/analyzer/protocol/
*/
/**
* #define BP_ENABLE_JTAG_SUPPORT
*
* Enables support for JTAG control programs, using the Bus Pirate as a hardware
* debug module on the device under test.
*
* @note BPv3 default firmware status: INCLUDED
* @note BPv4 default firmware status: INCLUDED
*
* OpenOCD support is not yet available on v4 boards, however plans are
* underway to get this working.
*/
/**
* #define BP_ENABLE_SMPS_SUPPORT
*
* Enables support for driving a switched mode power supply via binary I/O
* commands.
*
* @note BPv3 default firmware status: DISABLED
* @note BPv4 default firmware status: INCLUDED
*
* The schematic for such an interface board can be found at
* http://dangerousprototypes.com/docs/Bus_Pirate_SMPS - although it is not
* clear whether this design is compatible with the current code. In the
* DangerousPrototypes' repository, support for the SMPS board was limited to
* Bus Pirate v4 boards, whilst the information on that page is dated from 2010.
*
* From https://en.wikipedia.org/wiki/Switched-mode_power_supply :
*
* A switched-mode power supply (switching-mode power supply, switch-mode power
* supply, switched power supply, SMPS, or switcher) is an electronic power
* supply that incorporates a switching regulator to convert electrical power
* efficiently. Like other power supplies, an SMPS transfers power from a DC or
* AC source (often mains power), to DC loads, such as a personal computer,
* while converting voltage and current characteristics. Unlike a linear power
* supply, the pass transistor of a switching-mode supply continually switches
* between low-dissipation, full-on and full-off states, and spends very little
* time in the high dissipation transitions, which minimizes wasted energy.
* Ideally, a switched-mode power supply dissipates no power. Voltage regulation
* is achieved by varying the ratio of on-to-off time. In contrast, a linear
* power supply regulates the output voltage by continually dissipating power in
* the pass transistor. This higher power conversion efficiency is an important
* advantage of a switched-mode power supply. Switched-mode power supplies may
* also be substantially smaller and lighter than a linear supply due to the
* smaller transformer size and weight.
*
* @todo Clarify whether this code can still be used.
*/
#ifndef BP_CUSTOM_FEATURE_SET
#ifdef BUSPIRATEV4
#define BP_ENABLE_1WIRE_SUPPORT
#define BP_ENABLE_BASIC_SUPPORT
#define BP_ENABLE_DIO_SUPPORT
#define BP_ENABLE_HD44780_SUPPORT
#define BP_ENABLE_I2C_SUPPORT
#define BP_ENABLE_JTAG_SUPPORT
#define BP_ENABLE_PIC_SUPPORT
#define BP_ENABLE_PC_AT_KEYBOARD_SUPPORT
#define BP_ENABLE_RAW_2WIRE_SUPPORT
#define BP_ENABLE_RAW_3WIRE_SUPPORT
#define BP_ENABLE_SMPS_SUPPORT
#define BP_ENABLE_SPI_SUPPORT
#define BP_ENABLE_SUMP_SUPPORT
#define BP_ENABLE_UART_SUPPORT
#endif /* BUSPIRATEV4 */
#ifdef BUSPIRATEV3
#undef BP_ENABLE_1WIRE_SUPPORT
#undef BP_ENABLE_BASIC_SUPPORT
#undef BP_ENABLE_DIO_SUPPORT
#undef BP_ENABLE_HD44780_SUPPORT
#define BP_ENABLE_I2C_SUPPORT
#define BP_ENABLE_JTAG_SUPPORT
#undef BP_ENABLE_PIC_SUPPORT
#undef BP_ENABLE_PC_AT_KEYBOARD_SUPPORT
#undef BP_ENABLE_RAW_2WIRE_SUPPORT
#undef BP_ENABLE_RAW_3WIRE_SUPPORT
#undef BP_ENABLE_SMPS_SUPPORT
#define BP_ENABLE_SPI_SUPPORT
#define BP_ENABLE_SUMP_SUPPORT
#define BP_ENABLE_UART_SUPPORT
#endif /* BUSPIRATEV3 */
#endif /* !BP_CUSTOM_FEATURE_SET */
#ifdef BP_CUSTOM_FEATURE_SET
#define BP_ENABLE_1WIRE_SUPPORT
#define BP_ENABLE_BASIC_SUPPORT
#define BP_ENABLE_DIO_SUPPORT
#define BP_ENABLE_HD44780_SUPPORT
#define BP_ENABLE_I2C_SUPPORT
#define BP_ENABLE_JTAG_SUPPORT
#define BP_ENABLE_PC_AT_KEYBOARD_SUPPORT
#define BP_ENABLE_PIC_SUPPORT
#define BP_ENABLE_RAW_2WIRE_SUPPORT
#define BP_ENABLE_RAW_3WIRE_SUPPORT
#define BP_ENABLE_SMPS_SUPPORT
#define BP_ENABLE_SPI_SUPPORT
#define BP_ENABLE_SUMP_SUPPORT
#define BP_ENABLE_UART_SUPPORT
#endif /* BP_CUSTOM_FEATURE_SET */
/* 1-Wire module configuration definitions. */
#ifdef BP_ENABLE_1WIRE_SUPPORT
/**
* Maximum number of devices whose addresses will be stored as MACROs.
*/
#define BP_1WIRE_DEVICE_DEV_ROSTER_SLOTS 10
/**
* Lookup family ID and print that information when searching devices.
*/
#define BP_1WIRE_LOOKUP_FAMILY_ID
#ifdef BP_1WIRE_LOOKUP_FAMILY_ID
/**
* Print a description of the found device along with the device model when
* searching devices.
*/
#define BP_1WIRE_PRINT_FAMILY_DESCRIPTION
#endif /* BP_1WIRE_LOOKUP_FAMILY_ID */
#endif /* BP_ENABLE_1WIRE_SUPPORT */
/* I2C module configuration definitions. */
#ifdef BP_ENABLE_I2C_SUPPORT
#ifdef BUSPIRATEV4
/**
* Enable usage of the on-board hardware I2C bus.
*
* This is mandatory on Bus Pirate v4 hardware, optional on v3.
*/
#define BP_I2C_USE_HW_BUS
#endif /* BUSPIRATEV4 */
#endif /* BP_ENABLE_I2C_SUPPORT */
/* BASIC interpreter module configuration definitions. */
#ifdef BP_ENABLE_BASIC_SUPPORT
#ifdef BUSPIRATEV4
/**
* Enable storing and retrieving saved BASIC scripts on the on-board 8 kilobytes
* EEPROM that is available on Bus Pirate v4 boards.
*
* Disabled by default as the code involved has not been tested yet.
*/
/*
#define BP_BASIC_I2C_FILESYSTEM
*/
#endif /* BUSPIRATEV4 */
#endif /* BP_ENABLE_BASIC_SUPPORT */
/* SPI module configuration definitions. */
#ifdef BP_ENABLE_SPI_SUPPORT
/**
* Enable special AVR-specific commands for bulk flash reading and other
* purposes.
*/
#define AVR_EXTENDED_COMMANDS
#endif /* BP_ENABLE_SPI_SUPPORT */
/* JTAG module configuration definitions. */
#ifdef BP_ENABLE_JTAG_SUPPORT
#ifdef BUSPIRATEV3
/**
* Allow OpenOCD to interact with the Bus Pirate board for JTAG operations.
*
* This is not yet supported on v4 boards.
*/
#define BP_JTAG_OPENOCD_SUPPORT
#endif /* BUSPIRATEV3 */
#ifdef BUSPIRATEV4
/* SMPS module configuration definitions. */
#ifdef BP_ENABLE_SMPS_SUPPORT
#ifdef BUSPIRATEV3
#error "SMPS support is not available on Bus Pirate v3 boards."
#endif /* BUSPIRATEV3 */
#endif /* BP_ENABLE_SMPS_SUPPORT */
/**
* Enable support for XSVF JTAG commands.
*
* This is not enabled on v3 boards due to taking up too much memory.
*
* More information at https://en.wikipedia.org/wiki/Serial_Vector_Format
*/
#define BP_JTAG_XSVF_SUPPORT
#endif /* BUSPIRATEV4 */
#endif /* BP_ENABLE_JTAG_SUPPORT */
/* Module-agnostic configuration definitions. */
/**
* Enable the 'h' command to show command history.
*/
#define BP_ENABLE_COMMAND_HISTORY
#ifdef BP_ENABLE_COMMAND_HISTORY
/**
* How many past entries the command history should keep track of.
*/
#ifdef BUSPIRATEV3
#define BP_COMMAND_HISTORY_LENGTH 7
#else
#define BP_COMMAND_HISTORY_LENGTH 15
#endif /* BUSPIRATEV3 */
#endif /* BP_ENABLE_COMMAND_HISTORY */
/**
* How many user-defined macros can be set.
*/
#ifdef BUSPIRATEV3
#define BP_USER_MACROS_COUNT 3
#else
#define BP_USER_MACROS_COUNT 5
#endif /* BUSPIRATEV3 */
/**
* Maximum length, in bytes of a user-defined macro.
*/
#ifdef BUSPIRATEV3
#define BP_USER_MACRO_MAX_LENGTH 24
#else
#define BP_USER_MACRO_MAX_LENGTH 32
#endif /* BUSPIRATEV3 */
/**
* How big the serial command buffer can be, in bytes.
*
* @warning This must be set to a power of two, ie. 256, 128, 64, 32, etc.
*/
#ifdef BUSPIRATEV3
#define BP_COMMAND_BUFFER_SIZE 128
#else
#define BP_COMMAND_BUFFER_SIZE 256
#endif /* BUSPIRATEV3 */
/**
* How big the serial terminal buffer can be, in bytes.
*
* @todo Make sure that no hard-coded buffer sizes are present.
*/
#define BP_TERMINAL_BUFFER_SIZE 4096
#endif /* !BP_CONFIGURATION_H */