├── .gitignore ├── .gitmodules ├── README.md ├── boards.txt ├── cores └── arduino │ ├── Arduino.h │ ├── Client.h │ ├── HardwareSerial.cpp │ ├── HardwareSerial.h │ ├── HardwareTimer.cpp │ ├── HardwareTimer.h │ ├── IPAddress.cpp │ ├── IPAddress.h │ ├── Print.cpp │ ├── Print.h │ ├── Printable.h │ ├── Server.h │ ├── Stream.cpp │ ├── Stream.h │ ├── Tone.cpp │ ├── Tone.h │ ├── Udp.h │ ├── WCharacter.h │ ├── WInterrupts.cpp │ ├── WInterrupts.h │ ├── WMath.cpp │ ├── WMath.h │ ├── WSerial.h │ ├── WString.cpp │ ├── WString.h │ ├── abi.cpp │ ├── avr │ ├── dtostrf.c │ ├── dtostrf.h │ └── pgmspace.h │ ├── binary.h │ ├── board.c │ ├── board.h │ ├── ch32 │ ├── PeripheralPins.h │ ├── PinAF_ch32yyxx.h │ ├── PinConfigured.h │ ├── PinNames.h │ ├── PinNamesTypes.h │ ├── PortNames.c │ ├── PortNames.h │ ├── analog.cpp │ ├── analog.h │ ├── backup.h │ ├── bootloader.h │ ├── ch32_def.c │ ├── ch32_def.h │ ├── ch32_def_build.h │ ├── clock.c │ ├── clock.h │ ├── core_callback.h │ ├── digital_io.h │ ├── hw_config.c │ ├── hw_config.h │ ├── interrupt.cpp │ ├── interrupt.h │ ├── lib │ │ ├── ch32yyxx.h │ │ ├── ch32yyxx_adc.c │ │ ├── ch32yyxx_adc.h │ │ ├── ch32yyxx_bkp.c │ │ ├── ch32yyxx_bkp.h │ │ ├── ch32yyxx_can.c │ │ ├── ch32yyxx_can.h │ │ ├── ch32yyxx_crc.c │ │ ├── ch32yyxx_crc.h │ │ ├── ch32yyxx_dac.c │ │ ├── ch32yyxx_dac.h │ │ ├── ch32yyxx_dbgmcu.c │ │ ├── ch32yyxx_dbgmcu.h │ │ ├── ch32yyxx_debug.c │ │ ├── ch32yyxx_debug.h │ │ ├── ch32yyxx_dma.c │ │ ├── ch32yyxx_dma.h │ │ ├── ch32yyxx_dvp.c │ │ ├── ch32yyxx_dvp.h │ │ ├── ch32yyxx_eth.c │ │ ├── ch32yyxx_eth.h │ │ ├── ch32yyxx_exti.c │ │ ├── ch32yyxx_exti.h │ │ ├── ch32yyxx_flash.c │ │ ├── ch32yyxx_flash.h │ │ ├── ch32yyxx_fsmc.c │ │ ├── ch32yyxx_fsmc.h │ │ ├── ch32yyxx_gpio.c │ │ ├── ch32yyxx_gpio.h │ │ ├── ch32yyxx_i2c.c │ │ ├── ch32yyxx_i2c.h │ │ ├── ch32yyxx_it.c │ │ ├── ch32yyxx_it.h │ │ ├── ch32yyxx_iwdg.c │ │ ├── ch32yyxx_iwdg.h │ │ ├── ch32yyxx_lptim.c │ │ ├── ch32yyxx_lptim.h │ │ ├── ch32yyxx_misc.c │ │ ├── ch32yyxx_misc.h │ │ ├── ch32yyxx_opa.c │ │ ├── ch32yyxx_opa.h │ │ ├── ch32yyxx_pwr.c │ │ ├── ch32yyxx_pwr.h │ │ ├── ch32yyxx_rcc.c │ │ ├── ch32yyxx_rcc.h │ │ ├── ch32yyxx_rng.c │ │ ├── ch32yyxx_rng.h │ │ ├── ch32yyxx_rtc.c │ │ ├── ch32yyxx_rtc.h │ │ ├── ch32yyxx_sdio.c │ │ ├── ch32yyxx_sdio.h │ │ ├── ch32yyxx_spi.c │ │ ├── ch32yyxx_spi.h │ │ ├── ch32yyxx_tim.c │ │ ├── ch32yyxx_tim.h │ │ ├── ch32yyxx_usart.c │ │ ├── ch32yyxx_usart.h │ │ ├── ch32yyxx_wwdg.c │ │ ├── ch32yyxx_wwdg.h │ │ ├── core_riscv_ch32yyxx.c │ │ ├── core_riscv_ch32yyxx.h │ │ ├── system_ch32yyxx.c │ │ └── system_ch32yyxx.h │ ├── pinconfig.h │ ├── pinmap.c │ ├── pinmap.h │ ├── startup_ch32yyxx.S │ ├── timer.c │ ├── timer.h │ ├── uart.c │ └── uart.h │ ├── core_debug.c │ ├── core_debug.h │ ├── hooks.c │ ├── itoa.cpp │ ├── itoa.h │ ├── main.cpp │ ├── pins_arduino.cpp │ ├── pins_arduino.h │ ├── pins_arduino_analog.h │ ├── pins_arduino_digital.h │ ├── variant.h │ ├── wiring.h │ ├── wiring_analog.c │ ├── wiring_analog.h │ ├── wiring_constants.h │ ├── wiring_digital.c │ ├── wiring_digital.h │ ├── wiring_pulse.cpp │ ├── wiring_pulse.h │ ├── wiring_shift.c │ ├── wiring_shift.h │ ├── wiring_time.c │ └── wiring_time.h ├── libraries ├── EEPROM │ ├── README.md │ ├── examples │ │ ├── eeprom_counter │ │ │ └── eeprom_counter.ino │ │ ├── eeprom_crc │ │ │ └── eeprom_crc.ino │ │ ├── eeprom_get │ │ │ └── eeprom_get.ino │ │ ├── eeprom_put │ │ │ └── eeprom_put.ino │ │ ├── eeprom_read │ │ │ └── eeprom_read.ino │ │ └── eeprom_write │ │ │ └── eeprom_write.ino │ ├── keywords.txt │ ├── library.properties │ └── src │ │ ├── EEPROM.cpp │ │ └── EEPROM.h ├── SPI │ ├── examples │ │ └── SPIFlash │ │ │ └── SPIFlash.ino │ ├── keywords.txt │ ├── library.properties │ └── src │ │ ├── SPI.cpp │ │ ├── SPI.h │ │ └── utility │ │ ├── spi_com.c │ │ └── spi_com.h ├── USBPD_SINK │ ├── examples │ │ └── usbpd_sink_request_voltage │ │ │ └── usbpd_sink_request_voltage.ino │ ├── keywords.txt │ ├── library.properties │ └── src │ │ ├── usbpd_def.h │ │ ├── usbpd_sink.c │ │ └── usbpd_sink.h └── Wire │ ├── examples │ ├── at24c02_read_write │ │ └── at24c02_read_write.ino │ ├── i2cMinimalSlave │ │ └── i2cMinimalSlave.ino │ └── i2c_scanner │ │ ├── README.md │ │ └── i2c_scanner.ino │ ├── keywords.txt │ ├── library.properties │ └── src │ ├── Wire.cpp │ ├── Wire.h │ └── utility │ ├── twi.c │ └── twi.h ├── package.json ├── platform.txt ├── programmers.txt ├── system ├── CH32L10x │ ├── SRC │ │ ├── Core │ │ │ ├── core_riscv.c │ │ │ └── core_riscv.h │ │ ├── Debug │ │ │ ├── debug.c │ │ │ └── debug.h │ │ ├── Ld │ │ │ └── Link.ld │ │ ├── Peripheral │ │ │ ├── inc │ │ │ │ ├── ch32l103.h │ │ │ │ ├── ch32l103_adc.h │ │ │ │ ├── ch32l103_bkp.h │ │ │ │ ├── ch32l103_can.h │ │ │ │ ├── ch32l103_crc.h │ │ │ │ ├── ch32l103_dbgmcu.h │ │ │ │ ├── ch32l103_dma.h │ │ │ │ ├── ch32l103_exti.h │ │ │ │ ├── ch32l103_flash.h │ │ │ │ ├── ch32l103_gpio.h │ │ │ │ ├── ch32l103_i2c.h │ │ │ │ ├── ch32l103_iwdg.h │ │ │ │ ├── ch32l103_lptim.h │ │ │ │ ├── ch32l103_misc.h │ │ │ │ ├── ch32l103_opa.h │ │ │ │ ├── ch32l103_pwr.h │ │ │ │ ├── ch32l103_rcc.h │ │ │ │ ├── ch32l103_rtc.h │ │ │ │ ├── ch32l103_spi.h │ │ │ │ ├── ch32l103_tim.h │ │ │ │ ├── ch32l103_usart.h │ │ │ │ ├── ch32l103_usb.h │ │ │ │ ├── ch32l103_usbpd.h │ │ │ │ └── ch32l103_wwdg.h │ │ │ └── src │ │ │ │ ├── ch32l103_adc.c │ │ │ │ ├── ch32l103_bkp.c │ │ │ │ ├── ch32l103_can.c │ │ │ │ ├── ch32l103_crc.c │ │ │ │ ├── ch32l103_dbgmcu.c │ │ │ │ ├── ch32l103_dma.c │ │ │ │ ├── ch32l103_exti.c │ │ │ │ ├── ch32l103_flash.c │ │ │ │ ├── ch32l103_gpio.c │ │ │ │ ├── ch32l103_i2c.c │ │ │ │ ├── ch32l103_iwdg.c │ │ │ │ ├── ch32l103_lptim.c │ │ │ │ ├── ch32l103_misc.c │ │ │ │ ├── ch32l103_opa.c │ │ │ │ ├── ch32l103_pwr.c │ │ │ │ ├── ch32l103_rcc.c │ │ │ │ ├── ch32l103_rtc.c │ │ │ │ ├── ch32l103_spi.c │ │ │ │ ├── ch32l103_tim.c │ │ │ │ ├── ch32l103_usart.c │ │ │ │ └── ch32l103_wwdg.c │ │ └── Startup │ │ │ └── startup_ch32l103.S │ └── USER │ │ ├── ch32l103_conf.h │ │ ├── ch32l103_it.c │ │ ├── ch32l103_it.h │ │ ├── system_ch32l103.c │ │ └── system_ch32l103.h ├── CH32V00x │ ├── SRC │ │ ├── Core │ │ │ ├── core_riscv.c │ │ │ └── core_riscv.h │ │ ├── Debug │ │ │ ├── debug.c │ │ │ └── debug.h │ │ ├── Ld │ │ │ └── Link.ld │ │ ├── Peripheral │ │ │ ├── inc │ │ │ │ ├── ch32v00x.h │ │ │ │ ├── ch32v00x_adc.h │ │ │ │ ├── ch32v00x_dbgmcu.h │ │ │ │ ├── ch32v00x_dma.h │ │ │ │ ├── ch32v00x_exti.h │ │ │ │ ├── ch32v00x_flash.h │ │ │ │ ├── ch32v00x_gpio.h │ │ │ │ ├── ch32v00x_i2c.h │ │ │ │ ├── ch32v00x_iwdg.h │ │ │ │ ├── ch32v00x_misc.h │ │ │ │ ├── ch32v00x_opa.h │ │ │ │ ├── ch32v00x_pwr.h │ │ │ │ ├── ch32v00x_rcc.h │ │ │ │ ├── ch32v00x_spi.h │ │ │ │ ├── ch32v00x_tim.h │ │ │ │ ├── ch32v00x_usart.h │ │ │ │ └── ch32v00x_wwdg.h │ │ │ └── src │ │ │ │ ├── ch32v00x_adc.c │ │ │ │ ├── ch32v00x_dbgmcu.c │ │ │ │ ├── ch32v00x_dma.c │ │ │ │ ├── ch32v00x_exti.c │ │ │ │ ├── ch32v00x_flash.c │ │ │ │ ├── ch32v00x_gpio.c │ │ │ │ ├── ch32v00x_i2c.c │ │ │ │ ├── ch32v00x_iwdg.c │ │ │ │ ├── ch32v00x_misc.c │ │ │ │ ├── ch32v00x_opa.c │ │ │ │ ├── ch32v00x_pwr.c │ │ │ │ ├── ch32v00x_rcc.c │ │ │ │ ├── ch32v00x_spi.c │ │ │ │ ├── ch32v00x_tim.c │ │ │ │ ├── ch32v00x_usart.c │ │ │ │ └── ch32v00x_wwdg.c │ │ └── Startup │ │ │ └── startup_ch32v00x.S │ └── USER │ │ ├── ch32v00x_conf.h │ │ ├── ch32v00x_it.c │ │ ├── ch32v00x_it.h │ │ ├── system_ch32v00x.c │ │ └── system_ch32v00x.h ├── CH32V10x │ ├── SRC │ │ ├── Core │ │ │ ├── core_riscv.c │ │ │ └── core_riscv.h │ │ ├── Debug │ │ │ ├── debug.c │ │ │ └── debug.h │ │ ├── Ld │ │ │ └── Link.ld │ │ ├── Peripheral │ │ │ ├── inc │ │ │ │ ├── ch32v10x.h │ │ │ │ ├── ch32v10x_adc.h │ │ │ │ ├── ch32v10x_bkp.h │ │ │ │ ├── ch32v10x_crc.h │ │ │ │ ├── ch32v10x_dbgmcu.h │ │ │ │ ├── ch32v10x_dma.h │ │ │ │ ├── ch32v10x_exti.h │ │ │ │ ├── ch32v10x_flash.h │ │ │ │ ├── ch32v10x_gpio.h │ │ │ │ ├── ch32v10x_i2c.h │ │ │ │ ├── ch32v10x_iwdg.h │ │ │ │ ├── ch32v10x_misc.h │ │ │ │ ├── ch32v10x_pwr.h │ │ │ │ ├── ch32v10x_rcc.h │ │ │ │ ├── ch32v10x_rtc.h │ │ │ │ ├── ch32v10x_spi.h │ │ │ │ ├── ch32v10x_tim.h │ │ │ │ ├── ch32v10x_usart.h │ │ │ │ ├── ch32v10x_usb.h │ │ │ │ ├── ch32v10x_usb_host.h │ │ │ │ └── ch32v10x_wwdg.h │ │ │ └── src │ │ │ │ ├── ch32v10x_adc.c │ │ │ │ ├── ch32v10x_bkp.c │ │ │ │ ├── ch32v10x_crc.c │ │ │ │ ├── ch32v10x_dbgmcu.c │ │ │ │ ├── ch32v10x_dma.c │ │ │ │ ├── ch32v10x_exti.c │ │ │ │ ├── ch32v10x_flash.c │ │ │ │ ├── ch32v10x_gpio.c │ │ │ │ ├── ch32v10x_i2c.c │ │ │ │ ├── ch32v10x_iwdg.c │ │ │ │ ├── ch32v10x_misc.c │ │ │ │ ├── ch32v10x_pwr.c │ │ │ │ ├── ch32v10x_rcc.c │ │ │ │ ├── ch32v10x_rtc.c │ │ │ │ ├── ch32v10x_spi.c │ │ │ │ ├── ch32v10x_tim.c │ │ │ │ ├── ch32v10x_usart.c │ │ │ │ ├── ch32v10x_usb.c │ │ │ │ ├── ch32v10x_usb_host.c │ │ │ │ └── ch32v10x_wwdg.c │ │ └── Startup │ │ │ ├── startup_ch32v10x_3v3.S │ │ │ └── startup_ch32v10x_5v.S │ └── USER │ │ ├── ch32v10x_conf.h │ │ ├── ch32v10x_it.c │ │ ├── ch32v10x_it.h │ │ ├── system_ch32v10x.c │ │ └── system_ch32v10x.h ├── CH32V20x │ ├── SRC │ │ ├── Core │ │ │ ├── core_riscv.c │ │ │ └── core_riscv.h │ │ ├── Debug │ │ │ ├── debug.c │ │ │ └── debug.h │ │ ├── Ld │ │ │ └── Link.ld │ │ ├── Peripheral │ │ │ ├── inc │ │ │ │ ├── ch32v20x.h │ │ │ │ ├── ch32v20x_adc.h │ │ │ │ ├── ch32v20x_bkp.h │ │ │ │ ├── ch32v20x_can.h │ │ │ │ ├── ch32v20x_crc.h │ │ │ │ ├── ch32v20x_dbgmcu.h │ │ │ │ ├── ch32v20x_dma.h │ │ │ │ ├── ch32v20x_exti.h │ │ │ │ ├── ch32v20x_flash.h │ │ │ │ ├── ch32v20x_gpio.h │ │ │ │ ├── ch32v20x_i2c.h │ │ │ │ ├── ch32v20x_iwdg.h │ │ │ │ ├── ch32v20x_misc.h │ │ │ │ ├── ch32v20x_opa.h │ │ │ │ ├── ch32v20x_pwr.h │ │ │ │ ├── ch32v20x_rcc.h │ │ │ │ ├── ch32v20x_rtc.h │ │ │ │ ├── ch32v20x_spi.h │ │ │ │ ├── ch32v20x_tim.h │ │ │ │ ├── ch32v20x_usart.h │ │ │ │ └── ch32v20x_wwdg.h │ │ │ └── src │ │ │ │ ├── ch32v20x_adc.c │ │ │ │ ├── ch32v20x_bkp.c │ │ │ │ ├── ch32v20x_can.c │ │ │ │ ├── ch32v20x_crc.c │ │ │ │ ├── ch32v20x_dbgmcu.c │ │ │ │ ├── ch32v20x_dma.c │ │ │ │ ├── ch32v20x_exti.c │ │ │ │ ├── ch32v20x_flash.c │ │ │ │ ├── ch32v20x_gpio.c │ │ │ │ ├── ch32v20x_i2c.c │ │ │ │ ├── ch32v20x_iwdg.c │ │ │ │ ├── ch32v20x_misc.c │ │ │ │ ├── ch32v20x_opa.c │ │ │ │ ├── ch32v20x_pwr.c │ │ │ │ ├── ch32v20x_rcc.c │ │ │ │ ├── ch32v20x_rtc.c │ │ │ │ ├── ch32v20x_spi.c │ │ │ │ ├── ch32v20x_tim.c │ │ │ │ ├── ch32v20x_usart.c │ │ │ │ └── ch32v20x_wwdg.c │ │ └── Startup │ │ │ ├── startup_ch32v20x_D6.S │ │ │ ├── startup_ch32v20x_D8.S │ │ │ └── startup_ch32v20x_D8W.S │ └── USER │ │ ├── ch32v20x_conf.h │ │ ├── ch32v20x_it.c │ │ ├── ch32v20x_it.h │ │ ├── system_ch32v20x.c │ │ └── system_ch32v20x.h ├── CH32V30x │ ├── SRC │ │ ├── Core │ │ │ ├── core_riscv.c │ │ │ └── core_riscv.h │ │ ├── Debug │ │ │ ├── debug.c │ │ │ └── debug.h │ │ ├── Ld │ │ │ └── Link.ld │ │ ├── Peripheral │ │ │ ├── inc │ │ │ │ ├── ch32v30x.h │ │ │ │ ├── ch32v30x_adc.h │ │ │ │ ├── ch32v30x_bkp.h │ │ │ │ ├── ch32v30x_can.h │ │ │ │ ├── ch32v30x_crc.h │ │ │ │ ├── ch32v30x_dac.h │ │ │ │ ├── ch32v30x_dbgmcu.h │ │ │ │ ├── ch32v30x_dma.h │ │ │ │ ├── ch32v30x_dvp.h │ │ │ │ ├── ch32v30x_eth.h │ │ │ │ ├── ch32v30x_exti.h │ │ │ │ ├── ch32v30x_flash.h │ │ │ │ ├── ch32v30x_fsmc.h │ │ │ │ ├── ch32v30x_gpio.h │ │ │ │ ├── ch32v30x_i2c.h │ │ │ │ ├── ch32v30x_iwdg.h │ │ │ │ ├── ch32v30x_misc.h │ │ │ │ ├── ch32v30x_opa.h │ │ │ │ ├── ch32v30x_pwr.h │ │ │ │ ├── ch32v30x_rcc.h │ │ │ │ ├── ch32v30x_rng.h │ │ │ │ ├── ch32v30x_rtc.h │ │ │ │ ├── ch32v30x_sdio.h │ │ │ │ ├── ch32v30x_spi.h │ │ │ │ ├── ch32v30x_tim.h │ │ │ │ ├── ch32v30x_usart.h │ │ │ │ └── ch32v30x_wwdg.h │ │ │ └── src │ │ │ │ ├── ch32v30x_adc.c │ │ │ │ ├── ch32v30x_bkp.c │ │ │ │ ├── ch32v30x_can.c │ │ │ │ ├── ch32v30x_crc.c │ │ │ │ ├── ch32v30x_dac.c │ │ │ │ ├── ch32v30x_dbgmcu.c │ │ │ │ ├── ch32v30x_dma.c │ │ │ │ ├── ch32v30x_dvp.c │ │ │ │ ├── ch32v30x_eth.c │ │ │ │ ├── ch32v30x_exti.c │ │ │ │ ├── ch32v30x_flash.c │ │ │ │ ├── ch32v30x_fsmc.c │ │ │ │ ├── ch32v30x_gpio.c │ │ │ │ ├── ch32v30x_i2c.c │ │ │ │ ├── ch32v30x_iwdg.c │ │ │ │ ├── ch32v30x_misc.c │ │ │ │ ├── ch32v30x_opa.c │ │ │ │ ├── ch32v30x_pwr.c │ │ │ │ ├── ch32v30x_rcc.c │ │ │ │ ├── ch32v30x_rng.c │ │ │ │ ├── ch32v30x_rtc.c │ │ │ │ ├── ch32v30x_sdio.c │ │ │ │ ├── ch32v30x_spi.c │ │ │ │ ├── ch32v30x_tim.c │ │ │ │ ├── ch32v30x_usart.c │ │ │ │ └── ch32v30x_wwdg.c │ │ └── Startup │ │ │ ├── startup_ch32v30x_D8.S │ │ │ └── startup_ch32v30x_D8C.S │ └── USER │ │ ├── ch32v30x_conf.h │ │ ├── ch32v30x_it.c │ │ ├── ch32v30x_it.h │ │ ├── system_ch32v30x.c │ │ └── system_ch32v30x.h ├── CH32VM00X │ ├── SRC │ │ ├── Core │ │ │ ├── core_riscv.c │ │ │ └── core_riscv.h │ │ ├── Debug │ │ │ ├── debug.c │ │ │ └── debug.h │ │ ├── Ld │ │ │ └── Link.ld │ │ ├── Peripheral │ │ │ ├── inc │ │ │ │ ├── ch32v00X.h │ │ │ │ ├── ch32v00X_adc.h │ │ │ │ ├── ch32v00X_dbgmcu.h │ │ │ │ ├── ch32v00X_dma.h │ │ │ │ ├── ch32v00X_exti.h │ │ │ │ ├── ch32v00X_flash.h │ │ │ │ ├── ch32v00X_gpio.h │ │ │ │ ├── ch32v00X_i2c.h │ │ │ │ ├── ch32v00X_iwdg.h │ │ │ │ ├── ch32v00X_misc.h │ │ │ │ ├── ch32v00X_opa.h │ │ │ │ ├── ch32v00X_pwr.h │ │ │ │ ├── ch32v00X_rcc.h │ │ │ │ ├── ch32v00X_spi.h │ │ │ │ ├── ch32v00X_tim.h │ │ │ │ ├── ch32v00X_usart.h │ │ │ │ └── ch32v00X_wwdg.h │ │ │ └── src │ │ │ │ ├── ch32v00X_adc.c │ │ │ │ ├── ch32v00X_dbgmcu.c │ │ │ │ ├── ch32v00X_dma.c │ │ │ │ ├── ch32v00X_exti.c │ │ │ │ ├── ch32v00X_flash.c │ │ │ │ ├── ch32v00X_gpio.c │ │ │ │ ├── ch32v00X_i2c.c │ │ │ │ ├── ch32v00X_iwdg.c │ │ │ │ ├── ch32v00X_misc.c │ │ │ │ ├── ch32v00X_opa.c │ │ │ │ ├── ch32v00X_pwr.c │ │ │ │ ├── ch32v00X_rcc.c │ │ │ │ ├── ch32v00X_spi.c │ │ │ │ ├── ch32v00X_tim.c │ │ │ │ ├── ch32v00X_usart.c │ │ │ │ └── ch32v00X_wwdg.c │ │ └── Startup │ │ │ └── startup_ch32v00X.S │ └── USER │ │ ├── ch32v00X_conf.h │ │ ├── ch32v00X_it.c │ │ ├── ch32v00X_it.h │ │ ├── system_ch32v00X.c │ │ └── system_ch32v00X.h └── CH32X035 │ ├── SRC │ ├── Core │ │ ├── core_riscv.c │ │ └── core_riscv.h │ ├── Debug │ │ ├── debug.c │ │ └── debug.h │ ├── Ld │ │ └── Link.ld │ ├── Peripheral │ │ ├── inc │ │ │ ├── ch32x035.h │ │ │ ├── ch32x035_adc.h │ │ │ ├── ch32x035_awu.h │ │ │ ├── ch32x035_dbgmcu.h │ │ │ ├── ch32x035_dma.h │ │ │ ├── ch32x035_exti.h │ │ │ ├── ch32x035_flash.h │ │ │ ├── ch32x035_gpio.h │ │ │ ├── ch32x035_i2c.h │ │ │ ├── ch32x035_iwdg.h │ │ │ ├── ch32x035_misc.h │ │ │ ├── ch32x035_opa.h │ │ │ ├── ch32x035_pwr.h │ │ │ ├── ch32x035_rcc.h │ │ │ ├── ch32x035_spi.h │ │ │ ├── ch32x035_tim.h │ │ │ ├── ch32x035_usart.h │ │ │ └── ch32x035_wwdg.h │ │ └── src │ │ │ ├── ch32x035_adc.c │ │ │ ├── ch32x035_awu.c │ │ │ ├── ch32x035_dbgmcu.c │ │ │ ├── ch32x035_dma.c │ │ │ ├── ch32x035_exti.c │ │ │ ├── ch32x035_flash.c │ │ │ ├── ch32x035_gpio.c │ │ │ ├── ch32x035_i2c.c │ │ │ ├── ch32x035_iwdg.c │ │ │ ├── ch32x035_misc.c │ │ │ ├── ch32x035_opa.c │ │ │ ├── ch32x035_pwr.c │ │ │ ├── ch32x035_rcc.c │ │ │ ├── ch32x035_spi.c │ │ │ ├── ch32x035_tim.c │ │ │ ├── ch32x035_usart.c │ │ │ └── ch32x035_wwdg.c │ └── Startup │ │ └── startup_ch32x035.S │ └── USER │ ├── ch32x035_conf.h │ ├── ch32x035_it.c │ ├── ch32x035_it.h │ ├── system_ch32x035.c │ └── system_ch32x035.h ├── tools ├── makeboards.py └── platformio-build.py └── variants ├── CH32L10x ├── CH32L103C8T6 │ ├── CMakeLists.txt │ ├── PeripheralPins.c │ ├── PinNamesVar.h │ ├── boards_entry.txt │ ├── variant_CH32L103C8T6.cpp │ └── variant_CH32L103C8T6.h └── PinAF_CH32L10x.h ├── CH32V00x ├── CH32V003F4 │ ├── CMakeLists.txt │ ├── PeripheralPins.c │ ├── PinNamesVar.h │ ├── boards_entry.txt │ ├── variant_CH32V003F4.cpp │ └── variant_CH32V003F4.h └── PinAF_CH32V00x.h ├── CH32V10x ├── CH32V103R8T6 │ ├── CMakeLists.txt │ ├── PeripheralPins.c │ ├── PinNamesVar.h │ ├── boards_entry.txt │ ├── variant_CH32V103R8T6.cpp │ └── variant_CH32V103R8T6.h └── PinAF_CH32V10x.h ├── CH32V20x ├── CH32V203C6 │ ├── CMakeLists.txt │ ├── PeripheralPins.c │ ├── PinNamesVar.h │ ├── boards_entry.txt │ ├── variant_CH32V203C6.cpp │ └── variant_CH32V203C6.h ├── CH32V203C8 │ ├── CMakeLists.txt │ ├── PeripheralPins.c │ ├── PinNamesVar.h │ ├── boards_entry.txt │ ├── variant_CH32V203C8.cpp │ └── variant_CH32V203C8.h ├── CH32V203G6 │ ├── CMakeLists.txt │ ├── PeripheralPins.c │ ├── PinNamesVar.h │ ├── boards_entry.txt │ ├── variant_CH32V203G6.cpp │ └── variant_CH32V203G6.h ├── CH32V203G6_ADAFRUIT_QTPY │ ├── CMakeLists.txt │ ├── PeripheralPins.c │ ├── PinNamesVar.h │ ├── variant_CH32V203G6_ADAFRUIT_QTPY.cpp │ └── variant_CH32V203G6_ADAFRUIT_QTPY.h ├── CH32V203G8 │ ├── CMakeLists.txt │ ├── PeripheralPins.c │ ├── PinNamesVar.h │ ├── boards_entry.txt │ ├── variant_CH32V203G8.cpp │ └── variant_CH32V203G8.h ├── CH32V203RB │ ├── CMakeLists.txt │ ├── PeripheralPins.c │ ├── PinNamesVar.h │ ├── boards_entry.txt │ ├── variant_CH32V203RB.cpp │ └── variant_CH32V203RB.h └── PinAF_CH32V20x.h ├── CH32V30x ├── CH32V307VCT6 │ ├── CMakeLists.txt │ ├── PeripheralPins.c │ ├── PinNamesVar.h │ ├── boards_entry.txt │ ├── variant_CH32V307VCT6.cpp │ └── variant_CH32V307VCT6.h └── PinAF_CH32V30x.h ├── CH32VM00X ├── CH32V006K8 │ ├── CMakeLists.txt │ ├── PeripheralPins.c │ ├── PinNamesVar.h │ ├── boards_entry.txt │ ├── variant_CH32V006K8.cpp │ └── variant_CH32V006K8.h └── PinAF_CH32V00X.h └── CH32X035 ├── CH32X035G8U ├── CMakeLists.txt ├── PeripheralPins.c ├── PinNamesVar.h ├── boards_entry.txt ├── variant_CH32X035G8U.cpp └── variant_CH32X035G8U.h └── PinAF_CH32X035.h /.gitignore: -------------------------------------------------------------------------------- 1 | .vscode -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "libraries/Adafruit_TinyUSB_Arduino"] 2 | path = libraries/Adafruit_TinyUSB_Arduino 3 | url = https://github.com/adafruit/Adafruit_TinyUSB_Arduino.git 4 | -------------------------------------------------------------------------------- /cores/arduino/Client.h: -------------------------------------------------------------------------------- 1 | /* 2 | Client.h - Base class that provides Client 3 | Copyright (c) 2011 Adrian McEwen. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef client_h 21 | #define client_h 22 | #include "Print.h" 23 | #include "Stream.h" 24 | #include "IPAddress.h" 25 | 26 | class Client : public Stream { 27 | 28 | public: 29 | virtual int connect(IPAddress ip, uint16_t port) =0; 30 | virtual int connect(const char *host, uint16_t port) =0; 31 | virtual size_t write(uint8_t) =0; 32 | virtual size_t write(const uint8_t *buf, size_t size) =0; 33 | virtual int available() = 0; 34 | virtual int read() = 0; 35 | virtual int read(uint8_t *buf, size_t size) = 0; 36 | virtual int peek() = 0; 37 | virtual void flush() = 0; 38 | virtual void stop() = 0; 39 | virtual uint8_t connected() = 0; 40 | virtual operator bool() = 0; 41 | protected: 42 | uint8_t* rawIPAddress(IPAddress& addr) { return addr.raw_address(); }; 43 | }; 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /cores/arduino/Printable.h: -------------------------------------------------------------------------------- 1 | /* 2 | Printable.h - Interface class that allows printing of complex types 3 | Copyright (c) 2011 Adrian McEwen. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef Printable_h 21 | #define Printable_h 22 | 23 | #include 24 | 25 | class Print; 26 | 27 | /** The Printable class provides a way for new classes to allow themselves to be printed. 28 | By deriving from Printable and implementing the printTo method, it will then be possible 29 | for users to print out instances of this class by passing them into the usual 30 | Print::print and Print::println methods. 31 | */ 32 | 33 | class Printable { 34 | public: 35 | virtual size_t printTo(Print &p) const = 0; 36 | }; 37 | 38 | #endif 39 | 40 | -------------------------------------------------------------------------------- /cores/arduino/Server.h: -------------------------------------------------------------------------------- 1 | /* 2 | Server.h - Base class that provides Server 3 | Copyright (c) 2011 Adrian McEwen. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef server_h 21 | #define server_h 22 | 23 | #include "Print.h" 24 | 25 | class Server : public Print { 26 | public: 27 | virtual void begin() =0; 28 | }; 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /cores/arduino/Tone.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2011 Arduino. All right reserved. 3 | 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | See the GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with this library; if not, write to the Free Software 16 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | #ifndef _WIRING_TONE_ 20 | #define _WIRING_TONE_ 21 | 22 | #ifdef __cplusplus 23 | /* 24 | * \brief Generate a tone to a pin. 25 | * 26 | * \param _pin 27 | * \param frequency Tone frequency (in hertz) 28 | * \param duration Tone duration (in milliseconds) 29 | */ 30 | extern void tone(uint8_t _pin, unsigned int frequency, unsigned long duration = 0); 31 | 32 | /* 33 | * \brief Stop tone generation on pin. 34 | * 35 | * \param _pin 36 | */ 37 | extern void noTone(uint8_t _pin, bool destruct = false); 38 | 39 | #endif 40 | 41 | #endif /* _WIRING_TONE_ */ 42 | -------------------------------------------------------------------------------- /cores/arduino/WInterrupts.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2011-2012 Arduino. All right reserved. 3 | 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | See the GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with this library; if not, write to the Free Software 16 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | #include "WInterrupts.h" 20 | #include "Arduino.h" 21 | #include "PinAF_ch32yyxx.h" 22 | 23 | #include "interrupt.h" 24 | 25 | 26 | #if !defined(EXTI_MODULE_DISABLED) 27 | 28 | void attachInterrupt(uint32_t pin, GPIOMode_TypeDef io_mode, void (*callback)(void), EXTIMode_TypeDef it_mode, EXTITrigger_TypeDef trigger_mode) 29 | { 30 | PinName p = digitalPinToPinName(pin); 31 | GPIO_TypeDef* port = set_GPIO_Port_Clock(CH_PORT(p)); 32 | if (!port) return ; 33 | pinV32_DisconnectDebug(p); 34 | 35 | ch32_interrupt_enable(port, io_mode, CH_GPIO_PIN(p), callback, it_mode, trigger_mode); 36 | } 37 | 38 | 39 | void detachInterrupt(uint32_t pin) 40 | { 41 | PinName p = digitalPinToPinName(pin); 42 | GPIO_TypeDef* port = get_GPIO_Port(CH_PORT(p)); 43 | if (!port) 44 | return; 45 | ch32_interrupt_disable(port, CH_GPIO_PIN(p)); 46 | } 47 | 48 | #endif -------------------------------------------------------------------------------- /cores/arduino/WInterrupts.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2011-2012 Arduino. All right reserved. 3 | 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | See the GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with this library; if not, write to the Free Software 16 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | #ifndef _WIRING_INTERRUPTS_ 20 | #define _WIRING_INTERRUPTS_ 21 | 22 | #include 23 | #include "interrupt.h" 24 | 25 | 26 | 27 | void attachInterrupt(uint32_t pin,GPIOMode_TypeDef io_mode, void (*callback)(void), EXTIMode_TypeDef it_mode, EXTITrigger_TypeDef trigger_mode); 28 | void detachInterrupt(uint32_t pin); 29 | 30 | #endif /* _WIRING_INTERRUPTS_ */ 31 | -------------------------------------------------------------------------------- /cores/arduino/WMath.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2011 Arduino. All right reserved. 3 | 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | See the GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with this library; if not, write to the Free Software 16 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | extern "C" { 20 | #include "stdlib.h" 21 | #include "stdint.h" 22 | } 23 | #include "WMath.h" 24 | 25 | extern void randomSeed(uint32_t dwSeed) 26 | { 27 | if (dwSeed != 0) { 28 | srand(dwSeed) ; 29 | } 30 | } 31 | 32 | extern long random(long howbig) 33 | { 34 | if (howbig == 0) { 35 | return 0 ; 36 | } 37 | 38 | return rand() % howbig; 39 | } 40 | 41 | extern long random(long howsmall, long howbig) 42 | { 43 | if (howsmall >= howbig) { 44 | return howsmall; 45 | } 46 | 47 | long diff = howbig - howsmall; 48 | 49 | return random(diff) + howsmall; 50 | } 51 | 52 | extern long map(long x, long in_min, long in_max, long out_min, long out_max) 53 | { 54 | return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; 55 | } 56 | 57 | extern uint16_t makeWord(uint16_t w) 58 | { 59 | return w ; 60 | } 61 | 62 | extern uint16_t makeWord(uint8_t h, uint8_t l) 63 | { 64 | return (h << 8) | l ; 65 | } 66 | -------------------------------------------------------------------------------- /cores/arduino/WMath.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2011 Arduino. All right reserved. 3 | 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | See the GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with this library; if not, write to the Free Software 16 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | #ifndef _WIRING_MATH_ 20 | #define _WIRING_MATH_ 21 | 22 | extern long random(long) ; 23 | extern long random(long, long) ; 24 | extern void randomSeed(uint32_t dwSeed) ; 25 | extern long map(long, long, long, long, long) ; 26 | 27 | extern uint16_t makeWord(uint16_t w) ; 28 | extern uint16_t makeWord(uint8_t h, uint8_t l) ; 29 | 30 | #define word(...) makeWord(__VA_ARGS__) 31 | 32 | 33 | #endif /* _WIRING_MATH_ */ 34 | -------------------------------------------------------------------------------- /cores/arduino/abi.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014 Arduino. All right reserved. 3 | 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | See the GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with this library; if not, write to the Free Software 16 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | #include 20 | 21 | extern "C" void __cxa_pure_virtual(void) __attribute__ ((__noreturn__)); 22 | extern "C" void __cxa_deleted_virtual(void) __attribute__ ((__noreturn__)); 23 | 24 | void __cxa_pure_virtual(void) { 25 | // We might want to write some diagnostics to uart in this case 26 | //std::terminate(); 27 | while (1) 28 | ; 29 | } 30 | 31 | void __cxa_deleted_virtual(void) { 32 | // We might want to write some diagnostics to uart in this case 33 | //std::terminate(); 34 | while (1) 35 | ; 36 | } 37 | 38 | -------------------------------------------------------------------------------- /cores/arduino/avr/dtostrf.h: -------------------------------------------------------------------------------- 1 | /* 2 | dtostrf - Emulation for dtostrf function from avr-libc 3 | Copyright (c) 2013 Arduino. All rights reserved. 4 | Written by Cristian Maglie 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | #ifndef __DTOSTRF_H_ 21 | #define __DTOSTRF_H_ 1 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | char *dtostrf (double val, signed char width, unsigned char prec, char *sout); 28 | 29 | #ifdef __cplusplus 30 | } 31 | #endif 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /cores/arduino/board.c: -------------------------------------------------------------------------------- 1 | #include "board.h" 2 | 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | 8 | WEAK void pre_init(void) 9 | { 10 | hw_config_init(); 11 | } 12 | 13 | 14 | #ifdef __cplusplus 15 | } 16 | #endif 17 | -------------------------------------------------------------------------------- /cores/arduino/board.h: -------------------------------------------------------------------------------- 1 | #ifndef _BOARD_H_ 2 | #define _BOARD_H_ 3 | 4 | 5 | #include "interrupt.h" 6 | #include "analog.h" 7 | // #include "backup.h" 8 | #include "clock.h" 9 | // #include "core_callback.h" 10 | #include "digital_io.h" 11 | // #include "dwt.h" 12 | #include "hw_config.h" 13 | // #include "otp.h" 14 | #include "timer.h" 15 | #include "uart.h" 16 | 17 | 18 | /* 19 | * Core and peripherals registers definitions 20 | */ 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | void pre_init(void) ; 26 | 27 | #ifdef __cplusplus 28 | } 29 | #endif 30 | 31 | 32 | #endif /* _BOARD_H_ */ 33 | -------------------------------------------------------------------------------- /cores/arduino/ch32/PinAF_ch32yyxx.h: -------------------------------------------------------------------------------- 1 | #ifndef _PINAF_CH32YYXX_H 2 | #define _PINAF_CH32YYXX_H 3 | 4 | #if defined(CH32V20x) || defined(CH32V203xB) || defined(CH32V208) 5 | #include "../../../variants/CH32V20x/PinAF_CH32V20x.h" 6 | #endif 7 | 8 | 9 | #if defined(CH32V00x) 10 | #include "../../../variants/CH32V00x/PinAF_CH32V00x.h" 11 | #endif 12 | 13 | #if defined(CH32VM00X) 14 | #include "../../../variants/CH32VM00X/PinAF_CH32V00X.h" 15 | #endif 16 | 17 | #if defined(CH32V10x) 18 | #include "../../../variants/CH32V10x/PinAF_CH32V10x.h" 19 | #endif 20 | 21 | #if defined(CH32X035) 22 | #include "../../../variants/CH32X035/PinAF_CH32X035.h" 23 | #endif 24 | 25 | #if defined(CH32V30x) || defined(CH32V30x_C) 26 | #include "../../../variants/CH32V30x/PinAF_CH32V30x.h" 27 | #endif 28 | 29 | #if defined(CH32L10x) 30 | #include "../../../variants/CH32L10x/PinAF_CH32L10x.h" 31 | #endif 32 | 33 | #endif /* _PINAF_CH32YYXX_H */ 34 | -------------------------------------------------------------------------------- /cores/arduino/ch32/bootloader.h: -------------------------------------------------------------------------------- 1 | #ifndef _BOOTLOADER_H_ 2 | #define _BOOTLOADER_H_ 3 | 4 | /* Ensure DTR_TOGGLING_SEQ enabled */ 5 | #if defined(BL_LEGACY_LEAF) || defined(BL_HID) 6 | #ifndef DTR_TOGGLING_SEQ 7 | #define DTR_TOGGLING_SEQ 8 | #endif /* DTR_TOGGLING_SEQ || BL_HID */ 9 | #endif /* BL_LEGACY_LEAF */ 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif /* __cplusplus */ 14 | 15 | #ifdef __cplusplus 16 | } 17 | #endif /* __cplusplus */ 18 | #endif /* _BOOTLOADER_H_ */ 19 | -------------------------------------------------------------------------------- /cores/arduino/ch32/ch32_def.c: -------------------------------------------------------------------------------- 1 | #include "ch32_def.h" 2 | #include "core_debug.h" 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | /** 9 | * @brief This function is executed in case of error occurrence. 10 | * @param None 11 | * @retval None 12 | */ 13 | #if !defined(NDEBUG) 14 | WEAK void _Error_Handler(const char *msg, int val) 15 | { 16 | /* User can add his own implementation to report the HAL error return state */ 17 | core_debug("Error: %s (%i)\n", msg, val); 18 | while (1) { 19 | } 20 | } 21 | #endif 22 | 23 | #ifdef __cplusplus 24 | } 25 | #endif 26 | -------------------------------------------------------------------------------- /cores/arduino/ch32/ch32_def_build.h: -------------------------------------------------------------------------------- 1 | #ifndef _CH32_DEF_BUILD_ 2 | #define _CH32_DEF_BUILD_ 3 | 4 | #if !defined(COM_STARTUP_FILE) 5 | 6 | #if defined(CH32V00x) 7 | #define COM_STARTUP_FILE "startup_ch32v00x.S" 8 | #elif defined(CH32VM00X) 9 | #define COM_STARTUP_FILE "startup_ch32v00X.S" 10 | #elif defined(CH32X035) 11 | #define COM_STARTUP_FILE "startup_ch32x035.S" 12 | 13 | #elif defined(CH32V10x_3V3) 14 | #define COM_STARTUP_FILE "startup_ch32v10x_3v3.S" 15 | #elif defined(CH32V10x_5V) 16 | #define COM_STARTUP_FILE "startup_ch32v10x_5v.S" 17 | 18 | #elif defined(CH32V203) 19 | #define COM_STARTUP_FILE "startup_ch32v20x_D6.S" 20 | #define CH32V20x_D6 21 | #elif defined(CH32V203xB) 22 | #define COM_STARTUP_FILE "startup_ch32v20x_D8.S" 23 | #define CH32V20x_D8 24 | #elif defined(CH32V208) 25 | #define COM_STARTUP_FILE "startup_ch32v20x_D8W.S" 26 | #define CH32V20x_D8W 27 | 28 | #elif defined(CH32V30x_C) 29 | #define COM_STARTUP_FILE "startup_ch32v30x_D8C.S" 30 | #define CH32V30x_D8C 31 | #elif defined(CH32V30x) 32 | #define COM_STARTUP_FILE "startup_ch32v30x_D8.S" 33 | #define CH32V30x_D8 34 | 35 | #elif defined(CH32L10x) 36 | #define COM_STARTUP_FILE "startup_ch32l103.S" 37 | #else 38 | #error "Unknow chip!" 39 | #endif 40 | #else 41 | #warning "No startup file defined !" 42 | #endif /* CHIP Define */ 43 | #endif /* _CH32_DEF_BUILD_ */ 44 | 45 | -------------------------------------------------------------------------------- /cores/arduino/ch32/clock.h: -------------------------------------------------------------------------------- 1 | /** 2 | ******************************************************************************* 3 | * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. 4 | * All rights reserved. 5 | * 6 | * This software component is licensed by WCH under BSD 3-Clause license, 7 | * the "License"; You may not use this file except in compliance with the 8 | * License. You may obtain a copy of the License at: 9 | * opensource.org/licenses/BSD-3-Clause 10 | * 11 | ******************************************************************************* 12 | */ 13 | 14 | /* Define to prevent recursive inclusion -------------------------------------*/ 15 | #ifndef __CLOCK_H 16 | #define __CLOCK_H 17 | 18 | /* Includes ------------------------------------------------------------------*/ 19 | #include "ch32_def.h" 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | 26 | /* Exported constants --------------------------------------------------------*/ 27 | /* Exported macro ------------------------------------------------------------*/ 28 | /* Exported functions ------------------------------------------------------- */ 29 | WEAK uint64_t GetTick(void); 30 | uint32_t getCurrentMillis(void); 31 | uint32_t getCurrentMicros(void); 32 | 33 | // void configIPClock(void); 34 | // void enableClock(sourceClock_t source); 35 | // void configHSECapacitorTuning(void); 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | 41 | #endif /* __CLOCK_H */ 42 | 43 | 44 | -------------------------------------------------------------------------------- /cores/arduino/ch32/hw_config.c: -------------------------------------------------------------------------------- 1 | 2 | #include "hw_config.h" 3 | #include "clock.h" 4 | #include "core_riscv_ch32yyxx.h" 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | #ifndef CH32V10x 11 | void systick_init(void) 12 | { 13 | SysTick->SR = 0; 14 | SysTick->CTLR= 0; 15 | SysTick->CNT = 0; 16 | SysTick->CMP = SystemCoreClock / 1000 - 1; 17 | SysTick->CTLR= 0xF; 18 | NVIC_SetPriority(SysTicK_IRQn,0xFF); 19 | NVIC_EnableIRQ(SysTicK_IRQn); 20 | } 21 | #else //QingKe_V3A registers are different from others 22 | void systick_init(void) 23 | { 24 | uint32_t tmp = 25 | SystemCoreClock / 1000 / 8 - 1; 26 | SysTick->CTLR= 0; 27 | SysTick->CNTL0 = 0;SysTick->CNTL1 = 0;SysTick->CNTL2 = 0;SysTick->CNTL3 = 0; 28 | SysTick->CNTH0 = 0;SysTick->CNTH1 = 0;SysTick->CNTH2 = 0;SysTick->CNTH3 = 0; 29 | SysTick->CMPLR0=(uint8_t)(tmp); 30 | SysTick->CMPLR1=(uint8_t)((tmp)>>8); 31 | SysTick->CMPLR2=(uint8_t)((tmp)>>16); 32 | SysTick->CMPLR3=(uint8_t)((tmp)>>24); 33 | SysTick->CMPHR0=0;SysTick->CMPHR1=0;SysTick->CMPHR2=0;SysTick->CMPHR3=0; 34 | NVIC_SetPriority(SysTicK_IRQn,0xFF); 35 | NVIC_EnableIRQ(SysTicK_IRQn); 36 | SysTick->CTLR=0x1; 37 | } 38 | #endif 39 | 40 | /** 41 | * @brief This function performs the global init of the system (HAL, IOs...) 42 | * @param None 43 | * @retval None 44 | */ 45 | 46 | void hw_config_init(void) 47 | { 48 | systick_init(); 49 | } 50 | #ifdef __cplusplus 51 | } 52 | #endif 53 | 54 | 55 | -------------------------------------------------------------------------------- /cores/arduino/ch32/hw_config.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __HW_CONFIG_H 3 | #define __HW_CONFIG_H 4 | 5 | #include "ch32_def.h" 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | void hw_config_init(void); 12 | 13 | #ifdef __cplusplus 14 | } 15 | #endif 16 | 17 | #endif /* __HW_CONFIG_H */ 18 | 19 | 20 | -------------------------------------------------------------------------------- /cores/arduino/ch32/lib/ch32yyxx.h: -------------------------------------------------------------------------------- 1 | #ifndef _CH32YYXX_H_ 2 | #define _CH32YYXX_H_ 3 | 4 | /* Include Low Layers drivers */ 5 | #include "ch32yyxx_adc.h" 6 | #include "ch32yyxx_bkp.h" 7 | #include "ch32yyxx_can.h" 8 | #include "ch32yyxx_crc.h" 9 | #include "ch32yyxx_dac.h" 10 | #include "ch32yyxx_dbgmcu.h" 11 | #include "ch32yyxx_dma.h" 12 | #include "ch32yyxx_dvp.h" 13 | #include "ch32yyxx_eth.h" 14 | #include "ch32yyxx_exti.h" 15 | #include "ch32yyxx_flash.h" 16 | #include "ch32yyxx_fsmc.h" 17 | #include "ch32yyxx_gpio.h" 18 | #include "ch32yyxx_i2c.h" 19 | #include "ch32yyxx_iwdg.h" 20 | #include "ch32yyxx_misc.h" 21 | #include "ch32yyxx_opa.h" 22 | #include "ch32yyxx_pwr.h" 23 | #include "ch32yyxx_rcc.h" 24 | #include "ch32yyxx_rng.h" 25 | #include "ch32yyxx_rtc.h" 26 | #include "ch32yyxx_sdio.h" 27 | #include "ch32yyxx_spi.h" 28 | #include "ch32yyxx_tim.h" 29 | #include "ch32yyxx_usart.h" 30 | #include "ch32yyxx_wwdg.h" 31 | 32 | #include "ch32yyxx_debug.h" 33 | #include "system_ch32yyxx.h" 34 | #include "core_riscv_cH32yyxx.h" 35 | #include "ch32yyxx_it.h" 36 | 37 | 38 | 39 | 40 | #define UNUSED(x) x ## _UNUSED __attribute__((__unused__)) 41 | 42 | #endif /* _CH32YYXX_H_ */ 43 | -------------------------------------------------------------------------------- /cores/arduino/ch32/lib/ch32yyxx_adc.c: -------------------------------------------------------------------------------- 1 | #ifdef CH32V00x 2 | #include "ch32v00x_adc.c" 3 | 4 | #elif defined(CH32VM00X) 5 | #include "ch32v00X_adc.c" 6 | 7 | #elif defined(CH32X035) 8 | #include "ch32x035_adc.c" 9 | #include "ch32x035_awu.c" 10 | 11 | #elif defined(CH32V10x) 12 | #include "ch32v10x_adc.c" 13 | 14 | #elif defined(CH32V20x) 15 | #include "ch32v20x_adc.c" 16 | 17 | #elif defined(CH32V30x ) || defined (CH32V30x_C) 18 | #include "ch32v30x_adc.c" 19 | 20 | #elif defined(CH32L10x) 21 | #include "ch32l103_adc.c" 22 | #endif 23 | 24 | 25 | -------------------------------------------------------------------------------- /cores/arduino/ch32/lib/ch32yyxx_adc.h: -------------------------------------------------------------------------------- 1 | #ifndef _CH32YYXX_ADC_H_ 2 | #define _CH32YYXX_ADC_H_ 3 | 4 | #ifdef CH32V00x 5 | #include "ch32v00x_adc.h" 6 | 7 | #elif defined(CH32VM00X) 8 | #include "ch32v00X_adc.h" 9 | 10 | #elif defined(CH32X035) 11 | #include "ch32x035_adc.h" 12 | #include "ch32x035_awu.h" 13 | 14 | #elif defined(CH32V10x) 15 | #include "ch32v10x_adc.h" 16 | 17 | #elif defined(CH32V20x) 18 | #include "ch32v20x_adc.h" 19 | 20 | #elif defined(CH32V30x) || defined(CH32V30x_C) 21 | #include "ch32v30x_adc.h" 22 | 23 | #elif defined(CH32L10x) 24 | #include "ch32l103_adc.h" 25 | 26 | #endif 27 | 28 | #endif /* _CH32YYXX_ADC_H_ */ -------------------------------------------------------------------------------- /cores/arduino/ch32/lib/ch32yyxx_bkp.c: -------------------------------------------------------------------------------- 1 | #ifdef CH32V00x 2 | //nothing 3 | #elif defined(CH32V10x) 4 | #include "ch32v10x_bkp.c" 5 | 6 | #elif defined(CH32V20x) 7 | #include "ch32v20x_bkp.c" 8 | 9 | #elif defined(CH32V30x) || defined(CH32V30x_C) 10 | #include "ch32v30x_bkp.c" 11 | 12 | #elif defined(CH32L10x) 13 | #include "ch32l103_bkp.c" 14 | #endif -------------------------------------------------------------------------------- /cores/arduino/ch32/lib/ch32yyxx_bkp.h: -------------------------------------------------------------------------------- 1 | #ifndef _CH32YYXX__BKP_H_ 2 | #define _CH32YYXX__BKP_H_ 3 | 4 | #ifdef CH32V00x 5 | //nothing 6 | 7 | #elif defined (CH32V10x) 8 | #include "ch32v10x_bkp.h" 9 | 10 | #elif defined (CH32V20x) 11 | #include "ch32v20x_bkp.h" 12 | 13 | #elif defined (CH32V30x) || defined (CH32V30x_C) 14 | #include "ch32v30x_bkp.h" 15 | 16 | #elif defined(CH32L10x) 17 | #include "ch32l103_bkp.h" 18 | 19 | 20 | 21 | #endif 22 | 23 | #endif /* _CH32YYXX__BKP_H_ */ -------------------------------------------------------------------------------- /cores/arduino/ch32/lib/ch32yyxx_can.c: -------------------------------------------------------------------------------- 1 | #ifdef CH32V20x 2 | #include "ch32v20x_can.c" 3 | #endif 4 | 5 | #if defined(CH32V30x) || defined(CH32V30x_C) 6 | #include "ch32v30x_can.c" 7 | #endif 8 | 9 | 10 | #if defined(CH32L10x) 11 | #include "ch32l103_can.c" 12 | #endif -------------------------------------------------------------------------------- /cores/arduino/ch32/lib/ch32yyxx_can.h: -------------------------------------------------------------------------------- 1 | #ifndef __CH32YYXX_CAN_H_ 2 | #define __CH32YYXX_CAN_H_ 3 | 4 | #ifdef CH32V20x 5 | #include "ch32v20x_can.h" 6 | #endif 7 | 8 | #if defined(CH32V30x) || defined(CH32V30x_C) 9 | #include "ch32v30x_can.h" 10 | #endif 11 | 12 | #if defined(CH32L10x) 13 | #include "ch32l103_can.h" 14 | #endif 15 | 16 | #endif /*__CH32YYXX_CAN_H_*/ -------------------------------------------------------------------------------- /cores/arduino/ch32/lib/ch32yyxx_crc.c: -------------------------------------------------------------------------------- 1 | #ifdef CH32V10x 2 | #include "ch32v10x_crc.c" 3 | #endif 4 | 5 | #ifdef CH32V20x 6 | #include "ch32v20x_crc.c" 7 | #endif 8 | 9 | #if defined(CH32V30x) || defined(CH32V30x_C) 10 | #include "ch32v30x_crc.c" 11 | #endif 12 | 13 | #if defined(CH32L10x) 14 | #include "ch32l103_crc.c" 15 | #endif -------------------------------------------------------------------------------- /cores/arduino/ch32/lib/ch32yyxx_crc.h: -------------------------------------------------------------------------------- 1 | #ifndef __CH32YYXX_CRC_H_ 2 | #define __CH32YYXX_CRC_H_ 3 | 4 | #ifdef CH32V10x 5 | #include "ch32v10x_crc.h" 6 | #endif 7 | 8 | #ifdef CH32V20x 9 | #include "ch32v20x_crc.h" 10 | #endif 11 | 12 | #if defined(CH32V30x) || defined(CH32V30x_C) 13 | #include "ch32v30x_crc.h" 14 | #endif 15 | 16 | #if defined(CH32L10x) 17 | #include "ch32l103_crc.h" 18 | #endif 19 | 20 | #endif /* __CH32YYXX_CRC_H_ */ -------------------------------------------------------------------------------- /cores/arduino/ch32/lib/ch32yyxx_dac.c: -------------------------------------------------------------------------------- 1 | #if defined(CH32V30x) || defined( CH32V30x_C) 2 | #include "ch32v30x_dac.c" 3 | #endif 4 | -------------------------------------------------------------------------------- /cores/arduino/ch32/lib/ch32yyxx_dac.h: -------------------------------------------------------------------------------- 1 | #ifndef __CH32YYXX_DAC_H_ 2 | #define __CH32YYXX_DAC_H_ 3 | 4 | #if defined(CH32V30x) || defined(CH32V30x_C) 5 | #include "ch32v30x_dac.h" 6 | #endif 7 | 8 | #endif /* __CH32YYXX_DAC_H_ */ -------------------------------------------------------------------------------- /cores/arduino/ch32/lib/ch32yyxx_dbgmcu.c: -------------------------------------------------------------------------------- 1 | #ifdef CH32V00x 2 | #include "ch32v00x_dbgmcu.c" 3 | #endif 4 | 5 | #ifdef CH32VM00X 6 | #include "ch32v00X_dbgmcu.c" 7 | #endif 8 | 9 | #ifdef CH32X035 10 | #include "ch32x035_dbgmcu.c" 11 | #endif 12 | 13 | #ifdef CH32V10x 14 | #include "ch32v10x_dbgmcu.c" 15 | #endif 16 | 17 | #ifdef CH32V20x 18 | 19 | #include "ch32v20x_dbgmcu.c" 20 | 21 | #endif 22 | 23 | #if defined(CH32V30x) || defined(CH32V30x_C) 24 | 25 | #include "ch32v30x_dbgmcu.c" 26 | 27 | #endif 28 | 29 | #if defined(CH32L10x) 30 | #include "ch32l103_dbgmcu.c" 31 | #endif 32 | -------------------------------------------------------------------------------- /cores/arduino/ch32/lib/ch32yyxx_dbgmcu.h: -------------------------------------------------------------------------------- 1 | #ifndef _CH32YYXX_DBGMCU_H_ 2 | #define _CH32YYXX_DBGMCU_H 3 | 4 | #ifdef CH32V00x 5 | #include "ch32v00x_dbgmcu.h" 6 | #endif 7 | 8 | #ifdef CH32VM00X 9 | #include "ch32v00X_dbgmcu.h" 10 | #endif 11 | 12 | #ifdef CH32X035 13 | #include "ch32x035_dbgmcu.h" 14 | #endif 15 | 16 | #ifdef CH32V10x 17 | #include "ch32v10x_dbgmcu.h" 18 | #endif 19 | 20 | #ifdef CH32V20x 21 | #include "ch32v20x_dbgmcu.h" 22 | #endif 23 | 24 | #if defined(CH32V30x) || defined(CH32V30x_C) 25 | #include "ch32v30x_dbgmcu.h" 26 | #endif 27 | 28 | #if defined(CH32L10x) 29 | #include "ch32l103_dbgmcu.h" 30 | #endif 31 | 32 | #endif /* _CH32YYXX_DBGMCU_H_ */ -------------------------------------------------------------------------------- /cores/arduino/ch32/lib/ch32yyxx_debug.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include "debug.c" 4 | 5 | -------------------------------------------------------------------------------- /cores/arduino/ch32/lib/ch32yyxx_debug.h: -------------------------------------------------------------------------------- 1 | #ifndef _CH32YYXX_DEBUG_H_ 2 | #define _CH32YYXX_DEBUG_H_ 3 | 4 | #include "debug.h" 5 | 6 | 7 | #endif /* _CH32YYXX_ADC_H_ */ -------------------------------------------------------------------------------- /cores/arduino/ch32/lib/ch32yyxx_dma.c: -------------------------------------------------------------------------------- 1 | #ifdef CH32V00x 2 | #include "ch32v00x_dma.c" 3 | #endif 4 | 5 | #ifdef CH32VM00X 6 | #include "ch32v00X_dma.c" 7 | #endif 8 | 9 | #ifdef CH32X035 10 | #include "ch32x035_dma.c" 11 | #endif 12 | 13 | #ifdef CH32V10x 14 | #include "ch32v10x_dma.c" 15 | #endif 16 | 17 | #ifdef CH32V20x 18 | #include "ch32v20x_dma.c" 19 | #endif 20 | 21 | #if defined(CH32V30x) || defined(CH32V30x_C) 22 | #include "ch32v30x_dma.c" 23 | #endif 24 | 25 | #if defined(CH32L10x) 26 | #include "ch32l103_dma.c" 27 | #endif -------------------------------------------------------------------------------- /cores/arduino/ch32/lib/ch32yyxx_dma.h: -------------------------------------------------------------------------------- 1 | #ifndef __CH32YYXX_DMA_H__ 2 | #define __CH32YYXX_DMA_H__ 3 | 4 | #ifdef CH32V00x 5 | #include "ch32v00x_dma.h" 6 | #endif 7 | 8 | #ifdef CH32VM00X 9 | #include "ch32v00X_dma.h" 10 | #endif 11 | 12 | #ifdef CH32X035 13 | #include "ch32x035_dma.h" 14 | #endif 15 | 16 | #ifdef CH32V10x 17 | #include "ch32v10x_dma.h" 18 | #endif 19 | 20 | #ifdef CH32V20x 21 | #include "ch32v20x_dma.h" 22 | #endif 23 | 24 | #if defined(CH32V30x) || defined(CH32V30x_C) 25 | #include "ch32v30x_dma.h" 26 | #endif 27 | 28 | #if defined(CH32L10x) 29 | #include "ch32l103_dma.h" 30 | #endif 31 | 32 | #endif /* __CH32YYXX_DMA_H__ */ -------------------------------------------------------------------------------- /cores/arduino/ch32/lib/ch32yyxx_dvp.c: -------------------------------------------------------------------------------- 1 | #if defined(CH32V30x) || defined(CH32V30x_C) 2 | #include "ch32v30x_dvp.c" 3 | #endif -------------------------------------------------------------------------------- /cores/arduino/ch32/lib/ch32yyxx_dvp.h: -------------------------------------------------------------------------------- 1 | #ifndef __CH32YYXX_DVP_H_ 2 | #define __CH32YYXX_DVP_H_ 3 | 4 | #if defined(CH32V30x) || defined(CH32V30x_C) 5 | #include "ch32v30x_dvp.h" 6 | #endif 7 | 8 | #endif /* __CH32YYXX_DVP_H_ */ 9 | -------------------------------------------------------------------------------- /cores/arduino/ch32/lib/ch32yyxx_eth.c: -------------------------------------------------------------------------------- 1 | #if defined(CH32V30x) || defined(CH32V30x_C) 2 | #include "ch32v30x_eth.c" 3 | #endif -------------------------------------------------------------------------------- /cores/arduino/ch32/lib/ch32yyxx_eth.h: -------------------------------------------------------------------------------- 1 | #ifndef __CH32YYXX_ETH_H_ 2 | #define __CH32YYXX_ETH_H_ 3 | 4 | #if defined(CH32V30x) || defined(CH32V30x_C) 5 | #include "ch32v30x_eth.h" 6 | #endif 7 | 8 | #endif /* __CH32YYXX_ETH_H_ */ -------------------------------------------------------------------------------- /cores/arduino/ch32/lib/ch32yyxx_exti.c: -------------------------------------------------------------------------------- 1 | #ifdef CH32V00x 2 | #include "ch32v00x_exti.c" 3 | #endif 4 | 5 | #ifdef CH32VM00X 6 | #include "ch32v00X_exti.c" 7 | #endif 8 | 9 | #ifdef CH32X035 10 | #include "ch32x035_exti.c" 11 | #endif 12 | 13 | #ifdef CH32V10x 14 | #include "ch32v10x_exti.c" 15 | #endif 16 | 17 | #ifdef CH32V20x 18 | #include "ch32v20x_exti.c" 19 | #endif 20 | 21 | #if defined(CH32V30x) || defined(CH32V30x_C) 22 | #include "ch32v30x_exti.c" 23 | #endif 24 | 25 | #if defined(CH32L10x) 26 | #include "ch32l103_exti.c" 27 | #endif 28 | -------------------------------------------------------------------------------- /cores/arduino/ch32/lib/ch32yyxx_exti.h: -------------------------------------------------------------------------------- 1 | #ifndef __CH32YYXX_EXTI_H_ 2 | #define __CH32YYXX_EXTI_H_ 3 | 4 | #ifdef CH32V00x 5 | #include "ch32v00x_exti.h" 6 | #endif 7 | 8 | #ifdef CH32VM00X 9 | #include "ch32v00X_exti.h" 10 | #endif 11 | 12 | #ifdef CH32X035 13 | #include "ch32x035_exti.h" 14 | #endif 15 | 16 | #ifdef CH32V10x 17 | #include "ch32v10x_exti.h" 18 | #endif 19 | 20 | #ifdef CH32V20x 21 | #include "ch32v20x_exti.h" 22 | #endif 23 | 24 | #if defined(CH32V30x) || defined(CH32V30x_C) 25 | #include "ch32v30x_exti.h" 26 | #endif 27 | 28 | #if defined(CH32L10x) 29 | #include "ch32l103_exti.h" 30 | #endif 31 | 32 | #endif /* __CH32YYXX_EXTI_H_ */ -------------------------------------------------------------------------------- /cores/arduino/ch32/lib/ch32yyxx_flash.c: -------------------------------------------------------------------------------- 1 | #ifdef CH32V00x 2 | #include "ch32v00x_flash.c" 3 | #endif 4 | 5 | #ifdef CH32VM00X 6 | #include "ch32v00X_flash.c" 7 | #endif 8 | 9 | #ifdef CH32X035 10 | #include "ch32x035_flash.c" 11 | #endif 12 | 13 | #ifdef CH32V10x 14 | #include "ch32v10x_flash.c" 15 | #endif 16 | 17 | #ifdef CH32V20x 18 | #include "ch32v20x_flash.c" 19 | #endif 20 | 21 | #if defined (CH32V30x) || defined(CH32V30x_C) 22 | #include "ch32v30x_flash.c" 23 | #endif 24 | 25 | 26 | #if defined (CH32L10x) 27 | #include "ch32l103_flash.c" 28 | #endif -------------------------------------------------------------------------------- /cores/arduino/ch32/lib/ch32yyxx_flash.h: -------------------------------------------------------------------------------- 1 | #ifndef __CH32YYXX_FLASH_H_ 2 | #define __CH32YYXX_FLASH_H_ 3 | 4 | #ifdef CH32V00x 5 | #include "ch32v00x_flash.h" 6 | #endif 7 | 8 | #ifdef CH32VM00X 9 | #include "ch32v00X_flash.h" 10 | #endif 11 | 12 | #ifdef CH32X035 13 | #include "ch32x035_flash.h" 14 | #endif 15 | 16 | #ifdef CH32V10x 17 | #include "ch32v10x_flash.h" 18 | #endif 19 | 20 | #ifdef CH32V20x 21 | #include "ch32v20x_flash.h" 22 | #endif 23 | 24 | #if defined(CH32V30x) || defined(CH32V30x_C) 25 | #include "ch32v30x_flash.h" 26 | #endif 27 | 28 | #if defined(CH32L10x) 29 | #include "ch32l103_flash.h" 30 | #endif 31 | 32 | #endif /* __CH32YYXX_FLASH_H_ */ -------------------------------------------------------------------------------- /cores/arduino/ch32/lib/ch32yyxx_fsmc.c: -------------------------------------------------------------------------------- 1 | #if defined(CH32V30x) || defined(CH32V30x_C) 2 | #include "ch32v30x_fsmc.c" 3 | #endif -------------------------------------------------------------------------------- /cores/arduino/ch32/lib/ch32yyxx_fsmc.h: -------------------------------------------------------------------------------- 1 | #ifndef __CH32YYXX_FSMC_H_ 2 | #define __CH32YYXX_FSMC_H_ 3 | 4 | #if defined(CH32V30x) || defined(CH32V30x_C) 5 | #include "ch32v30x_fsmc.h" 6 | #endif 7 | 8 | #endif /* __CH32YYXX_FSMC_H_ */ -------------------------------------------------------------------------------- /cores/arduino/ch32/lib/ch32yyxx_gpio.c: -------------------------------------------------------------------------------- 1 | #ifdef CH32V00x 2 | #include "ch32v00x_gpio.c" 3 | #endif 4 | 5 | #ifdef CH32VM00X 6 | #include "ch32v00X_gpio.c" 7 | #endif 8 | 9 | #ifdef CH32X035 10 | #include "ch32x035_gpio.c" 11 | #endif 12 | 13 | #ifdef CH32V10x 14 | #include "ch32v10x_gpio.c" 15 | #endif 16 | 17 | #ifdef CH32V20x 18 | #include "ch32v20x_gpio.c" 19 | #endif 20 | 21 | #if defined(CH32V30x) || defined(CH32V30x_C) 22 | #include "ch32v30x_gpio.c" 23 | #endif 24 | 25 | #if defined(CH32L10x) 26 | #include "ch32l103_gpio.c" 27 | #endif -------------------------------------------------------------------------------- /cores/arduino/ch32/lib/ch32yyxx_gpio.h: -------------------------------------------------------------------------------- 1 | #ifndef __CH32YYXX_GPIO_H_ 2 | #define __CH32YYXX_GPIO_H_ 3 | 4 | #ifdef CH32V00x 5 | #include "ch32v00x_gpio.h" 6 | #endif 7 | 8 | #ifdef CH32VM00X 9 | #include "ch32v00X_gpio.h" 10 | #endif 11 | 12 | #ifdef CH32X035 13 | #include "ch32x035_gpio.h" 14 | #endif 15 | 16 | #ifdef CH32V10x 17 | #include "ch32v10x_gpio.h" 18 | #endif 19 | 20 | #ifdef CH32V20x 21 | #include "ch32v20x_gpio.h" 22 | #endif 23 | 24 | #if defined(CH32V30x) || defined(CH32V30x_C) 25 | #include "ch32v30x_gpio.h" 26 | #endif 27 | 28 | #if defined(CH32L10x) 29 | #include "ch32l103_gpio.h" 30 | #endif 31 | 32 | #endif /* __CH32YYXX_GPIO_H_ */ -------------------------------------------------------------------------------- /cores/arduino/ch32/lib/ch32yyxx_i2c.c: -------------------------------------------------------------------------------- 1 | #ifdef CH32V00x 2 | #include "ch32v00x_i2c.c" 3 | #endif 4 | 5 | #ifdef CH32VM00X 6 | #include "ch32v00X_i2c.c" 7 | #endif 8 | 9 | #ifdef CH32X035 10 | #include "ch32x035_i2c.c" 11 | #endif 12 | 13 | #ifdef CH32V10x 14 | #include "ch32v10x_i2c.c" 15 | #endif 16 | 17 | #ifdef CH32V20x 18 | #include "ch32v20x_i2c.c" 19 | #endif 20 | 21 | #if defined (CH32V30x) || defined(CH32V30x_C) 22 | #include "ch32v30x_i2c.c" 23 | #endif 24 | 25 | #if defined (CH32L10x) 26 | #include "ch32l103_i2c.c" 27 | #endif -------------------------------------------------------------------------------- /cores/arduino/ch32/lib/ch32yyxx_i2c.h: -------------------------------------------------------------------------------- 1 | #ifndef _CH32YYXX_I2C_H_ 2 | #define _CH32YYXX_I2C_H_ 3 | 4 | #ifdef CH32V00x 5 | #include "ch32v00x_i2c.h" 6 | #endif 7 | 8 | #ifdef CH32VM00X 9 | #include "ch32v00X_i2c.h" 10 | #endif 11 | 12 | #ifdef CH32X035 13 | #include "ch32x035_i2c.h" 14 | #endif 15 | 16 | #ifdef CH32V10x 17 | #include "ch32v10x_i2c.h" 18 | #endif 19 | 20 | #ifdef CH32V20x 21 | #include "ch32v20x_i2c.h" 22 | #endif 23 | 24 | #if defined (CH32V30x) || defined(CH32V30x_C) 25 | #include "ch32v30x_i2c.h" 26 | #endif 27 | 28 | #if defined(CH32L10x) 29 | #include "ch32l103_i2c.h" 30 | #endif 31 | 32 | #endif /* _CH32YYXX_I2C_H_ */ -------------------------------------------------------------------------------- /cores/arduino/ch32/lib/ch32yyxx_it.c: -------------------------------------------------------------------------------- 1 | #ifdef CH32V00x 2 | #include "ch32v00x_it.c" 3 | #endif 4 | 5 | #ifdef CH32VM00X 6 | #include "ch32v00X_it.c" 7 | #endif 8 | 9 | #ifdef CH32X035 10 | #include "ch32x035_it.c" 11 | #endif 12 | 13 | #ifdef CH32V10x 14 | #include "ch32v10x_it.c" 15 | #endif 16 | 17 | #ifdef CH32V20x 18 | #include "ch32v20x_it.c" 19 | #endif 20 | 21 | #if defined (CH32V30x) || defined(CH32V30x_C) 22 | #include "ch32v30x_it.c" 23 | #endif 24 | 25 | #if defined(CH32L10x) 26 | #include "ch32l103_it.c" 27 | #endif 28 | -------------------------------------------------------------------------------- /cores/arduino/ch32/lib/ch32yyxx_it.h: -------------------------------------------------------------------------------- 1 | #ifndef _CH32YYXX_IT_H_ 2 | #define _CH32YYXX_IT_H_ 3 | 4 | #ifdef CH32V00x 5 | #include "ch32v00x_it.h" 6 | #endif 7 | 8 | #ifdef CH32VM00X 9 | #include "ch32v00X_it.h" 10 | #endif 11 | 12 | #ifdef CH32X035 13 | #include "ch32x035_it.h" 14 | #endif 15 | 16 | #ifdef CH32V10x 17 | #include "ch32v10x_it.h" 18 | #endif 19 | 20 | #ifdef CH32V20x 21 | #include "ch32v20x_it.h" 22 | #endif 23 | 24 | #if defined (CH32V30x) || defined(CH32V30x_C) 25 | #include "ch32v30x_it.h" 26 | #endif 27 | 28 | #if defined(CH32L10x) 29 | #include "ch32l103_it.h" 30 | #endif 31 | 32 | #endif /* _CH32YYXX_ADC_H_ */ -------------------------------------------------------------------------------- /cores/arduino/ch32/lib/ch32yyxx_iwdg.c: -------------------------------------------------------------------------------- 1 | #ifdef CH32V00x 2 | #include "ch32v00x_iwdg.c" 3 | #endif 4 | 5 | #ifdef CH32VM00X 6 | #include "ch32v00X_iwdg.c" 7 | #endif 8 | 9 | #ifdef CH32X035 10 | #include "ch32x035_iwdg.c" 11 | #endif 12 | 13 | #ifdef CH32V10x 14 | #include "ch32v10x_iwdg.c" 15 | #endif 16 | 17 | #ifdef CH32V20x 18 | #include "ch32v20x_iwdg.c" 19 | #endif 20 | 21 | #if defined(CH32V30x) || defined(CH32V30x_C) 22 | #include "ch32v30x_iwdg.c" 23 | #endif 24 | 25 | #if defined(CH32L10x) 26 | #include "ch32l103_iwdg.c" 27 | #endif 28 | -------------------------------------------------------------------------------- /cores/arduino/ch32/lib/ch32yyxx_iwdg.h: -------------------------------------------------------------------------------- 1 | #ifndef __CH32YYXX_IWDG_H_ 2 | #define __CH32YYXX_IWDG_H_ 3 | 4 | #ifdef CH32V00x 5 | #include "ch32v00x_iwdg.h" 6 | #endif 7 | 8 | #ifdef CH32VM00X 9 | #include "ch32v00X_iwdg.h" 10 | #endif 11 | 12 | #ifdef CH32X035 13 | #include "ch32x035_iwdg.h" 14 | #endif 15 | 16 | #ifdef CH32V10x 17 | #include "ch32v10x_iwdg.h" 18 | #endif 19 | 20 | #ifdef CH32V20x 21 | #include "ch32v20x_iwdg.h" 22 | #endif 23 | 24 | #if defined (CH32V30x) || defined(CH32V30x_C) 25 | #include "ch32v30x_iwdg.h" 26 | #endif 27 | 28 | #if defined (CH32L10x) 29 | #include "ch32l103_iwdg.h" 30 | #endif 31 | 32 | #endif /* __CH32YYXX_IWDG_H_ */ -------------------------------------------------------------------------------- /cores/arduino/ch32/lib/ch32yyxx_lptim.c: -------------------------------------------------------------------------------- 1 | #if defined(CH32L10x) 2 | #include "ch32l103_lptim.c" 3 | #endif -------------------------------------------------------------------------------- /cores/arduino/ch32/lib/ch32yyxx_lptim.h: -------------------------------------------------------------------------------- 1 | #ifndef __CH32YYXX_LPTIM_H_ 2 | #define __CH32YYXX_LPTIM_H_ 3 | 4 | #if defined(CH32L10x) 5 | #include "ch32l103_lptim.h" 6 | #endif 7 | 8 | #endif /* __CH32YYXX_ETH_H_ */ -------------------------------------------------------------------------------- /cores/arduino/ch32/lib/ch32yyxx_misc.c: -------------------------------------------------------------------------------- 1 | #ifdef CH32V00x 2 | #include "ch32v00x_misc.c" 3 | #endif 4 | 5 | #ifdef CH32VM00X 6 | #include "ch32v00X_misc.c" 7 | #endif 8 | 9 | #ifdef CH32X035 10 | #include "ch32x035_misc.c" 11 | #endif 12 | 13 | #ifdef CH32V10x 14 | #include "ch32v10x_misc.c" 15 | #endif 16 | 17 | #ifdef CH32V20x 18 | #include "ch32v20x_misc.c" 19 | #endif 20 | 21 | #if defined (CH32V30x) || defined(CH32V30x_C) 22 | #include "ch32v30x_misc.c" 23 | #endif 24 | 25 | #if defined(CH32L10x) 26 | #include "ch32l103_misc.c" 27 | #endif 28 | -------------------------------------------------------------------------------- /cores/arduino/ch32/lib/ch32yyxx_misc.h: -------------------------------------------------------------------------------- 1 | #ifndef __CH32YYXX_MISC_H_ 2 | #define __CH32YYXX_MISC_H_ 3 | 4 | #ifdef CH32V00x 5 | #include "ch32v00x_misc.h" 6 | #endif 7 | 8 | #ifdef CH32VM00x 9 | #include "ch32v00X_misc.h" 10 | #endif 11 | 12 | #ifdef CH32X035 13 | #include "ch32x035_misc.h" 14 | #endif 15 | 16 | #ifdef CH32V10x 17 | #include "ch32v10x_misc.h" 18 | #endif 19 | 20 | #ifdef CH32V20x 21 | #include "ch32v20x_misc.h" 22 | #endif 23 | 24 | #if defined (CH32V30x) || defined(CH32V30x_C) 25 | #include "ch32v30x_misc.h" 26 | #endif 27 | 28 | #if defined(CH32L10x) 29 | #include "ch32l103_misc.h" 30 | #endif 31 | 32 | #endif /* __CH32YYXX_MISC_H_ */ -------------------------------------------------------------------------------- /cores/arduino/ch32/lib/ch32yyxx_opa.c: -------------------------------------------------------------------------------- 1 | 2 | #ifdef CH32V00x 3 | #include "ch32v00x_opa.c" 4 | #endif 5 | 6 | #ifdef CH32VM00x 7 | #include "ch32v00X_opa.c" 8 | #endif 9 | 10 | #ifdef CH32X035 11 | #include "ch32x035_opa.c" 12 | #endif 13 | 14 | #ifdef CH32V20x 15 | #include "ch32v20x_opa.c" 16 | #endif 17 | 18 | #if defined(CH32V30x) || defined(CH32V30x_C) 19 | #include "ch32v30x_opa.c" 20 | #endif 21 | 22 | #if defined(CH32L10x) 23 | #include "ch32l103_opa.c" 24 | #endif -------------------------------------------------------------------------------- /cores/arduino/ch32/lib/ch32yyxx_opa.h: -------------------------------------------------------------------------------- 1 | #ifndef __CH32YYXX_OPA_H_ 2 | #define __CH32YYXX_OPA_H_ 3 | 4 | 5 | #ifdef CH32V00x 6 | #include "ch32v00x_opa.h" 7 | #endif 8 | 9 | #ifdef CH32VM00X 10 | #include "ch32v00X_opa.h" 11 | #endif 12 | 13 | #ifdef CH32X035 14 | #include "ch32x035_opa.h" 15 | #endif 16 | 17 | #ifdef CH32V20x 18 | #include "ch32v20x_opa.h" 19 | #endif 20 | 21 | #if defined(CH32V30x) || defined(CH32V30x_C) 22 | #include "ch32v30x_opa.h" 23 | #endif 24 | 25 | #if defined(CH32L10x) 26 | #include "ch32l103_opa.h" 27 | #endif 28 | 29 | #endif /* __CH32YYXX_OPA_H_ */ -------------------------------------------------------------------------------- /cores/arduino/ch32/lib/ch32yyxx_pwr.c: -------------------------------------------------------------------------------- 1 | #ifdef CH32V00x 2 | #include "ch32v00x_pwr.c" 3 | #endif 4 | 5 | #ifdef CH32VM00X 6 | #include "ch32v00X_pwr.c" 7 | #endif 8 | 9 | #ifdef CH32X035 10 | #include "ch32x035_pwr.c" 11 | #endif 12 | 13 | #ifdef CH32V10x 14 | #include "ch32v10x_pwr.c" 15 | #endif 16 | 17 | #ifdef CH32V20x 18 | #include "ch32v20x_pwr.c" 19 | #endif 20 | 21 | #if defined(CH32V30x) || defined(CH32V30x_C) 22 | #include "ch32v30x_pwr.c" 23 | #endif 24 | 25 | #if defined(CH32L10x) 26 | #include "ch32l103_pwr.c" 27 | #endif -------------------------------------------------------------------------------- /cores/arduino/ch32/lib/ch32yyxx_pwr.h: -------------------------------------------------------------------------------- 1 | #ifndef __CH32YYXX_PWR_H_ 2 | #define __CH32YYXX_PWR_H_ 3 | 4 | #ifdef CH32V00x 5 | #include "ch32v00x_pwr.h" 6 | #endif 7 | 8 | #ifdef CH32VM00X 9 | #include "ch32v00X_pwr.h" 10 | #endif 11 | 12 | #ifdef CH32X035 13 | #include "ch32x035_pwr.h" 14 | #endif 15 | 16 | #ifdef CH32V10x 17 | #include "ch32v10x_pwr.h" 18 | #endif 19 | 20 | #ifdef CH32V20x 21 | #include "ch32v20x_pwr.h" 22 | #endif 23 | 24 | #if defined(CH32V30x) ||defined(CH32V30x_C) 25 | #include "ch32v30x_pwr.h" 26 | #endif 27 | 28 | #if defined(CH32L10x) 29 | #include "ch32l103_pwr.h" 30 | #endif 31 | 32 | 33 | 34 | #endif /* __CH32YYXX_PWR_H_ */ -------------------------------------------------------------------------------- /cores/arduino/ch32/lib/ch32yyxx_rcc.c: -------------------------------------------------------------------------------- 1 | #ifdef CH32V00x 2 | #include "ch32v00x_rcc.c" 3 | #endif 4 | 5 | #ifdef CH32VM00X 6 | #include "ch32v00X_rcc.c" 7 | #endif 8 | 9 | #ifdef CH32X035 10 | #include "ch32x035_rcc.c" 11 | #endif 12 | 13 | #ifdef CH32V10x 14 | #include "ch32v10x_rcc.c" 15 | #endif 16 | 17 | #ifdef CH32V20x 18 | #include "ch32v20x_rcc.c" 19 | #endif 20 | 21 | #if defined(CH32V30x) || defined(CH32V30x_C) 22 | #include "ch32v30x_rcc.c" 23 | #endif 24 | 25 | #if defined (CH32L10x) 26 | #include "ch32l103_rcc.c" 27 | #endif 28 | 29 | -------------------------------------------------------------------------------- /cores/arduino/ch32/lib/ch32yyxx_rcc.h: -------------------------------------------------------------------------------- 1 | #ifndef __CH32YYXX_RCC_H_ 2 | #define __CH32YYXX_RCC_H_ 3 | 4 | #ifdef CH32V00x 5 | #include "ch32v00x_rcc.h" 6 | #endif 7 | 8 | #ifdef CH32VM00X 9 | #include "ch32v00X_rcc.h" 10 | #endif 11 | 12 | #ifdef CH32X035 13 | #include "ch32x035_rcc.h" 14 | #endif 15 | 16 | #ifdef CH32V10x 17 | #include "ch32v10x_rcc.h" 18 | #endif 19 | 20 | #ifdef CH32V20x 21 | #include "ch32v20x_rcc.h" 22 | #endif 23 | 24 | #if defined(CH32V30x) || defined(CH32V30x_C) 25 | #include "ch32v30x_rcc.h" 26 | #endif 27 | 28 | #if defined (CH32L10x) 29 | #include "ch32l103_rcc.h" 30 | #endif 31 | 32 | #endif /* __CH32YYXX_RCC_H_ */ -------------------------------------------------------------------------------- /cores/arduino/ch32/lib/ch32yyxx_rng.c: -------------------------------------------------------------------------------- 1 | #if defined(CH32V30x) || defined(CH32V30x_C) 2 | #include "ch32v30x_rng.c" 3 | #endif -------------------------------------------------------------------------------- /cores/arduino/ch32/lib/ch32yyxx_rng.h: -------------------------------------------------------------------------------- 1 | #ifndef __CH32YYXX_RNG_H_ 2 | #define __CH32YYXX_RNG_H_ 3 | 4 | #if defined(CH32V30x) || defined(CH32V30x_C) 5 | #include "ch32v30x_rng.h" 6 | #endif 7 | 8 | #endif /* __CH32YYXX_RNG_H_ */ -------------------------------------------------------------------------------- /cores/arduino/ch32/lib/ch32yyxx_rtc.c: -------------------------------------------------------------------------------- 1 | #ifdef CH32V10x 2 | #include "ch32v10x_rtc.c" 3 | #endif 4 | 5 | #ifdef CH32V20x 6 | #include "ch32v20x_rtc.c" 7 | #endif 8 | 9 | #if defined(CH32V30x) || defined(CH32V30x_C) 10 | #include "ch32v30x_rtc.c" 11 | #endif 12 | 13 | #if defined(CH32L10x) 14 | #include "ch32l103_rtc.c" 15 | #endif -------------------------------------------------------------------------------- /cores/arduino/ch32/lib/ch32yyxx_rtc.h: -------------------------------------------------------------------------------- 1 | #ifndef __CH32YYXX_CTC_H_ 2 | #define __CH32YYXX_CTC_H_ 3 | 4 | #ifdef CH32V10x 5 | #include "ch32v10x_rtc.h" 6 | #endif 7 | 8 | #ifdef CH32V20x 9 | #include "ch32v20x_rtc.h" 10 | #endif 11 | 12 | #if defined(CH32V30x) || defined(CH32V30x_C) 13 | #include "ch32v30x_rtc.h" 14 | #endif 15 | 16 | #if defined(CH32L10x) 17 | #include "ch32l103_rtc.h" 18 | #endif 19 | 20 | #endif /* __CH32YYXX_CTC_H_ */ -------------------------------------------------------------------------------- /cores/arduino/ch32/lib/ch32yyxx_sdio.c: -------------------------------------------------------------------------------- 1 | #if defined(CH32V30x) || defined(CH32V30x_C) 2 | #include "ch32v30x_sdio.c" 3 | #endif -------------------------------------------------------------------------------- /cores/arduino/ch32/lib/ch32yyxx_sdio.h: -------------------------------------------------------------------------------- 1 | #ifndef __CH32YYXX_SDIO_H_ 2 | #define __CH32YYXX_SDIO_H_ 3 | 4 | #if defined(CH32V30x) || defined(CH32V30x_C) 5 | #include "ch32v30x_sdio.h" 6 | #endif 7 | 8 | #endif /* __CH32YYXX_SDIO_H_ */ -------------------------------------------------------------------------------- /cores/arduino/ch32/lib/ch32yyxx_spi.c: -------------------------------------------------------------------------------- 1 | #ifdef CH32V00x 2 | #include "ch32v00x_spi.c" 3 | #endif 4 | 5 | #ifdef CH32VM00X 6 | #include "ch32v00X_spi.c" 7 | #endif 8 | 9 | #ifdef CH32X035 10 | #include "ch32x035_spi.c" 11 | #endif 12 | 13 | #ifdef CH32V10x 14 | #include "ch32v10x_spi.c" 15 | #endif 16 | 17 | #ifdef CH32V20x 18 | #include "ch32v20x_spi.c" 19 | #endif 20 | 21 | #if defined(CH32V30x) || defined(CH32V30x_C) 22 | #include "ch32v30x_spi.c" 23 | #endif 24 | 25 | #if defined(CH32L10x) 26 | #include "ch32l103_spi.c" 27 | #endif -------------------------------------------------------------------------------- /cores/arduino/ch32/lib/ch32yyxx_spi.h: -------------------------------------------------------------------------------- 1 | #ifndef __CH32YYXX_SPI_H_ 2 | #define __CH32YYXX_SPI_H_ 3 | 4 | #ifdef CH32V00x 5 | #include "ch32v00x_spi.h" 6 | #endif 7 | 8 | #ifdef CH32VM00X 9 | #include "ch32v00X_spi.h" 10 | #endif 11 | 12 | #ifdef CH32X035 13 | #include "ch32x035_spi.h" 14 | #endif 15 | 16 | #ifdef CH32V10x 17 | #include "ch32v10x_spi.h" 18 | #endif 19 | 20 | #ifdef CH32V20x 21 | #include "ch32v20x_spi.h" 22 | #endif 23 | 24 | #if defined(CH32V30x) || defined(CH32V30x_C) 25 | #include "ch32v30x_spi.h" 26 | #endif 27 | 28 | #if defined(CH32L10x) 29 | #include "ch32l103_spi.h" 30 | #endif 31 | 32 | #endif /* __CH32YYXX_SPI_H_ */ -------------------------------------------------------------------------------- /cores/arduino/ch32/lib/ch32yyxx_tim.c: -------------------------------------------------------------------------------- 1 | #ifdef CH32V00x 2 | #include "ch32v00x_tim.c" 3 | #endif 4 | 5 | #ifdef CH32VM00X 6 | #include "ch32v00X_tim.c" 7 | #endif 8 | 9 | #ifdef CH32X035 10 | #include "ch32x035_tim.c" 11 | #endif 12 | 13 | #ifdef CH32V10x 14 | #include "ch32v10x_tim.c" 15 | #endif 16 | 17 | #ifdef CH32V20x 18 | #include "ch32v20x_tim.c" 19 | #endif 20 | 21 | #if defined (CH32V30x) || defined(CH32V30x_C) 22 | #include "ch32v30x_tim.c" 23 | #endif 24 | 25 | #if defined (CH32L10x) 26 | #include "ch32l103_tim.c" 27 | #endif -------------------------------------------------------------------------------- /cores/arduino/ch32/lib/ch32yyxx_tim.h: -------------------------------------------------------------------------------- 1 | #ifndef __CH32YYXX_TIM_H_ 2 | #define __CH32YYXX_TIM_H_ 3 | 4 | #ifdef CH32V00x 5 | #include "ch32v00x_tim.h" 6 | #endif 7 | 8 | #ifdef CH32VM00X 9 | #include "ch32v00X_tim.h" 10 | #endif 11 | 12 | #ifdef CH32X035 13 | #include "ch32x035_tim.h" 14 | #endif 15 | 16 | #ifdef CH32V10x 17 | #include "ch32v10x_tim.h" 18 | #endif 19 | 20 | #ifdef CH32V20x 21 | #include "ch32v20x_tim.h" 22 | #endif 23 | 24 | #if defined(CH32V30x) || defined(CH32V30x_C) 25 | #include "ch32v30x_tim.h" 26 | #endif 27 | 28 | #if defined (CH32L10x) 29 | #include "ch32l103_tim.h" 30 | #endif 31 | 32 | #endif /* __CH32YYXX_TIM_H_ */ -------------------------------------------------------------------------------- /cores/arduino/ch32/lib/ch32yyxx_usart.c: -------------------------------------------------------------------------------- 1 | 2 | #ifdef CH32V00x 3 | #include "ch32v00x_usart.c" 4 | #endif 5 | 6 | #ifdef CH32VM00X 7 | #include "ch32v00X_usart.c" 8 | #endif 9 | 10 | #ifdef CH32X035 11 | #include "ch32x035_usart.c" 12 | #endif 13 | 14 | #ifdef CH32V10x 15 | #include "ch32v10x_usart.c" 16 | #endif 17 | 18 | #ifdef CH32V20x 19 | #include "ch32v20x_usart.c" 20 | #endif 21 | 22 | #if defined(CH32V30x) || defined(CH32V30x_C) 23 | #include "ch32v30x_usart.c" 24 | #endif 25 | 26 | #if defined(CH32L10x) 27 | #include "ch32l103_usart.c" 28 | #endif -------------------------------------------------------------------------------- /cores/arduino/ch32/lib/ch32yyxx_usart.h: -------------------------------------------------------------------------------- 1 | #ifndef __CH32YYXX_USART_H_ 2 | #define __CH32YYXX_USART_H_ 3 | 4 | #ifdef CH32V00x 5 | #include "ch32v00x_usart.h" 6 | #endif 7 | 8 | #ifdef CH32VM00X 9 | #include "ch32v00X_usart.h" 10 | #endif 11 | 12 | #ifdef CH32X035 13 | #include "ch32x035_usart.h" 14 | #endif 15 | 16 | #ifdef CH32V10x 17 | #include "ch32v10x_usart.h" 18 | #endif 19 | 20 | #ifdef CH32V20x 21 | #include "ch32v20x_usart.h" 22 | #endif 23 | 24 | #if defined(CH32V30x) || defined(CH32V30x_C) 25 | #include "ch32v30x_usart.h" 26 | #endif 27 | 28 | #if defined(CH32L10x) 29 | #include "ch32l103_usart.h" 30 | #endif 31 | 32 | #endif /* __CH32YYXX_USART_H_ */ -------------------------------------------------------------------------------- /cores/arduino/ch32/lib/ch32yyxx_wwdg.c: -------------------------------------------------------------------------------- 1 | #ifdef CH32V00x 2 | #include "ch32v00x_wwdg.c" 3 | #endif 4 | 5 | #ifdef CH32VM00X 6 | #include "ch32v00X_wwdg.c" 7 | #endif 8 | 9 | #ifdef CH32X035 10 | #include "ch32x035_wwdg.c" 11 | #endif 12 | 13 | #ifdef CH32V10x 14 | #include "ch32v10x_wwdg.c" 15 | #endif 16 | 17 | #ifdef CH32V20x 18 | #include "ch32v20x_wwdg.c" 19 | #endif 20 | 21 | #if defined(CH32V30x) || defined(CH32V30x_C) 22 | #include "ch32v30x_wwdg.c" 23 | #endif 24 | 25 | #if defined(CH32L10x) 26 | #include "ch32l103_wwdg.c" 27 | #endif -------------------------------------------------------------------------------- /cores/arduino/ch32/lib/ch32yyxx_wwdg.h: -------------------------------------------------------------------------------- 1 | #ifndef __CH32YYXX_WWDG_H_ 2 | #define __CH32YYXX_WWDG_H_ 3 | 4 | #ifdef CH32V00x 5 | #include "ch32v00x_wwdg.h" 6 | #endif 7 | 8 | #ifdef CH32VM00X 9 | #include "ch32v00X_wwdg.h" 10 | #endif 11 | 12 | #ifdef CH32X035 13 | #include "ch32x035_wwdg.h" 14 | #endif 15 | 16 | #ifdef CH32V10x 17 | #include "ch32v10x_wwdg.h" 18 | #endif 19 | 20 | #ifdef CH32V20x 21 | #include "ch32v20x_wwdg.h" 22 | #endif 23 | 24 | #if defined(CH32V30x) || defined(CH32V30x_C) 25 | #include "ch32v30x_wwdg.h" 26 | #endif 27 | 28 | #if defined(CH32L10x) 29 | #include "ch32l103_wwdg.h" 30 | #endif 31 | 32 | #endif /* __CH32YYXX_WWDG_H_ */ -------------------------------------------------------------------------------- /cores/arduino/ch32/lib/core_riscv_ch32yyxx.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include "core_riscv.c" 4 | 5 | -------------------------------------------------------------------------------- /cores/arduino/ch32/lib/core_riscv_ch32yyxx.h: -------------------------------------------------------------------------------- 1 | #ifndef _CH32YYXX_DEBUG_H_ 2 | #define _CH32YYXX_DEBUG_H_ 3 | 4 | #include "core_riscv.h" 5 | 6 | 7 | #endif /* _CH32YYXX_DEBUG_H_ */ -------------------------------------------------------------------------------- /cores/arduino/ch32/lib/system_ch32yyxx.c: -------------------------------------------------------------------------------- 1 | #ifdef CH32V00x 2 | #include "system_ch32v00x.c" 3 | #endif 4 | 5 | #ifdef CH32VM00X 6 | #include "system_ch32v00X.c" 7 | #endif 8 | 9 | #ifdef CH32X035 10 | #include "system_ch32x035.c" 11 | #endif 12 | 13 | #ifdef CH32V10x 14 | #include "system_ch32v10x.c" 15 | #endif 16 | 17 | #ifdef CH32V20x 18 | #include "system_ch32v20x.c" 19 | #endif 20 | 21 | #if defined(CH32V30x) || defined(CH32V30x_C) 22 | #include "system_ch32v30x.c" 23 | #endif 24 | 25 | #if defined(CH32L10x) 26 | #include "system_ch32l103.c" 27 | #endif 28 | -------------------------------------------------------------------------------- /cores/arduino/ch32/lib/system_ch32yyxx.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _SYSTEM_CH32YYXX_H_ 3 | #define _SYSTEM_CH32YYXX_H_ 4 | 5 | #ifdef CH32V00x 6 | #include "system_ch32v00x.h" 7 | #endif 8 | 9 | #ifdef CH32VM00X 10 | #include "system_ch32v00X.h" 11 | #endif 12 | 13 | #ifdef CH32X035 14 | #include "system_ch32x035.h" 15 | #endif 16 | 17 | #ifdef CH32V10x 18 | #include "system_ch32v10x.h" 19 | #endif 20 | 21 | #ifdef CH32V20x 22 | #include "system_ch32v20x.h" 23 | #endif 24 | 25 | #if defined(CH32V30x) || defined(CH32V30x_C) 26 | #include "system_ch32v30x.h" 27 | #endif 28 | 29 | #if defined(CH32L10x) 30 | #include "system_ch32l103.h" 31 | #endif 32 | 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /cores/arduino/ch32/startup_ch32yyxx.S: -------------------------------------------------------------------------------- 1 | #include "ch32_def_build.h" 2 | 3 | 4 | #ifdef COM_STARTUP_FILE 5 | #include COM_STARTUP_FILE 6 | #endif 7 | 8 | -------------------------------------------------------------------------------- /cores/arduino/ch32/timer.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openwch/arduino_core_ch32/d76716239cdf8a084a5045c3dfd3151b3f69eeec/cores/arduino/ch32/timer.h -------------------------------------------------------------------------------- /cores/arduino/core_debug.c: -------------------------------------------------------------------------------- 1 | #include "core_debug.h" 2 | 3 | // Ensure inline functions have a definition emitted for when they are 4 | // not inlined (needed for C functions only) 5 | extern void core_debug(const char *format, ...); 6 | extern void vcore_debug(const char *format, va_list args); 7 | -------------------------------------------------------------------------------- /cores/arduino/core_debug.h: -------------------------------------------------------------------------------- 1 | #ifndef _CORE_DEBUG_H 2 | #define _CORE_DEBUG_H 3 | 4 | #include 5 | #if !defined(NDEBUG) 6 | #include 7 | #endif /* NDEBUG */ 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /** Output a debug message 14 | * 15 | * @param format printf-style format string, followed by variables 16 | * Note: By using the printf function of the library C this inflates the size of 17 | * the code, use a lot of stack. An alternative, will be to implement a tiny 18 | * and limited functionality implementation of printf. 19 | */ 20 | inline void core_debug(const char *format, ...) 21 | { 22 | #if !defined(NDEBUG) 23 | va_list args; 24 | va_start(args, format); 25 | vfprintf(stderr, format, args); 26 | va_end(args); 27 | #else 28 | (void)(format); 29 | #endif /* NDEBUG */ 30 | } 31 | 32 | inline void vcore_debug(const char *format, va_list args) 33 | { 34 | #if !defined(NDEBUG) 35 | vfprintf(stderr, format, args); 36 | #else 37 | (void)(format); 38 | (void)(args); 39 | #endif /* NDEBUG */ 40 | } 41 | 42 | #ifdef __cplusplus 43 | } 44 | #endif 45 | 46 | #endif /* _CORE_DEBUG_H */ 47 | -------------------------------------------------------------------------------- /cores/arduino/hooks.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012 Arduino. All right reserved. 3 | 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | See the GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with this library; if not, write to the Free Software 16 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | #include 20 | 21 | /** 22 | * Empty yield() hook. 23 | * 24 | * This function is intended to be used by library writers to build 25 | * libraries or sketches that supports cooperative threads. 26 | * 27 | * Its defined as a weak symbol and it can be redefined to implement a 28 | * real cooperative scheduler. 29 | */ 30 | static void __empty() 31 | { 32 | // Empty 33 | } 34 | void yield(void) __attribute__((weak, alias("__empty"))); 35 | 36 | #ifdef DTR_TOGGLING_SEQ 37 | /** 38 | * Empty dtr_toggling() hook. 39 | * 40 | * This function is intended to be used by library writers to build 41 | * libraries or sketches that require DTR toggling feature. 42 | * 43 | * Its defined as a weak symbol and it can be redefined to implement 44 | * task to achieve in this case. 45 | */ 46 | static void __empty_dtr_toggling(uint8_t *buf, uint32_t *len) 47 | { 48 | (void)buf; 49 | (void)len; 50 | } 51 | void dtr_togglingHook(uint8_t *buf, uint32_t *len) __attribute__((weak, alias("__empty_dtr_toggling"))); 52 | #endif -------------------------------------------------------------------------------- /cores/arduino/itoa.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2011 Arduino. All right reserved. 3 | 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | See the GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with this library; if not, write to the Free Software 16 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | #ifndef _ITOA_ 20 | #define _ITOA_ 21 | 22 | #ifdef __cplusplus 23 | extern "C"{ 24 | #endif // __cplusplus 25 | 26 | #if 0 27 | 28 | extern void itoa( int n, char s[] ) ; 29 | 30 | #else 31 | 32 | extern char* itoa( int value, char *string, int radix ) ; 33 | extern char* ltoa( long value, char *string, int radix ) ; 34 | #if __GNUC__ > 4 || (__GNUC__ == 4 && (__GNUC_MINOR__ > 9 || \ 35 | (__GNUC_MINOR__ == 9 && __GNUC_PATCHLEVEL__ > 2))) 36 | extern char* utoa( unsigned value, char *string, int radix ) ; 37 | #else 38 | extern char* utoa( unsigned long value, char *string, int radix ) ; 39 | #endif 40 | extern char* ultoa( unsigned long value, char *string, int radix ) ; 41 | #endif /* 0 */ 42 | 43 | #ifdef __cplusplus 44 | } // extern "C" 45 | #endif // __cplusplus 46 | 47 | #endif // _ITOA_ 48 | -------------------------------------------------------------------------------- /cores/arduino/main.cpp: -------------------------------------------------------------------------------- 1 | #define ARDUINO_MAIN 2 | 3 | #include "Arduino.h" 4 | #include "debug.h" 5 | 6 | 7 | /* 8 | * \brief Main entry point of Arduino application 9 | */ 10 | int main( void ) 11 | { 12 | pre_init( ); 13 | #if defined(USE_TINYUSB) 14 | if (TinyUSB_Device_Init) { 15 | TinyUSB_Device_Init(0); 16 | } 17 | #endif 18 | setup( ); 19 | 20 | do { 21 | loop( ); 22 | #if defined(USE_TINYUSB) 23 | if (TinyUSB_Device_Task) { 24 | TinyUSB_Device_Task(); 25 | } 26 | if (TinyUSB_Device_FlushCDC) { 27 | TinyUSB_Device_FlushCDC(); 28 | } 29 | #endif 30 | } while (1); 31 | 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /cores/arduino/variant.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | #include VARIANT_H 5 | -------------------------------------------------------------------------------- /cores/arduino/wiring_pulse.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2011 Arduino. All right reserved. 3 | 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | See the GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with this library; if not, write to the Free Software 16 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | #ifndef _WIRING_PULSE_ 20 | #define _WIRING_PULSE_ 21 | 22 | #ifdef __cplusplus 23 | /* 24 | * \brief Measures the length (in microseconds) of a pulse on the pin; state is HIGH 25 | * or LOW, the type of pulse to measure. Works on pulses from 2-3 microseconds 26 | * to 3 minutes in length, but must be called at least a few dozen microseconds 27 | * before the start of the pulse. 28 | */ 29 | extern uint32_t pulseIn(uint32_t pin, uint32_t state, uint32_t timeout = 1000000L) ; 30 | extern uint32_t pulseInLong(uint32_t pin, uint32_t state, uint32_t timeout = 1000000L) ; 31 | #endif 32 | 33 | #endif /* _WIRING_PULSE_ */ 34 | -------------------------------------------------------------------------------- /cores/arduino/wiring_shift.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2011 Arduino. All right reserved. 3 | 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | See the GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with this library; if not, write to the Free Software 16 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | #ifndef _WIRING_SHIFT_ 20 | #define _WIRING_SHIFT_ 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | /* 27 | * \brief 28 | */ 29 | extern uint32_t shiftIn(uint32_t ulDataPin, uint32_t ulClockPin, uint32_t ulBitOrder) ; 30 | 31 | 32 | /* 33 | * \brief 34 | */ 35 | extern void shiftOut(uint32_t ulDataPin, uint32_t ulClockPin, uint32_t ulBitOrder, uint32_t ulVal) ; 36 | 37 | 38 | #ifdef __cplusplus 39 | } 40 | #endif 41 | 42 | #endif /* _WIRING_SHIFT_ */ 43 | -------------------------------------------------------------------------------- /cores/arduino/wiring_time.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2011 Arduino. All right reserved. 3 | 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | See the GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with this library; if not, write to the Free Software 16 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | #include "Arduino.h" 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | uint32_t millis(void) 26 | { 27 | // ToDo: ensure no interrupts 28 | return getCurrentMillis(); 29 | } 30 | 31 | // Interrupt-compatible version of micros 32 | uint32_t micros(void) 33 | { 34 | return getCurrentMicros(); 35 | } 36 | 37 | void delay(uint32_t ms) 38 | { 39 | if (ms != 0) { 40 | uint32_t start = getCurrentMillis(); 41 | do { 42 | yield(); 43 | } while (getCurrentMillis() - start < ms); 44 | } 45 | } 46 | 47 | #ifdef __cplusplus 48 | } 49 | #endif 50 | -------------------------------------------------------------------------------- /libraries/EEPROM/examples/eeprom_counter/eeprom_counter.ino: -------------------------------------------------------------------------------- 1 | /*** 2 | eeprom_counter example. 3 | Written by by Maxint R&D for CH32. 4 | 5 | The purpose of this example is to demonstrate non-volatile storage of a simple counter that counts 6 | the times that the setup() function was called. It also shows the entire contents of the EEPROM. 7 | ***/ 8 | #include 9 | 10 | void setup() 11 | { 12 | Serial.begin(115200); 13 | delay(2000); // allow some time for Arduino IDE v2 serial console to show after recompiling 14 | Serial.println("\n--- EEPROM COUNTER EXAMPLE ---"); 15 | Serial.printf("Option bytes: 0x%08x\r\n", EEPROM.ReadOptionBytes()); // usually FF FF to start with 16 | EEPROM.begin(); 17 | 18 | // Read the counter at EEPROM address 0, increment and write it back. 19 | uint8_t bootcnt=EEPROM.read(0); 20 | bootcnt++; 21 | EEPROM.write(0, bootcnt); 22 | Serial.printf("Boot count is %d [0x%02X]\n",bootcnt, bootcnt); 23 | 24 | // Use EEPROM.commit() to write data to permanent storage 25 | EEPROM.commit(); 26 | 27 | // Show the contents of the entire EEPROM memory 28 | Serial.print("EEPROM contents:"); 29 | for(int n=0; n 12 | 13 | void setup() { 14 | // Initialize serial and wait for port to open: 15 | Serial.begin(115200); 16 | while (!Serial) { 17 | ; // wait for serial port to connect. Needed for native USB port only 18 | } 19 | 20 | // Initialize EEPROM object 21 | EEPROM.begin(); 22 | 23 | //Print length of data to run CRC on. 24 | Serial.print("EEPROM length: "); 25 | Serial.println(EEPROM.length()); 26 | 27 | //Print the result of calling eeprom_crc() 28 | Serial.print("CRC32 of EEPROM data: 0x"); 29 | Serial.println(eeprom_crc(), HEX); 30 | Serial.print("\n\nDone!"); 31 | } 32 | 33 | void loop() { 34 | /* Empty loop */ 35 | } 36 | 37 | unsigned long eeprom_crc(void) { 38 | 39 | const unsigned long crc_table[16] = { 40 | 0x00000000, 0x1db71064, 0x3b6e20c8, 0x26d930ac, 41 | 0x76dc4190, 0x6b6b51f4, 0x4db26158, 0x5005713c, 42 | 0xedb88320, 0xf00f9344, 0xd6d6a3e8, 0xcb61b38c, 43 | 0x9b64c2b0, 0x86d3d2d4, 0xa00ae278, 0xbdbdf21c 44 | }; 45 | 46 | unsigned long crc = ~0L; 47 | 48 | for (int index = 0 ; index < EEPROM.length() ; ++index) { 49 | crc = crc_table[(crc ^ EEPROM[index]) & 0x0f] ^ (crc >> 4); 50 | crc = crc_table[(crc ^ (EEPROM[index] >> 4)) & 0x0f] ^ (crc >> 4); 51 | crc = ~crc; 52 | } 53 | return crc; 54 | } 55 | -------------------------------------------------------------------------------- /libraries/EEPROM/examples/eeprom_put/eeprom_put.ino: -------------------------------------------------------------------------------- 1 | /*** 2 | eeprom_put example. 3 | 4 | This shows how to use the EEPROM.put() method. 5 | Also, this sketch will pre-set the EEPROM data for the 6 | example sketch eeprom_get. 7 | 8 | Note, unlike the single byte version EEPROM.write(), 9 | the put method will use update semantics. As in a byte 10 | will only be written to the EEPROM if the data is actually 11 | different. 12 | 13 | Written by Christopher Andrews 2015. Modified by Maxint R&D for CH32. 14 | Released under MIT licence. 15 | ***/ 16 | 17 | #include 18 | 19 | struct MyObject { 20 | float field1; 21 | byte field2; 22 | char name[10]; 23 | }; 24 | 25 | void setup() { 26 | float f = 123.456f; //Variable to store in EEPROM. 27 | int eeAddress = 0; //Location we want the data to be put. 28 | 29 | Serial.begin(115200); 30 | while (!Serial) { 31 | ; // wait for serial port to connect. Needed for native USB port only 32 | } 33 | 34 | // initialize EEPROM object 35 | EEPROM.begin(); 36 | 37 | //One simple call, with the address first and the object second. 38 | EEPROM.put(eeAddress, f); 39 | 40 | Serial.println("Written float data type!"); 41 | 42 | /** Put is designed for use with custom structures also. **/ 43 | 44 | //Data to store. 45 | MyObject customVar = { 46 | 3.14f, 47 | 42, 48 | "Working!" 49 | }; 50 | 51 | eeAddress += sizeof(float); //Move address to the next byte after float 'f'. 52 | 53 | EEPROM.put(eeAddress, customVar); 54 | 55 | // Use EEPROM.commit() to write data to permanent storage 56 | EEPROM.commit(); 57 | 58 | Serial.print("Written custom data type! \n\nView the example sketch eeprom_get to see how you can retrieve the values!"); 59 | } 60 | 61 | void loop() { 62 | /* Empty loop */ 63 | } 64 | -------------------------------------------------------------------------------- /libraries/EEPROM/examples/eeprom_read/eeprom_read.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * EEPROM Read 3 | * 4 | * Reads the value of each byte of the EEPROM and prints it 5 | * to the computer. 6 | * This example code is in the public domain. 7 | */ 8 | 9 | #include 10 | 11 | // start reading from the first byte (address 0) of the EEPROM 12 | int address = 0; 13 | byte value; 14 | 15 | void setup() { 16 | // initialize serial and wait for port to open: 17 | Serial.begin(115200); 18 | while (!Serial) { 19 | ; // wait for serial port to connect. Needed for native USB port only 20 | } 21 | 22 | // initialize EEPROM object 23 | EEPROM.begin(); 24 | } 25 | 26 | void loop() { 27 | // read a byte from the current address of the EEPROM 28 | value = EEPROM.read(address); 29 | 30 | Serial.print(address); 31 | Serial.print("\t"); 32 | Serial.print(value, DEC); 33 | Serial.println(); 34 | 35 | /*** 36 | Advance to the next address, when at the end restart at the beginning. 37 | 38 | The CH32 EEPROM library uses the user storage area, allowing 26 bytes of emulated EEPROM on the CH32V003. 39 | 40 | Other processors may have larger EEPROM sizes, e.g: 41 | - Arduno Duemilanove: 512b EEPROM storage. 42 | - Arduino Uno: 1kb EEPROM storage. 43 | - Arduino Mega: 4kb EEPROM storage. 44 | 45 | Rather than hard-coding the length, you should use the pre-provided length function. 46 | This will make your code portable to all AVR processors. 47 | ***/ 48 | address = address + 1; 49 | if (address == EEPROM.length()) { 50 | address = 0; 51 | } 52 | 53 | delay(500); 54 | } 55 | -------------------------------------------------------------------------------- /libraries/EEPROM/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For EEPROM 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | EEPROM KEYWORD1 10 | EEPROMClass KEYWORD1 11 | EERef KEYWORD1 12 | EEPtr KEYWORD2 13 | 14 | ####################################### 15 | # Methods and Functions (KEYWORD2) 16 | ####################################### 17 | 18 | update KEYWORD2 19 | begin KEYWORD2 20 | write KEYWORD2 21 | commit KEYWORD2 22 | 23 | ####################################### 24 | # Instances (KEYWORD2) 25 | ####################################### 26 | 27 | EEPROM KEYWORD2 28 | 29 | ####################################### 30 | # Constants (LITERAL1) 31 | ####################################### 32 | -------------------------------------------------------------------------------- /libraries/EEPROM/library.properties: -------------------------------------------------------------------------------- 1 | name=EEPROM 2 | version=1.0.0 3 | author=Maxint 4 | maintainer=https://github.com/maxint-rd 5 | sentence=Enables reading and writing to non-volatile storage in the processor. 6 | paragraph=This library uses the option bytes page of the CH32 to emulate EEPROM. EEPROM keeps its content also when the MCU is powered off. The amount of EEPROM available is limited to 26 bytes. Tested with CH32V003. 7 | category=Data Storage 8 | url=http://arduino.cc/en/Reference/EEPROM 9 | architectures=ch32v 10 | -------------------------------------------------------------------------------- /libraries/SPI/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map SPI 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | SPI KEYWORD1 10 | 11 | ####################################### 12 | # Methods and Functions (KEYWORD2) 13 | ####################################### 14 | begin KEYWORD2 15 | end KEYWORD2 16 | transfer KEYWORD2 17 | #setBitOrder KEYWORD2 18 | setDataMode KEYWORD2 19 | setClockDivider KEYWORD2 20 | setMISO KEYWORD2 21 | setMOSI KEYWORD2 22 | setSCLK KEYWORD2 23 | setSSEL KEYWORD2 24 | 25 | ####################################### 26 | # Constants (LITERAL1) 27 | ####################################### 28 | SPI_MODE0 LITERAL1 29 | SPI_MODE1 LITERAL1 30 | SPI_MODE2 LITERAL1 31 | SPI_MODE3 LITERAL1 32 | 33 | SPI_CONTINUE LITERAL1 34 | SPI_LAST LITERAL1 35 | -------------------------------------------------------------------------------- /libraries/SPI/library.properties: -------------------------------------------------------------------------------- 1 | name=SPI 2 | version=1.0.0 3 | author=Modified by Temperslee 4 | maintainer=CH32duino 5 | sentence=Enables the communication with devices that use the Serial Peripheral Interface (SPI) Bus. 6 | paragraph=This library is based on the official Arduino SPI library and adapted to CH32 boards. 7 | category=Communication 8 | url=http://www.arduino.cc/en/Reference/SPI 9 | architectures=ch32v 10 | -------------------------------------------------------------------------------- /libraries/USBPD_SINK/examples/usbpd_sink_request_voltage/usbpd_sink_request_voltage.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #define KEY_INPUT A10 //PC0 5 | 6 | uint8_t myIndex = 0; 7 | uint8_t setVoltage = REQUEST_5v; 8 | 9 | void setup() { 10 | // put your setup code here, to run once: 11 | 12 | Serial.begin(115200); 13 | usbpd_sink_init(); 14 | 15 | pinMode(KEY_INPUT,INPUT_PULLUP); 16 | } 17 | 18 | void loop() { 19 | // put your main code here, to run repeatedly: 20 | 21 | if(usbpd_sink_get_ready()) 22 | { 23 | if(usbpd_sink_set_request_fixed_voltage(setVoltage) == false) 24 | { 25 | Serial.printf("unsupported voltage\r\n"); 26 | } 27 | } 28 | 29 | // button, myIndex++ 30 | if(digitalRead(KEY_INPUT) == 0) 31 | { 32 | delay(50); 33 | if(digitalRead(KEY_INPUT) == 0) 34 | { 35 | while(digitalRead(KEY_INPUT) == 0); 36 | 37 | myIndex++; 38 | if(myIndex>4) myIndex = 0; 39 | Serial.printf("key press %d\r\n",myIndex); 40 | } 41 | } 42 | switch(myIndex) 43 | { 44 | case 0: 45 | setVoltage = REQUEST_5v; 46 | break; 47 | case 1: 48 | setVoltage = REQUEST_9v; 49 | break; 50 | case 2: 51 | setVoltage = REQUEST_12v; 52 | break; 53 | case 3: 54 | setVoltage = REQUEST_15v; 55 | break; 56 | case 4: 57 | setVoltage = REQUEST_20v; 58 | break; 59 | default: 60 | setVoltage = REQUEST_5v; 61 | break; 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /libraries/USBPD_SINK/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For USBPD 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | Request_voltage_t KEYWORD1 9 | 10 | 11 | ####################################### 12 | # Methods and Functions (KEYWORD2) 13 | ####################################### 14 | 15 | 16 | 17 | 18 | ####################################### 19 | # Instances (KEYWORD2) 20 | ####################################### 21 | 22 | 23 | 24 | ####################################### 25 | # Constants (LITERAL1) 26 | ####################################### 27 | REQUEST_5v LITERAL1 28 | REQUEST_9v LITERAL1 29 | REQUEST_12v LITERAL1 30 | REQUEST_15v LITERAL1 31 | REQUEST_20v LITERAL1 -------------------------------------------------------------------------------- /libraries/USBPD_SINK/library.properties: -------------------------------------------------------------------------------- 1 | name=USBPD_SINK 2 | version=1.0.0 3 | author= 4 | maintainer=ch32duino 5 | sentence= USBPD_SINK, request 5v, 9v, 12, 15v 20v. 6 | paragraph= 7 | category= 8 | url=https://www.wch.cn/ 9 | architectures=ch32v 10 | -------------------------------------------------------------------------------- /libraries/Wire/examples/at24c02_read_write/at24c02_read_write.ino: -------------------------------------------------------------------------------- 1 | /* 2 | EEPROM AT24C02 read and write 3 | 4 | This example read/write an EEPROM AT24C02 by I2C port. 5 | 6 | AT24c02 Circuit: 7 | 8 | A0/A1/A2/GND ----- GND (So device address is 0xA0 (0x50 << 1) ) 9 | VCC -------------- VCC 10 | WP -------------- GND 11 | SCL -------------- SCL(MCU) 12 | SDA ---------------SDA(MCU) 13 | 14 | created 30 Jurn 2023 15 | by TempersLee 16 | 17 | */ 18 | 19 | #include 20 | 21 | 22 | #define AT24C02_ADDR 0x50 //will left shift 1 bits in library 23 | void setup() 24 | { 25 | uint16_t i=0; 26 | Serial.begin(115200); 27 | Serial.printf("%s Chip ID: 0x%08x\r\n", "Hello CH32duino!", DBGMCU_GetDEVID()); 28 | Wire.begin(); // join i2c bus (address optional for master) 29 | 30 | Serial.printf("Write AT24C02:\r\n"); 31 | for(i=0;i<256;i++) 32 | { 33 | deviceWriteOneByte(i,i); 34 | delay(5); 35 | } 36 | Serial.printf("Write Finish!\r\n"); 37 | 38 | Serial.printf("Read AT24C02:\r\n"); 39 | for(i=0;i<256;i++) 40 | { 41 | if(i%16 == 0 && i!=0)Serial.printf("\n"); 42 | Serial.printf("%02x ",deviceReadOneByte(i)); 43 | } 44 | 45 | Serial.printf("\r\nEND!\r\n"); 46 | } 47 | 48 | 49 | void loop() 50 | { 51 | 52 | } 53 | 54 | 55 | 56 | void deviceWriteOneByte(uint8_t addr, uint8_t data) 57 | { 58 | Wire.beginTransmission(AT24C02_ADDR); //transmit to device AT24C02 59 | Wire.write(addr); 60 | Wire.write(data); 61 | Wire.endTransmission(); 62 | } 63 | 64 | uint8_t deviceReadOneByte(uint8_t addr) 65 | { 66 | Wire.requestFrom(AT24C02_ADDR,1,addr,1,1); 67 | while (Wire.available()) 68 | { 69 | return Wire.read(); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /libraries/Wire/examples/i2c_scanner/README.md: -------------------------------------------------------------------------------- 1 | # I2C Scanner 2 | Original I2C Scanner example by Nick Gammon 3 | I2C Scanner - Written by Nick Gammon - Date: 20th April 2011 [source](http://arduino-info.wikispaces.com/LCD-Blue-I2C). 4 | 5 | Demonstrates CH32 Support for I2C scanning using Wire.endTransmission() without sending data. 6 | To enable scanning these changes are required in libraries/Wire/src/utility/twi.c : 7 | - timeout on an addresses should release the bus 8 | - allow only sending the address (without actual data) 9 | - smaller timeout: I2C_TIMEOUT_TICK 25 (was 100ms) 10 | 11 | Note: Currently there's no support for [Wire.setWireTimeout(timeout, reset_on_timeout)](https://www.arduino.cc/reference/en/language/functions/communication/wire/setwiretimeout/). 12 | Inspiration from [i2c_scanner](https://github.com/mockthebear/easy-ch32v003/tree/main/examples/i2c_scanner) by @mockthebear. 13 | -------------------------------------------------------------------------------- /libraries/Wire/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For Wire 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | ####################################### 10 | # Methods and Functions (KEYWORD2) 11 | ####################################### 12 | 13 | begin KEYWORD2 14 | setClock KEYWORD2 15 | beginTransmission KEYWORD2 16 | endTransmission KEYWORD2 17 | requestFrom KEYWORD2 18 | onReceive KEYWORD2 19 | onRequest KEYWORD2 20 | setSCL KEYWORD2 21 | setSDA KEYWORD2 22 | 23 | ####################################### 24 | # Instances (KEYWORD2) 25 | ####################################### 26 | 27 | Wire KEYWORD2 28 | 29 | ####################################### 30 | # Constants (LITERAL1) 31 | ####################################### 32 | -------------------------------------------------------------------------------- /libraries/Wire/library.properties: -------------------------------------------------------------------------------- 1 | name=Wire 2 | version=1.0.0 3 | author=Arduino, Wi6Labs, Modified by Temperslee 4 | maintainer=ch32duino 5 | sentence=Allows the communication between devices or sensors connected via Two Wire (I2C) Interface Bus. 6 | paragraph= 7 | category=Communication 8 | url=http://www.arduino.cc/en/Reference/Wire 9 | architectures=ch32v 10 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Core library for CH32duino", 3 | "name": "framework-arduino-openwch-ch32", 4 | "system": "all", 5 | "url": "https://github.com/openwch/arduino_core_ch32", 6 | "version": "0.0.0" 7 | } 8 | -------------------------------------------------------------------------------- /programmers.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openwch/arduino_core_ch32/d76716239cdf8a084a5045c3dfd3151b3f69eeec/programmers.txt -------------------------------------------------------------------------------- /system/CH32L10x/SRC/Debug/debug.h: -------------------------------------------------------------------------------- 1 | /********************************** (C) COPYRIGHT ******************************* 2 | * File Name : debug.h 3 | * Author : WCH 4 | * Version : V1.0.0 5 | * Date : 2023/07/08 6 | * Description : This file contains all the functions prototypes for UART 7 | * Printf , Delay functions. 8 | ********************************************************************************* 9 | * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. 10 | * Attention: This software (modified or not) and binary are used for 11 | * microcontroller manufactured by Nanjing Qinheng Microelectronics. 12 | *******************************************************************************/ 13 | #ifndef __DEBUG_H 14 | #define __DEBUG_H 15 | 16 | #include "stdio.h" 17 | #include "ch32l103.h" 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | /* UART Printf Definition */ 24 | #define DEBUG_UART1 1 25 | #define DEBUG_UART2 2 26 | #define DEBUG_UART3 3 27 | 28 | /* DEBUG UATR Definition */ 29 | #ifndef DEBUG 30 | #define DEBUG DEBUG_UART1 31 | #endif 32 | 33 | extern uint32_t OPA_Trim; 34 | extern uint16_t ADC_Trim; 35 | extern uint32_t TS_Val; 36 | extern uint32_t CHIPID; 37 | 38 | void Delay_Init(void); 39 | void Delay_Us(uint32_t n); 40 | void Delay_Ms(uint32_t n); 41 | void USART_Printf_Init(uint32_t baudrate); 42 | 43 | #if(DEBUG) 44 | #define PRINT(format, ...) printf(format, ##__VA_ARGS__) 45 | #else 46 | #define PRINT(X...) 47 | #endif 48 | 49 | #ifdef __cplusplus 50 | } 51 | #endif 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /system/CH32L10x/SRC/Peripheral/inc/ch32l103_crc.h: -------------------------------------------------------------------------------- 1 | /********************************** (C) COPYRIGHT ******************************* 2 | * File Name : ch32l103_crc.h 3 | * Author : WCH 4 | * Version : V1.0.0 5 | * Date : 2023/07/08 6 | * Description : This file contains all the functions prototypes for the 7 | * CRC firmware library. 8 | ********************************************************************************* 9 | * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. 10 | * Attention: This software (modified or not) and binary are used for 11 | * microcontroller manufactured by Nanjing Qinheng Microelectronics. 12 | *******************************************************************************/ 13 | #ifndef __CH32L103_CRC_H 14 | #define __CH32L103_CRC_H 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | #include "ch32l103.h" 21 | 22 | void CRC_ResetDR(void); 23 | uint32_t CRC_CalcCRC(uint32_t Data); 24 | uint32_t CRC_CalcBlockCRC(uint32_t pBuffer[], uint32_t BufferLength); 25 | uint32_t CRC_GetCRC(void); 26 | void CRC_SetIDRegister(uint8_t IDValue); 27 | uint8_t CRC_GetIDRegister(void); 28 | 29 | #ifdef __cplusplus 30 | } 31 | #endif 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /system/CH32L10x/SRC/Peripheral/inc/ch32l103_wwdg.h: -------------------------------------------------------------------------------- 1 | /********************************** (C) COPYRIGHT ******************************* 2 | * File Name : ch32l103_wwdg.h 3 | * Author : WCH 4 | * Version : V1.0.0 5 | * Date : 2023/07/08 6 | * Description : This file contains all the functions prototypes for the WWDG 7 | * firmware library. 8 | ********************************************************************************* 9 | * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. 10 | * Attention: This software (modified or not) and binary are used for 11 | * microcontroller manufactured by Nanjing Qinheng Microelectronics. 12 | *******************************************************************************/ 13 | #ifndef __CH32L103_WWDG_H 14 | #define __CH32L103_WWDG_H 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | #include "ch32l103.h" 21 | 22 | /* WWDG_Prescaler */ 23 | #define WWDG_Prescaler_1 ((uint32_t)0x00000000) 24 | #define WWDG_Prescaler_2 ((uint32_t)0x00000080) 25 | #define WWDG_Prescaler_4 ((uint32_t)0x00000100) 26 | #define WWDG_Prescaler_8 ((uint32_t)0x00000180) 27 | 28 | void WWDG_DeInit(void); 29 | void WWDG_SetPrescaler(uint32_t WWDG_Prescaler); 30 | void WWDG_SetWindowValue(uint8_t WindowValue); 31 | void WWDG_EnableIT(void); 32 | void WWDG_SetCounter(uint8_t Counter); 33 | void WWDG_Enable(uint8_t Counter); 34 | FlagStatus WWDG_GetFlagStatus(void); 35 | void WWDG_ClearFlag(void); 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /system/CH32L10x/USER/ch32l103_conf.h: -------------------------------------------------------------------------------- 1 | /********************************** (C) COPYRIGHT ******************************* 2 | * File Name : ch32l103_conf.h 3 | * Author : WCH 4 | * Version : V1.0.0 5 | * Date : 2023/07/08 6 | * Description : Library configuration file. 7 | ********************************************************************************* 8 | * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. 9 | * Attention: This software (modified or not) and binary are used for 10 | * microcontroller manufactured by Nanjing Qinheng Microelectronics. 11 | *******************************************************************************/ 12 | #ifndef __CH32L103_CONF_H 13 | #define __CH32L103_CONF_H 14 | 15 | #include "ch32l103_adc.h" 16 | #include "ch32l103_bkp.h" 17 | #include "ch32l103_can.h" 18 | #include "ch32l103_crc.h" 19 | #include "ch32l103_dbgmcu.h" 20 | #include "ch32l103_dma.h" 21 | #include "ch32l103_exti.h" 22 | #include "ch32l103_flash.h" 23 | #include "ch32l103_gpio.h" 24 | #include "ch32l103_i2c.h" 25 | #include "ch32l103_iwdg.h" 26 | #include "ch32l103_pwr.h" 27 | #include "ch32l103_rcc.h" 28 | #include "ch32l103_rtc.h" 29 | #include "ch32l103_spi.h" 30 | #include "ch32l103_tim.h" 31 | #include "ch32l103_usart.h" 32 | #include "ch32l103_wwdg.h" 33 | #include "ch32l103_it.h" 34 | #include "ch32l103_misc.h" 35 | #include "ch32l103_lptim.h" 36 | #include "ch32l103_opa.h" 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /system/CH32L10x/USER/ch32l103_it.c: -------------------------------------------------------------------------------- 1 | /********************************** (C) COPYRIGHT ******************************* 2 | * File Name : ch32l103_it.c 3 | * Author : WCH 4 | * Version : V1.0.0 5 | * Date : 2023/07/08 6 | * Description : Main Interrupt Service Routines. 7 | ********************************************************************************* 8 | * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. 9 | * Attention: This software (modified or not) and binary are used for 10 | * microcontroller manufactured by Nanjing Qinheng Microelectronics. 11 | *******************************************************************************/ 12 | #include "ch32l103_it.h" 13 | 14 | void NMI_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast"))); 15 | void HardFault_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast"))); 16 | 17 | /********************************************************************* 18 | * @fn NMI_Handler 19 | * 20 | * @brief This function handles NMI exception. 21 | * 22 | * @return none 23 | */ 24 | void NMI_Handler(void) 25 | { 26 | while (1) 27 | { 28 | } 29 | } 30 | 31 | 32 | /********************************************************************* 33 | * @fn HardFault_Handler 34 | * 35 | * @brief This function handles Hard Fault exception. 36 | * 37 | * @return none 38 | */ 39 | void HardFault_Handler(void) 40 | { 41 | while (1) 42 | { 43 | } 44 | } 45 | 46 | 47 | -------------------------------------------------------------------------------- /system/CH32L10x/USER/ch32l103_it.h: -------------------------------------------------------------------------------- 1 | /********************************** (C) COPYRIGHT ******************************* 2 | * File Name : ch32l103_it.h 3 | * Author : WCH 4 | * Version : V1.0.0 5 | * Date : 2023/07/08 6 | * Description : This file contains the headers of the interrupt handlers. 7 | ********************************************************************************* 8 | * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. 9 | * Attention: This software (modified or not) and binary are used for 10 | * microcontroller manufactured by Nanjing Qinheng Microelectronics. 11 | *******************************************************************************/ 12 | #ifndef __CH32L103_IT_H 13 | #define __CH32L103_IT_H 14 | 15 | #include "debug.h" 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /system/CH32L10x/USER/system_ch32l103.h: -------------------------------------------------------------------------------- 1 | /********************************** (C) COPYRIGHT ******************************* 2 | * File Name : system_ch32l103.h 3 | * Author : WCH 4 | * Version : V1.0.0 5 | * Date : 2023/07/08 6 | * Description : CH32L103 Device Peripheral Access Layer System Header File. 7 | ********************************************************************************* 8 | * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. 9 | * Attention: This software (modified or not) and binary are used for 10 | * microcontroller manufactured by Nanjing Qinheng Microelectronics. 11 | *******************************************************************************/ 12 | #ifndef __SYSTEM_ch32l103_H 13 | #define __SYSTEM_ch32l103_H 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | extern uint32_t SystemCoreClock; /* System Clock Frequency (Core Clock) */ 20 | 21 | /* System_Exported_Functions */ 22 | extern void SystemInit(void); 23 | extern void SystemCoreClockUpdate(void); 24 | 25 | #ifdef __cplusplus 26 | } 27 | #endif 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /system/CH32V00x/SRC/Debug/debug.h: -------------------------------------------------------------------------------- 1 | /********************************** (C) COPYRIGHT ******************************* 2 | * File Name : debug.h 3 | * Author : WCH 4 | * Version : V1.0.0 5 | * Date : 2022/08/08 6 | * Description : This file contains all the functions prototypes for UART 7 | * Printf , Delay functions. 8 | ********************************************************************************* 9 | * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. 10 | * Attention: This software (modified or not) and binary are used for 11 | * microcontroller manufactured by Nanjing Qinheng Microelectronics. 12 | *******************************************************************************/ 13 | #ifndef __DEBUG_H 14 | #define __DEBUG_H 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | #include 21 | #include 22 | 23 | /* UART Printf Definition */ 24 | #define DEBUG_UART1 1 25 | 26 | /* DEBUG UATR Definition */ 27 | #ifndef DEBUG 28 | #define DEBUG DEBUG_UART1 29 | #endif 30 | 31 | void Delay_Init(void); 32 | void Delay_Us(uint32_t n); 33 | void Delay_Ms(uint32_t n); 34 | void USART_Printf_Init(uint32_t baudrate); 35 | 36 | #ifdef __cplusplus 37 | } 38 | #endif 39 | 40 | #endif /* __DEBUG_H */ 41 | -------------------------------------------------------------------------------- /system/CH32V00x/SRC/Peripheral/inc/ch32v00x_dbgmcu.h: -------------------------------------------------------------------------------- 1 | /********************************** (C) COPYRIGHT ******************************* 2 | * File Name : ch32v00x_dbgmcu.h 3 | * Author : WCH 4 | * Version : V1.0.0 5 | * Date : 2022/08/08 6 | * Description : This file contains all the functions prototypes for the 7 | * DBGMCU firmware library. 8 | ********************************************************************************* 9 | * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. 10 | * Attention: This software (modified or not) and binary are used for 11 | * microcontroller manufactured by Nanjing Qinheng Microelectronics. 12 | *******************************************************************************/ 13 | #ifndef __CH32V00x_DBGMCU_H 14 | #define __CH32V00x_DBGMCU_H 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | #include 21 | 22 | /* CFGR0 Register */ 23 | #define DBGMCU_IWDG_STOP ((uint32_t)0x00000001) 24 | #define DBGMCU_WWDG_STOP ((uint32_t)0x00000002) 25 | #define DBGMCU_TIM1_STOP ((uint32_t)0x00000010) 26 | #define DBGMCU_TIM2_STOP ((uint32_t)0x00000020) 27 | 28 | uint32_t DBGMCU_GetREVID(void); 29 | uint32_t DBGMCU_GetDEVID(void); 30 | uint32_t __get_DEBUG_CR(void); 31 | void __set_DEBUG_CR(uint32_t value); 32 | void DBGMCU_Config(uint32_t DBGMCU_Periph, FunctionalState NewState); 33 | 34 | #ifdef __cplusplus 35 | } 36 | #endif 37 | 38 | #endif /* __CH32V00x_DBGMCU_H */ 39 | -------------------------------------------------------------------------------- /system/CH32V00x/SRC/Peripheral/inc/ch32v00x_misc.h: -------------------------------------------------------------------------------- 1 | /********************************** (C) COPYRIGHT ******************************* 2 | * File Name : ch32v00x_misc.h 3 | * Author : WCH 4 | * Version : V1.0.0 5 | * Date : 2022/08/08 6 | * Description : This file contains all the functions prototypes for the 7 | * miscellaneous firmware library functions. 8 | ********************************************************************************* 9 | * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. 10 | * Attention: This software (modified or not) and binary are used for 11 | * microcontroller manufactured by Nanjing Qinheng Microelectronics. 12 | *******************************************************************************/ 13 | #ifndef __CH32V00X_MISC_H 14 | #define __CH32V00X_MISC_H 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | #include 21 | 22 | /* NVIC Init Structure definition */ 23 | typedef struct 24 | { 25 | uint8_t NVIC_IRQChannel; 26 | uint8_t NVIC_IRQChannelPreemptionPriority; 27 | uint8_t NVIC_IRQChannelSubPriority; 28 | FunctionalState NVIC_IRQChannelCmd; 29 | } NVIC_InitTypeDef; 30 | 31 | 32 | /* Preemption_Priority_Group */ 33 | #define NVIC_PriorityGroup_0 ((uint32_t)0x00) 34 | #define NVIC_PriorityGroup_1 ((uint32_t)0x01) 35 | #define NVIC_PriorityGroup_2 ((uint32_t)0x02) 36 | #define NVIC_PriorityGroup_3 ((uint32_t)0x03) 37 | #define NVIC_PriorityGroup_4 ((uint32_t)0x04) 38 | 39 | 40 | void NVIC_PriorityGroupConfig(uint32_t NVIC_PriorityGroup); 41 | void NVIC_Init(NVIC_InitTypeDef* NVIC_InitStruct); 42 | 43 | #ifdef __cplusplus 44 | } 45 | #endif 46 | 47 | #endif /* __CH32V00x_MISC_H */ 48 | 49 | -------------------------------------------------------------------------------- /system/CH32V00x/SRC/Peripheral/inc/ch32v00x_opa.h: -------------------------------------------------------------------------------- 1 | /********************************** (C) COPYRIGHT ******************************* 2 | * File Name : ch32v00x_opa.h 3 | * Author : WCH 4 | * Version : V1.0.0 5 | * Date : 2022/08/08 6 | * Description : This file contains all the functions prototypes for the 7 | * OPA firmware library. 8 | ********************************************************************************* 9 | * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. 10 | * Attention: This software (modified or not) and binary are used for 11 | * microcontroller manufactured by Nanjing Qinheng Microelectronics. 12 | *******************************************************************************/ 13 | #ifndef __CH32V00x_OPA_H 14 | #define __CH32V00x_OPA_H 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | #include "ch32v00x.h" 21 | 22 | /* OPA PSEL enumeration */ 23 | typedef enum 24 | { 25 | CHP0 = 0, 26 | CHP1 27 | } OPA_PSEL_TypeDef; 28 | 29 | /* OPA NSEL enumeration */ 30 | typedef enum 31 | { 32 | CHN0 = 0, 33 | CHN1 34 | } OPA_NSEL_TypeDef; 35 | 36 | 37 | /* OPA Init Structure definition */ 38 | typedef struct 39 | { 40 | OPA_PSEL_TypeDef PSEL; /* Specifies the positive channel of OPA */ 41 | OPA_NSEL_TypeDef NSEL; /* Specifies the negative channel of OPA */ 42 | } OPA_InitTypeDef; 43 | 44 | void OPA_DeInit(void); 45 | void OPA_Init(OPA_InitTypeDef *OPA_InitStruct); 46 | void OPA_StructInit(OPA_InitTypeDef *OPA_InitStruct); 47 | void OPA_Cmd(FunctionalState NewState); 48 | 49 | #ifdef __cplusplus 50 | } 51 | #endif 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /system/CH32V00x/SRC/Peripheral/inc/ch32v00x_wwdg.h: -------------------------------------------------------------------------------- 1 | /********************************** (C) COPYRIGHT ******************************* 2 | * File Name : ch32v00x_wwdg.h 3 | * Author : WCH 4 | * Version : V1.0.0 5 | * Date : 2022/08/08 6 | * Description : This file contains all the functions prototypes for the WWDG 7 | * firmware library. 8 | ********************************************************************************* 9 | * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. 10 | * Attention: This software (modified or not) and binary are used for 11 | * microcontroller manufactured by Nanjing Qinheng Microelectronics. 12 | *******************************************************************************/ 13 | #ifndef __CH32V00x_WWDG_H 14 | #define __CH32V00x_WWDG_H 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | #include 21 | 22 | /* WWDG_Prescaler */ 23 | #define WWDG_Prescaler_1 ((uint32_t)0x00000000) 24 | #define WWDG_Prescaler_2 ((uint32_t)0x00000080) 25 | #define WWDG_Prescaler_4 ((uint32_t)0x00000100) 26 | #define WWDG_Prescaler_8 ((uint32_t)0x00000180) 27 | 28 | void WWDG_DeInit(void); 29 | void WWDG_SetPrescaler(uint32_t WWDG_Prescaler); 30 | void WWDG_SetWindowValue(uint8_t WindowValue); 31 | void WWDG_EnableIT(void); 32 | void WWDG_SetCounter(uint8_t Counter); 33 | void WWDG_Enable(uint8_t Counter); 34 | FlagStatus WWDG_GetFlagStatus(void); 35 | void WWDG_ClearFlag(void); 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | 41 | #endif /* __CH32V00x_WWDG_H */ 42 | -------------------------------------------------------------------------------- /system/CH32V00x/USER/ch32v00x_conf.h: -------------------------------------------------------------------------------- 1 | /********************************** (C) COPYRIGHT ******************************* 2 | * File Name : ch32v00x_conf.h 3 | * Author : WCH 4 | * Version : V1.0.0 5 | * Date : 2020/08/08 6 | * Description : Library configuration file. 7 | ********************************************************************************* 8 | * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. 9 | * Attention: This software (modified or not) and binary are used for 10 | * microcontroller manufactured by Nanjing Qinheng Microelectronics. 11 | *******************************************************************************/ 12 | #ifndef __CH32V00x_CONF_H 13 | #define __CH32V00x_CONF_H 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | 34 | 35 | #endif /* __CH32V00x_CONF_H */ 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /system/CH32V00x/USER/ch32v00x_it.c: -------------------------------------------------------------------------------- 1 | /********************************** (C) COPYRIGHT ******************************* 2 | * File Name : ch32v00x_it.c 3 | * Author : WCH 4 | * Version : V1.0.0 5 | * Date : 2022/08/08 6 | * Description : Main Interrupt Service Routines. 7 | ********************************************************************************* 8 | * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. 9 | * Attention: This software (modified or not) and binary are used for 10 | * microcontroller manufactured by Nanjing Qinheng Microelectronics. 11 | *******************************************************************************/ 12 | #include 13 | 14 | void NMI_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast"))); 15 | void HardFault_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast"))); 16 | 17 | /********************************************************************* 18 | * @fn NMI_Handler 19 | * 20 | * @brief This function handles NMI exception. 21 | * 22 | * @return none 23 | */ 24 | void NMI_Handler(void) 25 | { 26 | } 27 | 28 | /********************************************************************* 29 | * @fn HardFault_Handler 30 | * 31 | * @brief This function handles Hard Fault exception. 32 | * 33 | * @return none 34 | */ 35 | void HardFault_Handler(void) 36 | { 37 | while (1) 38 | { 39 | } 40 | } 41 | 42 | 43 | -------------------------------------------------------------------------------- /system/CH32V00x/USER/ch32v00x_it.h: -------------------------------------------------------------------------------- 1 | /********************************** (C) COPYRIGHT ******************************* 2 | * File Name : ch32v00x_it.h 3 | * Author : WCH 4 | * Version : V1.0.0 5 | * Date : 2022/08/08 6 | * Description : This file contains the headers of the interrupt handlers. 7 | ********************************************************************************* 8 | * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. 9 | * Attention: This software (modified or not) and binary are used for 10 | * microcontroller manufactured by Nanjing Qinheng Microelectronics. 11 | *******************************************************************************/ 12 | #ifndef __CH32V00x_IT_H 13 | #define __CH32V00x_IT_H 14 | 15 | #include "debug.h" 16 | 17 | 18 | #endif /* __CH32V00x_IT_H */ 19 | 20 | 21 | -------------------------------------------------------------------------------- /system/CH32V00x/USER/system_ch32v00x.h: -------------------------------------------------------------------------------- 1 | /********************************** (C) COPYRIGHT ******************************* 2 | * File Name : system_ch32v00x.h 3 | * Author : WCH 4 | * Version : V1.0.0 5 | * Date : 2022/08/08 6 | * Description : CH32V00x Device Peripheral Access Layer System Header File. 7 | ********************************************************************************* 8 | * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. 9 | * Attention: This software (modified or not) and binary are used for 10 | * microcontroller manufactured by Nanjing Qinheng Microelectronics. 11 | *******************************************************************************/ 12 | #ifndef __SYSTEM_CH32V00x_H 13 | #define __SYSTEM_CH32V00x_H 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | extern uint32_t SystemCoreClock; /* System Clock Frequency (Core Clock) */ 20 | 21 | /* System_Exported_Functions */ 22 | extern void SystemInit(void); 23 | extern void SystemCoreClockUpdate(void); 24 | 25 | #ifdef __cplusplus 26 | } 27 | #endif 28 | 29 | #endif /*__CH32V00x_SYSTEM_H */ 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /system/CH32V10x/SRC/Debug/debug.h: -------------------------------------------------------------------------------- 1 | /********************************** (C) COPYRIGHT ******************************* 2 | * File Name : debug.h 3 | * Author : WCH 4 | * Version : V1.0.0 5 | * Date : 2020/04/30 6 | * Description : This file contains all the functions prototypes for UART 7 | * Printf , Delay functions. 8 | ********************************************************************************* 9 | * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. 10 | * Attention: This software (modified or not) and binary are used for 11 | * microcontroller manufactured by Nanjing Qinheng Microelectronics. 12 | *******************************************************************************/ 13 | #ifndef __DEBUG_H 14 | #define __DEBUG_H 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | #include "stdio.h" 21 | #include "ch32v10x.h" 22 | 23 | /* HID function switch, 1 is to turn off HID function, 0 is to turn on HID function */ 24 | #define ch32v10x_usb_hid 0 25 | 26 | /* UART Printf Definition */ 27 | #define DEBUG_UART1 1 28 | #define DEBUG_UART2 2 29 | #define DEBUG_UART3 3 30 | 31 | /* DEBUG UATR Definition */ 32 | #ifndef DEBUG 33 | #define DEBUG DEBUG_UART1 34 | #endif 35 | 36 | void Delay_Init(void); 37 | void Delay_Us(uint32_t n); 38 | void Delay_Ms(uint32_t n); 39 | void USART_Printf_Init(uint32_t baudrate); 40 | 41 | #ifdef __cplusplus 42 | } 43 | #endif 44 | 45 | #endif /* __DEBUG_H */ 46 | -------------------------------------------------------------------------------- /system/CH32V10x/SRC/Peripheral/inc/ch32v10x_crc.h: -------------------------------------------------------------------------------- 1 | /********************************** (C) COPYRIGHT ******************************* 2 | * File Name : ch32v10x_crc.h 3 | * Author : WCH 4 | * Version : V1.0.0 5 | * Date : 2020/04/30 6 | * Description : This file contains all the functions prototypes for the 7 | * CRC firmware library. 8 | ********************************************************************************* 9 | * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. 10 | * Attention: This software (modified or not) and binary are used for 11 | * microcontroller manufactured by Nanjing Qinheng Microelectronics. 12 | *******************************************************************************/ 13 | #ifndef __CH32V10x_CRC_H 14 | #define __CH32V10x_CRC_H 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | #include "ch32v10x.h" 21 | 22 | void CRC_ResetDR(void); 23 | uint32_t CRC_CalcCRC(uint32_t Data); 24 | uint32_t CRC_CalcBlockCRC(uint32_t pBuffer[], uint32_t BufferLength); 25 | uint32_t CRC_GetCRC(void); 26 | void CRC_SetIDRegister(uint8_t IDValue); 27 | uint8_t CRC_GetIDRegister(void); 28 | 29 | #ifdef __cplusplus 30 | } 31 | #endif 32 | 33 | #endif /* __CH32V10x_CRC_H */ 34 | -------------------------------------------------------------------------------- /system/CH32V10x/SRC/Peripheral/inc/ch32v10x_misc.h: -------------------------------------------------------------------------------- 1 | /********************************** (C) COPYRIGHT ******************************* 2 | * File Name : ch32v10x_misc.h 3 | * Author : WCH 4 | * Version : V1.0.0 5 | * Date : 2020/04/30 6 | * Description : This file contains all the functions prototypes for the 7 | * miscellaneous firmware library functions. 8 | ********************************************************************************* 9 | * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. 10 | * Attention: This software (modified or not) and binary are used for 11 | * microcontroller manufactured by Nanjing Qinheng Microelectronics. 12 | *******************************************************************************/ 13 | #ifndef __CH32V10X_MISC_H 14 | #define __CH32V10X_MISC_H 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | #include "ch32v10x.h" 21 | 22 | /* NVIC Init Structure definition */ 23 | typedef struct 24 | { 25 | uint8_t NVIC_IRQChannel; 26 | uint8_t NVIC_IRQChannelPreemptionPriority; 27 | uint8_t NVIC_IRQChannelSubPriority; 28 | FunctionalState NVIC_IRQChannelCmd; 29 | } NVIC_InitTypeDef; 30 | 31 | 32 | /* Preemption_Priority_Group */ 33 | #define NVIC_PriorityGroup_0 ((uint32_t)0x00) 34 | #define NVIC_PriorityGroup_1 ((uint32_t)0x01) 35 | #define NVIC_PriorityGroup_2 ((uint32_t)0x02) 36 | #define NVIC_PriorityGroup_3 ((uint32_t)0x03) 37 | #define NVIC_PriorityGroup_4 ((uint32_t)0x04) 38 | 39 | 40 | void NVIC_PriorityGroupConfig(uint32_t NVIC_PriorityGroup); 41 | void NVIC_Init(NVIC_InitTypeDef* NVIC_InitStruct); 42 | 43 | #ifdef __cplusplus 44 | } 45 | #endif 46 | 47 | #endif /* __CH32V10x_MISC_H */ 48 | 49 | -------------------------------------------------------------------------------- /system/CH32V10x/SRC/Peripheral/inc/ch32v10x_wwdg.h: -------------------------------------------------------------------------------- 1 | /********************************** (C) COPYRIGHT ******************************* 2 | * File Name : ch32v10x_wwdg.h 3 | * Author : WCH 4 | * Version : V1.0.0 5 | * Date : 2020/04/30 6 | * Description : This file contains all the functions prototypes for the WWDG 7 | * firmware library. 8 | ********************************************************************************* 9 | * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. 10 | * Attention: This software (modified or not) and binary are used for 11 | * microcontroller manufactured by Nanjing Qinheng Microelectronics. 12 | *******************************************************************************/ 13 | #ifndef __CH32V10x_WWDG_H 14 | #define __CH32V10x_WWDG_H 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | #include "ch32v10x.h" 21 | 22 | /* WWDG_Prescaler */ 23 | #define WWDG_Prescaler_1 ((uint32_t)0x00000000) 24 | #define WWDG_Prescaler_2 ((uint32_t)0x00000080) 25 | #define WWDG_Prescaler_4 ((uint32_t)0x00000100) 26 | #define WWDG_Prescaler_8 ((uint32_t)0x00000180) 27 | 28 | void WWDG_DeInit(void); 29 | void WWDG_SetPrescaler(uint32_t WWDG_Prescaler); 30 | void WWDG_SetWindowValue(uint8_t WindowValue); 31 | void WWDG_EnableIT(void); 32 | void WWDG_SetCounter(uint8_t Counter); 33 | void WWDG_Enable(uint8_t Counter); 34 | FlagStatus WWDG_GetFlagStatus(void); 35 | void WWDG_ClearFlag(void); 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | 41 | #endif /* __CH32V10x_WWDG_H */ 42 | -------------------------------------------------------------------------------- /system/CH32V10x/USER/ch32v10x_conf.h: -------------------------------------------------------------------------------- 1 | /********************************** (C) COPYRIGHT ******************************* 2 | * File Name : ch32v10x_conf.h 3 | * Author : WCH 4 | * Version : V1.0.0 5 | * Date : 2020/04/30 6 | * Description : Library configuration file. 7 | ********************************************************************************* 8 | * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. 9 | * Attention: This software (modified or not) and binary are used for 10 | * microcontroller manufactured by Nanjing Qinheng Microelectronics. 11 | *******************************************************************************/ 12 | #ifndef __CH32V10x_CONF_H 13 | #define __CH32V10x_CONF_H 14 | 15 | #include "ch32v10x_it.h" 16 | #include "ch32v10x_adc.h" 17 | #include "ch32v10x_bkp.h" 18 | #include "ch32v10x_crc.h" 19 | #include "ch32v10x_dbgmcu.h" 20 | #include "ch32v10x_dma.h" 21 | #include "ch32v10x_exti.h" 22 | #include "ch32v10x_flash.h" 23 | #include "ch32v10x_gpio.h" 24 | #include "ch32v10x_i2c.h" 25 | #include "ch32v10x_iwdg.h" 26 | #include "ch32v10x_pwr.h" 27 | #include "ch32v10x_rcc.h" 28 | #include "ch32v10x_rtc.h" 29 | #include "ch32v10x_spi.h" 30 | #include "ch32v10x_tim.h" 31 | #include "ch32v10x_usart.h" 32 | #include "ch32v10x_wwdg.h" 33 | #include "ch32v10x_usb.h" 34 | #include "ch32v10x_usb_host.h" 35 | #include "ch32v10x_misc.h" 36 | 37 | 38 | #endif /* __CH32V10x_CONF_H */ 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /system/CH32V10x/USER/ch32v10x_it.c: -------------------------------------------------------------------------------- 1 | /********************************** (C) COPYRIGHT ******************************* 2 | * File Name : ch32v10x_it.c 3 | * Author : WCH 4 | * Version : V1.0.0 5 | * Date : 2020/04/30 6 | * Description : Main Interrupt Service Routines. 7 | ********************************************************************************* 8 | * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. 9 | * Attention: This software (modified or not) and binary are used for 10 | * microcontroller manufactured by Nanjing Qinheng Microelectronics. 11 | *******************************************************************************/ 12 | #include "ch32v10x_it.h" 13 | 14 | void NMI_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast"))); 15 | void HardFault_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast"))); 16 | 17 | /********************************************************************* 18 | * @fn NMI_Handler 19 | * 20 | * @brief This function handles NMI exception. 21 | * 22 | * @return none 23 | */ 24 | void NMI_Handler(void) 25 | { 26 | } 27 | 28 | /********************************************************************* 29 | * @fn HardFault_Handler 30 | * 31 | * @brief This function handles Hard Fault exception. 32 | * 33 | * @return none 34 | */ 35 | void HardFault_Handler(void) 36 | { 37 | while (1) 38 | { 39 | } 40 | } 41 | 42 | 43 | -------------------------------------------------------------------------------- /system/CH32V10x/USER/ch32v10x_it.h: -------------------------------------------------------------------------------- 1 | /********************************** (C) COPYRIGHT ******************************* 2 | * File Name : ch32v10x_it.h 3 | * Author : WCH 4 | * Version : V1.0.0 5 | * Date : 2020/04/30 6 | * Description : This file contains the headers of the interrupt handlers. 7 | ********************************************************************************* 8 | * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. 9 | * Attention: This software (modified or not) and binary are used for 10 | * microcontroller manufactured by Nanjing Qinheng Microelectronics. 11 | *******************************************************************************/ 12 | #ifndef __CH32V10x_IT_H 13 | #define __CH32V10x_IT_H 14 | 15 | #include "debug.h" 16 | 17 | 18 | #endif /* __CH32V10x_IT_H */ 19 | 20 | 21 | -------------------------------------------------------------------------------- /system/CH32V10x/USER/system_ch32v10x.h: -------------------------------------------------------------------------------- 1 | /********************************** (C) COPYRIGHT ******************************* 2 | * File Name : system_ch32v10x.h 3 | * Author : WCH 4 | * Version : V1.0.0 5 | * Date : 2020/04/30 6 | * Description : CH32V10x Device Peripheral Access Layer System Header File. 7 | ********************************************************************************* 8 | * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. 9 | * Attention: This software (modified or not) and binary are used for 10 | * microcontroller manufactured by Nanjing Qinheng Microelectronics. 11 | *******************************************************************************/ 12 | #ifndef __SYSTEM_CH32V10x_H 13 | #define __SYSTEM_CH32V10x_H 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | extern uint32_t SystemCoreClock; /* System Clock Frequency (Core Clock) */ 20 | 21 | /* System_Exported_Functions */ 22 | extern void SystemInit(void); 23 | extern void SystemCoreClockUpdate(void); 24 | 25 | #ifdef __cplusplus 26 | } 27 | #endif 28 | 29 | #endif /*__CH32V10x_SYSTEM_H */ 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /system/CH32V20x/SRC/Debug/debug.h: -------------------------------------------------------------------------------- 1 | /********************************** (C) COPYRIGHT ******************************* 2 | * File Name : debug.h 3 | * Author : WCH 4 | * Version : V1.0.0 5 | * Date : 2021/06/06 6 | * Description : This file contains all the functions prototypes for UART 7 | * Printf , Delay functions. 8 | * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. 9 | * SPDX-License-Identifier: Apache-2.0 10 | *******************************************************************************/ 11 | #ifndef __DEBUG_H 12 | #define __DEBUG_H 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | #include "ch32v20x.h" 19 | #include "stdio.h" 20 | 21 | 22 | 23 | /* UART Printf Definition */ 24 | #define DEBUG_UART1 1 25 | #define DEBUG_UART2 2 26 | #define DEBUG_UART3 3 27 | 28 | /* DEBUG UATR Definition */ 29 | #define DEBUG DEBUG_UART1 30 | // #define DEBUG DEBUG_UART2 31 | //#define DEBUG DEBUG_UART3 32 | 33 | void Delay_Init(void); 34 | void Delay_Us(uint32_t n); 35 | void Delay_Ms(uint32_t n); 36 | void USART_Printf_Init(uint32_t baudrate); 37 | 38 | #if(DEBUG) 39 | #define PRINT(format, ...) printf(format, ##__VA_ARGS__) 40 | #else 41 | #define PRINT(X...) 42 | #endif 43 | 44 | #ifdef __cplusplus 45 | } 46 | #endif 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /system/CH32V20x/SRC/Peripheral/inc/ch32v20x_crc.h: -------------------------------------------------------------------------------- 1 | /********************************** (C) COPYRIGHT ******************************* 2 | * File Name : ch32v20x_crc.h 3 | * Author : WCH 4 | * Version : V1.0.0 5 | * Date : 2021/06/06 6 | * Description : This file contains all the functions prototypes for the 7 | * CRC firmware library. 8 | * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. 9 | * SPDX-License-Identifier: Apache-2.0 10 | *******************************************************************************/ 11 | #ifndef __CH32V20x_CRC_H 12 | #define __CH32V20x_CRC_H 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | #include "ch32v20x.h" 19 | 20 | void CRC_ResetDR(void); 21 | uint32_t CRC_CalcCRC(uint32_t Data); 22 | uint32_t CRC_CalcBlockCRC(uint32_t pBuffer[], uint32_t BufferLength); 23 | uint32_t CRC_GetCRC(void); 24 | void CRC_SetIDRegister(uint8_t IDValue); 25 | uint8_t CRC_GetIDRegister(void); 26 | 27 | #ifdef __cplusplus 28 | } 29 | #endif 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /system/CH32V20x/SRC/Peripheral/inc/ch32v20x_iwdg.h: -------------------------------------------------------------------------------- 1 | /********************************** (C) COPYRIGHT ******************************* 2 | * File Name : ch32v20x_iwdg.h 3 | * Author : WCH 4 | * Version : V1.0.0 5 | * Date : 2021/06/06 6 | * Description : This file contains all the functions prototypes for the 7 | * IWDG firmware library. 8 | * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. 9 | * SPDX-License-Identifier: Apache-2.0 10 | *******************************************************************************/ 11 | #ifndef __CH32V20x_IWDG_H 12 | #define __CH32V20x_IWDG_H 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | #include "ch32v20x.h" 19 | 20 | /* IWDG_WriteAccess */ 21 | #define IWDG_WriteAccess_Enable ((uint16_t)0x5555) 22 | #define IWDG_WriteAccess_Disable ((uint16_t)0x0000) 23 | 24 | /* IWDG_prescaler */ 25 | #define IWDG_Prescaler_4 ((uint8_t)0x00) 26 | #define IWDG_Prescaler_8 ((uint8_t)0x01) 27 | #define IWDG_Prescaler_16 ((uint8_t)0x02) 28 | #define IWDG_Prescaler_32 ((uint8_t)0x03) 29 | #define IWDG_Prescaler_64 ((uint8_t)0x04) 30 | #define IWDG_Prescaler_128 ((uint8_t)0x05) 31 | #define IWDG_Prescaler_256 ((uint8_t)0x06) 32 | 33 | /* IWDG_Flag */ 34 | #define IWDG_FLAG_PVU ((uint16_t)0x0001) 35 | #define IWDG_FLAG_RVU ((uint16_t)0x0002) 36 | 37 | void IWDG_WriteAccessCmd(uint16_t IWDG_WriteAccess); 38 | void IWDG_SetPrescaler(uint8_t IWDG_Prescaler); 39 | void IWDG_SetReload(uint16_t Reload); 40 | void IWDG_ReloadCounter(void); 41 | void IWDG_Enable(void); 42 | FlagStatus IWDG_GetFlagStatus(uint16_t IWDG_FLAG); 43 | 44 | #ifdef __cplusplus 45 | } 46 | #endif 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /system/CH32V20x/SRC/Peripheral/inc/ch32v20x_misc.h: -------------------------------------------------------------------------------- 1 | /********************************** (C) COPYRIGHT ******************************* 2 | * File Name : ch32v20x_misc.h 3 | * Author : WCH 4 | * Version : V1.0.0 5 | * Date : 2021/06/06 6 | * Description : This file contains all the functions prototypes for the 7 | * miscellaneous firmware library functions. 8 | * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. 9 | * SPDX-License-Identifier: Apache-2.0 10 | *******************************************************************************/ 11 | #ifndef __CH32V20x_MISC_H 12 | #define __CH32V20x_MISC_H 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | #include "ch32v20x.h" 19 | 20 | /* NVIC Init Structure definition */ 21 | typedef struct 22 | { 23 | uint8_t NVIC_IRQChannel; 24 | uint8_t NVIC_IRQChannelPreemptionPriority; 25 | uint8_t NVIC_IRQChannelSubPriority; 26 | FunctionalState NVIC_IRQChannelCmd; 27 | } NVIC_InitTypeDef; 28 | 29 | /* Preemption_Priority_Group */ 30 | #define NVIC_PriorityGroup_0 ((uint32_t)0x00) 31 | #define NVIC_PriorityGroup_1 ((uint32_t)0x01) 32 | #define NVIC_PriorityGroup_2 ((uint32_t)0x02) 33 | #define NVIC_PriorityGroup_3 ((uint32_t)0x03) 34 | #define NVIC_PriorityGroup_4 ((uint32_t)0x04) 35 | 36 | void NVIC_PriorityGroupConfig(uint32_t NVIC_PriorityGroup); 37 | void NVIC_Init(NVIC_InitTypeDef *NVIC_InitStruct); 38 | 39 | #ifdef __cplusplus 40 | } 41 | #endif 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /system/CH32V20x/SRC/Peripheral/inc/ch32v20x_wwdg.h: -------------------------------------------------------------------------------- 1 | /********************************** (C) COPYRIGHT ******************************* 2 | * File Name : ch32v20x_wwdg.h 3 | * Author : WCH 4 | * Version : V1.0.0 5 | * Date : 2021/06/06 6 | * Description : This file contains all the functions prototypes for the WWDG 7 | * firmware library. 8 | * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. 9 | * SPDX-License-Identifier: Apache-2.0 10 | *******************************************************************************/ 11 | #ifndef __CH32V20x_WWDG_H 12 | #define __CH32V20x_WWDG_H 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | #include "ch32v20x.h" 19 | 20 | /* WWDG_Prescaler */ 21 | #define WWDG_Prescaler_1 ((uint32_t)0x00000000) 22 | #define WWDG_Prescaler_2 ((uint32_t)0x00000080) 23 | #define WWDG_Prescaler_4 ((uint32_t)0x00000100) 24 | #define WWDG_Prescaler_8 ((uint32_t)0x00000180) 25 | 26 | void WWDG_DeInit(void); 27 | void WWDG_SetPrescaler(uint32_t WWDG_Prescaler); 28 | void WWDG_SetWindowValue(uint8_t WindowValue); 29 | void WWDG_EnableIT(void); 30 | void WWDG_SetCounter(uint8_t Counter); 31 | void WWDG_Enable(uint8_t Counter); 32 | FlagStatus WWDG_GetFlagStatus(void); 33 | void WWDG_ClearFlag(void); 34 | 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /system/CH32V20x/USER/ch32v20x_conf.h: -------------------------------------------------------------------------------- 1 | /********************************** (C) COPYRIGHT ******************************* 2 | * File Name : ch32v20x_conf.h 3 | * Author : WCH 4 | * Version : V1.0.0 5 | * Date : 2021/06/06 6 | * Description : Library configuration file. 7 | * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. 8 | * SPDX-License-Identifier: Apache-2.0 9 | *******************************************************************************/ 10 | #ifndef __CH32V20x_CONF_H 11 | #define __CH32V20x_CONF_H 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | #include "ch32v20x_adc.h" 18 | #include "ch32v20x_bkp.h" 19 | #include "ch32v20x_can.h" 20 | #include "ch32v20x_crc.h" 21 | #include "ch32v20x_dbgmcu.h" 22 | #include "ch32v20x_dma.h" 23 | #include "ch32v20x_exti.h" 24 | #include "ch32v20x_flash.h" 25 | #include "ch32v20x_gpio.h" 26 | #include "ch32v20x_i2c.h" 27 | #include "ch32v20x_iwdg.h" 28 | #include "ch32v20x_pwr.h" 29 | #include "ch32v20x_rcc.h" 30 | #include "ch32v20x_rtc.h" 31 | #include "ch32v20x_spi.h" 32 | #include "ch32v20x_tim.h" 33 | #include "ch32v20x_usart.h" 34 | #include "ch32v20x_wwdg.h" 35 | #include "ch32v20x_it.h" 36 | #include "ch32v20x_misc.h" 37 | 38 | #ifdef __cplusplus 39 | } 40 | #endif 41 | 42 | #endif /* __CH32V20x_CONF_H */ 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /system/CH32V20x/USER/ch32v20x_it.h: -------------------------------------------------------------------------------- 1 | /********************************** (C) COPYRIGHT ******************************* 2 | * File Name : ch32v20x_it.h 3 | * Author : WCH 4 | * Version : V1.0.0 5 | * Date : 2021/06/06 6 | * Description : This file contains the headers of the interrupt handlers. 7 | * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. 8 | * SPDX-License-Identifier: Apache-2.0 9 | *******************************************************************************/ 10 | #ifndef __CH32V20x_IT_H 11 | #define __CH32V20x_IT_H 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | #include "debug.h" 18 | 19 | 20 | 21 | #ifdef __cplusplus 22 | } 23 | #endif 24 | 25 | 26 | #endif /* __CH32V20x_IT_H */ 27 | 28 | 29 | -------------------------------------------------------------------------------- /system/CH32V20x/USER/system_ch32v20x.h: -------------------------------------------------------------------------------- 1 | /********************************** (C) COPYRIGHT ******************************* 2 | * File Name : system_ch32v20x.h 3 | * Author : WCH 4 | * Version : V1.0.0 5 | * Date : 2021/06/06 6 | * Description : CH32V20x Device Peripheral Access Layer System Header File. 7 | * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. 8 | * SPDX-License-Identifier: Apache-2.0 9 | *******************************************************************************/ 10 | #ifndef __SYSTEM_ch32v20x_H 11 | #define __SYSTEM_ch32v20x_H 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | extern uint32_t SystemCoreClock; /* System Clock Frequency (Core Clock) */ 18 | 19 | /* System_Exported_Functions */ 20 | extern void SystemInit(void); 21 | extern void SystemCoreClockUpdate(void); 22 | 23 | #ifdef __cplusplus 24 | } 25 | #endif 26 | 27 | #endif /*__CH32V20x_SYSTEM_H */ 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /system/CH32V30x/SRC/Debug/debug.h: -------------------------------------------------------------------------------- 1 | /********************************** (C) COPYRIGHT ******************************* 2 | * File Name : debug.h 3 | * Author : WCH 4 | * Version : V1.0.0 5 | * Date : 2021/06/06 6 | * Description : This file contains all the functions prototypes for UART 7 | * Printf , Delay functions. 8 | ********************************************************************************* 9 | * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. 10 | * Attention: This software (modified or not) and binary are used for 11 | * microcontroller manufactured by Nanjing Qinheng Microelectronics. 12 | *******************************************************************************/ 13 | #ifndef __DEBUG_H 14 | #define __DEBUG_H 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | #include "stdio.h" 21 | #include "ch32v30x.h" 22 | 23 | /* UART Printf Definition */ 24 | #define DEBUG_UART1 1 25 | #define DEBUG_UART2 2 26 | #define DEBUG_UART3 3 27 | 28 | /* DEBUG UATR Definition */ 29 | #ifndef DEBUG 30 | #define DEBUG DEBUG_UART1 31 | #endif 32 | 33 | 34 | void Delay_Init(void); 35 | void Delay_Us (uint32_t n); 36 | void Delay_Ms (uint32_t n); 37 | void USART_Printf_Init(uint32_t baudrate); 38 | 39 | #ifdef __cplusplus 40 | } 41 | #endif 42 | 43 | #endif 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /system/CH32V30x/SRC/Peripheral/inc/ch32v30x_crc.h: -------------------------------------------------------------------------------- 1 | /********************************** (C) COPYRIGHT ******************************* 2 | * File Name : ch32v30x_crc.h 3 | * Author : WCH 4 | * Version : V1.0.0 5 | * Date : 2021/06/06 6 | * Description : This file contains all the functions prototypes for the 7 | * CRC firmware library. 8 | ********************************************************************************* 9 | * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. 10 | * Attention: This software (modified or not) and binary are used for 11 | * microcontroller manufactured by Nanjing Qinheng Microelectronics. 12 | *******************************************************************************/ 13 | #ifndef __CH32V30x_CRC_H 14 | #define __CH32V30x_CRC_H 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | #include "ch32v30x.h" 21 | 22 | 23 | void CRC_ResetDR(void); 24 | uint32_t CRC_CalcCRC(uint32_t Data); 25 | uint32_t CRC_CalcBlockCRC(uint32_t pBuffer[], uint32_t BufferLength); 26 | uint32_t CRC_GetCRC(void); 27 | void CRC_SetIDRegister(uint8_t IDValue); 28 | uint8_t CRC_GetIDRegister(void); 29 | 30 | #ifdef __cplusplus 31 | } 32 | #endif 33 | 34 | #endif 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /system/CH32V30x/SRC/Peripheral/inc/ch32v30x_dvp.h: -------------------------------------------------------------------------------- 1 | /********************************** (C) COPYRIGHT ******************************* 2 | * File Name : ch32v30x_dvp.h 3 | * Author : WCH 4 | * Version : V1.0.0 5 | * Date : 2021/06/06 6 | * Description : This file contains all the functions prototypes for the 7 | * DVP firmware library. 8 | ********************************************************************************* 9 | * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. 10 | * Attention: This software (modified or not) and binary are used for 11 | * microcontroller manufactured by Nanjing Qinheng Microelectronics. 12 | *******************************************************************************/ 13 | #ifndef __CH32V30x_DVP_H 14 | #define __CH32V30x_DVP_H 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | #include "ch32v30x.h" 21 | 22 | /* DVP Data Mode */ 23 | typedef enum 24 | { 25 | Video_Mode = 0, 26 | JPEG_Mode, 27 | }DVP_Data_ModeTypeDef; 28 | 29 | 30 | /* DVP DMA */ 31 | typedef enum 32 | { 33 | DVP_DMA_Disable = 0, 34 | DVP_DMA_Enable, 35 | }DVP_DMATypeDef; 36 | 37 | /* DVP FLAG and FIFO Reset */ 38 | typedef enum 39 | { 40 | DVP_FLAG_FIFO_RESET_Disable = 0, 41 | DVP_FLAG_FIFO_RESET_Enable, 42 | }DVP_FLAG_FIFO_RESETTypeDef; 43 | 44 | /* DVP RX Reset */ 45 | typedef enum 46 | { 47 | DVP_RX_RESET_Disable = 0, 48 | DVP_RX_RESET_Enable, 49 | }DVP_RX_RESETTypeDef; 50 | 51 | 52 | 53 | void DVP_INTCfg( uint8_t s, uint8_t i ); 54 | void DVP_Mode( uint8_t s, DVP_Data_ModeTypeDef i); 55 | void DVP_Cfg( DVP_DMATypeDef s, DVP_FLAG_FIFO_RESETTypeDef i, DVP_RX_RESETTypeDef j); 56 | 57 | 58 | 59 | #ifdef __cplusplus 60 | } 61 | #endif 62 | 63 | #endif 64 | 65 | 66 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /system/CH32V30x/SRC/Peripheral/inc/ch32v30x_misc.h: -------------------------------------------------------------------------------- 1 | /********************************** (C) COPYRIGHT ******************************* 2 | * File Name : ch32v30x_misc.h 3 | * Author : WCH 4 | * Version : V1.0.0 5 | * Date : 2021/06/06 6 | * Description : This file contains all the functions prototypes for the 7 | * miscellaneous firmware library functions. 8 | ********************************************************************************* 9 | * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. 10 | * Attention: This software (modified or not) and binary are used for 11 | * microcontroller manufactured by Nanjing Qinheng Microelectronics. 12 | *******************************************************************************/ 13 | #ifndef __CH32V30X_MISC_H 14 | #define __CH32V30X_MISC_H 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | #include "ch32v30x.h" 21 | 22 | /* NVIC Init Structure definition */ 23 | typedef struct 24 | { 25 | uint8_t NVIC_IRQChannel; 26 | uint8_t NVIC_IRQChannelPreemptionPriority; 27 | uint8_t NVIC_IRQChannelSubPriority; 28 | FunctionalState NVIC_IRQChannelCmd; 29 | } NVIC_InitTypeDef; 30 | 31 | 32 | /* Preemption_Priority_Group */ 33 | #define NVIC_PriorityGroup_0 ((uint32_t)0x00) 34 | #define NVIC_PriorityGroup_1 ((uint32_t)0x01) 35 | #define NVIC_PriorityGroup_2 ((uint32_t)0x02) 36 | #define NVIC_PriorityGroup_3 ((uint32_t)0x03) 37 | #define NVIC_PriorityGroup_4 ((uint32_t)0x04) 38 | 39 | 40 | void NVIC_PriorityGroupConfig(uint32_t NVIC_PriorityGroup); 41 | void NVIC_Init(NVIC_InitTypeDef* NVIC_InitStruct); 42 | 43 | #ifdef __cplusplus 44 | } 45 | #endif 46 | 47 | #endif 48 | 49 | -------------------------------------------------------------------------------- /system/CH32V30x/SRC/Peripheral/inc/ch32v30x_rng.h: -------------------------------------------------------------------------------- 1 | /********************************** (C) COPYRIGHT ******************************* 2 | * File Name : ch32v30x_rng.h 3 | * Author : WCH 4 | * Version : V1.0.0 5 | * Date : 2021/06/06 6 | * Description : This file contains all the functions prototypes for the 7 | * RNG firmware library. 8 | ********************************************************************************* 9 | * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. 10 | * Attention: This software (modified or not) and binary are used for 11 | * microcontroller manufactured by Nanjing Qinheng Microelectronics. 12 | *******************************************************************************/ 13 | #ifndef __CH32V30x_RNG_H 14 | #define __CH32V30x_RNG_H 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | #include "ch32v30x.h" 20 | 21 | /* RNG_flags_definition*/ 22 | #define RNG_FLAG_DRDY ((uint8_t)0x0001) /* Data ready */ 23 | #define RNG_FLAG_CECS ((uint8_t)0x0002) /* Clock error current status */ 24 | #define RNG_FLAG_SECS ((uint8_t)0x0004) /* Seed error current status */ 25 | 26 | /* RNG_interrupts_definition */ 27 | #define RNG_IT_CEI ((uint8_t)0x20) /* Clock error interrupt */ 28 | #define RNG_IT_SEI ((uint8_t)0x40) /* Seed error interrupt */ 29 | 30 | 31 | void RNG_Cmd(FunctionalState NewState); 32 | uint32_t RNG_GetRandomNumber(void); 33 | void RNG_ITConfig(FunctionalState NewState); 34 | FlagStatus RNG_GetFlagStatus(uint8_t RNG_FLAG); 35 | void RNG_ClearFlag(uint8_t RNG_FLAG); 36 | ITStatus RNG_GetITStatus(uint8_t RNG_IT); 37 | void RNG_ClearITPendingBit(uint8_t RNG_IT); 38 | 39 | #ifdef __cplusplus 40 | } 41 | #endif 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /system/CH32V30x/SRC/Peripheral/inc/ch32v30x_wwdg.h: -------------------------------------------------------------------------------- 1 | /********************************** (C) COPYRIGHT ******************************* 2 | * File Name : ch32v30x_wwdg.h 3 | * Author : WCH 4 | * Version : V1.0.0 5 | * Date : 2021/06/06 6 | * Description : This file contains all the functions prototypes for the WWDG 7 | * firmware library. 8 | ********************************************************************************* 9 | * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. 10 | * Attention: This software (modified or not) and binary are used for 11 | * microcontroller manufactured by Nanjing Qinheng Microelectronics. 12 | *******************************************************************************/ 13 | #ifndef __CH32V30x_WWDG_H 14 | #define __CH32V30x_WWDG_H 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | #include "ch32v30x.h" 21 | 22 | 23 | /* WWDG_Prescaler */ 24 | #define WWDG_Prescaler_1 ((uint32_t)0x00000000) 25 | #define WWDG_Prescaler_2 ((uint32_t)0x00000080) 26 | #define WWDG_Prescaler_4 ((uint32_t)0x00000100) 27 | #define WWDG_Prescaler_8 ((uint32_t)0x00000180) 28 | 29 | 30 | void WWDG_DeInit(void); 31 | void WWDG_SetPrescaler(uint32_t WWDG_Prescaler); 32 | void WWDG_SetWindowValue(uint8_t WindowValue); 33 | void WWDG_EnableIT(void); 34 | void WWDG_SetCounter(uint8_t Counter); 35 | void WWDG_Enable(uint8_t Counter); 36 | FlagStatus WWDG_GetFlagStatus(void); 37 | void WWDG_ClearFlag(void); 38 | 39 | #ifdef __cplusplus 40 | } 41 | #endif 42 | 43 | #endif 44 | 45 | -------------------------------------------------------------------------------- /system/CH32V30x/USER/ch32v30x_conf.h: -------------------------------------------------------------------------------- 1 | /********************************** (C) COPYRIGHT ******************************* 2 | * File Name : ch32v30x_conf.h 3 | * Author : WCH 4 | * Version : V1.0.0 5 | * Date : 2021/06/06 6 | * Description : Library configuration file. 7 | ********************************************************************************* 8 | * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. 9 | * Attention: This software (modified or not) and binary are used for 10 | * microcontroller manufactured by Nanjing Qinheng Microelectronics. 11 | *******************************************************************************/ 12 | #ifndef __CH32V30x_CONF_H 13 | #define __CH32V30x_CONF_H 14 | 15 | #include "ch32v30x_adc.h" 16 | #include "ch32v30x_bkp.h" 17 | #include "ch32v30x_can.h" 18 | #include "ch32v30x_crc.h" 19 | #include "ch32v30x_dac.h" 20 | #include "ch32v30x_dbgmcu.h" 21 | #include "ch32v30x_dma.h" 22 | #include "ch32v30x_exti.h" 23 | #include "ch32v30x_flash.h" 24 | #include "ch32v30x_fsmc.h" 25 | #include "ch32v30x_gpio.h" 26 | #include "ch32v30x_i2c.h" 27 | #include "ch32v30x_iwdg.h" 28 | #include "ch32v30x_pwr.h" 29 | #include "ch32v30x_rcc.h" 30 | #include "ch32v30x_rtc.h" 31 | #include "ch32v30x_sdio.h" 32 | #include "ch32v30x_spi.h" 33 | #include "ch32v30x_tim.h" 34 | #include "ch32v30x_usart.h" 35 | #include "ch32v30x_wwdg.h" 36 | #include "ch32v30x_it.h" 37 | #include "ch32v30x_misc.h" 38 | 39 | 40 | #endif /* __CH32V30x_CONF_H */ 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /system/CH32V30x/USER/ch32v30x_it.c: -------------------------------------------------------------------------------- 1 | /********************************** (C) COPYRIGHT ******************************* 2 | * File Name : ch32v30x_it.c 3 | * Author : WCH 4 | * Version : V1.0.0 5 | * Date : 2021/06/06 6 | * Description : Main Interrupt Service Routines. 7 | ********************************************************************************* 8 | * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. 9 | * Attention: This software (modified or not) and binary are used for 10 | * microcontroller manufactured by Nanjing Qinheng Microelectronics. 11 | *******************************************************************************/ 12 | #include "ch32v30x_it.h" 13 | 14 | void NMI_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast"))); 15 | void HardFault_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast"))); 16 | 17 | /********************************************************************* 18 | * @fn NMI_Handler 19 | * 20 | * @brief This function handles NMI exception. 21 | * 22 | * @return none 23 | */ 24 | void NMI_Handler(void) 25 | { 26 | } 27 | 28 | /********************************************************************* 29 | * @fn HardFault_Handler 30 | * 31 | * @brief This function handles Hard Fault exception. 32 | * 33 | * @return none 34 | */ 35 | void HardFault_Handler(void) 36 | { 37 | while (1) 38 | { 39 | } 40 | } 41 | 42 | 43 | -------------------------------------------------------------------------------- /system/CH32V30x/USER/ch32v30x_it.h: -------------------------------------------------------------------------------- 1 | /********************************** (C) COPYRIGHT ******************************* 2 | * File Name : ch32v30x_it.h 3 | * Author : WCH 4 | * Version : V1.0.0 5 | * Date : 2021/06/06 6 | * Description : This file contains the headers of the interrupt handlers. 7 | ********************************************************************************* 8 | * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. 9 | * Attention: This software (modified or not) and binary are used for 10 | * microcontroller manufactured by Nanjing Qinheng Microelectronics. 11 | *******************************************************************************/ 12 | #ifndef __CH32V30x_IT_H 13 | #define __CH32V30x_IT_H 14 | 15 | #include "debug.h" 16 | 17 | 18 | #endif /* __CH32V30x_IT_H */ 19 | 20 | 21 | -------------------------------------------------------------------------------- /system/CH32V30x/USER/system_ch32v30x.h: -------------------------------------------------------------------------------- 1 | /********************************** (C) COPYRIGHT ******************************* 2 | * File Name : system_ch32v30x.h 3 | * Author : WCH 4 | * Version : V1.0.0 5 | * Date : 2021/06/06 6 | * Description : CH32V30x Device Peripheral Access Layer System Header File. 7 | ********************************************************************************* 8 | * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. 9 | * Attention: This software (modified or not) and binary are used for 10 | * microcontroller manufactured by Nanjing Qinheng Microelectronics. 11 | *******************************************************************************/ 12 | #ifndef __SYSTEM_CH32V30x_H 13 | #define __SYSTEM_CH32V30x_H 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | extern uint32_t SystemCoreClock; /* System Clock Frequency (Core Clock) */ 20 | 21 | /* System_Exported_Functions */ 22 | extern void SystemInit(void); 23 | extern void SystemCoreClockUpdate(void); 24 | 25 | #ifdef __cplusplus 26 | } 27 | #endif 28 | 29 | #endif /*__CH32V30x_SYSTEM_H */ 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /system/CH32VM00X/SRC/Peripheral/inc/ch32v00X_dbgmcu.h: -------------------------------------------------------------------------------- 1 | /********************************** (C) COPYRIGHT ******************************* 2 | * File Name : ch32v00X_dbgmcu.h 3 | * Author : WCH 4 | * Version : V1.0.0 5 | * Date : 2024/01/01 6 | * Description : This file contains all the functions prototypes for the 7 | * DBGMCU firmware library. 8 | ********************************************************************************* 9 | * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. 10 | * Attention: This software (modified or not) and binary are used for 11 | * microcontroller manufactured by Nanjing Qinheng Microelectronics. 12 | *******************************************************************************/ 13 | #ifndef __CH32V00X_DBGMCU_H 14 | #define __CH32V00X_DBGMCU_H 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | #include 21 | 22 | /* CFGR0 Register */ 23 | #define DBGMCU_SLEEP ((uint32_t)0x00000001) 24 | #define DBGMCU_STANDBY ((uint32_t)0x00000004) 25 | #define DBGMCU_IWDG_STOP ((uint32_t)0x00000100) 26 | #define DBGMCU_WWDG_STOP ((uint32_t)0x00000200) 27 | #define DBGMCU_TIM1_STOP ((uint32_t)0x00001000) 28 | #define DBGMCU_TIM2_STOP ((uint32_t)0x00002000) 29 | #define DBGMCU_TIM3_STOP ((uint32_t)0x00004000) 30 | 31 | uint32_t DBGMCU_GetREVID(void); 32 | uint32_t DBGMCU_GetDEVID(void); 33 | uint32_t __get_DEBUG_CR(void); 34 | void __set_DEBUG_CR(uint32_t value); 35 | void DBGMCU_Config(uint32_t DBGMCU_Periph, FunctionalState NewState); 36 | uint32_t DBGMCU_GetCHIPID( void ); 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | 41 | #endif /* __CH32V00X_DBGMCU_H */ 42 | -------------------------------------------------------------------------------- /system/CH32VM00X/SRC/Peripheral/inc/ch32v00X_wwdg.h: -------------------------------------------------------------------------------- 1 | /********************************** (C) COPYRIGHT ******************************* 2 | * File Name : ch32v00X_wwdg.h 3 | * Author : WCH 4 | * Version : V1.0.0 5 | * Date : 2024/01/01 6 | * Description : This file contains all the functions prototypes for the WWDG 7 | * firmware library. 8 | ********************************************************************************* 9 | * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. 10 | * Attention: This software (modified or not) and binary are used for 11 | * microcontroller manufactured by Nanjing Qinheng Microelectronics. 12 | *******************************************************************************/ 13 | #ifndef __CH32V00X_WWDG_H 14 | #define __CH32V00X_WWDG_H 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | #include 21 | 22 | /* WWDG_Prescaler */ 23 | #define WWDG_Prescaler_1 ((uint32_t)0x00000000) 24 | #define WWDG_Prescaler_2 ((uint32_t)0x00000080) 25 | #define WWDG_Prescaler_4 ((uint32_t)0x00000100) 26 | #define WWDG_Prescaler_8 ((uint32_t)0x00000180) 27 | 28 | void WWDG_DeInit(void); 29 | void WWDG_SetPrescaler(uint32_t WWDG_Prescaler); 30 | void WWDG_SetWindowValue(uint8_t WindowValue); 31 | void WWDG_EnableIT(void); 32 | void WWDG_SetCounter(uint8_t Counter); 33 | void WWDG_Enable(uint8_t Counter); 34 | FlagStatus WWDG_GetFlagStatus(void); 35 | void WWDG_ClearFlag(void); 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | 41 | #endif /* __CH32V00X_WWDG_H */ 42 | -------------------------------------------------------------------------------- /system/CH32VM00X/USER/ch32v00X_conf.h: -------------------------------------------------------------------------------- 1 | /********************************** (C) COPYRIGHT ******************************* 2 | * File Name : ch32v00X_conf.h 3 | * Author : WCH 4 | * Version : V1.0.0 5 | * Date : 2024/01/01 6 | * Description : Library configuration file. 7 | ********************************************************************************* 8 | * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. 9 | * Attention: This software (modified or not) and binary are used for 10 | * microcontroller manufactured by Nanjing Qinheng Microelectronics. 11 | *******************************************************************************/ 12 | #ifndef __CH32V00X_CONF_H 13 | #define __CH32V00X_CONF_H 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | 34 | 35 | #endif /* __CH32V00X_CONF_H */ 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /system/CH32VM00X/USER/ch32v00X_it.c: -------------------------------------------------------------------------------- 1 | /********************************** (C) COPYRIGHT ******************************* 2 | * File Name : ch32v00X_it.c 3 | * Author : WCH 4 | * Version : V1.0.0 5 | * Date : 2024/01/01 6 | * Description : Main Interrupt Service Routines. 7 | ********************************************************************************* 8 | * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. 9 | * Attention: This software (modified or not) and binary are used for 10 | * microcontroller manufactured by Nanjing Qinheng Microelectronics. 11 | *******************************************************************************/ 12 | #include 13 | 14 | void NMI_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast"))); 15 | void HardFault_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast"))); 16 | 17 | /********************************************************************* 18 | * @fn NMI_Handler 19 | * 20 | * @brief This function handles NMI exception. 21 | * 22 | * @return none 23 | */ 24 | void NMI_Handler(void) 25 | { 26 | while (1) 27 | { 28 | } 29 | } 30 | 31 | /********************************************************************* 32 | * @fn HardFault_Handler 33 | * 34 | * @brief This function handles Hard Fault exception. 35 | * 36 | * @return none 37 | */ 38 | void HardFault_Handler(void) 39 | { 40 | while (1) 41 | { 42 | } 43 | } 44 | 45 | 46 | -------------------------------------------------------------------------------- /system/CH32VM00X/USER/ch32v00X_it.h: -------------------------------------------------------------------------------- 1 | /********************************** (C) COPYRIGHT ******************************* 2 | * File Name : ch32v00X_it.h 3 | * Author : WCH 4 | * Version : V1.0.0 5 | * Date : 2024/01/01 6 | * Description : This file contains the headers of the interrupt handlers. 7 | ********************************************************************************* 8 | * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. 9 | * Attention: This software (modified or not) and binary are used for 10 | * microcontroller manufactured by Nanjing Qinheng Microelectronics. 11 | *******************************************************************************/ 12 | #ifndef __CH32V00X_IT_H 13 | #define __CH32V00X_IT_H 14 | 15 | #include "debug.h" 16 | 17 | 18 | #endif /* __CH32V00X_IT_H */ 19 | 20 | 21 | -------------------------------------------------------------------------------- /system/CH32VM00X/USER/system_ch32v00X.h: -------------------------------------------------------------------------------- 1 | /********************************** (C) COPYRIGHT ******************************* 2 | * File Name : system_ch32v00X.h 3 | * Author : WCH 4 | * Version : V1.0.0 5 | * Date : 2024/01/01 6 | * Description : CH32V00X Device Peripheral Access Layer System Header File. 7 | ********************************************************************************* 8 | * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. 9 | * Attention: This software (modified or not) and binary are used for 10 | * microcontroller manufactured by Nanjing Qinheng Microelectronics. 11 | *******************************************************************************/ 12 | #ifndef __SYSTEM_CH32V00X_H 13 | #define __SYSTEM_CH32V00X_H 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | extern uint32_t SystemCoreClock; /* System Clock Frequency (Core Clock) */ 20 | 21 | /* System_Exported_Functions */ 22 | extern void SystemInit(void); 23 | extern void SystemCoreClockUpdate(void); 24 | 25 | #ifdef __cplusplus 26 | } 27 | #endif 28 | 29 | #endif /*__CH32V00X_SYSTEM_H */ 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /system/CH32X035/SRC/Debug/debug.h: -------------------------------------------------------------------------------- 1 | /********************************** (C) COPYRIGHT ******************************* 2 | * File Name : debug.h 3 | * Author : WCH 4 | * Version : V1.0.0 5 | * Date : 2023/04/06 6 | * Description : This file contains all the functions prototypes for UART 7 | * Printf , Delay functions. 8 | ********************************************************************************* 9 | * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. 10 | * Attention: This software (modified or not) and binary are used for 11 | * microcontroller manufactured by Nanjing Qinheng Microelectronics. 12 | *******************************************************************************/ 13 | #ifndef __DEBUG_H 14 | #define __DEBUG_H 15 | 16 | #include "stdio.h" 17 | #include "ch32x035.h" 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | /* UART Printf Definition */ 24 | #define DEBUG_UART1 1 25 | #define DEBUG_UART2 2 26 | #define DEBUG_UART3 3 27 | 28 | /* DEBUG UATR Definition */ 29 | #ifndef DEBUG 30 | #define DEBUG DEBUG_UART1 31 | #endif 32 | 33 | void Delay_Init(void); 34 | void Delay_Us(uint32_t n); 35 | void Delay_Ms(uint32_t n); 36 | void USART_Printf_Init(uint32_t baudrate); 37 | 38 | #if(DEBUG) 39 | #define PRINT(format, ...) printf(format, ##__VA_ARGS__) 40 | #else 41 | #define PRINT(X...) 42 | #endif 43 | 44 | #ifdef __cplusplus 45 | } 46 | #endif 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /system/CH32X035/SRC/Peripheral/inc/ch32x035_dbgmcu.h: -------------------------------------------------------------------------------- 1 | /********************************** (C) COPYRIGHT ******************************* 2 | * File Name : ch32x035_dbgmcu.h 3 | * Author : WCH 4 | * Version : V1.0.0 5 | * Date : 2023/04/06 6 | * Description : This file contains all the functions prototypes for the 7 | * DBGMCU firmware library. 8 | ********************************************************************************* 9 | * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. 10 | * Attention: This software (modified or not) and binary are used for 11 | * microcontroller manufactured by Nanjing Qinheng Microelectronics. 12 | *******************************************************************************/ 13 | #ifndef __CH32X035_DBGMCU_H 14 | #define __CH32X035_DBGMCU_H 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | #include "ch32x035.h" 21 | 22 | #define DBGMCU_SLEEP ((uint32_t)0x00000001) 23 | #define DBGMCU_STOP ((uint32_t)0x00000002) 24 | #define DBGMCU_STANDBY ((uint32_t)0x00000004) 25 | #define DBGMCU_IWDG_STOP ((uint32_t)0x00000100) 26 | #define DBGMCU_WWDG_STOP ((uint32_t)0x00000200) 27 | #define DBGMCU_TIM1_STOP ((uint32_t)0x00001000) 28 | #define DBGMCU_TIM2_STOP ((uint32_t)0x00002000) 29 | #define DBGMCU_TIM3_STOP ((uint32_t)0x00004000) 30 | 31 | uint32_t DBGMCU_GetREVID(void); 32 | uint32_t DBGMCU_GetDEVID(void); 33 | uint32_t __get_DEBUG_CR(void); 34 | void __set_DEBUG_CR(uint32_t value); 35 | void DBGMCU_Config(uint32_t DBGMCU_Periph, FunctionalState NewState); 36 | uint32_t DBGMCU_GetCHIPID( void ); 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /system/CH32X035/SRC/Peripheral/inc/ch32x035_misc.h: -------------------------------------------------------------------------------- 1 | /********************************** (C) COPYRIGHT ******************************* 2 | * File Name : ch32x035_misc.h 3 | * Author : WCH 4 | * Version : V1.0.0 5 | * Date : 2023/04/06 6 | * Description : This file contains all the functions prototypes for the 7 | * miscellaneous firmware library functions. 8 | ********************************************************************************* 9 | * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. 10 | * Attention: This software (modified or not) and binary are used for 11 | * microcontroller manufactured by Nanjing Qinheng Microelectronics. 12 | *******************************************************************************/ 13 | #ifndef __CH32X035_MISC_H 14 | #define __CH32X035_MISC_H 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | #include "ch32x035.h" 21 | 22 | /* NVIC Init Structure definition */ 23 | typedef struct 24 | { 25 | uint8_t NVIC_IRQChannel; 26 | uint8_t NVIC_IRQChannelPreemptionPriority; 27 | uint8_t NVIC_IRQChannelSubPriority; 28 | FunctionalState NVIC_IRQChannelCmd; 29 | } NVIC_InitTypeDef; 30 | 31 | /* Preemption_Priority_Group */ 32 | #define NVIC_PriorityGroup_0 ((uint32_t)0x00) 33 | #define NVIC_PriorityGroup_1 ((uint32_t)0x01) 34 | #define NVIC_PriorityGroup_2 ((uint32_t)0x02) 35 | #define NVIC_PriorityGroup_3 ((uint32_t)0x03) 36 | #define NVIC_PriorityGroup_4 ((uint32_t)0x04) 37 | 38 | void NVIC_PriorityGroupConfig(uint32_t NVIC_PriorityGroup); 39 | void NVIC_Init(NVIC_InitTypeDef *NVIC_InitStruct); 40 | 41 | #ifdef __cplusplus 42 | } 43 | #endif 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /system/CH32X035/SRC/Peripheral/inc/ch32x035_pwr.h: -------------------------------------------------------------------------------- 1 | /********************************** (C) COPYRIGHT ******************************* 2 | * File Name : ch32x035_pwr.h 3 | * Author : WCH 4 | * Version : V1.0.0 5 | * Date : 2023/04/06 6 | * Description : This file contains all the functions prototypes for the PWR 7 | * firmware library. 8 | ********************************************************************************* 9 | * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. 10 | * Attention: This software (modified or not) and binary are used for 11 | * microcontroller manufactured by Nanjing Qinheng Microelectronics. 12 | *******************************************************************************/ 13 | #ifndef __CH32X035_PWR_H 14 | #define __CH32X035_PWR_H 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | #include "ch32x035.h" 21 | 22 | /* PVD_detection_level */ 23 | #define PWR_PVDLevel_2V1 ((uint32_t)0x00000000) 24 | #define PWR_PVDLevel_2V3 ((uint32_t)0x00000020) 25 | #define PWR_PVDLevel_3V0 ((uint32_t)0x00000040) 26 | #define PWR_PVDLevel_4V0 ((uint32_t)0x00000060) 27 | 28 | /* STOP_mode_entry */ 29 | #define PWR_STOPEntry_WFI ((uint8_t)0x01) 30 | #define PWR_STOPEntry_WFE ((uint8_t)0x02) 31 | 32 | /* PWR_Flag */ 33 | #define PWR_FLAG_PVDO ((uint32_t)0x00000004) 34 | #define PWR_FLAG_FLASH ((uint32_t)0x00000020) 35 | 36 | void PWR_DeInit(void); 37 | void PWR_PVDLevelConfig(uint32_t PWR_PVDLevel); 38 | void PWR_EnterSTOPMode(uint8_t PWR_STOPEntry); 39 | void PWR_EnterSTANDBYMode(void); 40 | FlagStatus PWR_GetFlagStatus(uint32_t PWR_FLAG); 41 | 42 | #ifdef __cplusplus 43 | } 44 | #endif 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /system/CH32X035/SRC/Peripheral/inc/ch32x035_wwdg.h: -------------------------------------------------------------------------------- 1 | /********************************** (C) COPYRIGHT ******************************* 2 | * File Name : ch32x035_wwdg.h 3 | * Author : WCH 4 | * Version : V1.0.0 5 | * Date : 2023/04/06 6 | * Description : This file contains all the functions prototypes for the WWDG 7 | * firmware library. 8 | ********************************************************************************* 9 | * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. 10 | * Attention: This software (modified or not) and binary are used for 11 | * microcontroller manufactured by Nanjing Qinheng Microelectronics. 12 | *******************************************************************************/ 13 | #ifndef __CH32X035_WWDG_H 14 | #define __CH32X035_WWDG_H 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | #include "ch32x035.h" 21 | 22 | /* WWDG_Prescaler */ 23 | #define WWDG_Prescaler_1 ((uint32_t)0x00000000) 24 | #define WWDG_Prescaler_2 ((uint32_t)0x00000080) 25 | #define WWDG_Prescaler_4 ((uint32_t)0x00000100) 26 | #define WWDG_Prescaler_8 ((uint32_t)0x00000180) 27 | 28 | void WWDG_DeInit(void); 29 | void WWDG_SetPrescaler(uint32_t WWDG_Prescaler); 30 | void WWDG_SetWindowValue(uint8_t WindowValue); 31 | void WWDG_EnableIT(void); 32 | void WWDG_SetCounter(uint8_t Counter); 33 | void WWDG_Enable(uint8_t Counter); 34 | FlagStatus WWDG_GetFlagStatus(void); 35 | void WWDG_ClearFlag(void); 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /system/CH32X035/USER/ch32x035_conf.h: -------------------------------------------------------------------------------- 1 | /********************************** (C) COPYRIGHT ******************************* 2 | * File Name : ch32x035_conf.h 3 | * Author : WCH 4 | * Version : V1.0.0 5 | * Date : 2023/04/06 6 | * Description : Library configuration file. 7 | ********************************************************************************* 8 | * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. 9 | * Attention: This software (modified or not) and binary are used for 10 | * microcontroller manufactured by Nanjing Qinheng Microelectronics. 11 | *******************************************************************************/ 12 | #ifndef __CH32X035_CONF_H 13 | #define __CH32X035_CONF_H 14 | 15 | #include "ch32x035_adc.h" 16 | #include "ch32x035_awu.h" 17 | #include "ch32x035_dbgmcu.h" 18 | #include "ch32x035_dma.h" 19 | #include "ch32x035_exti.h" 20 | #include "ch32x035_flash.h" 21 | #include "ch32x035_gpio.h" 22 | #include "ch32x035_i2c.h" 23 | #include "ch32x035_iwdg.h" 24 | #include "ch32x035_pwr.h" 25 | #include "ch32x035_rcc.h" 26 | #include "ch32x035_spi.h" 27 | #include "ch32x035_tim.h" 28 | #include "ch32x035_usart.h" 29 | #include "ch32x035_wwdg.h" 30 | #include "ch32x035_it.h" 31 | #include "ch32x035_misc.h" 32 | 33 | 34 | #endif 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /system/CH32X035/USER/ch32x035_it.c: -------------------------------------------------------------------------------- 1 | /********************************** (C) COPYRIGHT ******************************* 2 | * File Name : ch32x035_it.c 3 | * Author : WCH 4 | * Version : V1.0.0 5 | * Date : 2023/04/06 6 | * Description : Main Interrupt Service Routines. 7 | ********************************************************************************* 8 | * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. 9 | * Attention: This software (modified or not) and binary are used for 10 | * microcontroller manufactured by Nanjing Qinheng Microelectronics. 11 | *******************************************************************************/ 12 | #include "ch32x035_it.h" 13 | 14 | void NMI_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast"))); 15 | void HardFault_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast"))); 16 | 17 | /********************************************************************* 18 | * @fn NMI_Handler 19 | * 20 | * @brief This function handles NMI exception. 21 | * 22 | * @return none 23 | */ 24 | void NMI_Handler(void) 25 | { 26 | } 27 | 28 | /********************************************************************* 29 | * @fn HardFault_Handler 30 | * 31 | * @brief This function handles Hard Fault exception. 32 | * 33 | * @return none 34 | */ 35 | void HardFault_Handler(void) 36 | { 37 | while (1) 38 | { 39 | } 40 | } 41 | 42 | 43 | -------------------------------------------------------------------------------- /system/CH32X035/USER/ch32x035_it.h: -------------------------------------------------------------------------------- 1 | /********************************** (C) COPYRIGHT ******************************* 2 | * File Name : ch32x035_it.h 3 | * Author : WCH 4 | * Version : V1.0.0 5 | * Date : 2023/04/06 6 | * Description : This file contains the headers of the interrupt handlers. 7 | ********************************************************************************* 8 | * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. 9 | * Attention: This software (modified or not) and binary are used for 10 | * microcontroller manufactured by Nanjing Qinheng Microelectronics. 11 | *******************************************************************************/ 12 | #ifndef __CH32X035_IT_H 13 | #define __CH32X035_IT_H 14 | 15 | #include "debug.h" 16 | 17 | 18 | #endif 19 | 20 | 21 | -------------------------------------------------------------------------------- /system/CH32X035/USER/system_ch32x035.h: -------------------------------------------------------------------------------- 1 | /********************************** (C) COPYRIGHT ******************************* 2 | * File Name : system_ch32x035.h 3 | * Author : WCH 4 | * Version : V1.0.0 5 | * Date : 2023/04/06 6 | * Description : CH32X035 Device Peripheral Access Layer System Header File. 7 | ********************************************************************************* 8 | * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. 9 | * Attention: This software (modified or not) and binary are used for 10 | * microcontroller manufactured by Nanjing Qinheng Microelectronics. 11 | *******************************************************************************/ 12 | #ifndef __SYSTEM_CH32X035_H 13 | #define __SYSTEM_CH32X035_H 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | extern uint32_t SystemCoreClock; /* System Clock Frequency (Core Clock) */ 20 | 21 | /* System_Exported_Functions */ 22 | extern void SystemInit(void); 23 | extern void SystemCoreClockUpdate(void); 24 | 25 | #ifdef __cplusplus 26 | } 27 | #endif 28 | 29 | #endif 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /variants/CH32L10x/CH32L103C8T6/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # v3.21 implemented semantic changes regarding $ 2 | # See https://cmake.org/cmake/help/v3.21/command/target_link_libraries.html#linking-object-libraries-via-target-objects 3 | cmake_minimum_required(VERSION 3.21) 4 | 5 | add_library(variant INTERFACE) 6 | add_library(variant_usage INTERFACE) 7 | 8 | target_include_directories(variant_usage INTERFACE 9 | . 10 | ) 11 | 12 | 13 | target_link_libraries(variant_usage INTERFACE 14 | base_config 15 | ) 16 | 17 | target_link_libraries(variant INTERFACE variant_usage) 18 | 19 | 20 | 21 | add_library(variant_bin STATIC EXCLUDE_FROM_ALL 22 | PeripheralPins.c 23 | variant_CH32V103R8T6.cpp 24 | ) 25 | target_link_libraries(variant_bin PUBLIC variant_usage) 26 | 27 | target_link_libraries(variant INTERFACE 28 | variant_bin 29 | ) 30 | 31 | -------------------------------------------------------------------------------- /variants/CH32L10x/CH32L103C8T6/PinNamesVar.h: -------------------------------------------------------------------------------- 1 | /* Alternate pin name */ 2 | PA_0_ALT1 = PA_0 | ALT1, 3 | PA_1_ALT1 = PA_1 | ALT1, 4 | PA_2_ALT1 = PA_2 | ALT1, 5 | PA_3_ALT1 = PA_3 | ALT1, 6 | PA_4_ALT1 = PA_4 | ALT1, 7 | PA_5_ALT1 = PA_5 | ALT1, 8 | 9 | 10 | /* SYS_WKUP */ 11 | #ifdef PWR_WAKEUP_PIN1 12 | SYS_WKUP1 = PA_0, 13 | #endif 14 | 15 | /* USB */ 16 | #ifdef USBCON 17 | USB_DM = PA_11, 18 | USB_DP = PA_12, 19 | #endif 20 | -------------------------------------------------------------------------------- /variants/CH32L10x/CH32L103C8T6/boards_entry.txt: -------------------------------------------------------------------------------- 1 | # This file help to add generic board entry. 2 | 3 | 4 | 5 | # CH32L103C8T6 6 | CH32L10x_EVT.menu.pnum.CH32L103C8T6=CH32L103C8T6 EVT 7 | CH32L10x_EVT.menu.pnum.CH32L103C8T6.upload.maximum_size=65536 8 | CH32L10x_EVT.menu.pnum.CH32L103C8T6.upload.maximum_data_size=20480 9 | CH32L10x_EVT.menu.pnum.CH32L103C8T6.build.board=CH32L103C8T6 10 | CH32L10x_EVT.menu.pnum.CH32L103C8T6.build.variant=CH32L10x/CH32L103C8T6 11 | 12 | -------------------------------------------------------------------------------- /variants/CH32L10x/CH32L103C8T6/variant_CH32L103C8T6.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | ******************************************************************************* 3 | * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. 4 | * All rights reserved. 5 | * 6 | * This software component is licensed by WCH under BSD 3-Clause license, 7 | * the "License"; You may not use this file except in compliance with the 8 | * License. You may obtain a copy of the License at: 9 | * opensource.org/licenses/BSD-3-Clause 10 | * 11 | ******************************************************************************* 12 | */ 13 | 14 | #include "pins_arduino.h" 15 | 16 | 17 | 18 | 19 | // Digital PinName array 20 | const PinName digitalPin[] = { 21 | PA_0, //D0/A0 22 | PA_1, //D1/A1 23 | PA_2, //D2/A2 24 | PA_3, //D3/A3 25 | PA_4, //D4/A4 26 | PA_5, //D5/A5 27 | 28 | PA_10, //D6 USART1_RX 29 | PA_9, //D7 USART1_TX 30 | PB_4, //D8 31 | PB_6, //D9 32 | PB_7, //D10 33 | PB_8, //D11 34 | PB_9, //D12 35 | PA_8, //D13 36 | PB_1, //D14 37 | PB_0, //D15 38 | PB_12, //D16 SPI2_NSS 39 | PB_15, //D17 SPI2_MOSI 40 | PB_14, //D18 SPI2_MISO 41 | PB_13, //D19 SPI2_SCK 42 | PB_11, //D20 I2C2_SDA 43 | PB_10 //D21 I2C2_SCL 44 | }; 45 | 46 | // Analog (Ax) pin number array 47 | const uint32_t analogInputPin[] = { 48 | 0, // A0, PA0 49 | 1, // A1, PA1 50 | 2, // A2, PA2 51 | 3, // A3, PA3 52 | 4, // A4, PA4 53 | 5 // A5, PA5 54 | }; 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /variants/CH32V00x/CH32V003F4/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # v3.21 implemented semantic changes regarding $ 2 | # See https://cmake.org/cmake/help/v3.21/command/target_link_libraries.html#linking-object-libraries-via-target-objects 3 | cmake_minimum_required(VERSION 3.21) 4 | 5 | add_library(variant INTERFACE) 6 | add_library(variant_usage INTERFACE) 7 | 8 | target_include_directories(variant_usage INTERFACE 9 | . 10 | ) 11 | 12 | 13 | target_link_libraries(variant_usage INTERFACE 14 | base_config 15 | ) 16 | 17 | target_link_libraries(variant INTERFACE variant_usage) 18 | 19 | 20 | 21 | add_library(variant_bin STATIC EXCLUDE_FROM_ALL 22 | PeripheralPins.c 23 | variant_CH32V003F4.cpp 24 | ) 25 | target_link_libraries(variant_bin PUBLIC variant_usage) 26 | 27 | target_link_libraries(variant INTERFACE 28 | variant_bin 29 | ) 30 | 31 | -------------------------------------------------------------------------------- /variants/CH32V00x/CH32V003F4/PinNamesVar.h: -------------------------------------------------------------------------------- 1 | /* SYS_WKUP */ 2 | #ifdef PWR_WAKEUP_PIN1 3 | SYS_WKUP1 = PA_0, 4 | #endif 5 | #ifdef PWR_WAKEUP_PIN2 6 | SYS_WKUP2 = NC, 7 | #endif 8 | #ifdef PWR_WAKEUP_PIN3 9 | SYS_WKUP3 = NC, 10 | #endif 11 | #ifdef PWR_WAKEUP_PIN4 12 | SYS_WKUP4 = NC, 13 | #endif 14 | #ifdef PWR_WAKEUP_PIN5 15 | SYS_WKUP5 = NC, 16 | #endif 17 | #ifdef PWR_WAKEUP_PIN6 18 | SYS_WKUP6 = NC, 19 | #endif 20 | #ifdef PWR_WAKEUP_PIN7 21 | SYS_WKUP7 = NC, 22 | #endif 23 | #ifdef PWR_WAKEUP_PIN8 24 | SYS_WKUP8 = NC, 25 | #endif 26 | 27 | 28 | -------------------------------------------------------------------------------- /variants/CH32V00x/CH32V003F4/boards_entry.txt: -------------------------------------------------------------------------------- 1 | # This file help to add generic board entry. 2 | 3 | 4 | 5 | # CH32V003F4 6 | CH32V00x_EVT.menu.pnum.CH32V003F4=CH32V00x EVT 7 | CH32V00x_EVT.menu.pnum.CH32V003F4.upload.maximum_size=16384 8 | CH32V00x_EVT.menu.pnum.CH32V003F4.upload.maximum_data_size=2048 9 | CH32V00x_EVT.menu.pnum.CH32V003F4.build.board=CH32V003F4 10 | CH32V00x_EVT.menu.pnum.CH32V003F4.build.product_line=CH32V00x 11 | CH32V00x_EVT.menu.pnum.CH32V003F4.build.variant=CH32V00x/CH32V003F4 12 | 13 | -------------------------------------------------------------------------------- /variants/CH32V00x/CH32V003F4/variant_CH32V003F4.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | ******************************************************************************* 3 | * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. 4 | * All rights reserved. 5 | * 6 | * This software component is licensed by WCH under BSD 3-Clause license, 7 | * the "License"; You may not use this file except in compliance with the 8 | * License. You may obtain a copy of the License at: 9 | * opensource.org/licenses/BSD-3-Clause 10 | * 11 | ******************************************************************************* 12 | */ 13 | 14 | #include "pins_arduino.h" 15 | 16 | 17 | 18 | 19 | // Digital PinName array,Some GPIOs are bound to the same pin. 20 | const PinName digitalPin[] = { 21 | PA_1, // D0/A1 22 | PA_2, // D1/A0 23 | PC_0, // D2 24 | PC_1, // D3 25 | PC_2, // D4 26 | PC_3, // D5 27 | PC_4, // D6/A2 28 | PC_5, // D7 29 | PC_6, // D8 30 | PC_7, // D9 31 | PD_0, // D10 32 | PD_1, // D11 33 | PD_2, // D12/A3 34 | PD_3, // D13/A4 35 | PD_4, // D14/A7 36 | PD_5, // D15/A5 37 | PD_6, // D16/A6 38 | PD_7 // D17 39 | }; 40 | 41 | // Analog (Ax) pin number array 42 | const uint32_t analogInputPin[] = { 43 | 1, // A0/PA2 44 | 0, // A1/PA1 45 | 6, // A2/PC4 46 | 12, // A3/PD2 47 | 13, // A4/PD3 48 | 15, // A5/PD5 49 | 16, // A6/PD6 50 | 14 // A7/PD4 51 | }; 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /variants/CH32V10x/CH32V103R8T6/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # v3.21 implemented semantic changes regarding $ 2 | # See https://cmake.org/cmake/help/v3.21/command/target_link_libraries.html#linking-object-libraries-via-target-objects 3 | cmake_minimum_required(VERSION 3.21) 4 | 5 | add_library(variant INTERFACE) 6 | add_library(variant_usage INTERFACE) 7 | 8 | target_include_directories(variant_usage INTERFACE 9 | . 10 | ) 11 | 12 | 13 | target_link_libraries(variant_usage INTERFACE 14 | base_config 15 | ) 16 | 17 | target_link_libraries(variant INTERFACE variant_usage) 18 | 19 | 20 | 21 | add_library(variant_bin STATIC EXCLUDE_FROM_ALL 22 | PeripheralPins.c 23 | variant_CH32V103R8T6.cpp 24 | ) 25 | target_link_libraries(variant_bin PUBLIC variant_usage) 26 | 27 | target_link_libraries(variant INTERFACE 28 | variant_bin 29 | ) 30 | 31 | -------------------------------------------------------------------------------- /variants/CH32V10x/CH32V103R8T6/PinNamesVar.h: -------------------------------------------------------------------------------- 1 | /* Alternate pin name */ 2 | PA_0_ALT1 = PA_0 | ALT1, 3 | PA_1_ALT1 = PA_1 | ALT1, 4 | PA_2_ALT1 = PA_2 | ALT1, 5 | PA_3_ALT1 = PA_3 | ALT1, 6 | PA_4_ALT1 = PA_4 | ALT1, 7 | PA_5_ALT1 = PA_5 | ALT1, 8 | 9 | 10 | /* SYS_WKUP */ 11 | #ifdef PWR_WAKEUP_PIN1 12 | SYS_WKUP1 = PA_0, 13 | #endif 14 | 15 | /* USB */ 16 | #ifdef USBCON 17 | USB_DM = PA_11, 18 | USB_DP = PA_12, 19 | #endif 20 | -------------------------------------------------------------------------------- /variants/CH32V10x/CH32V103R8T6/boards_entry.txt: -------------------------------------------------------------------------------- 1 | # This file help to add generic board entry. 2 | 3 | 4 | 5 | # CH32V103R8T6 6 | CH32V10x_EVT.menu.pnum.CH32V103R8T6=CH32V103R8T6 EVT 7 | CH32V10x_EVT.menu.pnum.CH32V103R8T6.upload.maximum_size=262144 8 | CH32V10x_EVT.menu.pnum.CH32V103R8T6.upload.maximum_data_size=65536 9 | CH32V10x_EVT.menu.pnum.CH32V103R8T6.build.board=CH32V103R8T6 10 | CH32V10x_EVT.menu.pnum.CH32V103R8T6.build.variant=CH32V10x/CH32V103R8T6 11 | 12 | -------------------------------------------------------------------------------- /variants/CH32V10x/CH32V103R8T6/variant_CH32V103R8T6.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | ******************************************************************************* 3 | * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. 4 | * All rights reserved. 5 | * 6 | * This software component is licensed by WCH under BSD 3-Clause license, 7 | * the "License"; You may not use this file except in compliance with the 8 | * License. You may obtain a copy of the License at: 9 | * opensource.org/licenses/BSD-3-Clause 10 | * 11 | ******************************************************************************* 12 | */ 13 | 14 | #include "pins_arduino.h" 15 | 16 | 17 | 18 | 19 | // Digital PinName array 20 | const PinName digitalPin[] = { 21 | PA_0, //D0/A0 22 | PA_1, //D1/A1 23 | PA_2, //D2/A2 24 | PA_3, //D3/A3 25 | PA_4, //D4/A4 26 | PA_5, //D5/A5 27 | 28 | PA_10, //D6 USART1_RX 29 | PA_9, //D7 USART1_TX 30 | PB_4, //D8 31 | PB_6, //D9 32 | PB_7, //D10 33 | PB_8, //D11 34 | PB_9, //D12 35 | PA_8, //D13 36 | PB_1, //D14 37 | PB_0, //D15 38 | PB_12, //D16 SPI2_NSS 39 | PB_15, //D17 SPI2_MOSI 40 | PB_14, //D18 SPI2_MISO 41 | PB_13, //D19 SPI2_SCK 42 | PB_11, //D20 I2C2_SDA 43 | PB_10 //D21 I2C2_SCL 44 | }; 45 | 46 | // Analog (Ax) pin number array 47 | const uint32_t analogInputPin[] = { 48 | 0, // A0, PA0 49 | 1, // A1, PA1 50 | 2, // A2, PA2 51 | 3, // A3, PA3 52 | 4, // A4, PA4 53 | 5 // A5, PA5 54 | }; 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /variants/CH32V20x/CH32V203C6/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # v3.21 implemented semantic changes regarding $ 2 | # See https://cmake.org/cmake/help/v3.21/command/target_link_libraries.html#linking-object-libraries-via-target-objects 3 | cmake_minimum_required(VERSION 3.21) 4 | 5 | add_library(variant INTERFACE) 6 | add_library(variant_usage INTERFACE) 7 | 8 | target_include_directories(variant_usage INTERFACE 9 | . 10 | ) 11 | 12 | 13 | target_link_libraries(variant_usage INTERFACE 14 | base_config 15 | ) 16 | 17 | target_link_libraries(variant INTERFACE variant_usage) 18 | 19 | 20 | 21 | add_library(variant_bin STATIC EXCLUDE_FROM_ALL 22 | PeripheralPins.c 23 | variant_CH32V203C6.cpp 24 | ) 25 | target_link_libraries(variant_bin PUBLIC variant_usage) 26 | 27 | target_link_libraries(variant INTERFACE 28 | variant_bin 29 | ) 30 | 31 | -------------------------------------------------------------------------------- /variants/CH32V20x/CH32V203C6/PinNamesVar.h: -------------------------------------------------------------------------------- 1 | /* Alternate pin name */ 2 | PA_0_ALT1 = PA_0 | ALT1, 3 | PA_1_ALT1 = PA_1 | ALT1, 4 | PA_2_ALT1 = PA_2 | ALT1, 5 | PA_3_ALT1 = PA_3 | ALT1, 6 | PA_4_ALT1 = PA_4 | ALT1, 7 | PA_5_ALT1 = PA_5 | ALT1, 8 | PA_6_ALT1 = PA_6 | ALT1, 9 | PA_7_ALT1 = PA_7 | ALT1, 10 | PA_8_ALT1 = PA_8 | ALT1, 11 | PA_9_ALT1 = PA_9 | ALT1, 12 | PA_10_ALT1 = PA_10 | ALT1, 13 | PA_11_ALT1 = PA_11 | ALT1, 14 | PA_15_ALT1 = PA_15 | ALT1, 15 | PB_0_ALT1 = PB_0 | ALT1, 16 | PB_0_ALT2 = PB_0 | ALT2, 17 | PB_1_ALT1 = PB_1 | ALT1, 18 | PB_1_ALT2 = PB_1 | ALT2, 19 | PB_3_ALT1 = PB_3 | ALT1, 20 | PB_10_ALT1 = PB_10 | ALT1, 21 | PB_11_ALT1 = PB_11 | ALT1, 22 | 23 | /* SYS_WKUP */ 24 | #ifdef PWR_WAKEUP_PIN1 25 | SYS_WKUP1 = PA_0, 26 | #endif 27 | #ifdef PWR_WAKEUP_PIN2 28 | SYS_WKUP2 = NC, 29 | #endif 30 | #ifdef PWR_WAKEUP_PIN3 31 | SYS_WKUP3 = NC, 32 | #endif 33 | #ifdef PWR_WAKEUP_PIN4 34 | SYS_WKUP4 = NC, 35 | #endif 36 | #ifdef PWR_WAKEUP_PIN5 37 | SYS_WKUP5 = NC, 38 | #endif 39 | #ifdef PWR_WAKEUP_PIN6 40 | SYS_WKUP6 = NC, 41 | #endif 42 | #ifdef PWR_WAKEUP_PIN7 43 | SYS_WKUP7 = NC, 44 | #endif 45 | #ifdef PWR_WAKEUP_PIN8 46 | SYS_WKUP8 = NC, 47 | #endif 48 | 49 | /* USB */ 50 | #ifdef USBCON 51 | USB_DM = PA_11, 52 | USB_DP = PA_12, 53 | #endif 54 | -------------------------------------------------------------------------------- /variants/CH32V20x/CH32V203C6/boards_entry.txt: -------------------------------------------------------------------------------- 1 | # This file help to add generic board entry. 2 | 3 | 4 | 5 | # CH32V203C8 6 | CH32V20x_EVT.menu.pnum.CH32V203C8=CH32V203C8 EVT 7 | CH32V20x_EVT.menu.pnum.CH32V203C8.upload.maximum_size=65536 8 | CH32V20x_EVT.menu.pnum.CH32V203C8.upload.maximum_data_size=20480 9 | CH32V20x_EVT.menu.pnum.CH32V203C8.build.board=CH32V203C8 10 | CH32V20x_EVT.menu.pnum.CH32V203C8.build.product_line=CH32V203x8 11 | CH32V20x_EVT.menu.pnum.CH32V203C8.build.variant=CH32V20x/CH32V203C8 12 | 13 | -------------------------------------------------------------------------------- /variants/CH32V20x/CH32V203C6/variant_CH32V203C6.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | ******************************************************************************* 3 | * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. 4 | * All rights reserved. 5 | * 6 | * This software component is licensed by WCH under BSD 3-Clause license, 7 | * the "License"; You may not use this file except in compliance with the 8 | * License. You may obtain a copy of the License at: 9 | * opensource.org/licenses/BSD-3-Clause 10 | * 11 | ******************************************************************************* 12 | */ 13 | 14 | #include "pins_arduino.h" 15 | 16 | 17 | 18 | 19 | // Digital PinName array 20 | const PinName digitalPin[] = { 21 | PA_0, // D0/A0 22 | PA_1, // D1/A1 23 | PA_2, // D2/A2 24 | PA_3, // D3/A3 25 | PA_4, // D4/A4 26 | PA_5, // D5/A5 27 | PA_6, // D6/A6 28 | PA_7, // D7/A7 29 | PA_8, // D8 30 | PA_9, // D9 31 | PA_10, // D10 32 | PA_11, // D11 33 | PA_12, // D12 34 | PA_13, // D13 35 | PA_14, // D14 36 | PA_15, // D15 37 | PB_0, // D16/A8 38 | PB_1, // D17/A9 39 | PB_2, // D18 40 | PB_3, // D19 41 | PB_4, // D20 42 | PB_5, // D21 43 | PB_6, // D22 44 | PB_7, // D23 45 | PB_8, // D24 46 | PB_9, // D25 47 | PB_10, // D26 48 | PB_11, // D27 49 | PB_12, // D28 50 | PB_13, // D29 51 | PB_14, // D30 52 | PB_15, // D31 53 | PC_13, // D32 54 | PC_14, // D33 55 | PC_15, // D34 56 | PD_0, // D35 57 | PD_1 // D36 58 | }; 59 | 60 | // Analog (Ax) pin number array 61 | const uint32_t analogInputPin[] = { 62 | 0, // A0, PA0 63 | 1, // A1, PA1 64 | 2, // A2, PA2 65 | 3, // A3, PA3 66 | 4, // A4, PA4 67 | 5, // A5, PA5 68 | 6, // A6, PA6 69 | 7, // A7, PA7 70 | 16, // A8, PB0 71 | 17 // A9, PB1 72 | }; 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /variants/CH32V20x/CH32V203C8/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # v3.21 implemented semantic changes regarding $ 2 | # See https://cmake.org/cmake/help/v3.21/command/target_link_libraries.html#linking-object-libraries-via-target-objects 3 | cmake_minimum_required(VERSION 3.21) 4 | 5 | add_library(variant INTERFACE) 6 | add_library(variant_usage INTERFACE) 7 | 8 | target_include_directories(variant_usage INTERFACE 9 | . 10 | ) 11 | 12 | 13 | target_link_libraries(variant_usage INTERFACE 14 | base_config 15 | ) 16 | 17 | target_link_libraries(variant INTERFACE variant_usage) 18 | 19 | 20 | 21 | add_library(variant_bin STATIC EXCLUDE_FROM_ALL 22 | PeripheralPins.c 23 | variant_CH32V203C8.cpp 24 | ) 25 | target_link_libraries(variant_bin PUBLIC variant_usage) 26 | 27 | target_link_libraries(variant INTERFACE 28 | variant_bin 29 | ) 30 | 31 | -------------------------------------------------------------------------------- /variants/CH32V20x/CH32V203C8/PinNamesVar.h: -------------------------------------------------------------------------------- 1 | /* Alternate pin name */ 2 | PA_0_ALT1 = PA_0 | ALT1, 3 | PA_1_ALT1 = PA_1 | ALT1, 4 | PA_2_ALT1 = PA_2 | ALT1, 5 | PA_3_ALT1 = PA_3 | ALT1, 6 | PA_4_ALT1 = PA_4 | ALT1, 7 | PA_5_ALT1 = PA_5 | ALT1, 8 | PA_6_ALT1 = PA_6 | ALT1, 9 | PA_7_ALT1 = PA_7 | ALT1, 10 | PA_8_ALT1 = PA_8 | ALT1, 11 | PA_9_ALT1 = PA_9 | ALT1, 12 | PA_10_ALT1 = PA_10 | ALT1, 13 | PA_11_ALT1 = PA_11 | ALT1, 14 | PA_15_ALT1 = PA_15 | ALT1, 15 | PB_0_ALT1 = PB_0 | ALT1, 16 | PB_0_ALT2 = PB_0 | ALT2, 17 | PB_1_ALT1 = PB_1 | ALT1, 18 | PB_1_ALT2 = PB_1 | ALT2, 19 | PB_3_ALT1 = PB_3 | ALT1, 20 | PB_10_ALT1 = PB_10 | ALT1, 21 | PB_11_ALT1 = PB_11 | ALT1, 22 | 23 | /* SYS_WKUP */ 24 | #ifdef PWR_WAKEUP_PIN1 25 | SYS_WKUP1 = PA_0, 26 | #endif 27 | #ifdef PWR_WAKEUP_PIN2 28 | SYS_WKUP2 = NC, 29 | #endif 30 | #ifdef PWR_WAKEUP_PIN3 31 | SYS_WKUP3 = NC, 32 | #endif 33 | #ifdef PWR_WAKEUP_PIN4 34 | SYS_WKUP4 = NC, 35 | #endif 36 | #ifdef PWR_WAKEUP_PIN5 37 | SYS_WKUP5 = NC, 38 | #endif 39 | #ifdef PWR_WAKEUP_PIN6 40 | SYS_WKUP6 = NC, 41 | #endif 42 | #ifdef PWR_WAKEUP_PIN7 43 | SYS_WKUP7 = NC, 44 | #endif 45 | #ifdef PWR_WAKEUP_PIN8 46 | SYS_WKUP8 = NC, 47 | #endif 48 | 49 | /* USB */ 50 | #ifdef USBCON 51 | USB_DM = PA_11, 52 | USB_DP = PA_12, 53 | #endif 54 | -------------------------------------------------------------------------------- /variants/CH32V20x/CH32V203C8/boards_entry.txt: -------------------------------------------------------------------------------- 1 | # This file help to add generic board entry. 2 | 3 | 4 | 5 | # CH32V203C8 6 | CH32V20x_EVT.menu.pnum.CH32V203C8=CH32V203C8 EVT 7 | CH32V20x_EVT.menu.pnum.CH32V203C8.upload.maximum_size=65536 8 | CH32V20x_EVT.menu.pnum.CH32V203C8.upload.maximum_data_size=20480 9 | CH32V20x_EVT.menu.pnum.CH32V203C8.build.board=CH32V203C8 10 | CH32V20x_EVT.menu.pnum.CH32V203C8.build.product_line=CH32V203x8 11 | CH32V20x_EVT.menu.pnum.CH32V203C8.build.variant=CH32V20x/CH32V203C8 12 | 13 | -------------------------------------------------------------------------------- /variants/CH32V20x/CH32V203C8/variant_CH32V203C8.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | ******************************************************************************* 3 | * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. 4 | * All rights reserved. 5 | * 6 | * This software component is licensed by WCH under BSD 3-Clause license, 7 | * the "License"; You may not use this file except in compliance with the 8 | * License. You may obtain a copy of the License at: 9 | * opensource.org/licenses/BSD-3-Clause 10 | * 11 | ******************************************************************************* 12 | */ 13 | 14 | #include "pins_arduino.h" 15 | 16 | 17 | 18 | 19 | // Digital PinName array 20 | const PinName digitalPin[] = { 21 | PA_0, // D0/A0 22 | PA_1, // D1/A1 23 | PA_2, // D2/A2 24 | PA_3, // D3/A3 25 | PA_4, // D4/A4 26 | PA_5, // D5/A5 27 | PA_6, // D6/A6 28 | PA_7, // D7/A7 29 | PA_8, // D8 30 | PA_9, // D9 31 | PA_10, // D10 32 | PA_11, // D11 33 | PA_12, // D12 34 | PA_13, // D13 35 | PA_14, // D14 36 | PA_15, // D15 37 | PB_0, // D16/A8 38 | PB_1, // D17/A9 39 | PB_2, // D18 40 | PB_3, // D19 41 | PB_4, // D20 42 | PB_5, // D21 43 | PB_6, // D22 44 | PB_7, // D23 45 | PB_8, // D24 46 | PB_9, // D25 47 | PB_10, // D26 48 | PB_11, // D27 49 | PB_12, // D28 50 | PB_13, // D29 51 | PB_14, // D30 52 | PB_15, // D31 53 | PC_13, // D32 54 | PC_14, // D33 55 | PC_15, // D34 56 | PD_0, // D35 57 | PD_1 // D36 58 | }; 59 | 60 | // Analog (Ax) pin number array 61 | const uint32_t analogInputPin[] = { 62 | 0, // A0, PA0 63 | 1, // A1, PA1 64 | 2, // A2, PA2 65 | 3, // A3, PA3 66 | 4, // A4, PA4 67 | 5, // A5, PA5 68 | 6, // A6, PA6 69 | 7, // A7, PA7 70 | 16, // A8, PB0 71 | 17 // A9, PB1 72 | }; 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /variants/CH32V20x/CH32V203G6/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # v3.21 implemented semantic changes regarding $ 2 | # See https://cmake.org/cmake/help/v3.21/command/target_link_libraries.html#linking-object-libraries-via-target-objects 3 | cmake_minimum_required(VERSION 3.21) 4 | 5 | add_library(variant INTERFACE) 6 | add_library(variant_usage INTERFACE) 7 | 8 | target_include_directories(variant_usage INTERFACE 9 | . 10 | ) 11 | 12 | 13 | target_link_libraries(variant_usage INTERFACE 14 | base_config 15 | ) 16 | 17 | target_link_libraries(variant INTERFACE variant_usage) 18 | 19 | 20 | 21 | add_library(variant_bin STATIC EXCLUDE_FROM_ALL 22 | PeripheralPins.c 23 | variant_CH32V203G6.cpp 24 | ) 25 | target_link_libraries(variant_bin PUBLIC variant_usage) 26 | 27 | target_link_libraries(variant INTERFACE 28 | variant_bin 29 | ) 30 | 31 | -------------------------------------------------------------------------------- /variants/CH32V20x/CH32V203G6/PinNamesVar.h: -------------------------------------------------------------------------------- 1 | /* Alternate pin name */ 2 | PA_0_ALT1 = PA_0 | ALT1, 3 | PA_1_ALT1 = PA_1 | ALT1, 4 | PA_2_ALT1 = PA_2 | ALT1, 5 | PA_3_ALT1 = PA_3 | ALT1, 6 | PA_4_ALT1 = PA_4 | ALT1, 7 | PA_5_ALT1 = PA_5 | ALT1, 8 | PA_6_ALT1 = PA_6 | ALT1, 9 | PA_7_ALT1 = PA_7 | ALT1, 10 | PA_8_ALT1 = PA_8 | ALT1, 11 | PA_9_ALT1 = PA_9 | ALT1, 12 | PA_10_ALT1 = PA_10 | ALT1, 13 | PA_11_ALT1 = PA_11 | ALT1, 14 | PA_15_ALT1 = PA_15 | ALT1, 15 | PB_0_ALT1 = PB_0 | ALT1, 16 | PB_0_ALT2 = PB_0 | ALT2, 17 | PB_1_ALT1 = PB_1 | ALT1, 18 | PB_1_ALT2 = PB_1 | ALT2, 19 | PB_3_ALT1 = PB_3 | ALT1, 20 | PB_10_ALT1 = PB_10 | ALT1, 21 | PB_11_ALT1 = PB_11 | ALT1, 22 | 23 | /* SYS_WKUP */ 24 | #ifdef PWR_WAKEUP_PIN1 25 | SYS_WKUP1 = PA_0, 26 | #endif 27 | #ifdef PWR_WAKEUP_PIN2 28 | SYS_WKUP2 = NC, 29 | #endif 30 | #ifdef PWR_WAKEUP_PIN3 31 | SYS_WKUP3 = NC, 32 | #endif 33 | #ifdef PWR_WAKEUP_PIN4 34 | SYS_WKUP4 = NC, 35 | #endif 36 | #ifdef PWR_WAKEUP_PIN5 37 | SYS_WKUP5 = NC, 38 | #endif 39 | #ifdef PWR_WAKEUP_PIN6 40 | SYS_WKUP6 = NC, 41 | #endif 42 | #ifdef PWR_WAKEUP_PIN7 43 | SYS_WKUP7 = NC, 44 | #endif 45 | #ifdef PWR_WAKEUP_PIN8 46 | SYS_WKUP8 = NC, 47 | #endif 48 | 49 | /* USB */ 50 | #ifdef USBCON 51 | USB_DM = PA_11, 52 | USB_DP = PA_12, 53 | #endif 54 | -------------------------------------------------------------------------------- /variants/CH32V20x/CH32V203G6/boards_entry.txt: -------------------------------------------------------------------------------- 1 | # This file help to add generic board entry. 2 | 3 | 4 | 5 | # CH32V203G6 6 | CH32V20x_EVT.menu.pnum.CH32V203G6=CH32V203G6 EVT 7 | CH32V20x_EVT.menu.pnum.CH32V203G6.upload.maximum_size=32768 8 | CH32V20x_EVT.menu.pnum.CH32V203G6.upload.maximum_data_size=10240 9 | CH32V20x_EVT.menu.pnum.CH32V203G6.build.board=CH32V203G6 10 | CH32V20x_EVT.menu.pnum.CH32V203G6.build.product_line=CH32V203x6 11 | CH32V20x_EVT.menu.pnum.CH32V203G6.build.variant=CH32V20x/CH32V203G6 12 | 13 | -------------------------------------------------------------------------------- /variants/CH32V20x/CH32V203G6/variant_CH32V203G6.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | ******************************************************************************* 3 | * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. 4 | * All rights reserved. 5 | * 6 | * This software component is licensed by WCH under BSD 3-Clause license, 7 | * the "License"; You may not use this file except in compliance with the 8 | * License. You may obtain a copy of the License at: 9 | * opensource.org/licenses/BSD-3-Clause 10 | * 11 | ******************************************************************************* 12 | */ 13 | 14 | #include "pins_arduino.h" 15 | 16 | 17 | 18 | 19 | // Digital PinName array 20 | const PinName digitalPin[] = { 21 | PA_0, // D0/A0 22 | PA_1, // D1/A1 23 | PA_2, // D2/A2 24 | PA_3, // D3/A3 25 | PA_4, // D4/A4 26 | PA_5, // D5/A5 27 | PA_6, // D6/A6 28 | PA_7, // D7/A7 29 | PA_8, // D8 30 | PA_9, // D9 31 | PA_10, // D10 32 | PA_11, // D11 33 | PA_12, // D12 34 | PA_13, // D13 35 | PA_14, // D14 36 | PA_15, // D15 37 | PB_0, // D16/A8 38 | PB_1, // D17/A9 39 | PB_2, // D18 40 | PB_3, // D19 41 | PB_4, // D20 42 | PB_5, // D21 43 | PB_6, // D22 44 | PB_7, // D23 45 | PB_8, // D24 46 | }; 47 | 48 | // Analog (Ax) pin number array 49 | const uint32_t analogInputPin[] = { 50 | 0, // A0, PA0 51 | 1, // A1, PA1 52 | 2, // A2, PA2 53 | 3, // A3, PA3 54 | 4, // A4, PA4 55 | 5, // A5, PA5 56 | 6, // A6, PA6 57 | 7, // A7, PA7 58 | 16, // A8, PB0 59 | 17 // A9, PB1 60 | }; 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /variants/CH32V20x/CH32V203G6_ADAFRUIT_QTPY/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # v3.21 implemented semantic changes regarding $ 2 | # See https://cmake.org/cmake/help/v3.21/command/target_link_libraries.html#linking-object-libraries-via-target-objects 3 | cmake_minimum_required(VERSION 3.21) 4 | 5 | add_library(variant INTERFACE) 6 | add_library(variant_usage INTERFACE) 7 | 8 | target_include_directories(variant_usage INTERFACE 9 | . 10 | ) 11 | 12 | 13 | target_link_libraries(variant_usage INTERFACE 14 | base_config 15 | ) 16 | 17 | target_link_libraries(variant INTERFACE variant_usage) 18 | 19 | 20 | 21 | add_library(variant_bin STATIC EXCLUDE_FROM_ALL 22 | PeripheralPins.c 23 | variant_CH32V203G6_ADAFRUIT_QTPY.cpp 24 | ) 25 | target_link_libraries(variant_bin PUBLIC variant_usage) 26 | 27 | target_link_libraries(variant INTERFACE 28 | variant_bin 29 | ) 30 | 31 | -------------------------------------------------------------------------------- /variants/CH32V20x/CH32V203G6_ADAFRUIT_QTPY/PinNamesVar.h: -------------------------------------------------------------------------------- 1 | /* Alternate pin name */ 2 | PA_0_ALT1 = PA_0 | ALT1, 3 | PA_1_ALT1 = PA_1 | ALT1, 4 | PA_2_ALT1 = PA_2 | ALT1, 5 | PA_3_ALT1 = PA_3 | ALT1, 6 | PA_4_ALT1 = PA_4 | ALT1, 7 | PA_5_ALT1 = PA_5 | ALT1, 8 | PA_6_ALT1 = PA_6 | ALT1, 9 | PA_7_ALT1 = PA_7 | ALT1, 10 | PA_8_ALT1 = PA_8 | ALT1, 11 | PA_9_ALT1 = PA_9 | ALT1, 12 | PA_10_ALT1 = PA_10 | ALT1, 13 | PA_11_ALT1 = PA_11 | ALT1, 14 | PA_15_ALT1 = PA_15 | ALT1, 15 | PB_0_ALT1 = PB_0 | ALT1, 16 | PB_0_ALT2 = PB_0 | ALT2, 17 | PB_1_ALT1 = PB_1 | ALT1, 18 | PB_1_ALT2 = PB_1 | ALT2, 19 | PB_3_ALT1 = PB_3 | ALT1, 20 | PB_10_ALT1 = PB_10 | ALT1, 21 | PB_11_ALT1 = PB_11 | ALT1, 22 | 23 | /* SYS_WKUP */ 24 | #ifdef PWR_WAKEUP_PIN1 25 | SYS_WKUP1 = PA_0, 26 | #endif 27 | #ifdef PWR_WAKEUP_PIN2 28 | SYS_WKUP2 = NC, 29 | #endif 30 | #ifdef PWR_WAKEUP_PIN3 31 | SYS_WKUP3 = NC, 32 | #endif 33 | #ifdef PWR_WAKEUP_PIN4 34 | SYS_WKUP4 = NC, 35 | #endif 36 | #ifdef PWR_WAKEUP_PIN5 37 | SYS_WKUP5 = NC, 38 | #endif 39 | #ifdef PWR_WAKEUP_PIN6 40 | SYS_WKUP6 = NC, 41 | #endif 42 | #ifdef PWR_WAKEUP_PIN7 43 | SYS_WKUP7 = NC, 44 | #endif 45 | #ifdef PWR_WAKEUP_PIN8 46 | SYS_WKUP8 = NC, 47 | #endif 48 | 49 | /* USB */ 50 | #ifdef USBCON 51 | USB_DM = PA_11, 52 | USB_DP = PA_12, 53 | #endif 54 | -------------------------------------------------------------------------------- /variants/CH32V20x/CH32V203G6_ADAFRUIT_QTPY/variant_CH32V203G6_ADAFRUIT_QTPY.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | ******************************************************************************* 3 | * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. 4 | * All rights reserved. 5 | * 6 | * This software component is licensed by WCH under BSD 3-Clause license, 7 | * the "License"; You may not use this file except in compliance with the 8 | * License. You may obtain a copy of the License at: 9 | * opensource.org/licenses/BSD-3-Clause 10 | * 11 | ******************************************************************************* 12 | */ 13 | 14 | #include "pins_arduino.h" 15 | #include "hw_config.h" 16 | 17 | // Digital PinName array 18 | const PinName digitalPin[] = { 19 | PB_1, // D0/A0 20 | PB_0, // D1/A1 21 | PA_1, // D2/A2 22 | PA_0, // D3/A3 23 | PA_2, // D4/TX 24 | PA_3, // D5/RX 25 | PA_4, // D6/Neopixel 26 | PA_5, // D7/SCK 27 | PA_6, // D8/MISO 28 | PA_7, // D9/MOSI 29 | PB_6, // D10/SCL 30 | PB_7, // D11/SDA 31 | PB_8, // D12/BOOT0 Button 32 | }; 33 | 34 | // Analog (Ax) pin number array 35 | const uint32_t analogInputPin[] = { 36 | 0, // A0, PB1 37 | 1, // A1, PB0 38 | 2, // A2, PA1 39 | 3, // A3, PA0 40 | }; 41 | 42 | extern "C" { 43 | 44 | void pre_init(void) { 45 | // Enable Flash enhance read mode for full 224KB 46 | FLASH->KEYR = 0x45670123; // FLASH_Unlock_Fast(); 47 | FLASH->KEYR = 0xCDEF89AB; 48 | 49 | FLASH->CTLR |= (1 << 24); // Enhanced Read Mode 50 | 51 | FLASH->CTLR |= (1 << 15); // FLASH_Lock_Fast(); 52 | 53 | hw_config_init(); 54 | } 55 | 56 | } -------------------------------------------------------------------------------- /variants/CH32V20x/CH32V203G8/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # v3.21 implemented semantic changes regarding $ 2 | # See https://cmake.org/cmake/help/v3.21/command/target_link_libraries.html#linking-object-libraries-via-target-objects 3 | cmake_minimum_required(VERSION 3.21) 4 | 5 | add_library(variant INTERFACE) 6 | add_library(variant_usage INTERFACE) 7 | 8 | target_include_directories(variant_usage INTERFACE 9 | . 10 | ) 11 | 12 | 13 | target_link_libraries(variant_usage INTERFACE 14 | base_config 15 | ) 16 | 17 | target_link_libraries(variant INTERFACE variant_usage) 18 | 19 | 20 | 21 | add_library(variant_bin STATIC EXCLUDE_FROM_ALL 22 | PeripheralPins.c 23 | variant_CH32V203G8.cpp 24 | ) 25 | target_link_libraries(variant_bin PUBLIC variant_usage) 26 | 27 | target_link_libraries(variant INTERFACE 28 | variant_bin 29 | ) 30 | 31 | -------------------------------------------------------------------------------- /variants/CH32V20x/CH32V203G8/PinNamesVar.h: -------------------------------------------------------------------------------- 1 | /* Alternate pin name */ 2 | PA_0_ALT1 = PA_0 | ALT1, 3 | PA_1_ALT1 = PA_1 | ALT1, 4 | PA_2_ALT1 = PA_2 | ALT1, 5 | PA_3_ALT1 = PA_3 | ALT1, 6 | PA_4_ALT1 = PA_4 | ALT1, 7 | PA_5_ALT1 = PA_5 | ALT1, 8 | PA_6_ALT1 = PA_6 | ALT1, 9 | PA_7_ALT1 = PA_7 | ALT1, 10 | PA_8_ALT1 = PA_8 | ALT1, 11 | PA_9_ALT1 = PA_9 | ALT1, 12 | PA_10_ALT1 = PA_10 | ALT1, 13 | PA_11_ALT1 = PA_11 | ALT1, 14 | PA_15_ALT1 = PA_15 | ALT1, 15 | PB_0_ALT1 = PB_0 | ALT1, 16 | PB_0_ALT2 = PB_0 | ALT2, 17 | PB_1_ALT1 = PB_1 | ALT1, 18 | PB_1_ALT2 = PB_1 | ALT2, 19 | PB_3_ALT1 = PB_3 | ALT1, 20 | PB_10_ALT1 = PB_10 | ALT1, 21 | PB_11_ALT1 = PB_11 | ALT1, 22 | 23 | /* SYS_WKUP */ 24 | #ifdef PWR_WAKEUP_PIN1 25 | SYS_WKUP1 = PA_0, 26 | #endif 27 | #ifdef PWR_WAKEUP_PIN2 28 | SYS_WKUP2 = NC, 29 | #endif 30 | #ifdef PWR_WAKEUP_PIN3 31 | SYS_WKUP3 = NC, 32 | #endif 33 | #ifdef PWR_WAKEUP_PIN4 34 | SYS_WKUP4 = NC, 35 | #endif 36 | #ifdef PWR_WAKEUP_PIN5 37 | SYS_WKUP5 = NC, 38 | #endif 39 | #ifdef PWR_WAKEUP_PIN6 40 | SYS_WKUP6 = NC, 41 | #endif 42 | #ifdef PWR_WAKEUP_PIN7 43 | SYS_WKUP7 = NC, 44 | #endif 45 | #ifdef PWR_WAKEUP_PIN8 46 | SYS_WKUP8 = NC, 47 | #endif 48 | 49 | /* USB */ 50 | #ifdef USBCON 51 | USB_DM = PA_11, 52 | USB_DP = PA_12, 53 | #endif 54 | -------------------------------------------------------------------------------- /variants/CH32V20x/CH32V203G8/boards_entry.txt: -------------------------------------------------------------------------------- 1 | # This file help to add generic board entry. 2 | 3 | 4 | 5 | # CH32V203G8 6 | CH32V20x_EVT.menu.pnum.CH32V203G8=CH32V203G8 EVT 7 | CH32V20x_EVT.menu.pnum.CH32V203G8.upload.maximum_size=65536 8 | CH32V20x_EVT.menu.pnum.CH32V203G8.upload.maximum_data_size=20480 9 | CH32V20x_EVT.menu.pnum.CH32V203G8.build.board=CH32V203G8 10 | CH32V20x_EVT.menu.pnum.CH32V203G8.build.product_line=CH32V203x8 11 | CH32V20x_EVT.menu.pnum.CH32V203G8.build.variant=CH32V20x/CH32V203G8 12 | 13 | -------------------------------------------------------------------------------- /variants/CH32V20x/CH32V203G8/variant_CH32V203G8.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | ******************************************************************************* 3 | * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. 4 | * All rights reserved. 5 | * 6 | * This software component is licensed by WCH under BSD 3-Clause license, 7 | * the "License"; You may not use this file except in compliance with the 8 | * License. You may obtain a copy of the License at: 9 | * opensource.org/licenses/BSD-3-Clause 10 | * 11 | ******************************************************************************* 12 | */ 13 | 14 | #include "pins_arduino.h" 15 | 16 | 17 | 18 | 19 | // Digital PinName array 20 | const PinName digitalPin[] = { 21 | PA_0, // D0/A0 22 | PA_1, // D1/A1 23 | PA_2, // D2/A2 24 | PA_3, // D3/A3 25 | PA_4, // D4/A4 26 | PA_5, // D5/A5 27 | PA_6, // D6/A6 28 | PA_7, // D7/A7 29 | PA_8, // D8 30 | PA_9, // D9 31 | PA_10, // D10 32 | PA_11, // D11 33 | PA_12, // D12 34 | PA_13, // D13 35 | PA_14, // D14 36 | PA_15, // D15 37 | PB_0, // D16/A8 38 | PB_1, // D17/A9 39 | PB_2, // D18 40 | PB_3, // D19 41 | PB_4, // D20 42 | PB_5, // D21 43 | PB_6, // D22 44 | PB_7, // D23 45 | PB_8, // D24 46 | PB_9, // D25 47 | PB_10, // D26 48 | PB_11, // D27 49 | PB_12, // D28 50 | PB_13, // D29 51 | PB_14, // D30 52 | PB_15, // D31 53 | PC_13, // D32 54 | PC_14, // D33 55 | PC_15, // D34 56 | PD_0, // D35 57 | PD_1 // D36 58 | }; 59 | 60 | // Analog (Ax) pin number array 61 | const uint32_t analogInputPin[] = { 62 | 0, // A0, PA0 63 | 1, // A1, PA1 64 | 2, // A2, PA2 65 | 3, // A3, PA3 66 | 4, // A4, PA4 67 | 5, // A5, PA5 68 | 6, // A6, PA6 69 | 7, // A7, PA7 70 | 16, // A8, PB0 71 | 17 // A9, PB1 72 | }; 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /variants/CH32V20x/CH32V203RB/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # v3.21 implemented semantic changes regarding $ 2 | # See https://cmake.org/cmake/help/v3.21/command/target_link_libraries.html#linking-object-libraries-via-target-objects 3 | cmake_minimum_required(VERSION 3.21) 4 | 5 | add_library(variant INTERFACE) 6 | add_library(variant_usage INTERFACE) 7 | 8 | target_include_directories(variant_usage INTERFACE 9 | . 10 | ) 11 | 12 | 13 | target_link_libraries(variant_usage INTERFACE 14 | base_config 15 | ) 16 | 17 | target_link_libraries(variant INTERFACE variant_usage) 18 | 19 | 20 | 21 | add_library(variant_bin STATIC EXCLUDE_FROM_ALL 22 | PeripheralPins.c 23 | variant_CH32V203RB.cpp 24 | ) 25 | target_link_libraries(variant_bin PUBLIC variant_usage) 26 | 27 | target_link_libraries(variant INTERFACE 28 | variant_bin 29 | ) 30 | 31 | -------------------------------------------------------------------------------- /variants/CH32V20x/CH32V203RB/PinNamesVar.h: -------------------------------------------------------------------------------- 1 | /* Alternate pin name */ 2 | PA_0_ALT1 = PA_0 | ALT1, 3 | PA_1_ALT1 = PA_1 | ALT1, 4 | PA_2_ALT1 = PA_2 | ALT1, 5 | PA_3_ALT1 = PA_3 | ALT1, 6 | PA_4_ALT1 = PA_4 | ALT1, 7 | PA_5_ALT1 = PA_5 | ALT1, 8 | PA_6_ALT1 = PA_6 | ALT1, 9 | PA_7_ALT1 = PA_7 | ALT1, 10 | PA_8_ALT1 = PA_8 | ALT1, 11 | PA_9_ALT1 = PA_9 | ALT1, 12 | PA_10_ALT1 = PA_10 | ALT1, 13 | PA_11_ALT1 = PA_11 | ALT1, 14 | PA_15_ALT1 = PA_15 | ALT1, 15 | PB_0_ALT1 = PB_0 | ALT1, 16 | PB_0_ALT2 = PB_0 | ALT2, 17 | PB_1_ALT1 = PB_1 | ALT1, 18 | PB_1_ALT2 = PB_1 | ALT2, 19 | PB_3_ALT1 = PB_3 | ALT1, 20 | PB_10_ALT1 = PB_10 | ALT1, 21 | PB_11_ALT1 = PB_11 | ALT1, 22 | 23 | /* SYS_WKUP */ 24 | #ifdef PWR_WAKEUP_PIN1 25 | SYS_WKUP1 = PA_0, 26 | #endif 27 | #ifdef PWR_WAKEUP_PIN2 28 | SYS_WKUP2 = NC, 29 | #endif 30 | #ifdef PWR_WAKEUP_PIN3 31 | SYS_WKUP3 = NC, 32 | #endif 33 | #ifdef PWR_WAKEUP_PIN4 34 | SYS_WKUP4 = NC, 35 | #endif 36 | #ifdef PWR_WAKEUP_PIN5 37 | SYS_WKUP5 = NC, 38 | #endif 39 | #ifdef PWR_WAKEUP_PIN6 40 | SYS_WKUP6 = NC, 41 | #endif 42 | #ifdef PWR_WAKEUP_PIN7 43 | SYS_WKUP7 = NC, 44 | #endif 45 | #ifdef PWR_WAKEUP_PIN8 46 | SYS_WKUP8 = NC, 47 | #endif 48 | 49 | /* USB */ 50 | #ifdef USBCON 51 | USB_DM = PA_11, 52 | USB_DP = PA_12, 53 | #endif 54 | -------------------------------------------------------------------------------- /variants/CH32V20x/CH32V203RB/boards_entry.txt: -------------------------------------------------------------------------------- 1 | # This file help to add generic board entry. 2 | 3 | 4 | 5 | # CH32V203RB 6 | CH32V20x_EVT.menu.pnum.CH32V203RB=CH32V203RB EVT 7 | CH32V20x_EVT.menu.pnum.CH32V203RB.upload.maximum_size=131072 8 | CH32V20x_EVT.menu.pnum.CH32V203RB.upload.maximum_data_size=65536 9 | CH32V20x_EVT.menu.pnum.CH32V203RB.build.board=CH32V203RB 10 | CH32V20x_EVT.menu.pnum.CH32V203RB.build.product_line=CH32V203xB 11 | CH32V20x_EVT.menu.pnum.CH32V203RB.build.variant=CH32V20x/CH32V203RB 12 | 13 | -------------------------------------------------------------------------------- /variants/CH32V20x/CH32V203RB/variant_CH32V203RB.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | ******************************************************************************* 3 | * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. 4 | * All rights reserved. 5 | * 6 | * This software component is licensed by WCH under BSD 3-Clause license, 7 | * the "License"; You may not use this file except in compliance with the 8 | * License. You may obtain a copy of the License at: 9 | * opensource.org/licenses/BSD-3-Clause 10 | * 11 | ******************************************************************************* 12 | */ 13 | 14 | #include "pins_arduino.h" 15 | 16 | 17 | 18 | 19 | // Digital PinName array 20 | const PinName digitalPin[] = { 21 | PA_0, // D0/A0 22 | PA_1, // D1/A1 23 | PA_2, // D2/A2 24 | PA_3, // D3/A3 25 | PA_4, // D4/A4 26 | PA_5, // D5/A5 27 | PA_6, // D6/A6 28 | PA_7, // D7/A7 29 | PA_8, // D8 30 | PA_9, // D9 31 | PA_10, // D10 32 | PA_11, // D11 33 | PA_12, // D12 34 | PA_13, // D13 35 | PA_14, // D14 36 | PA_15, // D15 37 | PB_0, // D16/A8 38 | PB_1, // D17/A9 39 | PB_2, // D18 40 | PB_3, // D19 41 | PB_4, // D20 42 | PB_5, // D21 43 | PB_6, // D22 44 | PB_7, // D23 45 | PB_8, // D24 46 | PB_9, // D25 47 | PB_10, // D26 48 | PB_11, // D27 49 | PB_12, // D28 50 | PB_13, // D29 51 | PB_14, // D30 52 | PB_15, // D31 53 | PC_13, // D32 54 | PC_14, // D33 55 | PC_15, // D34 56 | PD_0, // D35 57 | PD_1 // D36 58 | }; 59 | 60 | // Analog (Ax) pin number array 61 | const uint32_t analogInputPin[] = { 62 | 0, // A0, PA0 63 | 1, // A1, PA1 64 | 2, // A2, PA2 65 | 3, // A3, PA3 66 | 4, // A4, PA4 67 | 5, // A5, PA5 68 | 6, // A6, PA6 69 | 7, // A7, PA7 70 | 16, // A8, PB0 71 | 17 // A9, PB1 72 | }; 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /variants/CH32V30x/CH32V307VCT6/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # v3.21 implemented semantic changes regarding $ 2 | # See https://cmake.org/cmake/help/v3.21/command/target_link_libraries.html#linking-object-libraries-via-target-objects 3 | cmake_minimum_required(VERSION 3.21) 4 | 5 | add_library(variant INTERFACE) 6 | add_library(variant_usage INTERFACE) 7 | 8 | target_include_directories(variant_usage INTERFACE 9 | . 10 | ) 11 | 12 | 13 | target_link_libraries(variant_usage INTERFACE 14 | base_config 15 | ) 16 | 17 | target_link_libraries(variant INTERFACE variant_usage) 18 | 19 | 20 | 21 | add_library(variant_bin STATIC EXCLUDE_FROM_ALL 22 | PeripheralPins.c 23 | variant_CH32V307VCT6.cpp 24 | ) 25 | target_link_libraries(variant_bin PUBLIC variant_usage) 26 | 27 | target_link_libraries(variant INTERFACE 28 | variant_bin 29 | ) 30 | 31 | -------------------------------------------------------------------------------- /variants/CH32V30x/CH32V307VCT6/PinNamesVar.h: -------------------------------------------------------------------------------- 1 | /* Alternate pin name */ 2 | PA_0_ALT1 = PA_0 | ALT1, 3 | PA_1_ALT1 = PA_1 | ALT1, 4 | PA_2_ALT1 = PA_2 | ALT1, 5 | PA_3_ALT1 = PA_3 | ALT1, 6 | PA_4_ALT1 = PA_4 | ALT1, 7 | PA_5_ALT1 = PA_5 | ALT1, 8 | 9 | PA_4_ALT2 = PA_4 | ALT2, 10 | PA_5_ALT2 = PA_5 | ALT2, 11 | 12 | 13 | 14 | /* SYS_WKUP */ 15 | #ifdef PWR_WAKEUP_PIN1 16 | SYS_WKUP1 = PA_0, 17 | #endif 18 | 19 | /* USB */ 20 | #ifdef USBCON 21 | USB_DM = PA_11, 22 | USB_DP = PA_12, 23 | #endif 24 | -------------------------------------------------------------------------------- /variants/CH32V30x/CH32V307VCT6/boards_entry.txt: -------------------------------------------------------------------------------- 1 | # This file help to add generic board entry. 2 | 3 | 4 | 5 | # CH32V307VCT6 6 | CH32V30x_EVT.menu.pnum.CH32V307VCT6=CH32V307VCT6 EVT 7 | CH32V30x_EVT.menu.pnum.CH32V307VCT6.upload.maximum_size=262144 8 | CH32V30x_EVT.menu.pnum.CH32V307VCT6.upload.maximum_data_size=65536 9 | CH32V30x_EVT.menu.pnum.CH32V307VCT6.build.board=CH32V307VCT6 10 | CH32V30x_EVT.menu.pnum.CH32V307VCT6.build.product_line=CH32V307 11 | CH32V30x_EVT.menu.pnum.CH32V307VCT6.build.variant=CH32V30x/CH32V307VCT6 12 | 13 | -------------------------------------------------------------------------------- /variants/CH32V30x/CH32V307VCT6/variant_CH32V307VCT6.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | ******************************************************************************* 3 | * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. 4 | * All rights reserved. 5 | * 6 | * This software component is licensed by WCH under BSD 3-Clause license, 7 | * the "License"; You may not use this file except in compliance with the 8 | * License. You may obtain a copy of the License at: 9 | * opensource.org/licenses/BSD-3-Clause 10 | * 11 | ******************************************************************************* 12 | */ 13 | 14 | #include "pins_arduino.h" 15 | 16 | 17 | 18 | 19 | // Digital PinName array 20 | const PinName digitalPin[] = { 21 | PA_0, //D0/A0 22 | PA_1, //D1/A1 23 | PA_2, //D2/A2 24 | PA_3, //D3/A3 25 | PA_4, //D4/A4 SPI1_NSS 26 | PA_5, //D5/A5 SPI1_SCK 27 | 28 | PA_10, //D6 USART1_RX 29 | PA_9, //D7 USART1_TX 30 | PA_8, //D8 31 | PA_7, //D9 SPI_MOSI TIM8_CH1N TIM3_CH2 32 | PA_6, //D10 SPI1_MISO 33 | PB_5, //D11 TIM3_CH2_2 TIM10_CH3_1 34 | PB_8, //D12 TIM4_CH3 TIM10_CH1 TIM8_CH3_1 35 | PB_9, //D13 36 | PB_1, //D14 TIM3_CH4 TIM8_CH3N TIM1_CH3N_1 TIM3_CH4_2 TIM9_CH2N_1 37 | PB_0, //D15 TIM3_CH3 TIM8_CH2N TIM1_CH2N_1 TIM3_CH3_2 TIM9_CH1N_1 38 | PB_12, //D16 SPI2_NSS 39 | PB_15, //D17 SPI2_MOSI 40 | PB_14, //D18 SPI2_MISO 41 | PB_13, //D19 SPI2_SCK 42 | PB_11, //D20 I2C2_SDA 43 | PB_10 //D21 I2C2_SCL 44 | }; 45 | 46 | // Analog (Ax) pin number array 47 | const uint32_t analogInputPin[] = { 48 | 0, // A0, PA0 49 | 1, // A1, PA1 50 | 2, // A2, PA2 51 | 3, // A3, PA3 52 | 4, // A4, PA4 53 | 5 // A5, PA5 54 | }; 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /variants/CH32VM00X/CH32V006K8/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # v3.21 implemented semantic changes regarding $ 2 | # See https://cmake.org/cmake/help/v3.21/command/target_link_libraries.html#linking-object-libraries-via-target-objects 3 | cmake_minimum_required(VERSION 3.21) 4 | 5 | add_library(variant INTERFACE) 6 | add_library(variant_usage INTERFACE) 7 | 8 | target_include_directories(variant_usage INTERFACE 9 | . 10 | ) 11 | 12 | 13 | target_link_libraries(variant_usage INTERFACE 14 | base_config 15 | ) 16 | 17 | target_link_libraries(variant INTERFACE variant_usage) 18 | 19 | 20 | 21 | add_library(variant_bin STATIC EXCLUDE_FROM_ALL 22 | PeripheralPins.c 23 | variant_CH32V006K8.cpp 24 | ) 25 | target_link_libraries(variant_bin PUBLIC variant_usage) 26 | 27 | target_link_libraries(variant INTERFACE 28 | variant_bin 29 | ) 30 | 31 | -------------------------------------------------------------------------------- /variants/CH32VM00X/CH32V006K8/PinNamesVar.h: -------------------------------------------------------------------------------- 1 | /* SYS_WKUP */ 2 | #ifdef PWR_WAKEUP_PIN1 3 | SYS_WKUP1 = PA_0, 4 | #endif 5 | #ifdef PWR_WAKEUP_PIN2 6 | SYS_WKUP2 = NC, 7 | #endif 8 | #ifdef PWR_WAKEUP_PIN3 9 | SYS_WKUP3 = NC, 10 | #endif 11 | #ifdef PWR_WAKEUP_PIN4 12 | SYS_WKUP4 = NC, 13 | #endif 14 | #ifdef PWR_WAKEUP_PIN5 15 | SYS_WKUP5 = NC, 16 | #endif 17 | #ifdef PWR_WAKEUP_PIN6 18 | SYS_WKUP6 = NC, 19 | #endif 20 | #ifdef PWR_WAKEUP_PIN7 21 | SYS_WKUP7 = NC, 22 | #endif 23 | #ifdef PWR_WAKEUP_PIN8 24 | SYS_WKUP8 = NC, 25 | #endif 26 | 27 | 28 | -------------------------------------------------------------------------------- /variants/CH32VM00X/CH32V006K8/boards_entry.txt: -------------------------------------------------------------------------------- 1 | # This file help to add generic board entry. 2 | 3 | 4 | 5 | # CH32V008K8 6 | CH32VM00X_EVT.menu.pnum.CH32V006K8=CH32VM00X EVT 7 | CH32VM00X_EVT.menu.pnum.CH32V006K8.upload.maximum_size=63488 8 | CH32VM00X_EVT.menu.pnum.CH32V006K8.upload.maximum_data_size=8192 9 | CH32VM00X_EVT.menu.pnum.CH32V006K8.build.board=CH32V006K8 10 | CH32VM00X_EVT.menu.pnum.CH32V006K8.build.product_line=CH32VM00X 11 | CH32VM00X_EVT.menu.pnum.CH32V006K8.build.variant=CH32VM00X/CH32V006K8 12 | 13 | -------------------------------------------------------------------------------- /variants/CH32VM00X/CH32V006K8/variant_CH32V006K8.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | ******************************************************************************* 3 | * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. 4 | * All rights reserved. 5 | * 6 | * This software component is licensed by WCH under BSD 3-Clause license, 7 | * the "License"; You may not use this file except in compliance with the 8 | * License. You may obtain a copy of the License at: 9 | * opensource.org/licenses/BSD-3-Clause 10 | * 11 | ******************************************************************************* 12 | */ 13 | 14 | #include "pins_arduino.h" 15 | 16 | 17 | 18 | 19 | // Digital PinName array,Some GPIOs are bound to the same pin. 20 | const PinName digitalPin[] = { 21 | PA_0, //D0 22 | PA_1, //D1/A1 23 | PA_2, //D2/A0 24 | PA_3, //D3 25 | PA_4, //D4 26 | PA_5, //D5 27 | PA_6, //D6 28 | PA_7, //D7 29 | PB_0, //D8 30 | PB_1, //D9 31 | PB_2, //D10 32 | PB_3, //D11 33 | PB_4, //D12 34 | PB_5, //D13 35 | PB_6, //D14 36 | PC_0, //D15 37 | PC_1, //D16 38 | PC_2, //D17 39 | PC_3, //D18 40 | PC_4, //D19/A2 41 | PC_5, //D20 42 | PC_6, //D21 43 | PC_7, //D22 44 | PD_0, //D23 45 | PD_1, //D24 46 | PD_2, //D25/A3 47 | PD_3, //D26/A4 48 | PD_4, //D27/A7 49 | PD_5, //D28/A5 50 | PD_6, //D29/A6 51 | PD_7 //D30 52 | }; 53 | 54 | // Analog (Ax) pin number array 55 | const uint32_t analogInputPin[] = { 56 | 2, // A0/PA2 57 | 1, // A1/PA1 58 | 19, // A2/PC4 59 | 25, // A3/PD2 60 | 26, // A4/PD3 61 | 28, // A5/PD5 62 | 29, // A6/PD6 63 | 27 // A7/PD4 64 | }; 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /variants/CH32X035/CH32X035G8U/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # v3.21 implemented semantic changes regarding $ 2 | # See https://cmake.org/cmake/help/v3.21/command/target_link_libraries.html#linking-object-libraries-via-target-objects 3 | cmake_minimum_required(VERSION 3.21) 4 | 5 | add_library(variant INTERFACE) 6 | add_library(variant_usage INTERFACE) 7 | 8 | target_include_directories(variant_usage INTERFACE 9 | . 10 | ) 11 | 12 | 13 | target_link_libraries(variant_usage INTERFACE 14 | base_config 15 | ) 16 | 17 | target_link_libraries(variant INTERFACE variant_usage) 18 | 19 | 20 | 21 | add_library(variant_bin STATIC EXCLUDE_FROM_ALL 22 | PeripheralPins.c 23 | variant_CH32X035G8U.cpp 24 | ) 25 | target_link_libraries(variant_bin PUBLIC variant_usage) 26 | 27 | target_link_libraries(variant INTERFACE 28 | variant_bin 29 | ) 30 | 31 | -------------------------------------------------------------------------------- /variants/CH32X035/CH32X035G8U/PinNamesVar.h: -------------------------------------------------------------------------------- 1 | /* Alternate pin name */ 2 | 3 | /* SYS_WKUP */ 4 | #ifdef PWR_WAKEUP_PIN1 5 | SYS_WKUP1 = PA_0, 6 | #endif 7 | /* USB */ 8 | #ifdef USBCON 9 | USB_DM = PC_16, 10 | USB_DP = PC_17, 11 | #endif 12 | -------------------------------------------------------------------------------- /variants/CH32X035/CH32X035G8U/boards_entry.txt: -------------------------------------------------------------------------------- 1 | # This file help to add generic board entry. 2 | 3 | 4 | 5 | # CH32X035G8U 6 | CH32X035_EVT.menu.pnum.CH32X035G8U=CH32X035G8U EVT 7 | CH32X035_EVT.menu.pnum.CH32X035G8U.upload.maximum_size=63488 8 | CH32X035_EVT.menu.pnum.CH32X035G8U.upload.maximum_data_size=20480 9 | CH32X035_EVT.menu.pnum.CH32X035G8U.build.board=CH32X035G8U 10 | CH32X035_EVT.menu.pnum.CH32X035G8U.build.product_line=CH32X035 11 | CH32X035_EVT.menu.pnum.CH32X035G8U.build.variant=CH32X035/CH32X035G8U 12 | 13 | -------------------------------------------------------------------------------- /variants/CH32X035/CH32X035G8U/variant_CH32X035G8U.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | ******************************************************************************* 3 | * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. 4 | * All rights reserved. 5 | * 6 | * This software component is licensed by WCH under BSD 3-Clause license, 7 | * the "License"; You may not use this file except in compliance with the 8 | * License. You may obtain a copy of the License at: 9 | * opensource.org/licenses/BSD-3-Clause 10 | * 11 | ******************************************************************************* 12 | */ 13 | 14 | #include "pins_arduino.h" 15 | 16 | 17 | 18 | 19 | // Digital PinName array 20 | const PinName digitalPin[] = { 21 | PA_0, // D0 22 | PA_1, // D1 23 | PA_2, // D2 24 | PA_3, // D3 25 | PA_4, // D4 26 | PA_5, // D5 27 | PA_6, // D6 28 | PA_7, // D7 29 | PB_0, // D8 30 | PB_1, // D9 31 | PB_3, // D10 32 | PB_4, // D11 33 | PB_6, // D12 34 | PB_7, // D13 35 | PB_8, // D14 36 | PB_9, // D15 37 | PB_10, // D16 38 | PB_11, // D17 39 | PB_12, // D18 40 | PC_0, // D19 41 | PC_3, // D20 42 | PC_14, // D21 43 | PC_15, // D22 44 | PC_16, // D23 45 | PC_17, // D24 46 | PC_18, // D25 47 | PC_19 // D26 48 | }; 49 | 50 | // Analog (Ax) pin number array 51 | const uint32_t analogInputPin[] = { 52 | 0, // A0, PA0 53 | 1, // A1, PA1 54 | 2, // A2, PA2 55 | 3, // A3, PA3 56 | 4, // A4, PA4 57 | 5, // A5, PA5 58 | 6, // A6, PA6 59 | 7, // A7, PA7 60 | 8, // A8, PB0 61 | 9, // A9, PB1 62 | 19, // A10, PC0 63 | 20, // A13 PC3 64 | }; 65 | 66 | 67 | 68 | --------------------------------------------------------------------------------