⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 基于STM32串口-CAN函数包.其中,串口以中断形式接受,C
💻 C
字号:
#include<stm32f10x_lib.h>
#include<stdio.h>
//申明调用外部函数
extern void SetupClock  (void);
extern void SetupUART   (void);
extern int GetKey (void) ;
extern int SendChar (int ch) ;
//申明内部函数
void NVIC_Configuration(void);

void Init(void) ;


int receved_code=0;
main()			 
{Init();
 printf("how are you!!\nwelecome !");
 while (1)
   {receved_code=GetKey();
 
   if(receved_code==0x05)
   		printf("yes,have receved!\n");
	else
	   ;
   }
}
  void Init(void)
   {SetupClock();
    NVIC_Configuration();
    SetupUART();
   }


   /*******************************************************************************
   * Function Name	: NVIC_Configuration
   * Description	: Configures the nested vectored interrupt controller.
   * Input			: None
   * Output 		: None
   * Return 		: None
   *******************************************************************************/
   void NVIC_Configuration(void)
   {
  NVIC_InitTypeDef NVIC_InitStructure;

#ifdef  VECT_TAB_RAM  
  /* Set the Vector Table base location at 0x20000000 */ 
  NVIC_SetVectorTable(NVIC_VectTab_RAM, 0x0); 
#else  /* VECT_TAB_FLASH  */
  /* Set the Vector Table base location at 0x08000000 */ 
  NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0);   
#endif

  /* Enable the USART1 Interrupt */
  NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQChannel;
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&NVIC_InitStructure);
  }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -