2024-12-02 16:26:55 +08:00
|
|
|
|
/********************************** (C) COPYRIGHT *******************************
|
2025-02-21 14:38:41 +08:00
|
|
|
|
* File Name : CH58x_common.h
|
2024-12-02 16:26:55 +08:00
|
|
|
|
* Author : WCH
|
|
|
|
|
* Version : V1.2
|
|
|
|
|
* Date : 2021/11/17
|
2025-02-21 14:38:41 +08:00
|
|
|
|
* Description : head file(ch585/ch584)
|
2024-12-02 16:26:55 +08:00
|
|
|
|
*********************************************************************************
|
|
|
|
|
* 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.
|
|
|
|
|
*******************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
2025-02-21 14:38:41 +08:00
|
|
|
|
#ifndef __CH58x_COMM_H__
|
|
|
|
|
#define __CH58x_COMM_H__
|
2024-12-02 16:26:55 +08:00
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef NULL
|
|
|
|
|
#define NULL 0
|
|
|
|
|
#endif
|
|
|
|
|
#define ALL 0xFFFF
|
|
|
|
|
|
|
|
|
|
#ifndef __HIGH_CODE
|
|
|
|
|
#define __HIGH_CODE __attribute__((section(".highcode")))
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef __INTERRUPT
|
|
|
|
|
#ifdef INT_SOFT
|
|
|
|
|
#define __INTERRUPT __attribute__((interrupt()))
|
|
|
|
|
#else
|
|
|
|
|
#define __INTERRUPT __attribute__((interrupt("WCH-Interrupt-fast")))
|
|
|
|
|
#endif
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#define Debug_UART0 0
|
|
|
|
|
#define Debug_UART1 1
|
|
|
|
|
#define Debug_UART2 2
|
|
|
|
|
#define Debug_UART3 3
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief ϵͳ<EFBFBD><EFBFBD>Ƶʱ<EFBFBD>ӣ<EFBFBD>Hz<EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
#ifndef FREQ_SYS
|
2025-02-21 14:38:41 +08:00
|
|
|
|
#define FREQ_SYS 62400000
|
2024-12-02 16:26:55 +08:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef SAFEOPERATE
|
2025-04-12 13:58:43 +08:00
|
|
|
|
#define SAFEOPERATE asm volatile("fence.i")
|
2024-12-02 16:26:55 +08:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief 32Kʱ<EFBFBD>ӣ<EFBFBD>Hz<EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
#ifdef CLK_OSC32K
|
|
|
|
|
#if ( CLK_OSC32K == 1 )
|
|
|
|
|
#define CAB_LSIFQ 32000
|
|
|
|
|
#else
|
|
|
|
|
#define CAB_LSIFQ 32768
|
|
|
|
|
#endif
|
|
|
|
|
#else
|
|
|
|
|
#define CAB_LSIFQ 32000
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <stdint.h>
|
2025-02-21 14:38:41 +08:00
|
|
|
|
#include <CH585SFR.h>
|
2024-12-02 16:26:55 +08:00
|
|
|
|
#include "core_riscv.h"
|
2025-02-21 14:38:41 +08:00
|
|
|
|
#include "CH58x_clk.h"
|
|
|
|
|
#include "CH58x_uart.h"
|
|
|
|
|
#include "CH58x_gpio.h"
|
|
|
|
|
#include "CH58x_i2c.h"
|
|
|
|
|
#include "CH58x_flash.h"
|
|
|
|
|
#include "CH58x_pwr.h"
|
|
|
|
|
#include "CH58x_pwm.h"
|
|
|
|
|
#include "CH58x_adc.h"
|
|
|
|
|
#include "CH58x_sys.h"
|
|
|
|
|
#include "CH58x_timer.h"
|
|
|
|
|
#include "CH58x_spi.h"
|
|
|
|
|
#include "CH58x_usbdev.h"
|
|
|
|
|
#include "CH58x_usbhost.h"
|
|
|
|
|
#include "ISP585.h"
|
2024-12-02 16:26:55 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define DelayMs(x) mDelaymS(x)
|
|
|
|
|
#define DelayUs(x) mDelayuS(x)
|
|
|
|
|
|
|
|
|
|
#define ROM_CFG_VERISON 0x7F010
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2025-02-21 14:38:41 +08:00
|
|
|
|
#endif // __CH58x_COMM_H__
|
2024-12-02 16:26:55 +08:00
|
|
|
|
|