92 lines
		
	
	
		
			2.9 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			92 lines
		
	
	
		
			2.9 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
/****************************************************************************
 | 
						|
 | 
						|
Copyright(c) 2019 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED.
 | 
						|
 | 
						|
This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT
 | 
						|
be copied by any method or incorporated into another program without
 | 
						|
the express written consent of Aerospace C.Power. This Information or any portion
 | 
						|
thereof remains the property of Aerospace C.Power. The Information contained herein
 | 
						|
is believed to be accurate and Aerospace C.Power assumes no responsibility or
 | 
						|
liability for its use in any way and conveys no license or title under
 | 
						|
any patent or copyright and makes no representation or warranty that this
 | 
						|
Information is free from patent or copyright infringement.
 | 
						|
 | 
						|
****************************************************************************/
 | 
						|
 | 
						|
#ifndef _APP_FLASH_H_
 | 
						|
#define _APP_FLASH_H_
 | 
						|
 | 
						|
#include "app_types.h"
 | 
						|
 | 
						|
#define APP_NV_FTM_SIZE           0x40    /* 64 Bytes */
 | 
						|
 | 
						|
/* ****************************************** */
 | 
						|
/* The total size of flash is 122880 (120K)   */
 | 
						|
/* ****************************************** */
 | 
						|
#define APP_FLASH_START_ADDR      0x0
 | 
						|
#define APP_FLASH_NV_FTM_ADDR     0x0
 | 
						|
#define APP_FLASH_NV_FTM_SIZE     0x1000
 | 
						|
#define APP_FLASH_NV_SCN_ADDR     0x1000
 | 
						|
#define APP_FLASH_NV_SCN_SIZE     0x1000
 | 
						|
 | 
						|
/* ****************************************** */
 | 
						|
/* The value range of id NV ID [0x00, 0x39]   */
 | 
						|
/* ****************************************** */
 | 
						|
#define NV_FTM_ID_START           0x00
 | 
						|
#define NV_FTM_FACTORY_ID         0x0f
 | 
						|
#define NV_FTM_ID_END             0x39
 | 
						|
 | 
						|
#pragma pack(push)
 | 
						|
#pragma pack(1)
 | 
						|
/* 8 Bytes Used*/
 | 
						|
typedef struct {
 | 
						|
    /* Baud rate. */
 | 
						|
    uint32_t baudrate;
 | 
						|
    /* Number of data bits. The value can be 6 bits, 7 bits, or 8 bits. */
 | 
						|
    uint8_t data_bits;
 | 
						|
    /* Number of stop bits. <1: 1 stop bit, 2: 2 stop bit> */
 | 
						|
    uint8_t stop_bits;
 | 
						|
    /* Parity check flag. <0: No check, 1: Odd parity, 2: Even parity> */
 | 
						|
    uint8_t parity;
 | 
						|
    /* pad 1 byte */
 | 
						|
    uint8_t resv;
 | 
						|
} app_uart_param;
 | 
						|
 | 
						|
/* NV="0x0f" 64 Bytes Used */
 | 
						|
typedef struct {
 | 
						|
    uint32_t hw_ver;
 | 
						|
    uint8_t multicast_mac[6];
 | 
						|
    app_uart_param uart_para;
 | 
						|
    uint8_t sta_join_notify;
 | 
						|
    /* pad 45 byte */
 | 
						|
    uint8_t resv[45];
 | 
						|
} nv_ftm_factory_id;
 | 
						|
 | 
						|
#pragma pack(pop)
 | 
						|
 | 
						|
/**
 | 
						|
 * @brief app_flash_read() - read data from customer flash
 | 
						|
 *
 | 
						|
 * @param [in] offset: offset of data
 | 
						|
 * @param [out] buffer: buffer of read out data
 | 
						|
 * @param [in] size: data size to read
 | 
						|
 *
 | 
						|
 * @return 0: succeeded;
 | 
						|
 * @return others: failed;
 | 
						|
 */
 | 
						|
uint16_t app_flash_read(uint32_t offset, uint8_t * buffer, uint32_t size);
 | 
						|
 | 
						|
/**
 | 
						|
 * @brief app_flash_write() - write data to customer flash
 | 
						|
 *
 | 
						|
 * @param [in] offset: offset of data
 | 
						|
 * @param [in] buffer: buffer of write data
 | 
						|
 * @param [in] size: data size to write
 | 
						|
 *
 | 
						|
 * @return 0: succeeded;
 | 
						|
 * @return others: failed;
 | 
						|
 */
 | 
						|
uint16_t app_flash_write(uint32_t offset, uint8_t * buffer, uint32_t size);
 | 
						|
 | 
						|
#endif  /* _APP_FLASH_H_ */
 |