久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 2195|回復: 2
打印 上一主題 下一主題
收起左側

急!求大佬幫忙給IAR軟件的一個點C文件的代碼解析!!

[復制鏈接]
跳轉到指定樓層
樓主
ID:271554 發表于 2018-7-5 23:33 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
求大佬幫忙給IAR軟件的一個點C文件的代碼解析!下載我發的附件給每一行注釋越詳細越好,急!

/**************************************************************************************************
  Filename:       SampleApp.c
  Revised:        $Date: 2009-03-18 15:56:27 -0700 (Wed, 18 Mar 2009) $
  Revision:       $Revision: 19453 $

  Description:    Sample Application (no Profile).


  Copyright 2007 Texas Instruments Incorporated. All rights reserved.

  IMPORTANT: Your use of this Software is limited to those specific rights
  granted under the terms of a software license agreement between the user
  who downloaded the software, his/her employer (which must be your employer)
  and Texas Instruments Incorporated (the "License").  You may not use this
  Software unless you agree to abide by the terms of the License. The License
  limits your use, and you acknowledge, that the Software may not be modified,
  copied or distributed unless embedded on a Texas Instruments microcontroller
  or used solely and exclusively in conjunction with a Texas Instruments radio
  frequency transceiver, which is integrated into your product.  Other than for
  the foregoing purpose, you may not use, reproduce, copy, prepare derivative
  works of, modify, distribute, perform, display or sell this Software and/or
  its documentation for any purpose.

  YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
  PROVIDED 揂S IS?WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
  INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
  NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
  TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
  NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
  LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
  INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
  OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
  OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
  (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.

  Should you have any questions regarding your right to use this Software,
  contact Texas Instruments Incorporated at www.TI.com.
**************************************************************************************************/

/*********************************************************************
  This application isn't intended to do anything useful, it is
  intended to be a simple example of an application's structure.

  This application sends it's messages either as broadcast or
  broadcast filtered group messages.  The other (more normal)
  message addressing is unicast.  Most of the other sample
  applications are written to support the unicast message model.

  Key control:
    SW1:  Sends a flash command to all devices in Group 1.
    SW2:  Adds/Removes (toggles) this device in and out
          of Group 1.  This will enable and disable the
          reception of the flash command.
*********************************************************************/

/*********************************************************************
* INCLUDES
*/
#include "OSAL.h"
#include "ZGlobals.h"
#include "AF.h"
#include "aps_groups.h"
#include "ZDApp.h"

#include "SampleApp.h"
#include "SampleAppHw.h"

#include "OnBoard.h"

/* HAL */
#include "hal_lcd.h"
#include "hal_led.h"
#include "hal_key.h"
#include "hal_uart.h"

//#include "MT_UART.h"
#include "MT_APP.h"
#include "MT.h"
#include "DHT11.h"


/*********************************************************************
* MACROS
*/

/*********************************************************************
* CONSTANTS
*/

/*********************************************************************
* TYPEDEFS
*/

/*********************************************************************
* GLOBAL VARIABLES
*/
uint8 AppTitle[] = "ALD2530 DHT11"; //應用程序名稱
halUARTCfg_t uartConfig;

uint8 WARN;
uint8 WT_H = 50;
uint8 WT_L = 20;
uint8 WH_H = 90;
uint8 WH_L = 60;


// This list should be filled with Application specific Cluster IDs.
const cId_t SampleApp_ClusterList[SAMPLEAPP_MAX_CLUSTERS] =
{
  SAMPLEAPP_PERIODIC_CLUSTERID,
  SAMPLEAPP_FLASH_CLUSTERID,
  SAMPLEAPP_P2P_CLUSTERID
};

