主程序如下。
#include <stm32f10x.h>
#include <stm32f10x_gpio.h>
#define RCC_GPIO_ADF4156 RCC_APB2Periph_GPIOD
#define GPIO_ADF4156_PORT GPIOD
#define GPIO_ADF4156_CLK GPIO_Pin_1
#define GPIO_ADF4156_DATA GPIO_Pin_2
#define GPIO_ADF4156_LE GPIO_Pin_3
#define GPIO_ADF4156_ALL GPIO_ADF4156_LE |GPIO_ADF4156_DATA |GPIO_ADF4156_CLK
//延时程序
void delay (int length)
{
while (length >0)
length--;
}
void ADF4156_config(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_GPIO_ADF4156,ENABLE);
GPIO_InitStructure.GPIO_Pin=GPIO_ADF4156_ALL;
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP;
GPIO_Init(GPIO_ADF4156_PORT,&GPIO_InitStructure);
}
//写入4156数据程序
void WriteToADF4156(unsigned char count, unsigned char *buf)
{
unsigned char ValueToWrite = 0;
unsigned char i = 0;
unsigned char j = 0;
delay(1);
/* GPIO_ADF4156_CLK=0; */
GPIO_ResetBits(GPIOD, GPIO_Pin_1);
/* GPIO_ADF4156_LE=0; */
GPIO_ResetBits(GPIOD, GPIO_Pin_3);
delay(1);
for(i=count;i>0;i--)
{
ValueToWrite = *(buf + i - 1);
for(j=0; j<8; j++)
{
if(0x80 == (ValueToWrite & 0x80))
{
/* GPIO_ADF4156_DATA=1; //Send one to SDO pin*/
GPIO_SetBits(GPIOD, GPIO_Pin_2);
}
else
{
/* GPIO_ADF4156_DATA=0; //Send zero to SDO pin */
GPIO_ResetBits(GPIOD, GPIO_Pin_2);
}
delay(1);
/* GPIO_ADF4156_CLK=1;*/
GPIO_SetBits(GPIOD, GPIO_Pin_1);
delay(1);
ValueToWrite <<= 1; //Rotate data
/* GPIO_ADF4156_CLK=0;*/
GPIO_ResetBits(GPIOD, GPIO_Pin_1);
}
}
/* GPIO_ADF4156_DATA=0;*/
GPIO_ResetBits(GPIOD, GPIO_Pin_2);
delay(1);
/* GPIO_ADF4156_LE=1;*/
GPIO_SetBits(GPIOD, GPIO_Pin3);
delay(1);
/* GPIO_ADF4156_LE=0;*/
GPIO_ResetBits(GPIOD, GPIO_Pin_3);
}
int main (void)
{
ADF4156_config();
WriteToADF4156();
}
错误的报告如下,我就不知道怎么和头文件有问题了?
compiling ADF4156spi.c...
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h(23): error: #256: invalid redeclaration of type name "s32" (declared at line 312 of "C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x.h")
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: typedef signed long s32;
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: ^
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h(27): error: #256: invalid redeclaration of type name "sc32" (declared at line 316 of "C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x.h")
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: typedef signed long const sc32; /* Read Only */
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: ^
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h(31): error: #256: invalid redeclaration of type name "vs32" (declared at line 320 of "C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x.h")
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: typedef volatile signed long vs32;
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: ^
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h(35): error: #256: invalid redeclaration of type name "vsc32" (declared at line 324 of "C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x.h")
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: typedef volatile signed long const vsc32; /* Read Only */
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: ^
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h(39): error: #256: invalid redeclaration of type name "u32" (declared at line 328 of "C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x.h")
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: typedef unsigned long u32;
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: ^
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h(43): error: #256: invalid redeclaration of type name "uc32" (declared at line 332 of "C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x.h")
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: typedef unsigned long const uc32; /* Read Only */
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: ^
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h(47): error: #256: invalid redeclaration of type name "vu32" (declared at line 336 of "C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x.h")
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: typedef volatile unsigned long vu32;
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: ^
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h(51): error: #256: invalid redeclaration of type name "vuc32" (declared at line 340 of "C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x.h")
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: typedef volatile unsigned long const vuc32; /* Read Only */
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: ^
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h(55): error: #101: "FALSE" has already been declared in the current scope
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: typedef enum {FALSE = 0, TRUE = !FALSE} bool;
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: ^
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h(55): error: #101: "TRUE" has already been declared in the current scope
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: typedef enum {FALSE = 0, TRUE = !FALSE} bool;
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: ^
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h(55): error: #256: invalid redeclaration of type name "bool" (declared at line 345 of "C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x.h")
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: typedef enum {FALSE = 0, TRUE = !FALSE} bool;
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: ^
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h(57): error: #101: "RESET" has already been declared in the current scope
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: typedef enum {RESET = 0, SET = !RESET} FlagStatus, ITStatus;
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: ^
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h(57): error: #101: "SET" has already been declared in the current scope
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: typedef enum {RESET = 0, SET = !RESET} FlagStatus, ITStatus;
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: ^
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h(57): error: #256: invalid redeclaration of type name "FlagStatus" (declared at line 348 of "C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x.h")
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: typedef enum {RESET = 0, SET = !RESET} FlagStatus, ITStatus;
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: ^
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h(57): error: #256: invalid redeclaration of type name "ITStatus" (declared at line 348 of "C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x.h")
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: typedef enum {RESET = 0, SET = !RESET} FlagStatus, ITStatus;
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: ^
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h(59): error: #101: "DISABLE" has already been declared in the current scope
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: typedef enum {DISABLE = 0, ENABLE = !DISABLE} FunctionalState;
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: ^
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h(59): error: #101: "ENABLE" has already been declared in the current scope
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: typedef enum {DISABLE = 0, ENABLE = !DISABLE} FunctionalState;
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: ^
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h(59): error: #256: invalid redeclaration of type name "FunctionalState" (declared at line 350 of "C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x.h")
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: typedef enum {DISABLE = 0, ENABLE = !DISABLE} FunctionalState;
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: ^
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h(62): error: #101: "ERROR" has already been declared in the current scope
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: typedef enum {ERROR = 0, SUCCESS = !ERROR} ErrorStatus;
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: ^
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h(62): error: #101: "SUCCESS" has already been declared in the current scope
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: typedef enum {ERROR = 0, SUCCESS = !ERROR} ErrorStatus;
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: ^
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h(62): error: #256: invalid redeclaration of type name "ErrorStatus" (declared at line 353 of "C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x.h")
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: typedef enum {ERROR = 0, SUCCESS = !ERROR} ErrorStatus;
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h: ^
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_conf.h(147): warning: #47-D: incompatible redefinition of macro "HSE_Value" (declared at line 83 of "C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x.h")
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_conf.h: #define HSE_Value ((u32)8000000) /* Value of the External oscillator in Hz*/
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_conf.h: ^
C:\Keil\ARM\INC\ST\STM32F10x\cortexm3_macro.h(30): error: #55: too many arguments in macro invocation
C:\Keil\ARM\INC\ST\STM32F10x\cortexm3_macro.h: void __ISB(void);
C:\Keil\ARM\INC\ST\STM32F10x\cortexm3_macro.h: ^
C:\Keil\ARM\INC\ST\STM32F10x\cortexm3_macro.h(30): error: #79: expected a type specifier
C:\Keil\ARM\INC\ST\STM32F10x\cortexm3_macro.h: void __ISB(void);
C:\Keil\ARM\INC\ST\STM32F10x\cortexm3_macro.h: ^
C:\Keil\ARM\INC\ST\STM32F10x\cortexm3_macro.h(31): error: #55: too many arguments in macro invocation
C:\Keil\ARM\INC\ST\STM32F10x\cortexm3_macro.h: void __DSB(void);
C:\Keil\ARM\INC\ST\STM32F10x\cortexm3_macro.h: ^
C:\Keil\ARM\INC\ST\STM32F10x\cortexm3_macro.h(31): error: #79: expected a type specifier
C:\Keil\ARM\INC\ST\STM32F10x\cortexm3_macro.h: void __DSB(void);
C:\Keil\ARM\INC\ST\STM32F10x\cortexm3_macro.h: ^
C:\Keil\ARM\INC\ST\STM32F10x\cortexm3_macro.h(32): error: #55: too many arguments in macro invocation
C:\Keil\ARM\INC\ST\STM32F10x\cortexm3_macro.h: void __DMB(void);
C:\Keil\ARM\INC\ST\STM32F10x\cortexm3_macro.h: ^
C:\Keil\ARM\INC\ST\STM32F10x\cortexm3_macro.h(32): error: #79: expected a type specifier
C:\Keil\ARM\INC\ST\STM32F10x\cortexm3_macro.h: void __DMB(void);
C:\Keil\ARM\INC\ST\STM32F10x\cortexm3_macro.h: ^
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_map.h(58): error: #256: invalid redeclaration of type name "ADC_TypeDef" (declared at line 389 of "C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x.h")
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_map.h: } ADC_TypeDef;
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_map.h: ^
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_map.h(154): error: #256: invalid redeclaration of type name "BKP_TypeDef" (declared at line 488 of "C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x.h")
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_map.h: } BKP_TypeDef;
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_map.h: ^
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_map.h(163): error: #256: invalid redeclaration of type name "CAN_TxMailBox_TypeDef" (declared at line 500 of "C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x.h")
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_map.h: } CAN_TxMailBox_TypeDef;
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_map.h: ^
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_map.h: ADF4156spi.c: 1 warning, 30 errors
ADF4156spi.c - 30 Error(s), 1 Warning(s). |