uarte

package
v0.1.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 15, 2020 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Overview

Package uarte provides access to the registers of UARTE peripheral. It also provides the driver that implements io.ReadWriter interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Baudrate

type Baudrate uint32
const (
	Baud1200   Baudrate = 0x0004F000 // Actual rate: 1205 baud.
	Baud2400   Baudrate = 0x0009D000 // Actual rate: 2396 baud.
	Baud4800   Baudrate = 0x0013B000 // Actual rate: 4808 baud.
	Baud9600   Baudrate = 0x00275000 // Actual rate: 9598 baud.
	Baud14400  Baudrate = 0x003AF000 // Actual rate: 14401 baud.
	Baud19200  Baudrate = 0x004EA000 // Actual rate: 19208 baud.
	Baud28800  Baudrate = 0x0075C000 // Actual rate: 28777 baud.
	Baud31250  Baudrate = 0x00800000
	Baud38400  Baudrate = 0x009D0000 // Actual rate: 38369 baud.
	Baud56000  Baudrate = 0x00E50000 // Actual rate: 55944 baud.
	Baud57600  Baudrate = 0x00EB0000 // Actual rate: 57554 baud.
	Baud76800  Baudrate = 0x013A9000 // Actual rate: 76923 baud.
	Baud115200 Baudrate = 0x01D60000 // Actual rate: 115108 baud.
	Baud230400 Baudrate = 0x03B00000 // Actual rate: 231884 baud.
	Baud250000 Baudrate = 0x04000000
	Baud460800 Baudrate = 0x07400000 // Actual rate: 457143 baud.
	Baud921600 Baudrate = 0x0F000000 // Actual rate: 941176 baud.
	Baud1M     Baudrate = 0x10000000
)

func Baud

func Baud(baud int) Baudrate

func (Baudrate) Baud

func (br Baudrate) Baud() int

type Config

type Config uint32
const (
	HWFC   Config = 0x01 << 0 // Hardware flow control
	PARITY Config = 0x07 << 1 // Parity
	STOP2  Config = 0x01 << 4 // Two stop bits
)

type Driver

type Driver struct {
	// contains filtered or unexported fields
}

func NewDriver

func NewDriver(p *Periph) *Driver

NewDriver returns a new driver for p.

func (*Driver) Disable

func (d *Driver) Disable()

Disable disables UART peripheral.

func (*Driver) Enable

func (d *Driver) Enable()

Enable enables UART peripheral.

func (*Driver) IRQ

func (d *Driver) IRQ() rtos.IRQ

IRQ returns the interrupt assigned to UART peripheral used by driver.

func (*Driver) ISR

func (d *Driver) ISR()

func (*Driver) Periph

func (d *Driver) Periph() *Periph

func (*Driver) SetBaudrate

func (d *Driver) SetBaudrate(br Baudrate)

SetBaudrate sets Tx and Rx baudrate.

func (*Driver) SetConfig

func (d *Driver) SetConfig(cfg Config)

SetConfig allows to configure UART peripheral to use hardware flow controll, add and check parity bit, and use two stop bits instead default one.

func (*Driver) UsePin

func (d *Driver) UsePin(pin gpio.Pin, s Signal)

UsePin configurs the specified pin to be used as signal s.

func (*Driver) Write

func (d *Driver) Write(s []byte) (n int, err error)

func (*Driver) WriteByte

func (d *Driver) WriteByte(b byte) (err error)

type DriverError

type DriverError uint8
const (
	// ErrBufOverflow is returned if one or more received bytes has been dropped
	// because of the lack of free space in the driver's receive buffer.
	ErrBufOverflow DriverError = iota + 1

	// ErrTimeout is returned if timeout occured. It means that the read/write
	// operation has been interrupted. In case of write you can not determine
	// the exact number of bytes sent to the remote party.
	ErrTimeout
)

func (DriverError) Error

func (e DriverError) Error() string

Error implements error interface.

type ErrorBits

type ErrorBits uint8

ErrorBits is a bitfield that lists detected errors.

const (
	EOVERRUN ErrorBits = 1 << 0
	EPARITY  ErrorBits = 1 << 1
	EFRAMING ErrorBits = 1 << 2
	EBREAK   ErrorBits = 1 << 3

	EALL = EOVERRUN | EPARITY | EFRAMING | EBREAK
)

func (ErrorBits) Error

func (e ErrorBits) Error() string

type Event

type Event uint8
const (
	CTS       Event = 0  // CTS is activated (set low).
	NCTS      Event = 1  // CTS is deactivated (set high).
	RXDRDY    Event = 2  // Data received in RXD.
	ENDRX     Event = 4  // Receive buffer is filled up.
	TXDRDY    Event = 7  // Data sent from TXD.
	ENDTX     Event = 8  // Last TX byte transmitted.
	ERROR     Event = 9  // Error detected.
	RXTO      Event = 17 // Receiver timeout.
	RXSTARTED Event = 19 // UART receiver has started.
	TXSTARTED Event = 20 // UART transmitter has started.
	TXSTOPPED Event = 22 // Transmitter stopped.
)

