mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-14 07:53:40 +00:00
attiny: remove dummy UART
I think it's better not to provide a UART0 global at all than one that does nothing.
This commit is contained in:
committed by
Ron Evans
parent
c60c36f0a8
commit
42088f938e
@@ -114,6 +114,12 @@ func (i2c I2C) readByte() byte {
|
|||||||
return byte(avr.TWDR.Get())
|
return byte(avr.TWDR.Get())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UART
|
||||||
|
var (
|
||||||
|
// UART0 is the hardware serial port on the AVR.
|
||||||
|
UART0 = UART{Buffer: NewRingBuffer()}
|
||||||
|
)
|
||||||
|
|
||||||
// UART on the AVR.
|
// UART on the AVR.
|
||||||
type UART struct {
|
type UART struct {
|
||||||
Buffer *RingBuffer
|
Buffer *RingBuffer
|
||||||
|
|||||||
@@ -2,23 +2,6 @@
|
|||||||
|
|
||||||
package machine
|
package machine
|
||||||
|
|
||||||
// UART on the AVR is a dummy implementation. UART has not been implemented for ATtiny
|
|
||||||
// devices.
|
|
||||||
type UART struct {
|
|
||||||
Buffer *RingBuffer
|
|
||||||
}
|
|
||||||
|
|
||||||
// Configure is a dummy implementation. UART has not been implemented for ATtiny
|
|
||||||
// devices.
|
|
||||||
func (uart UART) Configure(config UARTConfig) {
|
|
||||||
}
|
|
||||||
|
|
||||||
// WriteByte is a dummy implementation. UART has not been implemented for ATtiny
|
|
||||||
// devices.
|
|
||||||
func (uart UART) WriteByte(c byte) error {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Tx is a dummy implementation. I2C has not been implemented for ATtiny
|
// Tx is a dummy implementation. I2C has not been implemented for ATtiny
|
||||||
// devices.
|
// devices.
|
||||||
func (i2c I2C) Tx(addr uint16, w, r []byte) error {
|
func (i2c I2C) Tx(addr uint16, w, r []byte) error {
|
||||||
|
|||||||
@@ -148,9 +148,3 @@ type I2C struct {
|
|||||||
|
|
||||||
// I2C0 is the only I2C interface on most AVRs.
|
// I2C0 is the only I2C interface on most AVRs.
|
||||||
var I2C0 = I2C{}
|
var I2C0 = I2C{}
|
||||||
|
|
||||||
// UART
|
|
||||||
var (
|
|
||||||
// UART0 is the hardware serial port on the AVR.
|
|
||||||
UART0 = UART{Buffer: NewRingBuffer()}
|
|
||||||
)
|
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
// +build avr esp nrf sam sifive stm32 k210 nxp
|
// +build atmega esp nrf sam sifive stm32 k210 nxp
|
||||||
|
|
||||||
package machine
|
package machine
|
||||||
|
|
||||||
|
|||||||
@@ -4,8 +4,17 @@ package runtime
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"device/avr"
|
"device/avr"
|
||||||
|
"machine"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func initUART() {
|
||||||
|
machine.UART0.Configure(machine.UARTConfig{})
|
||||||
|
}
|
||||||
|
|
||||||
|
func putchar(c byte) {
|
||||||
|
machine.UART0.WriteByte(c)
|
||||||
|
}
|
||||||
|
|
||||||
// Sleep for a given period. The period is defined by the WDT peripheral, and is
|
// Sleep for a given period. The period is defined by the WDT peripheral, and is
|
||||||
// on most chips (at least) 3 bits wide, in powers of two from 16ms to 2s
|
// on most chips (at least) 3 bits wide, in powers of two from 16ms to 2s
|
||||||
// (0=16ms, 1=32ms, 2=64ms...). Note that the WDT is not very accurate: it can
|
// (0=16ms, 1=32ms, 2=64ms...). Note that the WDT is not very accurate: it can
|
||||||
|
|||||||
@@ -6,6 +6,13 @@ import (
|
|||||||
"device/avr"
|
"device/avr"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func initUART() {
|
||||||
|
}
|
||||||
|
|
||||||
|
func putchar(c byte) {
|
||||||
|
// UART is not supported.
|
||||||
|
}
|
||||||
|
|
||||||
func sleepWDT(period uint8) {
|
func sleepWDT(period uint8) {
|
||||||
// TODO: use the watchdog timer instead of a busy loop.
|
// TODO: use the watchdog timer instead of a busy loop.
|
||||||
for i := 0x45; i != 0; i-- {
|
for i := 0x45; i != 0; i-- {
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ package runtime
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"device/avr"
|
"device/avr"
|
||||||
"machine"
|
|
||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -59,14 +58,6 @@ func init() {
|
|||||||
initUART()
|
initUART()
|
||||||
}
|
}
|
||||||
|
|
||||||
func initUART() {
|
|
||||||
machine.UART0.Configure(machine.UARTConfig{})
|
|
||||||
}
|
|
||||||
|
|
||||||
func putchar(c byte) {
|
|
||||||
machine.UART0.WriteByte(c)
|
|
||||||
}
|
|
||||||
|
|
||||||
const asyncScheduler = false
|
const asyncScheduler = false
|
||||||
|
|
||||||
const tickNanos = 1024 * 16384 // roughly 16ms in nanoseconds
|
const tickNanos = 1024 * 16384 // roughly 16ms in nanoseconds
|
||||||
|
|||||||
Reference in New Issue
Block a user