#include #include #define USED __attribute__((used)) #define USED_NAKED __attribute__((used,naked)) #define USED_INT(type) __attribute__((used,interrupt(#type))) #if MCK > 30000000 #define FLASH_CYCLES AT91C_MC_FWS_1FWS #else #define FLASH_CYCLES AT91C_MC_FWS_0FWS #endif #ifndef MAIN_OSC_FREQ #define MAIN_OSC_FREQ 18432000 #endif #if MAIN_OSC_FREQ != 18432000 #error Unsupported main oscilator frequency #endif #if MCK == 23961600 #define PLL_DIV 5 #define PLL_MUL 26 #define PLL_USBDIV_EXP 1 #define MCK_DIV_EXP 2 #elif MCK == 47923200 #define PLL_DIV 5 #define PLL_MUL 26 #define PLL_USBDIV_EXP 1 #define MCK_DIV_EXP 1 #else #error "Unsupported main clock frequency" #endif #define PLL_FREQ ((MAIN_OSC_FREQ * PLL_MUL) / PLL_DIV) #if PLL_FREQ > 180000000 #error "PLL frequency too high" #elif PLL_FREQ < 80000000 #error "PLL frequency too low" #endif #if PLL_FREQ > 155000000 #define PLL_RANGE AT91C_CKGR_OUT_2 #else #define PLL_RANGE AT91C_CKGR_OUT_0 #endif #if PLL_USBDIV > 2 #error "PLL frequency too high for USB" #endif #define USB_FREQ (PLL_FREQ / (1< 48120000 || USB_FREQ < 47880000 #warning "USB frequency outside limits" #endif #if MCK * (1<