dc33-retro-tech-addon/firmware/retro_tech_fw/code/system_ch32x035.h
true f8a987a592 soft I2C implemented, LEDs are now lighting
copied over and modified for use my CH59x soft I2C.

CH32X GPIO does not have an open drain mode, so I have to implement this with RMW to the mode register. After doing this and adding missing functions needed for existing code, LED writes and EEPROM reads and writes.

using the AWU for system timing so the clock speed can change.

existing issues:
- changing clock speed divider in soft i2c routines causes the system to crash
- ADC seems to be reading, but result isn't being used
2025-07-24 06:19:24 -07:00

49 lines
1.2 KiB
C

/********************************** (C) COPYRIGHT *******************************
* File Name : system_ch32x035.h
* Author : WCH
* Version : V1.0.0
* Date : 2023/04/06
* Description : CH32X035 Device Peripheral Access Layer System Header File.
*********************************************************************************
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
* Attention: This software (modified or not) and binary are used for
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
*******************************************************************************/
#ifndef __SYSTEM_CH32X035_H
#define __SYSTEM_CH32X035_H
#ifdef __cplusplus
extern "C" {
#endif
#define SYSCLK_FREQ_8MHz_HSI 8000000
#define SYSCLK_FREQ_12MHz_HSI 12000000
#define SYSCLK_FREQ_16MHz_HSI 16000000
#define SYSCLK_FREQ_24MHz_HSI 24000000
#define SYSCLK_FREQ_48MHz_HSI HSI_VALUE
extern uint32_t SystemCoreClock; /* System Clock Frequency (Core Clock) */
/* System_Exported_Functions */
void SystemInit(void);
void SystemCoreClockUpdate(void);
void SetSysClock(uint32_t clock);
#ifdef __cplusplus
}
#endif
#endif