type Periph

type Periph struct {
	te.Regs
	// contains filtered or unexported fields
}

func UARTE

func UARTE(n int) *Periph

func (*Periph) ClearERRORSRC

func (p *Periph) ClearERRORSRC(e ErrorBits)

ClearERRORSRC clears specfied error flags.

func (*Periph) Event

func (p *Periph) Event(e Event) *te.Event

func (*Periph) LoadBAUDRATE

func (p *Periph) LoadBAUDRATE() Baudrate

LoadBAUDRATE returns configured baudrate.

func (*Periph) LoadCONFIG

func (p *Periph) LoadCONFIG() Config

LoadCONFIG returns configuration. nRF52.

func (*Periph) LoadENABLE

func (p *Periph) LoadENABLE() bool

LoadENABLE reports whether the UART peripheral is enabled.

func (*Periph) LoadERRORSRC

func (p *Periph) LoadERRORSRC() ErrorBits

LoadERRORSRC returns error flags.

func (*Periph) LoadPSEL

func (p *Periph) LoadPSEL(s Signal) (psel gpio.PSEL, en bool)

LoadPSEL returns configuration of signal s.

func (*Periph) LoadRXDAMOUNT

func (p *Periph) LoadRXDAMOUNT() int

LoadRXDAMOUNT returns the Number of bytes transferred in the last transaction

func (*Periph) LoadRXDMAXCNT

func (p *Periph) LoadRXDMAXCNT() int

LoadRXDMAXCNT returns the maximum number of bytes in receive buffer.

func (*Periph) LoadRXDPTR

func (p *Periph) LoadRXDPTR() uintptr

LoadRXDPTR returns the Rx data pointer.

func (*Periph) LoadSHORTS

func (p *Periph) LoadSHORTS() Shorts

func (*Periph) LoadTXDAMOUNT

func (p *Periph) LoadTXDAMOUNT() int

LoadTXDAMOUNT returns the number of bytes transferred in the last transaction

func (*Periph) LoadTXDMAXCNT

func (p *Periph) LoadTXDMAXCNT() int

LoadTXDMAXCNT returns the maximum number of bytes in transmit buffer.

func (*Periph) LoadTXDPTR

func (p *Periph) LoadTXDPTR() uintptr

LoadTXDPTR returns the Tx data pointer.

func (*Periph) StoreBAUDRATE

func (p *Periph) StoreBAUDRATE(br Baudrate)

StoreBAUDRATE stores baudrate.

func (*Periph) StoreCONFIG

func (p *Periph) StoreCONFIG(cfg Config)

StoreCONFIG stores baudrate. nRF52.

func (*Periph) StoreENABLE

func (p *Periph) StoreENABLE(en bool)

StoreENABLE enables or disables UART peripheral.

func (*Periph) StorePSEL

func (p *Periph) StorePSEL(s Signal, psel gpio.PSEL, en bool)

StorePSEL configures signal s.

func (*Periph) StoreRXDMAXCNT

func (p *Periph) StoreRXDMAXCNT(n int)

StoreRXDMAXCNT sets the maximum number of bytes in receive buffer.

func (*Periph) StoreRXDPTR

func (p *Periph) StoreRXDPTR(ptr unsafe.Pointer)

StoreRXDPTR sets the Rx data pointer.

func (*Periph) StoreSHORTS

func (p *Periph) StoreSHORTS(s Shorts)

func (*Periph) StoreTXDMAXCNT

func (p *Periph) StoreTXDMAXCNT(n int)

StoreTXDMAXCNT sets the maximum number of bytes in receive buffer.

func (*Periph) StoreTXDPTR

func (p *Periph) StoreTXDPTR(ptr unsafe.Pointer)

StoreTXDPTR sets the Tx data pointer.

func (*Periph) Task

func (p *Periph) Task(t Task) *te.Task

type Shorts

type Shorts uint32
const (
	ENDRX_STARTRX Shorts = 1 << 5
	ENDRX_STOPRX  Shorts = 1 << 6
)

type Signal

type Signal byte
const (
	RTSn Signal = 0
	TXD  Signal = 1
	CTSn Signal = 2
	RXD  Signal = 3
)

type Task

type Task uint8
const (
	STARTRX Task = 0  // Start UART receiver.
	STOPRX  Task = 1  // Stop UART receiver.
	STARTTX Task = 2  // Start UART transmitter.
	STOPTX  Task = 3  // Stop UART transmitter.
	FLUSHRX Task = 11 // Flush RX FIFO into RX buffer.
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL