Go to the documentation of this file.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 || defined(__AVR_ATxmega256A3BU__)
00369
00370 #define power_aes_enable() (PR_PRGEN &= (uint8_t)~(PR_AES_bm))
00371 #define power_aes_disable() (PR_PRGEN |= (uint8_t)PR_AES_bm)
00372
00373 #define power_ebi_enable() (PR_PRGEN &= (uint8_t)~(PR_EBI_bm))
00374 #define power_ebi_disable() (PR_PRGEN |= (uint8_t)PR_EBI_bm)
00375
00376 #define power_dma_enable() (PR_PRGEN &= (uint8_t)~(PR_DMA_bm))
00377 #define power_dma_disable() (PR_PRGEN |= (uint8_t)PR_DMA_bm)
00378
00379 #define power_daca_enable() (PR_PRPA &= (uint8_t)~(PR_DAC_bm))
00380 #define power_daca_disable() (PR_PRPA |= (uint8_t)PR_DAC_bm)
00381 #define power_dacb_enable() (PR_PRPB &= (uint8_t)~(PR_DAC_bm))
00382 #define power_dacb_disable() (PR_PRPB |= (uint8_t)PR_DAC_bm)
00383
00384 #define power_usartc1_enable() (PR_PRPC &= (uint8_t)~(PR_USART1_bm))
00385 #define power_usartc1_disable() (PR_PRPC |= (uint8_t)PR_USART1_bm)
00386 #define power_usartd1_enable() (PR_PRPD &= (uint8_t)~(PR_USART1_bm))
00387 #define power_usartd1_disable() (PR_PRPD |= (uint8_t)PR_USART1_bm)
00388 #define power_usarte1_enable() (PR_PRPE &= (uint8_t)~(PR_USART1_bm))
00389 #define power_usarte1_disable() (PR_PRPE |= (uint8_t)PR_USART1_bm)
00390 #define power_usartf1_enable() (PR_PRPF &= (uint8_t)~(PR_USART1_bm))
00391 #define power_usartf1_disable() (PR_PRPF |= (uint8_t)PR_USART1_bm)
00392
00393 #if defined(__AVR_ATxmega256A3BU__)
00394 #define power_usb_enable() (PR_PRGEN &= (uint8_t)~(PR_USB_bm))
00395 #define power_usb_disable() (PR_PRGEN &= (uint8_t)(PR_USB_bm))
00396
00397 #define power_all_enable() \
00398 do { \
00399 PR_PRGEN &= (uint8_t)~(PR_AES_bm|PR_EBI_bm|PR_RTC_bm|PR_EVSYS_bm|PR_DMA_bm|PR_USB_bm); \
00400 PR_PRPA &= (uint8_t)~(PR_DAC_bm|PR_ADC_bm|PR_AC_bm); \
00401 PR_PRPB &= (uint8_t)~(PR_DAC_bm|PR_ADC_bm|PR_AC_bm); \
00402 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); \
00403 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); \
00404 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); \
00405 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); \
00406 } while(0)
00407
00408 #define power_all_disable() \
00409 do { \
00410 PR_PRGEN |= (uint8_t)(PR_AES_bm|PR_EBI_bm|PR_RTC_bm|PR_EVSYS_bm|PR_DMA_bm|PR_USB_bm); \
00411 PR_PRPA |= (uint8_t)(PR_DAC_bm|PR_ADC_bm|PR_AC_bm); \
00412 PR_PRPB |= (uint8_t)(PR_DAC_bm|PR_ADC_bm|PR_AC_bm); \
00413 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); \
00414 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); \
00415 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); \
00416 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); \
00417 } while(0)
00418
00419 #else
00420
00421 #define power_all_enable() \
00422 do { \
00423 PR_PRGEN &= (uint8_t)~(PR_AES_bm|PR_EBI_bm|PR_RTC_bm|PR_EVSYS_bm|PR_DMA_bm); \
00424 PR_PRPA &= (uint8_t)~(PR_DAC_bm|PR_ADC_bm|PR_AC_bm); \
00425 PR_PRPB &= (uint8_t)~(PR_DAC_bm|PR_ADC_bm|PR_AC_bm); \
00426 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); \
00427 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); \
00428 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); \
00429 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); \
00430 } while(0)
00431
00432
00433 #define power_all_disable() \
00434 do { \
00435 PR_PRGEN|= (uint8_t)(PR_AES_bm|PR_EBI_bm|PR_RTC_bm|PR_EVSYS_bm|PR_DMA_bm); \
00436 PR_PRPA |= (uint8_t)(PR_DAC_bm|PR_ADC_bm|PR_AC_bm); \
00437 PR_PRPB |= (uint8_t)(PR_DAC_bm|PR_ADC_bm|PR_AC_bm); \
00438 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); \
00439 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); \
00440 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); \
00441 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); \
00442 } while(0)
00443
00444 #endif
00445
00446 #endif
00447
00448 #if defined(__AVR_ATxmega16A4__) \
00449 || defined(__AVR_ATxmega16D4__) \
00450 || defined(__AVR_ATxmega32A4__) \
00451 || defined(__AVR_ATxmega32D4__) \
00452 || defined(__AVR_ATxmega32X1__) \
00453 || defined(__AVR_ATxmega64A1__) \
00454 || defined(__AVR_ATxmega64A1U__) \
00455 || defined(__AVR_ATxmega64A3__) \
00456 || defined(__AVR_ATxmega64D3__) \
00457 || defined(__AVR_ATxmega128A1__) \
00458 || defined(__AVR_ATxmega128A1U__) \
00459 || defined(__AVR_ATxmega128A3__) \
00460 || defined(__AVR_ATxmega128D3__) \
00461 || defined(__AVR_ATxmega192A3__) \
00462 || defined(__AVR_ATxmega192D3__) \
00463 || defined(__AVR_ATxmega256A3__) \
00464 || defined(__AVR_ATxmega256A3B__) \
00465 || defined(__AVR_ATxmega256A3BU__)
00466
00467
00468 #define power_rtc_enable() (PR_PRGEN &= (uint8_t)~(PR_RTC_bm))
00469 #define power_rtc_disable() (PR_PRGEN |= (uint8_t)PR_RTC_bm)
00470
00471 #define power_evsys_enable() (PR_PRGEN &= (uint8_t)~(PR_EVSYS_bm))
00472 #define power_evsys_disable() (PR_PRGEN |= (uint8_t)PR_EVSYS_bm)
00473
00474 #define power_adca_enable() (PR_PRPA &= (uint8_t)~(PR_ADC_bm))
00475 #define power_adca_disable() (PR_PRPA |= (uint8_t)PR_ADC_bm)
00476 #define power_adcb_enable() (PR_PRPB &= (uint8_t)~(PR_ADC_bm))
00477 #define power_adcb_disable() (PR_PRPB |= (uint8_t)PR_ADC_bm)
00478
00479 #define power_aca_enable() (PR_PRPA &= (uint8_t)~(PR_AC_bm))
00480 #define power_aca_disable() (PR_PRPA |= (uint8_t)PR_AC_bm)
00481 #define power_acb_enable() (PR_PRPB &= (uint8_t)~(PR_AC_bm))
00482 #define power_acb_disable() (PR_PRPB |= (uint8_t)PR_AC_bm)
00483
00484 #define power_twic_enable() (PR_PRPC &= (uint8_t)~(PR_TWI_bm))
00485 #define power_twic_disable() (PR_PRPC |= (uint8_t)PR_TWI_bm)
00486 #define power_twid_enable() (PR_PRPD &= (uint8_t)~(PR_TWI_bm))
00487 #define power_twid_disable() (PR_PRPD |= (uint8_t)PR_TWI_bm)
00488 #define power_twie_enable() (PR_PRPE &= (uint8_t)~(PR_TWI_bm))
00489 #define power_twie_disable() (PR_PRPE |= (uint8_t)PR_TWI_bm)
00490 #define power_twif_enable() (PR_PRPF &= (uint8_t)~(PR_TWI_bm))
00491 #define power_twif_disable() (PR_PRPF |= (uint8_t)PR_TWI_bm)
00492
00493 #define power_usartc0_enable() (PR_PRPC &= (uint8_t)~(PR_USART0_bm))
00494 #define power_usartc0_disable() (PR_PRPC |= (uint8_t)PR_USART0_bm)
00495 #define power_usartd0_enable() (PR_PRPD &= (uint8_t)~(PR_USART0_bm))
00496 #define power_usartd0_disable() (PR_PRPD |= (uint8_t)PR_USART0_bm)
00497 #define power_usarte0_enable() (PR_PRPE &= (uint8_t)~(PR_USART0_bm))
00498 #define power_usarte0_disable() (PR_PRPE |= (uint8_t)PR_USART0_bm)
00499 #define power_usartf0_enable() (PR_PRPF &= (uint8_t)~(PR_USART0_bm))
00500 #define power_usartf0_disable() (PR_PRPF |= (uint8_t)PR_USART0_bm)
00501
00502 #define power_spic_enable() (PR_PRPC &= (uint8_t)~(PR_SPI_bm))
00503 #define power_spic_disable() (PR_PRPC |= (uint8_t)PR_SPI_bm)
00504 #define power_spid_enable() (PR_PRPD &= (uint8_t)~(PR_SPI_bm))
00505 #define power_spid_disable() (PR_PRPD |= (uint8_t)PR_SPI_bm)
00506 #define power_spie_enable() (PR_PRPE &= (uint8_t)~(PR_SPI_bm))
00507 #define power_spie_disable() (PR_PRPE |= (uint8_t)PR_SPI_bm)
00508 #define power_spif_enable() (PR_PRPF &= (uint8_t)~(PR_SPI_bm))
00509 #define power_spif_disable() (PR_PRPF |= (uint8_t)PR_SPI_bm)
00510
00511 #define power_hiresc_enable() (PR_PRPC &= (uint8_t)~(PR_HIRES_bm))
00512 #define power_hiresc_disable() (PR_PRPC |= (uint8_t)PR_HIRES_bm)
00513 #define power_hiresd_enable() (PR_PRPD &= (uint8_t)~(PR_HIRES_bm))
00514 #define power_hiresd_disable() (PR_PRPD |= (uint8_t)PR_HIRES_bm)
00515 #define power_hirese_enable() (PR_PRPE &= (uint8_t)~(PR_HIRES_bm))
00516 #define power_hirese_disable() (PR_PRPE |= (uint8_t)PR_HIRES_bm)
00517 #define power_hiresf_enable() (PR_PRPF &= (uint8_t)~(PR_HIRES_bm))
00518 #define power_hiresf_disable() (PR_PRPF |= (uint8_t)PR_HIRES_bm)
00519
00520 #define power_tc1c_enable() (PR_PRPC &= (uint8_t)~(PR_TC1_bm))
00521 #define power_tc1c_disable() (PR_PRPC |= (uint8_t)PR_TC1_bm)
00522 #define power_tc1d_enable() (PR_PRPD &= (uint8_t)~(PR_TC1_bm))
00523 #define power_tc1d_disable() (PR_PRPD |= (uint8_t)PR_TC1_bm)
00524 #define power_tc1e_enable() (PR_PRPE &= (uint8_t)~(PR_TC1_bm))
00525 #define power_tc1e_disable() (PR_PRPE |= (uint8_t)PR_TC1_bm)
00526 #define power_tc1f_enable() (PR_PRPF &= (uint8_t)~(PR_TC1_bm))
00527 #define power_tc1f_disable() (PR_PRPF |= (uint8_t)PR_TC1_bm)
00528
00529 #define power_tc0c_enable() (PR_PRPC &= (uint8_t)~(PR_TC0_bm))
00530 #define power_tc0c_disable() (PR_PRPC |= (uint8_t)PR_TC0_bm)
00531 #define power_tc0d_enable() (PR_PRPD &= (uint8_t)~(PR_TC0_bm))
00532 #define power_tc0d_disable() (PR_PRPD |= (uint8_t)PR_TC0_bm)
00533 #define power_tc0e_enable() (PR_PRPE &= (uint8_t)~(PR_TC0_bm))
00534 #define power_tc0e_disable() (PR_PRPE |= (uint8_t)PR_TC0_bm)
00535 #define power_tc0f_enable() (PR_PRPF &= (uint8_t)~(PR_TC0_bm))
00536 #define power_tc0f_disable() (PR_PRPF |= (uint8_t)PR_TC0_bm)
00537
00538 #endif
00539
00540 #if defined(__AVR_ATxmega16D4__) \
00541 || defined(__AVR_ATxmega32D4__) \
00542 || defined(__AVR_ATxmega64D3__) \
00543 || defined(__AVR_ATxmega128D3__) \
00544 || defined(__AVR_ATxmega192D3__)
00545
00546 #define power_all_enable() \
00547 do { \
00548 PR_PRGEN &= (uint8_t)~(PR_RTC_bm|PR_EVSYS_bm); \
00549 PR_PRPA &= (uint8_t)~(PR_ADC_bm|PR_AC_bm); \
00550 PR_PRPB &= (uint8_t)~(PR_ADC_bm|PR_AC_bm); \
00551 PR_PRPC &= (uint8_t)~(PR_TWI_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00552 PR_PRPD &= (uint8_t)~(PR_TWI_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00553 PR_PRPE &= (uint8_t)~(PR_TWI_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00554 PR_PRPF &= (uint8_t)~(PR_TWI_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00555 } while(0)
00556
00557
00558 #define power_all_disable() \
00559 do { \
00560 PR_PRGEN|= (uint8_t)(PR_EBI_bm|PR_RTC_bm|PR_EVSYS_bm|PR_DMA_bm); \
00561 PR_PRPA |= (uint8_t)(PR_ADC_bm|PR_AC_bm); \
00562 PR_PRPB |= (uint8_t)(PR_ADC_bm|PR_AC_bm); \
00563 PR_PRPC |= (uint8_t)(PR_TWI_bm|R_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00564 PR_PRPD |= (uint8_t)(PR_TWI_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00565 PR_PRPE |= (uint8_t)(PR_TWI_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00566 PR_PRPF |= (uint8_t)(PR_TWI_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00567 } while(0)
00568
00569 #endif
00570
00571 #if defined (__AVR_ATxmega128B1__)
00572 #define power_lcd_enable() (PR_PRGEN &= (uint8_t)~(PR_LCD_bm))
00573 #define power_lcd_disable() (PR_PRGEN |= (uint8_t)PR_LCD_bm)
00574
00575 #define power_usb_enable() (PR_PRGEN &= (uint8_t)~(PR_USB_bm))
00576 #define power_usb_disable() (PR_PRGEN |= (uint8_t)PR_USB_bm)
00577
00578 #define power_aes_enable() (PR_PRGEN &= (uint8_t)~(PR_AES_bm))
00579 #define power_aes_disable() (PR_PRGEN |= (uint8_t)PR_AES_bm)
00580
00581 #define power_rtc_enable() (PR_PRGEN &= (uint8_t)~(PR_RTC_bm))
00582 #define power_rtc_disable() (PR_PRGEN |= (uint8_t)PR_RTC_bm)
00583
00584 #define power_evsys_enable() (PR_PRGEN &= (uint8_t)~(PR_EVSYS_bm))
00585 #define power_evsys_disable() (PR_PRGEN |= (uint8_t)PR_EVSYS_bm)
00586
00587 #define power_dma_enable() (PR_PRGEN &= (uint8_t)~(PR_DMA_bm))
00588 #define power_dma_disable() (PR_PRGEN |= (uint8_t)PR_DMA_bm)
00589
00590 #define power_adca_enable() (PR_PRPA &= (uint8_t)~(PR_ADC_bm))
00591 #define power_adca_disable() (PR_PRPA |= (uint8_t)PR_ADC_bm)
00592 #define power_adcb_enable() (PR_PRPB &= (uint8_t)~(PR_ADC_bm))
00593 #define power_adcb_disable() (PR_PRPB |= (uint8_t)PR_ADC_bm)
00594
00595 #define power_aca_enable() (PR_PRPA &= (uint8_t)~(PR_AC_bm))
00596 #define power_aca_disable() (PR_PRPA |= (uint8_t)PR_AC_bm)
00597 #define power_acb_enable() (PR_PRPB &= (uint8_t)~(PR_AC_bm))
00598 #define power_acb_disable() (PR_PRPB |= (uint8_t)PR_AC_bm)
00599
00600 #define power_twic_enable() (PR_PRPC &= (uint8_t)~(PR_TWI_bm))
00601 #define power_twic_disable() (PR_PRPC |= (uint8_t)PR_TWI_bm)
00602 #define power_twid_enable() (PR_PRPD &= (uint8_t)~(PR_TWI_bm))
00603 #define power_twid_disable() (PR_PRPD |= (uint8_t)PR_TWI_bm)
00604 #define power_twie_enable() (PR_PRPE &= (uint8_t)~(PR_TWI_bm))
00605 #define power_twie_disable() (PR_PRPE |= (uint8_t)PR_TWI_bm)
00606 #define power_twif_enable() (PR_PRPF &= (uint8_t)~(PR_TWI_bm))
00607 #define power_twif_disable() (PR_PRPF |= (uint8_t)PR_TWI_bm)
00608
00609 #define power_usartc1_enable() (PR_PRPC &= (uint8_t)~(PR_USART1_bm))
00610 #define power_usartc1_disable() (PR_PRPC |= (uint8_t)PR_USART1_bm)
00611 #define power_usartd1_enable() (PR_PRPD &= (uint8_t)~(PR_USART1_bm))
00612 #define power_usartd1_disable() (PR_PRPD |= (uint8_t)PR_USART1_bm)
00613 #define power_usarte1_enable() (PR_PRPE &= (uint8_t)~(PR_USART1_bm))
00614 #define power_usarte1_disable() (PR_PRPE |= (uint8_t)PR_USART1_bm)
00615 #define power_usartf1_enable() (PR_PRPF &= (uint8_t)~(PR_USART1_bm))
00616 #define power_usartf1_disable() (PR_PRPF |= (uint8_t)PR_USART1_bm)
00617
00618 #define power_usartc0_enable() (PR_PRPC &= (uint8_t)~(PR_USART0_bm))
00619 #define power_usartc0_disable() (PR_PRPC |= (uint8_t)PR_USART0_bm)
00620 #define power_usartd0_enable() (PR_PRPD &= (uint8_t)~(PR_USART0_bm))
00621 #define power_usartd0_disable() (PR_PRPD |= (uint8_t)PR_USART0_bm)
00622 #define power_usarte0_enable() (PR_PRPE &= (uint8_t)~(PR_USART0_bm))
00623 #define power_usarte0_disable() (PR_PRPE |= (uint8_t)PR_USART0_bm)
00624 #define power_usartf0_enable() (PR_PRPF &= (uint8_t)~(PR_USART0_bm))
00625 #define power_usartf0_disable() (PR_PRPF |= (uint8_t)PR_USART0_bm)
00626
00627 #define power_all_enable() \
00628 do { \
00629 PR_PRGEN &= (uint8_t)~(PR_LCD_bm|PR_USB_bm|PR_AES_bm|PR_RTC_bm|PR_EVSYS_bm|PR_DMA_bm); \
00630 PR_PRPA &= (uint8_t)~(PR_ADC_bm|PR_AC_bm); \
00631 PR_PRPB &= (uint8_t)~(PR_ADC_bm|PR_AC_bm); \
00632 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); \
00633 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); \
00634 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); \
00635 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); \
00636 } while(0)
00637
00638 #define power_all_disable() \
00639 do { \
00640 PR_PRGEN |= (uint8_t)(PR_LCD_bm|PR_USB_bm|PR_AES_bm|PR_RTC_bm|PR_EVSYS_bm|PR_DMA_bm); \
00641 PR_PRPA |= (uint8_t)(PR_ADC_bm|PR_AC_bm); \
00642 PR_PRPB |= (uint8_t)(PR_ADC_bm|PR_AC_bm); \
00643 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); \
00644 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); \
00645 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); \
00646 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); \
00647 } while(0)
00648
00649 #elif defined(__AVR_ATmega640__) \
00650 || defined(__AVR_ATmega1280__) \
00651 || defined(__AVR_ATmega1281__) \
00652 || defined(__AVR_ATmega2560__) \
00653 || defined(__AVR_ATmega2561__)
00654
00655 #define power_adc_enable() (PRR0 &= (uint8_t)~(1 << PRADC))
00656 #define power_adc_disable() (PRR0 |= (uint8_t)(1 << PRADC))
00657
00658 #define power_spi_enable() (PRR0 &= (uint8_t)~(1 << PRSPI))
00659 #define power_spi_disable() (PRR0 |= (uint8_t)(1 << PRSPI))
00660
00661 #define power_twi_enable() (PRR0 &= (uint8_t)~(1 << PRTWI))
00662 #define power_twi_disable() (PRR0 |= (uint8_t)(1 << PRTWI))
00663
00664 #define power_timer0_enable() (PRR0 &= (uint8_t)~(1 << PRTIM0))
00665 #define power_timer0_disable() (PRR0 |= (uint8_t)(1 << PRTIM0))
00666
00667 #define power_timer1_enable() (PRR0 &= (uint8_t)~(1 << PRTIM1))
00668 #define power_timer1_disable() (PRR0 |= (uint8_t)(1 << PRTIM1))
00669
00670 #define power_timer2_enable() (PRR0 &= (uint8_t)~(1 << PRTIM2))
00671 #define power_timer2_disable() (PRR0 |= (uint8_t)(1 << PRTIM2))
00672
00673 #define power_timer3_enable() (PRR1 &= (uint8_t)~(1 << PRTIM3))
00674 #define power_timer3_disable() (PRR1 |= (uint8_t)(1 << PRTIM3))
00675
00676 #define power_timer4_enable() (PRR1 &= (uint8_t)~(1 << PRTIM4))
00677 #define power_timer4_disable() (PRR1 |= (uint8_t)(1 << PRTIM4))
00678
00679 #define power_timer5_enable() (PRR1 &= (uint8_t)~(1 << PRTIM5))
00680 #define power_timer5_disable() (PRR1 |= (uint8_t)(1 << PRTIM5))
00681
00682 #define power_usart0_enable() (PRR0 &= (uint8_t)~(1 << PRUSART0))
00683 #define power_usart0_disable() (PRR0 |= (uint8_t)(1 << PRUSART0))
00684
00685 #define power_usart1_enable() (PRR1 &= (uint8_t)~(1 << PRUSART1))
00686 #define power_usart1_disable() (PRR1 |= (uint8_t)(1 << PRUSART1))
00687
00688 #define power_usart2_enable() (PRR1 &= (uint8_t)~(1 << PRUSART2))
00689 #define power_usart2_disable() (PRR1 |= (uint8_t)(1 << PRUSART2))
00690
00691 #define power_usart3_enable() (PRR1 &= (uint8_t)~(1 << PRUSART3))
00692 #define power_usart3_disable() (PRR1 |= (uint8_t)(1 << PRUSART3))
00693
00694 #define power_all_enable() \
00695 do{ \
00696 PRR0 &= (uint8_t)~((1<<PRADC)|(1<<PRSPI)|(1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)|(1<<PRUSART0)); \
00697 PRR1 &= (uint8_t)~((1<<PRTIM3)|(1<<PRTIM4)|(1<<PRTIM5)|(1<<PRTIM5)|(1<<PRUSART1)|(1<<PRUSART2)|(1<<PRUSART3)); \
00698 }while(0)
00699
00700 #define power_all_disable() \
00701 do{ \
00702 PRR0 |= (uint8_t)((1<<PRADC)|(1<<PRSPI)|(1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)|(1<<PRUSART0)); \
00703 PRR1 |= (uint8_t)((1<<PRTIM3)|(1<<PRTIM4)|(1<<PRTIM5)|(1<<PRTIM5)|(1<<PRUSART1)|(1<<PRUSART2)|(1<<PRUSART3)); \
00704 }while(0)
00705
00706
00707 #elif defined(__AVR_ATmega128RFA1__)
00708
00709 #define power_adc_enable() (PRR0 &= (uint8_t)~(1 << PRADC))
00710 #define power_adc_disable() (PRR0 |= (uint8_t)(1 << PRADC))
00711
00712 #define power_spi_enable() (PRR0 &= (uint8_t)~(1 << PRSPI))
00713 #define power_spi_disable() (PRR0 |= (uint8_t)(1 << PRSPI))
00714
00715 #define power_twi_enable() (PRR0 &= (uint8_t)~(1 << PRTWI))
00716 #define power_twi_disable() (PRR0 |= (uint8_t)(1 << PRTWI))
00717
00718 #define power_timer0_enable() (PRR0 &= (uint8_t)~(1 << PRTIM0))
00719 #define power_timer0_disable() (PRR0 |= (uint8_t)(1 << PRTIM0))
00720
00721 #define power_timer1_enable() (PRR0 &= (uint8_t)~(1 << PRTIM1))
00722 #define power_timer1_disable() (PRR0 |= (uint8_t)(1 << PRTIM1))
00723
00724 #define power_timer2_enable() (PRR0 &= (uint8_t)~(1 << PRTIM2))
00725 #define power_timer2_disable() (PRR0 |= (uint8_t)(1 << PRTIM2))
00726
00727 #define power_timer3_enable() (PRR1 &= (uint8_t)~(1 << PRTIM3))
00728 #define power_timer3_disable() (PRR1 |= (uint8_t)(1 << PRTIM3))
00729
00730 #define power_timer4_enable() (PRR1 &= (uint8_t)~(1 << PRTIM4))
00731 #define power_timer4_disable() (PRR1 |= (uint8_t)(1 << PRTIM4))
00732
00733 #define power_timer5_enable() (PRR1 &= (uint8_t)~(1 << PRTIM5))
00734 #define power_timer5_disable() (PRR1 |= (uint8_t)(1 << PRTIM5))
00735
00736 #define power_usart0_enable() (PRR0 &= (uint8_t)~(1 << PRUSART0))
00737 #define power_usart0_disable() (PRR0 |= (uint8_t)(1 << PRUSART0))
00738
00739 #define power_usart1_enable() (PRR1 &= (uint8_t)~(1 << PRUSART1))
00740 #define power_usart1_disable() (PRR1 |= (uint8_t)(1 << PRUSART1))
00741
00742 #define power_all_enable() \
00743 do{ \
00744 PRR0 &= (uint8_t)~((1<<PRADC)|(1<<PRSPI)|(1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)|(1<<PRUSART0)); \
00745 PRR1 &= (uint8_t)~((1<<PRTIM3)|(1<<PRTIM4)|(1<<PRTIM5)|(1<<PRTIM5)|(1<<PRUSART1)); \
00746 }while(0)
00747
00748 #define power_all_disable() \
00749 do{ \
00750 PRR0 |= (uint8_t)((1<<PRADC)|(1<<PRSPI)|(1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)|(1<<PRUSART0)); \
00751 PRR1 |= (uint8_t)((1<<PRTIM3)|(1<<PRTIM4)|(1<<PRTIM5)|(1<<PRTIM5)|(1<<PRUSART1)); \
00752 }while(0)
00753
00754
00755 #elif defined(__AVR_AT90USB646__) \
00756 || defined(__AVR_AT90USB647__) \
00757 || defined(__AVR_AT90USB1286__) \
00758 || defined(__AVR_AT90USB1287__)
00759
00760 #define power_adc_enable() (PRR0 &= (uint8_t)~(1 << PRADC))
00761 #define power_adc_disable() (PRR0 |= (uint8_t)(1 << PRADC))
00762
00763 #define power_spi_enable() (PRR0 &= (uint8_t)~(1 << PRSPI))
00764 #define power_spi_disable() (PRR0 |= (uint8_t)(1 << PRSPI))
00765
00766 #define power_twi_enable() (PRR0 &= (uint8_t)~(1 << PRTWI))
00767 #define power_twi_disable() (PRR0 |= (uint8_t)(1 << PRTWI))
00768
00769 #define power_timer0_enable() (PRR0 &= (uint8_t)~(1 << PRTIM0))
00770 #define power_timer0_disable() (PRR0 |= (uint8_t)(1 << PRTIM0))
00771
00772 #define power_timer1_enable() (PRR0 &= (uint8_t)~(1 << PRTIM1))
00773 #define power_timer1_disable() (PRR0 |= (uint8_t)(1 << PRTIM1))
00774
00775 #define power_timer2_enable() (PRR0 &= (uint8_t)~(1 << PRTIM2))
00776 #define power_timer2_disable() (PRR0 |= (uint8_t)(1 << PRTIM2))
00777
00778 #define power_timer3_enable() (PRR1 &= (uint8_t)~(1 << PRTIM3))
00779 #define power_timer3_disable() (PRR1 |= (uint8_t)(1 << PRTIM3))
00780
00781 #define power_usart1_enable() (PRR1 &= (uint8_t)~(1 << PRUSART1))
00782 #define power_usart1_disable() (PRR1 |= (uint8_t)(1 << PRUSART1))
00783
00784 #define power_usb_enable() (PRR1 &= (uint8_t)~(1 << PRUSB))
00785 #define power_usb_disable() (PRR1 |= (uint8_t)(1 << PRUSB))
00786
00787 #define power_all_enable() \
00788 do{ \
00789 PRR0 &= (uint8_t)~((1<<PRADC)|(1<<PRSPI)|(1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)); \
00790 PRR1 &= (uint8_t)~((1<<PRTIM3)|(1<<PRUSART1)|(1<<PRUSB)); \
00791 }while(0)
00792
00793 #define power_all_disable() \
00794 do{ \
00795 PRR0 |= (uint8_t)((1<<PRADC)|(1<<PRSPI)|(1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)); \
00796 PRR1 |= (uint8_t)((1<<PRTIM3)|(1<<PRUSART1)|(1<<PRUSB)); \
00797 }while(0)
00798
00799
00800 #elif defined(__AVR_ATmega32U4__) \
00801 || defined(__AVR_ATmega16U4__)
00802
00803
00804 #define power_adc_enable() (PRR0 &= (uint8_t)~(1 << PRADC))
00805 #define power_adc_disable() (PRR0 |= (uint8_t)(1 << PRADC))
00806
00807 #define power_usart0_enable() (PRR0 &= (uint8_t)~(1 << PRUSART0))
00808 #define power_usart0_disable() (PRR0 |= (uint8_t)(1 << PRUSART0))
00809
00810 #define power_spi_enable() (PRR0 &= (uint8_t)~(1 << PRSPI))
00811 #define power_spi_disable() (PRR0 |= (uint8_t)(1 << PRSPI))
00812
00813 #define power_twi_enable() (PRR0 &= (uint8_t)~(1 << PRTWI))
00814 #define power_twi_disable() (PRR0 |= (uint8_t)(1 << PRTWI))
00815
00816 #define power_timer0_enable() (PRR0 &= (uint8_t)~(1 << PRTIM0))
00817 #define power_timer0_disable() (PRR0 |= (uint8_t)(1 << PRTIM0))
00818
00819 #define power_timer1_enable() (PRR0 &= (uint8_t)~(1 << PRTIM1))
00820 #define power_timer1_disable() (PRR0 |= (uint8_t)(1 << PRTIM1))
00821
00822 #define power_timer2_enable() (PRR0 &= (uint8_t)~(1 << PRTIM2))
00823 #define power_timer2_disable() (PRR0 |= (uint8_t)(1 << PRTIM2))
00824
00825 #define power_timer3_enable() (PRR1 &= (uint8_t)~(1 << PRTIM3))
00826 #define power_timer3_disable() (PRR1 |= (uint8_t)(1 << PRTIM3))
00827
00828 #define power_usart1_enable() (PRR1 &= (uint8_t)~(1 << PRUSART1))
00829 #define power_usart1_disable() (PRR1 |= (uint8_t)(1 << PRUSART1))
00830
00831 #define power_usb_enable() (PRR1 &= (uint8_t)~(1 << PRUSB))
00832 #define power_usb_disable() (PRR1 |= (uint8_t)(1 << PRUSB))
00833
00834 #define power_all_enable() \
00835 do{ \
00836 PRR0 &= (uint8_t)~((1<<PRADC)|(1<<PRUSART0)|(1<<PRSPI)|(1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)); \
00837 PRR1 &= (uint8_t)~((1<<PRTIM3)|(1<<PRUSART1)|(1<<PRUSB)); \
00838 }while(0)
00839
00840 #define power_all_disable() \
00841 do{ \
00842 PRR0 |= (uint8_t)((1<<PRADC)|(1<<PRUSART0)|(1<<PRSPI)|(1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)); \
00843 PRR1 |= (uint8_t)((1<<PRTIM3)|(1<<PRUSART1)|(1<<PRUSB)); \
00844 }while(0)
00845
00846
00847 #elif defined(__AVR_ATmega32U6__)
00848
00849
00850 #define power_adc_enable() (PRR0 &= (uint8_t)~(1 << PRADC))
00851 #define power_adc_disable() (PRR0 |= (uint8_t)(1 << PRADC))
00852
00853 #define power_spi_enable() (PRR0 &= (uint8_t)~(1 << PRSPI))
00854 #define power_spi_disable() (PRR0 |= (uint8_t)(1 << PRSPI))
00855
00856 #define power_twi_enable() (PRR0 &= (uint8_t)~(1 << PRTWI))
00857 #define power_twi_disable() (PRR0 |= (uint8_t)(1 << PRTWI))
00858
00859 #define power_timer0_enable() (PRR0 &= (uint8_t)~(1 << PRTIM0))
00860 #define power_timer0_disable() (PRR0 |= (uint8_t)(1 << PRTIM0))
00861
00862 #define power_timer1_enable() (PRR0 &= (uint8_t)~(1 << PRTIM1))
00863 #define power_timer1_disable() (PRR0 |= (uint8_t)(1 << PRTIM1))
00864
00865 #define power_timer2_enable() (PRR0 &= (uint8_t)~(1 << PRTIM2))
00866 #define power_timer2_disable() (PRR0 |= (uint8_t)(1 << PRTIM2))
00867
00868 #define power_timer3_enable() (PRR1 &= (uint8_t)~(1 << PRTIM3))
00869 #define power_timer3_disable() (PRR1 |= (uint8_t)(1 << PRTIM3))
00870
00871 #define power_usart1_enable() (PRR1 &= (uint8_t)~(1 << PRUSART1))
00872 #define power_usart1_disable() (PRR1 |= (uint8_t)(1 << PRUSART1))
00873
00874 #define power_usb_enable() (PRR1 &= (uint8_t)~(1 << PRUSB))
00875 #define power_usb_disable() (PRR1 |= (uint8_t)(1 << PRUSB))
00876
00877 #define power_all_enable() \
00878 do{ \
00879 PRR0 &= (uint8_t)~((1<<PRADC)|(1<<PRSPI)|(1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)); \
00880 PRR1 &= (uint8_t)~((1<<PRTIM3)|(1<<PRUSART1)|(1<<PRUSB)); \
00881 }while(0)
00882
00883 #define power_all_disable() \
00884 do{ \
00885 PRR0 |= (uint8_t)((1<<PRADC)|(1<<PRSPI)|(1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)); \
00886 PRR1 |= (uint8_t)((1<<PRTIM3)|(1<<PRUSART1)|(1<<PRUSB)); \
00887 }while(0)
00888
00889
00890 #elif defined(__AVR_AT90PWM1__)
00891
00892 #define power_adc_enable() (PRR &= (uint8_t)~(1 << PRADC))
00893 #define power_adc_disable() (PRR |= (uint8_t)(1 << PRADC))
00894
00895 #define power_spi_enable() (PRR &= (uint8_t)~(1 << PRSPI))
00896 #define power_spi_disable() (PRR |= (uint8_t)(1 << PRSPI))
00897
00898 #define power_timer0_enable() (PRR &= (uint8_t)~(1 << PRTIM0))
00899 #define power_timer0_disable() (PRR |= (uint8_t)(1 << PRTIM0))
00900
00901 #define power_timer1_enable() (PRR &= (uint8_t)~(1 << PRTIM1))
00902 #define power_timer1_disable() (PRR |= (uint8_t)(1 << PRTIM1))
00903
00904
00905 #define power_psc0_enable() (PRR &= (uint8_t)~(1 << PRPSC0))
00906 #define power_psc0_disable() (PRR |= (uint8_t)(1 << PRPSC0))
00907
00908
00909 #define power_psc1_enable() (PRR &= (uint8_t)~(1 << PRPSC1))
00910 #define power_psc1_disable() (PRR |= (uint8_t)(1 << PRPSC1))
00911
00912
00913 #define power_psc2_enable() (PRR &= (uint8_t)~(1 << PRPSC2))
00914 #define power_psc2_disable() (PRR |= (uint8_t)(1 << PRPSC2))
00915
00916 #define power_all_enable() (PRR &= (uint8_t)~((1<<PRADC)|(1<<PRSPI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRPSC0)|(1<<PRPSC1)|(1<<PRPSC2)))
00917 #define power_all_disable() (PRR |= (uint8_t)((1<<PRADC)|(1<<PRSPI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRPSC0)|(1<<PRPSC1)|(1<<PRPSC2)))
00918
00919
00920 #elif defined(__AVR_AT90PWM2__) \
00921 || defined(__AVR_AT90PWM2B__) \
00922 || defined(__AVR_AT90PWM3__) \
00923 || defined(__AVR_AT90PWM3B__) \
00924 || defined(__AVR_AT90PWM216__) \
00925 || defined(__AVR_AT90PWM316__)
00926
00927 #define power_adc_enable() (PRR &= (uint8_t)~(1 << PRADC))
00928 #define power_adc_disable() (PRR |= (uint8_t)(1 << PRADC))
00929
00930 #define power_spi_enable() (PRR &= (uint8_t)~(1 << PRSPI))
00931 #define power_spi_disable() (PRR |= (uint8_t)(1 << PRSPI))
00932
00933 #define power_usart_enable() (PRR &= (uint8_t)~(1 << PRUSART))
00934 #define power_usart_disable() (PRR |= (uint8_t)(1 << PRUSART))
00935
00936 #define power_timer0_enable() (PRR &= (uint8_t)~(1 << PRTIM0))
00937 #define power_timer0_disable() (PRR |= (uint8_t)(1 << PRTIM0))
00938
00939 #define power_timer1_enable() (PRR &= (uint8_t)~(1 << PRTIM1))
00940 #define power_timer1_disable() (PRR |= (uint8_t)(1 << PRTIM1))
00941
00942
00943 #define power_psc0_enable() (PRR &= (uint8_t)~(1 << PRPSC0))
00944 #define power_psc0_disable() (PRR |= (uint8_t)(1 << PRPSC0))
00945
00946
00947 #define power_psc1_enable() (PRR &= (uint8_t)~(1 << PRPSC1))
00948 #define power_psc1_disable() (PRR |= (uint8_t)(1 << PRPSC1))
00949
00950
00951 #define power_psc2_enable() (PRR &= (uint8_t)~(1 << PRPSC2))
00952 #define power_psc2_disable() (PRR |= (uint8_t)(1 << PRPSC2))
00953
00954 #define power_all_enable() (PRR &= (uint8_t)~((1<<PRADC)|(1<<PRSPI)|(1<<PRUSART)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRPSC0)|(1<<PRPSC1)|(1<<PRPSC2)))
00955 #define power_all_disable() (PRR |= (uint8_t)((1<<PRADC)|(1<<PRSPI)|(1<<PRUSART)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRPSC0)|(1<<PRPSC1)|(1<<PRPSC2)))
00956
00957
00958 #elif defined(__AVR_AT90PWM81__) \
00959 || defined(__AVR_AT90PWM161__)
00960
00961 #define power_adc_enable() (PRR &= (uint8_t)~(1 << PRADC))
00962 #define power_adc_disable() (PRR |= (uint8_t)(1 << PRADC))
00963
00964 #define power_spi_enable() (PRR &= (uint8_t)~(1 << PRSPI))
00965 #define power_spi_disable() (PRR |= (uint8_t)(1 << PRSPI))
00966
00967 #define power_timer1_enable() (PRR &= (uint8_t)~(1 << PRTIM1))
00968 #define power_timer1_disable() (PRR |= (uint8_t)(1 << PRTIM1))
00969
00970
00971 #define power_pscr_enable() (PRR &= (uint8_t)~(1 << PRPSCR))
00972 #define power_pscr_disable() (PRR |= (uint8_t)(1 << PRPSCR))
00973
00974
00975 #define power_psc2_enable() (PRR &= (uint8_t)~(1 << PRPSC2))
00976 #define power_psc2_disable() (PRR |= (uint8_t)(1 << PRPSC2))
00977
00978 #define power_all_enable() (PRR &= (uint8_t)~((1<<PRADC)|(1<<PRSPI)|(1<<PRTIM1)|(1<<PRPSCR)|(1<<PRPSC2)))
00979 #define power_all_disable() (PRR |= (uint8_t)((1<<PRADC)|(1<<PRSPI)|(1<<PRTIM1)|(1<<PRPSCR)|(1<<PRPSC2)))
00980
00981
00982 #elif defined(__AVR_ATmega165__) \
00983 || defined(__AVR_ATmega165A__) \
00984 || defined(__AVR_ATmega165P__) \
00985 || defined(__AVR_ATmega325__) \
00986 || defined(__AVR_ATmega325A__) \
00987 || defined(__AVR_ATmega325PA__) \
00988 || defined(__AVR_ATmega3250__) \
00989 || defined(__AVR_ATmega3250A__) \
00990 || defined(__AVR_ATmega3250PA__) \
00991 || defined(__AVR_ATmega645__) \
00992 || defined(__AVR_ATmega645A__) \
00993 || defined(__AVR_ATmega645P__) \
00994 || defined(__AVR_ATmega6450__) \
00995 || defined(__AVR_ATmega6450A__) \
00996 || defined(__AVR_ATmega6450P__)
00997
00998 #define power_adc_enable() (PRR &= (uint8_t)~(1 << PRADC))
00999 #define power_adc_disable() (PRR |= (uint8_t)(1 << PRADC))
01000
01001 #define power_spi_enable() (PRR &= (uint8_t)~(1 << PRSPI))
01002 #define power_spi_disable() (PRR |= (uint8_t)(1 << PRSPI))
01003
01004 #define power_usart0_enable() (PRR &= (uint8_t)~(1 << PRUSART0))
01005 #define power_usart0_disable() (PRR |= (uint8_t)(1 << PRUSART0))
01006
01007 #define power_timer1_enable() (PRR &= (uint8_t)~(1 << PRTIM1))
01008 #define power_timer1_disable() (PRR |= (uint8_t)(1 << PRTIM1))
01009
01010 #define power_all_enable() (PRR &= (uint8_t)~((1<<PRADC)|(1<<PRSPI)|(1<<PRUSART0)|(1<<PRTIM1)))
01011 #define power_all_disable() (PRR |= (uint8_t)((1<<PRADC)|(1<<PRSPI)|(1<<PRUSART0)|(1<<PRTIM1)))
01012
01013
01014 #elif defined(__AVR_ATmega169__) \
01015 || defined(__AVR_ATmega169A__) \
01016 || defined(__AVR_ATmega169P__) \
01017 || defined(__AVR_ATmega169PA__) \
01018 || defined(__AVR_ATmega329__) \
01019 || defined(__AVR_ATmega329A__) \
01020 || defined(__AVR_ATmega329P__) \
01021 || defined(__AVR_ATmega329PA__) \
01022 || defined(__AVR_ATmega3290__) \
01023 || defined(__AVR_ATmega3290A__) \
01024 || defined(__AVR_ATmega3290P__) \
01025 || defined(__AVR_ATmega3290PA__) \
01026 || defined(__AVR_ATmega649__) \
01027 || defined(__AVR_ATmega649A__) \
01028 || defined(__AVR_ATmega649P__) \
01029 || defined(__AVR_ATmega6490__) \
01030 || defined(__AVR_ATmega6490A__) \
01031 || defined(__AVR_ATmega6490P__)
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_timer1_enable() (PRR &= (uint8_t)~(1 << PRTIM1))
01043 #define power_timer1_disable() (PRR |= (uint8_t)(1 << PRTIM1))
01044
01045 #define power_lcd_enable() (PRR &= (uint8_t)~(1 << PRLCD))
01046 #define power_lcd_disable() (PRR |= (uint8_t)(1 << PRLCD))
01047
01048 #define power_all_enable() (PRR &= (uint8_t)~((1<<PRADC)|(1<<PRSPI)|(1<<PRUSART0)|(1<<PRTIM1)|(1<<PRLCD)))
01049 #define power_all_disable() (PRR |= (uint8_t)((1<<PRADC)|(1<<PRSPI)|(1<<PRUSART0)|(1<<PRTIM1)|(1<<PRLCD)))
01050
01051
01052 #elif defined(__AVR_ATmega164A__) \
01053 || defined(__AVR_ATmega164P__) \
01054 || defined(__AVR_ATmega324A__) \
01055 || defined(__AVR_ATmega324P__) \
01056 || defined(__AVR_ATmega324PA__) \
01057 || defined(__AVR_ATmega644P__) \
01058 || defined(__AVR_ATmega644A__) \
01059 || defined(__AVR_ATmega644PA__)
01060
01061 #define power_adc_enable() (PRR0 &= (uint8_t)~(1 << PRADC))
01062 #define power_adc_disable() (PRR0 |= (uint8_t)(1 << PRADC))
01063
01064 #define power_spi_enable() (PRR0 &= (uint8_t)~(1 << PRSPI))
01065 #define power_spi_disable() (PRR0 |= (uint8_t)(1 << PRSPI))
01066
01067 #define power_usart0_enable() (PRR0 &= (uint8_t)~(1 << PRUSART0))
01068 #define power_usart0_disable() (PRR0 |= (uint8_t)(1 << PRUSART0))
01069
01070 #define power_usart1_enable() (PRR0 &= (uint8_t)~(1 << PRUSART1))
01071 #define power_usart1_disable() (PRR0 |= (uint8_t)(1 << PRUSART1))
01072
01073 #define power_timer0_enable() (PRR0 &= (uint8_t)~(1 << PRTIM0))
01074 #define power_timer0_disable() (PRR0 |= (uint8_t)(1 << PRTIM0))
01075
01076 #define power_timer1_enable() (PRR0 &= (uint8_t)~(1 << PRTIM1))
01077 #define power_timer1_disable() (PRR0 |= (uint8_t)(1 << PRTIM1))
01078
01079 #define power_timer2_enable() (PRR0 &= (uint8_t)~(1 << PRTIM2))
01080 #define power_timer2_disable() (PRR0 |= (uint8_t)(1 << PRTIM2))
01081
01082 #define power_twi_enable() (PRR0 &= (uint8_t)~(1 << PRTWI))
01083 #define power_twi_disable() (PRR0 |= (uint8_t)(1 << PRTWI))
01084
01085 #define power_all_enable() (PRR0 &= (uint8_t)~((1<<PRADC)|(1<<PRSPI)|(1<<PRUSART0)|(1<<PRUSART1)|(1<<PRTIM0)|(1<<PRTIM2)|(1<<PRTWI)))
01086 #define power_all_disable() (PRR0 |= (uint8_t)((1<<PRADC)|(1<<PRSPI)|(1<<PRUSART0)|(1<<PRUSART1)|(1<<PRTIM0)|(1<<PRTIM2)|(1<<PRTWI)))
01087
01088
01089 #elif defined(__AVR_ATmega644__)
01090
01091 #define power_adc_enable() (PRR0 &= (uint8_t)~(1 << PRADC))
01092 #define power_adc_disable() (PRR0 |= (uint8_t)(1 << PRADC))
01093
01094 #define power_spi_enable() (PRR0 &= (uint8_t)~(1 << PRSPI))
01095 #define power_spi_disable() (PRR0 |= (uint8_t)(1 << PRSPI))
01096
01097 #define power_usart0_enable() (PRR0 &= (uint8_t)~(1 << PRUSART0))
01098 #define power_usart0_disable() (PRR0 |= (uint8_t)(1 << PRUSART0))
01099
01100 #define power_timer0_enable() (PRR0 &= (uint8_t)~(1 << PRTIM0))
01101 #define power_timer0_disable() (PRR0 |= (uint8_t)(1 << PRTIM0))
01102
01103 #define power_timer1_enable() (PRR0 &= (uint8_t)~(1 << PRTIM1))
01104 #define power_timer1_disable() (PRR0 |= (uint8_t)(1 << PRTIM1))
01105
01106 #define power_timer2_enable() (PRR0 &= (uint8_t)~(1 << PRTIM2))
01107 #define power_timer2_disable() (PRR0 |= (uint8_t)(1 << PRTIM2))
01108
01109 #define power_twi_enable() (PRR0 &= (uint8_t)~(1 << PRTWI))
01110 #define power_twi_disable() (PRR0 |= (uint8_t)(1 << PRTWI))
01111
01112 #define power_all_enable() (PRR0 &= (uint8_t)~((1<<PRADC)|(1<<PRSPI)|(1<<PRUSART0)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)|(1<<PRTWI)))
01113 #define power_all_disable() (PRR0 |= (uint8_t)((1<<PRADC)|(1<<PRSPI)|(1<<PRUSART0)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)|(1<<PRTWI)))
01114
01115
01116 #elif defined(__AVR_ATmega406__)
01117
01118 #define power_twi_enable() (PRR0 &= (uint8_t)~(1 << PRTWI))
01119 #define power_twi_disable() (PRR0 |= (uint8_t)(1 << PRTWI))
01120
01121 #define power_timer0_enable() (PRR0 &= (uint8_t)~(1 << PRTIM0))
01122 #define power_timer0_disable() (PRR0 |= (uint8_t)(1 << PRTIM0))
01123
01124 #define power_timer1_enable() (PRR0 &= (uint8_t)~(1 << PRTIM1))
01125 #define power_timer1_disable() (PRR0 |= (uint8_t)(1 << PRTIM1))
01126
01127
01128 #define power_vadc_enable() (PRR0 &= (uint8_t)~(1 << PRVADC))
01129 #define power_vadc_disable() (PRR0 |= (uint8_t)(1 << PRVADC))
01130
01131 #define power_all_enable() (PRR0 &= (uint8_t)~((1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRVADC)))
01132 #define power_all_disable() (PRR0 |= (uint8_t)((1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRVADC)))
01133
01134
01135 #elif defined(__AVR_ATmega48__) \
01136 || defined(__AVR_ATmega48A__) \
01137 || defined(__AVR_ATmega48PA__) \
01138 || defined(__AVR_ATmega48P__) \
01139 || defined(__AVR_ATmega88__) \
01140 || defined(__AVR_ATmega88A__) \
01141 || defined(__AVR_ATmega88P__) \
01142 || defined(__AVR_ATmega88PA__) \
01143 || defined(__AVR_ATmega168__) \
01144 || defined(__AVR_ATmega168A__) \
01145 || defined(__AVR_ATmega168P__) \
01146 || defined(__AVR_ATmega328__) \
01147 || defined(__AVR_ATmega328P__) \
01148 || defined(__AVR_ATtiny48__) \
01149 || defined(__AVR_ATtiny88__)
01150
01151 #define power_adc_enable() (PRR &= (uint8_t)~(1 << PRADC))
01152 #define power_adc_disable() (PRR |= (uint8_t)(1 << PRADC))
01153
01154 #define power_spi_enable() (PRR &= (uint8_t)~(1 << PRSPI))
01155 #define power_spi_disable() (PRR |= (uint8_t)(1 << PRSPI))
01156
01157 #define power_usart0_enable() (PRR &= (uint8_t)~(1 << PRUSART0))
01158 #define power_usart0_disable() (PRR |= (uint8_t)(1 << PRUSART0))
01159
01160 #define power_timer0_enable() (PRR &= (uint8_t)~(1 << PRTIM0))
01161 #define power_timer0_disable() (PRR |= (uint8_t)(1 << PRTIM0))
01162
01163 #define power_timer1_enable() (PRR &= (uint8_t)~(1 << PRTIM1))
01164 #define power_timer1_disable() (PRR |= (uint8_t)(1 << PRTIM1))
01165
01166 #define power_timer2_enable() (PRR &= (uint8_t)~(1 << PRTIM2))
01167 #define power_timer2_disable() (PRR |= (uint8_t)(1 << PRTIM2))
01168
01169 #define power_twi_enable() (PRR &= (uint8_t)~(1 << PRTWI))
01170 #define power_twi_disable() (PRR |= (uint8_t)(1 << PRTWI))
01171
01172 #define power_all_enable() (PRR &= (uint8_t)~((1<<PRADC)|(1<<PRSPI)|(1<<PRUSART0)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)|(1<<PRTWI)))
01173 #define power_all_disable() (PRR |= (uint8_t)((1<<PRADC)|(1<<PRSPI)|(1<<PRUSART0)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)|(1<<PRTWI)))
01174
01175
01176 #elif defined(__AVR_ATtiny24__) \
01177 || defined(__AVR_ATtiny24A__) \
01178 || defined(__AVR_ATtiny44__) \
01179 || defined(__AVR_ATtiny44A__) \
01180 || defined(__AVR_ATtiny84__) \
01181 || defined(__AVR_ATtiny84A__) \
01182 || defined(__AVR_ATtiny25__) \
01183 || defined(__AVR_ATtiny45__) \
01184 || defined(__AVR_ATtiny85__) \
01185 || defined(__AVR_ATtiny261__) \
01186 || defined(__AVR_ATtiny261A__) \
01187 || defined(__AVR_ATtiny461__) \
01188 || defined(__AVR_ATtiny461A__) \
01189 || defined(__AVR_ATtiny861__) \
01190 || defined(__AVR_ATtiny861A__) \
01191 || defined(__AVR_ATtiny43U__)
01192
01193 #define power_adc_enable() (PRR &= (uint8_t)~(1 << PRADC))
01194 #define power_adc_disable() (PRR |= (uint8_t)(1 << PRADC))
01195
01196 #define power_timer0_enable() (PRR &= (uint8_t)~(1 << PRTIM0))
01197 #define power_timer0_disable() (PRR |= (uint8_t)(1 << PRTIM0))
01198
01199 #define power_timer1_enable() (PRR &= (uint8_t)~(1 << PRTIM1))
01200 #define power_timer1_disable() (PRR |= (uint8_t)(1 << PRTIM1))
01201
01202
01203 #define power_usi_enable() (PRR &= (uint8_t)~(1 << PRUSI))
01204 #define power_usi_disable() (PRR |= (uint8_t)(1 << PRUSI))
01205
01206 #define power_all_enable() (PRR &= (uint8_t)~((1<<PRADC)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRUSI)))
01207 #define power_all_disable() (PRR |= (uint8_t)((1<<PRADC)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRUSI)))
01208
01209
01210 #elif defined(__AVR_ATmega1284P__)
01211
01212
01213 #define power_adc_enable() (PRR0 &= (uint8_t)~(1 << PRADC))
01214 #define power_adc_disable() (PRR0 |= (uint8_t)(1 << PRADC))
01215
01216 #define power_spi_enable() (PRR0 &= (uint8_t)~(1 << PRSPI))
01217 #define power_spi_disable() (PRR0 |= (uint8_t)(1 << PRSPI))
01218
01219 #define power_twi_enable() (PRR0 &= (uint8_t)~(1 << PRTWI))
01220 #define power_twi_disable() (PRR0 |= (uint8_t)(1 << PRTWI))
01221
01222 #define power_timer0_enable() (PRR0 &= (uint8_t)~(1 << PRTIM0))
01223 #define power_timer0_disable() (PRR0 |= (uint8_t)(1 << PRTIM0))
01224
01225 #define power_timer1_enable() (PRR0 &= (uint8_t)~(1 << PRTIM1))
01226 #define power_timer1_disable() (PRR0 |= (uint8_t)(1 << PRTIM1))
01227
01228 #define power_timer2_enable() (PRR0 &= (uint8_t)~(1 << PRTIM2))
01229 #define power_timer2_disable() (PRR0 |= (uint8_t)(1 << PRTIM2))
01230
01231 #define power_timer3_enable() (PRR1 &= (uint8_t)~(1 << PRTIM3))
01232 #define power_timer3_disable() (PRR1 |= (uint8_t)(1 << PRTIM3))
01233
01234 #define power_usart0_enable() (PRR0 &= (uint8_t)~(1 << PRUSART0))
01235 #define power_usart0_disable() (PRR0 |= (uint8_t)(1 << PRUSART0))
01236
01237 #define power_usart1_enable() (PRR0 &= (uint8_t)~(1 << PRUSART1))
01238 #define power_usart1_disable() (PRR0 |= (uint8_t)(1 << PRUSART1))
01239
01240 #define power_all_enable() \
01241 do{ \
01242 PRR0 &= (uint8_t)~((1<<PRADC)|(1<<PRSPI)|(1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)|(1<<PRUSART0)|(1<<PRUSART1)); \
01243 PRR1 &= (uint8_t)~(1<<PRTIM3); \
01244 }while(0)
01245
01246 #define power_all_disable() \
01247 do{ \
01248 PRR0 |= (uint8_t)((1<<PRADC)|(1<<PRSPI)|(1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)|(1<<PRUSART0)|(1<<PRUSART1)); \
01249 PRR1 |= (uint8_t)(1<<PRTIM3); \
01250 }while(0)
01251
01252
01253 #elif defined(__AVR_ATmega32HVB__) \
01254 || defined(__AVR_ATmega32HVBREVB__) \
01255 || defined(__AVR_ATmega16HVB__) \
01256 || defined(__AVR_ATmega16HVBREVB__)
01257
01258
01259 #define power_twi_enable() (PRR0 &= (uint8_t)~(1 << PRTWI))
01260 #define power_twi_disable() (PRR0 |= (uint8_t)(1 << PRTWI))
01261
01262 #define power_timer0_enable() (PRR0 &= (uint8_t)~(1 << PRTIM0))
01263 #define power_timer0_disable() (PRR0 |= (uint8_t)(1 << PRTIM0))
01264
01265 #define power_timer1_enable() (PRR0 &= (uint8_t)~(1 << PRTIM1))
01266 #define power_timer1_disable() (PRR0 |= (uint8_t)(1 << PRTIM1))
01267
01268
01269 #define power_vadc_enable() (PRR0 &= (uint8_t)~(1 << PRVADC))
01270 #define power_vadc_disable() (PRR0 |= (uint8_t)(1 << PRVADC))
01271
01272 #define power_spi_enable() (PRR0 &= (uint8_t)~(1 << PRSPI))
01273 #define power_spi_disable() (PRR0 |= (uint8_t)(1 << PRSPI))
01274
01275 #define power_vrm_enable() (PRR0 &= (uint8_t)~(1 << PRVRM))
01276 #define power_vrm_disable() (PRR0 |= (uint8_t)(1 << PRVRM))
01277
01278 #define power_all_enable() (PRR0 &= (uint8_t)~((1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRVADC)|(1<<PRSPI)|(1<<PRVRM)))
01279 #define power_all_disable() (PRR0 |= (uint8_t)((1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRVADC)|(1<<PRSPI)|(1<<PRVRM)))
01280
01281
01282 #elif defined(__AVR_ATmega16M1__) \
01283 || defined(__AVR_ATmega32C1__) \
01284 || defined(__AVR_ATmega32M1__) \
01285 || defined(__AVR_ATmega64C1__) \
01286 || defined(__AVR_ATmega64M1__)
01287
01288 #define power_adc_enable() (PRR &= (uint8_t)~(1 << PRADC))
01289 #define power_adc_disable() (PRR |= (uint8_t)(1 << PRADC))
01290
01291 #define power_lin_enable() (PRR &= (uint8_t)~(1 << PRLIN))
01292 #define power_lin_disable() (PRR |= (uint8_t)(1 << PRLIN))
01293
01294 #define power_spi_enable() (PRR &= (uint8_t)~(1 << PRSPI))
01295 #define power_spi_disable() (PRR |= (uint8_t)(1 << PRSPI))
01296
01297 #define power_timer0_enable() (PRR &= (uint8_t)~(1 << PRTIM0))
01298 #define power_timer0_disable() (PRR |= (uint8_t)(1 << PRTIM0))
01299
01300 #define power_timer1_enable() (PRR &= (uint8_t)~(1 << PRTIM1))
01301 #define power_timer1_disable() (PRR |= (uint8_t)(1 << PRTIM1))
01302
01303 #define power_psc_enable() (PRR &= (uint8_t)~(1 << PRPSC))
01304 #define power_psc_disable() (PRR |= (uint8_t)(1 << PRPSC))
01305
01306 #define power_can_enable() (PRR &= (uint8_t)~(1 << PRCAN))
01307 #define power_can_disable() (PRR |= (uint8_t)(1 << PRCAN))
01308
01309 #define power_all_enable() (PRR &= (uint8_t)~((1<<PRADC)|(1<<PRLIN)|(1<<PRSPI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRPSC)|(1<<PRCAN)))
01310 #define power_all_disable() (PRR |= (uint8_t)((1<<PRADC)|(1<<PRLIN)|(1<<PRSPI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRPSC)|(1<<PRCAN)))
01311
01312
01313 #elif defined(__AVR_ATtiny167__) \
01314 || defined(__AVR_ATtiny87__)
01315
01316
01317 #define power_adc_enable() (PRR &= (uint8_t)~(1 << PRADC))
01318 #define power_adc_disable() (PRR |= (uint8_t)(1 << PRADC))
01319
01320 #define power_usi_enable() (PRR &= (uint8_t)~(1 << PRUSI))
01321 #define power_usi_disable() (PRR |= (uint8_t)(1 << PRUSI))
01322
01323 #define power_timer0_enable() (PRR &= (uint8_t)~(1 << PRTIM0))
01324 #define power_timer0_disable() (PRR |= (uint8_t)(1 << PRTIM0))
01325
01326 #define power_timer1_enable() (PRR &= (uint8_t)~(1 << PRTIM1))
01327 #define power_timer1_disable() (PRR |= (uint8_t)(1 << PRTIM1))
01328
01329 #define power_spi_enable() (PRR &= (uint8_t)~(1 << PRSPI))
01330 #define power_spi_disable() (PRR |= (uint8_t)(1 << PRSPI))
01331
01332 #define power_lin_enable() (PRR &= (uint8_t)~(1 << PRLIN))
01333 #define power_lin_disable() (PRR |= (uint8_t)(1 << PRLIN))
01334
01335 #define power_all_enable() (PRR &= (uint8_t)~((1<<PRADC)|(1<<PRUSI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRSPI)|(1<<PRLIN)))
01336 #define power_all_disable() (PRR |= (uint8_t)((1<<PRADC)|(1<<PRUSI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRSPI)|(1<<PRLIN)))
01337
01338
01339 #elif defined(__AVR_ATtiny1634__)
01340
01341 #define power_adc_enable() (PRR &= (uint8_t)~(1 << PRADC))
01342 #define power_adc_disable() (PRR |= (uint8_t)(1 << PRADC))
01343
01344 #define power_usart0_enable() (PRR &= (uint8_t)~(1 << PRUSART0))
01345 #define power_usart0_disable() (PRR |= (uint8_t)(1 << PRUSART0))
01346
01347 #define power_usart1_enable() (PRR &= (uint8_t)~(1 << PRUSART1))
01348 #define power_usart1_disable() (PRR |= (uint8_t)(1 << PRUSART1))
01349
01350 #define power_usi_enable() (PRR &= (uint8_t)~(1 << PRUSI))
01351 #define power_usi_disable() (PRR |= (uint8_t)(1 << PRUSI))
01352
01353 #define power_timer0_enable() (PRR &= (uint8_t)~(1 << PRTIM0))
01354 #define power_timer0_disable() (PRR |= (uint8_t)(1 << PRTIM0))
01355
01356 #define power_timer1_enable() (PRR &= (uint8_t)~(1 << PRTIM1))
01357 #define power_timer1_disable() (PRR |= (uint8_t)(1 << PRTIM1))
01358
01359 #define power_twi_enable() (PRR &= (uint8_t)~(1 << PRTWI))
01360 #define power_twi_disable() (PRR |= (uint8_t)(1 << PRTWI))
01361
01362 #define power_all_enable() (PRR &= (uint8_t)~((1 << PRTWI)|(1 << PRUSI)|(1 << PRTIM0)|(1 << PRTIM1)|(1 << PRUSART0)|(1 << PRUSART1)|(1 << PRADC)))
01363 #define power_all_disable() (PRR |= (uint8_t)((1 << PRTWI)|(1 << PRUSI)|(1 << PRTIM0)|(1 << PRTIM1)|(1 << PRUSART0)|(1 << PRUSART1)|(1 << PRADC)))
01364
01365
01366 #elif defined(__AVR_AT90USB82__) \
01367 || defined(__AVR_AT90USB162__) \
01368 || defined(__AVR_ATmega8U2__) \
01369 || defined(__AVR_ATmega16U2__) \
01370 || defined(__AVR_ATmega32U2__)
01371
01372 #define power_spi_enable() (PRR0 &= (uint8_t)~(1 << PRSPI))
01373 #define power_spi_disable() (PRR0 |= (uint8_t)(1 << PRSPI))
01374
01375 #define power_timer0_enable() (PRR0 &= (uint8_t)~(1 << PRTIM0))
01376 #define power_timer0_disable() (PRR0 |= (uint8_t)(1 << PRTIM0))
01377
01378 #define power_timer1_enable() (PRR0 &= (uint8_t)~(1 << PRTIM1))
01379 #define power_timer1_disable() (PRR0 |= (uint8_t)(1 << PRTIM1))
01380
01381 #define power_usb_enable() (PRR1 &= (uint8_t)~(1 << PRUSB))
01382 #define power_usb_disable() (PRR1 |= (uint8_t)(1 << PRUSB))
01383
01384 #define power_usart1_enable() (PRR1 &= (uint8_t)~(1 << PRUSART1))
01385 #define power_usart1_disable() (PRR1 |= (uint8_t)(1 << PRUSART1))
01386
01387 #define power_all_enable() \
01388 do{ \
01389 PRR0 &= (uint8_t)~((1<<PRSPI)|(1<<PRTIM0)|(1<<PRTIM1)); \
01390 PRR1 &= (uint8_t)~((1<<PRUSB)|(1<<PRUSART1)); \
01391 }while(0)
01392
01393 #define power_all_disable() \
01394 do{ \
01395 PRR0 |= (uint8_t)((1<<PRSPI)|(1<<PRTIM0)|(1<<PRTIM1)); \
01396 PRR1 |= (uint8_t)((1<<PRUSB)|(1<<PRUSART1)); \
01397 }while(0)
01398
01399
01400 #elif defined(__AVR_AT90SCR100__)
01401
01402 #define power_usart0_enable() (PRR0 &= (uint8_t)~(1 << PRUSART0))
01403 #define power_usart0_disable() (PRR0 |= (uint8_t)(1 << PRUSART0))
01404
01405 #define power_spi_enable() (PRR0 &= (uint8_t)~(1 << PRSPI))
01406 #define power_spi_disable() (PRR0 |= (uint8_t)(1 << PRSPI))
01407
01408 #define power_timer1_enable() (PRR0 &= (uint8_t)~(1 << PRTIM1))
01409 #define power_timer1_disable() (PRR0 |= (uint8_t)(1 << PRTIM1))
01410
01411 #define power_timer0_enable() (PRR0 &= (uint8_t)~(1 << PRTIM0))
01412 #define power_timer0_disable() (PRR0 |= (uint8_t)(1 << PRTIM0))
01413
01414 #define power_timer2_enable() (PRR0 &= (uint8_t)~(1 << PRTIM2))
01415 #define power_timer2_disable() (PRR0 |= (uint8_t)(1 << PRTIM2))
01416
01417 #define power_twi_enable() (PRR0 &= (uint8_t)~(1 << PRTWI))
01418 #define power_twi_disable() (PRR0 |= (uint8_t)(1 << PRTWI))
01419
01420 #define power_usbh_enable() (PRR1 &= (uint8_t)~(1 << PRUSBH))
01421 #define power_usbh_disable() (PRR1 |= (uint8_t)(1 << PRUSBH))
01422
01423 #define power_usb_enable() (PRR1 &= (uint8_t)~(1 << PRUSB))
01424 #define power_usb_disable() (PRR1 |= (uint8_t)(1 << PRUSB))
01425
01426 #define power_hsspi_enable() (PRR1 &= (uint8_t)~(1 << PRHSSPI))
01427 #define power_hsspi_disable() (PRR1 |= (uint8_t)(1 << PRHSSPI))
01428
01429 #define power_sci_enable() (PRR1 &= (uint8_t)~(1 << PRSCI))
01430 #define power_sci_disable() (PRR1 |= (uint8_t)(1 << PRSCI))
01431
01432 #define power_aes_enable() (PRR1 &= (uint8_t)~(1 << PRAES))
01433 #define power_aes_disable() (PRR1 |= (uint8_t)(1 << PRAES))
01434
01435 #define power_kb_enable() (PRR1 &= (uint8_t)~(1 << PRKB))
01436 #define power_kb_disable() (PRR1 |= (uint8_t)(1 << PRKB))
01437
01438 #define power_all_enable() \
01439 do{ \
01440 PRR0 &= (uint8_t)~((1<<PRUSART0)|(1<<PRSPI)|(1<<PRTIM1)|(1<<PRTIM0)|(1<<PRTIM2)|(1<<PRTWI)); \
01441 PRR1 &= (uint8_t)~((1<<PRUSBH)|(1<<PRUSB)|(1<<PRHSSPI)|(1<<PRSCI)|(1<<PRAES)|(1<<PRKB)); \
01442 }while(0)
01443
01444 #define power_all_disable() \
01445 do{ \
01446 PRR0 |= (uint8_t)((1<<PRUSART0)|(1<<PRSPI)|(1<<PRTIM1)|(1<<PRTIM0)|(1<<PRTIM2)|(1<<PRTWI)); \
01447 PRR1 |= (uint8_t)((1<<PRUSBH)|(1<<PRUSB)|(1<<PRHSSPI)|(1<<PRSCI)|(1<<PRAES)|(1<<PRKB)); \
01448 }while(0)
01449
01450
01451 #elif defined(__AVR_ATtiny4__) \
01452 || defined(__AVR_ATtiny5__) \
01453 || defined(__AVR_ATtiny9__) \
01454 || defined(__AVR_ATtiny10__) \
01455 || defined(__AVR_ATtiny13A__) \
01456
01457 #define power_adc_enable() (PRR &= (uint8_t)~(1 << PRADC))
01458 #define power_adc_disable() (PRR |= (uint8_t)(1 << PRADC))
01459
01460 #define power_timer0_enable() (PRR &= (uint8_t)~(1 << PRTIM0))
01461 #define power_timer0_disable() (PRR |= (uint8_t)(1 << PRTIM0))
01462
01463 #define power_all_enable() (PRR &= (uint8_t)~((1<<PRADC)|(1<<PRTIM0)))
01464 #define power_all_disable() (PRR |= (uint8_t)((1<<PRADC)|(1<<PRTIM0)))
01465
01466
01467 #elif defined(__AVR_ATtiny20__) \
01468 || defined(__AVR_ATtiny40__)
01469
01470 #define power_adc_enable() (PRR &= (uint8_t)~(1 << PRADC))
01471 #define power_adc_disable() (PRR |= (uint8_t)(1 << PRADC))
01472
01473 #define power_timer0_enable() (PRR &= (uint8_t)~(1 << PRTIM0))
01474 #define power_timer0_disable() (PRR |= (uint8_t)(1 << PRTIM0))
01475
01476 #define power_timer1_enable() (PRR &= (uint8_t)~(1 << PRTIM1))
01477 #define power_timer1_disable() (PRR |= (uint8_t)(1 << PRTIM1))
01478
01479 #define power_spi_enable() (PRR &= (uint8_t)~(1 << PRSPI))
01480 #define power_spi_disable() (PRR |= (uint8_t)(1 << PRSPI))
01481
01482 #define power_twi_enable() (PRR &= (uint8_t)~(1 << PRTWI))
01483 #define power_twi_disable() (PRR |= (uint8_t)(1 << PRTWI))
01484
01485 #define power_all_enable() (PRR &= (uint8_t)~((1<<PRADC)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRSPI)|(1<<PRTWI)))
01486 #define power_all_disable() (PRR |= (uint8_t)((1<<PRADC)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRSPI)|(1<<PRTWI)))
01487
01488 #endif
01489
01490
01491 #if defined(__AVR_AT90CAN32__) \
01492 || defined(__AVR_AT90CAN64__) \
01493 || defined(__AVR_AT90CAN128__) \
01494 || defined(__AVR_AT90PWM1__) \
01495 || defined(__AVR_AT90PWM2__) \
01496 || defined(__AVR_AT90PWM2B__) \
01497 || defined(__AVR_AT90PWM3__) \
01498 || defined(__AVR_AT90PWM3B__) \
01499 || defined(__AVR_AT90PWM81__) \
01500 || defined(__AVR_AT90PWM161__) \
01501 || defined(__AVR_AT90PWM216__) \
01502 || defined(__AVR_AT90PWM316__) \
01503 || defined(__AVR_AT90SCR100__) \
01504 || defined(__AVR_AT90USB646__) \
01505 || defined(__AVR_AT90USB647__) \
01506 || defined(__AVR_AT90USB82__) \
01507 || defined(__AVR_AT90USB1286__) \
01508 || defined(__AVR_AT90USB1287__) \
01509 || defined(__AVR_AT90USB162__) \
01510 || defined(__AVR_ATmega1280__) \
01511 || defined(__AVR_ATmega1281__) \
01512 || defined(__AVR_ATmega128RFA1__) \
01513 || defined(__AVR_ATmega1284P__) \
01514 || defined(__AVR_ATmega162__) \
01515 || defined(__AVR_ATmega164A__) \
01516 || defined(__AVR_ATmega164P__) \
01517 || defined(__AVR_ATmega165__) \
01518 || defined(__AVR_ATmega165A__) \
01519 || defined(__AVR_ATmega165P__) \
01520 || defined(__AVR_ATmega168__) \
01521 || defined(__AVR_ATmega168P__) \
01522 || defined(__AVR_ATmega169__) \
01523 || defined(__AVR_ATmega169A__) \
01524 || defined(__AVR_ATmega169P__) \
01525 || defined(__AVR_ATmega169PA__) \
01526 || defined(__AVR_ATmega16U4__) \
01527 || defined(__AVR_ATmega2560__) \
01528 || defined(__AVR_ATmega2561__) \
01529 || defined(__AVR_ATmega324A__) \
01530 || defined(__AVR_ATmega324P__) \
01531 || defined(__AVR_ATmega325__) \
01532 || defined(__AVR_ATmega325A__) \
01533 || defined(__AVR_ATmega325PA__) \
01534 || defined(__AVR_ATmega3250__) \
01535 || defined(__AVR_ATmega3250A__) \
01536 || defined(__AVR_ATmega3250PA__) \
01537 || defined(__AVR_ATmega328P__) \
01538 || defined(__AVR_ATmega329__) \
01539 || defined(__AVR_ATmega329A__) \
01540 || defined(__AVR_ATmega329P__) \
01541 || defined(__AVR_ATmega329PA__) \
01542 || defined(__AVR_ATmega3290__) \
01543 || defined(__AVR_ATmega3290A__) \
01544 || defined(__AVR_ATmega3290PA__) \
01545 || defined(__AVR_ATmega32C1__) \
01546 || defined(__AVR_ATmega32HVB__) \
01547 || defined(__AVR_ATmega32HVBREVB__) \
01548 || defined(__AVR_ATmega16HVB__) \
01549 || defined(__AVR_ATmega16HVBREVB__) \
01550 || defined(__AVR_ATmega32M1__) \
01551 || defined(__AVR_ATmega32U2__) \
01552 || defined(__AVR_ATmega32U4__) \
01553 || defined(__AVR_ATmega32U6__) \
01554 || defined(__AVR_ATmega48__) \
01555 || defined(__AVR_ATmega48A__) \
01556 || defined(__AVR_ATmega48PA__) \
01557 || defined(__AVR_ATmega48P__) \
01558 || defined(__AVR_ATmega640__) \
01559 || defined(__AVR_ATmega649P__) \
01560 || defined(__AVR_ATmega644__) \
01561 || defined(__AVR_ATmega644A__) \
01562 || defined(__AVR_ATmega644P__) \
01563 || defined(__AVR_ATmega644PA__) \
01564 || defined(__AVR_ATmega645__) \
01565 || defined(__AVR_ATmega645A__) \
01566 || defined(__AVR_ATmega645P__) \
01567 || defined(__AVR_ATmega6450__) \
01568 || defined(__AVR_ATmega6450A__) \
01569 || defined(__AVR_ATmega6450P__) \
01570 || defined(__AVR_ATmega649__) \
01571 || defined(__AVR_ATmega649A__) \
01572 || defined(__AVR_ATmega6490__) \
01573 || defined(__AVR_ATmega6490A__) \
01574 || defined(__AVR_ATmega6490P__) \
01575 || defined(__AVR_ATmega88__) \
01576 || defined(__AVR_ATmega88P__) \
01577 || defined(__AVR_ATtiny48__) \
01578 || defined(__AVR_ATtiny167__) \
01579 || defined(__DOXYGEN__)
01580
01581
01582
01583
01584
01585
01586
01587
01588
01589
01590
01591
01592
01593
01594
01595
01596
01597
01598
01599
01600
01601
01602
01603
01604
01605
01606
01607
01608
01609
01610
01611
01612
01613 typedef enum
01614 {
01615 clock_div_1 = 0,
01616 clock_div_2 = 1,
01617 clock_div_4 = 2,
01618 clock_div_8 = 3,
01619 clock_div_16 = 4,
01620 clock_div_32 = 5,
01621 clock_div_64 = 6,
01622 clock_div_128 = 7,
01623 clock_div_256 = 8
01624 #if defined(__AVR_ATmega128RFA1__)
01625 , clock_div_1_rc = 15
01626 #endif
01627 } clock_div_t;
01628
01629
01630 static __inline__ void clock_prescale_set(clock_div_t) __attribute__((__always_inline__));
01631
01632
01633
01634
01635
01636
01637
01638
01639
01640
01641 void clock_prescale_set(clock_div_t __x)
01642 {
01643 uint8_t __tmp = _BV(CLKPCE);
01644 __asm__ __volatile__ (
01645 "in __tmp_reg__,__SREG__" "\n\t"
01646 "cli" "\n\t"
01647 "sts %1, %0" "\n\t"
01648 "sts %1, %2" "\n\t"
01649 "out __SREG__, __tmp_reg__"
01650 :
01651 : "d" (__tmp),
01652 "M" (_SFR_MEM_ADDR(CLKPR)),
01653 "d" (__x)
01654 : "r0");
01655 }
01656
01657
01658
01659
01660
01661
01662 #define clock_prescale_get() (clock_div_t)(CLKPR & (uint8_t)((1<<CLKPS0)|(1<<CLKPS1)|(1<<CLKPS2)|(1<<CLKPS3)))
01663
01664
01665 #elif defined(__AVR_ATtiny24__) \
01666 || defined(__AVR_ATtiny24A__) \
01667 || defined(__AVR_ATtiny44__) \
01668 || defined(__AVR_ATtiny44A__) \
01669 || defined(__AVR_ATtiny84__) \
01670 || defined(__AVR_ATtiny84A__) \
01671 || defined(__AVR_ATtiny25__) \
01672 || defined(__AVR_ATtiny45__) \
01673 || defined(__AVR_ATtiny85__) \
01674 || defined(__AVR_ATtiny261A__) \
01675 || defined(__AVR_ATtiny261__) \
01676 || defined(__AVR_ATtiny461__) \
01677 || defined(__AVR_ATtiny461A__) \
01678 || defined(__AVR_ATtiny861__) \
01679 || defined(__AVR_ATtiny861A__) \
01680 || defined(__AVR_ATtiny2313__) \
01681 || defined(__AVR_ATtiny2313A__) \
01682 || defined(__AVR_ATtiny4313__) \
01683 || defined(__AVR_ATtiny13__) \
01684 || defined(__AVR_ATtiny13A__) \
01685 || defined(__AVR_ATtiny43U__) \
01686
01687 typedef enum
01688 {
01689 clock_div_1 = 0,
01690 clock_div_2 = 1,
01691 clock_div_4 = 2,
01692 clock_div_8 = 3,
01693 clock_div_16 = 4,
01694 clock_div_32 = 5,
01695 clock_div_64 = 6,
01696 clock_div_128 = 7,
01697 clock_div_256 = 8
01698 } clock_div_t;
01699
01700 static __inline__ void clock_prescale_set(clock_div_t) __attribute__((__always_inline__));
01701
01702 void clock_prescale_set(clock_div_t __x)
01703 {
01704 uint8_t __tmp = _BV(CLKPCE);
01705 __asm__ __volatile__ (
01706 "in __tmp_reg__,__SREG__" "\n\t"
01707 "cli" "\n\t"
01708 "out %1, %0" "\n\t"
01709 "out %1, %2" "\n\t"
01710 "out __SREG__, __tmp_reg__"
01711 :
01712 : "d" (__tmp),
01713 "I" (_SFR_IO_ADDR(CLKPR)),
01714 "d" (__x)
01715 : "r0");
01716 }
01717
01718
01719 #define clock_prescale_get() (clock_div_t)(CLKPR & (uint8_t)((1<<CLKPS0)|(1<<CLKPS1)|(1<<CLKPS2)|(1<<CLKPS3)))
01720
01721
01722 #endif
01723
01724
01725
01726
01727 #endif