diff options
author | deadprogram <[email protected]> | 2024-05-06 19:29:11 +0200 |
---|---|---|
committer | Ron Evans <[email protected]> | 2024-05-08 10:57:46 +0200 |
commit | 7d6b667bba801205e32c5ff3b460100b0409fda2 (patch) | |
tree | 244a3fa1238490c055212cffd9d055e96c0a66f0 /src/machine/machine_stm32l0.go | |
parent | 72f30ca6ec13b8c5eaa74e4881839fd7360f37ed (diff) | |
download | tinygo-7d6b667bba801205e32c5ff3b460100b0409fda2.tar.gz tinygo-7d6b667bba801205e32c5ff3b460100b0409fda2.zip |
machine/stm32: add i2c Frequency and SetBaudRate() function for boards that were missing implementation
Signed-off-by: deadprogram <[email protected]>
Diffstat (limited to 'src/machine/machine_stm32l0.go')
-rw-r--r-- | src/machine/machine_stm32l0.go | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/machine/machine_stm32l0.go b/src/machine/machine_stm32l0.go index 844cfccb4..e3fcefb57 100644 --- a/src/machine/machine_stm32l0.go +++ b/src/machine/machine_stm32l0.go @@ -298,9 +298,20 @@ func (spi SPI) configurePins(config SPIConfig) { //---------- I2C related types and code // Gets the value for TIMINGR register -func (i2c I2C) getFreqRange() uint32 { +func (i2c I2C) getFreqRange(br uint32) uint32 { // This is a 'magic' value calculated by STM32CubeMX - // for 80MHz PCLK1. + // for 16MHz PCLK1. // TODO: Do calculations based on PCLK1 - return 0x00303D5B + switch br { + case 10 * KHz: + return 0x40003EFF + case 100 * KHz: + return 0x00303D5B + case 400 * KHz: + return 0x0010061A + case 500 * KHz: + return 0x00000117 + default: + return 0 + } } |