The solid state library defines 24 Variable types , Their type and size are fixed . In the file stm32f10x_type.h We define this

<> variable :
typedef signed long s32; typedef signed short s16; typedef signed char s8;
typedef signed long const sc32; /* Read Only */ typedef signed short const sc16;
/* Read Only */ typedef signed char const sc8; /* Read Only */ typedef volatile
signed long vs32; typedef volatile signed short vs16; typedef volatile signed
char vs8; typedef volatile signed long const vsc32; /* Read Only */ typedef
volatile signed short const vsc16; /* Read Only */ typedef volatile signed char
const vsc8; /* Read Only */ typedef unsigned long u32; typedef unsigned short
u16; typedef unsigned char u8; typedef unsigned long const uc32; /* Read Only */
typedef unsigned short const uc16; /* Read Only */ typedef unsigned char const
uc8; /* Read Only */ typedef volatile unsigned long vu32; typedef volatile
unsigned short vu16; typedef volatile unsigned char vu8; typedef volatile
unsigned long const vuc32; /* Read Only */ typedef volatile unsigned short const
vuc16; /* Read Only */ typedef volatile unsigned char const vuc8; /* Read Only
<> Boolean type

In the file stm32f10x_type.h in , Boolean variables are defined as follows :
typedef enum { FALSE = 0, TRUE = !FALSE } bool;
<> Flag bit status type

In the file stm32f10x_type.h in , We define the flag bit type ( FlagStatus type) Of 2 Possible values are “ set up ” And “ Reset ”( SET
or RESET).
typedef enum { RESET = 0, SET = !RESET } FlagStatus;
<> Functional state type

In the file stm32f10x_type.h in , We define functional state types ( FunctionalState type) Of 2 Possible values are “ Enable ” And “ lose
can ”( ENABLE or DISABLE).
typedef enum { DISABLE = 0, ENABLE = !DISABLE } FunctionalState;
<> Error status type

In the file stm32f10x_type.h in , Our error state type type ( ErrorStatus type) Of 2 Possible values are “ success ” And “ error ”
typedef enum { ERROR = 0, SUCCESS = !ERROR } ErrorStatus;
<> peripheral

Users can access the control register of each peripheral through the pointer to each peripheral . These pointers point to the data structure and the control of various peripherals
One to one correspondence of register layout .
Structure of peripheral control register
file stm32f10x_map.h It contains the structure of all peripheral control registers , The following example is SPI Declaration of register structure :
/*------------------ Serial Peripheral Interface ----------------*/ typedef
struct { vu16 CR1; u16 RESERVED0; vu16 CR2; u16 RESERVED1; vu16 SR; u16
RESERVED2; vu16 DR; u16 RESERVED3; vu16 CRCPR; u16 RESERVED4; vu16 RXCRCR; u16
Register naming follows the rules of register abbreviation in the previous section . RESERVEDi( i The value is an integer index ) Represents the reserved area .

<> Peripheral statement
file stm32f10x_map.h Contains the declaration of all peripherals , The following example is SPI Declaration of peripherals : #ifndef EXT #Define EXT extern #
endif ... #define PERIPH_BASE ((u32)0x40000000) #define APB1PERIPH_BASE
PERIPH_BASE #define APB2PERIPH_BASE (PERIPH_BASE + 0x10000) ... /* SPI2 Base
Address definition*/ #define SPI2_BASE (APB1PERIPH_BASE + 0x3800) ... /* SPI2
peripheral declaration*/ #ifndef DEBUG ... #ifdef _SPI2 #define SPI2
((SPI_TypeDef *) SPI2_BASE) #endif /*_SPI2 */ ... #else /* DEBUG */ ... #ifdef
_SPI2 EXT SPI_TypeDef *SPI2; #endif /*_SPI2 */ ... #endif /* DEBUG */
If the user wants to use peripherals SPI, Then it has to be in the file stm32f10x_conf.h Defined in _SPI label
By defining the label _SPIn, Users can access peripherals SPIn Register of . for example , User must be in file stm32f10x_conf.h Defined in
label _SPI2, Otherwise, it cannot be accessed SPI2 Of the register . In the file stm32f10x_conf.h in , The user can define the label according to the following example
_SPI and _SPIn
#define _SPI #define _SPI1 #define _SPI2

   Each peripheral has several registers specially assigned to flag bits . We define these registers according to the corresponding structure . Designation of flag bit , Also follow the peripheral abbreviation specification in the previous section , with ‘PPP_FLAG_’ start . For different peripherals , Flag bits are defined in the corresponding file stm32f10x_ppp.h
in .
The user wants to enter debugging ( DEBUG) Mode , Must be in file stm32f10x_conf.h Label defined in DEBUG.
   This will be in the SRAM Creates a pointer to the peripheral structure part of . So we can simplify the debugging process , The status of all registers can be obtained by dumping peripheral devices . In all cases , SPI2
It's all a pointing peripheral SPI2 Pointer to the first address .
   variable DEBUG You can follow the example below :
#define DEBUG 1
Can be initialized DEBUG Models and documents stm32f10x_lib.c As follows :
#ifdef DEBUG void debug(void) { ... #ifdef _SPI2 SPI2 = (SPI_TypeDef *)
SPI2_BASE; #endif /*_SPI2 */ ... } #endif /* DEBUG*/
Note: 1 When the user chooses DEBUG pattern , macro assert_param Expanded , At the same time, the runtime check function is also activated in the solid-state library code .
Note: 2 get into DEBUG Patterns increase the size of the code , Reduce code efficiency . therefore , We strongly recommend using the code only for debugging , In the final application , Delete them .