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

📄 data.c

📁 This network protcol stack,it is very strong and powerful!
💻 C
字号:
/************************************************************************************
* Implements data primitives 
*
* Author(s):
*   Thomas O. Jensen, Jesper Thomsen
*
* (c) Copyright 2004, Freescale, Inc.  All rights reserved.
*
* Freescale Confidential Proprietary
* Digianswer Confidential
*
* No part of this document must be reproduced in any form - including copied,
* transcribed, printed or by any electronic means - without specific written
* permission from Freescale.
*
* Last Inspected:
* Last Tested:
************************************************************************************/

#include "DigiType.h"
#include "Phy.h"
#include "PhyMacMsg.h"

/************************************************************************************
*************************************************************************************
* Private macros
*************************************************************************************
************************************************************************************/

/************************************************************************************
*************************************************************************************
* Private prototypes
*************************************************************************************
************************************************************************************/

/************************************************************************************
*************************************************************************************
* Private type definitions
*************************************************************************************
************************************************************************************/

/************************************************************************************
*************************************************************************************
* Public memory declarations
*************************************************************************************
************************************************************************************/

/************************************************************************************
*************************************************************************************
* Private memory declarations
*************************************************************************************
************************************************************************************/

/************************************************************************************
*************************************************************************************
* Public functions
*************************************************************************************
************************************************************************************/
/************************************************************************************
* Get and convert Link Quality
*
* Abel returns values between -95 dBm to about -18 dBm which are represented by decimal
* values 190 (0xbe) and 36 (0x24) respectively.
*
************************************************************************************/
void ConvertLinkQuality(void){
  uint8_t     linkQuality = gpPhyRxData->linkQuality;

  // Recalculate the link quality to conform with other link quality measures
  // Make dynamics of the energy level vary from 0x00-0xff
  if (linkQuality > 190) {
    linkQuality = 190; //190 = -95dBm as floor (translates to 0x00)
  }
  if (linkQuality < 33) {
    linkQuality = 33; //33 = -16.5 dBm as top (saturation)
  }
  linkQuality = 190 - linkQuality;  
  linkQuality = linkQuality + (linkQuality >> 1) + (linkQuality >> 3);
  gpPhyRxData->linkQuality = linkQuality;
}



/************************************************************************************
* Initiates data transmission
* 
*
* Interface assumptions:
*
* Return value:
*   NONE
*
* Revision history:
*
*    Date    Author    Comments
*   ------   ------    --------
*   010903   TOJ       Created
*   090903   JT        Implemented
*
************************************************************************************/

void PhyPdDataRequest(txPacket_t *pTxPacket)
{
  uint16_t tmpData;
    // Assert if not in tx state
  DigiAssert(PHY_ASSERT,(mPhyTxRxState==cBusy_Tx));

      // Get Tx buffer from MAC
  gpPhyTxPacket = pTxPacket->txData;

    // Write Length to Abel
  ABEL_WRITE_INT(TX_CONTROL, pTxPacket->frameLength);

    // Initialize remaining length counter to length minus (2+2) (2 CRC and the 2 first bytes copied here) 
  gTxRemainingLength = (uint8_t) pTxPacket->frameLength - 4;

  // Init Data Tx Buffer Index to 2 because 2 first bytes copied here 
  gPhyMacDataTxIndex=2;

  // Copy data from data buffer to Abel (Reverse Endianess)
  tmpData = ((gpPhyTxPacket[1] << 8) | gpPhyTxPacket[0]);
  ABEL_WRITE_INT(TX_DATA, tmpData);
}


/************************************************************************************
*************************************************************************************
* Private functions
*************************************************************************************
************************************************************************************/

/************************************************************************************
*************************************************************************************
* Module debug stuff
*************************************************************************************
************************************************************************************/




/************************************************************************************
*************************************************************************************
* Level 1 block comment
*************************************************************************************
************************************************************************************/

//-----------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------
// Level 2 block comment
//-----------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------

/* Level 3 block comment */




// Delimiters

/***********************************************************************************/

//-----------------------------------------------------------------------------------

⌨️ 快捷键说明

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