Documentation ¶
Overview ¶
Package uart defines the UART protocol.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Conn ¶
type Conn interface { conn.Conn // Speed changes the bus speed. Speed(baud int) error // Configure changes the communication parameters of the bus. // // There's rarely a reason to use anything else than One stop bit and 8 bits // per character. Configure(stopBit Stop, parity Parity, bits int) error }
Conn defines the interface a concrete UART driver must implement.
It implements conn.Conn.
type ConnCloser ¶
ConnCloser is a connection that can be closed.
type Pins ¶
type Pins interface { // RX returns the receive pin. RX() gpio.PinIn // TX returns the transmit pin. TX() gpio.PinOut // RTS returns the request to send pin. RTS() gpio.PinIO // CTS returns the clear to send pin. CTS() gpio.PinIO }
Pins defines the pins that an UART bus interconnect is using on the host.
It is expected that a implementer of Conn also implement Pins but this is not a requirement.
Example ¶
package main import ( "fmt" "log" "periph.io/x/periph/experimental/conn/uart" "periph.io/x/periph/experimental/conn/uart/uartreg" "periph.io/x/periph/host" ) func main() { // Make sure periph is initialized. if _, err := host.Init(); err != nil { log.Fatal(err) } // Use uartreg UART port registry to find the first available UART port. p, err := uartreg.Open("") if err != nil { log.Fatal(err) } defer p.Close() // Prints out the gpio pin used. if p, ok := p.(uart.Pins); ok { fmt.Printf(" RX : %s", p.RX()) fmt.Printf(" TX : %s", p.TX()) fmt.Printf(" RTS: %s", p.RTS()) fmt.Printf(" CTS: %s", p.CTS()) } }
Output:
Click to show internal directories.
Click to hide internal directories.