#ifndef _ON_CHIP_FLASH_H_
#define _ON_CHIP_FLASH_H_

//#include "cpu_types.h"
#include "gd32f4xx.h"
typedef  unsigned  int         U32;                      /* 32-bit unsigned integer                              */

/*
**  GD32flash只有一个 bank0，地址为0x08000000——0x0807ffff
**  bank0存储空间为512KB，扇区0-3大小为16KB，扇区4为64KB，扇区5-7为128KB
*/

#define ON_CHIP_FLASH_SECTOR_SIZE_16 1024*16
#define ON_CHIP_FLASH_SECTOR_SIZE_64 1024*64
#define ON_CHIP_FLASH_SECTOR_SIZE_128 1024*128



#define EXT_FLASH_SECTOR_SIZE   (1024*4)
#define EXT_FLASH_BLOCK_NUM     (0)
#define EXT_FLASH_BLOCK_NUM16   (16)

//#define one_byte  1
//#define half_word 2
//#define one_word  3


//RAM_FUNC void OnChip_Flash_init(void);
//RAM_FUNC U8 OnChip_Flash_erase_sector(U16 sectorNo);
//RAM_FUNC U8 OnChip_Flash_write_in_sector(U16 sectNo,U16 offset,U16 cnt,U8 buf[]);
//RAM_FUNC U8 OnChip_Flash_write(U32 addr,U16 cnt, U8 buf[]);
//RAM_FUNC U32 OnChip_Flash_cmd_launch(void);
void OnChip_Flash_read_in_add(uint32_t address,uint16_t cnt,uint8_t*bBuf);
uint8_t OnChip_Flash_write_byte(uint32_t address,uint16_t cnt, uint8_t buf[]);
uint8_t OnChip_Flash_erase_sector(uint16_t sectorNo);
#endif //_ON_CHIP_FLASH_H_