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

📄 test.c

📁 基于Freescale-smac的点对点通讯。 简介:在Router(特征:接口为COM口)上实现点对点通信。 子工程: 1、接收端receiver_13213_ver2.0 (目前只
💻 C
字号:
/**************************************************************
*    Includes
**************************************************************/
#include <hidef.h> /* for EnableInterrupts macro */
#include "pub_def.h"
#include "simple_mac.h"
#include "SCI.h"
#include "mc13192_hw_config.h"
#include "bootloader user api.h"
#include "sci_receiver.h"
#include "freescale_radio_hardware.h"
#include "MC13192_regs.h"
#include "drivers.h"

/**************************************************************
*    Main Program
**************************************************************/
void main(void) 
{
  for(;;) 
  {
    __RESET_WATCHDOG(); /* feeds the dog */
    
    /* initialize the leds */
    LED1DIR = DDIR_OUTPUT;  // initialize as output
  
    LED1 = LED_OFF;         // All lights off
  }
  
}

/**************************************************************
*    Function:     Received data handler
*    Parameters: tRxPacket
**************************************************************/
void MCPSDataIndication(tRxPacket *sRxPacket)
/* Just a direct return. Main loop will handle it. */
{
    ;
}

void MLMEMC13192ResetIndication(void) 
{
    //Notifies you that the MC13192 has been reset.
    //Application must handle this here.

}


/**************************************************************
*    Function:     Read MCU timer.
*    Parameters: none
*    Return:        16-bit timer value.
**************************************************************/
UINT16 MCUReadTmr1(void)
{
  UINT16  w; /* w[0] is MSB, w[1] is LSB */
  ((UINT8*)&w)[0] = TPM1CNTH; /* MSB */
  ((UINT8*)&w)[1] = TPM1CNTL; /* LSB */
  return w;
}

/**************************************************************
*    Function:     Delay.
*    Parameters: Delay u16Count
*    Return:        none.
**************************************************************/
void MCUDelay (UINT16 delay_t)
{
  UINT16 u16MCUOldTime;
  UINT16 u16MCUNewTime;
  u16MCUOldTime = MCUReadTmr1();
  u16MCUNewTime = u16MCUOldTime;
  while ((u16MCUNewTime-u16MCUOldTime) < delay_t)
  {
    u16MCUNewTime = MCUReadTmr1();
  }
}


/**************************************************************
*    Function:     Initiate leds (DS2 and DS3).
*    Parameters: none
*    Return:        none.
**************************************************************/
void LEDSInit(void) 
{
    UINT16 u16SpiReg = 0; // a variable to restore the content of the SPI register.
    
    // define the GPIO[7:6](LED: DS2 and DS3) as output only.
    u16SpiReg = SPIDrvRead(GPIO_CONFIG);
    u16SpiReg |= 0x3000;  // GPIO[7:6](LED: DS2 and DS3) output enable.
    u16SpiReg &= 0xFF9F;  // GPIO[7:6] input disable.
    SPIDrvWrite(GPIO_CONFIG, u16SpiReg);
    
    // set the output drive strength of GPIO[7:6]
    u16SpiReg = SPIDrvRead(GPIO_DATA);
    u16SpiReg |= 0xC000;
    SPIDrvWrite(GPIO_DATA, u16SpiReg);
    
    // turn off the LED DS2 and DS3
    LED_DS2_OFF();
    LED_DS3_OFF();

}


/**************************************************************
*    Function:     Turn ON the led of DS2.
*    Parameters: none
*    Return:        none.
**************************************************************/
void LED_DS2_ON(void) 
{
    UINT16 u16SpiReg; // a variable to restore the content of the SPI register.
    
    u16SpiReg = SPIDrvRead(GPIO_DATA);
    u16SpiReg |= 0x0020;
    SPIDrvWrite(GPIO_DATA, u16SpiReg);
}


/**************************************************************
*    Function:     Turn ON the led of DS3.
*    Parameters: none
*    Return:        none.
**************************************************************/
void LED_DS3_ON(void) 
{
    UINT16 u16SpiReg; // a variable to restore the content of the SPI register.
    
    u16SpiReg = SPIDrvRead(GPIO_DATA);
    u16SpiReg |= 0x0040;
    SPIDrvWrite(GPIO_DATA, u16SpiReg);
}


/**************************************************************
*    Function:     Turn OFF the led of DS2.
*    Parameters: none
*    Return:        none.
**************************************************************/
void LED_DS2_OFF(void) 
{
    UINT16 u16SpiReg; // a variable to restore the content of the SPI register.
    
    u16SpiReg = SPIDrvRead(GPIO_DATA);
    u16SpiReg &= 0xFFDF;
    SPIDrvWrite(GPIO_DATA, u16SpiReg);
}


/**************************************************************
*    Function:     Turn OFF the led of DS3.
*    Parameters: none
*    Return:        none.
**************************************************************/
void LED_DS3_OFF(void) 
{
    UINT16 u16SpiReg; // a variable to restore the content of the SPI register.
    
    u16SpiReg = SPIDrvRead(GPIO_DATA);
    u16SpiReg |= 0xFFBF;
    SPIDrvWrite(GPIO_DATA, u16SpiReg);
}

⌨️ 快捷键说明

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