Open jakub-m opened 2 years ago
There's no elegant solution I'm aware of since Go doesn't allow conditional compilation inside a source file.
I think the best thing is to have machine_stm32f4.go
only contain the strictly common stuff (so TIM1 through to TIM11), and copy these to both machine_stm32f405.go
and machine_stm32f407.go
:
I think the request was fulfilled in the new release, so closing. Please reopen if needed. Thanks!
Can you direct me to what is actually implemented in the next release? I'd know if I need to implement something on my own or if everything is covered. Thanks!
I don't think this is "solved" in any way, rather: build tags are the way to go here. It's a bit painful but I think it's the only reasonable option.
In many cases, it's possible to define peripheral implementations in a central file and only list specific instances in chip-specific files. For example, the file machine_nrf528xx.go implements PWM (type PWM
) for the chips in the nrf528xx family, and machine_nrf52840.go and machine_nrf52.go use those to define PWM0
etc.
Reopening since seems this is a question.
I want to add support for the stm32f401re Nucleo board. The existing
src/machine/machine_stm32f4.go
for this family of chips uses definitions for peripherals that do not exist for the stm32f401 family. For example, TIM13:Looking at
./src/device/stm32/stm32f401.go
I see that there are TIM1 to TIM11.Question: how to modify
machine_stm32f4.go
so it is still usable for different chips of stm32f4 family, even those with less peripherals? Should I maybe exclude stm32f401 frommachine_stm32f4.go
and re-implement everything, or should I makemachine_stm32f4.go
somehow more generic?