📄 simple_mac.c
字号:
/*!
* \mainpage SMAC 4.1a
*
* Copyright (c) 2004, Freescale Semiconductor
*
* Freescale Confidential Proprietary
*
* \b Project: SMAC (Simple Media Access Controller)
*
* \b Department: Freescale Radio Products Division
*
*/
/*!
* \file simple_mac.c
*
* \brief This is the SMAC C code for the MAC layer
*
* \author a19259
*
* \version 4.1a
*
* \date 2005/07/29 02:27:50
*
* \b Description: This is the SMAC C source media (i.e. MAC) layer file for
* the HC(S)08 MCU and MC13192 transceiver.
* The SMAC MAC is the highest layer of C code for the SMAC.*
*
* \b Department: Freescale Radio Products Division
*
* \b Project: SMAC (Simple Media Access Controller)
*
* \b History:
* - 16/11/2005 Doc. update to Doxygen compliant by Laura Delgado r12370c
*
*/
#include "pub_def.h"
#include "drivers.h"
#include "simple_phy.h"
#include "simple_mac.h"
#include "MC13192_regs.h"
/* Externals */
extern tRxPacket *psDrvRxPacket;//!< Where the packet received will be stored
extern UINT8 gu8RTxMode; //!< Global mode mirror. MC13192 Status.
extern tPhyOptions *psPhyOptions;
/* Version string to put in NVM. Note! size limits */
/* Normally it shoud be enough to change the version numbers. */
#define Database_Label_Version "1.00"
#define MAC_Version "4.20"
#define MAC_Label "SMAC "
#define SMAC_VerComplete "MAC " MAC_Label " Ver " MAC_Version " Build: " __DATE__ " " __TIME__
#define SMAC_VerSize sizeof(SMAC_VerComplete)
#if defined (HCS08G) | defined (HCS08R)| defined (HCS08Q)
#pragma MESSAGE DISABLE C3303 /*
* Warning C3303: Implicit concatenation of
* strings
*/
#pragma MESSAGE DISABLE C4200 /*
* Warning C4200: Other segment than in
* previous declaration
*/
#pragma CONST_SEG BOOTLOADER_MAC_NV_DATA0
#endif
/* DO NOT CHANGE OR REMOVE */
/* These strings will be located in the NV RAM0 section.*/
/* Note!!Check that items are location in the same sequence as specified. */
const unsigned char Freescale_Copyright[54] = "(c) Copyright 2004 Freescale Inc. All rights reserved";
const unsigned char Firmware_Database_Label[40] = {"DB Label: SMAC4.1c 1321x 1319xVer " Database_Label_Version};
const unsigned char SMAC_Version[SMAC_VerSize] = SMAC_VerComplete;
#if defined (HCS08G) | defined (HCS08R) | defined (HCS08Q)
#pragma CONST_SEG DEFAULT
#endif
/*!
* \fn UINT8 MCPSDataRequest (tTxPacket *psTxPacket)
*
* \brief Transmit data packet
*
* \param *psTxPacket packet pointer
*
* \return Status
*/
UINT8 MCPSDataRequest(tTxPacket *psTxPacket)
{
UINT8 u8Status;
/* Send it to the phy for processing */
u8Status = PDDataRequest(psTxPacket);
return u8Status;
}
/*
* MCPSDataIndication : Receive data packet indication
*
* Parameters : Data packet pointer
*
* Return : None
*
* Notes : This function return should be located in the application
*/
/*!
* \fn UINT8 MLMEHibernateRequest(void)
*
* \brief Hibernate the MC13192 (very low current, no CLKO)
*
* \return Status
*/
UINT8 MLMEHibernateRequest(void)
{
UINT8 u8Status = 0;
u8Status = PLMEHibernateRequest();
return u8Status;
}
/*!
* \fn UINT8 MLMEDozeRequest(UINT32 u32Timeout)
*
* \brief Doze the MC13192 (Low current, CLKO <= 1MHz)
*
* \param u32Timeout 32-bit time period
*
* \return Status
*/
UINT8 MLMEDozeRequest(UINT32 u32Timeout)
{
UINT8 u8Status = 0;
u8Status = PLMEDozeRequest(u32Timeout);
return u8Status;
}
/*!
* \fn UINT8 MLMEWakeRequest(void)
*
* \brief Wake the MC13192 from Hibernate or Doze
*
* \return Status
*/
UINT8 MLMEWakeRequest(void)
{
UINT8 u8Status = 0;
if (gu8RTxMode == DOZE_MODE || gu8RTxMode == HIBERNATE_MODE)
{
u8Status = PLMEWakeRequest();
return u8Status;
}
return ERROR;
}
/*!
* \fn UINT8 MLMESetChannelRequest(UINT8 u8Channel)
*
* \brief Set the MC13192 operating channel
*
* \param u8Channel Channel number (0-15) \n
* Channel frequencies : \n
* 0 : 2.405GHz \n
* 1 : 2.410GHz \n
* 2 : 2.415GHz \n
* 3 : 2.420GHz \n
* 4 : 2.425GHz \n
* 5 : 2.430GHz \n
* 6 : 2.435GHz \n
* 7 : 2.440GHz \n
* 8 : 2.445GHz \n
* 9 : 2.450GHz \n
* 10: 2.455GHz \n
* 11: 2.460GHz \n
* 12: 2.465GHz \n
* 13: 2.470GHz \n
* 14: 2.475GHz \n
* 15: 2.480GHz \n
*
* \return Status
*/
UINT8 MLMESetChannelRequest(UINT8 u8Channel)
{
UINT8 u8Status = 0;
u8Status = PLMESetChannelRequest(u8Channel);
return u8Status;
}
/*!
* \fn UINT8 MLMERXEnableRequest(tRxPacket *psRxPacket, UINT32 u32Timeout)
*
* \brief Set the MC13192 receiver ON (with optional timeout)
*
* \param *psRxPacket Packet pointer for received data
* \param u32Timeout timeout
*
* \note Timeout of 0 disables the timeout.
* The actual timeout period is the timeout value times the MC13192 timer rate
* from MLMESetMC13192TmrPrescale.
* \return Status
*/
UINT8 MLMERXEnableRequest(tRxPacket *psRxPacket, UINT32 u32Timeout)
{
UINT8 u8Status = 0;
psDrvRxPacket = psRxPacket; /* Assign the rx_packet to SMAC global. */
if (u32Timeout == 0) { /* Timeout disabled */
/* Just enable the receiver */
u8Status = PLMESetTrxStateRequest(RX_MODE);
}
else {
/* Timeout requested. Get the current time and add the timeout value. */
/* Erratum: In order to avoid the missing Irq, we reset the timer1 */
PLMESetTimeRequest(0x00000000);
u8Status = PLMEEnableMC13192Timer1(u32Timeout); /*
* Set the
* timeout in TC1
*/
u8Status = PLMESetTrxStateRequest(RX_MODE_WTO);
}
return u8Status;
}
/*!
* \fn UINT8 MLMERXDisableRequest(void)
*
* \brief Set the MC13192 receiver OFF
*
* \return Status
*/
UINT8 MLMERXDisableRequest(void)
{
(void)PLMEDisableMC13192Timer1(); /*
* In case the timeout is being used,
* disable it also
*/
if (PLMESetTrxStateRequest(IDLE_MODE) == SUCCESS) { /*
* Attempt to
* disable the
* timer
*/
return SUCCESS;
}
else {
return ERROR;
}
}
/*!
* \fn UINT8 MLMESetMC13192ClockRate(UINT8 u8Freq)
*
* \brief Set MC13192 CLKo frequency
*
* \param u8Freq Frequency value enumeration (0-7) \n
* \n
* Freq Output Frequency \n
* 0 16MHz (Recommended default) \n
* 1 8MHz \n
* 2 4MHz \n
* 3 2MHz \n
* 4 1MHz \n
* 5 62.5kHz \n
* 6 32.786kHz \n
* 7 16.393kHz \n
*
* \return Status
*/
UINT8 MLMESetMC13192ClockRate(UINT8 u8Freq)
{
UINT8 u8Status;
u8Status = PLMESetMC13192ClockRate(u8Freq);
return u8Status;
}
/*!
* \fn UINT8 MLMESetMC13192TmrPrescale (UINT8 u8Freq)
*
* \brief Set MC13192 timer frequency
*
* \param u8Freq Frequency value enumeration (0-7) \n
* \n
* Freq Output Frequency \n
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -