-
Notifications
You must be signed in to change notification settings - Fork 92
HydraFW SPI guide
#HydraFW Bus SPI (Serial Peripheral Interface)
Connections: four pins (MOSI/MISO/CLOCK/CS) and ground(GND).
Output type: 3.3volt normal, or open drain
(pull up/pull down resistors integrated in MCU or external).
Pull-up resistors: required for open drain output mode (2K – 10K).
Pull-up/down resistors Integrated in MCU: Between 30 to 50K (Typical 40K).
Maximum voltage: 5.5volts (5volt safe).
Output type - open drain/open collector (high=Hi-Z, low=ground),
normal (high=3.3volts, low=ground).
Use open drain/open collector output types with pull-up resistors
for multi-voltage interfacing.
This guide is updated towards firmware release HydraFW v0.5 Beta: HydraFW (HydraBus) v0.5-beta-0-gc0bc1f0 2015-02-11
##Protocol configuration syntax description:
-
show
Show SPI parameters orshow pins
Show pins used in this mode -
device
with parameter1
or2
to choose SPI device (1 or 2) -
pull
with parameterup
ordown
orfloating
to choose internal MCU pull up/down or no pull/external -
mode
with parametermaster
orslave
to choose master or slave SPI mode -
frequency
with frequency value (supportkhz
,mhz
suffix or no suffix)- Frequencies available for SPI1:
320khz
,650khz
,1.31mhz
,2.62mhz
,5.25mhz
,10.5mhz
,21mhz
,42mhz
- Frequencies available for SPI2:
160khz
,320khz
,650khz
,1.31mhz
,2.62mhz
,5.25mhz
,10.5mhz
,21mhz
- Frequencies available for SPI1:
-
polarity
with parameter0
or1
for clock polarity value (also called CPOL/CKP) -
phase
with parameter0
or1
for clock phase value (also called Clock Edge or CKE/CPHA) -
msb-first
orlsb-first
to send/receive respectively MSB first or LSB first. -
exit
to exit SPI mode
Note default value for device 1 or 2:
For device 1 (SPI1):
> spi device 1
Note: SPI parameters have been reset to default values.
Device: SPI1
GPIO resistor: floating
Mode: master
Frequency: 320khz (650khz, 1.31mhz, 2.62mhz, 5.25mhz, 10.50mhz, 21mhz, 42mhz)
Polarity: 0
Phase: 0
Bit order: MSB first
For device 2 (SPI2):
> spi device 2
Note: SPI parameters have been reset to default values.
Device: SPI2
GPIO resistor: floating
Mode: master
Frequency: 160khz (320khz, 650khz, 1.31mhz, 2.62mhz, 5.25mhz, 10.50mhz, 21mhz)
Polarity: 0
Phase: 0
Bit order: MSB first
###Configuration options:
Hardware Informations:
spi1> show pins
CS: PA15
SCK: PB3
MISO: PB4
MOSI: PB5
spi2> show pins
CS: PC1 (SW)
SCK: PB10
MISO: PC2
MOSI: PC3
###Protocol configuration example:
Configuration of SPI1 650KHz(using internal MCU pull down):
> spi device 1
Note: SPI parameters have been reset to default values.
Device: SPI1
GPIO resistor: floating
Mode: master
Frequency: 320khz (650khz, 1.31mhz, 2.62mhz, 5.25mhz, 10.50mhz, 21mhz, 42mhz)
Polarity: 0
Phase: 0
Bit order: MSB first
spi1> pull down frequency 650khz show
Device: SPI1
GPIO resistor: pull-down
Mode: master
Frequency: 650khz (320khz, 1.31mhz, 2.62mhz, 5.25mhz, 10.50mhz, 21mhz, 42mhz)
Polarity: 0
Phase: 0
Bit order: MSB first
##Protocol interaction syntax description:
cs on
or [
Chip select(CS) enable/active (low=state 0/GND).
cs off
or ]
Chip select(CS) disable (high=state +3.3V).
r
or read
Read one byte by sending dummy byte (0xff). (r:1…255 for bulk reads)
w
or write
Followed by values to write byte(s). (w:1…255 for bulk writes)
0
Write this Octal value. Format is prefixed by a 0 (values from 000 to 077)
0b
Write this Binary value. Format is 0b00000000 for a byte, but partial bytes are also fine: 0b1001
0x
Write this Hexadecimal value. Format is 0x01. Partial bytes are fine: 0xA. A-F can be lower-case or capital letters
0-255
Write this decimal value. Any number not preceded by 0x, or 0b is interpreted as a decimal value
Write support optional repeat :
(eg.: 10:1…255 for repeated write of same value 10 in this example)
space
Value delimiter.
Use a space to separate numbers/commands.
Any combination is fine, delimiter is required between each number/command, example: [ 0x1 0xff 0 10 0b11 077 ]
&
Delay 1uS. (&:1…1000000 for multiple delays)
%
Delay 1mS. (%:1…1000000 for multiple delays)
~
Write a random byte. (~:10 repeats the same random byte 10 times)
###Protocol interaction example usage SPI1 write/read:
spi1> [ 0xFF r ] [ 0 r ] [ 1 r ] [ 0x80 r ] [ 0x55 r 0xAA r 0xFF r 0x11:4 r:4 ]
/CS ENABLED
WRITE: 0xFF
READ: 0x00
/CS DISABLED
/CS ENABLED
WRITE: 0x00
READ: 0x00
/CS DISABLED
/CS ENABLED
WRITE: 0x01
READ: 0x00
/CS DISABLED
/CS ENABLED
WRITE: 0x80
READ: 0x00
/CS DISABLED
/CS ENABLED
WRITE: 0x55
READ: 0x00
WRITE: 0xAA
READ: 0x00
WRITE: 0xFF
READ: 0x00
WRITE: 0x11 0x11 0x11 0x11
READ: 0x00 0x00 0x00 0x00
/CS DISABLED
##Additional informations about SPI
For more details on SPI protocol see: http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus
- CHANGELOG
- Console commands
- Binary mode guide
-
NFC/HydraNFC v1 guide
- Read UID of an ISO/IEC_14443 Tag
- Read UID and data of a MIFARE Ultralight Tag
- Read UID of an ISO/IEC 15693 Tag
- Emul ISO14443a Tag
- Emul MIFARE Ultralight Tag
- Emul Mifare Classic Tag
- Unique NFC sniffer design
- Launch NFC sniffer from console
- Sniffer ISO14443A wireshark pcap
- Autonomous/stand-alone sniffer mode
- Sniffer ISO14443A real-time infinite trace mode
- HydraFW-HydraNFC-v1.x-TRF7970A-Tutorial