杰发科技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;
    }
}
相关推荐
minglie19 小时前
树莓派Pico‌的hc595例子
mcu
The️13 小时前
STM32-FreeRTOS操作系统-事件
arm开发·stm32·单片机·嵌入式硬件·mcu·物联网
意法半导体STM322 天前
【官方原创】使用STM32N6测试Helium指令 LAT1567
stm32·单片机·嵌入式硬件·mcu·stm32开发
飞来客isdn3 天前
GD32F407ZGT6在FreeRTOS下串口中断接收异常情况及解决方法
单片机·mcu·freertos·信息与通信
光子物联单片机4 天前
STM32单片机开发入门(十一)STM32CubeIDE下载安装及开发调试说明
c语言·stm32·单片机·嵌入式硬件·mcu
FPGA_ADDA4 天前
基于28DR+VU13P的宽带高速信号处理板
信号处理·国产·全国产·复旦微fpga-vu13p·复旦微rfsoc-28dr·宽带高速信号
Bigan(安)4 天前
【奶茶Beta专项】【LVGL9.4源码分析】09-core-obj_class对象类系统
linux·c语言·mcu·arm·unix
Bigan(安)4 天前
【奶茶Beta专项】【LVGL9.4源码分析】08-theme主题管理
linux·c语言·mcu·arm·unix
minglie14 天前
树莓派Pico‌的freeRtos
mcu
Bigan(安)5 天前
【奶茶Beta专项】【LVGL9.4源码分析】09-core-global全局核心管理
linux·c语言·mcu·arm·unix