杰发科技AC7801——使用EEP写版本号和日期

代码仅作为示例

各位看官自己优化即可

cpp 复制代码
#include <stdlib.h>
#include "ac780x_sweeprom.h"

uint32_t g_testReadA[10] = {0};
unsigned char g_version[50] = "V3.1_"__DATE__
                              "_"__TIME__;
unsigned int g_Write[2] = {0};
unsigned int g_test1 = 0;
unsigned int g_test2 = 0;
unsigned int g_test3 = 0;
unsigned int g_test4 = 0;
/**
 * @brief main function
 *
 * @param[in] none
 * @return none
 */
int main(void)
{
    InitDelay();

    SWEEPROM_Init(512, 31);

    EFLASH_UnlockCtrl();

    SWEEPROM_Read(0, (uint16_t *)g_testReadA, 1);
    if (g_testReadA[0] == 0xffff)
    {
        g_test1 = g_version[0] & 0x00ff;
        g_test2 = (g_version[1] << 8) & 0xff00;
        g_Write[0] = g_test1 + g_test2;
        SWEEPROM_Write(0, (uint16_t *)&g_Write[0], 1);
        g_test1 = g_version[2] & 0x00ff;
        g_test2 = (g_version[3] << 8) & 0xff00;
        g_Write[0] = g_test1 + g_test2;
        SWEEPROM_Write(1, (uint16_t *)&g_Write[0], 1);

        g_test1 = g_version[4] & 0x00ff;
        g_test2 = (g_version[5] << 8) & 0xff00;
        g_Write[0] = g_test1 + g_test2;
        SWEEPROM_Write(2, (uint16_t *)&g_Write[0], 1);
        g_test1 = g_version[6] & 0x00ff;
        g_test2 = (g_version[7] << 8) & 0xff00;
        g_Write[0] = g_test1 + g_test2;
        SWEEPROM_Write(3, (uint16_t *)&g_Write[0], 1);

        g_test1 = g_version[8] & 0x00ff;
        g_test2 = (g_version[9] << 8) & 0xff00;
        g_Write[0] = g_test1 + g_test2;
        SWEEPROM_Write(4, (uint16_t *)&g_Write[0], 1);
        g_test1 = g_version[10] & 0x00ff;
        g_test2 = (g_version[11] << 8) & 0xff00;
        g_Write[0] = g_test1 + g_test2;
        SWEEPROM_Write(5, (uint16_t *)&g_Write[0], 1);


        g_test1 = g_version[12] & 0x00ff;
        g_test2 = (g_version[13] << 8) & 0xff00;
        g_Write[0] = g_test1 + g_test2;
        SWEEPROM_Write(6, (uint16_t *)&g_Write[0], 1);
        g_test1 = g_version[14] & 0x00ff;
        g_test2 = (g_version[15] << 8) & 0xff00;
        g_Write[0] = g_test1 + g_test2;
        SWEEPROM_Write(7, (uint16_t *)&g_Write[0], 1);


        g_test1 = g_version[16] & 0x00ff;
        g_test2 = (g_version[7] << 8) & 0xff00;
        g_Write[0] = g_test1 + g_test2;
        SWEEPROM_Write(8, (uint16_t *)&g_Write[0], 1);
        g_test1 = g_version[18] & 0x00ff;
        g_test2 = (g_version[19] << 8) & 0xff00;
        g_Write[0] = g_test1 + g_test2;
        SWEEPROM_Write(9, (uint16_t *)&g_Write[0], 1);
    }

    while (1)
    {
        int a = 0;
    }
}
相关推荐
ysu_03143 小时前
TinyML 模型部署:从 Edge Impulse 到 STM32F103
驱动开发·stm32·嵌入式硬件·mcu·硬件架构·硬件工程·dsp开发
邵奈一16 小时前
【紧急处理ZCode事件】ZCode 工作区快照静默上传:检测方法与三层防护实践
人工智能·学习·大模型·国产
youyou-06061 天前
Classic AUTOSAR 中 CAN 协议栈整体架构
mcu·面试·汽车
意法半导体STM323 天前
【官方原创】LAT1709STM32C5硬件CRC值的计算话题
stm32·单片机·嵌入式硬件·mcu·crc·微控制器·stm32c5
国科安芯3 天前
低轨卫星姿轨控系统中高可靠嵌入式控制单元的设计与验证
单片机·mcu·低轨卫星·星间链路·卫星姿轨控
国科安芯4 天前
卫星电源管理系统中宽温域低功耗MCU的选型与适应性分析
嵌入式硬件·mcu·抗干扰·抗辐射·宽温
youcans_4 天前
【嵌入式软件AI编程】09. 使用VS Code调试STM32程序
stm32·mcu·ai编程·嵌入式软件·claude code
国科安芯4 天前
寄存器级 Flash 擦除与六轮迭代踩坑实录
嵌入式硬件·mcu·架构·flash·抗辐射·eflash
Groundwork Explorer4 天前
ESP32-C3 SuperMini 排查WIFI收发故障
python·单片机·嵌入式硬件·mcu
星源~5 天前
Linux - Trae Code Linux 环境嵌入式开发指南
linux·mcu·嵌入式·trae code