const SimpleDescriptionFormat_t SampleApp_SimpleDesc =
{
  SAMPLEAPP_ENDPOINT,              //  int Endpoint;
  SAMPLEAPP_PROFID,                //  uint16 AppProfId[2];
  SAMPLEAPP_DEVICEID,              //  uint16 AppDeviceId[2];
  SAMPLEAPP_DEVICE_VERSION,        //  int   AppDevVer:4;
  SAMPLEAPP_FLAGS,                 //  int   AppFlags:4;
  SAMPLEAPP_MAX_CLUSTERS,          //  uint8  AppNumInClusters;
  (cId_t *)SampleApp_ClusterList,  //  uint8 *pAppInClusterList;
  SAMPLEAPP_MAX_CLUSTERS,          //  uint8  AppNumInClusters;
  (cId_t *)SampleApp_ClusterList   //  uint8 *pAppInClusterList;
};

// This is the Endpoint/Interface description.  It is defined here, but
// filled-in in SampleApp_Init().  Another way to go would be to fill
// in the structure here and make it a "const" (in code space).  The
// way it's defined in this sample app it is define in RAM.
endPointDesc_t SampleApp_epDesc;

/*********************************************************************
* EXTERNAL VARIABLES
*/

/*********************************************************************
* EXTERNAL FUNCTIONS
*/

/*********************************************************************
* LOCAL VARIABLES
*/
uint8 SampleApp_TaskID;   // Task ID for internal task/event processing
                          // This variable will be received when
                          // SampleApp_Init() is called.
devStates_t SampleApp_NwkState;

uint8 SampleApp_TransID;  // This is the unique message ID (counter)

afAddrType_t SampleApp_Periodic_DstAddr; //廣播
afAddrType_t SampleApp_Flash_DstAddr;    //組播
afAddrType_t SampleApp_P2P_DstAddr;      //點播

aps_Group_t SampleApp_Group;

uint8 SampleAppPeriodicCounter = 0;
uint8 SampleAppFlashCounter = 0;

/*********************************************************************
* LOCAL FUNCTIONS
*/
void SampleApp_HandleKeys( uint8 shift, uint8 keys );
void SampleApp_MessageMSGCB( afIncomingMSGPacket_t *pckt );
void SampleApp_SendPeriodicMessage( void );
void SampleApp_SendFlashMessage( uint16 flashTime );
void SampleApp_Send_P2P_Message(void);
void Uart_Config(void);
void UartCallBackFunction(uint8 port, uint8 event);
/*********************************************************************
* NETWORK LAYER CALLBACKS
*/

/*********************************************************************
* PUBLIC FUNCTIONS
*/

/*********************************************************************
* @fn      SampleApp_Init
*
* @brief   Initialization function for the Generic App Task.
*          This is called during initialization and should contain
*          any application specific initialization (ie. hardware
*          initialization/setup, table initialization, power up
*          notificaiton ... ).
*
* @param   task_id - the ID assigned by OSAL.  This ID should be
*                    used to send messages and set timers.
*
* @return  none
*/

void Uart_Config(void)  //函數定義;
{

  uartConfig.configured            = TRUE;  //允許配置;
  uartConfig.baudRate              = HAL_UART_BR_115200;//波特率;
  uartConfig.flowControl           = FALSE;
  uartConfig.flowControlThreshold  = 64;   //don't care - see uart driver.
  uartConfig.rx.maxBufSize         = 128;  //串口接收緩沖區大小
  uartConfig.tx.maxBufSize         = 128;  //串口發送緩沖區大小
  uartConfig.idleTimeout           = 6;    //don't care - see uart driver.
  uartConfig.intEnable             = TRUE; //使能中斷
  uartConfig.callBackFunc          = UartCallBackFunction; //指定回調函數名;
}






