Documentation
¶
Index ¶
- Constants
- Variables
- type CR
- type Config
- type DMACR
- type Driver
- func (d *Driver) Baudrate() int
- func (d *Driver) Config() Config
- func (d *Driver) Disable()
- func (d *Driver) DisableRx()
- func (d *Driver) DisableTx()
- func (d *Driver) Enable()
- func (d *Driver) EnableRx()
- func (d *Driver) EnableTx()
- func (d *Driver) ISR()
- func (d *Driver) Periph() *Periph
- func (d *Driver) Read(s []byte) (n int, err error)
- func (d *Driver) ReadByte() (b byte, err error)
- func (d *Driver) SetBaudrate(baudrate int) (actual int)
- func (d *Driver) SetConfig(cfg Config)
- func (d *Driver) SetReadTimeout(timeout time.Duration)
- func (d *Driver) SetWriteTimeout(timeout time.Duration)
- func (d *Driver) Setup(cfg Config, baudrate int) (actualBaud int)
- func (d *Driver) UsePin(pin iomux.Pin, sig Signal) bool
- func (d *Driver) WaitTxDone()
- func (d *Driver) Write(s []byte) (n int, err error)
- func (d *Driver) WriteByte(b byte) error
- func (d *Driver) WriteString(s string) (n int, err error)
- type Error
- type FR
- type INT
- type LCR_H
- type Periph
- type Signal
Constants ¶
const ( FE uint32 = 0x01 << 0 //+ Framing error. PE uint32 = 0x01 << 1 //+ Parity error. BE uint32 = 0x01 << 2 //+ Break error. OE uint32 = 0x01 << 3 //+ Overrun error. )
RSR bits
const ( TXIFLSEL = 0x07 << 0 //+ Transmit interrupt FIFO level select. RXIFLSEL = 0x07 << 3 //+ Receive interrupt FIFO level select )
IFLS bits
const ( TXIFLSELn = 0 RXIFLSELn = 3 )
IFLS bit offsets
const ( Break = Config(BRK) // send break ParityEven = Config(PEN | EPS) // even parity ParityOdd = Config(PEN) // odd parity Stop2b = Config(STP2) // two stop bits instead of one WordLen = Config(3 << WLENn) // Data word length: Word5b = Config(0 << WLENn) // - 5 bit Word6b = Config(1 << WLENn) // - 6 bit Word7b = Config(2 << WLENn) // - 7 bit Word8b = Config(3 << WLENn) // - 8 bit )
const WLENn = 5
LCR_H bit ofsets
Variables ¶
var ErrTimeout = errors.New("uart: timeout")
Functions ¶
This section is empty.
Types ¶
type CR ¶
type CR uint32
const ( UARTEN CR = 0x01 << 0 //+ UART enable. SIREN CR = 0x01 << 1 //+ SIR enable. SIRLP CR = 0x01 << 2 //+ SIR low-power IrDA mode. LBE CR = 0x01 << 7 //+ Loopback enable. TXE CR = 0x01 << 8 //+ Transmit enable. RXE CR = 0x01 << 9 //+ Receive enable. DTRn CR = 0x01 << 10 //+ Data transmit ready. RTSn CR = 0x01 << 11 //+ Request to send. OUT1 CR = 0x01 << 12 //+ Complement of the UART Out1 modem status output. OUT2 CR = 0x01 << 13 //+ Complement of the UART Out2 modem status output RTSEN CR = 0x01 << 14 //+ RTS hardware flow control enable. CTSEN CR = 0x01 << 15 //+ CTS hardware flow control enable. )
CR bits
type Driver ¶
type Driver struct {
// contains filtered or unexported fields
}
Driver provides a driver for the UART peripheral.
The driver Rx and Tx parts are independent in means that they can be used conncurently by two goroutines. However, a given transmission direction can only be used by one goroutine at the same time.
func (*Driver) DisableTx ¶
func (d *Driver) DisableTx()
DisableTx waits for the end of transfer (see Flush) and disables the Tx part of the UART.
func (*Driver) ISR ¶
func (d *Driver) ISR()
ISR is the interrupt handler that handles the data transfers scheduled by the read and write methods.
func (*Driver) SetBaudrate ¶
SetBaudrate sets the UART baudrate.
func (*Driver) SetReadTimeout ¶
SetReadTimeout sets the read timeout used by Read* functions.
func (*Driver) SetWriteTimeout ¶
SetWriteTimeout sets the write timeout used by Write* functions.
func (*Driver) Setup ¶
Setup resets the underlying UART peripheral and configures it according to the driver needs. Next it calls the SetConfig and SetBaudrate methods with the provided arguments. You still need to call EnableTx/EnabeRx.
func (*Driver) UsePin ¶
UsePin is a helper function that can be used to configure IO pins as required by the UART peripheral. Only certain pins can be used (see datasheet). UsePin returns true on succes or false if it isn't possible to use a pin as a sig. See also Periph.Pins.
func (*Driver) WaitTxDone ¶
func (d *Driver) WaitTxDone()
WaitTxDone waits until the last byte (including all the stop bits) from the last write operation has been sent.
type FR ¶
type FR uint32
const ( CTSn FR = 0x01 << 0 //+ Clear to send. DSRn FR = 0x01 << 1 //+ Data set ready. DCDn FR = 0x01 << 2 //+ Data carrier detect. BUSY FR = 0x01 << 3 //+ UART busy. RXFE FR = 0x01 << 4 //+ Receive FIFO empty. TXFF FR = 0x01 << 5 //+ Transmit FIFO full. RXFF FR = 0x01 << 6 //+ Receive FIFO full. TXFE FR = 0x01 << 7 //+ Transmit FIFO empty. RI FR = 0x01 << 8 //+ Ring indicator. )
FR bits
type INT ¶
type INT uint32
const ( RIMI INT = 0x01 << 0 //+ nUARTRI modem interrupt. CTSMI INT = 0x01 << 1 //+ nUARTCTS modem interrupt. DCDMI INT = 0x01 << 2 //+ nUARTDCD modem interrupt. DSRMI INT = 0x01 << 3 //+ nUARTDSR modem interrupt. RXI INT = 0x01 << 4 //+ Receive interrupt. TXI INT = 0x01 << 5 //+ Transmit interrupt. RTI INT = 0x01 << 6 //+ Receive timeout interrupt. FEI INT = 0x01 << 7 //+ Framing error interrupt. PEI INT = 0x01 << 8 //+ Parity error interrupt. BEI INT = 0x01 << 9 //+ Break error interrupt. OEI INT = 0x01 << 10 //+ Overrun error interrupt. )
type LCR_H ¶
type LCR_H uint32
const ( BRK LCR_H = 0x01 << 0 //+ Send break. PEN LCR_H = 0x01 << 1 //+ Parity enable. EPS LCR_H = 0x01 << 2 //+ Even parity select. STP2 LCR_H = 0x01 << 3 //+ Two stop bits select. FEN LCR_H = 0x01 << 4 //+ Enable FIFOs. WLEN LCR_H = 0x03 << 5 //+ Word length. SPS LCR_H = 0x01 << 7 //+ Stick parity select. )
LCR_H bits
type Periph ¶
type Periph struct { DR mmio.U32 RSR mmio.U32 FR mmio.R32[FR] ILPR mmio.U32 IBRD mmio.U32 FBRD mmio.U32 LCR_H mmio.R32[LCR_H] CR mmio.R32[CR] IFLS mmio.U32 IMSC mmio.R32[INT] RIS mmio.R32[INT] MIS mmio.R32[INT] ICR mmio.R32[INT] DMACR mmio.R32[DMACR] PERIPHID0 mmio.U32 PERIPHID1 mmio.U32 PERIPHID2 mmio.U32 PERIPHID3 mmio.U32 PCELLID0 mmio.U32 PCELLID1 mmio.U32 PCELLID2 mmio.U32 PCELLID3 mmio.U32 // contains filtered or unexported fields }