📄 get_chip_id.c
字号:
//*----------------------------------------------------------------------------
//* ATMEL Microcontroller Software Support - ROUSSET -
//*----------------------------------------------------------------------------
//* The software is delivered "AS IS" without warranty or condition of any
//* kind, either express, implied or statutory. This includes without
//* limitation any warranty or condition with respect to merchantability or
//* fitness for any particular purpose, or against the infringements of
//* intellectual property rights of others.
//*----------------------------------------------------------------------------
//* File Name : get_chip_id.c
//* Object : get the chip ID
//*
//* 1.0 03/11/00 JPP : Creation
//*----------------------------------------------------------------------------
//* --------------------------- include file ----------------------------------
#include <stdio.h>
#include "periph/special_function/lib_sf.h"
//*----------------------------------------------------------------------------
//* Function Name : get_chip_id
//* Object : Write the chip ID
//* Input Parameters : <*message> string to write
//* Output Parameters : <message> update
//*----------------------------------------------------------------------------
void get_chip_id( char *string)
{
//* Read one of the Chip Identification Registers
int value;
int len=0;
value = at91_read_chip_id(0);
// * Non Volatile Program Memory Type
len += sprintf(&string[len],"AT91");
switch (SF_NVPTYP&value)
{
case SF_NVPTYP_M:
len += sprintf(&string[len],"m");
break;
case SF_NVPTYP_C:
len += sprintf(&string[len],"c");
break;
case SF_NVPTYP_S:
len += sprintf(&string[len],"s");
break;
case SF_NVPTYP_R:
len += sprintf(&string[len],"r");
break;
default:
len += sprintf(&string[len],"xx");
break;
}
//* Chip Architecture
len += sprintf(&string[len],"%02X",(SF_ARCH&value)>>20);
//* Volatile Data Memory Size
len += sprintf(&string[len],"%01X",(SF_VDSIZ&value)>>16);
len += sprintf(&string[len],"0");
//* Non Volatile Program Memory Size
switch (SF_NVPSIZ&value)
{
case SF_NVPSIZ_NONE:
len += sprintf(&string[len],"0");
break;
case SF_NVPSIZ_32K:
len += sprintf(&string[len],"5");
break;
case SF_NVPSIZ_64K:
len += sprintf(&string[len],"6");
break;
case SF_NVPSIZ_128K:
len += sprintf(&string[len],"7");
break;
case SF_NVPSIZ_256K:
len += sprintf(&string[len],"8");
break;
default:
len += sprintf(&string[len],"xx");
break;
}
//* Chip Version
len += sprintf(&string[len]," Version:%X", SF_VERSION & value);
//* End
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -