Skip to content

Commit 154c7c6

Browse files
aykevldeadprogram
authored andcommitted
stm32: use stm32-rs SVDs which are of much higher quality
This commit changes the number of wait states for the stm32f103 chip to 2 instead of 4. This gets it back in line with the datasheet, but it also has the side effect of breaking I2C. Therefore, another (seemingly unrelated) change is needed: the i2cTimeout constant must be increased to a higher value to adjust to the lower flash wait states - presumably because the lower number of wait states allows the chip to run code faster.
1 parent 65caf77 commit 154c7c6

24 files changed

+259
-333
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,6 @@
2020
[submodule "lib/picolibc"]
2121
path = lib/picolibc
2222
url = https://github.com/keith-packard/picolibc.git
23+
[submodule "lib/stm32-svd"]
24+
path = lib/stm32-svd
25+
url = https://github.com/tinygo-org/stm32-svd

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ gen-device-kendryte: build/gen-device-svd
130130
GO111MODULE=off $(GO) fmt ./src/device/kendryte
131131

132132
gen-device-stm32: build/gen-device-svd
133-
./build/gen-device-svd -source=https://github.com/posborne/cmsis-svd/tree/master/data/STMicro lib/cmsis-svd/data/STMicro/ src/device/stm32/
133+
./build/gen-device-svd -source=https://github.com/tinygo-org/stm32-svd lib/stm32-svd/svd src/device/stm32/
134134
GO111MODULE=off $(GO) fmt ./src/device/stm32
135135

136136

lib/stm32-svd

Submodule stm32-svd added at 9ec9982

src/device/stm32/stm32-moder-bitfields.go

Lines changed: 0 additions & 57 deletions
This file was deleted.

src/device/stm32/stm32f103xx-bitfields.go

Lines changed: 0 additions & 88 deletions
This file was deleted.

src/device/stm32/stm32f4-altfunc-bitfields.go

Lines changed: 0 additions & 28 deletions
This file was deleted.

src/machine/board_feather-stm32f405.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -122,17 +122,17 @@ var (
122122
UART1 = UART{
123123
Buffer: NewRingBuffer(),
124124
Bus: stm32.USART3,
125-
AltFuncSelector: stm32.AF7_USART1_2_3,
125+
AltFuncSelector: AF7_USART1_2_3,
126126
}
127127
UART2 = UART{
128128
Buffer: NewRingBuffer(),
129129
Bus: stm32.USART6,
130-
AltFuncSelector: stm32.AF8_USART4_5_6,
130+
AltFuncSelector: AF8_USART4_5_6,
131131
}
132132
UART3 = UART{
133133
Buffer: NewRingBuffer(),
134134
Bus: stm32.USART1,
135-
AltFuncSelector: stm32.AF7_USART1_2_3,
135+
AltFuncSelector: AF7_USART1_2_3,
136136
}
137137
UART0 = UART1
138138
)
@@ -181,15 +181,15 @@ const (
181181
var (
182182
SPI1 = SPI{
183183
Bus: stm32.SPI2,
184-
AltFuncSelector: stm32.AF5_SPI1_SPI2,
184+
AltFuncSelector: AF5_SPI1_SPI2,
185185
}
186186
SPI2 = SPI{
187187
Bus: stm32.SPI3,
188-
AltFuncSelector: stm32.AF6_SPI3,
188+
AltFuncSelector: AF6_SPI3,
189189
}
190190
SPI3 = SPI{
191191
Bus: stm32.SPI1,
192-
AltFuncSelector: stm32.AF5_SPI1_SPI2,
192+
AltFuncSelector: AF5_SPI1_SPI2,
193193
}
194194
SPI0 = SPI1
195195
)
@@ -229,15 +229,15 @@ const (
229229
var (
230230
I2C1 = I2C{
231231
Bus: stm32.I2C1,
232-
AltFuncSelector: stm32.AF4_I2C1_2_3,
232+
AltFuncSelector: AF4_I2C1_2_3,
233233
}
234234
I2C2 = I2C{
235235
Bus: stm32.I2C2,
236-
AltFuncSelector: stm32.AF4_I2C1_2_3,
236+
AltFuncSelector: AF4_I2C1_2_3,
237237
}
238238
I2C3 = I2C{
239239
Bus: stm32.I2C1,
240-
AltFuncSelector: stm32.AF4_I2C1_2_3,
240+
AltFuncSelector: AF4_I2C1_2_3,
241241
}
242242
I2C0 = I2C1
243243
)

src/machine/board_lgt92.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ var (
5555
// Console UART (LPUSART1)
5656
UART0 = UART{
5757
Buffer: NewRingBuffer(),
58-
Bus: stm32.LPUSART1,
58+
Bus: stm32.LPUART1,
5959
AltFuncSelector: 6,
6060
}
6161

src/machine/board_stm32f4disco.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ var (
3030
UART0 = UART{
3131
Buffer: NewRingBuffer(),
3232
Bus: stm32.USART2,
33-
AltFuncSelector: stm32.AF7_USART1_2_3,
33+
AltFuncSelector: AF7_USART1_2_3,
3434
}
3535
UART1 = &UART0
3636
)
@@ -62,7 +62,7 @@ const (
6262
var (
6363
SPI0 = SPI{
6464
Bus: stm32.SPI1,
65-
AltFuncSelector: stm32.AF5_SPI1_SPI2,
65+
AltFuncSelector: AF5_SPI1_SPI2,
6666
}
6767
SPI1 = &SPI0
6868
)

src/machine/machine_stm32_i2c.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// +build stm32,!stm32f103xx,!stm32f407,!stm32f7x2,!stm32l0
1+
// +build stm32,!stm32f103,!stm32f407,!stm32f7x2,!stm32l0
22

33
package machine
44

@@ -110,10 +110,10 @@ type (
110110
)
111111

112112
func (sa address7Bit) toRead() uint32 {
113-
return uint32(((uint8(sa) << 1) | uint8(stm32.I2C_OAR1_ADD0)) & 0xFF)
113+
return uint32(((uint8(sa) << 1) | 1) & 0xFF)
114114
}
115115
func (sa address7Bit) toWrite() uint32 {
116-
return uint32(((uint8(sa) << 1) & ^(uint8(stm32.I2C_OAR1_ADD0))) & 0xFF)
116+
return uint32((uint8(sa) << 1) & 0xFF)
117117
}
118118
func (sa address7Bit) bitSize() uint8 { return 7 } // 7-bit addresses
119119

0 commit comments

Comments
 (0)