📄 phy_hw_setup.c
字号:
/************************************************************************************
* This file contains PHY HW specific initializations.
*
* Author(s): Thomas O. Jensen, Allan Poulsen, Michael V. Christensen
*
* (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:
************************************************************************************/
typedef enum ePhyEnums_t phyTxRxState_t;
/************************************************************************************
* Includes
************************************************************************************/
#include "DigiType.h"
#include "phy_spi.h"
#include "AbelReg.h"
#include "gb60_io.h"
#include "MacPhy.h"
#include "NV_Data.h"
#include "PhyMacMsg.h"
#include "Debug.h"
#include "Target.h"
// Prototypes to be used by phy
extern void DoFastRxEof(void);
extern void DoFastTxEof(void);
extern void RxTimeout(void);
extern uint16_t gIsrMask;
extern bool_t gStopAsyncRx;
extern bool_t gSeqInErrorState;
extern void SeqIsrCompletedInErrorState(void);
extern void ReStartRx(void);
extern void SeqGenerateWakeInd(void);
extern uint8_t gIsrEntryCounter;
#pragma PLACE_DATA_SEG(SLEEP_VARIABLE)
extern uint8_t gSeqPowerSaveMode;
extern uint8_t gSeqClkoState;
#pragma RESTORE_DATA_SEG
extern phyTxRxState_t mPhyTxRxState;
extern void ICG_Setup(void);
#define ICG_FLL_LOCKED 0x08
#define aAckSize_s 22
// Needed to initialize Timer1 vector
void DummyISR(void)
{
;
}
void (*pTimer1Isr)(void) = DummyISR; // Makes it possible to dynamically change interrupt vector for testing!
extern void (*gpTimer2Isr)(void);
extern void (*mpfPendingSetup)(void);
extern void RestartRxOrTimeout(void);
/************************************************************************************
*************************************************************************************
* Private memory declarations
*************************************************************************************
************************************************************************************/
uint8_t StreamingRxError; //Counts up when a StreamingRx interrupt is received, but not
//serviced by gIsrFastAction as expected
uint8_t StreamingTxError; //Counts up when a StreamingTx interrupt is received, but not
//serviced by gIsrFastAction as expected
// The following table contains addresses of Abel register to be initialized
// Each address has a corresponding value in the setupValueTable table. Do NOT
// change the order of occurence. It might be worth considering entering
// the initialization tables into the NV section for costumer control
static const uint8_t setupAddrTable[] = {
ABEL_reg8,
ABEL_LO1DIV_REG,
ABEL_LO1NUM_REG,
ABEL_reg11,
ABEL_reg12,
ABEL_reg13,
ABEL_reg31,
ABEL_reg38,
// Abel 2.2 only. May be removed for Abel 2.3. Fix for excess power consumption during hibernate and doze.
// Must activate thermometer and deactivate later for power to be low enough in these modes
ABEL_CONTROL2_REG,// Abel 2.2 only
ABEL_reg9, // Abel 2.2 only
//
ABEL_CONTROL2_REG,
ABEL_MASK_REG,
ABEL_reg9,
ABEL_TMR1_HI_REG, // Stop all wrap around interrupts
ABEL_TMR2_HI_REG,
ABEL_TMR3_HI_REG,
ABEL_TMR4_HI_REG,
ABEL_regB // Configured to all outputs (inputs on all but GPIO1 and GPIO2 : 0x01FC)
};
// The following table contains values of Abel registers to be initialized
// Each value has a address value in the setupAddrTable table. Do NOT
// change the order of occurence
static const uint16_t setupValueTable[] = {
0xFFF7, // R0x08: 0xFFF7
0x0F95, // 0x0F8F for 2305Mhz, 0x0F95 for 2405Mhz
0x5000, // 0x1000 for 2305MHz, 0x5000 for 2405MHz
0xA0FF, // 0xA0FF: Recommended setting from Phoenix team
0x00BC, // V1.2:0x80CC, default V2.0:0x000C : PA level
0x1843, // V1.2:0x1803, default V2.0:0x1863 : Sigma-delta fade detector differs
0xA000,
0x0008, // Correlator VT, 0x0000=Abel 1.2
// The next two are for Abel 2.2 only. May be removed for Abel 2.3. Fix for excess power consumption
// during hibernate and doze. Must activate thermometer and deactivate later for power to be low enough
// in these modes
0x7D3C, // For Abel 2.2 only
0xF3FD, // For Abel 2.2 only
// The next three values may not be evaluated in a pretty way, but it is very effective - let the preprocessor do the work
#define tmp1 (0x7c00 | cABEL2SPI_MASK | cUSE_STRM_MODE)
#ifdef USE_INTERRUPT_TXEOF
#define tmp2 (tmp1 | (uint16_t) cTX_DONE_MASK) // Yes, we want Tx done interrupts
#else
#define tmp2 (tmp1)
#endif
#ifdef USE_INTERRUPT_RXEOF
#define tmp3 (tmp2 | (uint16_t) cRX_DONE_MASK) // Yes, we want Rx done interrupts
#else
#define tmp3 (tmp2)
#endif
tmp3, // Setup interrupt mask
#define tmp4 (cTMR4_MASK | cTMR2_MASK | cLO1_LOCK_MASK)
#if gAspPowerSaveCapability_d
#define tmp5 (tmp4 | cDOZE_MASK | cTMR1_MASK)
#else
#define tmp5 (tmp4)
#endif
tmp5, // Write Abel Mask registers ("Control2" and "Mask")
#define tmp6 (0xF3FD & ~cTMR_PRESCALEmask)
#define tmp7 (tmp6 | (5 << cTMR_PRESCALEshift)) // 5=62.5kHz, 3=250kHz(default)
#define tmp8 (tmp7 | 0x80) // Alternate GPIO enable
tmp8,
0x8000, // Stop all wrap around interrupts
0x8000,
0x8000,
0x8000,
0x3F80 // Configured to all outputs (inputs on all but GPIO1 and GPIO2 : 0x01FC)
};
/*************************************************************************************
*************************************************************************************
* Private functions
*************************************************************************************
************************************************************************************/
/************************************************************************************
* SPI configured as ABEL interface *
************************************************************************************/
void InitAbelSPI(void)
{
// SPI Bit Clock Rate = BUSCLK / 2
PTED = 0x04; //PTED.2=SS = LOW : 0x00 for autoselect
PTEPE = 0x00;
PTEDD |= 0x34;
SPIC1 = 0x50; //SPIC1.1 = SSOE : 0x52 for autoselect
SPIC2 = 0x00; //SPIC2.4 = MODEEN : 0x10 for autoselect
SPIBR = 0x00;
SPIS;
}
/************************************************************************************
* All the complete systems I/O port definitions are described here *
************************************************************************************/
void InitPHYIO(void)
{
// Setup port A
mSETUP_PORT_A
// Setup Port B
mSETUP_PORT_B
// Setup port C
mSETUP_PORT_C
// Setup port D
mSETUP_PORT_D
CODE_PROFILING_ENABLE_PINS
ENABLE_TIMING_PINS
ENABLE_ISR_TIMING_PINS
RX_ANTENNE_ENABLED
RxTxEnable // RxTxEnable static = 1;
HWAssertAbelReset // keep Abel in reset for now
}
/*******************************************************************
* Make a pulse on hardware reset PIN at ABEL *
*******************************************************************/
void HWResetAbel(void)
{
HWAssertAbelReset //To ensure time goes....
HWAssertAbelReset
HWAssertAbelReset
HWAssertAbelReset
HWDeAssertAbelReset
}
/*******************************************************************
* Now use SPI to initialize ABEL *
*******************************************************************/
void AbelRegisterSetup(void)
{
uint8_t idx, addr;
uint16_t retReg;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -