BusPirate / Bus_Pirate

Community driven firmware and hardware for Bus Pirate version 3 and 4
625 stars 131 forks source link

BusPirate script (BASIC) cannot switch/configure mode #151

Open PSLLSP opened 4 years ago

PSLLSP commented 4 years ago

There is no command in BusPirate BASIC to configure BUS mode, like a command to configure BusPirate to SPI mode with well defined parameters. This configuration has to be done by hand and it could be a source of an error. And it is boring manual task, there should be a way to script it... ;-)

And there is no command in BusPirate BASIC to verify that device is configured in correct mode.

An example, this simple BASIC program reads 2 bytes from SPI but because there is no way to configure SPI mode from BASIC, that has to be done manually before switching to script mode:

SPI(BASIC)>list

10  PSU 1
20  PULLUP 1
25  REM DELAY 5
30  START 
40  LET A= RECEIVE 
50  LET B= RECEIVE 
60  LET W=A*256+B
70  STOP 
80  PSU 0
90  PRINT A;",";B;",";W

Similar reading in manual mode WP%:5[rr]w:

SPI>WP%:5[rr]w
POWER SUPPLIES ON
Clutch engaged!!!
Pull-up resistors ON
DELAY 5ms
/CS ENABLED
READ: 0x06 
READ: 0x29 
/CS DISABLED
Clutch disengaged!!!
SPI>

My BusPirate device:

HiZ>i
Bus Pirate v3.b clone w/different PIC
Firmware v6.3-beta1 r2151  Bootloader v4.4
DEVID:0x044F REVID:0x3003 (24FJ64GA004 A3)
http://dangerousprototypes.com