rf_para_flash_t is missing defs
This commit is contained in:
@@ -5,8 +5,6 @@
|
|||||||
#include "bl602_sflash.h"
|
#include "bl602_sflash.h"
|
||||||
|
|
||||||
int8_t mfg_flash_init(SPI_Flash_Cfg_Type *flashCfg);
|
int8_t mfg_flash_init(SPI_Flash_Cfg_Type *flashCfg);
|
||||||
static int8_t mfg_flash_program(void);
|
|
||||||
static int8_t mfg_flash_read(void);
|
|
||||||
int8_t mfg_flash_write_xtal_capcode_pre(uint8_t capcode, uint8_t program);
|
int8_t mfg_flash_write_xtal_capcode_pre(uint8_t capcode, uint8_t program);
|
||||||
void mfg_flash_write_xtal_capcode(void);
|
void mfg_flash_write_xtal_capcode(void);
|
||||||
int8_t mfg_flash_read_xtal_capcode(uint8_t *capcode, uint8_t reload);
|
int8_t mfg_flash_read_xtal_capcode(uint8_t *capcode, uint8_t reload);
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#include "partition.h"
|
#include "partition.h"
|
||||||
#include "softcrc.h"
|
#include "softcrc.h"
|
||||||
|
|
||||||
static rf_para_flash_t rf_para;
|
// static rf_para_flash_t rf_para;
|
||||||
static uint32_t rf_para_addr = 0;
|
static uint32_t rf_para_addr = 0;
|
||||||
static SPI_Flash_Cfg_Type *pFlashCfg;
|
static SPI_Flash_Cfg_Type *pFlashCfg;
|
||||||
|
|
||||||
@@ -103,16 +103,16 @@ static int8_t mfg_flash_read(void)
|
|||||||
|
|
||||||
int8_t mfg_flash_write_xtal_capcode_pre(uint8_t capcode, uint8_t program)
|
int8_t mfg_flash_write_xtal_capcode_pre(uint8_t capcode, uint8_t program)
|
||||||
{
|
{
|
||||||
rf_para.magic = RF_PARA_MAGIC_FLAG;
|
// rf_para.magic = RF_PARA_MAGIC_FLAG;
|
||||||
rf_para.capcode_valid = RF_PARA_VALID_FLAG;
|
// rf_para.capcode_valid = RF_PARA_VALID_FLAG;
|
||||||
rf_para.capcode = capcode;
|
// rf_para.capcode = capcode;
|
||||||
rf_para.crc32 = BFLB_Soft_CRC32(&rf_para.capcode_valid, sizeof(rf_para) - 8);
|
// rf_para.crc32 = BFLB_Soft_CRC32(&rf_para.capcode_valid, sizeof(rf_para) - 8);
|
||||||
|
|
||||||
if (program) {
|
// if (program) {
|
||||||
return mfg_flash_program();
|
// return mfg_flash_program();
|
||||||
} else {
|
// } else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
void mfg_flash_write_xtal_capcode(void)
|
void mfg_flash_write_xtal_capcode(void)
|
||||||
@@ -126,32 +126,32 @@ int8_t mfg_flash_read_xtal_capcode(uint8_t *capcode, uint8_t reload)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rf_para.magic == RF_PARA_MAGIC_FLAG) {
|
// if (rf_para.magic == RF_PARA_MAGIC_FLAG) {
|
||||||
if (rf_para.crc32 == (BFLB_Soft_CRC32(&rf_para.capcode_valid, sizeof(rf_para) - 8))) {
|
// if (rf_para.crc32 == (BFLB_Soft_CRC32(&rf_para.capcode_valid, sizeof(rf_para) - 8))) {
|
||||||
if (rf_para.capcode_valid == RF_PARA_VALID_FLAG) {
|
// if (rf_para.capcode_valid == RF_PARA_VALID_FLAG) {
|
||||||
*capcode = rf_para.capcode;
|
// *capcode = rf_para.capcode;
|
||||||
return 0;
|
// return 0;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int8_t mfg_flash_write_poweroffset_pre(int8_t pwrOffset[14], uint8_t program)
|
int8_t mfg_flash_write_poweroffset_pre(int8_t pwrOffset[14], uint8_t program)
|
||||||
{
|
{
|
||||||
rf_para.magic = RF_PARA_MAGIC_FLAG;
|
// rf_para.magic = RF_PARA_MAGIC_FLAG;
|
||||||
rf_para.poweroffset_valid = RF_PARA_VALID_FLAG;
|
// rf_para.poweroffset_valid = RF_PARA_VALID_FLAG;
|
||||||
rf_para.poweroffset[0] = pwrOffset[0];
|
// rf_para.poweroffset[0] = pwrOffset[0];
|
||||||
rf_para.poweroffset[1] = pwrOffset[6];
|
// rf_para.poweroffset[1] = pwrOffset[6];
|
||||||
rf_para.poweroffset[2] = pwrOffset[12];
|
// rf_para.poweroffset[2] = pwrOffset[12];
|
||||||
rf_para.crc32 = BFLB_Soft_CRC32(&rf_para.capcode_valid, sizeof(rf_para) - 8);
|
// rf_para.crc32 = BFLB_Soft_CRC32(&rf_para.capcode_valid, sizeof(rf_para) - 8);
|
||||||
|
|
||||||
if (program) {
|
// if (program) {
|
||||||
return mfg_flash_program();
|
// return mfg_flash_program();
|
||||||
} else {
|
// } else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
void mfg_flash_write_poweroffset(void)
|
void mfg_flash_write_poweroffset(void)
|
||||||
@@ -168,55 +168,55 @@ int8_t mfg_flash_read_poweroffset(int8_t pwrOffset[14], uint8_t reload)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rf_para.magic == RF_PARA_MAGIC_FLAG) {
|
// if (rf_para.magic == RF_PARA_MAGIC_FLAG) {
|
||||||
if (rf_para.crc32 == (BFLB_Soft_CRC32(&rf_para.capcode_valid, sizeof(rf_para) - 8))) {
|
// if (rf_para.crc32 == (BFLB_Soft_CRC32(&rf_para.capcode_valid, sizeof(rf_para) - 8))) {
|
||||||
if (rf_para.poweroffset_valid == RF_PARA_VALID_FLAG) {
|
// if (rf_para.poweroffset_valid == RF_PARA_VALID_FLAG) {
|
||||||
memset(pwrOffset, 0, 14);
|
// memset(pwrOffset, 0, 14);
|
||||||
pwrOffsetTmp[0] = rf_para.poweroffset[0];
|
// pwrOffsetTmp[0] = rf_para.poweroffset[0];
|
||||||
pwrOffsetTmp[1] = rf_para.poweroffset[1];
|
// pwrOffsetTmp[1] = rf_para.poweroffset[1];
|
||||||
pwrOffsetTmp[2] = rf_para.poweroffset[2];
|
// pwrOffsetTmp[2] = rf_para.poweroffset[2];
|
||||||
|
|
||||||
pwrOffset[0] = pwrOffsetTmp[0];
|
// pwrOffset[0] = pwrOffsetTmp[0];
|
||||||
|
|
||||||
step = (pwrOffsetTmp[1] - pwrOffsetTmp[0]) * 100 / 6;
|
// step = (pwrOffsetTmp[1] - pwrOffsetTmp[0]) * 100 / 6;
|
||||||
pwrOffset[1] = (step + 50) / 100 + pwrOffsetTmp[0];
|
// pwrOffset[1] = (step + 50) / 100 + pwrOffsetTmp[0];
|
||||||
pwrOffset[2] = (step * 2 + 50) / 100 + pwrOffsetTmp[0];
|
// pwrOffset[2] = (step * 2 + 50) / 100 + pwrOffsetTmp[0];
|
||||||
pwrOffset[3] = (step * 3 + 50) / 100 + pwrOffsetTmp[0];
|
// pwrOffset[3] = (step * 3 + 50) / 100 + pwrOffsetTmp[0];
|
||||||
pwrOffset[4] = (step * 4 + 50) / 100 + pwrOffsetTmp[0];
|
// pwrOffset[4] = (step * 4 + 50) / 100 + pwrOffsetTmp[0];
|
||||||
pwrOffset[5] = (step * 5 + 50) / 100 + pwrOffsetTmp[0];
|
// pwrOffset[5] = (step * 5 + 50) / 100 + pwrOffsetTmp[0];
|
||||||
|
|
||||||
pwrOffset[6] = pwrOffsetTmp[1];
|
// pwrOffset[6] = pwrOffsetTmp[1];
|
||||||
|
|
||||||
step = (pwrOffsetTmp[2] - pwrOffsetTmp[1]) * 100 / 6;
|
// step = (pwrOffsetTmp[2] - pwrOffsetTmp[1]) * 100 / 6;
|
||||||
pwrOffset[7] = (step + 50) / 100 + pwrOffsetTmp[1];
|
// pwrOffset[7] = (step + 50) / 100 + pwrOffsetTmp[1];
|
||||||
pwrOffset[8] = (step * 2 + 50) / 100 + pwrOffsetTmp[1];
|
// pwrOffset[8] = (step * 2 + 50) / 100 + pwrOffsetTmp[1];
|
||||||
pwrOffset[9] = (step * 3 + 50) / 100 + pwrOffsetTmp[1];
|
// pwrOffset[9] = (step * 3 + 50) / 100 + pwrOffsetTmp[1];
|
||||||
pwrOffset[10] = (step * 4 + 50) / 100 + pwrOffsetTmp[1];
|
// pwrOffset[10] = (step * 4 + 50) / 100 + pwrOffsetTmp[1];
|
||||||
pwrOffset[11] = (step * 5 + 50) / 100 + pwrOffsetTmp[1];
|
// pwrOffset[11] = (step * 5 + 50) / 100 + pwrOffsetTmp[1];
|
||||||
|
|
||||||
pwrOffset[12] = pwrOffsetTmp[2];
|
// pwrOffset[12] = pwrOffsetTmp[2];
|
||||||
|
|
||||||
pwrOffset[13] = (step * 7 + 50) / 100 + pwrOffsetTmp[1];
|
// pwrOffset[13] = (step * 7 + 50) / 100 + pwrOffsetTmp[1];
|
||||||
return 0;
|
// return 0;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int8_t mfg_flash_write_macaddr_pre(uint8_t mac[6], uint8_t program)
|
int8_t mfg_flash_write_macaddr_pre(uint8_t mac[6], uint8_t program)
|
||||||
{
|
{
|
||||||
rf_para.magic = RF_PARA_MAGIC_FLAG;
|
// rf_para.magic = RF_PARA_MAGIC_FLAG;
|
||||||
rf_para.mac_valid = RF_PARA_VALID_FLAG;
|
// rf_para.mac_valid = RF_PARA_VALID_FLAG;
|
||||||
memcpy(rf_para.mac, mac, 6);
|
// memcpy(rf_para.mac, mac, 6);
|
||||||
rf_para.crc32 = BFLB_Soft_CRC32(&rf_para.capcode_valid, sizeof(rf_para) - 8);
|
// rf_para.crc32 = BFLB_Soft_CRC32(&rf_para.capcode_valid, sizeof(rf_para) - 8);
|
||||||
|
|
||||||
if (program) {
|
// if (program) {
|
||||||
return mfg_flash_program();
|
// return mfg_flash_program();
|
||||||
} else {
|
// } else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
void mfg_flash_write_macaddr(void)
|
void mfg_flash_write_macaddr(void)
|
||||||
@@ -231,14 +231,14 @@ int8_t mfg_flash_read_macaddr(uint8_t mac[6], uint8_t reload)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rf_para.magic == RF_PARA_MAGIC_FLAG) {
|
// if (rf_para.magic == RF_PARA_MAGIC_FLAG) {
|
||||||
if (rf_para.crc32 == (BFLB_Soft_CRC32(&rf_para.capcode_valid, sizeof(rf_para) - 8))) {
|
// if (rf_para.crc32 == (BFLB_Soft_CRC32(&rf_para.capcode_valid, sizeof(rf_para) - 8))) {
|
||||||
if (rf_para.mac_valid == RF_PARA_VALID_FLAG) {
|
// if (rf_para.mac_valid == RF_PARA_VALID_FLAG) {
|
||||||
memcpy(mac, rf_para.mac, 6);
|
// memcpy(mac, rf_para.mac, 6);
|
||||||
return 0;
|
// return 0;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "bl602_mfg_media.h"
|
#include "bl602_mfg_media.h"
|
||||||
#include "bl602_mfg_efuse.h"
|
#include "bl602_mfg_efuse.h"
|
||||||
#include "bl602_mfg_flash.h
|
#include "bl602_mfg_flash.h"
|
||||||
|
#include "hal_common.h"
|
||||||
static uint8_t rf_para_on_flash = 0;
|
static uint8_t rf_para_on_flash = 0;
|
||||||
|
|
||||||
int8_t mfg_media_init_need_lock(SPI_Flash_Cfg_Type *flashCfg)
|
int8_t mfg_media_init_need_lock(SPI_Flash_Cfg_Type *flashCfg)
|
||||||
@@ -184,12 +185,12 @@ int8_t mfg_media_write_macaddr_pre_with_lock(uint8_t mac[6], uint8_t program)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int mfg_media_write_macaddr_need_lock(void)
|
void mfg_media_write_macaddr_need_lock(void)
|
||||||
{
|
{
|
||||||
if (rf_para_on_flash) {
|
if (rf_para_on_flash) {
|
||||||
return mfg_flash_write_macaddr();
|
mfg_flash_write_macaddr();
|
||||||
} else {
|
} else {
|
||||||
return mfg_efuse_write_macaddr();
|
mfg_efuse_write_macaddr();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user