Files
kunlun/app/iot_cus_at_app/driver/app_flash.h

120 lines
4.2 KiB
C
Raw Permalink Normal View History

2024-09-28 14:24:04 +08:00
/****************************************************************************
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
#define APP_FLASH_NV_SILA_ADDR (APP_FLASH_NV_SCN_ADDR + APP_FLASH_NV_SCN_SIZE)
#define APP_FLASH_NV_SILA_SIZE 0x14000
/* ****************************************** */
/* The value range of id NV ID [0x00, 0x39] */
/* ****************************************** */
#define NV_FTM_ID_START 0x00
#define NV_FTM_FACTORY_ID 0x0f
#define NV_FTM_HWIO_ID 0x10
#define NV_FTM_BCAST_ID 0x12
#define NV_FTM_ID_END 0x39
/* Device address information */
#define ID_NV_APP_DEV_ADDR_INF 0x8a
/* Demo lamp state information */
#define ID_NV_APP_LAMP_STATE_INF 0x94
/* ****************************************** */
/* The flash block size is 4k */
/* ****************************************** */
#define PRODUCT_CFG_FLASH_BLOCK_SIZE 0x1000
/* ****************************************** */
/* Customer block serial */
/* ****************************************** */
#define CUSTOMER_SERIAL_SCENE_ID 0x00
#define BCAST_LEN_MAX 100
#pragma pack(push)
#pragma pack(1)
/* 8 Bytes Used*/
typedef struct {
uint32_t baudrate; /* Baud rate. */
uint8_t data_bits; /* Number of data bits. The value can be 6 bits, 7 bits, or 8 bits. */
uint8_t stop_bits; /* Number of stop bits. <1: 1 stop bit, 2: 2 stop bit> */
uint8_t parity; /* Parity check flag. <0: No check, 1: Odd parity, 2: Even parity> */
uint8_t resv; /* pad 1 byte */
} app_uart_param;
/* 8 Bytes Used*/
typedef struct {
uint8_t type; /* pin type <0:unknow, 1:GPIO, 2:PWM> */
uint8_t pin_num; /* GPIO pin */
uint8_t state; /* GPIO state <0:low level, 1:high level(pwm 0-100)> */
uint8_t pwm_freq; /* pwm frequency (unit:kHz) */
uint8_t pwm_ctl_mode; /* pwm ctl mode <0:real-time, 1:linear, 2:logar> */
uint8_t pwm_adjust_time; /* pwm gradient duration */
uint8_t pwm_channel; /* pwm channel */
uint8_t init_state; /* GPIO init state <0:uninitialized, 1:initialized> */
} app_io_state;
/* NV="0x0f" 64 Bytes Used */
typedef struct {
uint32_t hw_ver;
uint8_t work_mode;
uint8_t multicast_mac[6];
app_uart_param uart_para;
uint8_t sta_join_notify;
uint8_t idf_status;
uint8_t lock_mac;
uint8_t group[32]; /* sta group bitmap, support max num is 255 */
uint8_t resv[10]; /* pad 10 byte */
} nv_ftm_factory_id;
/* NV ID="0x10" 128 Bytes Used */
typedef struct {
app_io_state io_type[12];
uint8_t resv[32];
} nv_ftm_hwio_id;
/* NV ID="0x12" 128 Bytes Used */
typedef struct {
uint8_t status;
uint16_t period;
uint8_t len;
uint8_t send_flag;
uint8_t data[BCAST_LEN_MAX];
uint8_t resv[23];
} nv_ftm_bcast_id;
#pragma pack(pop)
uint16_t app_flash_read(uint32_t offset, uint8_t * buffer, uint32_t size);
uint16_t app_flash_write(uint32_t offset, uint8_t * buffer, uint32_t size);
#endif /* _APP_FLASH_H_ */