/* System Config */

#ifndef _CONFIG
#define _CONFIG

#define FOSC		12000000
#define PSEL0		5
#define PSEL1		6

//#define CCLK	60000000
#define CCLK	24000000

#if CCLK==60000000
/* 
	PLL
	
	- Main clock F_OSC=12MHz [limits: 10 MHz to 25 MHz]
	- System should run at max. Frequency (60MHz) [limit: max 60 MHz]
	- Choose multiplier M=5 
	 so cclk = M * F_OSC= 5 * 12000000Hz = 60000000Hz
	- MSEL-Bits in PLLCFG (bits 0-4) MSEL = M-1
	- F_CCO must be inbetween the limits 156 MHz to 320 MHz
	 datasheet: F_CCO = F_OSC * M * 2 * P
	- choose devider P=2 => F_CCO = 12000000Hz * 5 * 2 * 2
	 = 240000000 =240 MHz
	- PSEL1 (Bit6) = 0, PSEL0 (Bit5 in PLLCFG) = 1 (0b01)
*/

#define PLL_M		5	
#define MSEL		(PLL_M-1)
#define PSEL0val	1
#define PSEL1val	0

#elif CCLK==24000000
/* 
	PLL
	
	- Main clock F_OSC=12MHz [limits: 10 MHz to 25 MHz]
	- System should run at Frequency (24MHz) [limit: max 60 MHz]
	- Choose multiplier M=2 
	 so cclk = M * F_OSC= 2 * 12000000Hz = 24000000Hz
	- MSEL-Bits in PLLCFG (bits 0-4) MSEL = M-1
	- F_CCO must be inbetween the limits 156 MHz to 320 MHz
	 datasheet: F_CCO = F_OSC * M * 2 * P
	- choose devider P=4 => F_CCO = 12000000Hz * 2 * 2 * 4
	 = 192000000 =192 MHz
	- PSEL1 (Bit6) = 1, PSEL0 (Bit5 in PLLCFG) = 0 (0b01)
*/

#define PLL_M		2	
#define MSEL		(PLL_M-1)
#define PSEL0val	0
#define PSEL1val	1

#else
#error "Undefined CCLK value in convig.h"
#endif

#define PLLE		0
#define PLLC		1

#define PLOCK		10

#define PLL_FEED1	0xAA
#define PLL_FEED2	0x55


/*
	MAM(Memory Accelerator Module)
	- choosen: MAM fully enabled = MAM-Mode 2
	- System-Clock cclk=59MHz -> 3 CCLKs are proposed as fetch timing
*/
#define MAM_MODE 	2
#define MAM_FETCH   3

/*
	VPB (V... Pheriphal Bus)
	- choosen: VPB should run at full speed -> devider VPBDIV=1
	=> pclk = cclk = 60MHz
*/
#define VPBDIV_VAL	1
#define PCLK		(CCLK/VPBDIV_VAL)
/*
	SCB
*/
#define MEMMAP_BOOT_LOADER_MODE   0       // Interrupt vectors are re-mapped to Boot Block.
#define MEMMAP_USER_FLASH_MODE    (1<<0)  // Interrupt vectors are not re-mapped and reside in Flash.
#define MEMMAP_USER_RAM_MODE      (1<<1)  // Interrupt vectors are re-mapped to Static RAM.

#endif
