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

📄 msp430_ti_trf7950.h

📁 对TRF7950数据收发的源代码
💻 H
字号:
//*******************************************************************************
//   TI/Agilent Wireless Mouse Reference Design
//
//   File: "MSP430_TI_TRF7950.h"
//
//  Author: Randy Wu
//  Company: Texas Instruments, Inc.
//  Date: May 2006
//
// THIS PROGRAM IS PROVIDED "AS IS". TI MAKES NO WARRANTIES OR
// REPRESENTATIONS, EITHER EXPRESS, IMPLIED OR STATUTORY,
// INCLUDING ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE, LACK OF VIRUSES, ACCURACY OR
// COMPLETENESS OF RESPONSES, RESULTS AND LACK OF NEGLIGENCE.
// TI DISCLAIMS ANY WARRANTY OF TITLE, QUIET ENJOYMENT, QUIET
// POSSESSION, AND NON-INFRINGEMENT OF ANY THIRD PARTY
// INTELLECTUAL PROPERTY RIGHTS WITH REGARD TO THE PROGRAM OR
// YOUR USE OF THE PROGRAM.
//
// IN NO EVENT SHALL TI BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
// CONSEQUENTIAL OR INDIRECT DAMAGES, HOWEVER CAUSED, ON ANY
// THEORY OF LIABILITY AND WHETHER OR NOT TI HAS BEEN ADVISED
// OF THE POSSIBILITY OF SUCH DAMAGES, ARISING IN ANY WAY OUT
// OF THIS AGREEMENT, THE PROGRAM, OR YOUR USE OF THE PROGRAM.
// EXCLUDED DAMAGES INCLUDE, BUT ARE NOT LIMITED TO, COST OF
// REMOVAL OR REINSTALLATION, COMPUTER TIME, LABOR COSTS, LOSS
// OF GOODWILL, LOSS OF PROFITS, LOSS OF SAVINGS, OR LOSS OF
// USE OR INTERRUPTION OF BUSINESS. IN NO EVENT WILL TI'S
// AGGREGATE LIABILITY UNDER THIS AGREEMENT OR ARISING OUT OF
// YOUR USE OF THE PROGRAM EXCEED FIVE HUNDRED DOLLARS
// (U.S.$500).
//
// Unless otherwise stated, the Program written and copyrighted
// by Texas Instruments is distributed as "freeware".  You may,
// only under TI's copyright in the Program, use and modify the
// Program without any charge or restriction.  You may
// distribute to third parties, provided that you transfer a
// copy of this license to the third party and the third party
// agrees to these terms by its first use of the Program. You
// must reproduce the copyright notice and any other legend of
// ownership on each copy or partial copy, of the Program.
//
// You acknowledge and agree that the Program contains
// copyrighted material, trade secrets and other TI proprietary
// information and is protected by copyright laws,
// international copyright treaties, and trade secret laws, as
// well as other intellectual property laws.  To protect TI's
// rights in the Program, you agree not to decompile, reverse
// engineer, disassemble or otherwise translate any object code
// versions of the Program to a human-readable form.  You agree
// that in no event will you alter, remove or destroy any
// copyright notice included in the Program.  TI reserves all
// rights not specifically granted under this license. Except
// as specifically provided herein, nothing in this agreement
// shall be construed as conferring by implication, estoppel,
// or otherwise, upon you, any license or other right under any
// TI patents, copyrights or trade secrets.
//
// You may not use the Program in non-TI devices.
//*******************************************************************************
#ifndef _TI_TRF7950_H
#define _TI_TRF7950_H

#include <msp430x12x.h>
#include "wm430_system.h"

// ************************ HARDWARE PIN CONFIGURATIONS *************************


// ************************** DATA TYPES & DEFINITIONS **************************

#define _TRF7950_ERRORCHECK // Confirms TRF7950 register settings during init

#define TRF7950_OSC_HZ 27045000  // Crystal frequency input for TRF7950

// TRF7950 Individual Bit Mappings

#define TRF7950_OPMODE_ENTX       BIT7
#define TRF7950_OPMODE_ENOSC      BIT6
#define TRF7950_OPMODE_OSCSEL     BIT5
#define TRF7950_OPMODE_SETTSEL    BIT4
#define TRF7950_OPMODE_ENEEW      BIT0

#define TRF7950_DCDC_VSEL1        BIT7
#define TRF7950_DCDC_VSEL0        BIT6
#define TRF7950_DCDC_ISEL1        BIT4
#define TRF7950_DCDC_ISEL0        BIT3
#define TRF7950_DCDC_VDCS1        BIT2
#define TRF7950_DCDC_VDCS0        BIT1

