named the rffilter_t unions, corrected some names, added first access functions

This commit is contained in:
mightymax 2007-01-11 21:37:50 +00:00
parent ad264d8e66
commit 0a3d236c1a
2 changed files with 142 additions and 34 deletions

103
desmume/src/wifi.c Normal file
View File

@ -0,0 +1,103 @@
/*
Copyright (C) 2007 Tim Seidel
This file is part of DeSmuME
DeSmuME is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
DeSmuME is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DeSmuME; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "wifi.h"
void WIFI_resetRF(rffilter_t *rf) {
/* reinitialize RF chip with the default values refer RF2958 docs */
/* CFG1 */
rf->CFG1.bits.IF_VGA_REG_EN = 1 ;
rf->CFG1.bits.IF_VCO_REG_EN = 1 ;
rf->CFG1.bits.RF_VCO_REG_EN = 1 ;
rf->CFG1.bits.HYBERNATE = 0 ;
rf->CFG1.bits.REF_SEL = 0 ;
/* IFPLL1 */
rf->IFPLL1.bits.DAC = 3 ;
rf->IFPLL1.bits.P1 = 0 ;
rf->IFPLL1.bits.LD_EN1 = 0 ;
rf->IFPLL1.bits.AUTOCAL_EN1 = 0 ;
rf->IFPLL1.bits.PDP1 = 1 ;
rf->IFPLL1.bits.CPL1 = 0 ;
rf->IFPLL1.bits.LPF1 = 0 ;
rf->IFPLL1.bits.VTC_EN1 = 1 ;
rf->IFPLL1.bits.KV_EN1 = 0 ;
rf->IFPLL1.bits.PLL_EN1 = 0 ;
/* IFPLL2 */
rf->IFPLL2.bits.IF_N = 0x22 ;
/* IFPLL3 */
rf->IFPLL3.bits.KV_DEF1 = 8 ;
rf->IFPLL3.bits.CT_DEF1 = 7 ;
rf->IFPLL3.bits.DN1 = 0x1FF ;
/* RFPLL1 */
rf->RFPLL1.bits.DAC = 3 ;
rf->RFPLL1.bits.P = 0 ;
rf->RFPLL1.bits.LD_EN = 0 ;
rf->RFPLL1.bits.AUTOCAL_EN = 0 ;
rf->RFPLL1.bits.PDP = 1 ;
rf->RFPLL1.bits.CPL = 0 ;
rf->RFPLL1.bits.LPF = 0 ;
rf->RFPLL1.bits.VTC_EN = 0 ;
rf->RFPLL1.bits.KV_EN = 0 ;
rf->RFPLL1.bits.PLL_EN = 0 ;
/* RFPLL2 */
rf->RFPLL2.bits.NUM2 = 0 ;
rf->RFPLL2.bits.N2 = 0x5E ;
/* RFPLL3 */
rf->RFPLL3.bits.NUM2 = 0 ;
/* RFPLL4 */
rf->RFPLL4.bits.KV_DEF = 8 ;
rf->RFPLL4.bits.CT_DEF = 7 ;
rf->RFPLL4.bits.DN = 0x145 ;
/* CAL1 */
rf->CAL1.bits.LD_WINDOW = 2 ;
rf->CAL1.bits.M_CT_VALUE = 8 ;
rf->CAL1.bits.TLOCK = 7 ;
rf->CAL1.bits.TVCO = 0x0F ;
/* TXRX1 */
rf->TXRX1.bits.TXBYPASS = 0 ;
rf->TXRX1.bits.INTBIASEN = 0 ;
rf->TXRX1.bits.TXENMODE = 0 ;
rf->TXRX1.bits.TXDIFFMODE = 0 ;
rf->TXRX1.bits.TXLPFBW = 2 ;
rf->TXRX1.bits.RXLPFBW = 2 ;
rf->TXRX1.bits.TXVGC = 0 ;
rf->TXRX1.bits.PCONTROL = 0 ;
rf->TXRX1.bits.RXDCFBBYPS = 0 ;
/* PCNT1 */
rf->PCNT1.bits.TX_DELAY = 0 ;
rf->PCNT1.bits.PC_OFFSET = 0 ;
rf->PCNT1.bits.P_DESIRED = 0 ;
rf->PCNT1.bits.MID_BIAS = 0 ;
/* PCNT2 */
rf->PCNT2.bits.MIN_POWER = 0 ;
rf->PCNT2.bits.MID_POWER = 0 ;
rf->PCNT2.bits.MAX_POWER = 0 ;
/* VCOT1 */
rf->VCOT1.bits.AUX1 = 0 ;
rf->VCOT1.bits.AUX = 0 ;
} ;
void WIFI_setRF_CNT(wifimac_t *wifi, u16 val)
{
wifi->rfIOCnt.val = val ;
}

View File