void SampleApp_Init( uint8 task_id )
{
  SampleApp_TaskID = task_id;
  SampleApp_NwkState = DEV_INIT;
  SampleApp_TransID = 0;
  HalUARTInit ( );
  Uart_Config();
  HalUARTOpen ( HAL_UART_PORT_0, &uartConfig );




  //MT_UartInit();                  //串口初始化
  //MT_UartRegisterTaskID(task_id); //注冊串口任務
  P0SEL &= 0x7f;                  //P0_7配置成通用io

  // Device hardware initialization can be added here or in main() (Zmain.c).
  // If the hardware is application specific - add it here.
  // If the hardware is other parts of the device add it in main().

#if defined ( BUILD_ALL_DEVICES )
  // The "Demo" target is setup to have BUILD_ALL_DEVICES and HOLD_AUTO_START
  // We are looking at a jumper (defined in SampleAppHw.c) to be jumpered
  // together - if they are - we will start up a coordinator. Otherwise,
  // the device will start as a router.
  if ( readCoordinatorJumper() )
    zgDeviceLogicalType = ZG_DEVICETYPE_COORDINATOR;
  else
    zgDeviceLogicalType = ZG_DEVICETYPE_ROUTER;
#endif // BUILD_ALL_DEVICES

#if defined ( HOLD_AUTO_START )
  // HOLD_AUTO_START is a compile option that will surpress ZDApp
  //  from starting the device and wait for the application to
  //  start the device.
  ZDOInitDevice(0);
#endif

  // Setup for the periodic message's destination address
  // Broadcast to everyone
  SampleApp_Periodic_DstAddr.addrMode = (afAddrMode_t)AddrBroadcast;
  SampleApp_Periodic_DstAddr.endPoint = SAMPLEAPP_ENDPOINT;
  SampleApp_Periodic_DstAddr.addr.shortAddr = 0xFFFF;

  // Setup for the flash command's destination address - Group 1
  SampleApp_Flash_DstAddr.addrMode = (afAddrMode_t)afAddrGroup;
  SampleApp_Flash_DstAddr.endPoint = SAMPLEAPP_ENDPOINT;
  SampleApp_Flash_DstAddr.addr.shortAddr = SAMPLEAPP_FLASH_GROUP;

  SampleApp_P2P_DstAddr.addrMode = (afAddrMode_t)Addr16Bit; //點播
  SampleApp_P2P_DstAddr.endPoint = SAMPLEAPP_ENDPOINT;
  SampleApp_P2P_DstAddr.addr.shortAddr = 0x0000;            //發給協調器

  // Fill out the endpoint description.
  SampleApp_epDesc.endPoint = SAMPLEAPP_ENDPOINT;
  SampleApp_epDesc.task_id = &SampleApp_TaskID;
  SampleApp_epDesc.simpleDesc
            = (SimpleDescriptionFormat_t *)&SampleApp_SimpleDesc;
  SampleApp_epDesc.latencyReq = noLatencyReqs;

  // Register the endpoint description with the AF
  afRegister( &SampleApp_epDesc );

  // Register for all key events - This app will handle all key events
  RegisterForKeys( SampleApp_TaskID );

  // By default, all devices start out in Group 1
  SampleApp_Group.ID = 0x0001;
  osal_memcpy( SampleApp_Group.name, "Group 1", 7 );
  aps_AddGroup( SAMPLEAPP_ENDPOINT, &SampleApp_Group );

#if defined ( LCD_SUPPORTED )
  HalLcdWriteString( "SampleApp", HAL_LCD_LINE_1 );
#endif
}

/*********************************************************************
* @fn      SampleApp_ProcessEvent
*
* @brief   Generic Application Task event processor.  This function
*          is called to process all events for the task.  Events
*          include timers, messages and any other user defined events.
*
* @param   task_id  - The OSAL assigned task ID.
* @param   events - events to process.  This is a bit map and can
*                   contain more than one event.
*
* @return  none
*/
uint16 SampleApp_ProcessEvent( uint8 task_id, uint16 events )
{
  afIncomingMSGPacket_t *MSGpkt;
  (void)task_id;  // Intentionally unreferenced parameter

  if ( events & SYS_EVENT_MSG )
  {
    MSGpkt = (afIncomingMSGPacket_t *)osal_msg_receive( SampleApp_TaskID );
    while ( MSGpkt )
    {
      switch ( MSGpkt->hdr.event )
      {
        // Received when a key is pressed
        case KEY_CHANGE:
          SampleApp_HandleKeys( ((keyChange_t *)MSGpkt)->state, ((keyChange_t *)MSGpkt)->keys );
          break;

        // Received when a messages is received (OTA) for this endpoint
        case AF_INCOMING_MSG_CMD:
          SampleApp_MessageMSGCB( MSGpkt );
          break;

        // Received whenever the device changes state in the network
        case ZDO_STATE_CHANGE:
          SampleApp_NwkState = (devStates_t)(MSGpkt->hdr.status);
          if ( //(SampleApp_NwkState == DEV_ZB_COORD) ||
                 (SampleApp_NwkState == DEV_ROUTER)
              || (SampleApp_NwkState == DEV_END_DEVICE) )
          {
            // Start sending the periodic message in a regular interval.
            osal_start_timerEx( SampleApp_TaskID,
                              SAMPLEAPP_SEND_PERIODIC_MSG_EVT,
                              SAMPLEAPP_SEND_PERIODIC_MSG_TIMEOUT );
          }
          else
          {
            // Device is no longer in the network
          }
          break;

        default:
          break;
      }

      // Release the memory
      osal_msg_deallocate( (uint8 *)MSGpkt );

      // Next - if one is available
      MSGpkt = (afIncomingMSGPacket_t *)osal_msg_receive( SampleApp_TaskID );
    }

    // return unprocessed events
    return (events ^ SYS_EVENT_MSG);
  }

  // Send a message out - This event is generated by a timer
  //  (setup in SampleApp_Init()).
  if ( events & SAMPLEAPP_SEND_PERIODIC_MSG_EVT )
  {
    // Send the periodic message
    //SampleApp_SendPeriodicMessage();
    SampleApp_Send_P2P_Message();

    // Setup to send message again in normal period (+ a little jitter)
    osal_start_timerEx( SampleApp_TaskID, SAMPLEAPP_SEND_PERIODIC_MSG_EVT,
        (SAMPLEAPP_SEND_PERIODIC_MSG_TIMEOUT + (osal_rand() & 0x00FF)) );

    // return unprocessed events
    return (events ^ SAMPLEAPP_SEND_PERIODIC_MSG_EVT);
  }



//    if ( events & SAMPLEAPP_UART_READ_MSG_EVT )
//  {
    // Send the periodic message
    //SampleApp_SendPeriodicMessage();
//    SampleApp_UART_READ_Change();

    // Setup to send message again in normal period (+ a little jitter)
    //osal_start_timerEx( SampleApp_TaskID, SAMPLEAPP_SEND_PERIODIC_MSG_EVT,
    //   (SAMPLEAPP_SEND_PERIODIC_MSG_TIMEOUT + (osal_rand() & 0x00FF)) );

    // return unprocessed events
//    return (events ^ SAMPLEAPP_UART_READ_MSG_EVT);
//  }





  // Discard unknown events
  return 0;
}

/*********************************************************************
* Event Generation Functions
*/
/*********************************************************************
* @fn      SampleApp_HandleKeys
*
* @brief   Handles all key events for this device.
*
* @param   shift - true if in shift/alt.
* @param   keys - bit field for key events. Valid entries:
*                 HAL_KEY_SW_2
*                 HAL_KEY_SW_1
*
* @return  none
*/
void SampleApp_HandleKeys( uint8 shift, uint8 keys )
{
  (void)shift;  // Intentionally unreferenced parameter

  if ( keys & HAL_KEY_SW_1 )
  {
    /* This key sends the Flash Command is sent to Group 1.
     * This device will not receive the Flash Command from this
     * device (even if it belongs to group 1).
     */
    SampleApp_SendFlashMessage( SAMPLEAPP_FLASH_DURATION );
  }

  if ( keys & HAL_KEY_SW_2 )
  {
    /* The Flashr Command is sent to Group 1.
     * This key toggles this device in and out of group 1.
     * If this device doesn't belong to group 1, this application
     * will not receive the Flash command sent to group 1.
     */
    aps_Group_t *grp;
    grp = aps_FindGroup( SAMPLEAPP_ENDPOINT, SAMPLEAPP_FLASH_GROUP );
    if ( grp )
    {
      // Remove from the group
      aps_RemoveGroup( SAMPLEAPP_ENDPOINT, SAMPLEAPP_FLASH_GROUP );
    }
    else
    {
      // Add to the flash group
      aps_AddGroup( SAMPLEAPP_ENDPOINT, &SampleApp_Group );
    }
  }
}

/*********************************************************************
* LOCAL FUNCTIONS
*/

/*********************************************************************
* @fn      SampleApp_MessageMSGCB
*
* @brief   Data message processor callback.  This function processes
*          any incoming data - probably from other devices.  So, based
*          on cluster ID, perform the intended action.
*
* @param   none
*
* @return  none
*/
void SampleApp_MessageMSGCB( afIncomingMSGPacket_t *pkt )
{
  uint16 flashTime;
  uint8 WARN_THL[12],WARN_HHL[12];
  switch ( pkt->clusterId )
  {
    case SAMPLEAPP_P2P_CLUSTERID:


      WARN_THL[0] = 'W';
      WARN_THL[1] = 'T';
      WARN_THL[2] = 'E';
      WARN_THL[3] = 'M';
      WARN_THL[4] = 'P';
      WARN_THL[5] = ':';
      WARN_THL[6] = WT_H/10 + 0x30;
      WARN_THL[7] = WT_H%10 + 0x30;
      WARN_THL[8] = ' ';
      WARN_THL[9] = WT_L/10 + 0x30;
      WARN_THL[10] = WT_L%10 + 0x30;
      WARN_THL[11] = ' ';

      WARN_HHL[0] = 'W';
      WARN_HHL[1] = 'H';
      WARN_HHL[2] = 'U';
      WARN_HHL[3] = 'M';
      WARN_HHL[4] = 'I';
      WARN_HHL[5] = ':';
      WARN_HHL[6] = WH_H/10 + 0x30;
      WARN_HHL[7] = WH_H%10 + 0x30;
      WARN_HHL[8] = ' ';
      WARN_HHL[9] = WH_L/10 + 0x30;
      WARN_HHL[10] = WH_L%10 + 0x30;
      WARN_HHL[11] = ' ';




      HalUARTWrite(0, "T&H:", 4);       //提示接收到數據
      HalUARTWrite(0, pkt->cmd.Data, pkt->cmd.DataLength); //輸出接收到的數據
      HalUARTWrite(0, "\r\n", 2);         // 回車換行





      HalUARTWrite(0, "WARN:", 5);
      if(WARN == 1)
      {
        HalUARTWrite(0, "ON", 2);
        //HalUARTWrite(0, "\n", 1);

         if(((pkt->cmd.Data[0]-0x30)*10+(pkt->cmd.Data[1]-0x30)>=WT_H)
          ||  ((pkt->cmd.Data[0]-0x30)*10+(pkt->cmd.Data[1]-0x30)<=WT_L)

          ||  ((pkt->cmd.Data[3]-0x30)*10+(pkt->cmd.Data[4]-0x30)>=WH_H)

          ||  ((pkt->cmd.Data[3]-0x30)*10+(pkt->cmd.Data[4]-0x30)<=WH_L) )
       {
          HalLedBlink (HAL_LED_2, 10, 50, 500);
       }


      }     
        if(WARN == 0)
        {
          HalUARTWrite(0, "OFF", 3);
          //HalUARTWrite(0, "\n", 1);
        }
      HalUARTWrite(0, "\r\n", 2);

       HalUARTWrite(0, (uint8 *)WARN_THL, 12);
       HalUARTWrite(0, "\r\n", 2);  

       HalUARTWrite(0, (uint8 *)WARN_HHL, 12);
       HalUARTWrite(0, "\r\n", 2);
       HalUARTWrite(0, "\r\n", 2);




      break;   
    case SAMPLEAPP_PERIODIC_CLUSTERID:
      break;

    case SAMPLEAPP_FLASH_CLUSTERID:
      flashTime = BUILD_UINT16(pkt->cmd.Data[1], pkt->cmd.Data[2] );
      HalLedBlink( HAL_LED_4, 4, 50, (flashTime / 4) );
      break;
  }
}


/*********************************************************************
* @fn      SampleApp_SendPeriodicMessage
*
* @brief   Send the periodic message.
*
* @param   none
*
* @return  none
*/
void SampleApp_SendPeriodicMessage( void )
{
  if ( AF_DataRequest( &SampleApp_Periodic_DstAddr, &SampleApp_epDesc,
                       SAMPLEAPP_PERIODIC_CLUSTERID,
                       1,
                       (uint8*)&SampleAppPeriodicCounter,
                       &SampleApp_TransID,
                       AF_DISCV_ROUTE,
                       AF_DEFAULT_RADIUS ) == afStatus_SUCCESS )
  {
  }
  else
  {
    // Error occurred in request to send.
  }


}

/*********************************************************************
* @fn      SampleApp_SendFlashMessage
*
* @brief   Send the flash message to group 1.
*
* @param   flashTime - in milliseconds
*
* @return  none
*/
void SampleApp_SendFlashMessage( uint16 flashTime )
{
  uint8 buffer[3];
  buffer[0] = (uint8)(SampleAppFlashCounter++);
  buffer[1] = LO_UINT16( flashTime );
  buffer[2] = HI_UINT16( flashTime );

  if ( AF_DataRequest( &SampleApp_Flash_DstAddr, &SampleApp_epDesc,
                       SAMPLEAPP_FLASH_CLUSTERID,
                       3,
                       buffer,
                       &SampleApp_TransID,
                       AF_DISCV_ROUTE,
                       AF_DEFAULT_RADIUS ) == afStatus_SUCCESS )
  {
  }
  else
  {
    // Error occurred in request to send.
  }
}

/*********************************************************************
* @fn      SampleApp_Send_P2P_Message
*
* @brief   point to point.
*
* @param   none
*
* @return  none
*/
void SampleApp_Send_P2P_Message( void )
{
  char temp[3], humidity[3], strTemp[7];

  DHT11();             //獲取溫濕度

  //將溫濕度的轉換成字符串,供LCD顯示  
  temp[0] = wendu_shi+0x30;
  temp[1] = wendu_ge+0x30;
  temp[2] = '\0';
  humidity[0] = shidu_shi+0x30;
  humidity[1] = shidu_ge+0x30;
  humidity[2] = '\0';
  //將數據整合后方便發給協調器顯示
  osal_memcpy(strTemp, temp, 2);
  osal_memcpy(&strTemp[2], " ", 1);
  osal_memcpy(&strTemp[3], humidity, 3);

  //獲得的溫濕度通過串口輸出到電腦顯示
  HalUARTWrite(0, "T&H:", 4);
  HalUARTWrite(0, (uint8 *)strTemp, 5);
  HalUARTWrite(0, "\n",1);

  //輸出到LCD顯示
  Color    = BLACK;
  Color_BK = WHITE; //背景色  
  LCD_write_CN_string(7, 80, "溫度:");
  LCD_write_CN_string(7, 95, "濕度:");

  Color    = RED;
  HalLcdWriteEnString( 49, 80, temp );                  
  HalLcdWriteEnString( 49, 95, humidity );

  Color    = BLACK;
  LCD_write_CN_string(63, 80, "℃");
  LCD_write_CN_string(63, 95, "%");


  if ( AF_DataRequest( &SampleApp_P2P_DstAddr, &SampleApp_epDesc,
                       SAMPLEAPP_P2P_CLUSTERID,
                       5,
                       (uint8 *)strTemp,
                       &SampleApp_TransID,
                       AF_DISCV_ROUTE,
                       AF_DEFAULT_RADIUS ) == afStatus_SUCCESS )
  {
  }
  else
  {
    // Error occurred in request to send.
  }
}
/*********************************************************************
*********************************************************************/