#define TRF7950_CLOTXDEV_CLO2     BIT7
#define TRF7950_CLOTXDEV_CLO1     BIT6
#define TRF7950_CLOTXDEV_CLO0     BIT5
#define TRF7950_CLOTXDEV_FSKRATE  BIT4
#define TRF7950_CLOTXDEV_RES2     BIT2
#define TRF7950_CLOTXDEV_RES1     BIT1
#define TRF7950_CLOTXDEV_RES0     BIT0

#define TRF7950_OSC0SETTING0_DEV0 BIT5
#define TRF7950_OSC0SETTING0_DEV1 BIT4
#define TRF7950_OSC0SETTING0_DEV2 BIT3
#define TRF7950_OSC0SETTING0_FT2  BIT2
#define TRF7950_OSC0SETTING0_FT1  BIT1
#define TRF7950_OSC0SETTING0_FT0  BIT0

#define TRF7950_OSC0SETTING1_DEV0 BIT5
#define TRF7950_OSC0SETTING1_DEV1 BIT4
#define TRF7950_OSC0SETTING1_DEV2 BIT3
#define TRF7950_OSC0SETTING1_FT2  BIT2
#define TRF7950_OSC0SETTING1_FT1  BIT1
#define TRF7950_OSC0SETTING1_FT0  BIT0

#define TRF7950_OSC1SETTING0_DEV0 BIT5
#define TRF7950_OSC1SETTING0_DEV1 BIT4
#define TRF7950_OSC1SETTING0_DEV2 BIT3
#define TRF7950_OSC1SETTING0_FT2  BIT2
#define TRF7950_OSC1SETTING0_FT1  BIT1
#define TRF7950_OSC1SETTING0_FT0  BIT0

#define TRF7950_OSC1SETTING1_DEV0 BIT5
#define TRF7950_OSC1SETTING1_DEV1 BIT4
#define TRF7950_OSC1SETTING1_DEV2 BIT3
#define TRF7950_OSC1SETTING1_FT2  BIT2
#define TRF7950_OSC1SETTING1_FT1  BIT1
#define TRF7950_OSC1SETTING1_FT0  BIT0

#define TRF7950_STATUS_OSCOK      BIT7
#define TRF7950_STATUS_LOWBAT     BIT6
#define TRF7950_STATUS_LOWDCDC    BIT5

#define TRF7950_TEST_DISOSCOK     BIT5

#define TRF7950_TESTREG3456_DEV0  BIT5
#define TRF7950_TESTREG3456_DEV1  BIT4
#define TRF7950_TESTREG3456_DEV2  BIT3
#define TRF7950_TESTREG3456_FT2   BIT2
#define TRF7950_TESTREG3456_FT1   BIT1
#define TRF7950_TESTREG3456_FT0   BIT0

// TRF7950 Bit Combo Definitions

#define TRF7950_CLOTXDEV_CLODISABLED  (0+0+0)
#define TRF7950_CLOTXDEV_CLODIV16     (0+0+TRF7950_CLOTXDEV_CLO0)
#define TRF7950_CLOTXDEV_CLODIV07     (0+TRF7950_CLOTXDEV_CLO1+0)
#define TRF7950_CLOTXDEV_CLODIV06     (0+TRF7950_CLOTXDEV_CLO1+TRF7950_CLOTXDEV_CLO0)
#define TRF7950_CLOTXDEV_CLODIV05     (TRF7950_CLOTXDEV_CLO2+0+0)
#define TRF7950_CLOTXDEV_CLODIV04     (TRF7950_CLOTXDEV_CLO2+0+TRF7950_CLOTXDEV_CLO0)
#define TRF7950_CLOTXDEV_CLODIV03     (TRF7950_CLOTXDEV_CLO2+TRF7950_CLOTXDEV_CLO1+0)
#define TRF7950_CLOTXDEV_CLODIV02     (TRF7950_CLOTXDEV_CLO2+TRF7950_CLOTXDEV_CLO1+TRF7950_CLOTXDEV_CLO0)
#define TRF7950_CLOTXDEV_CLODIVMASK   (TRF7950_CLOTXDEV_CLO2+TRF7950_CLOTXDEV_CLO1+TRF7950_CLOTXDEV_CLO0)

