00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00035 #include <aversive.h>
00036
00037 #include "pwm.h"
00038
00039 #include <aversive/parts.h>
00040 #include <aversive/timers.h>
00041
00042 #include <pwm_config.h>
00043
00044 #include "timers_synch.h"
00045
00046 #if _PWM_CONFIG_VERSION_ != 2
00047 #warning "You are using an old version of pwm_config.h file"
00048 #warning "_PWM_CONFIG_VERSION_ is != 2"
00049 #warning "Look in modules/base/pwm/config directory to import changes"
00050 #warning "You should now use TIMERx_PRESCALER_DIV_XX from"
00051 #warning "include/aversive/parts.h that is arch specific"
00052 #endif
00053
00054 #ifdef TIMER1_MODE
00055
00056 #if (TIMER1_MODE == TIMER_16_MODE_PWM_10)
00057 #define TIMER1_PWM_BITS 10
00058 #elif (TIMER1_MODE == TIMER_16_MODE_PWM_9)
00059 #define TIMER1_PWM_BITS 9
00060 #elif (TIMER1_MODE == TIMER_16_MODE_PWM_8)
00061 #define TIMER1_PWM_BITS 8
00062 #else
00063 #error TIMER1 mode not valid, check pwm_config.h
00064 #endif
00065
00066 #endif // TIMER1_MODE
00067
00068 #ifdef TIMER3_MODE
00069
00070 #if (TIMER3_MODE == TIMER_16_MODE_PWM_10)
00071 #define TIMER3_PWM_BITS 10
00072 #elif (TIMER3_MODE == TIMER_16_MODE_PWM_9)
00073 #define TIMER3_PWM_BITS 9
00074 #elif (TIMER3_MODE == TIMER_16_MODE_PWM_8)
00075 #define TIMER3_PWM_BITS 8
00076 #else
00077 #error TIMER3 mode not valid, check pwm_config.h
00078 #endif
00079
00080 #endif // TIMER3_MODE
00081
00082 #if (PWM0_MODE & PWM_SIGNED)
00083 #define pwm0_init_ddr() \
00084 sbi(DDR(PWM0_SIGN_PORT), PWM0_SIGN_BIT); \
00085 cbi(PWM0_SIGN_PORT, PWM0_SIGN_BIT);
00086 #if (PWM0_MODE & PWM_SIGN_INVERTED)
00087 #define pwm0_sign_set() sbi(PWM0_SIGN_PORT, PWM0_SIGN_BIT);
00088 #define pwm0_sign_reset() cbi(PWM0_SIGN_PORT, PWM0_SIGN_BIT);
00089 #else
00090 #define pwm0_sign_set() cbi(PWM0_SIGN_PORT, PWM0_SIGN_BIT);
00091 #define pwm0_sign_reset() sbi(PWM0_SIGN_PORT, PWM0_SIGN_BIT);
00092 #endif
00093 #else
00094 #define pwm0_init_ddr()
00095 #define pwm0_sign_set()
00096 #define pwm0_sign_reset()
00097 #endif
00098
00099 #if (PWM1A_MODE & PWM_SIGNED)
00100 #define pwm1A_init_ddr() \
00101 sbi(DDR(PWM1A_SIGN_PORT), PWM1A_SIGN_BIT); \
00102 cbi(PWM1A_SIGN_PORT, PWM1A_SIGN_BIT);
00103 #if (PWM1A_MODE & PWM_SIGN_INVERTED)
00104 #define pwm1A_sign_set() sbi(PWM1A_SIGN_PORT, PWM1A_SIGN_BIT);
00105 #define pwm1A_sign_reset() cbi(PWM1A_SIGN_PORT, PWM1A_SIGN_BIT);
00106 #else
00107 #define pwm1A_sign_set() cbi(PWM1A_SIGN_PORT, PWM1A_SIGN_BIT);
00108 #define pwm1A_sign_reset() sbi(PWM1A_SIGN_PORT, PWM1A_SIGN_BIT);
00109 #endif
00110 #else
00111 #define pwm1A_init_ddr()
00112 #define pwm1A_sign_set()
00113 #define pwm1A_sign_reset()
00114 #endif
00115
00116 #if (PWM1B_MODE & PWM_SIGNED)
00117 #define pwm1B_init_ddr() \
00118 sbi(DDR(PWM1B_SIGN_PORT), PWM1B_SIGN_BIT); \
00119 cbi(PWM1B_SIGN_PORT, PWM1B_SIGN_BIT);
00120 #if (PWM1B_MODE & PWM_SIGN_INVERTED)
00121 #define pwm1B_sign_set() sbi(PWM1B_SIGN_PORT, PWM1B_SIGN_BIT);
00122 #define pwm1B_sign_reset() cbi(PWM1B_SIGN_PORT, PWM1B_SIGN_BIT);
00123 #else
00124 #define pwm1B_sign_set() cbi(PWM1B_SIGN_PORT, PWM1B_SIGN_BIT);
00125 #define pwm1B_sign_reset() sbi(PWM1B_SIGN_PORT, PWM1B_SIGN_BIT);
00126 #endif
00127 #else
00128 #define pwm1B_init_ddr()
00129 #define pwm1B_sign_set()
00130 #define pwm1B_sign_reset()
00131 #endif
00132
00133 #if (PWM1C_MODE & PWM_SIGNED)
00134 #define pwm1C_init_ddr() \
00135 sbi(DDR(PWM1C_SIGN_PORT), PWM1C_SIGN_BIT); \
00136 cbi(PWM1C_SIGN_PORT, PWM1C_SIGN_BIT);
00137 #if (PWM1C_MODE & PWM_SIGN_INVERTED)
00138 #define pwm1C_sign_set() sbi(PWM1C_SIGN_PORT, PWM1C_SIGN_BIT);
00139 #define pwm1C_sign_reset() cbi(PWM1C_SIGN_PORT, PWM1C_SIGN_BIT);
00140 #else
00141 #define pwm1C_sign_set() cbi(PWM1C_SIGN_PORT, PWM1C_SIGN_BIT);
00142 #define pwm1C_sign_reset() sbi(PWM1C_SIGN_PORT, PWM1C_SIGN_BIT);
00143 #endif
00144 #else
00145 #define pwm1C_init_ddr()
00146 #define pwm1C_sign_set()
00147 #define pwm1C_sign_reset()
00148 #endif
00149
00150 #if (PWM2_MODE & PWM_SIGNED)
00151 #define pwm2_init_ddr() \
00152 sbi(DDR(PWM2_SIGN_PORT), PWM2_SIGN_BIT); \
00153 cbi(PWM2_SIGN_PORT, PWM2_SIGN_BIT);
00154 #if (PWM2_MODE & PWM_SIGN_INVERTED)
00155 #define pwm2_sign_set() sbi(PWM2_SIGN_PORT, PWM2_SIGN_BIT);
00156 #define pwm2_sign_reset() cbi(PWM2_SIGN_PORT, PWM2_SIGN_BIT);
00157 #else
00158 #define pwm2_sign_set() cbi(PWM2_SIGN_PORT, PWM2_SIGN_BIT);
00159 #define pwm2_sign_reset() sbi(PWM2_SIGN_PORT, PWM2_SIGN_BIT);
00160 #endif
00161 #else
00162 #define pwm2_init_ddr()
00163 #define pwm2_sign_set()
00164 #define pwm2_sign_reset()
00165 #endif
00166
00167 #if (PWM3A_MODE & PWM_SIGNED)
00168 #define pwm3A_init_ddr() \
00169 sbi(DDR(PWM3A_SIGN_PORT), PWM3A_SIGN_BIT); \
00170 cbi(PWM3A_SIGN_PORT, PWM3A_SIGN_BIT);
00171 #if (PWM3A_MODE & PWM_SIGN_INVERTED)
00172 #define pwm3A_sign_set() sbi(PWM3A_SIGN_PORT, PWM3A_SIGN_BIT);
00173 #define pwm3A_sign_reset() cbi(PWM3A_SIGN_PORT, PWM3A_SIGN_BIT);
00174 #else
00175 #define pwm3A_sign_set() cbi(PWM3A_SIGN_PORT, PWM3A_SIGN_BIT);
00176 #define pwm3A_sign_reset() sbi(PWM3A_SIGN_PORT, PWM3A_SIGN_BIT);
00177 #endif
00178 #else
00179 #define pwm3A_init_ddr()
00180 #define pwm3A_sign_set()
00181 #define pwm3A_sign_reset()
00182 #endif
00183
00184 #if (PWM3B_MODE & PWM_SIGNED)
00185 #define pwm3B_init_ddr() \
00186 sbi(DDR(PWM3B_SIGN_PORT), PWM3B_SIGN_BIT); \
00187 cbi(PWM3B_SIGN_PORT, PWM3B_SIGN_BIT);
00188 #if (PWM3B_MODE & PWM_SIGN_INVERTED)
00189 #define pwm3B_sign_set() sbi(PWM3B_SIGN_PORT, PWM3B_SIGN_BIT);
00190 #define pwm3B_sign_reset() cbi(PWM3B_SIGN_PORT, PWM3B_SIGN_BIT);
00191 #else
00192 #define pwm3B_sign_set() cbi(PWM3B_SIGN_PORT, PWM3B_SIGN_BIT);
00193 #define pwm3B_sign_reset() sbi(PWM3B_SIGN_PORT, PWM3B_SIGN_BIT);
00194 #endif
00195 #else
00196 #define pwm3B_init_ddr()
00197 #define pwm3B_sign_set()
00198 #define pwm3B_sign_reset()
00199 #endif
00200
00201 #if (PWM3C_MODE & PWM_SIGNED)
00202 #define pwm3C_init_ddr() \
00203 sbi(DDR(PWM3C_SIGN_PORT), PWM3C_SIGN_BIT); \
00204 cbi(PWM3C_SIGN_PORT, PWM3C_SIGN_BIT);
00205 #if (PWM3C_MODE & PWM_SIGN_INVERTED)
00206 #define pwm3C_sign_set() sbi(PWM3C_SIGN_PORT, PWM3C_SIGN_BIT);
00207 #define pwm3C_sign_reset() cbi(PWM3C_SIGN_PORT, PWM3C_SIGN_BIT);
00208 #else
00209 #define pwm3C_sign_set() cbi(PWM3C_SIGN_PORT, PWM3C_SIGN_BIT);
00210 #define pwm3C_sign_reset() sbi(PWM3C_SIGN_PORT, PWM3C_SIGN_BIT);
00211 #endif
00212 #else
00213 #define pwm3C_init_ddr()
00214 #define pwm3C_sign_set()
00215 #define pwm3C_sign_reset()
00216 #endif
00217
00218
00219 #define pwm_invert_value(mode, value) \
00220 do { \
00221 if ( mode & PWM_SPECIAL_SIGN_MODE ) { \
00222 value = value & PWM_MAX; \
00223 } \
00224 else { \
00225 value = -value; \
00226 } \
00227 } while(0)
00228
00229
00230 #define pwm_timer_8bits_init(n, mode, prescale, timer_mode) \
00231 do { \
00232 TCCR##n = ( ( ( timer_mode & 0x01 )?( 1 << WGM##n##0 ):0 ) | \
00233 ( ( timer_mode & 0x02 )?( 1 << WGM##n##1 ):0 ) | \
00234 ( ( prescale << CS##n##0 ) ) ); \
00235 if(mode & PWM_REVERSE) { \
00236 TCCR##n = ( ( (TCCR##n) & (~(0x03 << COM##n##0)) ) | \
00237 (0x01 << COM##n##0) ); \
00238 } \
00239 else { \
00240 TCCR##n = ( ( (TCCR##n) & (~(0x03 << COM##n##0)) ) | \
00241 (0x02 << COM##n##0) ); \
00242 } \
00243 OCR##n = 0x00; \
00244 sbi(OCR##n##_DDR,OCR##n##_BIT); \
00245 pwm##n##_init_ddr(); \
00246 } while(0)
00247
00248
00249
00250
00251 #define pwm_timer_16bits_init(n, m, mode, prescale, timer_mode) \
00252 do { \
00253 TCCR##n##A = (TCCR##n##A | \
00254 ( ( timer_mode & 0x01 )?( 1 << WGM##n##0 ):0 ) | \
00255 ( ( timer_mode & 0x02 )?( 1 << WGM##n##1 ):0 ) ) ; \
00256 \
00257 TCCR##n##B = ( ( ( timer_mode & 0x04 )?( 1 << WGM##n##2 ):0 ) | \
00258 ( ( timer_mode & 0x08 )?( 1 << WGM##n##3 ):0 ) | \
00259 ( ( prescale << CS##n##0 ) ) ); \
00260 if(mode & PWM_REVERSE) { \
00261 TCCR##n##A = ( ( (TCCR##n##A) & \
00262 (~(0x03 << COM##n##m##0)) ) | \
00263 (0x01 << COM##n##m##0) ); \
00264 } \
00265 else { \
00266 TCCR##n##A = ( ( (TCCR##n##A) & \
00267 (~(0x03 << COM##n##m##0)) ) | \
00268 (0x02 << COM##n##m##0) ); \
00269 } \
00270 OCR##n##m = 0; \
00271 sbi(OCR##n##m##_DDR,OCR##n##m##_BIT); \
00272 pwm##n##m##_init_ddr(); \
00273 } while(0)
00274
00275
00276
00277
00278 #define pwm_timer_8bits_set(n, value, mode) \
00279 do { \
00280 MAX(value, PWM_MAX); \
00281 if ( mode & PWM_SIGNED ) { \
00282 MIN(value, PWM_MIN); \
00283 if (value < 0) { \
00284 pwm##n##_sign_set(); \
00285 pwm_invert_value(mode, value); \
00286 } \
00287 else { \
00288 pwm##n##_sign_reset(); \
00289 } \
00290 } \
00291 else { \
00292 MIN(value, 0); \
00293 } \
00294 OCR##n =(uint8_t) ( value >> ( PWM_SIGNIFICANT_BITS - 8 )); \
00295 } while(0)
00296
00297
00298
00299
00300 #define pwm_timer_16bits_set(n, m, value, mode) \
00301 do { \
00302 MAX(value, PWM_MAX); \
00303 if ( mode & PWM_SIGNED ) { \
00304 MIN(value, PWM_MIN); \
00305 if (value < 0) { \
00306 pwm##n##m##_sign_set(); \
00307 pwm_invert_value(mode, value); \
00308 } \
00309 else { \
00310 pwm##n##m##_sign_reset(); \
00311 } \
00312 } \
00313 else { \
00314 MIN(value, 0); \
00315 } \
00316 OCR##n##m = ( value >> ( PWM_SIGNIFICANT_BITS \
00317 - TIMER##n##_PWM_BITS )) ; \
00318 } while(0)
00319
00320
00321
00322
00323 #if (defined PWM0_NUM) && (defined PWM0_ENABLED)
00324 void pwm_init_0(void)
00325 {
00326 uint8_t flags;
00327
00328 IRQ_LOCK(flags);
00329 pwm_timer_8bits_init(0,PWM0_MODE,TIMER0_PRESCALE, TIMER0_MODE);
00330 IRQ_UNLOCK(flags);
00331 }
00332
00333
00334
00335 void pwm_set_0(int16_t value)
00336 {
00337 uint8_t flags;
00338
00339 IRQ_LOCK(flags);
00340 pwm_timer_8bits_set(0,value,PWM0_MODE);
00341 IRQ_UNLOCK(flags);
00342 }
00343 #endif // (defined PWM0_NUM) && (defined PWM0_ENABLED)
00344
00345
00346
00347
00348
00349
00350 #if (defined PWM1A_NUM) && (defined PWM1A_ENABLED)
00351 void pwm_init_1A(void)
00352 {
00353 uint8_t flags;
00354
00355 IRQ_LOCK(flags);
00356 pwm_timer_16bits_init(1,A,PWM1A_MODE,TIMER1_PRESCALE, TIMER1_MODE);
00357 IRQ_UNLOCK(flags);
00358 }
00359
00360
00361
00362
00363 void pwm_set_1A(int16_t value)
00364 {
00365 uint8_t flags;
00366
00367 IRQ_LOCK(flags);
00368 pwm_timer_16bits_set(1,A,value,PWM1A_MODE);
00369 IRQ_UNLOCK(flags);
00370 }
00371 #endif // (defined PWM1A_NUM) && (defined PWM1A_ENABLED)
00372
00373
00374
00375
00376
00377
00378
00379
00380 #if (defined PWM1B_NUM) && (defined PWM1B_ENABLED)
00381 void pwm_init_1B(void)
00382 {
00383 uint8_t flags;
00384
00385 IRQ_LOCK(flags);
00386 pwm_timer_16bits_init(1,B,PWM1B_MODE,TIMER1_PRESCALE, TIMER1_MODE);
00387 IRQ_UNLOCK(flags);
00388 }
00389
00390
00391
00392
00393 void pwm_set_1B(int16_t value)
00394 {
00395 uint8_t flags;
00396
00397 IRQ_LOCK(flags);
00398 pwm_timer_16bits_set(1,B,value,PWM1B_MODE);
00399 IRQ_UNLOCK(flags);
00400 }
00401 #endif // (defined PWM1B_NUM) && (defined PWM1B_ENABLED)
00402
00403
00404
00405
00406
00407
00408
00409
00410 #if (defined PWM1C_NUM) && (defined PWM1C_ENABLED)
00411 void pwm_init_1C(void)
00412 {
00413 uint8_t flags;
00414
00415 IRQ_LOCK(flags);
00416 pwm_timer_16bits_init(1,C,PWM1C_MODE,TIMER1_PRESCALE, TIMER1_MODE);
00417 IRQ_UNLOCK(flags);
00418 }
00419
00420
00421
00422
00423 void pwm_set_1C(int16_t value)
00424 {
00425 uint8_t flags;
00426
00427 IRQ_LOCK(flags);
00428 pwm_timer_16bits_set(1,C,value, PWM1C_MODE);
00429 IRQ_UNLOCK(flags);
00430 }
00431 #endif // (defined PWM1C_NUM) && (defined PWM1C_ENABLED)
00432
00433
00434
00435
00436
00437
00438
00439
00440 #if (defined PWM2_NUM) && (defined PWM2_ENABLED)
00441 void pwm_init_2(void)
00442 {
00443 uint8_t flags;
00444
00445 IRQ_LOCK(flags);
00446 pwm_timer_8bits_init(2,PWM2_MODE,TIMER2_PRESCALE, TIMER2_MODE);
00447 IRQ_UNLOCK(flags);
00448 }
00449
00450
00451
00452
00453 void pwm_set_2(int16_t value)
00454 {
00455 uint8_t flags;
00456
00457 IRQ_LOCK(flags);
00458 pwm_timer_8bits_set(2,value,PWM2_MODE);
00459 IRQ_UNLOCK(flags);
00460 }
00461 #endif // (defined PWM2_NUM) && (defined PWM2_ENABLED)
00462
00463
00464
00465
00466
00467
00468
00469
00470 #if (defined PWM3A_NUM) && (defined PWM3A_ENABLED)
00471 void pwm_init_3A(void)
00472 {
00473 uint8_t flags;
00474
00475 IRQ_LOCK(flags);
00476 pwm_timer_16bits_init(3,A,PWM3A_MODE,TIMER3_PRESCALE, TIMER3_MODE);
00477 IRQ_UNLOCK(flags);
00478 }
00479
00480
00481
00482
00483 void pwm_set_3A(int16_t value)
00484 {
00485 uint8_t flags;
00486
00487 IRQ_LOCK(flags);
00488 pwm_timer_16bits_set(3,A,value,PWM3A_MODE);
00489 IRQ_UNLOCK(flags);
00490 }
00491 #endif // (defined PWM3A_NUM) && (defined PWM3A_ENABLED)
00492
00493
00494
00495
00496
00497
00498
00499
00500 #if (defined PWM3B_NUM) && (defined PWM3B_ENABLED)
00501 void pwm_init_3B(void)
00502 {
00503 uint8_t flags;
00504
00505 IRQ_LOCK(flags);
00506 pwm_timer_16bits_init(3,B,PWM3B_MODE,TIMER3_PRESCALE, TIMER3_MODE);
00507 IRQ_UNLOCK(flags);
00508 }
00509
00510
00511
00512
00513 void pwm_set_3B(int16_t value)
00514 {
00515 uint8_t flags;
00516
00517 IRQ_LOCK(flags);
00518 pwm_timer_16bits_set(3,B,value,PWM3B_MODE);
00519 IRQ_UNLOCK(flags);
00520 }
00521 #endif // (defined PWM3B_NUM) && (defined PWM3B_ENABLED)
00522
00523
00524
00525
00526
00527
00528
00529
00530 #if (defined PWM3C_NUM) && (defined PWM3C_ENABLED)
00531 void pwm_init_3C(void)
00532 {
00533 uint8_t flags;
00534
00535 IRQ_LOCK(flags);
00536 pwm_timer_16bits_init(3,C,PWM3C_MODE,TIMER3_PRESCALE, TIMER3_MODE);
00537 IRQ_UNLOCK(flags);
00538 }
00539
00540
00541
00542
00543 void pwm_set_3C(int16_t value)
00544 {
00545 uint8_t flags;
00546
00547 IRQ_LOCK(flags);
00548 pwm_timer_16bits_set(3,C,value,PWM3C_MODE);
00549 IRQ_UNLOCK(flags);
00550 }
00551 #endif // (defined PWM3C_NUM) && (defined PWM3C_ENABLED)
00552
00553
00554
00555
00556
00557
00558
00559
00560 void pwm_init(void)
00561 {
00562 #if (defined PWM0_NUM) && (defined PWM0_ENABLED)
00563 pwm_init_0();
00564 #endif
00565
00566 #if (defined PWM1A_NUM) && (defined PWM1A_ENABLED)
00567 pwm_init_1A();
00568 #endif
00569 #if (defined PWM1B_NUM) && (defined PWM1B_ENABLED)
00570 pwm_init_1B();
00571 #endif
00572 #if (defined PWM1C_NUM) && (defined PWM1C_ENABLED)
00573 pwm_init_1C();
00574 #endif
00575
00576 #if (defined PWM2_NUM) && (defined PWM2_ENABLED)
00577 pwm_init_2();
00578 #endif
00579
00580 #if (defined PWM3A_NUM) && (defined PWM3A_ENABLED)
00581 pwm_init_3A();
00582 #endif
00583 #if (defined PWM3B_NUM) && (defined PWM3B_ENABLED)
00584 pwm_init_3B();
00585 #endif
00586 #if (defined PWM3C_NUM) && (defined PWM3C_ENABLED)
00587 pwm_init_3C();
00588 #endif
00589
00590
00591 #if ( (defined TIMER0_SYNCH) || (defined TIMER1_SYNCH) || (defined TIMER2_SYNCH) || (defined TIMER3_SYNCH) )
00592 pwm_synch();
00593 #endif // ( (defined TIMER0_SYNCH) || (defined TIMER1_SYNCH) || (defined TIMER2_SYNCH) || (defined TIMER3_SYNCH) )
00594
00595
00596 }
00597
00598
00599
00600
00601
00602
00603
00604
00605 void pwm_set(void * data, int32_t value)
00606 {
00607 uint8_t num = (uint8_t)(int)data;
00608 S_MAX(value, 0x7FFF);
00609
00610 switch(num)
00611 {
00612 #if (defined PWM0_NUM) && (defined PWM0_ENABLED)
00613 case PWM0_NUM:
00614 pwm_set_0(value);
00615 break;
00616 #endif
00617
00618 #if (defined PWM1A_NUM) && (defined PWM1A_ENABLED)
00619 case PWM1A_NUM:
00620 pwm_set_1A(value);
00621 break;
00622 #endif
00623 #if (defined PWM1B_NUM) && (defined PWM1B_ENABLED)
00624 case PWM1B_NUM:
00625 pwm_set_1B(value);
00626 break;
00627 #endif
00628 #if (defined PWM1C_NUM) && (defined PWM1C_ENABLED)
00629 case PWM1C_NUM:
00630 pwm_set_1C(value);
00631 break;
00632 #endif
00633
00634 #if (defined PWM2_NUM) && (defined PWM2_ENABLED)
00635 case PWM2_NUM:
00636 pwm_set_2(value);
00637 break;
00638 #endif
00639
00640 #if (defined PWM3A_NUM) && (defined PWM3A_ENABLED)
00641 case PWM3A_NUM:
00642 pwm_set_3A(value);
00643 break;
00644 #endif
00645 #if (defined PWM3B_NUM) && (defined PWM3B_ENABLED)
00646 case PWM3B_NUM:
00647 pwm_set_3B(value);
00648 break;
00649 #endif
00650 #if (defined PWM3C_NUM) && (defined PWM3C_ENABLED)
00651 case PWM3C_NUM:
00652 pwm_set_3C(value);
00653 break;
00654 #endif
00655
00656 default:
00657 break;
00658 }
00659
00660 }
00661
00662
00663