6 changed files with 30 additions and 105 deletions
-
40basic/sn.c
-
38basic/sn.h
-
2basic/zbase.h
-
28basic/zflash.c
-
24basic/zflash.h
-
1zbasic.h
@ -1,40 +0,0 @@ |
|||
#include "sn.h" |
|||
|
|||
#include <stdbool.h> |
|||
#include <stdlib.h> |
|||
#include <string.h> |
|||
#include <stdio.h> |
|||
|
|||
/******************************************************************************* |
|||
* EXTERN * |
|||
*******************************************************************************/ |
|||
|
|||
static sn_t m_sn; |
|||
|
|||
sn_t* xs_device_info_get() { // |
|||
sn_t* info = (sn_t*)DEVICE_INFO_START_ADD; |
|||
m_sn = *info; |
|||
|
|||
if (m_sn.year < 0) { |
|||
m_sn.year = 0; |
|||
} |
|||
|
|||
if (m_sn.weak < 0) { |
|||
m_sn.weak = 0; |
|||
} |
|||
|
|||
if (m_sn.index < 0) { |
|||
m_sn.index = 0; |
|||
} |
|||
|
|||
return &m_sn; |
|||
} |
|||
|
|||
const char* sn_get_str() { |
|||
sn_t* info = xs_device_info_get(); |
|||
static char sn_str[32]; |
|||
|
|||
|
|||
sprintf(sn_str, "%s%02ld%02ld%04ld", SN_HEADER, info->year, info->weak, info->index); |
|||
return sn_str; |
|||
} |
@ -1,38 +0,0 @@ |
|||
#pragma once |
|||
#include <stdbool.h> |
|||
|
|||
#include "main.h" |
|||
#include "project_configs.h" |
|||
|
|||
/** |
|||
* @brief |
|||
* STM32F407VETx 1024k |
|||
* |
|||
* index startAdd size |
|||
* 0 0x08000000 16k |
|||
* 1 0x08004000 16k |
|||
* 2 0x08008000 16k |
|||
* 3 0x0800C000 16k |
|||
* 4 0x08010000 64k |
|||
* 5 0x08020000 128k |
|||
* 6 0x08040000 128k |
|||
* 7 0x08060000 128k |
|||
* 8 0x08080000 128k |
|||
* 9 0x080A0000 128k |
|||
* 10 0x080C0000 128k |
|||
* 11 0x080E0000 128k |
|||
* |
|||
* |
|||
* @WARNING: |
|||
*/ |
|||
|
|||
#define DEVICE_INFO_START_ADD SDK_CFG__SN_FLASH_ADDR // |
|||
|
|||
typedef struct { |
|||
int32_t year; |
|||
int32_t weak; |
|||
int32_t index; |
|||
} sn_t; |
|||
|
|||
sn_t* sn_get(); |
|||
const char* sn_get_str(); |
Write
Preview
Loading…
Cancel
Save
Reference in new issue