#define TRF7950_DCDC_2_6V (0+0)
#define TRF7950_DCDC_3_3V (0+TRF7950_DCDC_VSEL0)
#define TRF7950_DCDC_NA   (TRF7950_DCDC_VSEL1+0)
#define TRF7950_DCDC_3_6V (TRF7950_DCDC_VSEL1+TRF7950_DCDC_VSEL0)

#define TRF7950_DCDC_ISEL125MA  (0+0)
#define TRF7950_DCDC_ISEL250MA  (0+TRF7950_DCDC_ISEL0)
#define TRF7950_DCDC_ISEL500MA  (TRF7950_DCDC_ISEL1+0)
#define TRF7950_DCDC_ISEL600MA  (TRF7950_DCDC_ISEL1+TRF7950_DCDC_ISEL0)

#define TRF7950_DCDC_LOWBATT_0_8V (0+0)
#define TRF7950_DCDC_LOWBATT_0_9V (0+TRF7950_DCDC_VDCS0)
#define TRF7950_DCDC_LOWBATT_1_0V (TRF7950_DCDC_VDCS1+0)
#define TRF7950_DCDC_LOWBATT_1_1V (TRF7950_DCDC_VDCS1+TRF7950_DCDC_VDCS0)

#define TRF7950_CLOTXDEV_023OHMS (0+0+0)
#define TRF7950_CLOTXDEV_039OHMS (0+0+TRF7950_CLOTXDEV_RES0)
#define TRF7950_CLOTXDEV_073OHMS (0+TRF7950_CLOTXDEV_RES1+0)
#define TRF7950_CLOTXDEV_125OHMS (0+TRF7950_CLOTXDEV_RES1+TRF7950_CLOTXDEV_RES0)
#define TRF7950_CLOTXDEV_230OHMS (TRF7950_CLOTXDEV_RES2+0+0)
#define TRF7950_CLOTXDEV_390OHMS (TRF7950_CLOTXDEV_RES2+0+TRF7950_CLOTXDEV_RES0)

#define TRF7950_OSCSET_FI_0_00PF (0+0)
#define TRF7950_OSCSET_FI_0_90PF (0+BIT6)
#define TRF7950_OSCSET_FI_1_80PF (BIT7+0)
#define TRF7950_OSCSET_FI_2_70PF (BIT7+BIT6)

#define TRF7950_OSCSET_DEV_00_00PF (0+0+0)
#define TRF7950_OSCSET_DEV_01_30PF (0+0+BIT3)
#define TRF7950_OSCSET_DEV_02_70PF (0+BIT4+0)
#define TRF7950_OSCSET_DEV_04_30PF (0+BIT4+BIT3)
#define TRF7950_OSCSET_DEV_06_20PF (BIT5+0+0)
#define TRF7950_OSCSET_DEV_08_10PF (BIT5+0+BIT3)
#define TRF7950_OSCSET_DEV_10_20PF (BIT5+BIT1+0)
#define TRF7950_OSCSET_DEV_12_70PF (BIT5+BIT4+BIT3)

#define TRF7950_OSCSET_FT_0_00PF (0+0+0)
#define TRF7950_OSCSET_FT_0_40PF (0+0+BIT0)
#define TRF7950_OSCSET_FT_0_45PF (0+BIT1+0)
#define TRF7950_OSCSET_FT_1_30PF (0+BIT1+BIT0)
#define TRF7950_OSCSET_FT_1_80PF (BIT2+0+0)
#define TRF7950_OSCSET_FT_2_30PF (BIT2+0+BIT0)
#define TRF7950_OSCSET_FT_2_90PF (BIT2+BIT1+0)
#define TRF7950_OSCSET_FT_3_50PF (BIT2+BIT1+BIT0)

// TRF7950 Initial Register Settings

/* Transmit enabled; Oscillator enabled */
#define TRF7950_OPERATIONMODE_INIT \
        (TRF7950_OPMODE_ENTX + TRF7950_OPMODE_ENOSC)

/* DCDC = 3.3V; Peak current = 500mA; Low Batt = 1.0V */
#define TRF7950_DCDC_INIT \
        (TRF7950_DCDC_3_3V + TRF7950_DCDC_ISEL500MA + TRF7950_DCDC_LOWBATT_1_0V)

/* CLO freq = (DIV 4), FSK rate = low, TX out res = 39 ohms */
#define TRF7950_CLOTXDEV_INIT \
        (TRF7950_CLOTXDEV_CLODIV04 + TRF7950_CLOTXDEV_039OHMS)

