From 8b3c45cebd90aff2244e102833720b42704b6706 Mon Sep 17 00:00:00 2001 From: true Date: Mon, 29 Jul 2024 03:44:14 -0700 Subject: [PATCH] minor cleanup, add i2c single register read/write functions --- code/firmware/user/src/i2c.h | 26 ------------ code/{firmware => retro_tech_fw}/.cproject | 0 code/{firmware => retro_tech_fw}/.project | 0 .../.settings/language.settings.xml | 0 .../org.eclipse.cdt.codan.core.prefs | 0 .../org.eclipse.cdt.managedbuilder.core.prefs | 0 .../org.eclipse.core.resources.prefs | 2 + code/{firmware => retro_tech_fw}/.template | 0 .../core/core_riscv.c | 0 .../core/core_riscv.h | 0 .../{firmware => retro_tech_fw}/debug/debug.c | 0 .../{firmware => retro_tech_fw}/debug/debug.h | 0 .../ld/ch32v003.ld | 0 .../periph/inc/ch32v00x.h | 0 .../periph/inc/ch32v00x_adc.h | 0 .../periph/inc/ch32v00x_dbgmcu.h | 0 .../periph/inc/ch32v00x_dma.h | 0 .../periph/inc/ch32v00x_exti.h | 0 .../periph/inc/ch32v00x_flash.h | 0 .../periph/inc/ch32v00x_gpio.h | 0 .../periph/inc/ch32v00x_i2c.h | 0 .../periph/inc/ch32v00x_iwdg.h | 0 .../periph/inc/ch32v00x_misc.h | 0 .../periph/inc/ch32v00x_opa.h | 0 .../periph/inc/ch32v00x_pwr.h | 0 .../periph/inc/ch32v00x_rcc.h | 0 .../periph/inc/ch32v00x_spi.h | 0 .../periph/inc/ch32v00x_tim.h | 0 .../periph/inc/ch32v00x_usart.h | 0 .../periph/inc/ch32v00x_wwdg.h | 0 .../periph/src/ch32v00x_adc.c | 0 .../periph/src/ch32v00x_dbgmcu.c | 0 .../periph/src/ch32v00x_dma.c | 0 .../periph/src/ch32v00x_exti.c | 0 .../periph/src/ch32v00x_flash.c | 0 .../periph/src/ch32v00x_gpio.c | 0 .../periph/src/ch32v00x_i2c.c | 0 .../periph/src/ch32v00x_iwdg.c | 0 .../periph/src/ch32v00x_misc.c | 0 .../periph/src/ch32v00x_opa.c | 0 .../periph/src/ch32v00x_pwr.c | 0 .../periph/src/ch32v00x_rcc.c | 0 .../periph/src/ch32v00x_spi.c | 0 .../periph/src/ch32v00x_tim.c | 0 .../periph/src/ch32v00x_usart.c | 0 .../periph/src/ch32v00x_wwdg.c | 0 .../retro_tech_fw.wvproj | Bin .../startup/startup_ch32v00x.S | 0 .../user/ch32v00x_conf.h | 0 .../user/ch32v00x_it.c | 4 +- .../user/ch32v00x_it.h | 3 +- code/{firmware => retro_tech_fw}/user/main.c | 2 +- .../user/src/31fl3729.c | 0 .../user/src/31fl3729.h | 0 .../user/src/adc.c | 0 .../user/src/adc.h | 0 .../user/src/btn.c | 0 .../user/src/btn.h | 0 .../user/src/config.c | 0 .../user/src/config.h | 0 .../user/src/eeprom.c | 0 .../user/src/eeprom.h | 0 .../user/src/hsv2rgb.c | 0 .../user/src/hsv2rgb.h | 0 .../user/src/i2c.c | 39 ++++++++++++------ code/retro_tech_fw/user/src/i2c.h | 26 ++++++++++++ .../user/src/led.c | 2 +- .../user/src/led.h | 0 .../user/src/led_rgbprog.c | 0 .../user/src/led_rgbprog.h | 0 .../user/src/rand.c | 0 .../user/src/rand.h | 0 .../{firmware => retro_tech_fw}/user/src/ui.c | 0 .../{firmware => retro_tech_fw}/user/src/ui.h | 0 .../user/system_ch32v00x.c | 0 .../user/system_ch32v00x.h | 0 76 files changed, 58 insertions(+), 46 deletions(-) delete mode 100644 code/firmware/user/src/i2c.h rename code/{firmware => retro_tech_fw}/.cproject (100%) rename code/{firmware => retro_tech_fw}/.project (100%) rename code/{firmware => retro_tech_fw}/.settings/language.settings.xml (100%) rename code/{firmware => retro_tech_fw}/.settings/org.eclipse.cdt.codan.core.prefs (100%) rename code/{firmware => retro_tech_fw}/.settings/org.eclipse.cdt.managedbuilder.core.prefs (100%) rename code/{firmware => retro_tech_fw}/.settings/org.eclipse.core.resources.prefs (95%) rename code/{firmware => retro_tech_fw}/.template (100%) rename code/{firmware => retro_tech_fw}/core/core_riscv.c (100%) rename code/{firmware => retro_tech_fw}/core/core_riscv.h (100%) rename code/{firmware => retro_tech_fw}/debug/debug.c (100%) rename code/{firmware => retro_tech_fw}/debug/debug.h (100%) rename code/{firmware => retro_tech_fw}/ld/ch32v003.ld (100%) rename code/{firmware => retro_tech_fw}/periph/inc/ch32v00x.h (100%) rename code/{firmware => retro_tech_fw}/periph/inc/ch32v00x_adc.h (100%) rename code/{firmware => retro_tech_fw}/periph/inc/ch32v00x_dbgmcu.h (100%) rename code/{firmware => retro_tech_fw}/periph/inc/ch32v00x_dma.h (100%) rename code/{firmware => retro_tech_fw}/periph/inc/ch32v00x_exti.h (100%) rename code/{firmware => retro_tech_fw}/periph/inc/ch32v00x_flash.h (100%) rename code/{firmware => retro_tech_fw}/periph/inc/ch32v00x_gpio.h (100%) rename code/{firmware => retro_tech_fw}/periph/inc/ch32v00x_i2c.h (100%) rename code/{firmware => retro_tech_fw}/periph/inc/ch32v00x_iwdg.h (100%) rename code/{firmware => retro_tech_fw}/periph/inc/ch32v00x_misc.h (100%) rename code/{firmware => retro_tech_fw}/periph/inc/ch32v00x_opa.h (100%) rename code/{firmware => retro_tech_fw}/periph/inc/ch32v00x_pwr.h (100%) rename code/{firmware => retro_tech_fw}/periph/inc/ch32v00x_rcc.h (100%) rename code/{firmware => retro_tech_fw}/periph/inc/ch32v00x_spi.h (100%) rename code/{firmware => retro_tech_fw}/periph/inc/ch32v00x_tim.h (100%) rename code/{firmware => retro_tech_fw}/periph/inc/ch32v00x_usart.h (100%) rename code/{firmware => retro_tech_fw}/periph/inc/ch32v00x_wwdg.h (100%) rename code/{firmware => retro_tech_fw}/periph/src/ch32v00x_adc.c (100%) rename code/{firmware => retro_tech_fw}/periph/src/ch32v00x_dbgmcu.c (100%) rename code/{firmware => retro_tech_fw}/periph/src/ch32v00x_dma.c (100%) rename code/{firmware => retro_tech_fw}/periph/src/ch32v00x_exti.c (100%) rename code/{firmware => retro_tech_fw}/periph/src/ch32v00x_flash.c (100%) rename code/{firmware => retro_tech_fw}/periph/src/ch32v00x_gpio.c (100%) rename code/{firmware => retro_tech_fw}/periph/src/ch32v00x_i2c.c (100%) rename code/{firmware => retro_tech_fw}/periph/src/ch32v00x_iwdg.c (100%) rename code/{firmware => retro_tech_fw}/periph/src/ch32v00x_misc.c (100%) rename code/{firmware => retro_tech_fw}/periph/src/ch32v00x_opa.c (100%) rename code/{firmware => retro_tech_fw}/periph/src/ch32v00x_pwr.c (100%) rename code/{firmware => retro_tech_fw}/periph/src/ch32v00x_rcc.c (100%) rename code/{firmware => retro_tech_fw}/periph/src/ch32v00x_spi.c (100%) rename code/{firmware => retro_tech_fw}/periph/src/ch32v00x_tim.c (100%) rename code/{firmware => retro_tech_fw}/periph/src/ch32v00x_usart.c (100%) rename code/{firmware => retro_tech_fw}/periph/src/ch32v00x_wwdg.c (100%) rename code/{firmware => retro_tech_fw}/retro_tech_fw.wvproj (100%) rename code/{firmware => retro_tech_fw}/startup/startup_ch32v00x.S (100%) rename code/{firmware => retro_tech_fw}/user/ch32v00x_conf.h (100%) rename code/{firmware => retro_tech_fw}/user/ch32v00x_it.c (98%) rename code/{firmware => retro_tech_fw}/user/ch32v00x_it.h (99%) rename code/{firmware => retro_tech_fw}/user/main.c (97%) rename code/{firmware => retro_tech_fw}/user/src/31fl3729.c (100%) rename code/{firmware => retro_tech_fw}/user/src/31fl3729.h (100%) rename code/{firmware => retro_tech_fw}/user/src/adc.c (100%) rename code/{firmware => retro_tech_fw}/user/src/adc.h (100%) rename code/{firmware => retro_tech_fw}/user/src/btn.c (100%) rename code/{firmware => retro_tech_fw}/user/src/btn.h (100%) rename code/{firmware => retro_tech_fw}/user/src/config.c (100%) rename code/{firmware => retro_tech_fw}/user/src/config.h (100%) rename code/{firmware => retro_tech_fw}/user/src/eeprom.c (100%) rename code/{firmware => retro_tech_fw}/user/src/eeprom.h (100%) rename code/{firmware => retro_tech_fw}/user/src/hsv2rgb.c (100%) rename code/{firmware => retro_tech_fw}/user/src/hsv2rgb.h (100%) rename code/{firmware => retro_tech_fw}/user/src/i2c.c (79%) create mode 100644 code/retro_tech_fw/user/src/i2c.h rename code/{firmware => retro_tech_fw}/user/src/led.c (100%) rename code/{firmware => retro_tech_fw}/user/src/led.h (100%) rename code/{firmware => retro_tech_fw}/user/src/led_rgbprog.c (100%) rename code/{firmware => retro_tech_fw}/user/src/led_rgbprog.h (100%) rename code/{firmware => retro_tech_fw}/user/src/rand.c (100%) rename code/{firmware => retro_tech_fw}/user/src/rand.h (100%) rename code/{firmware => retro_tech_fw}/user/src/ui.c (100%) rename code/{firmware => retro_tech_fw}/user/src/ui.h (100%) rename code/{firmware => retro_tech_fw}/user/system_ch32v00x.c (100%) rename code/{firmware => retro_tech_fw}/user/system_ch32v00x.h (100%) diff --git a/code/firmware/user/src/i2c.h b/code/firmware/user/src/i2c.h deleted file mode 100644 index c4a532f..0000000 --- a/code/firmware/user/src/i2c.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * i2c.h - * - * Created on: Jul 27, 2024 - * Author: true - */ - -#ifndef USER_SRC_I2C_H_ -#define USER_SRC_I2C_H_ - - - -#include - - - -void i2c_init(); - -void i2c_read_addr1b(uint8_t devaddr, uint8_t addr, uint8_t *data, uint8_t len); -void i2c_write_addr1b(uint8_t devaddr, uint8_t addr, uint8_t *data, uint8_t len); - -int8_t i2c_ack_poll(uint8_t devaddr); - - - -#endif /* USER_SRC_I2C_H_ */ diff --git a/code/firmware/.cproject b/code/retro_tech_fw/.cproject similarity index 100% rename from code/firmware/.cproject rename to code/retro_tech_fw/.cproject diff --git a/code/firmware/.project b/code/retro_tech_fw/.project similarity index 100% rename from code/firmware/.project rename to code/retro_tech_fw/.project diff --git a/code/firmware/.settings/language.settings.xml b/code/retro_tech_fw/.settings/language.settings.xml similarity index 100% rename from code/firmware/.settings/language.settings.xml rename to code/retro_tech_fw/.settings/language.settings.xml diff --git a/code/firmware/.settings/org.eclipse.cdt.codan.core.prefs b/code/retro_tech_fw/.settings/org.eclipse.cdt.codan.core.prefs similarity index 100% rename from code/firmware/.settings/org.eclipse.cdt.codan.core.prefs rename to code/retro_tech_fw/.settings/org.eclipse.cdt.codan.core.prefs diff --git a/code/firmware/.settings/org.eclipse.cdt.managedbuilder.core.prefs b/code/retro_tech_fw/.settings/org.eclipse.cdt.managedbuilder.core.prefs similarity index 100% rename from code/firmware/.settings/org.eclipse.cdt.managedbuilder.core.prefs rename to code/retro_tech_fw/.settings/org.eclipse.cdt.managedbuilder.core.prefs diff --git a/code/firmware/.settings/org.eclipse.core.resources.prefs b/code/retro_tech_fw/.settings/org.eclipse.core.resources.prefs similarity index 95% rename from code/firmware/.settings/org.eclipse.core.resources.prefs rename to code/retro_tech_fw/.settings/org.eclipse.core.resources.prefs index b42db85..a663b22 100644 --- a/code/firmware/.settings/org.eclipse.core.resources.prefs +++ b/code/retro_tech_fw/.settings/org.eclipse.core.resources.prefs @@ -8,6 +8,7 @@ encoding//periph/inc/ch32v00x_pwr.h=GBK encoding//periph/inc/ch32v00x_rcc.h=GBK encoding//periph/src/ch32v00x_adc.c=GBK encoding//periph/src/ch32v00x_dbgmcu.c=GBK +encoding//periph/src/ch32v00x_flash.c=GBK encoding//periph/src/ch32v00x_gpio.c=GBK encoding//periph/src/ch32v00x_i2c.c=GBK encoding//periph/src/ch32v00x_misc.c=GBK @@ -42,3 +43,4 @@ encoding//user/src/ui.h=GBK encoding//user/system_ch32v00x.c=GBK encoding//user/system_ch32v00x.h=UTF-8 encoding/CH32V003F4P6.launch=GBK +encoding/retro_tech_fw.launch=GBK diff --git a/code/firmware/.template b/code/retro_tech_fw/.template similarity index 100% rename from code/firmware/.template rename to code/retro_tech_fw/.template diff --git a/code/firmware/core/core_riscv.c b/code/retro_tech_fw/core/core_riscv.c similarity index 100% rename from code/firmware/core/core_riscv.c rename to code/retro_tech_fw/core/core_riscv.c diff --git a/code/firmware/core/core_riscv.h b/code/retro_tech_fw/core/core_riscv.h similarity index 100% rename from code/firmware/core/core_riscv.h rename to code/retro_tech_fw/core/core_riscv.h diff --git a/code/firmware/debug/debug.c b/code/retro_tech_fw/debug/debug.c similarity index 100% rename from code/firmware/debug/debug.c rename to code/retro_tech_fw/debug/debug.c diff --git a/code/firmware/debug/debug.h b/code/retro_tech_fw/debug/debug.h similarity index 100% rename from code/firmware/debug/debug.h rename to code/retro_tech_fw/debug/debug.h diff --git a/code/firmware/ld/ch32v003.ld b/code/retro_tech_fw/ld/ch32v003.ld similarity index 100% rename from code/firmware/ld/ch32v003.ld rename to code/retro_tech_fw/ld/ch32v003.ld diff --git a/code/firmware/periph/inc/ch32v00x.h b/code/retro_tech_fw/periph/inc/ch32v00x.h similarity index 100% rename from code/firmware/periph/inc/ch32v00x.h rename to code/retro_tech_fw/periph/inc/ch32v00x.h diff --git a/code/firmware/periph/inc/ch32v00x_adc.h b/code/retro_tech_fw/periph/inc/ch32v00x_adc.h similarity index 100% rename from code/firmware/periph/inc/ch32v00x_adc.h rename to code/retro_tech_fw/periph/inc/ch32v00x_adc.h diff --git a/code/firmware/periph/inc/ch32v00x_dbgmcu.h b/code/retro_tech_fw/periph/inc/ch32v00x_dbgmcu.h similarity index 100% rename from code/firmware/periph/inc/ch32v00x_dbgmcu.h rename to code/retro_tech_fw/periph/inc/ch32v00x_dbgmcu.h diff --git a/code/firmware/periph/inc/ch32v00x_dma.h b/code/retro_tech_fw/periph/inc/ch32v00x_dma.h similarity index 100% rename from code/firmware/periph/inc/ch32v00x_dma.h rename to code/retro_tech_fw/periph/inc/ch32v00x_dma.h diff --git a/code/firmware/periph/inc/ch32v00x_exti.h b/code/retro_tech_fw/periph/inc/ch32v00x_exti.h similarity index 100% rename from code/firmware/periph/inc/ch32v00x_exti.h rename to code/retro_tech_fw/periph/inc/ch32v00x_exti.h diff --git a/code/firmware/periph/inc/ch32v00x_flash.h b/code/retro_tech_fw/periph/inc/ch32v00x_flash.h similarity index 100% rename from code/firmware/periph/inc/ch32v00x_flash.h rename to code/retro_tech_fw/periph/inc/ch32v00x_flash.h diff --git a/code/firmware/periph/inc/ch32v00x_gpio.h b/code/retro_tech_fw/periph/inc/ch32v00x_gpio.h similarity index 100% rename from code/firmware/periph/inc/ch32v00x_gpio.h rename to code/retro_tech_fw/periph/inc/ch32v00x_gpio.h diff --git a/code/firmware/periph/inc/ch32v00x_i2c.h b/code/retro_tech_fw/periph/inc/ch32v00x_i2c.h similarity index 100% rename from code/firmware/periph/inc/ch32v00x_i2c.h rename to code/retro_tech_fw/periph/inc/ch32v00x_i2c.h diff --git a/code/firmware/periph/inc/ch32v00x_iwdg.h b/code/retro_tech_fw/periph/inc/ch32v00x_iwdg.h similarity index 100% rename from code/firmware/periph/inc/ch32v00x_iwdg.h rename to code/retro_tech_fw/periph/inc/ch32v00x_iwdg.h diff --git a/code/firmware/periph/inc/ch32v00x_misc.h b/code/retro_tech_fw/periph/inc/ch32v00x_misc.h similarity index 100% rename from code/firmware/periph/inc/ch32v00x_misc.h rename to code/retro_tech_fw/periph/inc/ch32v00x_misc.h diff --git a/code/firmware/periph/inc/ch32v00x_opa.h b/code/retro_tech_fw/periph/inc/ch32v00x_opa.h similarity index 100% rename from code/firmware/periph/inc/ch32v00x_opa.h rename to code/retro_tech_fw/periph/inc/ch32v00x_opa.h diff --git a/code/firmware/periph/inc/ch32v00x_pwr.h b/code/retro_tech_fw/periph/inc/ch32v00x_pwr.h similarity index 100% rename from code/firmware/periph/inc/ch32v00x_pwr.h rename to code/retro_tech_fw/periph/inc/ch32v00x_pwr.h diff --git a/code/firmware/periph/inc/ch32v00x_rcc.h b/code/retro_tech_fw/periph/inc/ch32v00x_rcc.h similarity index 100% rename from code/firmware/periph/inc/ch32v00x_rcc.h rename to code/retro_tech_fw/periph/inc/ch32v00x_rcc.h diff --git a/code/firmware/periph/inc/ch32v00x_spi.h b/code/retro_tech_fw/periph/inc/ch32v00x_spi.h similarity index 100% rename from code/firmware/periph/inc/ch32v00x_spi.h rename to code/retro_tech_fw/periph/inc/ch32v00x_spi.h diff --git a/code/firmware/periph/inc/ch32v00x_tim.h b/code/retro_tech_fw/periph/inc/ch32v00x_tim.h similarity index 100% rename from code/firmware/periph/inc/ch32v00x_tim.h rename to code/retro_tech_fw/periph/inc/ch32v00x_tim.h diff --git a/code/firmware/periph/inc/ch32v00x_usart.h b/code/retro_tech_fw/periph/inc/ch32v00x_usart.h similarity index 100% rename from code/firmware/periph/inc/ch32v00x_usart.h rename to code/retro_tech_fw/periph/inc/ch32v00x_usart.h diff --git a/code/firmware/periph/inc/ch32v00x_wwdg.h b/code/retro_tech_fw/periph/inc/ch32v00x_wwdg.h similarity index 100% rename from code/firmware/periph/inc/ch32v00x_wwdg.h rename to code/retro_tech_fw/periph/inc/ch32v00x_wwdg.h diff --git a/code/firmware/periph/src/ch32v00x_adc.c b/code/retro_tech_fw/periph/src/ch32v00x_adc.c similarity index 100% rename from code/firmware/periph/src/ch32v00x_adc.c rename to code/retro_tech_fw/periph/src/ch32v00x_adc.c diff --git a/code/firmware/periph/src/ch32v00x_dbgmcu.c b/code/retro_tech_fw/periph/src/ch32v00x_dbgmcu.c similarity index 100% rename from code/firmware/periph/src/ch32v00x_dbgmcu.c rename to code/retro_tech_fw/periph/src/ch32v00x_dbgmcu.c diff --git a/code/firmware/periph/src/ch32v00x_dma.c b/code/retro_tech_fw/periph/src/ch32v00x_dma.c similarity index 100% rename from code/firmware/periph/src/ch32v00x_dma.c rename to code/retro_tech_fw/periph/src/ch32v00x_dma.c diff --git a/code/firmware/periph/src/ch32v00x_exti.c b/code/retro_tech_fw/periph/src/ch32v00x_exti.c similarity index 100% rename from code/firmware/periph/src/ch32v00x_exti.c rename to code/retro_tech_fw/periph/src/ch32v00x_exti.c diff --git a/code/firmware/periph/src/ch32v00x_flash.c b/code/retro_tech_fw/periph/src/ch32v00x_flash.c similarity index 100% rename from code/firmware/periph/src/ch32v00x_flash.c rename to code/retro_tech_fw/periph/src/ch32v00x_flash.c diff --git a/code/firmware/periph/src/ch32v00x_gpio.c b/code/retro_tech_fw/periph/src/ch32v00x_gpio.c similarity index 100% rename from code/firmware/periph/src/ch32v00x_gpio.c rename to code/retro_tech_fw/periph/src/ch32v00x_gpio.c diff --git a/code/firmware/periph/src/ch32v00x_i2c.c b/code/retro_tech_fw/periph/src/ch32v00x_i2c.c similarity index 100% rename from code/firmware/periph/src/ch32v00x_i2c.c rename to code/retro_tech_fw/periph/src/ch32v00x_i2c.c diff --git a/code/firmware/periph/src/ch32v00x_iwdg.c b/code/retro_tech_fw/periph/src/ch32v00x_iwdg.c similarity index 100% rename from code/firmware/periph/src/ch32v00x_iwdg.c rename to code/retro_tech_fw/periph/src/ch32v00x_iwdg.c diff --git a/code/firmware/periph/src/ch32v00x_misc.c b/code/retro_tech_fw/periph/src/ch32v00x_misc.c similarity index 100% rename from code/firmware/periph/src/ch32v00x_misc.c rename to code/retro_tech_fw/periph/src/ch32v00x_misc.c diff --git a/code/firmware/periph/src/ch32v00x_opa.c b/code/retro_tech_fw/periph/src/ch32v00x_opa.c similarity index 100% rename from code/firmware/periph/src/ch32v00x_opa.c rename to code/retro_tech_fw/periph/src/ch32v00x_opa.c diff --git a/code/firmware/periph/src/ch32v00x_pwr.c b/code/retro_tech_fw/periph/src/ch32v00x_pwr.c similarity index 100% rename from code/firmware/periph/src/ch32v00x_pwr.c rename to code/retro_tech_fw/periph/src/ch32v00x_pwr.c diff --git a/code/firmware/periph/src/ch32v00x_rcc.c b/code/retro_tech_fw/periph/src/ch32v00x_rcc.c similarity index 100% rename from code/firmware/periph/src/ch32v00x_rcc.c rename to code/retro_tech_fw/periph/src/ch32v00x_rcc.c diff --git a/code/firmware/periph/src/ch32v00x_spi.c b/code/retro_tech_fw/periph/src/ch32v00x_spi.c similarity index 100% rename from code/firmware/periph/src/ch32v00x_spi.c rename to code/retro_tech_fw/periph/src/ch32v00x_spi.c diff --git a/code/firmware/periph/src/ch32v00x_tim.c b/code/retro_tech_fw/periph/src/ch32v00x_tim.c similarity index 100% rename from code/firmware/periph/src/ch32v00x_tim.c rename to code/retro_tech_fw/periph/src/ch32v00x_tim.c diff --git a/code/firmware/periph/src/ch32v00x_usart.c b/code/retro_tech_fw/periph/src/ch32v00x_usart.c similarity index 100% rename from code/firmware/periph/src/ch32v00x_usart.c rename to code/retro_tech_fw/periph/src/ch32v00x_usart.c diff --git a/code/firmware/periph/src/ch32v00x_wwdg.c b/code/retro_tech_fw/periph/src/ch32v00x_wwdg.c similarity index 100% rename from code/firmware/periph/src/ch32v00x_wwdg.c rename to code/retro_tech_fw/periph/src/ch32v00x_wwdg.c diff --git a/code/firmware/retro_tech_fw.wvproj b/code/retro_tech_fw/retro_tech_fw.wvproj similarity index 100% rename from code/firmware/retro_tech_fw.wvproj rename to code/retro_tech_fw/retro_tech_fw.wvproj diff --git a/code/firmware/startup/startup_ch32v00x.S b/code/retro_tech_fw/startup/startup_ch32v00x.S similarity index 100% rename from code/firmware/startup/startup_ch32v00x.S rename to code/retro_tech_fw/startup/startup_ch32v00x.S diff --git a/code/firmware/user/ch32v00x_conf.h b/code/retro_tech_fw/user/ch32v00x_conf.h similarity index 100% rename from code/firmware/user/ch32v00x_conf.h rename to code/retro_tech_fw/user/ch32v00x_conf.h diff --git a/code/firmware/user/ch32v00x_it.c b/code/retro_tech_fw/user/ch32v00x_it.c similarity index 98% rename from code/firmware/user/ch32v00x_it.c rename to code/retro_tech_fw/user/ch32v00x_it.c index 54235be..00614d5 100644 --- a/code/firmware/user/ch32v00x_it.c +++ b/code/retro_tech_fw/user/ch32v00x_it.c @@ -51,7 +51,7 @@ void HardFault_Handler(void) volatile uint16_t ticnt; volatile uint32_t uptime; -void SysTick_Handler() +void SysTick_Handler(void) { if (++ticnt > 0x7ff) { ticnt = 0; @@ -81,5 +81,3 @@ void SysTick_Handler() return; } - - diff --git a/code/firmware/user/ch32v00x_it.h b/code/retro_tech_fw/user/ch32v00x_it.h similarity index 99% rename from code/firmware/user/ch32v00x_it.h rename to code/retro_tech_fw/user/ch32v00x_it.h index b50edb5..c9026ab 100644 --- a/code/firmware/user/ch32v00x_it.h +++ b/code/retro_tech_fw/user/ch32v00x_it.h @@ -22,6 +22,5 @@ extern volatile uint16_t ticnt; extern volatile uint32_t uptime; + #endif /* __CH32V00x_IT_H */ - - diff --git a/code/firmware/user/main.c b/code/retro_tech_fw/user/main.c similarity index 97% rename from code/firmware/user/main.c rename to code/retro_tech_fw/user/main.c index c91788a..7a2175a 100644 --- a/code/firmware/user/main.c +++ b/code/retro_tech_fw/user/main.c @@ -30,7 +30,7 @@ void systick_init(void) { - SysTick->CMP = (SystemCoreClock / 2000) - 1; // we want a 2KHz interrupt + SysTick->CMP = (SystemCoreClock / 2048) - 1; // we want a 2048Hz interrupt SysTick->CNT = 0; // clear counter SysTick->CTLR = 0xF; // start counter in /1 mode, enable interrupts, auto-reset counter SysTick->SR = 0; // clear count comparison flag diff --git a/code/firmware/user/src/31fl3729.c b/code/retro_tech_fw/user/src/31fl3729.c similarity index 100% rename from code/firmware/user/src/31fl3729.c rename to code/retro_tech_fw/user/src/31fl3729.c diff --git a/code/firmware/user/src/31fl3729.h b/code/retro_tech_fw/user/src/31fl3729.h similarity index 100% rename from code/firmware/user/src/31fl3729.h rename to code/retro_tech_fw/user/src/31fl3729.h diff --git a/code/firmware/user/src/adc.c b/code/retro_tech_fw/user/src/adc.c similarity index 100% rename from code/firmware/user/src/adc.c rename to code/retro_tech_fw/user/src/adc.c diff --git a/code/firmware/user/src/adc.h b/code/retro_tech_fw/user/src/adc.h similarity index 100% rename from code/firmware/user/src/adc.h rename to code/retro_tech_fw/user/src/adc.h diff --git a/code/firmware/user/src/btn.c b/code/retro_tech_fw/user/src/btn.c similarity index 100% rename from code/firmware/user/src/btn.c rename to code/retro_tech_fw/user/src/btn.c diff --git a/code/firmware/user/src/btn.h b/code/retro_tech_fw/user/src/btn.h similarity index 100% rename from code/firmware/user/src/btn.h rename to code/retro_tech_fw/user/src/btn.h diff --git a/code/firmware/user/src/config.c b/code/retro_tech_fw/user/src/config.c similarity index 100% rename from code/firmware/user/src/config.c rename to code/retro_tech_fw/user/src/config.c diff --git a/code/firmware/user/src/config.h b/code/retro_tech_fw/user/src/config.h similarity index 100% rename from code/firmware/user/src/config.h rename to code/retro_tech_fw/user/src/config.h diff --git a/code/firmware/user/src/eeprom.c b/code/retro_tech_fw/user/src/eeprom.c similarity index 100% rename from code/firmware/user/src/eeprom.c rename to code/retro_tech_fw/user/src/eeprom.c diff --git a/code/firmware/user/src/eeprom.h b/code/retro_tech_fw/user/src/eeprom.h similarity index 100% rename from code/firmware/user/src/eeprom.h rename to code/retro_tech_fw/user/src/eeprom.h diff --git a/code/firmware/user/src/hsv2rgb.c b/code/retro_tech_fw/user/src/hsv2rgb.c similarity index 100% rename from code/firmware/user/src/hsv2rgb.c rename to code/retro_tech_fw/user/src/hsv2rgb.c diff --git a/code/firmware/user/src/hsv2rgb.h b/code/retro_tech_fw/user/src/hsv2rgb.h similarity index 100% rename from code/firmware/user/src/hsv2rgb.h rename to code/retro_tech_fw/user/src/hsv2rgb.h diff --git a/code/firmware/user/src/i2c.c b/code/retro_tech_fw/user/src/i2c.c similarity index 79% rename from code/firmware/user/src/i2c.c rename to code/retro_tech_fw/user/src/i2c.c index 767c46f..cae1c1e 100644 --- a/code/firmware/user/src/i2c.c +++ b/code/retro_tech_fw/user/src/i2c.c @@ -4,11 +4,11 @@ * routines more or less copied from WCH example code, then fucked around with to work. * * these routines have serious issues. - * - any i2c issue will lock up the machine, and there's no timeout handlers + * - any i2c issue may lock up the machine. + * - timeout handlers are hastily added and may have problems. * - there's no error handling of any kind * - the library code makes some serious assumptions re: flags - * - * this MUST be fixed before con. + * - it's a shitpile of polling */ #include @@ -43,9 +43,9 @@ void i2c_init() } /* - * reads data from devices which use a single-byte address + * reads data from devices which use a single-byte address register */ -int8_t i2c_read_addr1b(uint8_t devaddr, uint8_t addr, uint8_t *data, uint8_t len) +int8_t i2c_read_addr1b(uint8_t addr, uint8_t reg, uint8_t *data, uint8_t len) { timeout = I2C_TIMEOUT; while((I2C_GetFlagStatus(I2C1, I2C_FLAG_BUSY) != RESET) && timeout--); @@ -56,12 +56,12 @@ int8_t i2c_read_addr1b(uint8_t devaddr, uint8_t addr, uint8_t *data, uint8_t len while(!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_MODE_SELECT) && timeout--); if (!timeout) return -2; - I2C_Send7bitAddress(I2C1, devaddr, I2C_Direction_Transmitter); + I2C_Send7bitAddress(I2C1, addr, I2C_Direction_Transmitter); timeout = I2C_TIMEOUT; while(!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED) && timeout--); if (!timeout) return -3; - I2C_SendData(I2C1, addr); + I2C_SendData(I2C1, reg); timeout = I2C_TIMEOUT; while(!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_BYTE_TRANSMITTED) && timeout--); if (!timeout) return -4; @@ -71,7 +71,7 @@ int8_t i2c_read_addr1b(uint8_t devaddr, uint8_t addr, uint8_t *data, uint8_t len while(!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_MODE_SELECT) && timeout--); if (!timeout) return -5; - I2C_Send7bitAddress(I2C1, devaddr, I2C_Direction_Receiver); + I2C_Send7bitAddress(I2C1, addr, I2C_Direction_Receiver); timeout = I2C_TIMEOUT; while(!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_RECEIVER_MODE_SELECTED) && timeout--); if (!timeout) return -6; @@ -92,7 +92,15 @@ int8_t i2c_read_addr1b(uint8_t devaddr, uint8_t addr, uint8_t *data, uint8_t len return 0; } -int8_t i2c_write_addr1b(uint8_t devaddr, uint8_t addr, uint8_t *data, uint8_t len) +uint8_t i2c_read_reg_8b(uint8_t addr, uint8_t reg) +{ + uint8_t dat; + + i2c_read_addr1b(addr, reg, &dat, 1); + return dat; +} + +int8_t i2c_write_addr1b(uint8_t addr, uint8_t reg, uint8_t *data, uint8_t len) { timeout = I2C_TIMEOUT; while((I2C_GetFlagStatus(I2C1, I2C_FLAG_BUSY) != RESET) && timeout--); @@ -103,12 +111,12 @@ int8_t i2c_write_addr1b(uint8_t devaddr, uint8_t addr, uint8_t *data, uint8_t le while(!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_MODE_SELECT) && timeout--); if (!timeout) return -2; - I2C_Send7bitAddress(I2C1, devaddr, I2C_Direction_Transmitter); + I2C_Send7bitAddress(I2C1, addr, I2C_Direction_Transmitter); timeout = I2C_TIMEOUT; while(!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED) && timeout--); if (!timeout) return -3; - I2C_SendData(I2C1, addr); + I2C_SendData(I2C1, reg); timeout = I2C_TIMEOUT; while(!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_BYTE_TRANSMITTED) && timeout--); if (!timeout) return -4; @@ -126,7 +134,12 @@ int8_t i2c_write_addr1b(uint8_t devaddr, uint8_t addr, uint8_t *data, uint8_t le return 0; } -int8_t i2c_ack_poll(uint8_t devaddr) +void i2c_write_reg_8b(uint8_t addr, uint8_t reg, uint8_t dat) +{ + i2c_write_addr1b(addr, reg, &dat, 1); +} + +int8_t i2c_ack_poll(uint8_t addr) { int8_t addr_match = 0; @@ -139,7 +152,7 @@ int8_t i2c_ack_poll(uint8_t devaddr) while(!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_MODE_SELECT) && timeout--); if (!timeout) return -2; - I2C_Send7bitAddress(I2C1, devaddr, I2C_Direction_Receiver); + I2C_Send7bitAddress(I2C1, addr, I2C_Direction_Receiver); timeout = I2C_TIMEOUT_ACK_POLL; while (!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_RECEIVER_MODE_SELECTED) && timeout--); if (!timeout) { diff --git a/code/retro_tech_fw/user/src/i2c.h b/code/retro_tech_fw/user/src/i2c.h new file mode 100644 index 0000000..c3c3568 --- /dev/null +++ b/code/retro_tech_fw/user/src/i2c.h @@ -0,0 +1,26 @@ +/* + * Created on: Jul 27, 2024 + */ + +#ifndef USER_SRC_I2C_H_ +#define USER_SRC_I2C_H_ + + + +#include + + + +void i2c_init(); + +int8_t i2c_read_addr1b(uint8_t addr, uint8_t reg, uint8_t *data, uint8_t len); +int8_t i2c_write_addr1b(uint8_t addr, uint8_t reg, uint8_t *data, uint8_t len); + +uint8_t i2c_read_reg_8b(uint8_t addr, uint8_t reg); +void i2c_write_reg_8b(uint8_t addr, uint8_t reg, uint8_t dat); + +int8_t i2c_ack_poll(uint8_t devaddr); + + + +#endif /* USER_SRC_I2C_H_ */ diff --git a/code/firmware/user/src/led.c b/code/retro_tech_fw/user/src/led.c similarity index 100% rename from code/firmware/user/src/led.c rename to code/retro_tech_fw/user/src/led.c index 833ed50..a402f28 100644 --- a/code/firmware/user/src/led.c +++ b/code/retro_tech_fw/user/src/led.c @@ -6,8 +6,8 @@ #define FL3729_CS_OUTPUTS 15 -#define LED_INIT_CURRENT 0 +#define LED_INIT_CURRENT 0 #define LED_INIT_SCALING 0xff diff --git a/code/firmware/user/src/led.h b/code/retro_tech_fw/user/src/led.h similarity index 100% rename from code/firmware/user/src/led.h rename to code/retro_tech_fw/user/src/led.h diff --git a/code/firmware/user/src/led_rgbprog.c b/code/retro_tech_fw/user/src/led_rgbprog.c similarity index 100% rename from code/firmware/user/src/led_rgbprog.c rename to code/retro_tech_fw/user/src/led_rgbprog.c diff --git a/code/firmware/user/src/led_rgbprog.h b/code/retro_tech_fw/user/src/led_rgbprog.h similarity index 100% rename from code/firmware/user/src/led_rgbprog.h rename to code/retro_tech_fw/user/src/led_rgbprog.h diff --git a/code/firmware/user/src/rand.c b/code/retro_tech_fw/user/src/rand.c similarity index 100% rename from code/firmware/user/src/rand.c rename to code/retro_tech_fw/user/src/rand.c diff --git a/code/firmware/user/src/rand.h b/code/retro_tech_fw/user/src/rand.h similarity index 100% rename from code/firmware/user/src/rand.h rename to code/retro_tech_fw/user/src/rand.h diff --git a/code/firmware/user/src/ui.c b/code/retro_tech_fw/user/src/ui.c similarity index 100% rename from code/firmware/user/src/ui.c rename to code/retro_tech_fw/user/src/ui.c diff --git a/code/firmware/user/src/ui.h b/code/retro_tech_fw/user/src/ui.h similarity index 100% rename from code/firmware/user/src/ui.h rename to code/retro_tech_fw/user/src/ui.h diff --git a/code/firmware/user/system_ch32v00x.c b/code/retro_tech_fw/user/system_ch32v00x.c similarity index 100% rename from code/firmware/user/system_ch32v00x.c rename to code/retro_tech_fw/user/system_ch32v00x.c diff --git a/code/firmware/user/system_ch32v00x.h b/code/retro_tech_fw/user/system_ch32v00x.h similarity index 100% rename from code/firmware/user/system_ch32v00x.h rename to code/retro_tech_fw/user/system_ch32v00x.h