Skip to content

Zero not a valid value for f in Port.Connect #69

Description

@nathan-osman

Describe the bug
According to the documentation for spi.Port.Connect(), 0 is a valid value to use for specifying SPI speed:

...Use 0 for f if there is no known maximum value for this device...

However, I instead receive an error when providing 0:

panic: sysfs-spi: invalid speed 0Hz; minimum supported clock is 100Hz; did you forget to multiply by physic.MegaHertz?

To Reproduce
Steps to reproduce the behavior:

  1. Enter program
package main

import (
  "periph.io/x/host/v3"
  "periph.io/x/conn/v3/spi/spireg"
)

func main() {
  host.Init()
  p, err := spireg.Open("0")
  if err != nil {
    panic(err)
  }
  defer p.Close()
  c, err := p.Connect(0, spi.Mode0, 8)
  if err != nil {
    panic(err)
  }
}
  1. Run it.
  2. See error

Expected behavior
No error, and the connection to the SPI device succeeds.

Platform (please complete the following information):

  • OS: Raspbian GNU/Linux 12 with armv7l kernel
  • Board: Raspberry Pi Zero 2W

Additional thoughts
Perhaps if this is not intended to be supported behavior, the documentation should be updated to remove the 0 option.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions