IAR编译STM32F417时FPUTC重定义报错:参数类型FILE未定义。求大神指点
自己建的工程,仅用到CMSIS以及inc和src的文件,不知道为什么每次编译时都说fputc的参数类型"FILE"未定义如果用标准库中的EXAMPLE直接rebuild就没有,到底我哪错了,各位高手指点一下
#include "stm32f4xx.h"
#include "stm32f4xx_conf.h"
#include
#include
#ifdef __GNUC__
/* With GCC/RAISONANCE, small printf (option LD Linker->Libraries->Small printf
set to 'Yes') calls __io_putchar() */
#define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
#else
#define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)
#endif /* __GNUC__ */
void GPIO_Config(void);
void USART1_Config(void);
/*******************************************************************************
* Function Name : main
* Description : Main program.
* Input : None
* Output : None
* Return : None
*******************************************************************************/
int main(void)
{
/*GPIO Configuration*/
GPIO_Config();
/*USART1 Configuration*/
USART1_Config();
/* Output a message on Hyperterminal using printf function */
printf("\n\rThis is a printf demo!\n\r");
}
/*******************************************************************************
* Function Name : GPIO_Config
* Description : Configure the GPIO.
* Input : None
* Output : None
* Return : None
*******************************************************************************/
void GPIO_Config(void)
{
RCC_APB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
GPIO_InitTypeDef GPIO_InitStructure;
// Configure the GPIO ports( USART1 Transmit and Receive Lines)
// Configure the USART1_Tx as Alternate function Push-Pull
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOA, &GPIO_InitStructure);
// Configure the USART1_Rx as input floating
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOA, &GPIO_InitStructure);
}
/*******************************************************************************
* Function Name : USART1_Config
* Description : Configures the USART1 Peripheral.
* Input : None
* Output : None
* Return : None
*******************************************************************************/
void USART1_Config(void)
{
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE);
USART_InitTypeDef USART_InitStructure;
/* USARTx configured as follow:
- BaudRate = 115200 baud
- Word Length = 8 Bits
- One Stop Bit
- No parity
- Hardware flow control disabled (RTS and CTS signals)
- Receive and transmit enabled
*/
USART_InitStructure.USART_BaudRate = 115200;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
USART_InitStructure.USART_StopBits = USART_StopBits_1;
USART_InitStructure.USART_Parity = USART_Parity_No;
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
/* Configure the USARTx */
USART_Init(USART1, &USART_InitStructure);
/* Enable the USARTx */
USART_Cmd(USART1, ENABLE);
}
/*******************************************************************************
* Function Name : PUTCHAR_PROTOTYPE
* Description : Retargets the C library printf function to the USART.
* Input : None
* Output : None
* Return : None
*******************************************************************************/
PUTCHAR_PROTOTYPE
{
/*send the content of printf to USRT1*/
USART_SendData(USART1,(uint8_t)ch);
while(USART_GetFlagStatus(USART1,USART_FLAG_TC)!=SET);
return (ch);
}
RE:IAR编译STM32F417时FPUTC重定义报错:参数类型FILE未定义。求大神指点
需要在 IAR的Options -> General Options ->Library Configuration里设置一下函数库,将Library Configuration 中的Library 设置由"Normal"改为"Full"就可以了。回复:IAR编译STM32F417时FPUTC重定义报错:参数类型FILE未定义。求大神指点
试试这个
回复:IAR编译STM32F417时FPUTC重定义报错:参数类型FILE未定义。求大神指点
谢谢啊,改成full果然就好了:)回复第 2 楼 于2013-10-23 09:30:07发表:
需要在 IAR的Options -> General Options ->Library Configuration里设置一下函数库,将Library Configuration 中的Library 设置由"Normal"改为"Full"就可以了。
回复:IAR编译STM32F417时FPUTC重定义报错:参数类型FILE未定义。求大神指点
谢谢,已解决:)回复第 3 楼 于2013-10-23 09:30:30发表:
试试这个
页:
[1]