All pastes #2048853 Raw Edit

Someone

public text v1 · immutable
#2048853 ·published 2011-04-21 04:14 UTC
rendered paste body
#include "s3c2440.h"
#include "option.h"
#include "memcfg.h"

extern unsigned long _sidata;
extern unsigned long _sdata;
extern unsigned long _edata;
extern unsigned long _sbss;
extern unsigned long _ebss;
extern unsigned long _eheap;

static int handler_stack[64];
#define STACK_TOP ((void*)handler_stack + sizeof(handler_stack))

register void *stack_pointer asm("sp");
void _start(void) __attribute__((noreturn, naked));
void _start(void) {
	register unsigned long *src, *dst;
	
	WTCON = 0; // watch dog disable
	INTMSK = 0xFFFFFFFF; // all interrupt disable
	INTSUBMSK = 0x7FFF; // all sub interrupt disable
    
    GPBCON = 0x15400; // outputs on LED pins, GPB[8:5]
    GPBUP  = 0x7FF; // pullups disabled, GPB10..0
    GPBDAT = 0x1E0; // LEDs off
    
    GPHCON = 0x00AAA0; // RXD2, TXD2, RXD1, TXD1, RXD0, TXD0
    GPHUP  = 0x7FF; // pullups disabled, GPH10..0
    	
    // To reduce PLL lock time, adjust the LOCKTIME register
    LOCKTIME = 0xFFFFFF;
    	
    CLKDIVN = CLKDIV_VALUE(0, 2, 1); // udiv, hdiv, pdiv
// if hdiv != 0
#if 1
	asm(
		"mrc p15,0,r0,c1,c0,0\n"
		"orr r0,r0,#0xC0000000\n"
		"mcr p15,0,r0,c1,c0,0\n"
	);
#else
	asm(
		"mrc p15,0,r0,c1,c0,0\n"
		"bic r0,r0,#0xC0000000\n"
		"mcr p15,0,r0,c1,c0,0\n"
	);
#endif	

    UPLLCON = PLL_VALUE(56, 2, 2); // 48MHz output with 12MHz input
	asm("nop\nnop\nnop\nnop\nnop\nnop\nnop\n");
	MPLLCON = PLL_VALUE(M_MDIV, M_PDIV, M_SDIV);
	
	BWSCON = (0+(B1_BWSCON<<4)+(B2_BWSCON<<8)+(B3_BWSCON<<12)+(B4_BWSCON<<16)+(B5_BWSCON<<20)+(B6_BWSCON<<24)+(B7_BWSCON<<28));	

	BANKCON0 = ((B0_Tacs<<13)+(B0_Tcos<<11)+(B0_Tacc<<8)+(B0_Tcoh<<6)+(B0_Tah<<4)+(B0_Tacp<<2)+(B0_PMC));

	BANKCON1 = ((B1_Tacs<<13)+(B1_Tcos<<11)+(B1_Tacc<<8)+(B1_Tcoh<<6)+(B1_Tah<<4)+(B1_Tacp<<2)+(B1_PMC));

	BANKCON2 = ((B2_Tacs<<13)+(B2_Tcos<<11)+(B2_Tacc<<8)+(B2_Tcoh<<6)+(B2_Tah<<4)+(B2_Tacp<<2)+(B2_PMC));

	BANKCON3 = ((B3_Tacs<<13)+(B3_Tcos<<11)+(B3_Tacc<<8)+(B3_Tcoh<<6)+(B3_Tah<<4)+(B3_Tacp<<2)+(B3_PMC));

	BANKCON4 = ((B4_Tacs<<13)+(B4_Tcos<<11)+(B4_Tacc<<8)+(B4_Tcoh<<6)+(B4_Tah<<4)+(B4_Tacp<<2)+(B4_PMC));

	BANKCON5 = ((B5_Tacs<<13)+(B5_Tcos<<11)+(B5_Tacc<<8)+(B5_Tcoh<<6)+(B5_Tah<<4)+(B5_Tacp<<2)+(B5_PMC));

	BANKCON6 = ((B6_MT<<15)+(B6_Trcd<<2)+(B6_SCAN));

	BANKCON7 = ((B7_MT<<15)+(B7_Trcd<<2)+(B7_SCAN));
	REFRESH = ((REFEN<<23)+(TREFMD<<22)+(Trp<<20)+(Tsrc<<18)+(Tchr<<16)+REFCNT);
	BANKSIZE = 0x32;	    //SCLK power saving mode, BANKSIZE 128M/128M
	MRSRB6 = 0x30;	    //MRSR6 CL=3clk

	MRSRB7 = 0x30;	    //MRSR7 CL=3clk
	
	src = &_sidata;
	dst = &_sdata;
	if(src != dst)
		while(dst < &_edata)
			*(dst++) = *(src++);
	
	dst = &_sbss;
	while(dst < &_ebss)
		*(dst++) = 0;
	
	stack_pointer = STACK_TOP;
	handler_stack[0] = handler_stack[1] = 0xDEADBEEF;
	
	unsigned long *block_start = &_ebss;
	*block_start++ = 0xDEADBEEF;
	*block_start++ = 0xDEADBEEF;
	unsigned long block_size = &_eheap - block_start;
//	add_malloc_block(block_start, block_size);
	
	main();
}

