杰发科技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;
    }
}
相关推荐
上层精灵的赞美诗7 分钟前
电子工程师转战汽车OEM主机厂之路
单片机·嵌入式硬件·mcu·eclipse·汽车
猫猫的小茶馆4 小时前
【PCB工艺】基础:电子元器件
stm32·单片机·嵌入式硬件·mcu·51单片机·pcb工艺
阿巴~阿巴~4 小时前
STM32 —— MCU、MPU、ARM、FPGA、DSP
arm开发·stm32·单片机·mcu
猫猫的小茶馆2 天前
【STM32】从新建一个工程开始:STM32 新建工程的详细步骤
stm32·单片机·嵌入式硬件·mcu·51单片机
猫猫的小茶馆2 天前
【STM32】NVIC(嵌套向量中断控制器)
c语言·stm32·单片机·嵌入式硬件·mcu·51单片机
马浩同学4 天前
【ESP32】ESP-IDF开发 | 经典蓝牙开发 | 蓝牙串口协议(SPP) + 客户端和服务端例程
c语言·单片机·嵌入式硬件·mcu·物联网·iot
FreakStudio5 天前
三分钟教学:手把手教你实现Arduino发布第三方库
单片机·mcu·github·嵌入式·arduino·开发工具·电子diy·电子计算机
小麦嵌入式5 天前
Linux驱动开发实战(五):Qt应用程序点RGB灯(保姆级快速入门!)
linux·驱动开发·stm32·嵌入式硬件·mcu·qt·ubuntu
工程师平哥6 天前
【vscode-01】vscode不同项目不同语言扩展插件隔离方案
ide·笔记·vscode·嵌入式硬件·mcu·编辑器
电子科技圈6 天前
芯科科技推出的BG29超小型低功耗蓝牙®无线SoC,是蓝牙应用的理想之选
人工智能·嵌入式硬件·mcu·物联网·健康医疗·智能硬件·iot