Skip to content
Baldanos edited this page Sep 29, 2018 · 51 revisions

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.9 Beta

Protocol configuration syntax description:

  • show Show SPI parameters or show pins Show pins used in this mode

  • device with parameter 1 or 2 to choose SPI device (1 or 2)

  • pull with parameter up or down or floating to choose internal MCU pull up/down or no pull/external

  • mode with parameter master or slave to choose master or slave SPI mode

  • frequency with floating frequency value (support k (for khz), m (for 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
  • polarity with parameter 0 or 1 for clock polarity value (also called CPOL/CKP)

  • phase with parameter 0 or 1 for clock phase value (also called Clock Edge or CKE/CPHA)

  • msb-first or lsb-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 650k 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:

trigger configures the trigger mode

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)

hd Read one byte by sending dummy byte (0xff). (hd:1…255 for bulk reads). Displays a hexdump of the result (See Hexdump guide)

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 an ASCII-encoded string

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

How to Flash/Use HydraFW

How to Build/Flash/Use HydraFW

Developer Getting-Started with HydraBus and STM32CubeIDE

Hardware

Firmware (hydrafw) performances

Firmware (hydrafw) Application guides

Firmware (hydrafw) guides

How to Help

Clone this wiki locally