杰发科技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;
    }
}
相关推荐
范纹杉想快点毕业2 天前
ZYNQ PS 端 UART 接收数据数据帧(初学者友好版)嵌入式编程 C语言 c++ 软件开发
c语言·笔记·stm32·单片机·嵌入式硬件·mcu·51单片机
电子科技圈2 天前
芯科科技FG23L无线SoC现已全面供货,为Sub-GHz物联网应用提供最佳性价比
科技·嵌入式硬件·mcu·物联网·制造·智能硬件·交通物流
意法半导体STM323 天前
运行 Ux_Host_HUB_HID_MSC 通过 Hub 连接 U 盘读写不稳定问题分析 LAT1511
mcu·usb·st·hub·usb_otg_hs·filex·u 盘
路弥行至5 天前
从0°到180°,STM32玩转MG996R舵机
c语言·数据库·stm32·单片机·嵌入式硬件·mcu·mongodb
索迪迈科技5 天前
基于野火F407开发板实现电源管理-停止模式
c语言·stm32·单片机·嵌入式硬件·mcu
方案开发PCBA抄板芯片解密5 天前
MCU、CPLD、DSP、FPGA 有什么区别,该如何选择?
mcu
蜀黍@猿6 天前
【GD32】存储器架构介绍
单片机·mcu
伴杯猫6 天前
【ESP32-IDF】基础外设开发2:系统中断矩阵
c语言·单片机·嵌入式硬件·mcu·物联网·github
【ql君】qlexcel6 天前
MCU上电到运行的全过程
单片机·嵌入式硬件·mcu·启动过程
今日待办9 天前
Arduino Nano33 BLESense Rev2【室内空气质量检测语音识别蓝牙调光台灯】
c语言·单片机·嵌入式硬件·mcu·语音识别·ardunio·arduinonano33