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

📄 main.c

📁 STM32 单片机例程
💻 C
字号:
/*----------------------------------------------------------------------------
QQ: 958664258
21IC用户名:banhushui
交流平台:http://blog.21ic.com/user1/5817/index.html
淘宝店铺:http://shop58559908.taobao.com
旺旺:半壶水电子
编译器版本:MDK3.5
 *---------------------------------------------------------------------------*/

/* Includes ------------------------------------------------------------------*/
#define SYS_GLOBALS
#include "include.h"



void LEDFlash(void)
{static uint32 counter=0;
   
   IntervalTimems(500);
   
   GPIO_Write(GPIOC, (u16)~GPIO_ReadOutputData(GPIOC));
}
/***************************************************************************************
函数名称:void Init_PCCOM(void)
函数功能:串口初始化
输入参数:
输出参数:
函数说明:
**************************************************************************************/
void Init_PCCOM(void)
{
   SetLocalAddr(1);
   InitCom();
   
   USART1_InitConfig(57600);
   
   PC_RS485Receive_Enable();
}
/**************************************************************************************
* 函数原型:PC_COMTask
* 函数功能:串口任务
* 输入参数:
* 输出参数:
* 函数说明:
**************************************************************************************/
void PC_COM_Task(void) //__task
{uint16   cmd;
 static uint32 counter=0;
     
     IntervalTimems(20);
     
     //while(1)
     //{
        //os_evt_wait_or(0x0001, 0xffff);
        
        if( testReceiveOver()==0 ) //有数据
        {
           
           cmd=getCmd();
           if( cmd !=0 )
              PC_ComdCpp(cmd);
           
           init_Receive();//处理完后清空接受缓冲重新开始接收数据
        }
     //}
}

/*******************************************************************************
* Function Name  : main
* Description    : Main program.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
int main(void)
{
#ifdef DEBUG
  debug();
#endif

  /* System Clocks Configuration */
  RCC_Configuration();   

  GPIO_Configuration();

  GPIO_Write(GPIOC, GPIO_Pin_8 | GPIO_Pin_9);

  /* NVIC configuration */
  NVIC_Configuration();

  SysTick_Init();
  //USART_InitConfig(19200);
  Init_PCCOM();
  
  InitTime();
  //DebugSendBuf("abcdefgh\r\n", 10);
  while (1)
  {
    LEDFlash();
    PC_COM_Task();
  }
}



/*END OF FILE*/

⌨️ 快捷键说明

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