void delay(unsigned long n) {
	volatile unsigned long x = n;
	
	while(x--)
		;
}

void Uart_Init(int pclk,int baud)

{

    int i;

//    if(pclk == 0)

//    pclk    = PCLK;

    UFCON0 = 0x0;   //UART channel 0 FIFO control register, FIFO disable

    UFCON1 = 0x0;   //UART channel 1 FIFO control register, FIFO disable

    UFCON2 = 0x0;   //UART channel 2 FIFO control register, FIFO disable

    UMCON0 = 0x0;   //UART chaneel 0 MODEM control register, AFC disable

    UMCON1 = 0x0;   //UART chaneel 1 MODEM control register, AFC disable

//UART0

    ULCON0 = 0x3;   //Line control register : Normal,No parity,1 stop,8 bits

     //    [10]       [9]     [8]        [7]        [6]      [5]         [4]           [3:2]        [1:0]

     // Clock Sel,  Tx Int,  Rx Int, Rx Time Out, Rx err, Loop-back, Send break,  Transmit Mode, Receive Mode

     //     0          1       0    ,     0          1        0           0     ,       01          01

     //   PCLK       Level    Pulse    Disable    Generate  Normal      Normal        Interrupt or Polling

    UCON0  = 0x245;   // Control register

    UBRDIV0=( (int)(pclk/8/baud +1) / 2 -1 );   //Baud rate divisior register 0

//UART1

    ULCON1 = 0x3;

    UCON1  = 0x245;

    UBRDIV1=( (int)(pclk/8/baud +1) / 2 -1 );

//UART2

    ULCON2 = 0x3;

    UCON2  = 0x245;

    UBRDIV2=( (int)(pclk/8/baud +1) / 2 -1 );    



    for(i=0;i<100;i++);

}

int main(void) {
	register unsigned int data;

    Uart_Init( 0,115200 );

	data = 0x66;


//    GPBCON = 0x015550; // 0000 0001 0101 0101 0101 0000
    GPBCON = 0x15400; // 0001 0101 0100 0000 0000
    GPBUP  = 0x7ff;     // The pull up function is disabled GPB[10:0]

// nLED1 GPB5
// nLED2 GPB6
// nLED3 GPB7
// nLED4 GPB8

	data = 0;
	
		char *mode;

	int i;

	unsigned char key;

	unsigned long mpll_val = 0 ;

	//U32 divn_upll = 0 ;

    

	#if ADS10   

//	__rt_lib_init(); //for ADS 1.0

	#endif





//	Port_Init();

	

//	Isr_Init();

	



	//400

	key = 14;

	mpll_val = (92<<12)|(1<<4)|(1);

	

	//init FCLK=400M, so change MPLL first

//	ChangeMPllValue((mpll_val>>12)&0xff, (mpll_val>>4)&0x3f, mpll_val&3);

//	ChangeClockDivider(key, 12);

//	cal_cpu_bus_clk();

x:
//	GPBDAT = (GPBDAT & ~(0xf<<5)) | ((~data & 0xf)<<5);
	GPBDAT = 0x1E0;
	GPBDAT = 0x0;
y:
	GPBDAT = ((data++)<<5) & 0x1E0;
	delay(4000);
	goto y;
	goto x;
}

void _exit(int x) {
for(;;);
}