@ -25,15 +25,17 @@
extern "C" {
#endif
#include "types.h"
/* Referenced as RF_ in dswifi: rffilter_t */
/* based on the documentation for the RF2958 chip of RF Micro Devices */
/* using the register names as in docs ( http://www.rfmd.com/pdfs/2958.pdf )*/
/* even tho every register only has 18 bits we are using u32 */
typedef struct rffilter_t
{
union
union CFG1
{
struct
struct bits
{
/* 0*/ unsigned IF_VGA_REG_EN:1;
/* 1*/ unsigned IF_VCO_REG_EN:1;
@ -45,9 +47,9 @@ typedef struct rffilter_t
} bits ;
u32 val ;
} CFG1 ;
union
union IFPLL1
{
struct
struct bits
{
/* 0*/ unsigned DAC:4;
/* 4*/ unsigned :5;
@ -62,30 +64,30 @@ typedef struct rffilter_t
/*17*/ unsigned PLL_EN1:1;
} bits ;
u32 val ;
} IFPLL1
union
} IFPLL1 ;
union IFPLL2
{
struct
struct bits
{
/* 0*/ unsigned IF_N:16;
/*16*/ unsigned :2;
} bits ;
u32 val ;
} IFPLL2
union
} IFPLL2 ;
union IFPLL3
{
struct
struct bits
{
/* 0*/ unsigned KV_DEF:4;
/* 4*/ unsigned CT_DEF:4;
/* 0*/ unsigned KV_DEF1:4;
/* 4*/ unsigned CT_DEF1:4;
/* 8*/ unsigned DN1:9;
/*17*/ unsigned :1;
} bits ;
u32 val ;
} IFPLL3
union
} IFPLL3 ;
union RFPLL1
{
struct
struct bits
{
/* 0*/ unsigned DAC:4;
/* 4*/ unsigned :5;
@ -101,26 +103,26 @@ typedef struct rffilter_t
} bits ;
u32 val ;
} RFPLL1 ;
union
union RFPLL2
{
struct
struct bits
{
/* 0*/ unsigned NUM2:6;
/* 6*/ unsigned N2:12;
} bits ;
u32 val ;
} RFPLL2 ;
union
union RFPLL3
{
struct
struct bits
{
/* 0*/ unsigned NUM2:18;
} bits ;
u32 val ;
} RFPLL3 ;
union
union RFPLL4
{
struct
struct bits
{
/* 0*/ unsigned KV_DEF:4;
/* 4*/ unsigned CT_DEF:4;
@ -129,9 +131,9 @@ typedef struct rffilter_t
} bits ;
u32 val ;
} RFPLL4 ;
union
union CAL1
{
struct
struct bits
{
/* 0*/ unsigned LD_WINDOW:3;
/* 3*/ unsigned M_CT_VALUE:5;
@ -140,9 +142,9 @@ typedef struct rffilter_t
} bits ;
u32 val ;
} CAL1 ;
union
union TXRX1
{
struct
struct bits
{
/* 0*/ unsigned TXBYPASS:1;
/* 1*/ unsigned INTBIASEN:1;
@ -156,9 +158,9 @@ typedef struct rffilter_t
} bits ;
u32 val ;
} TXRX1 ;
union
union PCNT1
{
struct
struct bits
{
/* 0*/ unsigned TX_DELAY:3;
/* 3*/ unsigned PC_OFFSET:6;
@ -167,18 +169,18 @@ typedef struct rffilter_t
} bits ;
u32 val ;
} PCNT1 ;
union
union PCNT2
{
struct
struct bits
{
/* 0*/ unsigned MIN_POWER:6;
/* 6*/ unsigned MID_POWER:6;
/*12*/ unsigned MAX_POWER:6;
} bits ;
} PCNT2 ;
union
union VCOT1
{
struct
struct bits
{
/* 0*/ unsigned :16;
/*16*/ unsigned AUX1:1;
@ -192,14 +194,14 @@ typedef struct rffilter_t
/* it has at least 105 bytes of functional data */
typedef struct
{
bb_t data[105] ;
u8 data[105] ;
} bb_t ;
/* communication interface between RF,BB and the mac */
typedef union
{
struct {
/* 0*/ unsigned address:5;
/* 0*/ unsigned wordsize:5;
/* 5*/ unsigned :2;
/* 7*/ unsigned readOperation:1;
/* 8*/ unsigned :8;
@ -214,7 +216,7 @@ typedef union
/* 7*/ unsigned :5;
/*12*/ unsigned mode:2;
/*14*/ unsigned enable:1;
/*15*/ unsigned :!;
/*15*/ unsigned :1;
} bits ;
u16 val ;
} bbIOCnt_t ;
@ -268,6 +270,9 @@ typedef struct
} wifimac_t ;
void WIFI_setRF_CNT(wifimac_t *wifi, u16 val) ;
#ifdef __cplusplus
}
#endif