goldseeker
Newbie level 1
- Joined
- Jul 26, 2013
- Messages
- 1
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 56
this is the code (main.c) i have 8 errors:
/* Includes ------------------------------------------------------------------*/
#include "stm32f4xx.h"
/* Private typedef -----------------------------------------------------------*/
typedef enum { FAILED = 0, PASSED = !FAILED} TestStatus;
/* Private define ------------------------------------------------------------*/
#define USARTy USART1
#define USARTy_GPIO GPIOA
#define USARTy_CLK RCC_APB2Periph_USART1
#define USARTy_GPIO_CLK RCC_APB2Periph_GPIOA
#define USARTy_RxPin GPIO_Pin_10
#define USARTy_TxPin GPIO_Pin_9
#define TxBufferSize (countof(TxBuffer))
/* Private macro -------------------------------------------------------------*/
#define countof(a) (sizeof(a) / sizeof(*(a)))
/* Private variables ---------------------------------------------------------*/
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
TIM_OCInitTypeDef TIM_OCInitStructure;
TIM_ICInitTypeDef TIM_ICInitStructure;
USART_InitTypeDef USART_InitStructure;
GPIO_InitTypeDef GPIO_InitStructure;
uint8_t TxBuffer[] = "$PSRF102,1,2580,8,1,0*0F",Month,Day,Hour,Minute,second;
uint8_t RxBuffer[100],DataRecieve,*decDat[5],InitPORT[]={0xA0,0xA2,0x00,0x09,0x86,0x00,0x00,0x96,0x00,0x08,0x01,0x00,0x00,0x01,0x025,0xB0,0xB3};
uint16_t Year,speed;
uint32_t latitude,longitude,itmp;
__IO uint8_t TxCounter = 0, RxCounter = 0,i=0,j=0,index = 0;
volatile TestStatus TransferStatus = FAILED;
/* Private function prototypes -----------------------------------------------*/
void RCC_Configuration(void);
void GPIO_Configuration(void);
void NVIC_Configuration(void);
TestStatus Buffercmp(uint8_t* pBuffer1, uint8_t* pBuffer2, uint16_t BufferLength);
void Delay(__IO uint32_t nCount);
void decode_Data(void);
/* Private functions ---------------------------------------------------------*/
void RCC_Configuration(void)
{
/* Enable GPIO clock */
SystemInit();
/* TIM3 clock enable */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE);
RCC_APB2PeriphClockCmd(USARTy_GPIO_CLK | RCC_APB2Periph_AFIO|USARTy_CLK, ENABLE); ERROR IN THIS "RCC_APB2Periph_AFIO"
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC,ENABLE); ERROR IN THIS "RCC_APB2Periph_GPIOC"
}
void GPIO_Configuration(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
//USART1+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
GPIO_DeInit(GPIOA);
GPIO_InitStructure.GPIO_Pin =USARTy_RxPin;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; ERROR IIN THIS " GPIO_Mode_IN_FLOATING"
GPIO_Init(USARTy_GPIO, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin =USARTy_TxPin;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; ERROR IN THIS "GPIO_Mode_AF_PP"
GPIO_Init(USARTy_GPIO, &GPIO_InitStructure);
//=============================================================
GPIO_InitStructure.GPIO_Pin =GPIO_Pin_0;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPD;
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_DeInit(GPIOC);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_9;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOC, &GPIO_InitStructure);
GPIO_PinRemapConfig(GPIO_FullRemap_TIM3, ENABLE); ERROR IN THIS" GPIO_FullRemap_TIM3"
}
//void NVIC_Configuration(void)
//{
// NVIC_InitTypeDef NVIC_InitStructure;
/* Enable the TIM3 global Interrupt */
//NVIC_InitStructure.NVIC_IRQChannel = TIM3_IRQn;
//NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
//NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
//NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
//NVIC_Init(&NVIC_InitStructure);
//}
int main(void)
{
RCC_Configuration();
GPIO_Configuration();
//NVIC_Configuration();
USART_DeInit(USART1);
USART_InitStructure.USART_BaudRate = 38400;
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;
USART_Init(USARTy, &USART_InitStructure);
USART_Cmd(USARTy, ENABLE);
while(1)
{
while(USART_GetFlagStatus(USARTy, USART_FLAG_RXNE) == RESET);
DataRecieve=USART_ReceiveData(USARTy);
RxBuffer[RxCounter]=DataRecieve;
if(RxBuffer[RxCounter]==0xA0){
itmp=0;
while(RxCounter<=91){
RxCounter++;
if(RxCounter>=91){
RxCounter=0;
break;
}
while(USART_GetFlagStatus(USARTy, USART_FLAG_RXNE) == RESET);
RxBuffer[RxCounter]=USART_ReceiveData(USARTy);
}
if(RxBuffer[0]==0xA0&&RxBuffer[1]==0xA2&&RxBuffer[2]==0x00&&RxBuffer[3]==0x5B){
GPIO_SetBits(GPIOC,GPIO_Pin_9);
RxCounter=0;
decode_Data();
while(latitude!=0){
GPIO_SetBits(GPIOC,GPIO_Pin_8);
Delay(0xFFFFF);
GPIO_ResetBits(GPIOC,GPIO_Pin_8);
Delay(0xFFFFF);
if(i>=5){break;}
i++;
}
}else{GPIO_ResetBits(GPIOC,GPIO_Pin_9);}
DataRecieve=0;
RxCounter=0;
}/*else{itmp++;}
if(itmp>=5000){
j=0;
itmp=0;
while(j!=17){
USART_SendData(USARTy,InitPORT[j]);
j++;
}
}*/
}
}
void decode_Data(){
uint8_t count=7,i=0;
latitude=0;
longitude=0;
Year=0;
if(RxBuffer[4]==0x29){
count=27;
for(i=0;i<4;i++){
latitude=latitude<<8;
latitude=latitude|RxBuffer[count];
count++;
}
for(i=0;i<4;i++){
longitude=longitude<<8;
longitude=longitude|RxBuffer[count];
count++;
}count=44;
}
}
TestStatus Buffercmp(uint8_t* pBuffer1, uint8_t* pBuffer2, uint16_t BufferLength)
{
while(BufferLength--)
{
if(*pBuffer1 != *pBuffer2)
{
return FAILED;
}
pBuffer1++;
pBuffer2++;
}
return PASSED;
}
#ifdef USE_FULL_ASSERT
void assert_failed(uint8_t* file, uint32_t line)
{
/* User can add his own implementation to report the file name and line number,
ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
/* Infinite loop */
while (1)
{
}
}
#endif
void Delay(__IO uint32_t nCount)
{
for(; nCount != 0; nCount--);
}
can you help me plzase , thanks
/* Includes ------------------------------------------------------------------*/
#include "stm32f4xx.h"
/* Private typedef -----------------------------------------------------------*/
typedef enum { FAILED = 0, PASSED = !FAILED} TestStatus;
/* Private define ------------------------------------------------------------*/
#define USARTy USART1
#define USARTy_GPIO GPIOA
#define USARTy_CLK RCC_APB2Periph_USART1
#define USARTy_GPIO_CLK RCC_APB2Periph_GPIOA
#define USARTy_RxPin GPIO_Pin_10
#define USARTy_TxPin GPIO_Pin_9
#define TxBufferSize (countof(TxBuffer))
/* Private macro -------------------------------------------------------------*/
#define countof(a) (sizeof(a) / sizeof(*(a)))
/* Private variables ---------------------------------------------------------*/
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
TIM_OCInitTypeDef TIM_OCInitStructure;
TIM_ICInitTypeDef TIM_ICInitStructure;
USART_InitTypeDef USART_InitStructure;
GPIO_InitTypeDef GPIO_InitStructure;
uint8_t TxBuffer[] = "$PSRF102,1,2580,8,1,0*0F",Month,Day,Hour,Minute,second;
uint8_t RxBuffer[100],DataRecieve,*decDat[5],InitPORT[]={0xA0,0xA2,0x00,0x09,0x86,0x00,0x00,0x96,0x00,0x08,0x01,0x00,0x00,0x01,0x025,0xB0,0xB3};
uint16_t Year,speed;
uint32_t latitude,longitude,itmp;
__IO uint8_t TxCounter = 0, RxCounter = 0,i=0,j=0,index = 0;
volatile TestStatus TransferStatus = FAILED;
/* Private function prototypes -----------------------------------------------*/
void RCC_Configuration(void);
void GPIO_Configuration(void);
void NVIC_Configuration(void);
TestStatus Buffercmp(uint8_t* pBuffer1, uint8_t* pBuffer2, uint16_t BufferLength);
void Delay(__IO uint32_t nCount);
void decode_Data(void);
/* Private functions ---------------------------------------------------------*/
void RCC_Configuration(void)
{
/* Enable GPIO clock */
SystemInit();
/* TIM3 clock enable */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE);
RCC_APB2PeriphClockCmd(USARTy_GPIO_CLK | RCC_APB2Periph_AFIO|USARTy_CLK, ENABLE); ERROR IN THIS "RCC_APB2Periph_AFIO"
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC,ENABLE); ERROR IN THIS "RCC_APB2Periph_GPIOC"
}
void GPIO_Configuration(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
//USART1+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
GPIO_DeInit(GPIOA);
GPIO_InitStructure.GPIO_Pin =USARTy_RxPin;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; ERROR IIN THIS " GPIO_Mode_IN_FLOATING"
GPIO_Init(USARTy_GPIO, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin =USARTy_TxPin;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; ERROR IN THIS "GPIO_Mode_AF_PP"
GPIO_Init(USARTy_GPIO, &GPIO_InitStructure);
//=============================================================
GPIO_InitStructure.GPIO_Pin =GPIO_Pin_0;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPD;
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_DeInit(GPIOC);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_9;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOC, &GPIO_InitStructure);
GPIO_PinRemapConfig(GPIO_FullRemap_TIM3, ENABLE); ERROR IN THIS" GPIO_FullRemap_TIM3"
}
//void NVIC_Configuration(void)
//{
// NVIC_InitTypeDef NVIC_InitStructure;
/* Enable the TIM3 global Interrupt */
//NVIC_InitStructure.NVIC_IRQChannel = TIM3_IRQn;
//NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
//NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
//NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
//NVIC_Init(&NVIC_InitStructure);
//}
int main(void)
{
RCC_Configuration();
GPIO_Configuration();
//NVIC_Configuration();
USART_DeInit(USART1);
USART_InitStructure.USART_BaudRate = 38400;
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;
USART_Init(USARTy, &USART_InitStructure);
USART_Cmd(USARTy, ENABLE);
while(1)
{
while(USART_GetFlagStatus(USARTy, USART_FLAG_RXNE) == RESET);
DataRecieve=USART_ReceiveData(USARTy);
RxBuffer[RxCounter]=DataRecieve;
if(RxBuffer[RxCounter]==0xA0){
itmp=0;
while(RxCounter<=91){
RxCounter++;
if(RxCounter>=91){
RxCounter=0;
break;
}
while(USART_GetFlagStatus(USARTy, USART_FLAG_RXNE) == RESET);
RxBuffer[RxCounter]=USART_ReceiveData(USARTy);
}
if(RxBuffer[0]==0xA0&&RxBuffer[1]==0xA2&&RxBuffer[2]==0x00&&RxBuffer[3]==0x5B){
GPIO_SetBits(GPIOC,GPIO_Pin_9);
RxCounter=0;
decode_Data();
while(latitude!=0){
GPIO_SetBits(GPIOC,GPIO_Pin_8);
Delay(0xFFFFF);
GPIO_ResetBits(GPIOC,GPIO_Pin_8);
Delay(0xFFFFF);
if(i>=5){break;}
i++;
}
}else{GPIO_ResetBits(GPIOC,GPIO_Pin_9);}
DataRecieve=0;
RxCounter=0;
}/*else{itmp++;}
if(itmp>=5000){
j=0;
itmp=0;
while(j!=17){
USART_SendData(USARTy,InitPORT[j]);
j++;
}
}*/
}
}
void decode_Data(){
uint8_t count=7,i=0;
latitude=0;
longitude=0;
Year=0;
if(RxBuffer[4]==0x29){
count=27;
for(i=0;i<4;i++){
latitude=latitude<<8;
latitude=latitude|RxBuffer[count];
count++;
}
for(i=0;i<4;i++){
longitude=longitude<<8;
longitude=longitude|RxBuffer[count];
count++;
}count=44;
}
}
TestStatus Buffercmp(uint8_t* pBuffer1, uint8_t* pBuffer2, uint16_t BufferLength)
{
while(BufferLength--)
{
if(*pBuffer1 != *pBuffer2)
{
return FAILED;
}
pBuffer1++;
pBuffer2++;
}
return PASSED;
}
#ifdef USE_FULL_ASSERT
void assert_failed(uint8_t* file, uint32_t line)
{
/* User can add his own implementation to report the file name and line number,
ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
/* Infinite loop */
while (1)
{
}
}
#endif
void Delay(__IO uint32_t nCount)
{
for(; nCount != 0; nCount--);
}
can you help me plzase , thanks