杰发科技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;
    }
}
相关推荐
Wx120不知道取啥名2 天前
微控制器(MCU)如何运行存储在Flash的程序???
单片机·嵌入式硬件·mcu
CyberSecurity_zhang2 天前
多核架构的基本概念
mcu·汽车·amp·smp·同构多核·异构多核
马浩同学3 天前
【ESP32】ESP-IDF开发 | I2C从机接收i2c_slave_receive函数的BUG导致程序崩溃解决(idf-v5.3.1版本)
c语言·单片机·嵌入式硬件·mcu·bug
youcans_4 天前
【动手学电机驱动】 STM32-FOC(2)STM32 导入和创建项目
stm32·单片机·嵌入式硬件·mcu·电机
@haihi4 天前
IIC和SPI的区别和相同之处
arm开发·stm32·mcu
7yewh5 天前
嵌入式硬件重点(四)常用信号处理、放大电路、运算放大器(运放)基础篇
stm32·单片机·嵌入式硬件·mcu·51单片机·proteus·硬件工程
鼎盛合设计开发6 天前
宠物自动喂食器方案芯片
单片机·mcu
7yewh6 天前
嵌入式硬件电子电路设计(三)电源电路之负电源
stm32·单片机·嵌入式硬件·mcu·51单片机·proteus
ShiinaKaze6 天前
用图说明 CPU、MCU、MPU、SoC 的区别
mcu·cpu·mpu·soc·计算机架构
陌夏微秋8 天前
00 硬件、嵌入式硬件知识-目录篇
linux·stm32·单片机·嵌入式硬件·mcu·ubuntu