00001
00038 #ifndef CHIP_CLK_H_INCLUDED
00039 #define CHIP_CLK_H_INCLUDED
00040
00041 #include <chip/regs.h>
00042
00046 static inline void clk_enable_at90usb(void)
00047 {
00048 avr_write_reg8(PLLCSR, AVR_BIT(PLLCSR_PLLP1)
00049 #if CONFIG_CPU_HZ == 8000000UL
00050 | AVR_BIT(PLLCSR_PLLP0)
00051 #elif CONFIG_CPU_HZ == 16000000UL
00052 | AVR_BIT(PLLCSR_PLLP2)
00053 #else
00054 # error Chip CPU frequency must be 8 MHz or 16 MHz when using the USB peripheral
00055 #endif
00056 | AVR_BIT(PLLCSR_PLLE));
00057 do {
00058 barrier();
00059 } while (!(avr_read_reg8(PLLCSR) & AVR_BIT(PLLCSR_PLOCK)));
00060 }
00061
00062 #endif