@@ -225,101 +225,58 @@ endif
225225build/gen-device-% : ./tools/gen-device-% /* .go
226226 $(GO ) build -o $@ ./tools/gen-device-$* /
227227
228- gen-device-avr : gen-device-atmega gen-device-attiny
228+ toUpper = $(shell echo $(1 ) | tr '[a-z0-9]' '[A-Z0-9]')
229+ toLower = $(shell echo $(1 ) | tr '[A-Z0-9]' '[a-z0-9]')
229230
230- # ATmega
231+ define avr_gen_rule
232+ gen-device-avr: $(1 ) .go $(1 ) .s $(1 ) .ld
231233
232- DEVICES_AVR_MEGA = 1280 1284P 2560 328PB 328P 32U4
234+ $(1 ) .go $(1 ) .s $(1 ) .ld &: $(2 ) build/gen-device-avr
235+ build/gen-device-avr $$< $(1 ) .go $(1 ) .s $(1 ) .ld
233236
234- gen-device-atmega : $(foreach m,$(DEVICES_AVR_MEGA ) ,src/device/avr/ATmega$(m ) .go src/device/avr/ATmega$(m ) .s src/device/avr/ATmega$(m ) .ld)
237+ endef
238+ define gen_device_software_rule
239+ gen-device-$(1 ) : $(2 ) .go
235240
236- src/device/avr/ATmega % .go src/device/avr/ATmega % .s src/device/avr/ATmega % .ld : lib/avr/packs/atmega/ATmega % .atdf build/gen-device-avr
237- build/gen-device-avr $< src/device/avr/ATmega $* .go src/device/avr/ATmega $* .s src/device/avr/ATmega $* .ld
241+ $( 2 ) .go: $( 3 ) build/gen-device-svd
242+ build/gen-device-svd -url= $( 4 ) -interrupts=software $$< $$@
238243
239- # ATtiny
244+ endef
245+ define gen_device_rule
246+ gen-device-$(1 ) : $(2 ) .go $(2 ) .s
240247
241- DEVICES_AVR_TINY = 1616 85
248+ $(2 ) .go $(2 ) .s &: $(3 ) build/gen-device-svd
249+ build/gen-device-svd -url=$(4 ) -asm=$(2 ) .s $$< $(2 ) .go
242250
243- gen-device-attiny : $( foreach m, $( DEVICES_AVR_TINY ) ,src/device/avr/ATtiny $( m ) .go src/device/avr/ATtiny $( m ) .s src/device/avr/ATtiny $( m ) .ld)
251+ endef
244252
245- src/device/avr/ATtiny% .go src/device/avr/ATtiny% .s src/device/avr/ATtiny% .ld : lib/avr/packs/tiny/ATtiny% .atdf build/gen-device-avr
246- build/gen-device-avr $< src/device/avr/ATtiny$* .go src/device/avr/ATtiny$* .s src/device/avr/ATtiny$* .ld
247-
248- # Espressif
249-
250- # Both Espressif and Espressif-Community define esp32.
251- # The Espressif directory takes priority.
252-
253- gen-device-esp : src/device/esp/esp32c3.go src/device/esp/esp32s3.go src/device/esp/esp32.go src/device/esp/esp8266.go
254-
255- src/device/esp/% .go : lib/cmsis-svd/data/Espressif/% .svd build/gen-device-svd
256- build/gen-device-svd -url=https://github.com/posborne/cmsis-svd/tree/master/data/Espressif -interrupts=software $< $@
257-
258- src/device/esp/% .go : lib/cmsis-svd/data/Espressif-Community/% .svd build/gen-device-svd
259- build/gen-device-svd -url=https://github.com/posborne/cmsis-svd/tree/master/data/Espressif-Community -interrupts=software $< $@
260-
261- # NRF
262-
263- DEVICES_NRF = 51 52833 52840 52
264-
265- gen-device-nrf : $(foreach m,$(DEVICES_NRF ) ,src/device/nrf/nrf$(m ) .go src/device/nrf/nrf$(m ) .s)
266-
267- src/device/nrf/nrf% .go src/device/nrf/nrf% .s : lib/nrfx/mdk/nrf% .svd build/gen-device-svd
268- build/gen-device-svd -url=https://github.com/NordicSemiconductor/nrfx/tree/master/mdk -asm=src/device/nrf/nrf$* .s $< src/device/nrf/nrf$* .go
269-
270- # NXP
253+ avr_gen_group = $(foreach m,$(3 ) ,$(call avr_gen_rule,src/device/avr/$(1 )$(m ) ,lib/avr/packs/$(2 )$(call toUpper,$(m ) ) .atdf) )
254+ gen_device_software_group = $(foreach m,$(4 ) ,$(call gen_device_software_rule,$(1 ) ,src/device/$(1 ) /$(call toLower,$(m ) ) ,$(2 ) /$(m ) .svd,$(3 ) ) )
255+ gen_device_group = $(foreach m,$(4 ) ,$(call gen_device_rule,$(1 ) ,src/device/$(1 ) /$(call toLower,$(m ) ) ,$(2 ) /$(m ) .svd,$(3 ) ) )
271256
257+ DEVICES_ATMEGA = 1280 1284p 2560 328pb 328p 32u4
258+ DEVICES_ATTINY = 1616 85
259+ DEVICES_ESP = esp32 esp32c3 esp32s3
260+ DEVICES_ESP_COMMUNITY = esp8266
261+ DEVICES_NRF = nrf51 nrf52 nrf52833 nrf52840
272262DEVICES_NXP = MIMXRT1062 MK66F18
273-
274- gen-device-nxp : $(foreach m,$(DEVICES_NXP ) ,src/device/nxp/$(m ) .go src/device/nxp/$(m ) .s)
275-
276- src/device/nxp/% .go src/device/nxp/% .s : lib/cmsis-svd/data/NXP/% .svd build/gen-device-svd
277- build/gen-device-svd -url=https://github.com/posborne/cmsis-svd/tree/master/data/NXP -asm=src/device/nxp/$* .s $< src/device/nxp/$* .go
278-
279- # SAM
280-
281- DEVICES_SAM = D21E18A D21G18A D51G19A D51J19A D51J20A D51P19A D51P20A D51J19A E51J19A E54P20A
282-
283- gen-device-sam : $(foreach m,$(DEVICES_SAM ) ,src/device/sam/ATSAM$(m ) .go src/device/sam/ATSAM$(m ) .s)
284-
285- src/device/sam/ATSAM% .go src/device/sam/ATSAM% .s : lib/cmsis-svd/data/Atmel/ATSAM% .svd build/gen-device-svd
286- build/gen-device-svd -url=https://github.com/posborne/cmsis-svd/tree/master/data/Atmel -asm=src/device/sam/ATSAM$* .s $< src/device/sam/ATSAM$* .go
287-
288- # SiFive
289-
263+ DEVICES_SAM = ATSAMD21E18A ATSAMD21G18A ATSAMD51G19A ATSAMD51J19A ATSAMD51J20A ATSAMD51P19A ATSAMD51P20A ATSAME51J19A ATSAME54P20A
290264DEVICES_SIFIVE = e310x
291-
292- gen-device-sifive : $(foreach m,$(DEVICES_SIFIVE ) ,src/device/sifive/$(m ) .go)
293-
294- src/device/sifive/% .go : lib/cmsis-svd/data/SiFive-Community/% .svd build/gen-device-svd
295- build/gen-device-svd -url=https://github.com/posborne/cmsis-svd/tree/master/data/SiFive-Community -interrupts=software $< $@
296-
297- # Kendryte
298-
299- DEVICES_KENDRYTE = 210
300-
301- gen-device-kendryte : $(foreach m,$(DEVICES_KENDRYTE ) ,src/device/kendryte/k$(m ) .go)
302-
303- src/device/kendryte/k% .go : lib/cmsis-svd/data/Kendryte-Community/k% .svd build/gen-device-svd
304- build/gen-device-svd -url=https://github.com/posborne/cmsis-svd/tree/master/data/Kendryte-Community -interrupts=software $< $@
305-
306- # STM32
307-
308- DEVICES_STM32 = f103 f405 f407 f469 f722 g0b1 l4r5 l0x1 l0x2 l4x2 l4x5 l4x6 l552 u585 wl5x_cm4 wle5
309-
310- gen-device-stm32 : $(foreach m,$(DEVICES_STM32 ) ,src/device/stm32/stm32$(m ) .go src/device/stm32/stm32$(m ) .s)
311-
312- src/device/stm32/stm32% .go src/device/stm32/stm32% .s : lib/stm32-svd/svd/stm32% .svd build/gen-device-svd
313- build/gen-device-svd -url=https://github.com/tinygo-org/stm32-svd -asm=src/device/stm32/stm32$* .s $< src/device/stm32/stm32$* .go
314-
315- # Raspberry Pi
316-
317- DEVICES_RP = 2040 2350
318-
319- gen-device-rp : $(foreach m,$(DEVICES_RP ) ,src/device/rp/rp$(m ) .go src/device/rp/rp$(m ) .s)
320-
321- src/device/rp/rp% .go src/device/rp/rp% .s : lib/cmsis-svd/data/RaspberryPi/rp% .svd build/gen-device-svd
322- build/gen-device-svd -url=https://github.com/posborne/cmsis-svd/tree/master/data/RaspberryPi -asm=src/device/rp/rp$* .s $< src/device/rp/rp$* .go
265+ DEVICES_KENDRYTE = k210
266+ DEVICES_STM32 = stm32f103 stm32f405 stm32f407 stm32f469 stm32f722 stm32g0b1 stm32l4r5 stm32l0x1 stm32l0x2 stm32l4x2 stm32l4x5 stm32l4x6 stm32l552 stm32u585 stm32wl5x_cm4 stm32wle5
267+ DEVICES_RP = rp2040 rp2350
268+
269+ $(eval $(call avr_gen_group,atmega,atmega/ATmega,$(DEVICES_ATMEGA)))
270+ $(eval $(call avr_gen_group,attiny,tiny/ATtiny,$(DEVICES_ATTINY)))
271+ $(eval $(call gen_device_software_group,esp,lib/cmsis-svd/data/Espressif,https ://github.com/posborne/cmsis-svd/tree/master/data/Espressif,$(DEVICES_ESP ) ))
272+ $(eval $(call gen_device_software_group,esp,lib/cmsis-svd/data/Espressif-Community,https ://github.com/posborne/cmsis-svd/tree/master/data/Espressif-Community,$(DEVICES_ESP_COMMUNITY ) ))
273+ $(eval $(call gen_device_group,nrf,lib/nrfx/mdk,https ://github.com/NordicSemiconductor/nrfx/tree/master/mdk,$(DEVICES_NRF ) ))
274+ $(eval $(call gen_device_group,nxp,lib/cmsis-svd/data/NXP,https ://github.com/posborne/cmsis-svd/tree/master/data/NXP,MIMXRT1062 MK66F18))
275+ $(eval $(call gen_device_group,sam,lib/cmsis-svd/data/Atmel,https ://github.com/posborne/cmsis-svd/tree/master/data/Atmel,$(DEVICES_SAM ) ))
276+ $(eval $(call gen_device_software_group,sifive,lib/cmsis-svd/data/SiFive-Community,https ://github.com/posborne/cmsis-svd/tree/master/data/SiFive-Community,$(DEVICES_SIFIVE ) ))
277+ $(eval $(call gen_device_software_group,kendryte,lib/cmsis-svd/data/Kendryte-Community,https ://github.com/posborne/cmsis-svd/tree/master/data/Kendryte-Community,$(DEVICES_KENDRYTE ) ))
278+ $(eval $(call gen_device_group,stm32,lib/stm32-svd/svd,https ://github.com/tinygo-org/stm32-svd,$(DEVICES_STM32 ) ))
279+ $(eval $(call gen_device_group,rp,lib/cmsis-svd/data/RaspberryPi,https ://github.com/posborne/cmsis-svd/tree/master/data/RaspberryPi,$(DEVICES_RP ) ))
323280
324281
325282$(LLVM_PROJECTDIR ) /llvm :
0 commit comments