3 void hal_get_ethernet_address( phw_data_t pHwData, u8 *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, u8 *current_address )
14 if( pHwData->SurpriseRemove ) return;
16 memcpy( pHwData->CurrentMacAddress, current_address, ETH_LENGTH_OF_ADDRESS );
18 ltmp[0]= cpu_to_le32( *(u32 *)pHwData->CurrentMacAddress );
19 ltmp[1]= cpu_to_le32( *(u32 *)(pHwData->CurrentMacAddress + 4) ) & 0xffff;
21 Wb35Reg_BurstWrite( pHwData, 0x03e8, ltmp, 2, AUTO_INCREMENT );
24 void hal_get_permanent_address( phw_data_t pHwData, u8 *pethernet_address )
26 if( pHwData->SurpriseRemove ) return;
28 memcpy( pethernet_address, pHwData->PermanentMacAddress, 6 );
31 u8 hal_init_hardware(phw_data_t pHwData, struct wb35_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 pHwData->InitialResource = 1;
41 if( Wb35Reg_initial(pHwData)) {
42 pHwData->InitialResource = 2;
43 if (Wb35Tx_initial(pHwData)) {
44 pHwData->InitialResource = 3;
45 if (Wb35Rx_initial(pHwData)) {
46 pHwData->InitialResource = 4;
47 OS_TIMER_INITIAL( &pHwData->LEDTimer, hal_led_control, pHwData );
48 OS_TIMER_SET( &pHwData->LEDTimer, 1000 ); // 20060623
51 // For restrict to vendor's hardware
53 SoftwareSet = hal_software_set( pHwData );
56 // Try to make sure the EEPROM contain
58 if( SoftwareSet != 0x82 )
62 Wb35Rx_start( pHwData );
63 Wb35Tx_EP2VM_start( pHwData );
70 pHwData->SurpriseRemove = 1;
75 void hal_halt(phw_data_t pHwData, void *ppa_data)
77 switch( pHwData->InitialResource )
80 case 3: OS_TIMER_CANCEL( &pHwData->LEDTimer, &cancel );
81 msleep(100); // Wait for Timer DPC exit 940623.2
82 Wb35Rx_destroy( pHwData ); // Release the Rx
83 case 2: Wb35Tx_destroy( pHwData ); // Release the Tx
84 case 1: Wb35Reg_destroy( pHwData ); // Release the Wb35 Regisster resources
88 //---------------------------------------------------------------------------------------------------
89 void hal_set_rates(phw_data_t pHwData, u8 *pbss_rates,
90 u8 length, unsigned char basic_rate_set)
92 struct wb35_reg *reg = &pHwData->reg;
94 u8 Rate[12]={ 2, 4, 11, 22, 12, 18, 24, 36, 48, 72, 96, 108 };
96 u8 i, j, k, Count1, Count2, Byte;
98 if( pHwData->SurpriseRemove ) return;
100 if (basic_rate_set) {
101 reg->M28_MacControl &= ~0x000fff00;
104 reg->M28_MacControl &= ~0xfff00000;
109 for (i=0; i<length; i++) {
110 Byte = pbss_rates[i] & 0x7f;
111 for (j=0; j<12; j++) {
112 if( Byte == Rate[j] )
120 reg->M28_MacControl |= tmp;
121 Wb35Reg_Write( pHwData, 0x0828, reg->M28_MacControl );
123 // 930206.2.c M78 setting
124 j = k = Count1 = Count2 = 0;
125 memset( SupportedRate, 0, 16 );
128 for (i=0; i<12; i++) { // Get the supported rate
129 if (tmp & reg->M28_MacControl) {
130 SupportedRate[j] = Rate[i];
132 if (tmp1 & reg->M28_MacControl)
133 SupportedRate[j] |= 0x80;
144 if( !(reg->M28_MacControl & 0x000ff000) ) // if basic rate in 11g domain)
155 // Fill data into support rate until buffer full
156 //---20060926 add by anson's endian
158 *(u32 *)(SupportedRate+(i<<2)) = cpu_to_le32( *(u32 *)(SupportedRate+(i<<2)) );
159 //--- end 20060926 add by anson's endian
160 Wb35Reg_BurstWrite( pHwData,0x087c, (u32 *)SupportedRate, 4, AUTO_INCREMENT );
161 reg->M7C_MacControl = ((u32 *)SupportedRate)[0];
162 reg->M80_MacControl = ((u32 *)SupportedRate)[1];
163 reg->M84_MacControl = ((u32 *)SupportedRate)[2];
164 reg->M88_MacControl = ((u32 *)SupportedRate)[3];
167 tmp = Count1<<28 | Count2<<24;
168 reg->M78_ERPInformation &= ~0xff000000;
169 reg->M78_ERPInformation |= tmp;
170 Wb35Reg_Write( pHwData, 0x0878, reg->M78_ERPInformation );
174 //---------------------------------------------------------------------------------------------------
175 void hal_set_beacon_period( phw_data_t pHwData, u16 beacon_period )
179 if( pHwData->SurpriseRemove ) return;
181 pHwData->BeaconPeriod = beacon_period;
182 tmp = pHwData->BeaconPeriod << 16;
183 tmp |= pHwData->ProbeDelay;
184 Wb35Reg_Write( pHwData, 0x0848, tmp );
188 void hal_set_current_channel_ex( phw_data_t pHwData, ChanInfo channel )
190 struct wb35_reg *reg = &pHwData->reg;
192 if( pHwData->SurpriseRemove )
195 printk("Going to channel: %d/%d\n", channel.band, channel.ChanNo);
197 RFSynthesizer_SwitchingChannel( pHwData, channel );// Switch channel
198 pHwData->Channel = channel.ChanNo;
199 pHwData->band = channel.band;
200 #ifdef _PE_STATE_DUMP_
201 WBDEBUG(("Set channel is %d, band =%d\n", pHwData->Channel, pHwData->band));
203 reg->M28_MacControl &= ~0xff; // Clean channel information field
204 reg->M28_MacControl |= channel.ChanNo;
205 Wb35Reg_WriteWithCallbackValue( pHwData, 0x0828, reg->M28_MacControl,
206 (s8 *)&channel, sizeof(ChanInfo));
208 //---------------------------------------------------------------------------------------------------
209 void hal_set_current_channel( phw_data_t pHwData, ChanInfo channel )
211 hal_set_current_channel_ex( pHwData, channel );
213 //---------------------------------------------------------------------------------------------------
214 void hal_get_current_channel( phw_data_t pHwData, ChanInfo *channel )
216 channel->ChanNo = pHwData->Channel;
217 channel->band = pHwData->band;
219 //---------------------------------------------------------------------------------------------------
220 void hal_set_accept_broadcast( phw_data_t pHwData, u8 enable )
222 struct wb35_reg *reg = &pHwData->reg;
224 if( pHwData->SurpriseRemove ) return;
226 reg->M00_MacControl &= ~0x02000000;//The HW value
229 reg->M00_MacControl |= 0x02000000;//The HW value
231 Wb35Reg_Write( pHwData, 0x0800, reg->M00_MacControl );
234 //for wep key error detection, we need to accept broadcast packets to be received temporary.
235 void hal_set_accept_promiscuous( phw_data_t pHwData, u8 enable)
237 struct wb35_reg *reg = &pHwData->reg;
239 if (pHwData->SurpriseRemove) return;
241 reg->M00_MacControl |= 0x00400000;
242 Wb35Reg_Write( pHwData, 0x0800, reg->M00_MacControl );
244 reg->M00_MacControl&=~0x00400000;
245 Wb35Reg_Write( pHwData, 0x0800, reg->M00_MacControl );
249 void hal_set_accept_multicast( phw_data_t pHwData, u8 enable )
251 struct wb35_reg *reg = &pHwData->reg;
253 if( pHwData->SurpriseRemove ) return;
255 reg->M00_MacControl &= ~0x01000000;//The HW value
256 if (enable) reg->M00_MacControl |= 0x01000000;//The HW value
257 Wb35Reg_Write( pHwData, 0x0800, reg->M00_MacControl );
260 void hal_set_accept_beacon( phw_data_t pHwData, u8 enable )
262 struct wb35_reg *reg = &pHwData->reg;
264 if( pHwData->SurpriseRemove ) return;
267 if( !enable )//Due to SME and MLME are not suitable for 35
270 reg->M00_MacControl &= ~0x04000000;//The HW value
272 reg->M00_MacControl |= 0x04000000;//The HW value
274 Wb35Reg_Write( pHwData, 0x0800, reg->M00_MacControl );
276 //---------------------------------------------------------------------------------------------------
277 void hal_set_multicast_address( phw_data_t pHwData, u8 *address, u8 number )
279 struct wb35_reg *reg = &pHwData->reg;
282 if( pHwData->SurpriseRemove ) return;
284 //Erases and refills the card multicast registers. Used when an address
285 // has been deleted and all bits must be recomputed.
286 reg->M04_MulticastAddress1 = 0;
287 reg->M08_MulticastAddress2 = 0;
292 CardGetMulticastBit( (address+(number*ETH_LENGTH_OF_ADDRESS)), &Byte, &Bit);
293 reg->Multicast[Byte] |= Bit;
297 Wb35Reg_BurstWrite( pHwData, 0x0804, (u32 *)reg->Multicast, 2, AUTO_INCREMENT );
299 //---------------------------------------------------------------------------------------------------
300 u8 hal_get_accept_beacon( phw_data_t pHwData )
302 struct wb35_reg *reg = &pHwData->reg;
304 if( pHwData->SurpriseRemove ) return 0;
306 if( reg->M00_MacControl & 0x04000000 )
312 unsigned char hal_reset_hardware( phw_data_t pHwData, void* ppa )
318 void hal_stop( phw_data_t pHwData )
320 struct wb35_reg *reg = &pHwData->reg;
322 pHwData->Wb35Rx.rx_halt = 1;
323 Wb35Rx_stop( pHwData );
325 pHwData->Wb35Tx.tx_halt = 1;
326 Wb35Tx_stop( pHwData );
328 reg->D00_DmaControl &= ~0xc0000000;//Tx Off, Rx Off
329 Wb35Reg_Write( pHwData, 0x0400, reg->D00_DmaControl );
332 unsigned char hal_idle(phw_data_t pHwData)
334 struct wb35_reg *reg = &pHwData->reg;
335 PWBUSB pWbUsb = &pHwData->WbUsb;
337 if( !pHwData->SurpriseRemove && ( pWbUsb->DetectCount || reg->EP0vm_state!=VM_STOP ) )
342 //---------------------------------------------------------------------------------------------------
343 void hal_set_cwmin( phw_data_t pHwData, u8 cwin_min )
345 struct wb35_reg *reg = &pHwData->reg;
347 if( pHwData->SurpriseRemove ) return;
349 pHwData->cwmin = cwin_min;
350 reg->M2C_MacControl &= ~0x7c00; //bit 10 ~ 14
351 reg->M2C_MacControl |= (pHwData->cwmin<<10);
352 Wb35Reg_Write( pHwData, 0x082c, reg->M2C_MacControl );
355 s32 hal_get_rssi( phw_data_t pHwData, u32 *HalRssiArry, u8 Count )
357 struct wb35_reg *reg = &pHwData->reg;
362 if( pHwData->SurpriseRemove ) return -200;
363 if( Count > MAX_ACC_RSSI_COUNT ) // Because the TS may use this funtion
364 Count = MAX_ACC_RSSI_COUNT;
366 // RSSI = C1 + C2 * (agc_state[7:0] + offset_map(lna_state[1:0]))
367 // C1 = -195, C2 = 0.66 = 85/128
368 for (i=0; i<Count; i++)
370 r01.value = HalRssiArry[i];
371 tmp = ((( r01.R01_AGC_state + reg->LNAValue[r01.R01_LNA_state]) * 85 ) >>7 ) - 195;
375 if( pHwData->phy_type == RF_AIROHA_2230 ) ltmp -= 5; // 10;
376 if( pHwData->phy_type == RF_AIROHA_2230S ) ltmp -= 5; // 10; 20060420 Add this
378 //if( ltmp < -200 ) ltmp = -200;
379 if( ltmp < -110 ) ltmp = -110;// 1.0.24.0 For NJRC
383 //----------------------------------------------------------------------------------------------------
384 s32 hal_get_rssi_bss( phw_data_t pHwData, u16 idx, u8 Count )
386 struct wb35_reg *reg = &pHwData->reg;
390 struct wb35_adapter * adapter = pHwData->adapter;
391 // u32 *HalRssiArry = psBSS(idx)->HalRssi;
393 if( pHwData->SurpriseRemove ) return -200;
394 if( Count > MAX_ACC_RSSI_COUNT ) // Because the TS may use this funtion
395 Count = MAX_ACC_RSSI_COUNT;
397 // RSSI = C1 + C2 * (agc_state[7:0] + offset_map(lna_state[1:0]))
398 // C1 = -195, C2 = 0.66 = 85/128
400 for (i=0; i<Count; i++)
402 r01.value = HalRssiArry[i];
403 tmp = ((( r01.R01_AGC_state + reg->LNAValue[r01.R01_LNA_state]) * 85 ) >>7 ) - 195;
407 if (psBSS(idx)->HalRssiIndex == 0)
408 psBSS(idx)->HalRssiIndex = MAX_ACC_RSSI_COUNT;
409 j = (u8)psBSS(idx)->HalRssiIndex-1;
411 for (i=0; i<Count; i++)
413 r01.value = psBSS(idx)->HalRssi[j];
414 tmp = ((( r01.R01_AGC_state + reg->LNAValue[r01.R01_LNA_state]) * 85 ) >>7 ) - 195;
418 j = MAX_ACC_RSSI_COUNT;
424 if( pHwData->phy_type == RF_AIROHA_2230 ) ltmp -= 5; // 10;
425 if( pHwData->phy_type == RF_AIROHA_2230S ) ltmp -= 5; // 10; 20060420 Add this
427 //if( ltmp < -200 ) ltmp = -200;
428 if( ltmp < -110 ) ltmp = -110;// 1.0.24.0 For NJRC
433 //---------------------------------------------------------------------------
434 void hal_led_control_1a( phw_data_t pHwData )
436 hal_led_control( NULL, pHwData, NULL, NULL );
439 void hal_led_control( void* S1, phw_data_t pHwData, void* S3, void* S4 )
441 struct wb35_adapter * adapter = pHwData->adapter;
442 struct wb35_reg *reg = &pHwData->reg;
443 u32 LEDSet = (pHwData->SoftwareSet & HAL_LED_SET_MASK) >> HAL_LED_SET_SHIFT;
444 u8 LEDgray[20] = { 0,3,4,6,8,10,11,12,13,14,15,14,13,12,11,10,8,6,4,2 };
445 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 };
446 u32 TimeInterval = 500, ltmp, ltmp2;
449 if( pHwData->SurpriseRemove ) return;
451 if( pHwData->LED_control ) {
452 ltmp2 = pHwData->LED_control & 0xff;
453 if( ltmp2 == 5 ) // 5 is WPS mode
456 ltmp2 = (pHwData->LED_control>>8) & 0xff;
459 case 1: // [0.2 On][0.1 Off]...
460 pHwData->LED_Blinking %= 3;
461 ltmp = 0x1010; // Led 1 & 0 Green and Red
462 if( pHwData->LED_Blinking == 2 ) // Turn off
465 case 2: // [0.1 On][0.1 Off]...
466 pHwData->LED_Blinking %= 2;
467 ltmp = 0x0010; // Led 0 red color
468 if( pHwData->LED_Blinking ) // Turn off
471 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]...
472 pHwData->LED_Blinking %= 15;
473 ltmp = 0x0010; // Led 0 red color
474 if( (pHwData->LED_Blinking >= 9) || (pHwData->LED_Blinking%2) ) // Turn off 0.6 sec
477 case 4: // [300 On][ off ]
478 ltmp = 0x1000; // Led 1 Green color
479 if( pHwData->LED_Blinking >= 3000 )
480 ltmp = 0; // led maybe on after 300sec * 32bit counter overlap.
483 pHwData->LED_Blinking++;
485 reg->U1BC_LEDConfigure = ltmp;
486 if( LEDSet != 7 ) // Only 111 mode has 2 LEDs on PCB.
488 reg->U1BC_LEDConfigure |= (ltmp &0xff)<<8; // Copy LED result to each LED control register
489 reg->U1BC_LEDConfigure |= (ltmp &0xff00)>>8;
491 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure );
494 else if( pHwData->CurrentRadioSw || pHwData->CurrentRadioHw ) // If radio off
496 if( reg->U1BC_LEDConfigure & 0x1010 )
498 reg->U1BC_LEDConfigure &= ~0x1010;
499 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure );
506 case 4: // [100] Only 1 Led be placed on PCB and use pin 21 of IC. Use LED_0 for showing
507 if( !pHwData->LED_LinkOn ) // Blink only if not Link On
509 // Blinking if scanning is on progress
510 if( pHwData->LED_Scanning )
512 if( pHwData->LED_Blinking == 0 )
514 reg->U1BC_LEDConfigure |= 0x10;
515 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure ); // LED_0 On
516 pHwData->LED_Blinking = 1;
521 reg->U1BC_LEDConfigure &= ~0x10;
522 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure ); // LED_0 Off
523 pHwData->LED_Blinking = 0;
530 if( reg->U1BC_LEDConfigure & 0x10 )
532 reg->U1BC_LEDConfigure &= ~0x10;
533 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure ); // LED_0 Off
540 if( (reg->U1BC_LEDConfigure & 0x10) == 0 )
542 reg->U1BC_LEDConfigure |= 0x10;
543 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure ); // LED_0 Off
548 case 6: // [110] Only 1 Led be placed on PCB and use pin 21 of IC. Use LED_0 for showing
549 if( !pHwData->LED_LinkOn ) // Blink only if not Link On
551 // Blinking if scanning is on progress
552 if( pHwData->LED_Scanning )
554 if( pHwData->LED_Blinking == 0 )
556 reg->U1BC_LEDConfigure &= ~0xf;
557 reg->U1BC_LEDConfigure |= 0x10;
558 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure ); // LED_0 On
559 pHwData->LED_Blinking = 1;
564 reg->U1BC_LEDConfigure &= ~0x1f;
565 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure ); // LED_0 Off
566 pHwData->LED_Blinking = 0;
572 // 20060901 Gray blinking if in disconnect state and not scanning
573 ltmp = reg->U1BC_LEDConfigure;
574 reg->U1BC_LEDConfigure &= ~0x1f;
575 if( LEDgray2[(pHwData->LED_Blinking%30)] )
577 reg->U1BC_LEDConfigure |= 0x10;
578 reg->U1BC_LEDConfigure |= LEDgray2[ (pHwData->LED_Blinking%30) ];
580 pHwData->LED_Blinking++;
581 if( reg->U1BC_LEDConfigure != ltmp )
582 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure ); // LED_0 Off
589 if( (reg->U1BC_LEDConfigure & 0x10) == 0 )
591 reg->U1BC_LEDConfigure |= 0x10;
592 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure ); // LED_0 Off
597 case 5: // [101] Only 1 Led be placed on PCB and use LED_1 for showing
598 if( !pHwData->LED_LinkOn ) // Blink only if not Link On
600 // Blinking if scanning is on progress
601 if( pHwData->LED_Scanning )
603 if( pHwData->LED_Blinking == 0 )
605 reg->U1BC_LEDConfigure |= 0x1000;
606 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure ); // LED_1 On
607 pHwData->LED_Blinking = 1;
612 reg->U1BC_LEDConfigure &= ~0x1000;
613 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure ); // LED_1 Off
614 pHwData->LED_Blinking = 0;
621 if( reg->U1BC_LEDConfigure & 0x1000 )
623 reg->U1BC_LEDConfigure &= ~0x1000;
624 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure ); // LED_1 Off
630 // Is transmitting/receiving ??
631 if( (OS_CURRENT_RX_BYTE( adapter ) != pHwData->RxByteCountLast ) ||
632 (OS_CURRENT_TX_BYTE( adapter ) != pHwData->TxByteCountLast ) )
634 if( (reg->U1BC_LEDConfigure & 0x3000) != 0x3000 )
636 reg->U1BC_LEDConfigure |= 0x3000;
637 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure ); // LED_1 On
641 pHwData->RxByteCountLast = OS_CURRENT_RX_BYTE( adapter );
642 pHwData->TxByteCountLast = OS_CURRENT_TX_BYTE( adapter );
647 // Turn On LED_1 and blinking if transmitting/receiving
648 if( (reg->U1BC_LEDConfigure & 0x3000) != 0x1000 )
650 reg->U1BC_LEDConfigure &= ~0x3000;
651 reg->U1BC_LEDConfigure |= 0x1000;
652 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure ); // LED_1 On
658 default: // Default setting. 2 LED be placed on PCB. LED_0: Link On LED_1 Active
659 if( (reg->U1BC_LEDConfigure & 0x3000) != 0x3000 )
661 reg->U1BC_LEDConfigure |= 0x3000;// LED_1 is always on and event enable
662 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure );
665 if( pHwData->LED_Blinking )
668 reg->U1BC_LEDConfigure &= ~0x0f;
669 reg->U1BC_LEDConfigure |= 0x10;
670 reg->U1BC_LEDConfigure |= LEDgray[ (pHwData->LED_Blinking-1)%20 ];
671 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure );
673 pHwData->LED_Blinking += 2;
674 if( pHwData->LED_Blinking < 40 )
678 pHwData->LED_Blinking = 0; // Stop blinking
679 reg->U1BC_LEDConfigure &= ~0x0f;
680 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure );
685 if( pHwData->LED_LinkOn )
687 if( !(reg->U1BC_LEDConfigure & 0x10) ) // Check the LED_0
689 //Try to turn ON LED_0 after gray blinking
690 reg->U1BC_LEDConfigure |= 0x10;
691 pHwData->LED_Blinking = 1; //Start blinking
697 if( reg->U1BC_LEDConfigure & 0x10 ) // Check the LED_0
699 reg->U1BC_LEDConfigure &= ~0x10;
700 Wb35Reg_Write( pHwData, 0x03bc, reg->U1BC_LEDConfigure );
706 //20060828.1 Active send null packet to avoid AP disconnect
707 if( pHwData->LED_LinkOn )
709 pHwData->NullPacketCount += TimeInterval;
710 if( pHwData->NullPacketCount >= DEFAULT_NULL_PACKET_COUNT )
712 pHwData->NullPacketCount = 0;
717 pHwData->time_count += TimeInterval;
718 Wb35Tx_CurrentTime( pHwData, pHwData->time_count ); // 20060928 add
719 OS_TIMER_SET( &pHwData->LEDTimer, TimeInterval ); // 20060623.1
723 void hal_set_phy_type( phw_data_t pHwData, u8 PhyType )
725 pHwData->phy_type = PhyType;
728 void hal_get_phy_type( phw_data_t pHwData, u8 *PhyType )
730 *PhyType = pHwData->phy_type;
733 void hal_reset_counter( phw_data_t pHwData )
735 pHwData->dto_tx_retry_count = 0;
736 pHwData->dto_tx_frag_count = 0;
737 memset( pHwData->tx_retry_count, 0, 8);
740 void hal_set_radio_mode( phw_data_t pHwData, unsigned char radio_off)
742 struct wb35_reg *reg = &pHwData->reg;
744 if( pHwData->SurpriseRemove ) return;
746 if (radio_off) //disable Baseband receive off
748 pHwData->CurrentRadioSw = 1; // off
749 reg->M24_MacControl &= 0xffffffbf;
753 pHwData->CurrentRadioSw = 0; // on
754 reg->M24_MacControl |= 0x00000040;
756 Wb35Reg_Write( pHwData, 0x0824, reg->M24_MacControl );
759 u8 hal_get_antenna_number( phw_data_t pHwData )
761 struct wb35_reg *reg = &pHwData->reg;
763 if ((reg->BB2C & BIT(11)) == 0)
769 void hal_set_antenna_number( phw_data_t pHwData, u8 number )
772 struct wb35_reg *reg = &pHwData->reg;
775 reg->BB2C |= BIT(11);
777 reg->BB2C &= ~BIT(11);
779 Wb35Reg_Write( pHwData, 0x102c, reg->BB2C );
780 #ifdef _PE_STATE_DUMP_
781 WBDEBUG(("Current antenna number : %d\n", number));
785 //----------------------------------------------------------------------------------------------------
786 //0 : radio on; 1: radio off
787 u8 hal_get_hw_radio_off( phw_data_t pHwData )
789 struct wb35_reg *reg = &pHwData->reg;
791 if( pHwData->SurpriseRemove ) return 1;
793 //read the bit16 of register U1B0
794 Wb35Reg_Read( pHwData, 0x3b0, ®->U1B0 );
795 if ((reg->U1B0 & 0x00010000)) {
796 pHwData->CurrentRadioHw = 1;
799 pHwData->CurrentRadioHw = 0;
804 unsigned char hal_get_dxx_reg( phw_data_t pHwData, u16 number, u32 * pValue )
806 if( number < 0x1000 )
808 return Wb35Reg_ReadSync( pHwData, number, pValue );
811 unsigned char hal_set_dxx_reg( phw_data_t pHwData, u16 number, u32 value )
815 if( number < 0x1000 )
817 ret = Wb35Reg_WriteSync( pHwData, number, value );
821 void hal_scan_status_indicate(phw_data_t pHwData, unsigned char IsOnProgress)
823 if( pHwData->SurpriseRemove ) return;
824 pHwData->LED_Scanning = IsOnProgress ? 1 : 0;
827 void hal_system_power_change(phw_data_t pHwData, u32 PowerState)
829 if( PowerState != 0 )
831 pHwData->SurpriseRemove = 1;
832 if( pHwData->WbUsb.IsUsb20 )
837 if( !pHwData->WbUsb.IsUsb20 )
842 void hal_surprise_remove( phw_data_t pHwData )
844 struct wb35_adapter * adapter = pHwData->adapter;
845 if (OS_ATOMIC_INC( adapter, &pHwData->SurpriseRemoveCount ) == 1) {
846 #ifdef _PE_STATE_DUMP_
847 WBDEBUG(("Calling hal_surprise_remove\n"));
853 void hal_rate_change( phw_data_t pHwData ) // Notify the HAL rate is changing 20060613.1
855 struct wb35_adapter * adapter = pHwData->adapter;
856 u8 rate = CURRENT_TX_RATE;
858 BBProcessor_RateChanging( pHwData, rate );
861 void hal_set_rf_power(phw_data_t pHwData, u8 PowerIndex)
863 RFSynthesizer_SetPowerIndex( pHwData, PowerIndex );
866 unsigned char hal_set_LED(phw_data_t pHwData, u32 Mode) // 20061108 for WPS led control
868 pHwData->LED_Blinking = 0;
869 pHwData->LED_control = Mode;
870 OS_TIMER_SET( &pHwData->LEDTimer, 10 ); // 20060623