このファイルのドキュメントを参照する00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifndef _AVR_POWER_H_
00032 #define _AVR_POWER_H_ 1
00033
00034 #include <avr/io.h>
00035 #include <stdint.h>
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357 #if defined(__AVR_ATxmega16A4__) \
00358 || defined(__AVR_ATxmega32A4__) \
00359 || defined(__AVR_ATxmega64A1__) \
00360 || defined(__AVR_ATxmega64A1U__) \
00361 || defined(__AVR_ATxmega64A3__) \
00362 || defined(__AVR_ATxmega128A1__) \
00363 || defined(__AVR_ATxmega128A1U__) \
00364 || defined(__AVR_ATxmega128A3__) \
00365 || defined(__AVR_ATxmega192A3__) \
00366 || defined(__AVR_ATxmega256A3__) \
00367 || defined(__AVR_ATxmega256A3B__)
00368
00369 #define power_aes_enable() (PR_PRGEN &= (uint8_t)~(PR_AES_bm))
00370 #define power_aes_disable() (PR_PRGEN |= (uint8_t)PR_AES_bm)
00371
00372 #define power_ebi_enable() (PR_PRGEN &= (uint8_t)~(PR_EBI_bm))
00373 #define power_ebi_disable() (PR_PRGEN |= (uint8_t)PR_EBI_bm)
00374
00375 #define power_dma_enable() (PR_PRGEN &= (uint8_t)~(PR_DMA_bm))
00376 #define power_dma_disable() (PR_PRGEN |= (uint8_t)PR_DMA_bm)
00377
00378 #define power_daca_enable() (PR_PRPA &= (uint8_t)~(PR_DAC_bm))
00379 #define power_daca_disable() (PR_PRPA |= (uint8_t)PR_DAC_bm)
00380 #define power_dacb_enable() (PR_PRPB &= (uint8_t)~(PR_DAC_bm))
00381 #define power_dacb_disable() (PR_PRPB |= (uint8_t)PR_DAC_bm)
00382
00383 #define power_usartc1_enable() (PR_PRPC &= (uint8_t)~(PR_USART1_bm))
00384 #define power_usartc1_disable() (PR_PRPC |= (uint8_t)PR_USART1_bm)
00385 #define power_usartd1_enable() (PR_PRPD &= (uint8_t)~(PR_USART1_bm))
00386 #define power_usartd1_disable() (PR_PRPD |= (uint8_t)PR_USART1_bm)
00387 #define power_usarte1_enable() (PR_PRPE &= (uint8_t)~(PR_USART1_bm))
00388 #define power_usarte1_disable() (PR_PRPE |= (uint8_t)PR_USART1_bm)
00389 #define power_usartf1_enable() (PR_PRPF &= (uint8_t)~(PR_USART1_bm))
00390 #define power_usartf1_disable() (PR_PRPF |= (uint8_t)PR_USART1_bm)
00391
00392 #define power_all_enable() \
00393 do { \
00394 PR_PRGEN &= (uint8_t)~(PR_AES_bm|PR_EBI_bm|PR_RTC_bm|PR_EVSYS_bm|PR_DMA_bm); \
00395 PR_PRPA &= (uint8_t)~(PR_DAC_bm|PR_ADC_bm|PR_AC_bm); \
00396 PR_PRPB &= (uint8_t)~(PR_DAC_bm|PR_ADC_bm|PR_AC_bm); \
00397 PR_PRPC &= (uint8_t)~(PR_TWI_bm|PR_USART1_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00398 PR_PRPD &= (uint8_t)~(PR_TWI_bm|PR_USART1_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00399 PR_PRPE &= (uint8_t)~(PR_TWI_bm|PR_USART1_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00400 PR_PRPF &= (uint8_t)~(PR_TWI_bm|PR_USART1_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00401 } while(0)
00402
00403
00404 #define power_all_disable() \
00405 do { \
00406 PR_PRGEN|= (uint8_t)(PR_AES_bm|PR_EBI_bm|PR_RTC_bm|PR_EVSYS_bm|PR_DMA_bm); \
00407 PR_PRPA |= (uint8_t)(PR_DAC_bm|PR_ADC_bm|PR_AC_bm); \
00408 PR_PRPB |= (uint8_t)(PR_DAC_bm|PR_ADC_bm|PR_AC_bm); \
00409 PR_PRPC |= (uint8_t)(PR_TWI_bm|PR_USART1_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00410 PR_PRPD |= (uint8_t)(PR_TWI_bm|PR_USART1_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00411 PR_PRPE |= (uint8_t)(PR_TWI_bm|PR_USART1_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00412 PR_PRPF |= (uint8_t)(PR_TWI_bm|PR_USART1_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00413 #endif
00414
00415 #if defined(__AVR_ATxmega16A4__) \
00416 || defined(__AVR_ATxmega16D4__) \
00417 || defined(__AVR_ATxmega32A4__) \
00418 || defined(__AVR_ATxmega32D4__) \
00419 || defined(__AVR_ATxmega64A1__) \
00420 || defined(__AVR_ATxmega64A1U__) \
00421 || defined(__AVR_ATxmega64A3__) \
00422 || defined(__AVR_ATxmega64D3__) \
00423 || defined(__AVR_ATxmega128A1__) \
00424 || defined(__AVR_ATxmega128A1U__) \
00425 || defined(__AVR_ATxmega128A3__) \
00426 || defined(__AVR_ATxmega128D3__) \
00427 || defined(__AVR_ATxmega192A3__) \
00428 || defined(__AVR_ATxmega192D3__) \
00429 || defined(__AVR_ATxmega256A3__) \
00430 || defined(__AVR_ATxmega256A3B__)
00431
00432
00433 #define power_rtc_enable() (PR_PRGEN &= (uint8_t)~(PR_RTC_bm))
00434 #define power_rtc_disable() (PR_PRGEN |= (uint8_t)PR_RTC_bm)
00435
00436 #define power_evsys_enable() (PR_PRGEN &= (uint8_t)~(PR_EVSYS_bm))
00437 #define power_evsys_disable() (PR_PRGEN |= (uint8_t)PR_EVSYS_bm)
00438
00439 #define power_adca_enable() (PR_PRPA &= (uint8_t)~(PR_ADC_bm))
00440 #define power_adca_disable() (PR_PRPA |= (uint8_t)PR_ADC_bm)
00441 #define power_adcb_enable() (PR_PRPB &= (uint8_t)~(PR_ADC_bm))
00442 #define power_adcb_disable() (PR_PRPB |= (uint8_t)PR_ADC_bm)
00443
00444 #define power_aca_enable() (PR_PRPA &= (uint8_t)~(PR_AC_bm))
00445 #define power_aca_disable() (PR_PRPA |= (uint8_t)PR_AC_bm)
00446 #define power_acb_enable() (PR_PRPB &= (uint8_t)~(PR_AC_bm))
00447 #define power_acb_disable() (PR_PRPB |= (uint8_t)PR_AC_bm)
00448
00449 #define power_twic_enable() (PR_PRPC &= (uint8_t)~(PR_TWI_bm))
00450 #define power_twic_disable() (PR_PRPC |= (uint8_t)PR_TWI_bm)
00451 #define power_twid_enable() (PR_PRPD &= (uint8_t)~(PR_TWI_bm))
00452 #define power_twid_disable() (PR_PRPD |= (uint8_t)PR_TWI_bm)
00453 #define power_twie_enable() (PR_PRPE &= (uint8_t)~(PR_TWI_bm))
00454 #define power_twie_disable() (PR_PRPE |= (uint8_t)PR_TWI_bm)
00455 #define power_twif_enable() (PR_PRPF &= (uint8_t)~(PR_TWI_bm))
00456 #define power_twif_disable() (PR_PRPF |= (uint8_t)PR_TWI_bm)
00457
00458 #define power_usartc0_enable() (PR_PRPC &= (uint8_t)~(PR_USART0_bm))
00459 #define power_usartc0_disable() (PR_PRPC |= (uint8_t)PR_USART0_bm)
00460 #define power_usartd0_enable() (PR_PRPD &= (uint8_t)~(PR_USART0_bm))
00461 #define power_usartd0_disable() (PR_PRPD |= (uint8_t)PR_USART0_bm)
00462 #define power_usarte0_enable() (PR_PRPE &= (uint8_t)~(PR_USART0_bm))
00463 #define power_usarte0_disable() (PR_PRPE |= (uint8_t)PR_USART0_bm)
00464 #define power_usartf0_enable() (PR_PRPF &= (uint8_t)~(PR_USART0_bm))
00465 #define power_usartf0_disable() (PR_PRPF |= (uint8_t)PR_USART0_bm)
00466
00467 #define power_spic_enable() (PR_PRPC &= (uint8_t)~(PR_SPI_bm))
00468 #define power_spic_disable() (PR_PRPC |= (uint8_t)PR_SPI_bm)
00469 #define power_spid_enable() (PR_PRPD &= (uint8_t)~(PR_SPI_bm))
00470 #define power_spid_disable() (PR_PRPD |= (uint8_t)PR_SPI_bm)
00471 #define power_spie_enable() (PR_PRPE &= (uint8_t)~(PR_SPI_bm))
00472 #define power_spie_disable() (PR_PRPE |= (uint8_t)PR_SPI_bm)
00473 #define power_spif_enable() (PR_PRPF &= (uint8_t)~(PR_SPI_bm))
00474 #define power_spif_disable() (PR_PRPF |= (uint8_t)PR_SPI_bm)
00475
00476 #define power_hiresc_enable() (PR_PRPC &= (uint8_t)~(PR_HIRES_bm))
00477 #define power_hiresc_disable() (PR_PRPC |= (uint8_t)PR_HIRES_bm)
00478 #define power_hiresd_enable() (PR_PRPD &= (uint8_t)~(PR_HIRES_bm))
00479 #define power_hiresd_disable() (PR_PRPD |= (uint8_t)PR_HIRES_bm)
00480 #define power_hirese_enable() (PR_PRPE &= (uint8_t)~(PR_HIRES_bm))
00481 #define power_hirese_disable() (PR_PRPE |= (uint8_t)PR_HIRES_bm)
00482 #define power_hiresf_enable() (PR_PRPF &= (uint8_t)~(PR_HIRES_bm))
00483 #define power_hiresf_disable() (PR_PRPF |= (uint8_t)PR_HIRES_bm)
00484
00485 #define power_tc1c_enable() (PR_PRPC &= (uint8_t)~(PR_TC1_bm))
00486 #define power_tc1c_disable() (PR_PRPC |= (uint8_t)PR_TC1_bm)
00487 #define power_tc1d_enable() (PR_PRPD &= (uint8_t)~(PR_TC1_bm))
00488 #define power_tc1d_disable() (PR_PRPD |= (uint8_t)PR_TC1_bm)
00489 #define power_tc1e_enable() (PR_PRPE &= (uint8_t)~(PR_TC1_bm))
00490 #define power_tc1e_disable() (PR_PRPE |= (uint8_t)PR_TC1_bm)
00491 #define power_tc1f_enable() (PR_PRPF &= (uint8_t)~(PR_TC1_bm))
00492 #define power_tc1f_disable() (PR_PRPF |= (uint8_t)PR_TC1_bm)
00493
00494 #define power_tc0c_enable() (PR_PRPC &= (uint8_t)~(PR_TC0_bm))
00495 #define power_tc0c_disable() (PR_PRPC |= (uint8_t)PR_TC0_bm)
00496 #define power_tc0d_enable() (PR_PRPD &= (uint8_t)~(PR_TC0_bm))
00497 #define power_tc0d_disable() (PR_PRPD |= (uint8_t)PR_TC0_bm)
00498 #define power_tc0e_enable() (PR_PRPE &= (uint8_t)~(PR_TC0_bm))
00499 #define power_tc0e_disable() (PR_PRPE |= (uint8_t)PR_TC0_bm)
00500 #define power_tc0f_enable() (PR_PRPF &= (uint8_t)~(PR_TC0_bm))
00501 #define power_tc0f_disable() (PR_PRPF |= (uint8_t)PR_TC0_bm)
00502
00503 #endif
00504
00505 #if defined(__AVR_ATxmega16D4__) \
00506 || defined(__AVR_ATxmega32D4__) \
00507 || defined(__AVR_ATxmega64D3__) \
00508 || defined(__AVR_ATxmega128D3__) \
00509 || defined(__AVR_ATxmega192D3__)
00510
00511 #define power_all_enable() \
00512 do { \
00513 PR_PRGEN &= (uint8_t)~(PR_RTC_bm|PR_EVSYS_bm); \
00514 PR_PRPA &= (uint8_t)~(PR_ADC_bm|PR_AC_bm); \
00515 PR_PRPB &= (uint8_t)~(PR_ADC_bm|PR_AC_bm); \
00516 PR_PRPC &= (uint8_t)~(PR_TWI_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00517 PR_PRPD &= (uint8_t)~(PR_TWI_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00518 PR_PRPE &= (uint8_t)~(PR_TWI_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00519 PR_PRPF &= (uint8_t)~(PR_TWI_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00520 } while(0)
00521
00522
00523 #define power_all_disable() \
00524 do { \
00525 PR_PRGEN|= (uint8_t)(PR_EBI_bm|PR_RTC_bm|PR_EVSYS_bm|PR_DMA_bm); \
00526 PR_PRPA |= (uint8_t)(PR_ADC_bm|PR_AC_bm); \
00527 PR_PRPB |= (uint8_t)(PR_ADC_bm|PR_AC_bm); \
00528 PR_PRPC |= (uint8_t)(PR_TWI_bm|R_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00529 PR_PRPD |= (uint8_t)(PR_TWI_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00530 PR_PRPE |= (uint8_t)(PR_TWI_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00531 PR_PRPF |= (uint8_t)(PR_TWI_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00532 } while(0)
00533
00534 #endif
00535
00536 #elif defined(__AVR_ATmega640__) \
00537 || defined(__AVR_ATmega1280__) \
00538 || defined(__AVR_ATmega1281__) \
00539 || defined(__AVR_ATmega2560__) \
00540 || defined(__AVR_ATmega2561__)
00541
00542 #define power_adc_enable() (PRR0 &= (uint8_t)~(1 << PRADC))
00543 #define power_adc_disable() (PRR0 |= (uint8_t)(1 << PRADC))
00544
00545 #define power_spi_enable() (PRR0 &= (uint8_t)~(1 << PRSPI))
00546 #define power_spi_disable() (PRR0 |= (uint8_t)(1 << PRSPI))
00547
00548 #define power_twi_enable() (PRR0 &= (uint8_t)~(1 << PRTWI))
00549 #define power_twi_disable() (PRR0 |= (uint8_t)(1 << PRTWI))
00550
00551 #define power_timer0_enable() (PRR0 &= (uint8_t)~(1 << PRTIM0))
00552 #define power_timer0_disable() (PRR0 |= (uint8_t)(1 << PRTIM0))
00553
00554 #define power_timer1_enable() (PRR0 &= (uint8_t)~(1 << PRTIM1))
00555 #define power_timer1_disable() (PRR0 |= (uint8_t)(1 << PRTIM1))
00556
00557 #define power_timer2_enable() (PRR0 &= (uint8_t)~(1 << PRTIM2))
00558 #define power_timer2_disable() (PRR0 |= (uint8_t)(1 << PRTIM2))
00559
00560 #define power_timer3_enable() (PRR1 &= (uint8_t)~(1 << PRTIM3))
00561 #define power_timer3_disable() (PRR1 |= (uint8_t)(1 << PRTIM3))
00562
00563 #define power_timer4_enable() (PRR1 &= (uint8_t)~(1 << PRTIM4))
00564 #define power_timer4_disable() (PRR1 |= (uint8_t)(1 << PRTIM4))
00565
00566 #define power_timer5_enable() (PRR1 &= (uint8_t)~(1 << PRTIM5))
00567 #define power_timer5_disable() (PRR1 |= (uint8_t)(1 << PRTIM5))
00568
00569 #define power_usart0_enable() (PRR0 &= (uint8_t)~(1 << PRUSART0))
00570 #define power_usart0_disable() (PRR0 |= (uint8_t)(1 << PRUSART0))
00571
00572 #define power_usart1_enable() (PRR1 &= (uint8_t)~(1 << PRUSART1))
00573 #define power_usart1_disable() (PRR1 |= (uint8_t)(1 << PRUSART1))
00574
00575 #define power_usart2_enable() (PRR1 &= (uint8_t)~(1 << PRUSART2))
00576 #define power_usart2_disable() (PRR1 |= (uint8_t)(1 << PRUSART2))
00577
00578 #define power_usart3_enable() (PRR1 &= (uint8_t)~(1 << PRUSART3))
00579 #define power_usart3_disable() (PRR1 |= (uint8_t)(1 << PRUSART3))
00580
00581 #define power_all_enable() \
00582 do{ \
00583 PRR0 &= (uint8_t)~((1<<PRADC)|(1<<PRSPI)|(1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)|(1<<PRUSART0)); \
00584 PRR1 &= (uint8_t)~((1<<PRTIM3)|(1<<PRTIM4)|(1<<PRTIM5)|(1<<PRTIM5)|(1<<PRUSART1)|(1<<PRUSART2)|(1<<PRUSART3)); \
00585 }while(0)
00586
00587 #define power_all_disable() \
00588 do{ \
00589 PRR0 |= (uint8_t)((1<<PRADC)|(1<<PRSPI)|(1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)|(1<<PRUSART0)); \
00590 PRR1 |= (uint8_t)((1<<PRTIM3)|(1<<PRTIM4)|(1<<PRTIM5)|(1<<PRTIM5)|(1<<PRUSART1)|(1<<PRUSART2)|(1<<PRUSART3)); \
00591 }while(0)
00592
00593
00594 #elif defined(__AVR_ATmega128RFA1__)
00595
00596 #define power_adc_enable() (PRR0 &= (uint8_t)~(1 << PRADC))
00597 #define power_adc_disable() (PRR0 |= (uint8_t)(1 << PRADC))
00598
00599 #define power_spi_enable() (PRR0 &= (uint8_t)~(1 << PRSPI))
00600 #define power_spi_disable() (PRR0 |= (uint8_t)(1 << PRSPI))
00601
00602 #define power_twi_enable() (PRR0 &= (uint8_t)~(1 << PRTWI))
00603 #define power_twi_disable() (PRR0 |= (uint8_t)(1 << PRTWI))
00604
00605 #define power_timer0_enable() (PRR0 &= (uint8_t)~(1 << PRTIM0))
00606 #define power_timer0_disable() (PRR0 |= (uint8_t)(1 << PRTIM0))
00607
00608 #define power_timer1_enable() (PRR0 &= (uint8_t)~(1 << PRTIM1))
00609 #define power_timer1_disable() (PRR0 |= (uint8_t)(1 << PRTIM1))
00610
00611 #define power_timer2_enable() (PRR0 &= (uint8_t)~(1 << PRTIM2))
00612 #define power_timer2_disable() (PRR0 |= (uint8_t)(1 << PRTIM2))
00613
00614 #define power_timer3_enable() (PRR1 &= (uint8_t)~(1 << PRTIM3))
00615 #define power_timer3_disable() (PRR1 |= (uint8_t)(1 << PRTIM3))
00616
00617 #define power_timer4_enable() (PRR1 &= (uint8_t)~(1 << PRTIM4))
00618 #define power_timer4_disable() (PRR1 |= (uint8_t)(1 << PRTIM4))
00619
00620 #define power_timer5_enable() (PRR1 &= (uint8_t)~(1 << PRTIM5))
00621 #define power_timer5_disable() (PRR1 |= (uint8_t)(1 << PRTIM5))
00622
00623 #define power_usart0_enable() (PRR0 &= (uint8_t)~(1 << PRUSART0))
00624 #define power_usart0_disable() (PRR0 |= (uint8_t)(1 << PRUSART0))
00625
00626 #define power_usart1_enable() (PRR1 &= (uint8_t)~(1 << PRUSART1))
00627 #define power_usart1_disable() (PRR1 |= (uint8_t)(1 << PRUSART1))
00628
00629 #define power_all_enable() \
00630 do{ \
00631 PRR0 &= (uint8_t)~((1<<PRADC)|(1<<PRSPI)|(1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)|(1<<PRUSART0)); \
00632 PRR1 &= (uint8_t)~((1<<PRTIM3)|(1<<PRTIM4)|(1<<PRTIM5)|(1<<PRTIM5)|(1<<PRUSART1)); \
00633 }while(0)
00634
00635 #define power_all_disable() \
00636 do{ \
00637 PRR0 |= (uint8_t)((1<<PRADC)|(1<<PRSPI)|(1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)|(1<<PRUSART0)); \
00638 PRR1 |= (uint8_t)((1<<PRTIM3)|(1<<PRTIM4)|(1<<PRTIM5)|(1<<PRTIM5)|(1<<PRUSART1)); \
00639 }while(0)
00640
00641
00642 #elif defined(__AVR_AT90USB646__) \
00643 || defined(__AVR_AT90USB647__) \
00644 || defined(__AVR_AT90USB1286__) \
00645 || defined(__AVR_AT90USB1287__)
00646
00647 #define power_adc_enable() (PRR0 &= (uint8_t)~(1 << PRADC))
00648 #define power_adc_disable() (PRR0 |= (uint8_t)(1 << PRADC))
00649
00650 #define power_spi_enable() (PRR0 &= (uint8_t)~(1 << PRSPI))
00651 #define power_spi_disable() (PRR0 |= (uint8_t)(1 << PRSPI))
00652
00653 #define power_twi_enable() (PRR0 &= (uint8_t)~(1 << PRTWI))
00654 #define power_twi_disable() (PRR0 |= (uint8_t)(1 << PRTWI))
00655
00656 #define power_timer0_enable() (PRR0 &= (uint8_t)~(1 << PRTIM0))
00657 #define power_timer0_disable() (PRR0 |= (uint8_t)(1 << PRTIM0))
00658
00659 #define power_timer1_enable() (PRR0 &= (uint8_t)~(1 << PRTIM1))
00660 #define power_timer1_disable() (PRR0 |= (uint8_t)(1 << PRTIM1))
00661
00662 #define power_timer2_enable() (PRR0 &= (uint8_t)~(1 << PRTIM2))
00663 #define power_timer2_disable() (PRR0 |= (uint8_t)(1 << PRTIM2))
00664
00665 #define power_timer3_enable() (PRR1 &= (uint8_t)~(1 << PRTIM3))
00666 #define power_timer3_disable() (PRR1 |= (uint8_t)(1 << PRTIM3))
00667
00668 #define power_usart1_enable() (PRR1 &= (uint8_t)~(1 << PRUSART1))
00669 #define power_usart1_disable() (PRR1 |= (uint8_t)(1 << PRUSART1))
00670
00671 #define power_usb_enable() (PRR1 &= (uint8_t)~(1 << PRUSB))
00672 #define power_usb_disable() (PRR1 |= (uint8_t)(1 << PRUSB))
00673
00674 #define power_all_enable() \
00675 do{ \
00676 PRR0 &= (uint8_t)~((1<<PRADC)|(1<<PRSPI)|(1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)); \
00677 PRR1 &= (uint8_t)~((1<<PRTIM3)|(1<<PRUSART1)|(1<<PRUSB)); \
00678 }while(0)
00679
00680 #define power_all_disable() \
00681 do{ \
00682 PRR0 |= (uint8_t)((1<<PRADC)|(1<<PRSPI)|(1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)); \
00683 PRR1 |= (uint8_t)((1<<PRTIM3)|(1<<PRUSART1)|(1<<PRUSB)); \
00684 }while(0)
00685
00686
00687 #elif defined(__AVR_ATmega32U4__) \
00688 || defined(__AVR_ATmega16U4__)
00689
00690
00691 #define power_adc_enable() (PRR0 &= (uint8_t)~(1 << PRADC))
00692 #define power_adc_disable() (PRR0 |= (uint8_t)(1 << PRADC))
00693
00694 #define power_usart0_enable() (PRR0 &= (uint8_t)~(1 << PRUSART0))
00695 #define power_usart0_disable() (PRR0 |= (uint8_t)(1 << PRUSART0))
00696
00697 #define power_spi_enable() (PRR0 &= (uint8_t)~(1 << PRSPI))
00698 #define power_spi_disable() (PRR0 |= (uint8_t)(1 << PRSPI))
00699
00700 #define power_twi_enable() (PRR0 &= (uint8_t)~(1 << PRTWI))
00701 #define power_twi_disable() (PRR0 |= (uint8_t)(1 << PRTWI))
00702
00703 #define power_timer0_enable() (PRR0 &= (uint8_t)~(1 << PRTIM0))
00704 #define power_timer0_disable() (PRR0 |= (uint8_t)(1 << PRTIM0))
00705
00706 #define power_timer1_enable() (PRR0 &= (uint8_t)~(1 << PRTIM1))
00707 #define power_timer1_disable() (PRR0 |= (uint8_t)(1 << PRTIM1))
00708
00709 #define power_timer2_enable() (PRR0 &= (uint8_t)~(1 << PRTIM2))
00710 #define power_timer2_disable() (PRR0 |= (uint8_t)(1 << PRTIM2))
00711
00712 #define power_timer3_enable() (PRR1 &= (uint8_t)~(1 << PRTIM3))
00713 #define power_timer3_disable() (PRR1 |= (uint8_t)(1 << PRTIM3))
00714
00715 #define power_usart1_enable() (PRR1 &= (uint8_t)~(1 << PRUSART1))
00716 #define power_usart1_disable() (PRR1 |= (uint8_t)(1 << PRUSART1))
00717
00718 #define power_usb_enable() (PRR1 &= (uint8_t)~(1 << PRUSB))
00719 #define power_usb_disable() (PRR1 |= (uint8_t)(1 << PRUSB))
00720
00721 #define power_all_enable() \
00722 do{ \
00723 PRR0 &= (uint8_t)~((1<<PRADC)|(1<<PRUSART0)|(1<<PRSPI)|(1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)); \
00724 PRR1 &= (uint8_t)~((1<<PRTIM3)|(1<<PRUSART1)|(1<<PRUSB)); \
00725 }while(0)
00726
00727 #define power_all_disable() \
00728 do{ \
00729 PRR0 |= (uint8_t)((1<<PRADC)|(1<<PRUSART0)|(1<<PRSPI)|(1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)); \
00730 PRR1 |= (uint8_t)((1<<PRTIM3)|(1<<PRUSART1)|(1<<PRUSB)); \
00731 }while(0)
00732
00733
00734 #elif defined(__AVR_ATmega32U6__)
00735
00736
00737 #define power_adc_enable() (PRR0 &= (uint8_t)~(1 << PRADC))
00738 #define power_adc_disable() (PRR0 |= (uint8_t)(1 << PRADC))
00739
00740 #define power_spi_enable() (PRR0 &= (uint8_t)~(1 << PRSPI))
00741 #define power_spi_disable() (PRR0 |= (uint8_t)(1 << PRSPI))
00742
00743 #define power_twi_enable() (PRR0 &= (uint8_t)~(1 << PRTWI))
00744 #define power_twi_disable() (PRR0 |= (uint8_t)(1 << PRTWI))
00745
00746 #define power_timer0_enable() (PRR0 &= (uint8_t)~(1 << PRTIM0))
00747 #define power_timer0_disable() (PRR0 |= (uint8_t)(1 << PRTIM0))
00748
00749 #define power_timer1_enable() (PRR0 &= (uint8_t)~(1 << PRTIM1))
00750 #define power_timer1_disable() (PRR0 |= (uint8_t)(1 << PRTIM1))
00751
00752 #define power_timer2_enable() (PRR0 &= (uint8_t)~(1 << PRTIM2))
00753 #define power_timer2_disable() (PRR0 |= (uint8_t)(1 << PRTIM2))
00754
00755 #define power_timer3_enable() (PRR1 &= (uint8_t)~(1 << PRTIM3))
00756 #define power_timer3_disable() (PRR1 |= (uint8_t)(1 << PRTIM3))
00757
00758 #define power_usart1_enable() (PRR1 &= (uint8_t)~(1 << PRUSART1))
00759 #define power_usart1_disable() (PRR1 |= (uint8_t)(1 << PRUSART1))
00760
00761 #define power_usb_enable() (PRR1 &= (uint8_t)~(1 << PRUSB))
00762 #define power_usb_disable() (PRR1 |= (uint8_t)(1 << PRUSB))
00763
00764 #define power_all_enable() \
00765 do{ \
00766 PRR0 &= (uint8_t)~((1<<PRADC)|(1<<PRSPI)|(1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)); \
00767 PRR1 &= (uint8_t)~((1<<PRTIM3)|(1<<PRUSART1)|(1<<PRUSB)); \
00768 }while(0)
00769
00770 #define power_all_disable() \
00771 do{ \
00772 PRR0 |= (uint8_t)((1<<PRADC)|(1<<PRSPI)|(1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)); \
00773 PRR1 |= (uint8_t)((1<<PRTIM3)|(1<<PRUSART1)|(1<<PRUSB)); \
00774 }while(0)
00775
00776
00777 #elif defined(__AVR_AT90PWM1__)
00778
00779 #define power_adc_enable() (PRR &= (uint8_t)~(1 << PRADC))
00780 #define power_adc_disable() (PRR |= (uint8_t)(1 << PRADC))
00781
00782 #define power_spi_enable() (PRR &= (uint8_t)~(1 << PRSPI))
00783 #define power_spi_disable() (PRR |= (uint8_t)(1 << PRSPI))
00784
00785 #define power_timer0_enable() (PRR &= (uint8_t)~(1 << PRTIM0))
00786 #define power_timer0_disable() (PRR |= (uint8_t)(1 << PRTIM0))
00787
00788 #define power_timer1_enable() (PRR &= (uint8_t)~(1 << PRTIM1))
00789 #define power_timer1_disable() (PRR |= (uint8_t)(1 << PRTIM1))
00790
00791
00792 #define power_psc0_enable() (PRR &= (uint8_t)~(1 << PRPSC0))
00793 #define power_psc0_disable() (PRR |= (uint8_t)(1 << PRPSC0))
00794
00795
00796 #define power_psc1_enable() (PRR &= (uint8_t)~(1 << PRPSC1))
00797 #define power_psc1_disable() (PRR |= (uint8_t)(1 << PRPSC1))
00798
00799
00800 #define power_psc2_enable() (PRR &= (uint8_t)~(1 << PRPSC2))
00801 #define power_psc2_disable() (PRR |= (uint8_t)(1 << PRPSC2))
00802
00803 #define power_all_enable() (PRR &= (uint8_t)~((1<<PRADC)|(1<<PRSPI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRPSC0)|(1<<PRPSC1)|(1<<PRPSC2)))
00804 #define power_all_disable() (PRR |= (uint8_t)((1<<PRADC)|(1<<PRSPI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRPSC0)|(1<<PRPSC1)|(1<<PRPSC2)))
00805
00806
00807 #elif defined(__AVR_AT90PWM2__) \
00808 || defined(__AVR_AT90PWM2B__) \
00809 || defined(__AVR_AT90PWM3__) \
00810 || defined(__AVR_AT90PWM3B__) \
00811 || defined(__AVR_AT90PWM216__) \
00812 || defined(__AVR_AT90PWM316__)
00813
00814 #define power_adc_enable() (PRR &= (uint8_t)~(1 << PRADC))
00815 #define power_adc_disable() (PRR |= (uint8_t)(1 << PRADC))
00816
00817 #define power_spi_enable() (PRR &= (uint8_t)~(1 << PRSPI))
00818 #define power_spi_disable() (PRR |= (uint8_t)(1 << PRSPI))
00819
00820 #define power_usart_enable() (PRR &= (uint8_t)~(1 << PRUSART))
00821 #define power_usart_disable() (PRR |= (uint8_t)(1 << PRUSART))
00822
00823 #define power_timer0_enable() (PRR &= (uint8_t)~(1 << PRTIM0))
00824 #define power_timer0_disable() (PRR |= (uint8_t)(1 << PRTIM0))
00825
00826 #define power_timer1_enable() (PRR &= (uint8_t)~(1 << PRTIM1))
00827 #define power_timer1_disable() (PRR |= (uint8_t)(1 << PRTIM1))
00828
00829
00830 #define power_psc0_enable() (PRR &= (uint8_t)~(1 << PRPSC0))
00831 #define power_psc0_disable() (PRR |= (uint8_t)(1 << PRPSC0))
00832
00833
00834 #define power_psc1_enable() (PRR &= (uint8_t)~(1 << PRPSC1))
00835 #define power_psc1_disable() (PRR |= (uint8_t)(1 << PRPSC1))
00836
00837
00838 #define power_psc2_enable() (PRR &= (uint8_t)~(1 << PRPSC2))
00839 #define power_psc2_disable() (PRR |= (uint8_t)(1 << PRPSC2))
00840
00841 #define power_all_enable() (PRR &= (uint8_t)~((1<<PRADC)|(1<<PRSPI)|(1<<PRUSART)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRPSC0)|(1<<PRPSC1)|(1<<PRPSC2)))
00842 #define power_all_disable() (PRR |= (uint8_t)((1<<PRADC)|(1<<PRSPI)|(1<<PRUSART)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRPSC0)|(1<<PRPSC1)|(1<<PRPSC2)))
00843
00844
00845 #elif defined(__AVR_AT90PWM81__)
00846
00847 #define power_adc_enable() (PRR &= (uint8_t)~(1 << PRADC))
00848 #define power_adc_disable() (PRR |= (uint8_t)(1 << PRADC))
00849
00850 #define power_spi_enable() (PRR &= (uint8_t)~(1 << PRSPI))
00851 #define power_spi_disable() (PRR |= (uint8_t)(1 << PRSPI))
00852
00853 #define power_timer1_enable() (PRR &= (uint8_t)~(1 << PRTIM1))
00854 #define power_timer1_disable() (PRR |= (uint8_t)(1 << PRTIM1))
00855
00856
00857 #define power_pscr_enable() (PRR &= (uint8_t)~(1 << PRPSCR))
00858 #define power_pscr_disable() (PRR |= (uint8_t)(1 << PRPSCR))
00859
00860
00861 #define power_psc2_enable() (PRR &= (uint8_t)~(1 << PRPSC2))
00862 #define power_psc2_disable() (PRR |= (uint8_t)(1 << PRPSC2))
00863
00864 #define power_all_enable() (PRR &= (uint8_t)~((1<<PRADC)|(1<<PRSPI)|(1<<PRTIM1)|(1<<PRPSCR)|(1<<PRPSC2)))
00865 #define power_all_disable() (PRR |= (uint8_t)((1<<PRADC)|(1<<PRSPI)|(1<<PRTIM1)|(1<<PRPSCR)|(1<<PRPSC2)))
00866
00867
00868 #elif defined(__AVR_ATmega165__) \
00869 || defined(__AVR_ATmega165A__) \
00870 || defined(__AVR_ATmega165P__) \
00871 || defined(__AVR_ATmega325__) \
00872 || defined(__AVR_ATmega325A__) \
00873 || defined(__AVR_ATmega3250__) \
00874 || defined(__AVR_ATmega3250A__) \
00875 || defined(__AVR_ATmega645__) \
00876 || defined(__AVR_ATmega645A__) \
00877 || defined(__AVR_ATmega645P__) \
00878 || defined(__AVR_ATmega6450__) \
00879 || defined(__AVR_ATmega6450A__) \
00880 || defined(__AVR_ATmega6450P__)
00881
00882 #define power_adc_enable() (PRR &= (uint8_t)~(1 << PRADC))
00883 #define power_adc_disable() (PRR |= (uint8_t)(1 << PRADC))
00884
00885 #define power_spi_enable() (PRR &= (uint8_t)~(1 << PRSPI))
00886 #define power_spi_disable() (PRR |= (uint8_t)(1 << PRSPI))
00887
00888 #define power_usart0_enable() (PRR &= (uint8_t)~(1 << PRUSART0))
00889 #define power_usart0_disable() (PRR |= (uint8_t)(1 << PRUSART0))
00890
00891 #define power_timer1_enable() (PRR &= (uint8_t)~(1 << PRTIM1))
00892 #define power_timer1_disable() (PRR |= (uint8_t)(1 << PRTIM1))
00893
00894 #define power_all_enable() (PRR &= (uint8_t)~((1<<PRADC)|(1<<PRSPI)|(1<<PRUSART0)|(1<<PRTIM1)))
00895 #define power_all_disable() (PRR |= (uint8_t)((1<<PRADC)|(1<<PRSPI)|(1<<PRUSART0)|(1<<PRTIM1)))
00896
00897
00898 #elif defined(__AVR_ATmega169__) \
00899 || defined(__AVR_ATmega169A__) \
00900 || defined(__AVR_ATmega169P__) \
00901 || defined(__AVR_ATmega169PA__) \
00902 || defined(__AVR_ATmega329__) \
00903 || defined(__AVR_ATmega329A__) \
00904 || defined(__AVR_ATmega329P__) \
00905 || defined(__AVR_ATmega329PA__) \
00906 || defined(__AVR_ATmega3290__) \
00907 || defined(__AVR_ATmega3290A__) \
00908 || defined(__AVR_ATmega3290P__) \
00909 || defined(__AVR_ATmega649__) \
00910 || defined(__AVR_ATmega649A__) \
00911 || defined(__AVR_ATmega649P__) \
00912 || defined(__AVR_ATmega6490__) \
00913 || defined(__AVR_ATmega6490A__) \
00914 || defined(__AVR_ATmega6490P__)
00915
00916 #define power_adc_enable() (PRR &= (uint8_t)~(1 << PRADC))
00917 #define power_adc_disable() (PRR |= (uint8_t)(1 << PRADC))
00918
00919 #define power_spi_enable() (PRR &= (uint8_t)~(1 << PRSPI))
00920 #define power_spi_disable() (PRR |= (uint8_t)(1 << PRSPI))
00921
00922 #define power_usart0_enable() (PRR &= (uint8_t)~(1 << PRUSART0))
00923 #define power_usart0_disable() (PRR |= (uint8_t)(1 << PRUSART0))
00924
00925 #define power_timer1_enable() (PRR &= (uint8_t)~(1 << PRTIM1))
00926 #define power_timer1_disable() (PRR |= (uint8_t)(1 << PRTIM1))
00927
00928 #define power_lcd_enable() (PRR &= (uint8_t)~(1 << PRLCD))
00929 #define power_lcd_disable() (PRR |= (uint8_t)(1 << PRLCD))
00930
00931 #define power_all_enable() (PRR &= (uint8_t)~((1<<PRADC)|(1<<PRSPI)|(1<<PRUSART0)|(1<<PRTIM1)|(1<<PRLCD)))
00932 #define power_all_disable() (PRR |= (uint8_t)((1<<PRADC)|(1<<PRSPI)|(1<<PRUSART0)|(1<<PRTIM1)|(1<<PRLCD)))
00933
00934
00935 #elif defined(__AVR_ATmega164A__) \
00936 || defined(__AVR_ATmega164P__) \
00937 || defined(__AVR_ATmega324A__) \
00938 || defined(__AVR_ATmega324P__) \
00939 || defined(__AVR_ATmega324PA__) \
00940 || defined(__AVR_ATmega644P__) \
00941 || defined(__AVR_ATmega644A__) \
00942 || defined(__AVR_ATmega644PA__)
00943
00944 #define power_adc_enable() (PRR0 &= (uint8_t)~(1 << PRADC))
00945 #define power_adc_disable() (PRR0 |= (uint8_t)(1 << PRADC))
00946
00947 #define power_spi_enable() (PRR0 &= (uint8_t)~(1 << PRSPI))
00948 #define power_spi_disable() (PRR0 |= (uint8_t)(1 << PRSPI))
00949
00950 #define power_usart0_enable() (PRR0 &= (uint8_t)~(1 << PRUSART0))
00951 #define power_usart0_disable() (PRR0 |= (uint8_t)(1 << PRUSART0))
00952
00953 #define power_usart1_enable() (PRR0 &= (uint8_t)~(1 << PRUSART1))
00954 #define power_usart1_disable() (PRR0 |= (uint8_t)(1 << PRUSART1))
00955
00956 #define power_timer0_enable() (PRR0 &= (uint8_t)~(1 << PRTIM0))
00957 #define power_timer0_disable() (PRR0 |= (uint8_t)(1 << PRTIM0))
00958
00959 #define power_timer1_enable() (PRR0 &= (uint8_t)~(1 << PRTIM1))
00960 #define power_timer1_disable() (PRR0 |= (uint8_t)(1 << PRTIM1))
00961
00962 #define power_timer2_enable() (PRR0 &= (uint8_t)~(1 << PRTIM2))
00963 #define power_timer2_disable() (PRR0 |= (uint8_t)(1 << PRTIM2))
00964
00965 #define power_twi_enable() (PRR0 &= (uint8_t)~(1 << PRTWI))
00966 #define power_twi_disable() (PRR0 |= (uint8_t)(1 << PRTWI))
00967
00968 #define power_all_enable() (PRR0 &= (uint8_t)~((1<<PRADC)|(1<<PRSPI)|(1<<PRUSART0)|(1<<PRUSART1)|(1<<PRTIM0)|(1<<PRTIM2)|(1<<PRTWI)))
00969 #define power_all_disable() (PRR0 |= (uint8_t)((1<<PRADC)|(1<<PRSPI)|(1<<PRUSART0)|(1<<PRUSART1)|(1<<PRTIM0)|(1<<PRTIM2)|(1<<PRTWI)))
00970
00971
00972 #elif defined(__AVR_ATmega644__)
00973
00974 #define power_adc_enable() (PRR0 &= (uint8_t)~(1 << PRADC))
00975 #define power_adc_disable() (PRR0 |= (uint8_t)(1 << PRADC))
00976
00977 #define power_spi_enable() (PRR0 &= (uint8_t)~(1 << PRSPI))
00978 #define power_spi_disable() (PRR0 |= (uint8_t)(1 << PRSPI))
00979
00980 #define power_usart0_enable() (PRR0 &= (uint8_t)~(1 << PRUSART0))
00981 #define power_usart0_disable() (PRR0 |= (uint8_t)(1 << PRUSART0))
00982
00983 #define power_timer0_enable() (PRR0 &= (uint8_t)~(1 << PRTIM0))
00984 #define power_timer0_disable() (PRR0 |= (uint8_t)(1 << PRTIM0))
00985
00986 #define power_timer1_enable() (PRR0 &= (uint8_t)~(1 << PRTIM1))
00987 #define power_timer1_disable() (PRR0 |= (uint8_t)(1 << PRTIM1))
00988
00989 #define power_timer2_enable() (PRR0 &= (uint8_t)~(1 << PRTIM2))
00990 #define power_timer2_disable() (PRR0 |= (uint8_t)(1 << PRTIM2))
00991
00992 #define power_twi_enable() (PRR0 &= (uint8_t)~(1 << PRTWI))
00993 #define power_twi_disable() (PRR0 |= (uint8_t)(1 << PRTWI))
00994
00995 #define power_all_enable() (PRR0 &= (uint8_t)~((1<<PRADC)|(1<<PRSPI)|(1<<PRUSART0)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)|(1<<PRTWI)))
00996 #define power_all_disable() (PRR0 |= (uint8_t)((1<<PRADC)|(1<<PRSPI)|(1<<PRUSART0)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)|(1<<PRTWI)))
00997
00998
00999 #elif defined(__AVR_ATmega406__)
01000
01001 #define power_twi_enable() (PRR0 &= (uint8_t)~(1 << PRTWI))
01002 #define power_twi_disable() (PRR0 |= (uint8_t)(1 << PRTWI))
01003
01004 #define power_timer0_enable() (PRR0 &= (uint8_t)~(1 << PRTIM0))
01005 #define power_timer0_disable() (PRR0 |= (uint8_t)(1 << PRTIM0))
01006
01007 #define power_timer1_enable() (PRR0 &= (uint8_t)~(1 << PRTIM1))
01008 #define power_timer1_disable() (PRR0 |= (uint8_t)(1 << PRTIM1))
01009
01010
01011 #define power_vadc_enable() (PRR0 &= (uint8_t)~(1 << PRVADC))
01012 #define power_vadc_disable() (PRR0 |= (uint8_t)(1 << PRVADC))
01013
01014 #define power_all_enable() (PRR0 &= (uint8_t)~((1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRVADC)))
01015 #define power_all_disable() (PRR0 |= (uint8_t)((1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRVADC)))
01016
01017
01018 #elif defined(__AVR_ATmega48__) \
01019 || defined(__AVR_ATmega48A__) \
01020 || defined(__AVR_ATmega48P__) \
01021 || defined(__AVR_ATmega88__) \
01022 || defined(__AVR_ATmega88A__) \
01023 || defined(__AVR_ATmega88P__) \
01024 || defined(__AVR_ATmega88PA__) \
01025 || defined(__AVR_ATmega168__) \
01026 || defined(__AVR_ATmega168A__) \
01027 || defined(__AVR_ATmega168P__) \
01028 || defined(__AVR_ATmega328__) \
01029 || defined(__AVR_ATmega328P__) \
01030 || defined(__AVR_ATtiny48__) \
01031 || defined(__AVR_ATtiny88__)
01032
01033 #define power_adc_enable() (PRR &= (uint8_t)~(1 << PRADC))
01034 #define power_adc_disable() (PRR |= (uint8_t)(1 << PRADC))
01035
01036 #define power_spi_enable() (PRR &= (uint8_t)~(1 << PRSPI))
01037 #define power_spi_disable() (PRR |= (uint8_t)(1 << PRSPI))
01038
01039 #define power_usart0_enable() (PRR &= (uint8_t)~(1 << PRUSART0))
01040 #define power_usart0_disable() (PRR |= (uint8_t)(1 << PRUSART0))
01041
01042 #define power_timer0_enable() (PRR &= (uint8_t)~(1 << PRTIM0))
01043 #define power_timer0_disable() (PRR |= (uint8_t)(1 << PRTIM0))
01044
01045 #define power_timer1_enable() (PRR &= (uint8_t)~(1 << PRTIM1))
01046 #define power_timer1_disable() (PRR |= (uint8_t)(1 << PRTIM1))
01047
01048 #define power_timer2_enable() (PRR &= (uint8_t)~(1 << PRTIM2))
01049 #define power_timer2_disable() (PRR |= (uint8_t)(1 << PRTIM2))
01050
01051 #define power_twi_enable() (PRR &= (uint8_t)~(1 << PRTWI))
01052 #define power_twi_disable() (PRR |= (uint8_t)(1 << PRTWI))
01053
01054 #define power_all_enable() (PRR &= (uint8_t)~((1<<PRADC)|(1<<PRSPI)|(1<<PRUSART0)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)|(1<<PRTWI)))
01055 #define power_all_disable() (PRR |= (uint8_t)((1<<PRADC)|(1<<PRSPI)|(1<<PRUSART0)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)|(1<<PRTWI)))
01056
01057
01058 #elif defined(__AVR_ATtiny24__) \
01059 || defined(__AVR_ATtiny24A__) \
01060 || defined(__AVR_ATtiny44__) \
01061 || defined(__AVR_ATtiny44A__) \
01062 || defined(__AVR_ATtiny84__) \
01063 || defined(__AVR_ATtiny84A__) \
01064 || defined(__AVR_ATtiny25__) \
01065 || defined(__AVR_ATtiny45__) \
01066 || defined(__AVR_ATtiny85__) \
01067 || defined(__AVR_ATtiny261__) \
01068 || defined(__AVR_ATtiny261A__) \
01069 || defined(__AVR_ATtiny461__) \
01070 || defined(__AVR_ATtiny461A__) \
01071 || defined(__AVR_ATtiny861__) \
01072 || defined(__AVR_ATtiny861A__) \
01073 || defined(__AVR_ATtiny43U__)
01074
01075 #define power_adc_enable() (PRR &= (uint8_t)~(1 << PRADC))
01076 #define power_adc_disable() (PRR |= (uint8_t)(1 << PRADC))
01077
01078 #define power_timer0_enable() (PRR &= (uint8_t)~(1 << PRTIM0))
01079 #define power_timer0_disable() (PRR |= (uint8_t)(1 << PRTIM0))
01080
01081 #define power_timer1_enable() (PRR &= (uint8_t)~(1 << PRTIM1))
01082 #define power_timer1_disable() (PRR |= (uint8_t)(1 << PRTIM1))
01083
01084
01085 #define power_usi_enable() (PRR &= (uint8_t)~(1 << PRUSI))
01086 #define power_usi_disable() (PRR |= (uint8_t)(1 << PRUSI))
01087
01088 #define power_all_enable() (PRR &= (uint8_t)~((1<<PRADC)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRUSI)))
01089 #define power_all_disable() (PRR |= (uint8_t)((1<<PRADC)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRUSI)))
01090
01091
01092 #elif defined(__AVR_ATmega1284P__)
01093
01094
01095 #define power_adc_enable() (PRR0 &= (uint8_t)~(1 << PRADC))
01096 #define power_adc_disable() (PRR0 |= (uint8_t)(1 << PRADC))
01097
01098 #define power_spi_enable() (PRR0 &= (uint8_t)~(1 << PRSPI))
01099 #define power_spi_disable() (PRR0 |= (uint8_t)(1 << PRSPI))
01100
01101 #define power_twi_enable() (PRR0 &= (uint8_t)~(1 << PRTWI))
01102 #define power_twi_disable() (PRR0 |= (uint8_t)(1 << PRTWI))
01103
01104 #define power_timer0_enable() (PRR0 &= (uint8_t)~(1 << PRTIM0))
01105 #define power_timer0_disable() (PRR0 |= (uint8_t)(1 << PRTIM0))
01106
01107 #define power_timer1_enable() (PRR0 &= (uint8_t)~(1 << PRTIM1))
01108 #define power_timer1_disable() (PRR0 |= (uint8_t)(1 << PRTIM1))
01109
01110 #define power_timer2_enable() (PRR0 &= (uint8_t)~(1 << PRTIM2))
01111 #define power_timer2_disable() (PRR0 |= (uint8_t)(1 << PRTIM2))
01112
01113 #define power_timer3_enable() (PRR1 &= (uint8_t)~(1 << PRTIM3))
01114 #define power_timer3_disable() (PRR1 |= (uint8_t)(1 << PRTIM3))
01115
01116 #define power_usart0_enable() (PRR0 &= (uint8_t)~(1 << PRUSART0))
01117 #define power_usart0_disable() (PRR0 |= (uint8_t)(1 << PRUSART0))
01118
01119 #define power_usart1_enable() (PRR0 &= (uint8_t)~(1 << PRUSART1))
01120 #define power_usart1_disable() (PRR0 |= (uint8_t)(1 << PRUSART1))
01121
01122 #define power_all_enable() \
01123 do{ \
01124 PRR0 &= (uint8_t)~((1<<PRADC)|(1<<PRSPI)|(1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)|(1<<PRUSART0)|(1<<PRUSART1)); \
01125 PRR1 &= (uint8_t)~(1<<PRTIM3); \
01126 }while(0)
01127
01128 #define power_all_disable() \
01129 do{ \
01130 PRR0 |= (uint8_t)((1<<PRADC)|(1<<PRSPI)|(1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)|(1<<PRUSART0)|(1<<PRUSART1)); \
01131 PRR1 |= (uint8_t)(1<<PRTIM3); \
01132 }while(0)
01133
01134
01135 #elif defined(__AVR_ATmega32HVB__) \
01136 || defined(__AVR_ATmega32HVBREVB__) \
01137 || defined(__AVR_ATmega16HVB__) \
01138 || defined(__AVR_ATmega16HVBREVB__)
01139
01140
01141 #define power_twi_enable() (PRR0 &= (uint8_t)~(1 << PRTWI))
01142 #define power_twi_disable() (PRR0 |= (uint8_t)(1 << PRTWI))
01143
01144 #define power_timer0_enable() (PRR0 &= (uint8_t)~(1 << PRTIM0))
01145 #define power_timer0_disable() (PRR0 |= (uint8_t)(1 << PRTIM0))
01146
01147 #define power_timer1_enable() (PRR0 &= (uint8_t)~(1 << PRTIM1))
01148 #define power_timer1_disable() (PRR0 |= (uint8_t)(1 << PRTIM1))
01149
01150
01151 #define power_vadc_enable() (PRR0 &= (uint8_t)~(1 << PRVADC))
01152 #define power_vadc_disable() (PRR0 |= (uint8_t)(1 << PRVADC))
01153
01154 #define power_spi_enable() (PRR0 &= (uint8_t)~(1 << PRSPI))
01155 #define power_spi_disable() (PRR0 |= (uint8_t)(1 << PRSPI))
01156
01157 #define power_vrm_enable() (PRR0 &= (uint8_t)~(1 << PRVRM))
01158 #define power_vrm_disable() (PRR0 |= (uint8_t)(1 << PRVRM))
01159
01160 #define power_all_enable() (PRR0 &= (uint8_t)~((1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRVADC)|(1<<PRSPI)|(1<<PRVRM)))
01161 #define power_all_disable() (PRR0 |= (uint8_t)((1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRVADC)|(1<<PRSPI)|(1<<PRVRM)))
01162
01163
01164 #elif defined(__AVR_ATmega16M1__) \
01165 || defined(__AVR_ATmega32C1__) \
01166 || defined(__AVR_ATmega32M1__) \
01167 || defined(__AVR_ATmega64C1__) \
01168 || defined(__AVR_ATmega64M1__)
01169
01170 #define power_adc_enable() (PRR &= (uint8_t)~(1 << PRADC))
01171 #define power_adc_disable() (PRR |= (uint8_t)(1 << PRADC))
01172
01173 #define power_lin_enable() (PRR &= (uint8_t)~(1 << PRLIN))
01174 #define power_lin_disable() (PRR |= (uint8_t)(1 << PRLIN))
01175
01176 #define power_spi_enable() (PRR &= (uint8_t)~(1 << PRSPI))
01177 #define power_spi_disable() (PRR |= (uint8_t)(1 << PRSPI))
01178
01179 #define power_timer0_enable() (PRR &= (uint8_t)~(1 << PRTIM0))
01180 #define power_timer0_disable() (PRR |= (uint8_t)(1 << PRTIM0))
01181
01182 #define power_timer1_enable() (PRR &= (uint8_t)~(1 << PRTIM1))
01183 #define power_timer1_disable() (PRR |= (uint8_t)(1 << PRTIM1))
01184
01185 #define power_psc_enable() (PRR &= (uint8_t)~(1 << PRPSC))
01186 #define power_psc_disable() (PRR |= (uint8_t)(1 << PRPSC))
01187
01188 #define power_can_enable() (PRR &= (uint8_t)~(1 << PRCAN))
01189 #define power_can_disable() (PRR |= (uint8_t)(1 << PRCAN))
01190
01191 #define power_all_enable() (PRR &= (uint8_t)~((1<<PRADC)|(1<<PRLIN)|(1<<PRSPI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRPSC)|(1<<PRCAN)))
01192 #define power_all_disable() (PRR |= (uint8_t)((1<<PRADC)|(1<<PRLIN)|(1<<PRSPI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRPSC)|(1<<PRCAN)))
01193
01194
01195 #elif defined(__AVR_ATtiny167__) \
01196 || defined(__AVR_ATtiny87__)
01197
01198
01199 #define power_adc_enable() (PRR &= (uint8_t)~(1 << PRADC))
01200 #define power_adc_disable() (PRR |= (uint8_t)(1 << PRADC))
01201
01202 #define power_usi_enable() (PRR &= (uint8_t)~(1 << PRUSI))
01203 #define power_usi_disable() (PRR |= (uint8_t)(1 << PRUSI))
01204
01205 #define power_timer0_enable() (PRR &= (uint8_t)~(1 << PRTIM0))
01206 #define power_timer0_disable() (PRR |= (uint8_t)(1 << PRTIM0))
01207
01208 #define power_timer1_enable() (PRR &= (uint8_t)~(1 << PRTIM1))
01209 #define power_timer1_disable() (PRR |= (uint8_t)(1 << PRTIM1))
01210
01211 #define power_spi_enable() (PRR &= (uint8_t)~(1 << PRSPI))
01212 #define power_spi_disable() (PRR |= (uint8_t)(1 << PRSPI))
01213
01214 #define power_lin_enable() (PRR &= (uint8_t)~(1 << PRLIN))
01215 #define power_lin_disable() (PRR |= (uint8_t)(1 << PRLIN))
01216
01217 #define power_all_enable() (PRR &= (uint8_t)~((1<<PRADC)|(1<<PRUSI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRSPI)|(1<<PRLIN)))
01218 #define power_all_disable() (PRR |= (uint8_t)((1<<PRADC)|(1<<PRUSI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRSPI)|(1<<PRLIN)))
01219
01220
01221 #elif defined(__AVR_AT90USB82__) \
01222 || defined(__AVR_AT90USB162__) \
01223 || defined(__AVR_ATmega8U2__) \
01224 || defined(__AVR_ATmega16U2__) \
01225 || defined(__AVR_ATmega32U2__)
01226
01227 #define power_spi_enable() (PRR0 &= (uint8_t)~(1 << PRSPI))
01228 #define power_spi_disable() (PRR0 |= (uint8_t)(1 << PRSPI))
01229
01230 #define power_timer0_enable() (PRR0 &= (uint8_t)~(1 << PRTIM0))
01231 #define power_timer0_disable() (PRR0 |= (uint8_t)(1 << PRTIM0))
01232
01233 #define power_timer1_enable() (PRR0 &= (uint8_t)~(1 << PRTIM1))
01234 #define power_timer1_disable() (PRR0 |= (uint8_t)(1 << PRTIM1))
01235
01236 #define power_usb_enable() (PRR1 &= (uint8_t)~(1 << PRUSB))
01237 #define power_usb_disable() (PRR1 |= (uint8_t)(1 << PRUSB))
01238
01239 #define power_usart1_enable() (PRR1 &= (uint8_t)~(1 << PRUSART1))
01240 #define power_usart1_disable() (PRR1 |= (uint8_t)(1 << PRUSART1))
01241
01242 #define power_all_enable() \
01243 do{ \
01244 PRR0 &= (uint8_t)~((1<<PRSPI)|(1<<PRTIM0)|(1<<PRTIM1)); \
01245 PRR1 &= (uint8_t)~((1<<PRUSB)|(1<<PRUSART1)); \
01246 }while(0)
01247
01248 #define power_all_disable() \
01249 do{ \
01250 PRR0 |= (uint8_t)((1<<PRSPI)|(1<<PRTIM0)|(1<<PRTIM1)); \
01251 PRR1 |= (uint8_t)((1<<PRUSB)|(1<<PRUSART1)); \
01252 }while(0)
01253
01254
01255 #elif defined(__AVR_AT90SCR100__)
01256
01257 #define power_usart0_enable() (PRR0 &= (uint8_t)~(1 << PRUSART0))
01258 #define power_usart0_disable() (PRR0 |= (uint8_t)(1 << PRUSART0))
01259
01260 #define power_spi_enable() (PRR0 &= (uint8_t)~(1 << PRSPI))
01261 #define power_spi_disable() (PRR0 |= (uint8_t)(1 << PRSPI))
01262
01263 #define power_timer1_enable() (PRR0 &= (uint8_t)~(1 << PRTIM1))
01264 #define power_timer1_disable() (PRR0 |= (uint8_t)(1 << PRTIM1))
01265
01266 #define power_timer0_enable() (PRR0 &= (uint8_t)~(1 << PRTIM0))
01267 #define power_timer0_disable() (PRR0 |= (uint8_t)(1 << PRTIM0))
01268
01269 #define power_timer2_enable() (PRR0 &= (uint8_t)~(1 << PRTIM2))
01270 #define power_timer2_disable() (PRR0 |= (uint8_t)(1 << PRTIM2))
01271
01272 #define power_twi_enable() (PRR0 &= (uint8_t)~(1 << PRTWI))
01273 #define power_twi_disable() (PRR0 |= (uint8_t)(1 << PRTWI))
01274
01275 #define power_usbh_enable() (PRR1 &= (uint8_t)~(1 << PRUSBH))
01276 #define power_usbh_disable() (PRR1 |= (uint8_t)(1 << PRUSBH))
01277
01278 #define power_usb_enable() (PRR1 &= (uint8_t)~(1 << PRUSB))
01279 #define power_usb_disable() (PRR1 |= (uint8_t)(1 << PRUSB))
01280
01281 #define power_hsspi_enable() (PRR1 &= (uint8_t)~(1 << PRHSSPI))
01282 #define power_hsspi_disable() (PRR1 |= (uint8_t)(1 << PRHSSPI))
01283
01284 #define power_sci_enable() (PRR1 &= (uint8_t)~(1 << PRSCI))
01285 #define power_sci_disable() (PRR1 |= (uint8_t)(1 << PRSCI))
01286
01287 #define power_aes_enable() (PRR1 &= (uint8_t)~(1 << PRAES))
01288 #define power_aes_disable() (PRR1 |= (uint8_t)(1 << PRAES))
01289
01290 #define power_kb_enable() (PRR1 &= (uint8_t)~(1 << PRKB))
01291 #define power_kb_disable() (PRR1 |= (uint8_t)(1 << PRKB))
01292
01293 #define power_all_enable() \
01294 do{ \
01295 PRR0 &= (uint8_t)~((1<<PRUSART0)|(1<<PRSPI)|(1<<PRTIM1)|(1<<PRTIM0)|(1<<PRTIM2)|(1<<PRTWI)); \
01296 PRR1 &= (uint8_t)~((1<<PRUSBH)|(1<<PRUSB)|(1<<PRHSSPI)|(1<<PRSCI)|(1<<PRAES)|(1<<PRKB)); \
01297 }while(0)
01298
01299 #define power_all_disable() \
01300 do{ \
01301 PRR0 |= (uint8_t)((1<<PRUSART0)|(1<<PRSPI)|(1<<PRTIM1)|(1<<PRTIM0)|(1<<PRTIM2)|(1<<PRTWI)); \
01302 PRR1 |= (uint8_t)((1<<PRUSBH)|(1<<PRUSB)|(1<<PRHSSPI)|(1<<PRSCI)|(1<<PRAES)|(1<<PRKB)); \
01303 }while(0)
01304
01305
01306 #elif defined(__AVR_ATtiny4__) \
01307 || defined(__AVR_ATtiny5__) \
01308 || defined(__AVR_ATtiny9__) \
01309 || defined(__AVR_ATtiny10__) \
01310 || defined(__AVR_ATtiny13A__) \
01311
01312 #define power_adc_enable() (PRR &= (uint8_t)~(1 << PRADC))
01313 #define power_adc_disable() (PRR |= (uint8_t)(1 << PRADC))
01314
01315 #define power_timer0_enable() (PRR &= (uint8_t)~(1 << PRTIM0))
01316 #define power_timer0_disable() (PRR |= (uint8_t)(1 << PRTIM0))
01317
01318 #define power_all_enable() (PRR &= (uint8_t)~((1<<PRADC)|(1<<PRTIM0)))
01319 #define power_all_disable() (PRR |= (uint8_t)((1<<PRADC)|(1<<PRTIM0)))
01320
01321
01322 #elif defined(__AVR_ATtiny20__) \
01323 || defined(__AVR_ATtiny40__)
01324
01325 #define power_adc_enable() (PRR &= (uint8_t)~(1 << PRADC))
01326 #define power_adc_disable() (PRR |= (uint8_t)(1 << PRADC))
01327
01328 #define power_timer0_enable() (PRR &= (uint8_t)~(1 << PRTIM0))
01329 #define power_timer0_disable() (PRR |= (uint8_t)(1 << PRTIM0))
01330
01331 #define power_timer1_enable() (PRR &= (uint8_t)~(1 << PRTIM1))
01332 #define power_timer1_disable() (PRR |= (uint8_t)(1 << PRTIM1))
01333
01334 #define power_spi_enable() (PRR &= (uint8_t)~(1 << PRSPI))
01335 #define power_spi_disable() (PRR |= (uint8_t)(1 << PRSPI))
01336
01337 #define power_twi_enable() (PRR &= (uint8_t)~(1 << PRTWI))
01338 #define power_twi_disable() (PRR |= (uint8_t)(1 << PRTWI))
01339
01340 #define power_all_enable() (PRR &= (uint8_t)~((1<<PRADC)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRSPI)|(1<<PRTWI)))
01341 #define power_all_disable() (PRR |= (uint8_t)((1<<PRADC)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRSPI)|(1<<PRTWI)))
01342
01343 #endif
01344
01345
01346 #if defined(__AVR_AT90CAN32__) \
01347 || defined(__AVR_AT90CAN64__) \
01348 || defined(__AVR_AT90CAN128__) \
01349 || defined(__AVR_AT90PWM1__) \
01350 || defined(__AVR_AT90PWM2__) \
01351 || defined(__AVR_AT90PWM2B__) \
01352 || defined(__AVR_AT90PWM3__) \
01353 || defined(__AVR_AT90PWM3B__) \
01354 || defined(__AVR_AT90PWM216__) \
01355 || defined(__AVR_AT90PWM316__) \
01356 || defined(__AVR_AT90SCR100__) \
01357 || defined(__AVR_AT90USB646__) \
01358 || defined(__AVR_AT90USB647__) \
01359 || defined(__AVR_AT90USB82__) \
01360 || defined(__AVR_AT90USB1286__) \
01361 || defined(__AVR_AT90USB1287__) \
01362 || defined(__AVR_AT90USB162__) \
01363 || defined(__AVR_ATmega1280__) \
01364 || defined(__AVR_ATmega1281__) \
01365 || defined(__AVR_ATmega128RFA1__) \
01366 || defined(__AVR_ATmega1284P__) \
01367 || defined(__AVR_ATmega162__) \
01368 || defined(__AVR_ATmega164A__) \
01369 || defined(__AVR_ATmega164P__) \
01370 || defined(__AVR_ATmega165__) \
01371 || defined(__AVR_ATmega165A__) \
01372 || defined(__AVR_ATmega165P__) \
01373 || defined(__AVR_ATmega168__) \
01374 || defined(__AVR_ATmega168P__) \
01375 || defined(__AVR_ATmega169__) \
01376 || defined(__AVR_ATmega169A__) \
01377 || defined(__AVR_ATmega169P__) \
01378 || defined(__AVR_ATmega169PA__) \
01379 || defined(__AVR_ATmega16U4__) \
01380 || defined(__AVR_ATmega2560__) \
01381 || defined(__AVR_ATmega2561__) \
01382 || defined(__AVR_ATmega324A__) \
01383 || defined(__AVR_ATmega324P__) \
01384 || defined(__AVR_ATmega325__) \
01385 || defined(__AVR_ATmega325A__) \
01386 || defined(__AVR_ATmega3250__) \
01387 || defined(__AVR_ATmega3250A__) \
01388 || defined(__AVR_ATmega328P__) \
01389 || defined(__AVR_ATmega329__) \
01390 || defined(__AVR_ATmega329A__) \
01391 || defined(__AVR_ATmega329P__) \
01392 || defined(__AVR_ATmega329PA__) \
01393 || defined(__AVR_ATmega3290__) \
01394 || defined(__AVR_ATmega3290A__) \
01395 || defined(__AVR_ATmega32C1__) \
01396 || defined(__AVR_ATmega32HVB__) \
01397 || defined(__AVR_ATmega32HVBREVB__) \
01398 || defined(__AVR_ATmega16HVB__) \
01399 || defined(__AVR_ATmega16HVBREVB__) \
01400 || defined(__AVR_ATmega32M1__) \
01401 || defined(__AVR_ATmega32U2__) \
01402 || defined(__AVR_ATmega32U4__) \
01403 || defined(__AVR_ATmega32U6__) \
01404 || defined(__AVR_ATmega48__) \
01405 || defined(__AVR_ATmega48P__) \
01406 || defined(__AVR_ATmega640__) \
01407 || defined(__AVR_ATmega649P__) \
01408 || defined(__AVR_ATmega644__) \
01409 || defined(__AVR_ATmega644A__) \
01410 || defined(__AVR_ATmega644P__) \
01411 || defined(__AVR_ATmega644PA__) \
01412 || defined(__AVR_ATmega645__) \
01413 || defined(__AVR_ATmega645A__) \
01414 || defined(__AVR_ATmega645P__) \
01415 || defined(__AVR_ATmega6450__) \
01416 || defined(__AVR_ATmega6450A__) \
01417 || defined(__AVR_ATmega6450P__) \
01418 || defined(__AVR_ATmega649__) \
01419 || defined(__AVR_ATmega649A__) \
01420 || defined(__AVR_ATmega6490__) \
01421 || defined(__AVR_ATmega6490A__) \
01422 || defined(__AVR_ATmega6490P__) \
01423 || defined(__AVR_ATmega88__) \
01424 || defined(__AVR_ATmega88P__) \
01425 || defined(__AVR_ATtiny48__) \
01426 || defined(__AVR_ATtiny167__) \
01427 || defined(__DOXYGEN__)
01428
01429
01430
01431
01432
01433
01434
01435
01436
01437
01438
01439
01440
01441
01442
01443
01444
01445
01446
01447
01448
01449
01450
01451
01452
01453
01454
01455
01456
01457
01458
01459
01460
01461 typedef enum
01462 {
01463 clock_div_1 = 0,
01464 clock_div_2 = 1,
01465 clock_div_4 = 2,
01466 clock_div_8 = 3,
01467 clock_div_16 = 4,
01468 clock_div_32 = 5,
01469 clock_div_64 = 6,
01470 clock_div_128 = 7,
01471 clock_div_256 = 8
01472 #if defined(__AVR_ATmega128RFA1__)
01473 , clock_div_1_rc = 15
01474 #endif
01475 } clock_div_t;
01476
01477
01478 static __inline__ void clock_prescale_set(clock_div_t) __attribute__((__always_inline__));
01479
01480
01481
01482
01483
01484
01485
01486
01487
01488
01489 void clock_prescale_set(clock_div_t __x)
01490 {
01491 uint8_t __tmp = _BV(CLKPCE);
01492 __asm__ __volatile__ (
01493 "in __tmp_reg__,__SREG__" "\n\t"
01494 "cli" "\n\t"
01495 "sts %1, %0" "\n\t"
01496 "sts %1, %2" "\n\t"
01497 "out __SREG__, __tmp_reg__"
01498 :
01499 : "d" (__tmp),
01500 "M" (_SFR_MEM_ADDR(CLKPR)),
01501 "d" (__x)
01502 : "r0");
01503 }
01504
01505
01506
01507
01508
01509
01510 #define clock_prescale_get() (clock_div_t)(CLKPR & (uint8_t)((1<<CLKPS0)|(1<<CLKPS1)|(1<<CLKPS2)|(1<<CLKPS3)))
01511
01512
01513 #elif defined(__AVR_ATtiny24__) \
01514 || defined(__AVR_ATtiny24A__) \
01515 || defined(__AVR_ATtiny44__) \
01516 || defined(__AVR_ATtiny44A__) \
01517 || defined(__AVR_ATtiny84__) \
01518 || defined(__AVR_ATtiny84A__) \
01519 || defined(__AVR_ATtiny25__) \
01520 || defined(__AVR_ATtiny45__) \
01521 || defined(__AVR_ATtiny85__) \
01522 || defined(__AVR_ATtiny261A__) \
01523 || defined(__AVR_ATtiny261__) \
01524 || defined(__AVR_ATtiny461__) \
01525 || defined(__AVR_ATtiny461A__) \
01526 || defined(__AVR_ATtiny861__) \
01527 || defined(__AVR_ATtiny861A__) \
01528 || defined(__AVR_ATtiny2313__) \
01529 || defined(__AVR_ATtiny2313A__) \
01530 || defined(__AVR_ATtiny4313__) \
01531 || defined(__AVR_ATtiny13__) \
01532 || defined(__AVR_ATtiny13A__) \
01533 || defined(__AVR_ATtiny43U__) \
01534
01535 typedef enum
01536 {
01537 clock_div_1 = 0,
01538 clock_div_2 = 1,
01539 clock_div_4 = 2,
01540 clock_div_8 = 3,
01541 clock_div_16 = 4,
01542 clock_div_32 = 5,
01543 clock_div_64 = 6,
01544 clock_div_128 = 7,
01545 clock_div_256 = 8
01546 } clock_div_t;
01547
01548 static __inline__ void clock_prescale_set(clock_div_t) __attribute__((__always_inline__));
01549
01550 void clock_prescale_set(clock_div_t __x)
01551 {
01552 uint8_t __tmp = _BV(CLKPCE);
01553 __asm__ __volatile__ (
01554 "in __tmp_reg__,__SREG__" "\n\t"
01555 "cli" "\n\t"
01556 "out %1, %0" "\n\t"
01557 "out %1, %2" "\n\t"
01558 "out __SREG__, __tmp_reg__"
01559 :
01560 : "d" (__tmp),
01561 "I" (_SFR_IO_ADDR(CLKPR)),
01562 "d" (__x)
01563 : "r0");
01564 }
01565
01566
01567 #define clock_prescale_get() (clock_div_t)(CLKPR & (uint8_t)((1<<CLKPS0)|(1<<CLKPS1)|(1<<CLKPS2)|(1<<CLKPS3)))
01568
01569
01570 #endif
01571
01572
01573
01574
01575 #endif