Go to the documentation of this file.00001
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "pal.h"
00022
00023 #if (PAL_TYPE == ATMEGA128RFA1)
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 static void mcu_clock_init(void);
00034
00035
00036
00040 void mcu_init(void)
00041 {
00042 mcu_clock_init();
00043
00044
00045 DRTRAM0 = _BV(ENDRT);
00046 DRTRAM1 = _BV(ENDRT);
00047 DRTRAM2 = _BV(ENDRT);
00048 DRTRAM3 = _BV(ENDRT);
00049 }
00050
00051
00052
00059 void mcu_clock_init(void)
00060 {
00061 uint8_t low_fuse, prescaler;
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071 ENTER_CRITICAL_REGION();
00072 low_fuse = read_avr_fuse(0);
00073 LEAVE_CRITICAL_REGION();
00074
00075 if ((low_fuse & 0x0F) == 0x02)
00076 {
00077
00078 #if (F_CPU == 16000000)
00079 prescaler = 0x0F;
00080 #endif
00081 #if (F_CPU == 8000000)
00082 prescaler = clock_div_1;
00083 #endif
00084 #if (F_CPU == 4000000)
00085 prescaler = clock_div_2;
00086 #endif
00087 }
00088 else
00089 {
00090
00091 prescaler = clock_div_1;
00092 }
00093
00094 clock_prescale_set(prescaler);
00095 }
00096
00097 #endif
00098
00099