esp: add support for the Espressif ESP32 chip

This is only very minimal support. More support (such as tinygo flash,
or peripheral access) should be added in later commits, to keep this one
focused.

Importantly, this commit changes the LLVM repo from llvm/llvm-project to
tinygo-org/llvm-project. This provides a little bit of versioning in
case something changes in the Espressif fork. If we want to upgrade to
LLVM 11 it's easy to switch back to llvm/llvm-project until Espressif
has updated their fork.
This commit is contained in:
Ayke van Laethem
2020-08-06 23:28:45 +02:00
committed by Ron Evans
parent da7db81087
commit 3ee47a9c1b
15 changed files with 520 additions and 39 deletions
+44
View File
@@ -0,0 +1,44 @@
// +build esp32
package machine
import "device/esp"
const peripheralClock = 80000000 // 80MHz
type PinMode uint8
const (
PinOutput PinMode = iota
PinInput
)
func (p Pin) Set(value bool)
var (
UART0 = UART{Bus: esp.UART0, Buffer: NewRingBuffer()}
UART1 = UART{Bus: esp.UART1, Buffer: NewRingBuffer()}
UART2 = UART{Bus: esp.UART2, Buffer: NewRingBuffer()}
)
type UART struct {
Bus *esp.UART_Type
Buffer *RingBuffer
}
func (uart UART) Configure(config UARTConfig) {
if config.BaudRate == 0 {
config.BaudRate = 115200
}
uart.Bus.CLKDIV.Set(peripheralClock / config.BaudRate)
}
func (uart UART) WriteByte(b byte) error {
for (uart.Bus.STATUS.Get()>>16)&0xff >= 128 {
// Read UART_TXFIFO_CNT from the status register, which indicates how
// many bytes there are in the transmit buffer. Wait until there are
// less than 128 bytes in this buffer (the default buffer size).
}
uart.Bus.TX_FIFO.Set(b)
return nil
}
+1 -1
View File
@@ -1,4 +1,4 @@
// +build avr nrf sam sifive stm32 k210 nxp
// +build avr esp nrf sam sifive stm32 k210 nxp
package machine