3 void hal_get_ethernet_address( phw_data_t pHwData
, PUCHAR current_address
)
5 if( pHwData
->SurpriseRemove
) return;
7 memcpy( current_address
, pHwData
->CurrentMacAddress
, ETH_LENGTH_OF_ADDRESS
);
10 void hal_set_ethernet_address( phw_data_t pHwData
, PUCHAR current_address
)
14 if( pHwData
->SurpriseRemove
) return;
16 memcpy( pHwData
->CurrentMacAddress
, current_address
, ETH_LENGTH_OF_ADDRESS
);
18 ltmp
[0]= cpu_to_le32( *(PULONG
)pHwData
->CurrentMacAddress
);
19 ltmp
[1]= cpu_to_le32( *(PULONG
)(pHwData
->CurrentMacAddress
+ 4) ) & 0xffff;
21 Wb35Reg_BurstWrite( pHwData
, 0x03e8, ltmp
, 2, AUTO_INCREMENT
);
24 void hal_get_permanent_address( phw_data_t pHwData
, PUCHAR pethernet_address
)
26 if( pHwData
->SurpriseRemove
) return;
28 memcpy( pethernet_address
, pHwData
->PermanentMacAddress
, 6 );
31 u8
hal_init_hardware(phw_data_t pHwData
, PWB32_ADAPTER Adapter
)
34 pHwData
->Adapter
= Adapter
;
36 // Initial the variable
37 pHwData
->MaxReceiveLifeTime
= DEFAULT_MSDU_LIFE_TIME
; // Setting Rx maximum MSDU life time
38 pHwData
->FragmentThreshold
= DEFAULT_FRAGMENT_THRESHOLD
; // Setting default fragment threshold
40 if (WbUsb_initial(pHwData
)) {
41 pHwData
->InitialResource
= 1;
42 if( Wb35Reg_initial(pHwData
)) {
43 pHwData
->InitialResource
= 2;
44 if (Wb35Tx_initial(pHwData
)) {
45 pHwData
->InitialResource
= 3;
46 if (Wb35Rx_initial(pHwData
)) {
47 pHwData
->InitialResource
= 4;
48 OS_TIMER_INITIAL( &pHwData
->LEDTimer
, hal_led_control
, pHwData
);
49 OS_TIMER_SET( &pHwData
->LEDTimer
, 1000 ); // 20060623
52 // For restrict to vendor's hardware
54 SoftwareSet
= hal_software_set( pHwData
);
57 // Try to make sure the EEPROM contain
59 if( SoftwareSet
!= 0x82 )
63 Wb35Rx_start( pHwData
);
64 Wb35Tx_EP2VM_start( pHwData
);
72 pHwData
->SurpriseRemove
= 1;
77 void hal_halt(phw_data_t pHwData
, void *ppa_data
)
79 switch( pHwData
->InitialResource
)
82 case 3: OS_TIMER_CANCEL( &pHwData
->LEDTimer
, &cancel
);
83 OS_SLEEP(100000); // Wait for Timer DPC exit 940623.2
84 Wb35Rx_destroy( pHwData
); // Release the Rx
85 case 2: Wb35Tx_destroy( pHwData
); // Release the Tx
86 case 1: Wb35Reg_destroy( pHwData
); // Release the Wb35 Regisster resources
87 WbUsb_destroy( pHwData
);// Release the WbUsb
91 //---------------------------------------------------------------------------------------------------
92 void hal_set_rates(phw_data_t pHwData
, PUCHAR pbss_rates
,
93 u8 length
, unsigned char basic_rate_set
)
95 PWB35REG pWb35Reg
= &pHwData
->Wb35Reg
;
97 u8 Rate
[12]={ 2, 4, 11, 22, 12, 18, 24, 36, 48, 72, 96, 108 };
99 u8 i
, j
, k
, Count1
, Count2
, Byte
;
101 if( pHwData
->SurpriseRemove
) return;
103 if (basic_rate_set
) {
104 pWb35Reg
->M28_MacControl
&= ~0x000fff00;
107 pWb35Reg
->M28_MacControl
&= ~0xfff00000;
112 for (i
=0; i
<length
; i
++) {
113 Byte
= pbss_rates
[i
] & 0x7f;
114 for (j
=0; j
<12; j
++) {
115 if( Byte
== Rate
[j
] )
123 pWb35Reg
->M28_MacControl
|= tmp
;
124 Wb35Reg_Write( pHwData
, 0x0828, pWb35Reg
->M28_MacControl
);
126 // 930206.2.c M78 setting
127 j
= k
= Count1
= Count2
= 0;
128 memset( SupportedRate
, 0, 16 );
131 for (i
=0; i
<12; i
++) { // Get the supported rate
132 if (tmp
& pWb35Reg
->M28_MacControl
) {
133 SupportedRate
[j
] = Rate
[i
];
135 if (tmp1
& pWb35Reg
->M28_MacControl
)
136 SupportedRate
[j
] |= 0x80;
147 if( !(pWb35Reg
->M28_MacControl
& 0x000ff000) ) // if basic rate in 11g domain)
158 // Fill data into support rate until buffer full
159 //---20060926 add by anson's endian
161 *(PULONG
)(SupportedRate
+(i
<<2)) = cpu_to_le32( *(PULONG
)(SupportedRate
+(i
<<2)) );
162 //--- end 20060926 add by anson's endian
163 Wb35Reg_BurstWrite( pHwData
,0x087c, (PULONG
)SupportedRate
, 4, AUTO_INCREMENT
);
164 pWb35Reg
->M7C_MacControl
= ((PULONG
)SupportedRate
)[0];
165 pWb35Reg
->M80_MacControl
= ((PULONG
)SupportedRate
)[1];
166 pWb35Reg
->M84_MacControl
= ((PULONG
)SupportedRate
)[2];
167 pWb35Reg
->M88_MacControl
= ((PULONG
)SupportedRate
)[3];
170 tmp
= Count1
<<28 | Count2
<<24;
171 pWb35Reg
->M78_ERPInformation
&= ~0xff000000;
172 pWb35Reg
->M78_ERPInformation
|= tmp
;
173 Wb35Reg_Write( pHwData
, 0x0878, pWb35Reg
->M78_ERPInformation
);
177 //---------------------------------------------------------------------------------------------------
178 void hal_set_beacon_period( phw_data_t pHwData
, u16 beacon_period
)
182 if( pHwData
->SurpriseRemove
) return;
184 pHwData
->BeaconPeriod
= beacon_period
;
185 tmp
= pHwData
->BeaconPeriod
<< 16;
186 tmp
|= pHwData
->ProbeDelay
;
187 Wb35Reg_Write( pHwData
, 0x0848, tmp
);
191 void hal_set_current_channel_ex( phw_data_t pHwData
, ChanInfo channel
)
193 PWB35REG pWb35Reg
= &pHwData
->Wb35Reg
;
195 if( pHwData
->SurpriseRemove
)
198 printk("Going to channel: %d/%d\n", channel
.band
, channel
.ChanNo
);
200 RFSynthesizer_SwitchingChannel( pHwData
, channel
);// Switch channel
201 pHwData
->Channel
= channel
.ChanNo
;
202 pHwData
->band
= channel
.band
;
203 #ifdef _PE_STATE_DUMP_
204 WBDEBUG(("Set channel is %d, band =%d\n", pHwData
->Channel
, pHwData
->band
));
206 pWb35Reg
->M28_MacControl
&= ~0xff; // Clean channel information field
207 pWb35Reg
->M28_MacControl
|= channel
.ChanNo
;
208 Wb35Reg_WriteWithCallbackValue( pHwData
, 0x0828, pWb35Reg
->M28_MacControl
,
209 (PCHAR
)&channel
, sizeof(ChanInfo
));
211 //---------------------------------------------------------------------------------------------------
212 void hal_set_current_channel( phw_data_t pHwData
, ChanInfo channel
)
214 hal_set_current_channel_ex( pHwData
, channel
);
216 //---------------------------------------------------------------------------------------------------
217 void hal_get_current_channel( phw_data_t pHwData
, ChanInfo
*channel
)
219 channel
->ChanNo
= pHwData
->Channel
;
220 channel
->band
= pHwData
->band
;
222 //---------------------------------------------------------------------------------------------------
223 void hal_set_accept_broadcast( phw_data_t pHwData
, u8 enable
)
225 PWB35REG pWb35Reg
= &pHwData
->Wb35Reg
;
227 if( pHwData
->SurpriseRemove
) return;
229 pWb35Reg
->M00_MacControl
&= ~0x02000000;//The HW value
232 pWb35Reg
->M00_MacControl
|= 0x02000000;//The HW value
234 Wb35Reg_Write( pHwData
, 0x0800, pWb35Reg
->M00_MacControl
);
237 //for wep key error detection, we need to accept broadcast packets to be received temporary.
238 void hal_set_accept_promiscuous( phw_data_t pHwData
, u8 enable
)
240 PWB35REG pWb35Reg
= &pHwData
->Wb35Reg
;
242 if (pHwData
->SurpriseRemove
) return;
244 pWb35Reg
->M00_MacControl
|= 0x00400000;
245 Wb35Reg_Write( pHwData
, 0x0800, pWb35Reg
->M00_MacControl
);
247 pWb35Reg
->M00_MacControl
&=~0x00400000;
248 Wb35Reg_Write( pHwData
, 0x0800, pWb35Reg
->M00_MacControl
);
252 void hal_set_accept_multicast( phw_data_t pHwData
, u8 enable
)
254 PWB35REG pWb35Reg
= &pHwData
->Wb35Reg
;
256 if( pHwData
->SurpriseRemove
) return;
258 pWb35Reg
->M00_MacControl
&= ~0x01000000;//The HW value
259 if (enable
) pWb35Reg
->M00_MacControl
|= 0x01000000;//The HW value
260 Wb35Reg_Write( pHwData
, 0x0800, pWb35Reg
->M00_MacControl
);
263 void hal_set_accept_beacon( phw_data_t pHwData
, u8 enable
)
265 PWB35REG pWb35Reg
= &pHwData
->Wb35Reg
;
267 if( pHwData
->SurpriseRemove
) return;
270 if( !enable
)//Due to SME and MLME are not suitable for 35
273 pWb35Reg
->M00_MacControl
&= ~0x04000000;//The HW value
275 pWb35Reg
->M00_MacControl
|= 0x04000000;//The HW value
277 Wb35Reg_Write( pHwData
, 0x0800, pWb35Reg
->M00_MacControl
);
279 //---------------------------------------------------------------------------------------------------
280 void hal_set_multicast_address( phw_data_t pHwData
, PUCHAR address
, u8 number
)
282 PWB35REG pWb35Reg
= &pHwData
->Wb35Reg
;
285 if( pHwData
->SurpriseRemove
) return;
287 //Erases and refills the card multicast registers. Used when an address
288 // has been deleted and all bits must be recomputed.
289 pWb35Reg
->M04_MulticastAddress1
= 0;
290 pWb35Reg
->M08_MulticastAddress2
= 0;
295 CardGetMulticastBit( (address
+(number
*ETH_LENGTH_OF_ADDRESS
)), &Byte
, &Bit
);
296 pWb35Reg
->Multicast
[Byte
] |= Bit
;
300 Wb35Reg_BurstWrite( pHwData
, 0x0804, (PULONG
)pWb35Reg
->Multicast
, 2, AUTO_INCREMENT
);
302 //---------------------------------------------------------------------------------------------------
303 u8
hal_get_accept_beacon( phw_data_t pHwData
)
305 PWB35REG pWb35Reg
= &pHwData
->Wb35Reg
;
307 if( pHwData
->SurpriseRemove
) return 0;
309 if( pWb35Reg
->M00_MacControl
& 0x04000000 )
315 unsigned char hal_reset_hardware( phw_data_t pHwData
, void* ppa
)
321 void hal_stop( phw_data_t pHwData
)
323 PWB35REG pWb35Reg
= &pHwData
->Wb35Reg
;
325 pHwData
->Wb35Rx
.rx_halt
= 1;
326 Wb35Rx_stop( pHwData
);
328 pHwData
->Wb35Tx
.tx_halt
= 1;
329 Wb35Tx_stop( pHwData
);
331 pWb35Reg
->D00_DmaControl
&= ~0xc0000000;//Tx Off, Rx Off
332 Wb35Reg_Write( pHwData
, 0x0400, pWb35Reg
->D00_DmaControl
);
334 WbUsb_Stop( pHwData
); // 20051230 Add.4
337 unsigned char hal_idle(phw_data_t pHwData
)
339 PWB35REG pWb35Reg
= &pHwData
->Wb35Reg
;
340 PWBUSB pWbUsb
= &pHwData
->WbUsb
;
342 if( !pHwData
->SurpriseRemove
&& ( pWbUsb
->DetectCount
|| pWb35Reg
->EP0vm_state
!=VM_STOP
) )
347 //---------------------------------------------------------------------------------------------------
348 void hal_set_cwmin( phw_data_t pHwData
, u8 cwin_min
)
350 PWB35REG pWb35Reg
= &pHwData
->Wb35Reg
;
352 if( pHwData
->SurpriseRemove
) return;
354 pHwData
->cwmin
= cwin_min
;
355 pWb35Reg
->M2C_MacControl
&= ~0x7c00; //bit 10 ~ 14
356 pWb35Reg
->M2C_MacControl
|= (pHwData
->cwmin
<<10);
357 Wb35Reg_Write( pHwData
, 0x082c, pWb35Reg
->M2C_MacControl
);
360 s32
hal_get_rssi( phw_data_t pHwData
, u32
*HalRssiArry
, u8 Count
)
362 PWB35REG pWb35Reg
= &pHwData
->Wb35Reg
;
367 if( pHwData
->SurpriseRemove
) return -200;
368 if( Count
> MAX_ACC_RSSI_COUNT
) // Because the TS may use this funtion
369 Count
= MAX_ACC_RSSI_COUNT
;
371 // RSSI = C1 + C2 * (agc_state[7:0] + offset_map(lna_state[1:0]))
372 // C1 = -195, C2 = 0.66 = 85/128
373 for (i
=0; i
<Count
; i
++)
375 r01
.value
= HalRssiArry
[i
];
376 tmp
= ((( r01
.R01_AGC_state
+ pWb35Reg
->LNAValue
[r01
.R01_LNA_state
]) * 85 ) >>7 ) - 195;
380 if( pHwData
->phy_type
== RF_AIROHA_2230
) ltmp
-= 5; // 10;
381 if( pHwData
->phy_type
== RF_AIROHA_2230S
) ltmp
-= 5; // 10; 20060420 Add this
383 //if( ltmp < -200 ) ltmp = -200;
384 if( ltmp
< -110 ) ltmp
= -110;// 1.0.24.0 For NJRC
388 //----------------------------------------------------------------------------------------------------
389 s32
hal_get_rssi_bss( phw_data_t pHwData
, u16 idx
, u8 Count
)
391 PWB35REG pWb35Reg
= &pHwData
->Wb35Reg
;
395 PADAPTER Adapter
= pHwData
->Adapter
;
396 // u32 *HalRssiArry = psBSS(idx)->HalRssi;
398 if( pHwData
->SurpriseRemove
) return -200;
399 if( Count
> MAX_ACC_RSSI_COUNT
) // Because the TS may use this funtion
400 Count
= MAX_ACC_RSSI_COUNT
;
402 // RSSI = C1 + C2 * (agc_state[7:0] + offset_map(lna_state[1:0]))
403 // C1 = -195, C2 = 0.66 = 85/128
405 for (i
=0; i
<Count
; i
++)
407 r01
.value
= HalRssiArry
[i
];
408 tmp
= ((( r01
.R01_AGC_state
+ pWb35Reg
->LNAValue
[r01
.R01_LNA_state
]) * 85 ) >>7 ) - 195;
412 if (psBSS(idx
)->HalRssiIndex
== 0)
413 psBSS(idx
)->HalRssiIndex
= MAX_ACC_RSSI_COUNT
;
414 j
= (u8
)psBSS(idx
)->HalRssiIndex
-1;
416 for (i
=0; i
<Count
; i
++)
418 r01
.value
= psBSS(idx
)->HalRssi
[j
];
419 tmp
= ((( r01
.R01_AGC_state
+ pWb35Reg
->LNAValue
[r01
.R01_LNA_state
]) * 85 ) >>7 ) - 195;
423 j
= MAX_ACC_RSSI_COUNT
;
429 if( pHwData
->phy_type
== RF_AIROHA_2230
) ltmp
-= 5; // 10;
430 if( pHwData
->phy_type
== RF_AIROHA_2230S
) ltmp
-= 5; // 10; 20060420 Add this
432 //if( ltmp < -200 ) ltmp = -200;
433 if( ltmp
< -110 ) ltmp
= -110;// 1.0.24.0 For NJRC
438 //---------------------------------------------------------------------------
439 void hal_led_control_1a( phw_data_t pHwData
)
441 hal_led_control( NULL
, pHwData
, NULL
, NULL
);
444 void hal_led_control( void* S1
, phw_data_t pHwData
, void* S3
, void* S4
)
446 PADAPTER Adapter
= pHwData
->Adapter
;
447 PWB35REG pWb35Reg
= &pHwData
->Wb35Reg
;
448 u32 LEDSet
= (pHwData
->SoftwareSet
& HAL_LED_SET_MASK
) >> HAL_LED_SET_SHIFT
;
449 u8 LEDgray
[20] = { 0,3,4,6,8,10,11,12,13,14,15,14,13,12,11,10,8,6,4,2 };
450 u8 LEDgray2
[30] = { 7,8,9,10,11,12,13,14,15,0,0,0,0,0,0,0,0,0,0,0,0,0,15,14,13,12,11,10,9,8 };
451 u32 TimeInterval
= 500, ltmp
, ltmp2
;
454 if( pHwData
->SurpriseRemove
) return;
456 if( pHwData
->LED_control
) {
457 ltmp2
= pHwData
->LED_control
& 0xff;
458 if( ltmp2
== 5 ) // 5 is WPS mode
461 ltmp2
= (pHwData
->LED_control
>>8) & 0xff;
464 case 1: // [0.2 On][0.1 Off]...
465 pHwData
->LED_Blinking
%= 3;
466 ltmp
= 0x1010; // Led 1 & 0 Green and Red
467 if( pHwData
->LED_Blinking
== 2 ) // Turn off
470 case 2: // [0.1 On][0.1 Off]...
471 pHwData
->LED_Blinking
%= 2;
472 ltmp
= 0x0010; // Led 0 red color
473 if( pHwData
->LED_Blinking
) // Turn off
476 case 3: // [0.1 On][0.1 Off][0.1 On][0.1 Off][0.1 On][0.1 Off][0.1 On][0.1 Off][0.1 On][0.1 Off][0.5 Off]...
477 pHwData
->LED_Blinking
%= 15;
478 ltmp
= 0x0010; // Led 0 red color
479 if( (pHwData
->LED_Blinking
>= 9) || (pHwData
->LED_Blinking
%2) ) // Turn off 0.6 sec
482 case 4: // [300 On][ off ]
483 ltmp
= 0x1000; // Led 1 Green color
484 if( pHwData
->LED_Blinking
>= 3000 )
485 ltmp
= 0; // led maybe on after 300sec * 32bit counter overlap.
488 pHwData
->LED_Blinking
++;
490 pWb35Reg
->U1BC_LEDConfigure
= ltmp
;
491 if( LEDSet
!= 7 ) // Only 111 mode has 2 LEDs on PCB.
493 pWb35Reg
->U1BC_LEDConfigure
|= (ltmp
&0xff)<<8; // Copy LED result to each LED control register
494 pWb35Reg
->U1BC_LEDConfigure
|= (ltmp
&0xff00)>>8;
496 Wb35Reg_Write( pHwData
, 0x03bc, pWb35Reg
->U1BC_LEDConfigure
);
499 else if( pHwData
->CurrentRadioSw
|| pHwData
->CurrentRadioHw
) // If radio off
501 if( pWb35Reg
->U1BC_LEDConfigure
& 0x1010 )
503 pWb35Reg
->U1BC_LEDConfigure
&= ~0x1010;
504 Wb35Reg_Write( pHwData
, 0x03bc, pWb35Reg
->U1BC_LEDConfigure
);
511 case 4: // [100] Only 1 Led be placed on PCB and use pin 21 of IC. Use LED_0 for showing
512 if( !pHwData
->LED_LinkOn
) // Blink only if not Link On
514 // Blinking if scanning is on progress
515 if( pHwData
->LED_Scanning
)
517 if( pHwData
->LED_Blinking
== 0 )
519 pWb35Reg
->U1BC_LEDConfigure
|= 0x10;
520 Wb35Reg_Write( pHwData
, 0x03bc, pWb35Reg
->U1BC_LEDConfigure
); // LED_0 On
521 pHwData
->LED_Blinking
= 1;
526 pWb35Reg
->U1BC_LEDConfigure
&= ~0x10;
527 Wb35Reg_Write( pHwData
, 0x03bc, pWb35Reg
->U1BC_LEDConfigure
); // LED_0 Off
528 pHwData
->LED_Blinking
= 0;
535 if( pWb35Reg
->U1BC_LEDConfigure
& 0x10 )
537 pWb35Reg
->U1BC_LEDConfigure
&= ~0x10;
538 Wb35Reg_Write( pHwData
, 0x03bc, pWb35Reg
->U1BC_LEDConfigure
); // LED_0 Off
545 if( (pWb35Reg
->U1BC_LEDConfigure
& 0x10) == 0 )
547 pWb35Reg
->U1BC_LEDConfigure
|= 0x10;
548 Wb35Reg_Write( pHwData
, 0x03bc, pWb35Reg
->U1BC_LEDConfigure
); // LED_0 Off
553 case 6: // [110] Only 1 Led be placed on PCB and use pin 21 of IC. Use LED_0 for showing
554 if( !pHwData
->LED_LinkOn
) // Blink only if not Link On
556 // Blinking if scanning is on progress
557 if( pHwData
->LED_Scanning
)
559 if( pHwData
->LED_Blinking
== 0 )
561 pWb35Reg
->U1BC_LEDConfigure
&= ~0xf;
562 pWb35Reg
->U1BC_LEDConfigure
|= 0x10;
563 Wb35Reg_Write( pHwData
, 0x03bc, pWb35Reg
->U1BC_LEDConfigure
); // LED_0 On
564 pHwData
->LED_Blinking
= 1;
569 pWb35Reg
->U1BC_LEDConfigure
&= ~0x1f;
570 Wb35Reg_Write( pHwData
, 0x03bc, pWb35Reg
->U1BC_LEDConfigure
); // LED_0 Off
571 pHwData
->LED_Blinking
= 0;
577 // 20060901 Gray blinking if in disconnect state and not scanning
578 ltmp
= pWb35Reg
->U1BC_LEDConfigure
;
579 pWb35Reg
->U1BC_LEDConfigure
&= ~0x1f;
580 if( LEDgray2
[(pHwData
->LED_Blinking
%30)] )
582 pWb35Reg
->U1BC_LEDConfigure
|= 0x10;
583 pWb35Reg
->U1BC_LEDConfigure
|= LEDgray2
[ (pHwData
->LED_Blinking
%30) ];
585 pHwData
->LED_Blinking
++;
586 if( pWb35Reg
->U1BC_LEDConfigure
!= ltmp
)
587 Wb35Reg_Write( pHwData
, 0x03bc, pWb35Reg
->U1BC_LEDConfigure
); // LED_0 Off
594 if( (pWb35Reg
->U1BC_LEDConfigure
& 0x10) == 0 )
596 pWb35Reg
->U1BC_LEDConfigure
|= 0x10;
597 Wb35Reg_Write( pHwData
, 0x03bc, pWb35Reg
->U1BC_LEDConfigure
); // LED_0 Off
602 case 5: // [101] Only 1 Led be placed on PCB and use LED_1 for showing
603 if( !pHwData
->LED_LinkOn
) // Blink only if not Link On
605 // Blinking if scanning is on progress
606 if( pHwData
->LED_Scanning
)
608 if( pHwData
->LED_Blinking
== 0 )
610 pWb35Reg
->U1BC_LEDConfigure
|= 0x1000;
611 Wb35Reg_Write( pHwData
, 0x03bc, pWb35Reg
->U1BC_LEDConfigure
); // LED_1 On
612 pHwData
->LED_Blinking
= 1;
617 pWb35Reg
->U1BC_LEDConfigure
&= ~0x1000;
618 Wb35Reg_Write( pHwData
, 0x03bc, pWb35Reg
->U1BC_LEDConfigure
); // LED_1 Off
619 pHwData
->LED_Blinking
= 0;
626 if( pWb35Reg
->U1BC_LEDConfigure
& 0x1000 )
628 pWb35Reg
->U1BC_LEDConfigure
&= ~0x1000;
629 Wb35Reg_Write( pHwData
, 0x03bc, pWb35Reg
->U1BC_LEDConfigure
); // LED_1 Off
635 // Is transmitting/receiving ??
636 if( (OS_CURRENT_RX_BYTE( Adapter
) != pHwData
->RxByteCountLast
) ||
637 (OS_CURRENT_TX_BYTE( Adapter
) != pHwData
->TxByteCountLast
) )
639 if( (pWb35Reg
->U1BC_LEDConfigure
& 0x3000) != 0x3000 )
641 pWb35Reg
->U1BC_LEDConfigure
|= 0x3000;
642 Wb35Reg_Write( pHwData
, 0x03bc, pWb35Reg
->U1BC_LEDConfigure
); // LED_1 On
646 pHwData
->RxByteCountLast
= OS_CURRENT_RX_BYTE( Adapter
);
647 pHwData
->TxByteCountLast
= OS_CURRENT_TX_BYTE( Adapter
);
652 // Turn On LED_1 and blinking if transmitting/receiving
653 if( (pWb35Reg
->U1BC_LEDConfigure
& 0x3000) != 0x1000 )
655 pWb35Reg
->U1BC_LEDConfigure
&= ~0x3000;
656 pWb35Reg
->U1BC_LEDConfigure
|= 0x1000;
657 Wb35Reg_Write( pHwData
, 0x03bc, pWb35Reg
->U1BC_LEDConfigure
); // LED_1 On
663 default: // Default setting. 2 LED be placed on PCB. LED_0: Link On LED_1 Active
664 if( (pWb35Reg
->U1BC_LEDConfigure
& 0x3000) != 0x3000 )
666 pWb35Reg
->U1BC_LEDConfigure
|= 0x3000;// LED_1 is always on and event enable
667 Wb35Reg_Write( pHwData
, 0x03bc, pWb35Reg
->U1BC_LEDConfigure
);
670 if( pHwData
->LED_Blinking
)
673 pWb35Reg
->U1BC_LEDConfigure
&= ~0x0f;
674 pWb35Reg
->U1BC_LEDConfigure
|= 0x10;
675 pWb35Reg
->U1BC_LEDConfigure
|= LEDgray
[ (pHwData
->LED_Blinking
-1)%20 ];
676 Wb35Reg_Write( pHwData
, 0x03bc, pWb35Reg
->U1BC_LEDConfigure
);
678 pHwData
->LED_Blinking
+= 2;
679 if( pHwData
->LED_Blinking
< 40 )
683 pHwData
->LED_Blinking
= 0; // Stop blinking
684 pWb35Reg
->U1BC_LEDConfigure
&= ~0x0f;
685 Wb35Reg_Write( pHwData
, 0x03bc, pWb35Reg
->U1BC_LEDConfigure
);
690 if( pHwData
->LED_LinkOn
)
692 if( !(pWb35Reg
->U1BC_LEDConfigure
& 0x10) ) // Check the LED_0
694 //Try to turn ON LED_0 after gray blinking
695 pWb35Reg
->U1BC_LEDConfigure
|= 0x10;
696 pHwData
->LED_Blinking
= 1; //Start blinking
702 if( pWb35Reg
->U1BC_LEDConfigure
& 0x10 ) // Check the LED_0
704 pWb35Reg
->U1BC_LEDConfigure
&= ~0x10;
705 Wb35Reg_Write( pHwData
, 0x03bc, pWb35Reg
->U1BC_LEDConfigure
);
711 //20060828.1 Active send null packet to avoid AP disconnect
712 if( pHwData
->LED_LinkOn
)
714 pHwData
->NullPacketCount
+= TimeInterval
;
715 if( pHwData
->NullPacketCount
>= DEFAULT_NULL_PACKET_COUNT
)
717 pHwData
->NullPacketCount
= 0;
722 pHwData
->time_count
+= TimeInterval
;
723 Wb35Tx_CurrentTime( pHwData
, pHwData
->time_count
); // 20060928 add
724 OS_TIMER_SET( &pHwData
->LEDTimer
, TimeInterval
); // 20060623.1
728 void hal_set_phy_type( phw_data_t pHwData
, u8 PhyType
)
730 pHwData
->phy_type
= PhyType
;
733 void hal_get_phy_type( phw_data_t pHwData
, u8
*PhyType
)
735 *PhyType
= pHwData
->phy_type
;
738 void hal_reset_counter( phw_data_t pHwData
)
740 pHwData
->dto_tx_retry_count
= 0;
741 pHwData
->dto_tx_frag_count
= 0;
742 memset( pHwData
->tx_retry_count
, 0, 8);
745 void hal_set_radio_mode( phw_data_t pHwData
, unsigned char radio_off
)
747 PWB35REG pWb35Reg
= &pHwData
->Wb35Reg
;
749 if( pHwData
->SurpriseRemove
) return;
751 if (radio_off
) //disable Baseband receive off
753 pHwData
->CurrentRadioSw
= 1; // off
754 pWb35Reg
->M24_MacControl
&= 0xffffffbf;
758 pHwData
->CurrentRadioSw
= 0; // on
759 pWb35Reg
->M24_MacControl
|= 0x00000040;
761 Wb35Reg_Write( pHwData
, 0x0824, pWb35Reg
->M24_MacControl
);
764 u8
hal_get_antenna_number( phw_data_t pHwData
)
766 PWB35REG pWb35Reg
= &pHwData
->Wb35Reg
;
768 if ((pWb35Reg
->BB2C
& BIT(11)) == 0)
774 void hal_set_antenna_number( phw_data_t pHwData
, u8 number
)
777 PWB35REG pWb35Reg
= &pHwData
->Wb35Reg
;
780 pWb35Reg
->BB2C
|= BIT(11);
782 pWb35Reg
->BB2C
&= ~BIT(11);
784 Wb35Reg_Write( pHwData
, 0x102c, pWb35Reg
->BB2C
);
785 #ifdef _PE_STATE_DUMP_
786 WBDEBUG(("Current antenna number : %d\n", number
));
790 //----------------------------------------------------------------------------------------------------
791 //0 : radio on; 1: radio off
792 u8
hal_get_hw_radio_off( phw_data_t pHwData
)
794 PWB35REG pWb35Reg
= &pHwData
->Wb35Reg
;
796 if( pHwData
->SurpriseRemove
) return 1;
798 //read the bit16 of register U1B0
799 Wb35Reg_Read( pHwData
, 0x3b0, &pWb35Reg
->U1B0
);
800 if ((pWb35Reg
->U1B0
& 0x00010000)) {
801 pHwData
->CurrentRadioHw
= 1;
804 pHwData
->CurrentRadioHw
= 0;
809 unsigned char hal_get_dxx_reg( phw_data_t pHwData
, u16 number
, PULONG pValue
)
811 if( number
< 0x1000 )
813 return Wb35Reg_ReadSync( pHwData
, number
, pValue
);
816 unsigned char hal_set_dxx_reg( phw_data_t pHwData
, u16 number
, u32 value
)
820 if( number
< 0x1000 )
822 ret
= Wb35Reg_WriteSync( pHwData
, number
, value
);
826 void hal_scan_status_indicate(phw_data_t pHwData
, unsigned char IsOnProgress
)
828 if( pHwData
->SurpriseRemove
) return;
829 pHwData
->LED_Scanning
= IsOnProgress
? 1 : 0;
832 void hal_system_power_change(phw_data_t pHwData
, u32 PowerState
)
834 if( PowerState
!= 0 )
836 pHwData
->SurpriseRemove
= 1;
837 if( pHwData
->WbUsb
.IsUsb20
)
842 if( !pHwData
->WbUsb
.IsUsb20
)
847 void hal_surprise_remove( phw_data_t pHwData
)
849 PADAPTER Adapter
= pHwData
->Adapter
;
850 if (OS_ATOMIC_INC( Adapter
, &pHwData
->SurpriseRemoveCount
) == 1) {
851 #ifdef _PE_STATE_DUMP_
852 WBDEBUG(("Calling hal_surprise_remove\n"));
858 void hal_rate_change( phw_data_t pHwData
) // Notify the HAL rate is changing 20060613.1
860 PADAPTER Adapter
= pHwData
->Adapter
;
861 u8 rate
= CURRENT_TX_RATE
;
863 BBProcessor_RateChanging( pHwData
, rate
);
866 void hal_set_rf_power(phw_data_t pHwData
, u8 PowerIndex
)
868 RFSynthesizer_SetPowerIndex( pHwData
, PowerIndex
);
871 unsigned char hal_set_LED(phw_data_t pHwData
, u32 Mode
) // 20061108 for WPS led control
873 pHwData
->LED_Blinking
= 0;
874 pHwData
->LED_control
= Mode
;
875 OS_TIMER_SET( &pHwData
->LEDTimer
, 10 ); // 20060623