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

📄 freescale

📁 Freescale 系列单片机常用模块与综合系统设计
💻
字号:
/** ###################################################################
**     Filename  : RS_485.C
**     Project   : RS_485
**     Processor : MC9S08JM60CLHE
**     Version   : Driver 01.11
**     Compiler  : CodeWarrior HCS08 C Compiler
**     Date/Time : 2009-11-9, 19:20
**     Abstract  :
**         Main module.
**         This module contains user's application code.
**     Settings  :
**     Contents  :
**         No public methods
**
**     (c) Copyright UNIS, spol. s r.o. 1997-2008
**     UNIS, spol. s r.o.
**     Jundrovska 33
**     624 00 Brno
**     Czech Republic
**     http      : www.processorexpert.com
**     mail      : info@processorexpert.com
** ###################################################################*/
/* MODULE RS_485 */


/* Including needed modules to compile this module/procedure */
#include "Cpu.h"
#include "Events.h"
#include "Uart.h"
#include "Device_Addr.h"
#include "Uart_Ctrl.h"
/* Include shared modules, which are used for whole project */
#include "PE_Types.h"
#include "PE_Error.h"
#include "PE_Const.h"
#include "IO_Map.h"

#include "Recv_Tran.h"

//帧头的宏定义
#define ACTIVE   0x11
#define GETDATA  0x22
#define READY    0x33
#define SENDDATA  0x44

extern unsigned char DevNo;

uchar type;


void main(void)
{
  /* Write your local variable definition here */

  /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
  PE_low_level_init();
  /*** End of Processor Expert internal initialization.                    ***/
  DevNo = Device_Addr_GetVal();

  for(;;)
  {
    if(Recv_Data(&type) == 0) //接收帧错误或者地址不符合,丢弃
    {
      continue; 
    } 
    
    switch(type): 
    {
      case ACTIVE:           //主机询问从机是否在线
        Send_Data(READY, 0, StatusBuf);//发送READY命令
        break;
        
      case GETDATA:         //主机读设备请求
        Clr_StatusBuf();    //设备状态信息缓冲区初始化
        Get_Stat();         //数据采集函数
        Send_Data(SENDDATA, strlen(StatusBuf), StatusBuf);//发送设备状态信息
        break;
        
      default:
        break;  
    }
  }
}
/* END RS_485 */
/*
** ###################################################################
**
**     This file was created by UNIS Processor Expert 3.03 [04.07]
**     for the Freescale HCS08 series of microcontrollers.
**
** ###################################################################
*/

⌨️ 快捷键说明

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