#ifndef __PUBLIC_H_
#define __PUBLIC_H_

#include "gd32h7xx.h"

/* section placement helpers */
#if defined(__ICCARM__)
    #define IAR_STRINGIFY_HELPER(__VALUE) #__VALUE
    #define IAR_STRINGIFY(__VALUE)        IAR_STRINGIFY_HELPER(__VALUE)
    #define AT_ADDR(__ADDR)               _Pragma(IAR_STRINGIFY(location = __ADDR))
    #define SET_AREA(__AREA)              _Pragma(IAR_STRINGIFY(location = #__AREA))
    #define SET_ADDR(__ADDR)              AT_ADDR(__ADDR)
    #define SET_RAM_CODE                  SET_AREA(RAM_CODE)
    #define SET_FLASH_AREA                SET_AREA(FLASH_AREA)
    #define SET_SDRAM                     _Pragma(IAR_STRINGIFY(data_alignment = 64)) SET_AREA(SDRAM)
    #define SET_DMA_AREA_RAM              _Pragma(IAR_STRINGIFY(data_alignment = 64)) SET_AREA(DMA_AREA_RAM)
    #define SET_DMA_AREA_SDRAM            _Pragma(IAR_STRINGIFY(data_alignment = 64)) SET_AREA(DMA_AREA_SDRAM)
    #define SET_DTC                       _Pragma(IAR_STRINGIFY(data_alignment = 64)) SET_AREA(DTC_RAM)
    #define SET_AXI                       _Pragma(IAR_STRINGIFY(data_alignment = 64)) SET_AREA(AXI_RAM)
    #define SET_VECTOR_TABLE              _Pragma(IAR_STRINGIFY(data_alignment = 1024)) SET_AREA(VECTOR_TABLE)
    #define SET_ANY_RO_1                  SET_AREA(ANY_RO_PRIO1)
    #define SET_ANY_RO_2                  SET_AREA(ANY_RO_PRIO2)
    #define SET_ANY_RW_1                  SET_AREA(ANY_RW_PRIO1)
    #define SET_ANY_RW_3                  SET_AREA(ANY_RW_PRIO3)
    #define SET_ANY_RW_4                  SET_AREA(ANY_RW_PRIO4)
#else
    #define AT_ADDR(__ADDR)               __attribute__ ((section(".ARM.__at_" #__ADDR)))
    #define SET_AREA(__AREA)              __attribute__((section(""#__AREA)))
    #define SET_ADDR(__ADDR)              AT_ADDR(__ADDR)
    #define SET_RAM_CODE                  __attribute__ ((aligned(64))) SET_AREA(RAM_CODE)
    #define SET_FLASH_AREA                __attribute__ ((aligned(64))) SET_AREA(FLASH_AREA)
    #define SET_SDRAM                     __attribute__ ((aligned(64))) SET_AREA(SDRAM)
    #define SET_DMA_AREA_RAM              __attribute__ ((aligned(64))) SET_AREA(DMA_AREA_RAM)
    #define SET_DMA_AREA_SDRAM            __attribute__ ((aligned(64))) SET_AREA(DMA_AREA_SDRAM)
    #define SET_DTC                       __attribute__ ((aligned(64))) SET_AREA(DTC_RAM)
    #define SET_AXI                       __attribute__ ((aligned(64))) SET_AREA(AXI_RAM)
    #define SET_VECTOR_TABLE              __attribute__ ((aligned(0x400))) SET_AREA(VECTOR_TABLE)
    #define SET_ANY_RO_1
    #define SET_ANY_RO_2
    #define SET_ANY_RW_1
    #define SET_ANY_RW_3
    #define SET_ANY_RW_4
#endif

/*����/����洢λ��*/
void delay_init(void);
void driver_init(void);
void delay_us(uint32_t count);
void delay_ms(uint32_t count);
void driver_tic_inc(void);
void delay_sysclk(uint32_t count);
void cache_enable(void);

void mpu_config(uint32_t region_base_address,uint32_t region_size,uint32_t access_permission,\
                                    uint32_t access_bufferable,uint32_t access_cacheable,uint32_t access_shareable,\
                                    uint32_t instruction_exec,uint32_t tex_type);

void driver_system_config(void);


#endif /*#ifndef __PUBLIC_H_*/
