/**
  **************************************************************************
  * @file     flash.h
  * @brief    flash header file
  **************************************************************************
  *                       Copyright notice & Disclaimer
  *
  * The software Board Support Package (BSP) that is made available to
  * download from Artery official website is the copyrighted work of Artery.
  * Artery authorizes customers to use, copy, and distribute the BSP
  * software and its related documentation for the purpose of design and
  * development in conjunction with Artery microcontrollers. Use of the
  * software is governed by this copyright notice and the following disclaimer.
  *
  * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
  * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
  * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
  * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
  * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
  * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
  *
  **************************************************************************
  */

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __BSP_FLASH_H__
#define __BSP_FLASH_H__

#include "at32a423.h"

#define FMC_WRITE_START_ADDR  (0x08000000 + 1024 * 50)

#pragma pack (1)
typedef struct
{
	uint32_t flash_head;
  	uint16_t output_mode;
	uint16_t output_ax;
	uint16_t output_ay;
	uint16_t min_trigger_res_value;
	uint16_t max_trigger_res_value;
	uint16_t div_trigger_res;
	uint32_t flash_tail;
 }flash_para_struct;
#pragma pack ()

// 已修改为匹配结构体要求的函数声明
uint8_t flash_read(uint32_t read_addr, void *p_buffer, uint32_t num_read);
uint8_t flash_write_nocheck(uint32_t write_addr, const void *p_buffer, uint32_t num_write);
uint8_t flash_write(uint32_t write_addr, const void *p_Buffer, uint32_t num_write);

int load_config_params(flash_para_struct *params);
int save_config_params(flash_para_struct *params);

uint8_t flash_erase(uint32_t sector_addr, uint32_t len);
uint8_t bsp_flash_is_erased(uint32_t addr, uint32_t size);

/**
  * @}
  */

/**
  * @}
  */

/**
  * @}
  */

#endif


