From df828c1ce7d6ac4ac4c6c4d3885579d8ad8cfb38 Mon Sep 17 00:00:00 2001 From: Thomas Kohler Date: Sun, 7 Jan 2024 19:35:59 +0100 Subject: [PATCH] re-generated by skipping targets with sanity check errors --- .../microcontrollers/arduino-mega1280.md | 2 +- .../reference/microcontrollers/bluepill.md | 2 +- .../machine/arduino-mega1280.md | 47 +++++-- .../machine/arduino-mega2560.md | 47 +++++-- .../microcontrollers/machine/arduino-nano.md | 111 ++++++++++++++-- .../microcontrollers/machine/arduino.md | 111 ++++++++++++++-- .../microcontrollers/machine/bluepill.md | 71 +++++++++- .../microcontrollers/machine/d1mini.md | 9 +- .../microcontrollers/machine/digispark.md | 2 + .../machine/esp32-coreboard-v2.md | 9 +- .../microcontrollers/machine/esp32-mini32.md | 9 +- .../machine/feather-stm32f405.md | 71 +++++++++- .../machine/gameboy-advance.md | 2 + .../microcontrollers/machine/hifive1b.md | 18 ++- .../microcontrollers/machine/lgt92.md | 71 +++++++++- .../microcontrollers/machine/lorae5.md | 71 +++++++++- .../microcontrollers/machine/m5stack-core2.md | 9 +- .../microcontrollers/machine/m5stack.md | 9 +- .../microcontrollers/machine/m5stamp-c3.md | 125 +++++++++++++++++- .../microcontrollers/machine/maixbit.md | 18 ++- .../microcontrollers/machine/microbit.md | 40 +++++- .../microcontrollers/machine/nodemcu.md | 9 +- .../microcontrollers/machine/nucleo-f103rb.md | 71 +++++++++- .../microcontrollers/machine/nucleo-f722ze.md | 69 +++++++++- .../microcontrollers/machine/nucleo-l031k6.md | 71 +++++++++- .../microcontrollers/machine/nucleo-l432kc.md | 71 +++++++++- .../microcontrollers/machine/nucleo-l552ze.md | 69 +++++++++- .../microcontrollers/machine/nucleo-wl55jc.md | 71 +++++++++- .../microcontrollers/machine/pca10031.md | 40 +++++- .../microcontrollers/machine/pca10040.md | 40 +++++- .../microcontrollers/machine/stm32f4disco.md | 71 +++++++++- .../microcontrollers/machine/swan.md | 71 +++++++++- .../microcontrollers/machine/teensy40.md | 124 +++++++++++++++-- .../microcontrollers/machine/x9pro.md | 40 +++++- doc-gen/main.go | 28 ++-- 35 files changed, 1573 insertions(+), 126 deletions(-) diff --git a/content/docs/reference/microcontrollers/arduino-mega1280.md b/content/docs/reference/microcontrollers/arduino-mega1280.md index 83482fb6..3f9dfee1 100644 --- a/content/docs/reference/microcontrollers/arduino-mega1280.md +++ b/content/docs/reference/microcontrollers/arduino-mega1280.md @@ -3,7 +3,7 @@ title: "Arduino Mega 1280" weight: 3 --- -The [Arduino Mega 1280](https://www.arduino.cc/en/Main/arduinoBoardMega/) is based on the AVR [ATmega1280](https://www.microchip.com/wwwproducts/en/ATMEGA1280) microcontroller. +The [Arduino Mega 1280](https://docs.arduino.cc/retired/other/arduino-older-boards#arduino-mega/) is based on the AVR [ATmega1280](https://www.microchip.com/wwwproducts/en/ATMEGA1280) microcontroller. Note: the AVR backend of LLVM is still experimental so you may encounter bugs. diff --git a/content/docs/reference/microcontrollers/bluepill.md b/content/docs/reference/microcontrollers/bluepill.md index c4a8530f..d74c6f8c 100644 --- a/content/docs/reference/microcontrollers/bluepill.md +++ b/content/docs/reference/microcontrollers/bluepill.md @@ -3,7 +3,7 @@ title: 'ST Micro STM32F103XX "Bluepill"' weight: 3 --- -The [Bluepill](http://wiki.stm32duino.com/index.php?title=Blue_Pill) is a popular, ultra-cheap and compact ARM development board based on the ST Micro [STM32F103C8](https://www.st.com/en/microcontrollers/stm32f103c8.html) SoC. +The [Bluepill](https://stm32-base.org/boards/STM32F103C8T6-Blue-Pill.html) is a popular, ultra-cheap and compact ARM development board based on the ST Micro [STM32F103C8](https://www.st.com/en/microcontrollers/stm32f103c8.html) SoC. ## Interfaces diff --git a/content/docs/reference/microcontrollers/machine/arduino-mega1280.md b/content/docs/reference/microcontrollers/machine/arduino-mega1280.md index 647604a8..27a9964c 100644 --- a/content/docs/reference/microcontrollers/machine/arduino-mega1280.md +++ b/content/docs/reference/microcontrollers/machine/arduino-mega1280.md @@ -317,13 +317,6 @@ var ( -```go -var I2C0 *I2C = nil -``` - -I2C0 is the only I2C interface on most AVRs. - - ```go var DefaultUART = UART0 ``` @@ -496,6 +489,18 @@ value of each parameter will use the peripheral's default settings. ```go type I2C struct { + srReg *volatile.Register8 + brReg *volatile.Register8 + crReg *volatile.Register8 + drReg *volatile.Register8 + + srPS0 byte + srPS1 byte + crEN byte + crINT byte + crSTO byte + crEA byte + crSTA byte } ``` @@ -526,6 +531,15 @@ is a shortcut to easily read such registers. Also, it only works for devices with 7-bit addresses, which is the vast majority. +### func (*I2C) SetBaudRate + +```go +func (i2c *I2C) SetBaudRate(br uint32) error +``` + +SetBaudRate sets the communication speed for I2C. + + ### func (*I2C) Tx ```go @@ -1003,6 +1017,17 @@ type SPI struct { spdr *volatile.Register8 spsr *volatile.Register8 + spcrR0 byte + spcrR1 byte + spcrCPHA byte + spcrCPOL byte + spcrDORD byte + spcrSPE byte + spcrMSTR byte + + spsrI2X byte + spsrSPIF byte + // The io pins for the SPIx port set by the chip sck Pin sdi Pin @@ -1150,7 +1175,8 @@ Usually called by the IRQ handler for a machine. func (uart *UART) Write(data []byte) (n int, err error) ``` -Write data to the UART. +Write data over the UART's Tx. +This function blocks until the data is finished being sent. ### func (*UART) WriteByte @@ -1159,7 +1185,8 @@ Write data to the UART. func (uart *UART) WriteByte(c byte) error ``` -WriteByte writes a byte of data to the UART. +WriteByte writes a byte of data over the UART's Tx. +This function blocks until the data is finished being sent. @@ -1171,6 +1198,8 @@ type UARTConfig struct { BaudRate uint32 TX Pin RX Pin + RTS Pin + CTS Pin } ``` diff --git a/content/docs/reference/microcontrollers/machine/arduino-mega2560.md b/content/docs/reference/microcontrollers/machine/arduino-mega2560.md index 7c6922e2..42ba55ee 100644 --- a/content/docs/reference/microcontrollers/machine/arduino-mega2560.md +++ b/content/docs/reference/microcontrollers/machine/arduino-mega2560.md @@ -375,13 +375,6 @@ var ( -```go -var I2C0 *I2C = nil -``` - -I2C0 is the only I2C interface on most AVRs. - - ```go var DefaultUART = UART0 ``` @@ -541,6 +534,18 @@ value of each parameter will use the peripheral's default settings. ```go type I2C struct { + srReg *volatile.Register8 + brReg *volatile.Register8 + crReg *volatile.Register8 + drReg *volatile.Register8 + + srPS0 byte + srPS1 byte + crEN byte + crINT byte + crSTO byte + crEA byte + crSTA byte } ``` @@ -571,6 +576,15 @@ is a shortcut to easily read such registers. Also, it only works for devices with 7-bit addresses, which is the vast majority. +### func (*I2C) SetBaudRate + +```go +func (i2c *I2C) SetBaudRate(br uint32) error +``` + +SetBaudRate sets the communication speed for I2C. + + ### func (*I2C) Tx ```go @@ -918,6 +932,17 @@ type SPI struct { spdr *volatile.Register8 spsr *volatile.Register8 + spcrR0 byte + spcrR1 byte + spcrCPHA byte + spcrCPOL byte + spcrDORD byte + spcrSPE byte + spcrMSTR byte + + spsrI2X byte + spsrSPIF byte + // The io pins for the SPIx port set by the chip sck Pin sdi Pin @@ -1065,7 +1090,8 @@ Usually called by the IRQ handler for a machine. func (uart *UART) Write(data []byte) (n int, err error) ``` -Write data to the UART. +Write data over the UART's Tx. +This function blocks until the data is finished being sent. ### func (*UART) WriteByte @@ -1074,7 +1100,8 @@ Write data to the UART. func (uart *UART) WriteByte(c byte) error ``` -WriteByte writes a byte of data to the UART. +WriteByte writes a byte of data over the UART's Tx. +This function blocks until the data is finished being sent. @@ -1086,6 +1113,8 @@ type UARTConfig struct { BaudRate uint32 TX Pin RX Pin + RTS Pin + CTS Pin } ``` diff --git a/content/docs/reference/microcontrollers/machine/arduino-nano.md b/content/docs/reference/microcontrollers/machine/arduino-nano.md index 9ba2d9e8..e135e6e4 100644 --- a/content/docs/reference/microcontrollers/machine/arduino-nano.md +++ b/content/docs/reference/microcontrollers/machine/arduino-nano.md @@ -163,6 +163,16 @@ NoPin explicitly indicates "not a pin". Use this pin if you want to leave one of the pins in a peripheral unconfigured (if supported by the hardware). +```go +const ( + PinRising PinChange = 1 << iota + PinFalling + PinToggle = PinRising | PinFalling +) +``` + + + ```go const ( PinInput PinMode = iota @@ -223,13 +233,6 @@ var ( -```go -var I2C0 *I2C = nil -``` - -I2C0 is the only I2C interface on most AVRs. - - ```go var DefaultUART = UART0 ``` @@ -267,15 +270,47 @@ var ( +```go +var I2C0 = &I2C{ + srReg: avr.TWSR, + brReg: avr.TWBR, + crReg: avr.TWCR, + drReg: avr.TWDR, + srPS0: avr.TWSR_TWPS0, + srPS1: avr.TWSR_TWPS1, + crEN: avr.TWCR_TWEN, + crINT: avr.TWCR_TWINT, + crSTO: avr.TWCR_TWSTO, + crEA: avr.TWCR_TWEA, + crSTA: avr.TWCR_TWSTA, +} +``` + +I2C0 is the only I2C interface on most AVRs. + + ```go var SPI0 = SPI{ spcr: avr.SPCR, spdr: avr.SPDR, spsr: avr.SPSR, + + spcrR0: avr.SPCR_SPR0, + spcrR1: avr.SPCR_SPR1, + spcrCPHA: avr.SPCR_CPHA, + spcrCPOL: avr.SPCR_CPOL, + spcrDORD: avr.SPCR_DORD, + spcrSPE: avr.SPCR_SPE, + spcrMSTR: avr.SPCR_MSTR, + + spsrI2X: avr.SPSR_SPI2X, + spsrSPIF: avr.SPSR_SPIF, + sck: PB5, sdo: PB3, sdi: PB4, - cs: PB2} + cs: PB2, +} ``` SPI configuration @@ -399,6 +434,18 @@ value of each parameter will use the peripheral's default settings. ```go type I2C struct { + srReg *volatile.Register8 + brReg *volatile.Register8 + crReg *volatile.Register8 + drReg *volatile.Register8 + + srPS0 byte + srPS1 byte + crEN byte + crINT byte + crSTO byte + crEA byte + crSTA byte } ``` @@ -429,6 +476,15 @@ is a shortcut to easily read such registers. Also, it only works for devices with 7-bit addresses, which is the vast majority. +### func (*I2C) SetBaudRate + +```go +func (i2c *I2C) SetBaudRate(br uint32) error +``` + +SetBaudRate sets the communication speed for I2C. + + ### func (*I2C) Tx ```go @@ -813,6 +869,26 @@ func (p Pin) Set(value bool) Set changes the value of the GPIO pin. The pin must be configured as output. +### func (Pin) SetInterrupt + +```go +func (pin Pin) SetInterrupt(pinChange PinChange, callback func(Pin)) (err error) +``` + + + + + +## type PinChange + +```go +type PinChange uint8 +``` + +Pin Change Interrupts + + + ## type PinConfig @@ -906,6 +982,17 @@ type SPI struct { spdr *volatile.Register8 spsr *volatile.Register8 + spcrR0 byte + spcrR1 byte + spcrCPHA byte + spcrCPOL byte + spcrDORD byte + spcrSPE byte + spcrMSTR byte + + spsrI2X byte + spsrSPIF byte + // The io pins for the SPIx port set by the chip sck Pin sdi Pin @@ -1053,7 +1140,8 @@ Usually called by the IRQ handler for a machine. func (uart *UART) Write(data []byte) (n int, err error) ``` -Write data to the UART. +Write data over the UART's Tx. +This function blocks until the data is finished being sent. ### func (*UART) WriteByte @@ -1062,7 +1150,8 @@ Write data to the UART. func (uart *UART) WriteByte(c byte) error ``` -WriteByte writes a byte of data to the UART. +WriteByte writes a byte of data over the UART's Tx. +This function blocks until the data is finished being sent. @@ -1074,6 +1163,8 @@ type UARTConfig struct { BaudRate uint32 TX Pin RX Pin + RTS Pin + CTS Pin } ``` diff --git a/content/docs/reference/microcontrollers/machine/arduino.md b/content/docs/reference/microcontrollers/machine/arduino.md index 2da082bf..9624d303 100644 --- a/content/docs/reference/microcontrollers/machine/arduino.md +++ b/content/docs/reference/microcontrollers/machine/arduino.md @@ -163,6 +163,16 @@ NoPin explicitly indicates "not a pin". Use this pin if you want to leave one of the pins in a peripheral unconfigured (if supported by the hardware). +```go +const ( + PinRising PinChange = 1 << iota + PinFalling + PinToggle = PinRising | PinFalling +) +``` + + + ```go const ( PinInput PinMode = iota @@ -223,13 +233,6 @@ var ( -```go -var I2C0 *I2C = nil -``` - -I2C0 is the only I2C interface on most AVRs. - - ```go var DefaultUART = UART0 ``` @@ -267,15 +270,47 @@ var ( +```go +var I2C0 = &I2C{ + srReg: avr.TWSR, + brReg: avr.TWBR, + crReg: avr.TWCR, + drReg: avr.TWDR, + srPS0: avr.TWSR_TWPS0, + srPS1: avr.TWSR_TWPS1, + crEN: avr.TWCR_TWEN, + crINT: avr.TWCR_TWINT, + crSTO: avr.TWCR_TWSTO, + crEA: avr.TWCR_TWEA, + crSTA: avr.TWCR_TWSTA, +} +``` + +I2C0 is the only I2C interface on most AVRs. + + ```go var SPI0 = SPI{ spcr: avr.SPCR, spdr: avr.SPDR, spsr: avr.SPSR, + + spcrR0: avr.SPCR_SPR0, + spcrR1: avr.SPCR_SPR1, + spcrCPHA: avr.SPCR_CPHA, + spcrCPOL: avr.SPCR_CPOL, + spcrDORD: avr.SPCR_DORD, + spcrSPE: avr.SPCR_SPE, + spcrMSTR: avr.SPCR_MSTR, + + spsrI2X: avr.SPSR_SPI2X, + spsrSPIF: avr.SPSR_SPIF, + sck: PB5, sdo: PB3, sdi: PB4, - cs: PB2} + cs: PB2, +} ``` SPI configuration @@ -399,6 +434,18 @@ value of each parameter will use the peripheral's default settings. ```go type I2C struct { + srReg *volatile.Register8 + brReg *volatile.Register8 + crReg *volatile.Register8 + drReg *volatile.Register8 + + srPS0 byte + srPS1 byte + crEN byte + crINT byte + crSTO byte + crEA byte + crSTA byte } ``` @@ -429,6 +476,15 @@ is a shortcut to easily read such registers. Also, it only works for devices with 7-bit addresses, which is the vast majority. +### func (*I2C) SetBaudRate + +```go +func (i2c *I2C) SetBaudRate(br uint32) error +``` + +SetBaudRate sets the communication speed for I2C. + + ### func (*I2C) Tx ```go @@ -813,6 +869,26 @@ func (p Pin) Set(value bool) Set changes the value of the GPIO pin. The pin must be configured as output. +### func (Pin) SetInterrupt + +```go +func (pin Pin) SetInterrupt(pinChange PinChange, callback func(Pin)) (err error) +``` + + + + + +## type PinChange + +```go +type PinChange uint8 +``` + +Pin Change Interrupts + + + ## type PinConfig @@ -906,6 +982,17 @@ type SPI struct { spdr *volatile.Register8 spsr *volatile.Register8 + spcrR0 byte + spcrR1 byte + spcrCPHA byte + spcrCPOL byte + spcrDORD byte + spcrSPE byte + spcrMSTR byte + + spsrI2X byte + spsrSPIF byte + // The io pins for the SPIx port set by the chip sck Pin sdi Pin @@ -1053,7 +1140,8 @@ Usually called by the IRQ handler for a machine. func (uart *UART) Write(data []byte) (n int, err error) ``` -Write data to the UART. +Write data over the UART's Tx. +This function blocks until the data is finished being sent. ### func (*UART) WriteByte @@ -1062,7 +1150,8 @@ Write data to the UART. func (uart *UART) WriteByte(c byte) error ``` -WriteByte writes a byte of data to the UART. +WriteByte writes a byte of data over the UART's Tx. +This function blocks until the data is finished being sent. @@ -1074,6 +1163,8 @@ type UARTConfig struct { BaudRate uint32 TX Pin RX Pin + RTS Pin + CTS Pin } ``` diff --git a/content/docs/reference/microcontrollers/machine/bluepill.md b/content/docs/reference/microcontrollers/machine/bluepill.md index 04c2ce75..7d81e5fd 100644 --- a/content/docs/reference/microcontrollers/machine/bluepill.md +++ b/content/docs/reference/microcontrollers/machine/bluepill.md @@ -219,6 +219,18 @@ const ( I2C fast mode (Fm) duty cycle +```go +const ( + // WatchdogMaxTimeout in milliseconds (32.768s) + // + // Timeout is based on 12-bit counter with /256 divider on + // 32.768kHz clock. See 21.3.3 of RM0090 for table. + WatchdogMaxTimeout = ((0xfff + 1) * 256 * 1024) / 32768 +) +``` + + + ```go const PWM_MODE1 = 0x6 ``` @@ -461,6 +473,14 @@ var ( +```go +var ( + Watchdog = &watchdogImpl{} +) +``` + + + ```go var ( SPI1 = SPI{Bus: stm32.SPI1} @@ -714,6 +734,20 @@ func CPUReset() CPUReset performs a hard system reset. +### func DeviceID + +```go +func DeviceID() []byte +``` + +DeviceID returns an identifier that is unique within +a particular chipset. + +The identity is one burnt into the MCU itself. + +The length of the device ID for STM32 is 12 bytes (96 bits). + + ### func InitADC ```go @@ -837,6 +871,15 @@ is a shortcut to easily read such registers. Also, it only works for devices with 7-bit addresses, which is the vast majority. +### func (*I2C) SetBaudRate + +```go +func (i2c *I2C) SetBaudRate(br uint32) error +``` + +SetBaudRate sets the communication speed for I2C. + + ### func (*I2C) Tx ```go @@ -1224,7 +1267,7 @@ type SPI struct { ### func (SPI) Configure ```go -func (spi SPI) Configure(config SPIConfig) +func (spi SPI) Configure(config SPIConfig) error ``` Configure is intended to setup the STM32 SPI1 interface. @@ -1544,7 +1587,8 @@ routines for calculation func (uart *UART) Write(data []byte) (n int, err error) ``` -Write data to the UART. +Write data over the UART's Tx. +This function blocks until the data is finished being sent. ### func (*UART) WriteByte @@ -1553,7 +1597,8 @@ Write data to the UART. func (uart *UART) WriteByte(c byte) error ``` -WriteByte writes a byte of data to the UART. +WriteByte writes a byte of data over the UART's Tx. +This function blocks until the data is finished being sent. @@ -1565,6 +1610,8 @@ type UARTConfig struct { BaudRate uint32 TX Pin RX Pin + RTS Pin + CTS Pin } ``` @@ -1588,3 +1635,21 @@ UARTParity is the parity setting to be used for UART communication. +## type WatchdogConfig + +```go +type WatchdogConfig struct { + // The timeout (in milliseconds) before the watchdog fires. + // + // If the requested timeout exceeds `MaxTimeout` it will be rounded + // down. + TimeoutMillis uint32 +} +``` + +WatchdogConfig holds configuration for the watchdog timer. + + + + + diff --git a/content/docs/reference/microcontrollers/machine/d1mini.md b/content/docs/reference/microcontrollers/machine/d1mini.md index 424f5dff..ca461262 100644 --- a/content/docs/reference/microcontrollers/machine/d1mini.md +++ b/content/docs/reference/microcontrollers/machine/d1mini.md @@ -587,7 +587,8 @@ Usually called by the IRQ handler for a machine. func (uart *UART) Write(data []byte) (n int, err error) ``` -Write data to the UART. +Write data over the UART's Tx. +This function blocks until the data is finished being sent. ### func (*UART) WriteByte @@ -596,8 +597,8 @@ Write data to the UART. func (uart *UART) WriteByte(c byte) error ``` -WriteByte writes a single byte to the output buffer. Note that the hardware -includes a buffer of 128 bytes which will be used first. +WriteByte writes a byte of data over the UART's Tx. +This function blocks until the data is finished being sent. @@ -609,6 +610,8 @@ type UARTConfig struct { BaudRate uint32 TX Pin RX Pin + RTS Pin + CTS Pin } ``` diff --git a/content/docs/reference/microcontrollers/machine/digispark.md b/content/docs/reference/microcontrollers/machine/digispark.md index 701ff021..25b9bba0 100644 --- a/content/docs/reference/microcontrollers/machine/digispark.md +++ b/content/docs/reference/microcontrollers/machine/digispark.md @@ -479,6 +479,8 @@ type UARTConfig struct { BaudRate uint32 TX Pin RX Pin + RTS Pin + CTS Pin } ``` diff --git a/content/docs/reference/microcontrollers/machine/esp32-coreboard-v2.md b/content/docs/reference/microcontrollers/machine/esp32-coreboard-v2.md index 7bc260f7..6a9871d2 100644 --- a/content/docs/reference/microcontrollers/machine/esp32-coreboard-v2.md +++ b/content/docs/reference/microcontrollers/machine/esp32-coreboard-v2.md @@ -783,15 +783,18 @@ Usually called by the IRQ handler for a machine. func (uart *UART) Write(data []byte) (n int, err error) ``` -Write data to the UART. +Write data over the UART's Tx. +This function blocks until the data is finished being sent. ### func (*UART) WriteByte ```go -func (uart *UART) WriteByte(b byte) error +func (uart *UART) WriteByte(c byte) error ``` +WriteByte writes a byte of data over the UART's Tx. +This function blocks until the data is finished being sent. @@ -803,6 +806,8 @@ type UARTConfig struct { BaudRate uint32 TX Pin RX Pin + RTS Pin + CTS Pin } ``` diff --git a/content/docs/reference/microcontrollers/machine/esp32-mini32.md b/content/docs/reference/microcontrollers/machine/esp32-mini32.md index 3c599a8b..b4ee52d6 100644 --- a/content/docs/reference/microcontrollers/machine/esp32-mini32.md +++ b/content/docs/reference/microcontrollers/machine/esp32-mini32.md @@ -783,15 +783,18 @@ Usually called by the IRQ handler for a machine. func (uart *UART) Write(data []byte) (n int, err error) ``` -Write data to the UART. +Write data over the UART's Tx. +This function blocks until the data is finished being sent. ### func (*UART) WriteByte ```go -func (uart *UART) WriteByte(b byte) error +func (uart *UART) WriteByte(c byte) error ``` +WriteByte writes a byte of data over the UART's Tx. +This function blocks until the data is finished being sent. @@ -803,6 +806,8 @@ type UARTConfig struct { BaudRate uint32 TX Pin RX Pin + RTS Pin + CTS Pin } ``` diff --git a/content/docs/reference/microcontrollers/machine/feather-stm32f405.md b/content/docs/reference/microcontrollers/machine/feather-stm32f405.md index cf267d79..1e058438 100644 --- a/content/docs/reference/microcontrollers/machine/feather-stm32f405.md +++ b/content/docs/reference/microcontrollers/machine/feather-stm32f405.md @@ -290,6 +290,18 @@ const ( I2C fast mode (Fm) duty cycle +```go +const ( + // WatchdogMaxTimeout in milliseconds (32.768s) + // + // Timeout is based on 12-bit counter with /256 divider on + // 32.768kHz clock. See 21.3.3 of RM0090 for table. + WatchdogMaxTimeout = ((0xfff + 1) * 256 * 1024) / 32768 +) +``` + + + ```go const ( // Mode Flag @@ -683,6 +695,14 @@ var Flash flashBlockDevice +```go +var ( + Watchdog = &watchdogImpl{} +) +``` + + + ```go var ( TIM1 = TIM{ @@ -915,6 +935,20 @@ func CPUReset() CPUReset performs a hard system reset. +### func DeviceID + +```go +func DeviceID() []byte +``` + +DeviceID returns an identifier that is unique within +a particular chipset. + +The identity is one burnt into the MCU itself. + +The length of the device ID for STM32 is 12 bytes (96 bits). + + ### func FlashDataEnd ```go @@ -1105,6 +1139,15 @@ is a shortcut to easily read such registers. Also, it only works for devices with 7-bit addresses, which is the vast majority. +### func (*I2C) SetBaudRate + +```go +func (i2c *I2C) SetBaudRate(br uint32) error +``` + +SetBaudRate sets the communication speed for I2C. + + ### func (*I2C) Tx ```go @@ -1512,7 +1555,7 @@ type SPI struct { ### func (SPI) Configure ```go -func (spi SPI) Configure(config SPIConfig) +func (spi SPI) Configure(config SPIConfig) error ``` Configure is intended to setup the STM32 SPI1 interface. @@ -1832,7 +1875,8 @@ routines for calculation func (uart *UART) Write(data []byte) (n int, err error) ``` -Write data to the UART. +Write data over the UART's Tx. +This function blocks until the data is finished being sent. ### func (*UART) WriteByte @@ -1841,7 +1885,8 @@ Write data to the UART. func (uart *UART) WriteByte(c byte) error ``` -WriteByte writes a byte of data to the UART. +WriteByte writes a byte of data over the UART's Tx. +This function blocks until the data is finished being sent. @@ -1853,6 +1898,8 @@ type UARTConfig struct { BaudRate uint32 TX Pin RX Pin + RTS Pin + CTS Pin } ``` @@ -1876,3 +1923,21 @@ UARTParity is the parity setting to be used for UART communication. +## type WatchdogConfig + +```go +type WatchdogConfig struct { + // The timeout (in milliseconds) before the watchdog fires. + // + // If the requested timeout exceeds `MaxTimeout` it will be rounded + // down. + TimeoutMillis uint32 +} +``` + +WatchdogConfig holds configuration for the watchdog timer. + + + + + diff --git a/content/docs/reference/microcontrollers/machine/gameboy-advance.md b/content/docs/reference/microcontrollers/machine/gameboy-advance.md index da2453a4..9107885f 100644 --- a/content/docs/reference/microcontrollers/machine/gameboy-advance.md +++ b/content/docs/reference/microcontrollers/machine/gameboy-advance.md @@ -431,6 +431,8 @@ type UARTConfig struct { BaudRate uint32 TX Pin RX Pin + RTS Pin + CTS Pin } ``` diff --git a/content/docs/reference/microcontrollers/machine/hifive1b.md b/content/docs/reference/microcontrollers/machine/hifive1b.md index 072ddf8c..1475b038 100644 --- a/content/docs/reference/microcontrollers/machine/hifive1b.md +++ b/content/docs/reference/microcontrollers/machine/hifive1b.md @@ -410,6 +410,15 @@ is a shortcut to easily read such registers. Also, it only works for devices with 7-bit addresses, which is the vast majority. +### func (*I2C) SetBaudRate + +```go +func (i2c *I2C) SetBaudRate(br uint32) error +``` + +SetBaudRate sets the communication speed for I2C. + + ### func (*I2C) Tx ```go @@ -887,15 +896,18 @@ Usually called by the IRQ handler for a machine. func (uart *UART) Write(data []byte) (n int, err error) ``` -Write data to the UART. +Write data over the UART's Tx. +This function blocks until the data is finished being sent. ### func (*UART) WriteByte ```go -func (uart *UART) WriteByte(c byte) +func (uart *UART) WriteByte(c byte) error ``` +WriteByte writes a byte of data over the UART's Tx. +This function blocks until the data is finished being sent. @@ -907,6 +919,8 @@ type UARTConfig struct { BaudRate uint32 TX Pin RX Pin + RTS Pin + CTS Pin } ``` diff --git a/content/docs/reference/microcontrollers/machine/lgt92.md b/content/docs/reference/microcontrollers/machine/lgt92.md index 2952e609..025297b5 100644 --- a/content/docs/reference/microcontrollers/machine/lgt92.md +++ b/content/docs/reference/microcontrollers/machine/lgt92.md @@ -157,6 +157,18 @@ const ( +```go +const ( + // WatchdogMaxTimeout in milliseconds (32.768s) + // + // Timeout is based on 12-bit counter with /256 divider on + // 32.768kHz clock. See 21.3.3 of RM0090 for table. + WatchdogMaxTimeout = ((0xfff + 1) * 256 * 1024) / 32768 +) +``` + + + ```go const ( // Mode Flag @@ -430,6 +442,14 @@ var ( +```go +var ( + Watchdog = &watchdogImpl{} +) +``` + + + ```go var ( TIM2 = TIM{ @@ -613,6 +633,20 @@ func CPUReset() CPUReset performs a hard system reset. +### func DeviceID + +```go +func DeviceID() []byte +``` + +DeviceID returns an identifier that is unique within +a particular chipset. + +The identity is one burnt into the MCU itself. + +The length of the device ID for STM32 is 12 bytes (96 bits). + + ### func GetRNG ```go @@ -717,6 +751,15 @@ is a shortcut to easily read such registers. Also, it only works for devices with 7-bit addresses, which is the vast majority. +### func (*I2C) SetBaudRate + +```go +func (i2c *I2C) SetBaudRate(br uint32) error +``` + +SetBaudRate sets the communication speed for I2C. + + ### func (*I2C) Tx ```go @@ -1123,7 +1166,7 @@ SPI on the STM32Fxxx using MODER / alternate function pins ### func (SPI) Configure ```go -func (spi SPI) Configure(config SPIConfig) +func (spi SPI) Configure(config SPIConfig) error ``` Configure is intended to setup the STM32 SPI1 interface. @@ -1443,7 +1486,8 @@ routines for calculation func (uart *UART) Write(data []byte) (n int, err error) ``` -Write data to the UART. +Write data over the UART's Tx. +This function blocks until the data is finished being sent. ### func (*UART) WriteByte @@ -1452,7 +1496,8 @@ Write data to the UART. func (uart *UART) WriteByte(c byte) error ``` -WriteByte writes a byte of data to the UART. +WriteByte writes a byte of data over the UART's Tx. +This function blocks until the data is finished being sent. @@ -1464,6 +1509,8 @@ type UARTConfig struct { BaudRate uint32 TX Pin RX Pin + RTS Pin + CTS Pin } ``` @@ -1487,3 +1534,21 @@ UARTParity is the parity setting to be used for UART communication. +## type WatchdogConfig + +```go +type WatchdogConfig struct { + // The timeout (in milliseconds) before the watchdog fires. + // + // If the requested timeout exceeds `MaxTimeout` it will be rounded + // down. + TimeoutMillis uint32 +} +``` + +WatchdogConfig holds configuration for the watchdog timer. + + + + + diff --git a/content/docs/reference/microcontrollers/machine/lorae5.md b/content/docs/reference/microcontrollers/machine/lorae5.md index 887d8a1a..aa9b3240 100644 --- a/content/docs/reference/microcontrollers/machine/lorae5.md +++ b/content/docs/reference/microcontrollers/machine/lorae5.md @@ -163,6 +163,18 @@ const ( +```go +const ( + // WatchdogMaxTimeout in milliseconds (32.768s) + // + // Timeout is based on 12-bit counter with /256 divider on + // 32.768kHz clock. See 21.3.3 of RM0090 for table. + WatchdogMaxTimeout = ((0xfff + 1) * 256 * 1024) / 32768 +) +``` + + + ```go const ( // Mode Flag @@ -403,6 +415,14 @@ var Flash flashBlockDevice +```go +var ( + Watchdog = &watchdogImpl{} +) +``` + + + ```go var ( TIM1 = TIM{ @@ -502,6 +522,20 @@ func CPUReset() CPUReset performs a hard system reset. +### func DeviceID + +```go +func DeviceID() []byte +``` + +DeviceID returns an identifier that is unique within +a particular chipset. + +The identity is one burnt into the MCU itself. + +The length of the device ID for STM32 is 12 bytes (96 bits). + + ### func FlashDataEnd ```go @@ -663,6 +697,15 @@ is a shortcut to easily read such registers. Also, it only works for devices with 7-bit addresses, which is the vast majority. +### func (*I2C) SetBaudRate + +```go +func (i2c *I2C) SetBaudRate(br uint32) error +``` + +SetBaudRate sets the communication speed for I2C. + + ### func (*I2C) Tx ```go @@ -1068,7 +1111,7 @@ type SPI struct { ### func (SPI) Configure ```go -func (spi SPI) Configure(config SPIConfig) +func (spi SPI) Configure(config SPIConfig) error ``` Configure is intended to setup the STM32 SPI1 interface. @@ -1388,7 +1431,8 @@ routines for calculation func (uart *UART) Write(data []byte) (n int, err error) ``` -Write data to the UART. +Write data over the UART's Tx. +This function blocks until the data is finished being sent. ### func (*UART) WriteByte @@ -1397,7 +1441,8 @@ Write data to the UART. func (uart *UART) WriteByte(c byte) error ``` -WriteByte writes a byte of data to the UART. +WriteByte writes a byte of data over the UART's Tx. +This function blocks until the data is finished being sent. @@ -1409,6 +1454,8 @@ type UARTConfig struct { BaudRate uint32 TX Pin RX Pin + RTS Pin + CTS Pin } ``` @@ -1432,3 +1479,21 @@ UARTParity is the parity setting to be used for UART communication. +## type WatchdogConfig + +```go +type WatchdogConfig struct { + // The timeout (in milliseconds) before the watchdog fires. + // + // If the requested timeout exceeds `MaxTimeout` it will be rounded + // down. + TimeoutMillis uint32 +} +``` + +WatchdogConfig holds configuration for the watchdog timer. + + + + + diff --git a/content/docs/reference/microcontrollers/machine/m5stack-core2.md b/content/docs/reference/microcontrollers/machine/m5stack-core2.md index 4fa2ec4e..6d50d03f 100644 --- a/content/docs/reference/microcontrollers/machine/m5stack-core2.md +++ b/content/docs/reference/microcontrollers/machine/m5stack-core2.md @@ -786,15 +786,18 @@ Usually called by the IRQ handler for a machine. func (uart *UART) Write(data []byte) (n int, err error) ``` -Write data to the UART. +Write data over the UART's Tx. +This function blocks until the data is finished being sent. ### func (*UART) WriteByte ```go -func (uart *UART) WriteByte(b byte) error +func (uart *UART) WriteByte(c byte) error ``` +WriteByte writes a byte of data over the UART's Tx. +This function blocks until the data is finished being sent. @@ -806,6 +809,8 @@ type UARTConfig struct { BaudRate uint32 TX Pin RX Pin + RTS Pin + CTS Pin } ``` diff --git a/content/docs/reference/microcontrollers/machine/m5stack.md b/content/docs/reference/microcontrollers/machine/m5stack.md index dbc6a03e..64b3471e 100644 --- a/content/docs/reference/microcontrollers/machine/m5stack.md +++ b/content/docs/reference/microcontrollers/machine/m5stack.md @@ -799,15 +799,18 @@ Usually called by the IRQ handler for a machine. func (uart *UART) Write(data []byte) (n int, err error) ``` -Write data to the UART. +Write data over the UART's Tx. +This function blocks until the data is finished being sent. ### func (*UART) WriteByte ```go -func (uart *UART) WriteByte(b byte) error +func (uart *UART) WriteByte(c byte) error ``` +WriteByte writes a byte of data over the UART's Tx. +This function blocks until the data is finished being sent. @@ -819,6 +822,8 @@ type UARTConfig struct { BaudRate uint32 TX Pin RX Pin + RTS Pin + CTS Pin } ``` diff --git a/content/docs/reference/microcontrollers/machine/m5stamp-c3.md b/content/docs/reference/microcontrollers/machine/m5stamp-c3.md index 74c3cb5c..912ca253 100644 --- a/content/docs/reference/microcontrollers/machine/m5stamp-c3.md +++ b/content/docs/reference/microcontrollers/machine/m5stamp-c3.md @@ -229,6 +229,18 @@ var ( +```go +var ( + _USBCDC = &USB_DEVICE{ + Bus: esp.USB_DEVICE, + } + + USBCDC Serialer = _USBCDC +) +``` + + + ```go var ( ErrInvalidSPIBus = errors.New("machine: SPI bus is invalid") @@ -275,6 +287,19 @@ CPUFrequency returns the current CPU frequency of the chip. Currently it is a fixed frequency but it may allow changing in the future. +### func GetRNG + +```go +func GetRNG() (ret uint32, err error) +``` + +GetRNG returns 32-bit random numbers using the ESP32-C3 true random number generator, +Random numbers are generated based on the thermal noise in the system and the +asynchronous clock mismatch. +For maximum entropy also make sure that the SAR_ADC is enabled. +See esp32-c3_technical_reference_manual_en.pdf p.524 + + ### func InitSerial ```go @@ -687,6 +712,25 @@ SPIConfig is used to store config info for SPI. +## type Serialer + +```go +type Serialer interface { + WriteByte(c byte) error + Write(data []byte) (n int, err error) + Configure(config UARTConfig) error + Buffered() int + ReadByte() (byte, error) + DTR() bool + RTS() bool +} +``` + + + + + + ## type UART ```go @@ -770,15 +814,18 @@ func (uart *UART) SetFormat(dataBits, stopBits int, parity UARTParity) error func (uart *UART) Write(data []byte) (n int, err error) ``` -Write data to the UART. +Write data over the UART's Tx. +This function blocks until the data is finished being sent. ### func (*UART) WriteByte ```go -func (uart *UART) WriteByte(b byte) error +func (uart *UART) WriteByte(c byte) error ``` +WriteByte writes a byte of data over the UART's Tx. +This function blocks until the data is finished being sent. @@ -790,6 +837,8 @@ type UARTConfig struct { BaudRate uint32 TX Pin RX Pin + RTS Pin + CTS Pin } ``` @@ -813,3 +862,75 @@ UARTParity is the parity setting to be used for UART communication. +## type USB_DEVICE + +```go +type USB_DEVICE struct { + Bus *esp.USB_DEVICE_Type +} +``` + +USB Serial/JTAG Controller +See esp32-c3_technical_reference_manual_en.pdf +pg. 736 + + + +### func (*USB_DEVICE) Buffered + +```go +func (usbdev *USB_DEVICE) Buffered() int +``` + + + +### func (*USB_DEVICE) Configure + +```go +func (usbdev *USB_DEVICE) Configure(config UARTConfig) error +``` + + + +### func (*USB_DEVICE) DTR + +```go +func (usbdev *USB_DEVICE) DTR() bool +``` + + + +### func (*USB_DEVICE) RTS + +```go +func (usbdev *USB_DEVICE) RTS() bool +``` + + + +### func (*USB_DEVICE) ReadByte + +```go +func (usbdev *USB_DEVICE) ReadByte() (byte, error) +``` + + + +### func (*USB_DEVICE) Write + +```go +func (usbdev *USB_DEVICE) Write(data []byte) (n int, err error) +``` + + + +### func (*USB_DEVICE) WriteByte + +```go +func (usbdev *USB_DEVICE) WriteByte(c byte) error +``` + + + + + diff --git a/content/docs/reference/microcontrollers/machine/maixbit.md b/content/docs/reference/microcontrollers/machine/maixbit.md index 5767b6ab..f9f95218 100644 --- a/content/docs/reference/microcontrollers/machine/maixbit.md +++ b/content/docs/reference/microcontrollers/machine/maixbit.md @@ -742,6 +742,15 @@ is a shortcut to easily read such registers. Also, it only works for devices with 7-bit addresses, which is the vast majority. +### func (*I2C) SetBaudRate + +```go +func (i2c *I2C) SetBaudRate(br uint32) error +``` + +SetBaudRate sets the communication speed for I2C. + + ### func (*I2C) Tx ```go @@ -1241,15 +1250,18 @@ Usually called by the IRQ handler for a machine. func (uart *UART) Write(data []byte) (n int, err error) ``` -Write data to the UART. +Write data over the UART's Tx. +This function blocks until the data is finished being sent. ### func (*UART) WriteByte ```go -func (uart *UART) WriteByte(c byte) +func (uart *UART) WriteByte(c byte) error ``` +WriteByte writes a byte of data over the UART's Tx. +This function blocks until the data is finished being sent. @@ -1261,6 +1273,8 @@ type UARTConfig struct { BaudRate uint32 TX Pin RX Pin + RTS Pin + CTS Pin } ``` diff --git a/content/docs/reference/microcontrollers/machine/microbit.md b/content/docs/reference/microcontrollers/machine/microbit.md index 09541f86..c9ff6aa7 100644 --- a/content/docs/reference/microcontrollers/machine/microbit.md +++ b/content/docs/reference/microcontrollers/machine/microbit.md @@ -383,6 +383,26 @@ func CPUReset() CPUReset performs a hard system reset. +### func DeviceID + +```go +func DeviceID() []byte +``` + +DeviceID returns an identifier that is unique within +a particular chipset. + +The identity is one burnt into the MCU itself, or the +flash chip at time of manufacture. + +It's possible that two different vendors may allocate +the same DeviceID, so callers should take this into +account if needing to generate a globally unique id. + +The length of the hardware ID is vendor-specific, but +8 bytes (64 bits) is common. + + ### func FlashDataEnd ```go @@ -573,6 +593,16 @@ is a shortcut to easily read such registers. Also, it only works for devices with 7-bit addresses, which is the vast majority. +### func (*I2C) SetBaudRate + +```go +func (i2c *I2C) SetBaudRate(br uint32) error +``` + +SetBaudRate sets the I2C frequency. It has the side effect of also +enabling the I2C hardware if disabled beforehand. + + ### func (*I2C) Tx ```go @@ -948,7 +978,7 @@ SPI on the NRF. ### func (SPI) Configure ```go -func (spi SPI) Configure(config SPIConfig) +func (spi SPI) Configure(config SPIConfig) error ``` Configure is intended to setup the SPI interface. @@ -1083,7 +1113,8 @@ SetBaudRate sets the communication speed for the UART. func (uart *UART) Write(data []byte) (n int, err error) ``` -Write data to the UART. +Write data over the UART's Tx. +This function blocks until the data is finished being sent. ### func (*UART) WriteByte @@ -1092,7 +1123,8 @@ Write data to the UART. func (uart *UART) WriteByte(c byte) error ``` -WriteByte writes a byte of data to the UART. +WriteByte writes a byte of data over the UART's Tx. +This function blocks until the data is finished being sent. @@ -1104,6 +1136,8 @@ type UARTConfig struct { BaudRate uint32 TX Pin RX Pin + RTS Pin + CTS Pin } ``` diff --git a/content/docs/reference/microcontrollers/machine/nodemcu.md b/content/docs/reference/microcontrollers/machine/nodemcu.md index 8487307d..3ddc6eef 100644 --- a/content/docs/reference/microcontrollers/machine/nodemcu.md +++ b/content/docs/reference/microcontrollers/machine/nodemcu.md @@ -587,7 +587,8 @@ Usually called by the IRQ handler for a machine. func (uart *UART) Write(data []byte) (n int, err error) ``` -Write data to the UART. +Write data over the UART's Tx. +This function blocks until the data is finished being sent. ### func (*UART) WriteByte @@ -596,8 +597,8 @@ Write data to the UART. func (uart *UART) WriteByte(c byte) error ``` -WriteByte writes a single byte to the output buffer. Note that the hardware -includes a buffer of 128 bytes which will be used first. +WriteByte writes a byte of data over the UART's Tx. +This function blocks until the data is finished being sent. @@ -609,6 +610,8 @@ type UARTConfig struct { BaudRate uint32 TX Pin RX Pin + RTS Pin + CTS Pin } ``` diff --git a/content/docs/reference/microcontrollers/machine/nucleo-f103rb.md b/content/docs/reference/microcontrollers/machine/nucleo-f103rb.md index 1ea3e7e1..89ff894f 100644 --- a/content/docs/reference/microcontrollers/machine/nucleo-f103rb.md +++ b/content/docs/reference/microcontrollers/machine/nucleo-f103rb.md @@ -166,6 +166,18 @@ const ( I2C fast mode (Fm) duty cycle +```go +const ( + // WatchdogMaxTimeout in milliseconds (32.768s) + // + // Timeout is based on 12-bit counter with /256 divider on + // 32.768kHz clock. See 21.3.3 of RM0090 for table. + WatchdogMaxTimeout = ((0xfff + 1) * 256 * 1024) / 32768 +) +``` + + + ```go const PWM_MODE1 = 0x6 ``` @@ -399,6 +411,14 @@ var ( +```go +var ( + Watchdog = &watchdogImpl{} +) +``` + + + ```go var ( SPI1 = SPI{Bus: stm32.SPI1} @@ -652,6 +672,20 @@ func CPUReset() CPUReset performs a hard system reset. +### func DeviceID + +```go +func DeviceID() []byte +``` + +DeviceID returns an identifier that is unique within +a particular chipset. + +The identity is one burnt into the MCU itself. + +The length of the device ID for STM32 is 12 bytes (96 bits). + + ### func InitADC ```go @@ -775,6 +809,15 @@ is a shortcut to easily read such registers. Also, it only works for devices with 7-bit addresses, which is the vast majority. +### func (*I2C) SetBaudRate + +```go +func (i2c *I2C) SetBaudRate(br uint32) error +``` + +SetBaudRate sets the communication speed for I2C. + + ### func (*I2C) Tx ```go @@ -1162,7 +1205,7 @@ type SPI struct { ### func (SPI) Configure ```go -func (spi SPI) Configure(config SPIConfig) +func (spi SPI) Configure(config SPIConfig) error ``` Configure is intended to setup the STM32 SPI1 interface. @@ -1482,7 +1525,8 @@ routines for calculation func (uart *UART) Write(data []byte) (n int, err error) ``` -Write data to the UART. +Write data over the UART's Tx. +This function blocks until the data is finished being sent. ### func (*UART) WriteByte @@ -1491,7 +1535,8 @@ Write data to the UART. func (uart *UART) WriteByte(c byte) error ``` -WriteByte writes a byte of data to the UART. +WriteByte writes a byte of data over the UART's Tx. +This function blocks until the data is finished being sent. @@ -1503,6 +1548,8 @@ type UARTConfig struct { BaudRate uint32 TX Pin RX Pin + RTS Pin + CTS Pin } ``` @@ -1526,3 +1573,21 @@ UARTParity is the parity setting to be used for UART communication. +## type WatchdogConfig + +```go +type WatchdogConfig struct { + // The timeout (in milliseconds) before the watchdog fires. + // + // If the requested timeout exceeds `MaxTimeout` it will be rounded + // down. + TimeoutMillis uint32 +} +``` + +WatchdogConfig holds configuration for the watchdog timer. + + + + + diff --git a/content/docs/reference/microcontrollers/machine/nucleo-f722ze.md b/content/docs/reference/microcontrollers/machine/nucleo-f722ze.md index 1636b86f..93b04e95 100644 --- a/content/docs/reference/microcontrollers/machine/nucleo-f722ze.md +++ b/content/docs/reference/microcontrollers/machine/nucleo-f722ze.md @@ -160,6 +160,18 @@ const ( +```go +const ( + // WatchdogMaxTimeout in milliseconds (32.768s) + // + // Timeout is based on 12-bit counter with /256 divider on + // 32.768kHz clock. See 21.3.3 of RM0090 for table. + WatchdogMaxTimeout = ((0xfff + 1) * 256 * 1024) / 32768 +) +``` + + + ```go const ( // Mode Flag @@ -479,6 +491,14 @@ var ( +```go +var ( + Watchdog = &watchdogImpl{} +) +``` + + + ```go var ( TIM1 = TIM{ @@ -801,6 +821,20 @@ func CPUReset() CPUReset performs a hard system reset. +### func DeviceID + +```go +func DeviceID() []byte +``` + +DeviceID returns an identifier that is unique within +a particular chipset. + +The identity is one burnt into the MCU itself. + +The length of the device ID for STM32 is 12 bytes (96 bits). + + ### func GetRNG ```go @@ -905,6 +939,15 @@ is a shortcut to easily read such registers. Also, it only works for devices with 7-bit addresses, which is the vast majority. +### func (*I2C) SetBaudRate + +```go +func (i2c *I2C) SetBaudRate(br uint32) error +``` + +SetBaudRate sets the communication speed for I2C. + + ### func (*I2C) Tx ```go @@ -1554,7 +1597,8 @@ routines for calculation func (uart *UART) Write(data []byte) (n int, err error) ``` -Write data to the UART. +Write data over the UART's Tx. +This function blocks until the data is finished being sent. ### func (*UART) WriteByte @@ -1563,7 +1607,8 @@ Write data to the UART. func (uart *UART) WriteByte(c byte) error ``` -WriteByte writes a byte of data to the UART. +WriteByte writes a byte of data over the UART's Tx. +This function blocks until the data is finished being sent. @@ -1575,6 +1620,8 @@ type UARTConfig struct { BaudRate uint32 TX Pin RX Pin + RTS Pin + CTS Pin } ``` @@ -1598,3 +1645,21 @@ UARTParity is the parity setting to be used for UART communication. +## type WatchdogConfig + +```go +type WatchdogConfig struct { + // The timeout (in milliseconds) before the watchdog fires. + // + // If the requested timeout exceeds `MaxTimeout` it will be rounded + // down. + TimeoutMillis uint32 +} +``` + +WatchdogConfig holds configuration for the watchdog timer. + + + + + diff --git a/content/docs/reference/microcontrollers/machine/nucleo-l031k6.md b/content/docs/reference/microcontrollers/machine/nucleo-l031k6.md index a6aff4a7..1b7f6859 100644 --- a/content/docs/reference/microcontrollers/machine/nucleo-l031k6.md +++ b/content/docs/reference/microcontrollers/machine/nucleo-l031k6.md @@ -181,6 +181,18 @@ const ( +```go +const ( + // WatchdogMaxTimeout in milliseconds (32.768s) + // + // Timeout is based on 12-bit counter with /256 divider on + // 32.768kHz clock. See 21.3.3 of RM0090 for table. + WatchdogMaxTimeout = ((0xfff + 1) * 256 * 1024) / 32768 +) +``` + + + ```go const ( // Mode Flag @@ -435,6 +447,14 @@ var ( +```go +var ( + Watchdog = &watchdogImpl{} +) +``` + + + ```go var ( TIM2 = TIM{ @@ -563,6 +583,20 @@ func CPUReset() CPUReset performs a hard system reset. +### func DeviceID + +```go +func DeviceID() []byte +``` + +DeviceID returns an identifier that is unique within +a particular chipset. + +The identity is one burnt into the MCU itself. + +The length of the device ID for STM32 is 12 bytes (96 bits). + + ### func InitSerial ```go @@ -658,6 +692,15 @@ is a shortcut to easily read such registers. Also, it only works for devices with 7-bit addresses, which is the vast majority. +### func (*I2C) SetBaudRate + +```go +func (i2c *I2C) SetBaudRate(br uint32) error +``` + +SetBaudRate sets the communication speed for I2C. + + ### func (*I2C) Tx ```go @@ -1064,7 +1107,7 @@ SPI on the STM32Fxxx using MODER / alternate function pins ### func (SPI) Configure ```go -func (spi SPI) Configure(config SPIConfig) +func (spi SPI) Configure(config SPIConfig) error ``` Configure is intended to setup the STM32 SPI1 interface. @@ -1384,7 +1427,8 @@ routines for calculation func (uart *UART) Write(data []byte) (n int, err error) ``` -Write data to the UART. +Write data over the UART's Tx. +This function blocks until the data is finished being sent. ### func (*UART) WriteByte @@ -1393,7 +1437,8 @@ Write data to the UART. func (uart *UART) WriteByte(c byte) error ``` -WriteByte writes a byte of data to the UART. +WriteByte writes a byte of data over the UART's Tx. +This function blocks until the data is finished being sent. @@ -1405,6 +1450,8 @@ type UARTConfig struct { BaudRate uint32 TX Pin RX Pin + RTS Pin + CTS Pin } ``` @@ -1428,3 +1475,21 @@ UARTParity is the parity setting to be used for UART communication. +## type WatchdogConfig + +```go +type WatchdogConfig struct { + // The timeout (in milliseconds) before the watchdog fires. + // + // If the requested timeout exceeds `MaxTimeout` it will be rounded + // down. + TimeoutMillis uint32 +} +``` + +WatchdogConfig holds configuration for the watchdog timer. + + + + + diff --git a/content/docs/reference/microcontrollers/machine/nucleo-l432kc.md b/content/docs/reference/microcontrollers/machine/nucleo-l432kc.md index 7f389d80..7c3b4d59 100644 --- a/content/docs/reference/microcontrollers/machine/nucleo-l432kc.md +++ b/content/docs/reference/microcontrollers/machine/nucleo-l432kc.md @@ -183,6 +183,18 @@ const ( +```go +const ( + // WatchdogMaxTimeout in milliseconds (32.768s) + // + // Timeout is based on 12-bit counter with /256 divider on + // 32.768kHz clock. See 21.3.3 of RM0090 for table. + WatchdogMaxTimeout = ((0xfff + 1) * 256 * 1024) / 32768 +) +``` + + + ```go const ( // Mode Flag @@ -453,6 +465,14 @@ var Flash flashBlockDevice +```go +var ( + Watchdog = &watchdogImpl{} +) +``` + + + ```go var ( TIM1 = TIM{ @@ -619,6 +639,20 @@ func CPUReset() CPUReset performs a hard system reset. +### func DeviceID + +```go +func DeviceID() []byte +``` + +DeviceID returns an identifier that is unique within +a particular chipset. + +The identity is one burnt into the MCU itself. + +The length of the device ID for STM32 is 12 bytes (96 bits). + + ### func FlashDataEnd ```go @@ -780,6 +814,15 @@ is a shortcut to easily read such registers. Also, it only works for devices with 7-bit addresses, which is the vast majority. +### func (*I2C) SetBaudRate + +```go +func (i2c *I2C) SetBaudRate(br uint32) error +``` + +SetBaudRate sets the communication speed for I2C. + + ### func (*I2C) Tx ```go @@ -1186,7 +1229,7 @@ SPI on the STM32Fxxx using MODER / alternate function pins ### func (SPI) Configure ```go -func (spi SPI) Configure(config SPIConfig) +func (spi SPI) Configure(config SPIConfig) error ``` Configure is intended to setup the STM32 SPI1 interface. @@ -1506,7 +1549,8 @@ routines for calculation func (uart *UART) Write(data []byte) (n int, err error) ``` -Write data to the UART. +Write data over the UART's Tx. +This function blocks until the data is finished being sent. ### func (*UART) WriteByte @@ -1515,7 +1559,8 @@ Write data to the UART. func (uart *UART) WriteByte(c byte) error ``` -WriteByte writes a byte of data to the UART. +WriteByte writes a byte of data over the UART's Tx. +This function blocks until the data is finished being sent. @@ -1527,6 +1572,8 @@ type UARTConfig struct { BaudRate uint32 TX Pin RX Pin + RTS Pin + CTS Pin } ``` @@ -1550,3 +1597,21 @@ UARTParity is the parity setting to be used for UART communication. +## type WatchdogConfig + +```go +type WatchdogConfig struct { + // The timeout (in milliseconds) before the watchdog fires. + // + // If the requested timeout exceeds `MaxTimeout` it will be rounded + // down. + TimeoutMillis uint32 +} +``` + +WatchdogConfig holds configuration for the watchdog timer. + + + + + diff --git a/content/docs/reference/microcontrollers/machine/nucleo-l552ze.md b/content/docs/reference/microcontrollers/machine/nucleo-l552ze.md index d380dd43..0d848e9b 100644 --- a/content/docs/reference/microcontrollers/machine/nucleo-l552ze.md +++ b/content/docs/reference/microcontrollers/machine/nucleo-l552ze.md @@ -148,6 +148,18 @@ const ( +```go +const ( + // WatchdogMaxTimeout in milliseconds (32.768s) + // + // Timeout is based on 12-bit counter with /256 divider on + // 32.768kHz clock. See 21.3.3 of RM0090 for table. + WatchdogMaxTimeout = ((0xfff + 1) * 256 * 1024) / 32768 +) +``` + + + ```go const ( // Mode Flag @@ -437,6 +449,14 @@ var ( +```go +var ( + Watchdog = &watchdogImpl{} +) +``` + + + ```go var ( TIM1 = TIM{ @@ -621,6 +641,20 @@ func CPUReset() CPUReset performs a hard system reset. +### func DeviceID + +```go +func DeviceID() []byte +``` + +DeviceID returns an identifier that is unique within +a particular chipset. + +The identity is one burnt into the MCU itself. + +The length of the device ID for STM32 is 12 bytes (96 bits). + + ### func GetRNG ```go @@ -725,6 +759,15 @@ is a shortcut to easily read such registers. Also, it only works for devices with 7-bit addresses, which is the vast majority. +### func (*I2C) SetBaudRate + +```go +func (i2c *I2C) SetBaudRate(br uint32) error +``` + +SetBaudRate sets the communication speed for I2C. + + ### func (*I2C) Tx ```go @@ -1374,7 +1417,8 @@ routines for calculation func (uart *UART) Write(data []byte) (n int, err error) ``` -Write data to the UART. +Write data over the UART's Tx. +This function blocks until the data is finished being sent. ### func (*UART) WriteByte @@ -1383,7 +1427,8 @@ Write data to the UART. func (uart *UART) WriteByte(c byte) error ``` -WriteByte writes a byte of data to the UART. +WriteByte writes a byte of data over the UART's Tx. +This function blocks until the data is finished being sent. @@ -1395,6 +1440,8 @@ type UARTConfig struct { BaudRate uint32 TX Pin RX Pin + RTS Pin + CTS Pin } ``` @@ -1418,3 +1465,21 @@ UARTParity is the parity setting to be used for UART communication. +## type WatchdogConfig + +```go +type WatchdogConfig struct { + // The timeout (in milliseconds) before the watchdog fires. + // + // If the requested timeout exceeds `MaxTimeout` it will be rounded + // down. + TimeoutMillis uint32 +} +``` + +WatchdogConfig holds configuration for the watchdog timer. + + + + + diff --git a/content/docs/reference/microcontrollers/machine/nucleo-wl55jc.md b/content/docs/reference/microcontrollers/machine/nucleo-wl55jc.md index 3efea05b..269e3357 100644 --- a/content/docs/reference/microcontrollers/machine/nucleo-wl55jc.md +++ b/content/docs/reference/microcontrollers/machine/nucleo-wl55jc.md @@ -154,6 +154,18 @@ const ( +```go +const ( + // WatchdogMaxTimeout in milliseconds (32.768s) + // + // Timeout is based on 12-bit counter with /256 divider on + // 32.768kHz clock. See 21.3.3 of RM0090 for table. + WatchdogMaxTimeout = ((0xfff + 1) * 256 * 1024) / 32768 +) +``` + + + ```go const ( // Mode Flag @@ -394,6 +406,14 @@ var Flash flashBlockDevice +```go +var ( + Watchdog = &watchdogImpl{} +) +``` + + + ```go var ( TIM1 = TIM{ @@ -493,6 +513,20 @@ func CPUReset() CPUReset performs a hard system reset. +### func DeviceID + +```go +func DeviceID() []byte +``` + +DeviceID returns an identifier that is unique within +a particular chipset. + +The identity is one burnt into the MCU itself. + +The length of the device ID for STM32 is 12 bytes (96 bits). + + ### func FlashDataEnd ```go @@ -654,6 +688,15 @@ is a shortcut to easily read such registers. Also, it only works for devices with 7-bit addresses, which is the vast majority. +### func (*I2C) SetBaudRate + +```go +func (i2c *I2C) SetBaudRate(br uint32) error +``` + +SetBaudRate sets the communication speed for I2C. + + ### func (*I2C) Tx ```go @@ -1059,7 +1102,7 @@ type SPI struct { ### func (SPI) Configure ```go -func (spi SPI) Configure(config SPIConfig) +func (spi SPI) Configure(config SPIConfig) error ``` Configure is intended to setup the STM32 SPI1 interface. @@ -1379,7 +1422,8 @@ routines for calculation func (uart *UART) Write(data []byte) (n int, err error) ``` -Write data to the UART. +Write data over the UART's Tx. +This function blocks until the data is finished being sent. ### func (*UART) WriteByte @@ -1388,7 +1432,8 @@ Write data to the UART. func (uart *UART) WriteByte(c byte) error ``` -WriteByte writes a byte of data to the UART. +WriteByte writes a byte of data over the UART's Tx. +This function blocks until the data is finished being sent. @@ -1400,6 +1445,8 @@ type UARTConfig struct { BaudRate uint32 TX Pin RX Pin + RTS Pin + CTS Pin } ``` @@ -1423,3 +1470,21 @@ UARTParity is the parity setting to be used for UART communication. +## type WatchdogConfig + +```go +type WatchdogConfig struct { + // The timeout (in milliseconds) before the watchdog fires. + // + // If the requested timeout exceeds `MaxTimeout` it will be rounded + // down. + TimeoutMillis uint32 +} +``` + +WatchdogConfig holds configuration for the watchdog timer. + + + + + diff --git a/content/docs/reference/microcontrollers/machine/pca10031.md b/content/docs/reference/microcontrollers/machine/pca10031.md index 07e39bdc..bcb4fd94 100644 --- a/content/docs/reference/microcontrollers/machine/pca10031.md +++ b/content/docs/reference/microcontrollers/machine/pca10031.md @@ -331,6 +331,26 @@ func CPUReset() CPUReset performs a hard system reset. +### func DeviceID + +```go +func DeviceID() []byte +``` + +DeviceID returns an identifier that is unique within +a particular chipset. + +The identity is one burnt into the MCU itself, or the +flash chip at time of manufacture. + +It's possible that two different vendors may allocate +the same DeviceID, so callers should take this into +account if needing to generate a globally unique id. + +The length of the hardware ID is vendor-specific, but +8 bytes (64 bits) is common. + + ### func FlashDataEnd ```go @@ -521,6 +541,16 @@ is a shortcut to easily read such registers. Also, it only works for devices with 7-bit addresses, which is the vast majority. +### func (*I2C) SetBaudRate + +```go +func (i2c *I2C) SetBaudRate(br uint32) error +``` + +SetBaudRate sets the I2C frequency. It has the side effect of also +enabling the I2C hardware if disabled beforehand. + + ### func (*I2C) Tx ```go @@ -896,7 +926,7 @@ SPI on the NRF. ### func (SPI) Configure ```go -func (spi SPI) Configure(config SPIConfig) +func (spi SPI) Configure(config SPIConfig) error ``` Configure is intended to setup the SPI interface. @@ -1031,7 +1061,8 @@ SetBaudRate sets the communication speed for the UART. func (uart *UART) Write(data []byte) (n int, err error) ``` -Write data to the UART. +Write data over the UART's Tx. +This function blocks until the data is finished being sent. ### func (*UART) WriteByte @@ -1040,7 +1071,8 @@ Write data to the UART. func (uart *UART) WriteByte(c byte) error ``` -WriteByte writes a byte of data to the UART. +WriteByte writes a byte of data over the UART's Tx. +This function blocks until the data is finished being sent. @@ -1052,6 +1084,8 @@ type UARTConfig struct { BaudRate uint32 TX Pin RX Pin + RTS Pin + CTS Pin } ``` diff --git a/content/docs/reference/microcontrollers/machine/pca10040.md b/content/docs/reference/microcontrollers/machine/pca10040.md index 267d3de7..8782f608 100644 --- a/content/docs/reference/microcontrollers/machine/pca10040.md +++ b/content/docs/reference/microcontrollers/machine/pca10040.md @@ -368,6 +368,26 @@ func CPUReset() CPUReset performs a hard system reset. +### func DeviceID + +```go +func DeviceID() []byte +``` + +DeviceID returns an identifier that is unique within +a particular chipset. + +The identity is one burnt into the MCU itself, or the +flash chip at time of manufacture. + +It's possible that two different vendors may allocate +the same DeviceID, so callers should take this into +account if needing to generate a globally unique id. + +The length of the hardware ID is vendor-specific, but +8 bytes (64 bits) is common. + + ### func FlashDataEnd ```go @@ -558,6 +578,16 @@ is a shortcut to easily read such registers. Also, it only works for devices with 7-bit addresses, which is the vast majority. +### func (*I2C) SetBaudRate + +```go +func (i2c *I2C) SetBaudRate(br uint32) error +``` + +SetBaudRate sets the I2C frequency. It has the side effect of also +enabling the I2C hardware if disabled beforehand. + + ### func (*I2C) Tx ```go @@ -1038,7 +1068,7 @@ SPI on the NRF. ### func (SPI) Configure ```go -func (spi SPI) Configure(config SPIConfig) +func (spi SPI) Configure(config SPIConfig) error ``` Configure is intended to setup the SPI interface. @@ -1161,7 +1191,8 @@ SetBaudRate sets the communication speed for the UART. func (uart *UART) Write(data []byte) (n int, err error) ``` -Write data to the UART. +Write data over the UART's Tx. +This function blocks until the data is finished being sent. ### func (*UART) WriteByte @@ -1170,7 +1201,8 @@ Write data to the UART. func (uart *UART) WriteByte(c byte) error ``` -WriteByte writes a byte of data to the UART. +WriteByte writes a byte of data over the UART's Tx. +This function blocks until the data is finished being sent. @@ -1182,6 +1214,8 @@ type UARTConfig struct { BaudRate uint32 TX Pin RX Pin + RTS Pin + CTS Pin } ``` diff --git a/content/docs/reference/microcontrollers/machine/stm32f4disco.md b/content/docs/reference/microcontrollers/machine/stm32f4disco.md index 77bd5a77..46694701 100644 --- a/content/docs/reference/microcontrollers/machine/stm32f4disco.md +++ b/content/docs/reference/microcontrollers/machine/stm32f4disco.md @@ -192,6 +192,18 @@ const ( I2C fast mode (Fm) duty cycle +```go +const ( + // WatchdogMaxTimeout in milliseconds (32.768s) + // + // Timeout is based on 12-bit counter with /256 divider on + // 32.768kHz clock. See 21.3.3 of RM0090 for table. + WatchdogMaxTimeout = ((0xfff + 1) * 256 * 1024) / 32768 +) +``` + + + ```go const ( // Mode Flag @@ -556,6 +568,14 @@ var Flash flashBlockDevice +```go +var ( + Watchdog = &watchdogImpl{} +) +``` + + + ```go var ( TIM1 = TIM{ @@ -788,6 +808,20 @@ func CPUReset() CPUReset performs a hard system reset. +### func DeviceID + +```go +func DeviceID() []byte +``` + +DeviceID returns an identifier that is unique within +a particular chipset. + +The identity is one burnt into the MCU itself. + +The length of the device ID for STM32 is 12 bytes (96 bits). + + ### func FlashDataEnd ```go @@ -978,6 +1012,15 @@ is a shortcut to easily read such registers. Also, it only works for devices with 7-bit addresses, which is the vast majority. +### func (*I2C) SetBaudRate + +```go +func (i2c *I2C) SetBaudRate(br uint32) error +``` + +SetBaudRate sets the communication speed for I2C. + + ### func (*I2C) Tx ```go @@ -1385,7 +1428,7 @@ type SPI struct { ### func (SPI) Configure ```go -func (spi SPI) Configure(config SPIConfig) +func (spi SPI) Configure(config SPIConfig) error ``` Configure is intended to setup the STM32 SPI1 interface. @@ -1705,7 +1748,8 @@ routines for calculation func (uart *UART) Write(data []byte) (n int, err error) ``` -Write data to the UART. +Write data over the UART's Tx. +This function blocks until the data is finished being sent. ### func (*UART) WriteByte @@ -1714,7 +1758,8 @@ Write data to the UART. func (uart *UART) WriteByte(c byte) error ``` -WriteByte writes a byte of data to the UART. +WriteByte writes a byte of data over the UART's Tx. +This function blocks until the data is finished being sent. @@ -1726,6 +1771,8 @@ type UARTConfig struct { BaudRate uint32 TX Pin RX Pin + RTS Pin + CTS Pin } ``` @@ -1749,3 +1796,21 @@ UARTParity is the parity setting to be used for UART communication. +## type WatchdogConfig + +```go +type WatchdogConfig struct { + // The timeout (in milliseconds) before the watchdog fires. + // + // If the requested timeout exceeds `MaxTimeout` it will be rounded + // down. + TimeoutMillis uint32 +} +``` + +WatchdogConfig holds configuration for the watchdog timer. + + + + + diff --git a/content/docs/reference/microcontrollers/machine/swan.md b/content/docs/reference/microcontrollers/machine/swan.md index 21750e2d..b1076cea 100644 --- a/content/docs/reference/microcontrollers/machine/swan.md +++ b/content/docs/reference/microcontrollers/machine/swan.md @@ -134,6 +134,18 @@ const ( +```go +const ( + // WatchdogMaxTimeout in milliseconds (32.768s) + // + // Timeout is based on 12-bit counter with /256 divider on + // 32.768kHz clock. See 21.3.3 of RM0090 for table. + WatchdogMaxTimeout = ((0xfff + 1) * 256 * 1024) / 32768 +) +``` + + + ```go const ( // Mode Flag @@ -403,6 +415,14 @@ var Flash flashBlockDevice +```go +var ( + Watchdog = &watchdogImpl{} +) +``` + + + ```go var ( TIM1 = TIM{ @@ -569,6 +589,20 @@ func CPUReset() CPUReset performs a hard system reset. +### func DeviceID + +```go +func DeviceID() []byte +``` + +DeviceID returns an identifier that is unique within +a particular chipset. + +The identity is one burnt into the MCU itself. + +The length of the device ID for STM32 is 12 bytes (96 bits). + + ### func FlashDataEnd ```go @@ -730,6 +764,15 @@ is a shortcut to easily read such registers. Also, it only works for devices with 7-bit addresses, which is the vast majority. +### func (*I2C) SetBaudRate + +```go +func (i2c *I2C) SetBaudRate(br uint32) error +``` + +SetBaudRate sets the communication speed for I2C. + + ### func (*I2C) Tx ```go @@ -1136,7 +1179,7 @@ SPI on the STM32Fxxx using MODER / alternate function pins ### func (SPI) Configure ```go -func (spi SPI) Configure(config SPIConfig) +func (spi SPI) Configure(config SPIConfig) error ``` Configure is intended to setup the STM32 SPI1 interface. @@ -1456,7 +1499,8 @@ routines for calculation func (uart *UART) Write(data []byte) (n int, err error) ``` -Write data to the UART. +Write data over the UART's Tx. +This function blocks until the data is finished being sent. ### func (*UART) WriteByte @@ -1465,7 +1509,8 @@ Write data to the UART. func (uart *UART) WriteByte(c byte) error ``` -WriteByte writes a byte of data to the UART. +WriteByte writes a byte of data over the UART's Tx. +This function blocks until the data is finished being sent. @@ -1477,6 +1522,8 @@ type UARTConfig struct { BaudRate uint32 TX Pin RX Pin + RTS Pin + CTS Pin } ``` @@ -1500,3 +1547,21 @@ UARTParity is the parity setting to be used for UART communication. +## type WatchdogConfig + +```go +type WatchdogConfig struct { + // The timeout (in milliseconds) before the watchdog fires. + // + // If the requested timeout exceeds `MaxTimeout` it will be rounded + // down. + TimeoutMillis uint32 +} +``` + +WatchdogConfig holds configuration for the watchdog timer. + + + + + diff --git a/content/docs/reference/microcontrollers/machine/teensy40.md b/content/docs/reference/microcontrollers/machine/teensy40.md index d0191a37..1869f768 100644 --- a/content/docs/reference/microcontrollers/machine/teensy40.md +++ b/content/docs/reference/microcontrollers/machine/teensy40.md @@ -193,6 +193,49 @@ const ( #===========#==========#=============#=========-=====# +```go +const ( + TWI_FREQ_100KHZ = 100000 + TWI_FREQ_400KHZ = 400000 +) +``` + +TWI_FREQ is the I2C bus speed. Normally either 100 kHz, or 400 kHz for high-speed bus. + +Deprecated: use 100 * machine.KHz or 400 * machine.KHz instead. + + +```go +const ( + // I2CReceive indicates target has received a message from the controller. + I2CReceive I2CTargetEvent = iota + + // I2CRequest indicates the controller is expecting a message from the target. + I2CRequest + + // I2CFinish indicates the controller has ended the transaction. + // + // I2C controllers can chain multiple receive/request messages without + // relinquishing the bus by doing 'restarts'. I2CFinish indicates the + // bus has been relinquished by an I2C 'stop'. + I2CFinish +) +``` + + + +```go +const ( + // I2CModeController represents an I2C peripheral in controller mode. + I2CModeController I2CMode = iota + + // I2CModeTarget represents an I2C peripheral in target mode. + I2CModeTarget +) +``` + + + ```go const Device = deviceName ``` @@ -838,16 +881,16 @@ type I2C struct { ### func (*I2C) Configure ```go -func (i2c *I2C) Configure(config I2CConfig) +func (i2c *I2C) Configure(config I2CConfig) error ``` Configure is intended to setup an I2C interface for transmit/receive. -### func (I2C) ReadRegister +### func (*I2C) ReadRegister ```go -func (i2c I2C) ReadRegister(address uint8, register uint8, data []byte) error +func (i2c *I2C) ReadRegister(address uint8, register uint8, data []byte) error ``` ReadRegister transmits the register, restarts the connection as a read @@ -858,6 +901,29 @@ is a shortcut to easily read such registers. Also, it only works for devices with 7-bit addresses, which is the vast majority. +### func (I2C) ReadRegisterEx + +```go +func (i2c I2C) ReadRegisterEx(address uint8, register uint8, data []byte) error +``` + +ReadRegisterEx transmits the register, restarts the connection as a read +operation, and reads the response. + +Many I2C-compatible devices are organized in terms of registers. This method +is a shortcut to easily read such registers. Also, it only works for devices +with 7-bit addresses, which is the vast majority. + + +### func (I2C) SetBaudRate + +```go +func (i2c I2C) SetBaudRate(br uint32) error +``` + +SetBaudRate sets the communication speed for I2C. + + ### func (I2C) Tx ```go @@ -866,10 +932,10 @@ func (i2c I2C) Tx(addr uint16, w, r []byte) error -### func (I2C) WriteRegister +### func (*I2C) WriteRegister ```go -func (i2c I2C) WriteRegister(address uint8, register uint8, data []byte) error +func (i2c *I2C) WriteRegister(address uint8, register uint8, data []byte) error ``` WriteRegister transmits first the register and then the data to the @@ -880,6 +946,20 @@ is a shortcut to easily write to such registers. Also, it only works for devices with 7-bit addresses, which is the vast majority. +### func (I2C) WriteRegisterEx + +```go +func (i2c I2C) WriteRegisterEx(address uint8, register uint8, data []byte) error +``` + +WriteRegisterEx transmits first the register and then the data to the +peripheral device. + +Many I2C-compatible devices are organized in terms of registers. This method +is a shortcut to easily write to such registers. Also, it only works for +devices with 7-bit addresses, which is the vast majority. + + ## type I2CConfig @@ -898,6 +978,30 @@ I2CConfig is used to store config info for I2C. +## type I2CMode + +```go +type I2CMode int +``` + +I2CMode determines if an I2C peripheral is in Controller or Target mode. + + + + + +## type I2CTargetEvent + +```go +type I2CTargetEvent uint8 +``` + +I2CTargetEvent reflects events on the I2C bus + + + + + ## type NullSerial ```go @@ -1207,7 +1311,7 @@ type SPI struct { ### func (*SPI) Configure ```go -func (spi *SPI) Configure(config SPIConfig) +func (spi *SPI) Configure(config SPIConfig) error ``` Configure is intended to setup an SPI interface for transmit/receive. @@ -1380,7 +1484,8 @@ been transmitted. func (uart *UART) Write(data []byte) (n int, err error) ``` -Write data to the UART. +Write data over the UART's Tx. +This function blocks until the data is finished being sent. ### func (*UART) WriteByte @@ -1389,7 +1494,8 @@ Write data to the UART. func (uart *UART) WriteByte(c byte) error ``` -WriteByte writes a single byte of data to the UART interface. +WriteByte writes a byte of data over the UART's Tx. +This function blocks until the data is finished being sent. @@ -1401,6 +1507,8 @@ type UARTConfig struct { BaudRate uint32 TX Pin RX Pin + RTS Pin + CTS Pin } ``` diff --git a/content/docs/reference/microcontrollers/machine/x9pro.md b/content/docs/reference/microcontrollers/machine/x9pro.md index 7b4e2460..4e392d9e 100644 --- a/content/docs/reference/microcontrollers/machine/x9pro.md +++ b/content/docs/reference/microcontrollers/machine/x9pro.md @@ -327,6 +327,26 @@ func CPUReset() CPUReset performs a hard system reset. +### func DeviceID + +```go +func DeviceID() []byte +``` + +DeviceID returns an identifier that is unique within +a particular chipset. + +The identity is one burnt into the MCU itself, or the +flash chip at time of manufacture. + +It's possible that two different vendors may allocate +the same DeviceID, so callers should take this into +account if needing to generate a globally unique id. + +The length of the hardware ID is vendor-specific, but +8 bytes (64 bits) is common. + + ### func FlashDataEnd ```go @@ -517,6 +537,16 @@ is a shortcut to easily read such registers. Also, it only works for devices with 7-bit addresses, which is the vast majority. +### func (*I2C) SetBaudRate + +```go +func (i2c *I2C) SetBaudRate(br uint32) error +``` + +SetBaudRate sets the I2C frequency. It has the side effect of also +enabling the I2C hardware if disabled beforehand. + + ### func (*I2C) Tx ```go @@ -997,7 +1027,7 @@ SPI on the NRF. ### func (SPI) Configure ```go -func (spi SPI) Configure(config SPIConfig) +func (spi SPI) Configure(config SPIConfig) error ``` Configure is intended to setup the SPI interface. @@ -1120,7 +1150,8 @@ SetBaudRate sets the communication speed for the UART. func (uart *UART) Write(data []byte) (n int, err error) ``` -Write data to the UART. +Write data over the UART's Tx. +This function blocks until the data is finished being sent. ### func (*UART) WriteByte @@ -1129,7 +1160,8 @@ Write data to the UART. func (uart *UART) WriteByte(c byte) error ``` -WriteByte writes a byte of data to the UART. +WriteByte writes a byte of data over the UART's Tx. +This function blocks until the data is finished being sent. @@ -1141,6 +1173,8 @@ type UARTConfig struct { BaudRate uint32 TX Pin RX Pin + RTS Pin + CTS Pin } ``` diff --git a/doc-gen/main.go b/doc-gen/main.go index 818a48d1..1d430aa3 100644 --- a/doc-gen/main.go +++ b/doc-gen/main.go @@ -105,18 +105,21 @@ func main() { continue } fmt.Println("Generating documentation for:", target) - updateDocumentation(target, path, docPath) + if err := updateDocumentation(target, path, docPath); err != nil { + fmt.Fprintln(os.Stderr, err) + os.Exit(1) + } } } -func updateDocumentation(target, path, docPath string) { +func updateDocumentation(target, path, docPath string) error { // Get the important information from the compiler. cmd := exec.Command("tinygo", "info", target) outBytes, err := cmd.Output() if err != nil { - fmt.Fprintln(os.Stderr, "could not run tinygo:", err) - os.Exit(1) + return fmt.Errorf("could not run tinygo: %v", err) } + var buildTags []string var goos, goarch, goroot string for _, line := range strings.Split(string(outBytes), "\n") { @@ -138,8 +141,7 @@ func updateDocumentation(target, path, docPath string) { } } if len(buildTags) == 0 || goos == "" || goarch == "" || goroot == "" { - fmt.Fprintln(os.Stderr, "could not find all needed properties (build tags, GOOS, GOARCH, GOROOT)") - os.Exit(1) + return fmt.Errorf("could not find all needed properties (build tags, GOOS, GOARCH, GOROOT)") } // Get the list of files that would be compiled for this package. @@ -154,24 +156,26 @@ func updateDocumentation(target, path, docPath string) { // Do some sanity checking. if len(pkgs[0].Errors) != 0 { + fmt.Fprintf(os.Stderr, " sanity check failed with %d error(s)\n", len(pkgs[0].Errors)) for _, err := range pkgs[0].Errors { - fmt.Fprintln(os.Stderr, err) + fmt.Fprintf(os.Stderr, " * %v\n", err) } - os.Exit(1) + return nil + //os.Exit(1) } pkg := pkgs[0] err = writeMachinePackageDoc(path, target, pkg) if err != nil { - fmt.Fprintln(os.Stderr, "error:", err) - os.Exit(1) + return fmt.Errorf("error on write machine package doc: %v", err) } err = updateBoardDocumentation(docPath, pkg, buildTags) if err != nil { - fmt.Fprintln(os.Stderr, "error:", err) - os.Exit(1) + return fmt.Errorf("error on update board documentation: %v", err) } + + return nil } func writeMachinePackageDoc(path, target string, pkg *packages.Package) error {