代码
main.c
#include "MyIncludes.h"
char buff[100];
//用来存储身份信息
CHIP_ID_TypeDef stm32_id;
//id结构体变量声明
uint32_t flash_size = 0;
//flash大小变量
u16 sys_cnt = 0;
void systick_isr(void)
{
if(sys_cnt <1000)
sys_cnt++;
else
{
sys_cnt = 0;
HAL_GPIO_TogglePin(GPIOC,GPIO_PIN_4|GPIO_PIN_5);
}
}
int main()
{
System_Init();
SysTick_Init(systick_isr);
LED_Init();
USART1_Init(115200,NULL,NULL);
ChipID_Get(&stm32_id);
//获取芯片ID
flash_size = ChipFlashSize_Get();
//获取芯片大小
sprintf(buff,"CHIP ID: %d%d%d\r\n",stm32_id.ID_H,stm32_id.ID_M,stm32_id.ID_L);
//将信息存储在buff数组中
printf(buff);
//打印buff数组数据
sprintf(buff,"CHIP FLASH: %dKB\r\n",flash_size);
printf(buff);
while(1)
{
}
}
|