/* Init Decline Cload = 0.00 pF; Dev Cload contribution = 6.20 pF; Init Cload contribution = 0.00 pF */
#define TRF7950_OSC0SETTING0_INIT \
        (TRF7950_OSCSET_FI_0_00PF + TRF7950_OSCSET_DEV_06_20PF + TRF7950_OSCSET_FT_0_00PF)

/* Init Decline Cload = 0.00 pF; Dev Cload contribution = 0.00 pF; Init Cload contribution = 0.00 pF */
#define TRF7950_OSC0SETTING1_INIT \
        (TRF7950_OSCSET_FI_0_00PF + TRF7950_OSCSET_DEV_00_00PF + TRF7950_OSCSET_FT_0_00PF)

/* Init Decline Cload = 0.00 pF; Dev Cload contribution = 6.20 pF; Init Cload contribution = 0.00 pF */
#define TRF7950_OSC1SETTING0_INIT \
        (TRF7950_OSCSET_FI_0_00PF + TRF7950_OSCSET_DEV_06_20PF + TRF7950_OSCSET_FT_0_00PF)

/* Init Decline Cload = 0.00 pF; Dev Cload contribution = 0.00 pF; Init Cload contribution = 0.00 pF */
#define TRF7950_OSC1SETTING1_INIT \
        (TRF7950_OSCSET_FI_0_00PF + TRF7950_OSCSET_DEV_00_00PF + TRF7950_OSCSET_FT_0_00PF)

/* All tests disabled */
#define TRF7950_TEST_INIT \
        0x00

// TRF7950 Register Addresses
#define TRF7950_OPERATIONMODE_ADDR  0x00
#define TRF7950_DCDC_ADDR           0x01
#define TRF7950_CLOTXDEV_ADDR       0x02
#define TRF7950_OSC0SETTING0_ADDR   0x03
#define TRF7950_OSC0SETTING1_ADDR   0x04
#define TRF7950_OSC1SETTING0_ADDR   0x05
#define TRF7950_OSC1SETTING1_ADDR   0x06
#define TRF7950_STATUS_ADDR         0x14
#define TRF7950_TEST_ADDR           0x15
#define TRF7950_TESTREG3456_ADDR    0x16

// TRF7950 Read/Write configuration settings
#define TRF7950_WRITE      0x80
#define TRF7950_READ       0x00
#define TRF7950_DUMMYDATA  0xFF

// TRF7950 Shadow Registers
typedef struct TRF7950_Regs {
  unsigned char OperationMode;
  unsigned char DCDC;
  unsigned char CLOTXDev;
  unsigned char OSC0Setting0;
  unsigned char OSC0Setting1;
  unsigned char OSC1Setting0;
  unsigned char OSC1Setting1;
  unsigned char status;
  unsigned char test;
  unsigned char test3456;
} TRF7950_Regs;

// ************************** FUNCTION PROTOTYPES **************************

void TRF7950_delayOperation(void);
// Usage:       Execute a set delay to separate each access to the TRF7950
// Parameters:  none
// Returns:     nothing

unsigned char TRF7950_readRegister(unsigned char regAddress);
// Usage:       Reads a byte from the TRF7950
// Parameters:  Desired register address
// Returns:     Most currently received data

void TRF7950_writeRegister(unsigned char regAddress, unsigned char data);
// Usage:       Writes a byte from the specified TRF7950 register
// Parameters:  Desired register address & data
// Returns:     nothing

void TRF7950_enableCS(void);
// Usage:       Asserts (active low) CS for the TRF7950 device
// Parameters:  none
// Returns:     nothing

void TRF7950_disableCS(void);
// Usage:       De-asserts (deactive high) CS for the TRF7950 device
// Parameters:  none
// Returns:     nothing

void TRF7950_enableTX(void);
// Usage:       Turns on the transmitter of the TRF7950 device
// Parameters:  none
// Returns:     nothing

void TRF7950_disableTX(void);
// Usage:       Turns off the transmitter of the TRF7950 device
// Parameters:  none
// Returns:     nothing

void TRF7950_disableCLO(void);
// Usage:       Turns off the clock output of the TRF7950 device
// Parameters:  none
// Returns:     nothing

WM430_SYS_Bool TRF7950_checkLowBattery(void);
// Usage:       Checks to see if the BAT input voltage drops below the low batt setting
// Parameters:  none
// Returns:     TRUE if battery voltage is low, FALSE otherwise

WM430_SYS_Bool TRF7950_init(void);
// Usage:       Executes proper sequence to bring up the TRF7950 device
// Parameters:  none
// Returns:     TRUE if success, FALSE otherwise

#endif /* _TI_TRF7950_H */

⌨️ 快捷键说明

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