/*

void UartCallBackFunction( void )
{
  uint8 rev[6];
  HalUARTRead(0, (uint8 *)rev, 6);
  if( (rev[0]=='w') && (rev[1]=='o') && (rev[2]=='n'))
  {
    WARN = 1;
  }
    else if( (rev[0]=='w') && (rev[1]=='o') && (rev[2]=='f') && (rev[3]=='f'))
    {
      WARN = 0;
    }
      else if( (rev[0]=='w') && (rev[1]=='t') && (rev[2]=='h'))
      {
        WT_H = (rev[3]-0x30)*10 + (rev[4]-0x30);
      }
        else if( (rev[0]=='w') && (rev[1]=='t') && (rev[2]=='l'))
        {
          WT_L = (rev[3]-0x30)*10 + (rev[4]-0x30);
        }
          else if( (rev[0]=='w') && (rev[1]=='h') && (rev[2]=='h'))
          {
            WH_H = (rev[3]-0x30)*10 + (rev[4]-0x30);
          }
            else if( (rev[0]=='w') && (rev[1]=='h') && (rev[2]=='l'))
            {
              WH_L = (rev[3]-0x30)*10 + (rev[4]-0x30);
            }

}

*/

void UartCallBackFunction(uint8 port, uint8 event)
{
  uint8 rev[6];
  uint16 rxlen=0;
  rxlen = Hal_UART_RxBufLen( HAL_UART_PORT_0 );
  if(rxlen != 0)
  {
    HalUARTRead(0, (uint8 *)rev, 6);
  if( (rev[0]=='w') && (rev[1]=='o') && (rev[2]=='n'))
  {
    WARN = 1;
  }
    else if( (rev[0]=='w') && (rev[1]=='o') && (rev[2]=='f') && (rev[3]=='f'))
    {
      WARN = 0;
    }
      else if( (rev[0]=='w') && (rev[1]=='t') && (rev[2]=='h'))
      {
        WT_H = (rev[3]-0x30)*10 + (rev[4]-0x30);
      }
        else if( (rev[0]=='w') && (rev[1]=='t') && (rev[2]=='l'))
        {
          WT_L = (rev[3]-0x30)*10 + (rev[4]-0x30);
        }
          else if( (rev[0]=='w') && (rev[1]=='h') && (rev[2]=='h'))
          {
            WH_H = (rev[3]-0x30)*10 + (rev[4]-0x30);
          }
            else if( (rev[0]=='w') && (rev[1]=='h') && (rev[2]=='l'))
            {
              WH_L = (rev[3]-0x30)*10 + (rev[4]-0x30);
            }
  }

}



分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享淘帖 頂 踩
回復

使用道具 舉報

沙發
ID:271554 發表于 2018-7-5 23:35 | 只看該作者
幫忙給主要部分做個注釋,越詳細越好!謝謝啦!
回復

使用道具 舉報

板凳
ID:308437 發表于 2018-7-6 09:38 | 只看該作者
看到您的要求。我很想笑。題主您的時間是時間,別人的時間不是時間?
每一行,代碼,注釋!!牛B。
回復

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規則

手機版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術交流QQ群281945664

Powered by 單片機教程網

快速回復 返回頂部 返回列表
主站蜘蛛池模板: 日韩一级免费观看 | 欧美激情亚洲天堂 | 亚洲一区二区在线电影 | 奇米影视首页 | 精品一区二区三区在线视频 | 先锋资源站 | 精品中文字幕视频 | 成人高清视频在线观看 | wwww.xxxx免费| 国产亚洲精品综合一区 | 国产精品免费视频一区 | 国产一区二区三区网站 | 精品久久精品 | 国产精品久久久久久久久久久免费看 | 国产精品国产馆在线真实露脸 | 国产视频久久久 | 亚洲高清视频在线 | 国产av毛片| 一区二区三区亚洲 | 成人免费观看男女羞羞视频 | 五月精品视频 | 天天夜干| 欧美精品一二三 | 卡通动漫第一页 | 午夜精品影院 | 日韩中文字幕在线不卡 | 国产精品久久久久久久一区二区 | 精品国产乱码久久久久久蜜退臀 | 免费一级欧美在线观看视频 | 在线观看免费观看在线91 | 久久国产高清 | 色眯眯视频在线观看 | 国产剧情久久 | 国产精品久久国产精品久久 | 欧美理论在线观看 | 日本a∨精品中文字幕在线 亚洲91视频 | 亚洲永久精品国产 | 91日日| 久久久久久久久91 | 国产精品二区三区在线观看 | 日韩激情在线 |