completed rf-chip communication interface
This commit is contained in:
parent
fdfb4d3d04
commit
d4a24ccfb7
|
@ -97,7 +97,52 @@ void WIFI_resetRF(rffilter_t *rf) {
|
|||
|
||||
void WIFI_setRF_CNT(wifimac_t *wifi, u16 val)
|
||||
{
|
||||
if (!wifi->rfIOStatus.bits.busy)
|
||||
wifi->rfIOCnt.val = val ;
|
||||
}
|
||||
|
||||
void WIFI_setRF_DATA(wifimac_t *wifi, u16 val, u8 part)
|
||||
{
|
||||
if (!wifi->rfIOStatus.bits.busy)
|
||||
{
|
||||
rfIOData_t *rfreg = (rfIOData_t *)&wifi->RF;
|
||||
switch (wifi->rfIOCnt.bits.readOperation)
|
||||
{
|
||||
case 1: /* read from RF chip */
|
||||
/* low part of data is ignored on reads */
|
||||
/* on high part, the address is read, and the data at this is written back */
|
||||
if (part==1)
|
||||
{
|
||||
wifi->rfIOData.array16[part] = val ;
|
||||
if (wifi->rfIOData.bits.address > (sizeof(wifi->RF) / 4)) return ; /* out of bound */
|
||||
/* get content of the addressed register */
|
||||
wifi->rfIOData.bits.content = rfreg[wifi->rfIOData.bits.address].bits.content ;
|
||||
}
|
||||
break ;
|
||||
case 0: /* write to RF chip */
|
||||
wifi->rfIOData.array16[part] = val ;
|
||||
if (wifi->rfIOData.bits.address > (sizeof(wifi->RF) / 4)) return ; /* out of bound */
|
||||
/* set content of the addressed register */
|
||||
rfreg[wifi->rfIOData.bits.address].bits.content = wifi->rfIOData.bits.content ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
u16 WIFI_getRF_DATA(wifimac_t *wifi, u8 part)
|
||||
{
|
||||
if (!wifi->rfIOStatus.bits.busy)
|
||||
{
|
||||
return wifi->rfIOData.array16[part] ;
|
||||
} else
|
||||
{ /* data is not (yet) available */
|
||||
return 0 ;
|
||||
}
|
||||
}
|
||||
|
||||
u16 WIFI_getRF_STATUS(wifimac_t *wifi)
|
||||
{
|
||||
return rfIOStatus.val ;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -209,6 +209,30 @@ typedef union
|
|||
u16 val ;
|
||||
} rfIOCnt_t ;
|
||||
|
||||
typedef union
|
||||
{
|
||||
struct {
|
||||
/* 0*/ unsigned busy:1;
|
||||
/* 1*/ unsigned :15;
|
||||
} bits ;
|
||||
u16 val ;
|
||||
} rfIOStat_t ;
|
||||
|
||||
typedef union
|
||||
{
|
||||
struct {
|
||||
/* 0*/ unsigned content:18 ;
|
||||
/*18*/ unsigned address:5;
|
||||
/*23*/ unsigned :9;
|
||||
} bits ;
|
||||
struct {
|
||||
/* 0*/ unsigned low:16 ;
|
||||
/*16*/ unsigned high:16 ;
|
||||
} val16 ;
|
||||
u16 array16[2] ;
|
||||
u32 val ;
|
||||
} rfIOData_t ;
|
||||
|
||||
typedef union
|
||||
{
|
||||
struct {
|
||||
|
@ -266,11 +290,18 @@ typedef struct
|
|||
|
||||
/* subchip communications */
|
||||
rfIOCnt_t rfIOCnt ;
|
||||
rfIOStat_t rfIOStatus ;
|
||||
rfIOData_t rfIOData ;
|
||||
bbIOCnt_t bbIOCnt ;
|
||||
|
||||
} wifimac_t ;
|
||||
|
||||
|
||||
/* subchip communication IO functions */
|
||||
void WIFI_setRF_CNT(wifimac_t *wifi, u16 val) ;
|
||||
void WIFI_setRF_DATA(wifimac_t *wifi, u16 val, u8 part) ;
|
||||
u16 WIFI_getRF_DATA(wifimac_t *wifi, u8 part) ;
|
||||
u16 WIFI_getRF_STATUS(wifimac_t *wifi) ;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
Loading…
Reference in New Issue