Пример #1
0
void Camera_Test(void)
{
	int i;
	
	SetSysFclk(FCLK_220M);  //设置系统时钟 220M     
	ChangeClockDivider(1, 1);      //设置分频 1:2:4
	CalcBusClk();           //计算总线频

	Uart_Select(0);
    Uart_Init(0, 115200);
	
	Uart_Printf("\nCamera Preview Test\n");

	CamReset();

	// Initializing camif
	rCLKCON |= (1<<19); // enable camclk
	CamPortSet();	
	ChangeUPllValue(56, 2, 1);		// UPLL clock = 96MHz, PLL input 12MHz
	rCLKDIVN|=(1<<3); // UCLK 48MHz setting for UPLL 96MHz
	// 0:48MHz, 1:24MHz, 2:16MHz, 3:12MHz...
	// Camera clock = UPLL/[(CAMCLK_DIV+1)X2]

	SetCAMClockDivider(CAMCLK24000000); //Set Camera Clock 24MHz s5x532, OV9650

	i = Test_OV9650();
	if( i )
	{
		Uart_Printf("\nTest is failed!!!\n");
		return ;
	}

	Uart_Printf("Initializing end...\n");
	
	Test_CamPreview() ;
	
	Uart_Printf("\nCamera Preview Test End\n");

	rCLKCON &= ~(1<<19); // disable camclk
	
	TFT_Init();
	
	SetSysFclk(FCLK_400M);  //设置系统时钟 400M     
	ChangeClockDivider(2, 1);      //设置分频 1:4:8
	CalcBusClk();           //计算总线频

	Uart_Select(0);
    Uart_Init(0, 115200);
	
}
Пример #2
0
//
//  Function:       _InitModem
//
//  Description:    Initialization of Radio Modem
//
//  Return Values:
//
//  Name        Explanation
//  ----------- -------------------------------------------------------------------
//  RetStatus    Error code
//
int _InitModem( t_boolean FirstTime )
{
  int       RetStatus     = RM_SUCCESS;
  time_t      ltime;

  HeapBuffDef *pHeap      = Data_GetHeapPtr();
  pHeap->DataLength      = 0;           //Initialization of Main Heap Buffer

  RM_InitPrint( "ErrorRM.txt" ); //I need to put here fileName of error log file

  time( &ltime );
  PrintLogMessage( "[I] Initialization started at: ", ctime( &ltime ), 0 );

  //Initialization of internal memory manager
  if ( (RetStatus = Mem_Init( FirstTime )) != RM_SUCCESS )
    PrintError( "[E] InitModem ( Memory Error )", "RetStatus:", RetStatus ); 

  //Initialization of internal queues
  QueueInit(FirstTime); 

#ifdef RM_STANDALONE
  Uart_Init();
#endif

  if ( (RetStatus = VRM_Init(UNCONFIRMED)) == RM_SUCCESS )
    PrintError( "InitModem: COMPLETED", "", 0 ); 
  else
  {
    PrintError( "InitModem: FATAL ERROR", "Power cycle your modem. RetStatus:", RetStatus ); 
  }//end else

  return( RetStatus );
}//RM_InitModem
Пример #3
0
int main(void ){
	Uart_Init();
	CoreScheduler_Init();
	CoreScheduler_RegisterJob(jobIndex[0], Function0);
	CoreScheduler_RegisterJob(jobIndex[1], Function1);
	CoreScheduler_RegisterJob(jobIndex[2], Function2);
	CoreScheduler_RegisterJob(jobIndex[3], Function3);
	CoreScheduler_RegisterJob(jobIndex[4], Function4);
	CoreScheduler_RegisterJob(jobIndex[5], Function5);
	CoreScheduler_RegisterJob(jobIndex[6], Function6);
	CoreScheduler_RegisterJob(jobIndex[7], Function7);
	CoreScheduler_RegisterJob(jobIndex[8], Function8);
	CoreScheduler_RegisterJob(jobIndex[9], Function9);
	
#if defined(CoreScheduler_EnableCheckRetrig)
	//Data_1Byte i;
	//for(i = 0; i < 10; i++) CoreScheduler_AllowRetrigger(jobIndex[i], (i % 2 == 0)?TRUE:FALSE);
#endif
	
	Uart_Uart1RXCompleteInterruptFunction = CommandIn;
	CoreMemory_Init();
	if(CoreMemory_MemorySpaceVerify()){
		Uart_Transmit(Uart_Uart1DeviceIdentify,  0xB8);
	}
	else{
		Uart_Transmit(Uart_Uart1DeviceIdentify,  0xC7);
	}
	CoreTimer_Init();
	CoreTimer_EnableBaseTimer(TRUE);
	CoreScheduler_RunLoop();
	while(1);
	return 0;
}
Пример #4
0
interrupt(PORT1_VECTOR) Buttopn(void)
{
	P1IFG &= ~0x04;
	P1OUT ^=  0x03;
	//after press the button , we can send and recieve message 
	BSP_Init();
	MRFI_Init();
	MRFI_SetLogicalChannel(1);
	MRFI_SetRFPwr(0);

	Uart_Init();

	MRFI_WakeUp();
	MRFI_RxOn(); 

	Scan_Init(&etat);			//open timer B for scan
	Start_Timer_Surveille();		//open timer for surveille

	print("\n\r");
	print("command: \n\r");
	print("o  : who is on line \n\r");
	print("v  : voisin \n\r");
	print("r  : router table \n\r");
	print("i  : sysinfo \n\r");
	print("ESC: help \n\r");
}
Пример #5
0
Файл: main.c Проект: huig-/SED
/*--- codigo de la funcion ---*/
int Main(void){

	char *pt_str = str;
	leds_off();
	sys_init(); // inicializacion de la placa, interrupciones, puertos
	Eint4567_init();
	keyboard_init();
	Uart_Init(115200); // inicializacion de la Uart
	Uart_Config(); // configuración de interrupciones y buffers

	while(1){
		*pt_str = Uart_Getch1(); // leer caracter
		if(pt_str[0] == 'L'){
			led1_on();
			led2_off();
		} else if (pt_str[0] == 'R'){
			led2_on();
			led1_off();
		}

		else  {
			D8Led_symbol(pt_str[0]-'0');
		}
	}
}
Пример #6
0
int main(void)
{
    _U08 u8Config;

    ANCON0 = 0XFF;  /*Desactivamos las entradas analógicas*/
    ANCON1 = 0XFF;  /*Desactivamos las entradas analógicas*/

    Gpios_PinDirection(GPIOS_PORTD, 0, GPIOS_INPUT);  /*SCL2*/
    Gpios_PinDirection(GPIOS_PORTD, 1, GPIOS_INPUT);  /*SDA2*/
    Gpios_PinDirection(GPIOS_PORTC, 6, GPIOS_OUTPUT); /*puerto de tx uart como salida*/

    (void)Uart_Init(UART_PORT1, 115200);   /*velocidad a 115200 bauds*/
    xdev_out(putChar);                     /*funcion Uart_PutChar como salida estandar*/

    I2c_Init(I2C_PORT2, 100000);           /*puerto I2C 2 a 100KHz de velocidad*/

    I2c_Start(I2C_PORT2);                                   /*generamos condicion start*/
    (void)I2c_bTxByte(I2C_PORT2, ADDR_WRITE(0b1001101));    /*madamos direccion del sensor en modo escritura*/
    (void)I2c_bTxByte(I2C_PORT2, 0x01);                     /*mandamos direccion a leer*/
    I2c_RepeatedStart(I2C_PORT2);                           /*repetimos señal start*/
    (void)I2c_bTxByte(I2C_PORT2, ADDR_READ(0b1001101));     /*madmaos direccion del sensor en modo lectura*/
    u8Config = I2c_u8RxByte(I2C_PORT2, I2C_NACK);           /*leemos dato leido y contestamos NACK*/
    I2c_Stop(I2C_PORT2);                                    /*indicamos fin de comunicacion*/

    /*mostramos por serial el byte leido el cual tendra el valor de 0x40, indica sensor listo*/
    xprintf("Registro config: 0x%X\r\n", (_U16)u8Config);

    while (1)
    {
        /*Escribe aqui tu aplicacion*/
    }
}
Пример #7
0
//------------------------------------------------------------------------------
//     					===== main_init =====  					
//------------------------------------------------------------------------------
void main_init(void)
{
	cbi(SREG,7);				//all interrupt disable

	//ADC
	ADMUX = 0x40;							//ADC 초기화
	ADCSRA = 0x87;							//ADC Enable, 분주비=128
	cbi(DDRF,0);							//ADC1 핀 입력으로 설정
	sbi(SREG,7);							//모든 인터럽트 활성화

	//USART 
	Uart_Init(0,9600);			// uart enable
 	Uart_Init(1,9600);
	
	sbi(SREG,7);
	
}
Пример #8
0
void Init_Fun(void)
{
	UART_SEND;
	Flash_IO_Init();
	Delay_Init();
	Uart_Init();
	ADC_Init_Fun();	
	EEPROM_IO_Init();	
	Key_IO_Init();
	Cartridge_Type_Check();
	UART_RECEIVE;
  Flash_Times = Read_Num_From_EEPROM();
  if(Flash_Times >= Flash_Times_Level8)
	{
		Flash_Times_Level = Flash_Times_Level_9;
		Low_Lamp = 1;
	}else{
		Low_Lamp = 0;
		if(Flash_Times >= Flash_Times_Level7)
		{
			Flash_Times_Level = Flash_Times_Level_8;
		}else{
			if(Flash_Times >= Flash_Times_Level6)
			{
				Flash_Times_Level = Flash_Times_Level_7;
			}else{
				if(Flash_Times >= Flash_Times_Level5)
				{
					Flash_Times_Level = Flash_Times_Level_6;
				}else{
					if(Flash_Times >= Flash_Times_Level4)
					{
						Flash_Times_Level = Flash_Times_Level_5;
					}else{
						if(Flash_Times >= Flash_Times_Level3)
						{
							Flash_Times_Level = Flash_Times_Level_4;
						}else{
							if(Flash_Times >= Flash_Times_Level2)
							{
								Flash_Times_Level = Flash_Times_Level_3;
							}else{
								if(Flash_Times >= Flash_Times_Level1)
								{
									Flash_Times_Level = Flash_Times_Level_2;
								}else{
									Flash_Times_Level = Flash_Times_Level_1;
								}
							}
						}
					}
				}
			}
		}
	}		
}
Пример #9
0
static void init_system_component() {  
    // timer
    init_system_tick();

    // ble
    Uart_Init();

    // DRIVER_IO
    driver_io_init();
}
Пример #10
0
int main(void)
{
    Gpios_PinDirection(GPIOS_PORTD, 1, GPIOS_OUTPUT); /*pin de tx como salida*/
    (void)Uart_Init(UART_PORT0, 57600); /*se iniclaiza el puerto serial a 115200 baudios*/
    
    while (1)
    {
        Uart_PutString(UART_PORT0, (const _U08*)"Hola mundo\n\r");   /*se manda mensaje por puerto serial*/
        Delays_ms(1000);                    /*se cicla por 1 seg*/
    }
}
Пример #11
0
void TargetInit(void)
{
	int i;
	U8 key;
	U32 mpll_val=0;
	#if ADS10   
	__rt_lib_init(0,0); //for ADS 1.0
 
	#endif
    
	i = 2 ;	//use 400M!
		
	switch ( i ) {
	case 0:	//200
		key = 12;
		mpll_val = (92<<12)|(4<<4)|(1);
		break;
	case 1:	//300
		key = 14;
		mpll_val = (67<<12)|(1<<4)|(1);
		break;
	case 2:	//400
		key = 14;
		mpll_val = (92<<12)|(1<<4)|(1);
		break;
	case 3:	//440!!!
		key = 14;
		mpll_val = (102<<12)|(1<<4)|(1);
		break;
	default:
		key = 14;
		mpll_val = (92<<12)|(1<<4)|(1);
		break;
	}
	
	//init FCLK=400M
	ChangeClockDivider(key, 12);    
	ChangeMPllValue((mpll_val>>12)&0xff, (mpll_val>>4)&0x3f, mpll_val&3);

	//MMU_EnableICache();
	//MMU_EnableDCache();
    
	MMU_DisableICache();
	MMU_DisableDCache();
 	Port_Init();
	MMU_Init();

	Delay(0);
	Uart_Init(0,115200);
	Uart_Select(0);
	Uart_SendString("Board init complete.\n");
}
Пример #12
0
void Main(void)
{
	//硬件初始化
	var_Init();//初始化定时器相关的参数
	Port_Init();//IO端口初始化
	Isr_Init();//中断初始化
	Uart_Init(0,115200);//串口初始化
	Uart_Select(0);
	_init_alloc(0x32500000,0x333fffff);//初始化堆地址:15M,使能malloc等存储分配函数
	setlocale(LC_ALL,"C");//使能本地函数,如sprintf等
	Timer4_Init();
	lcdTest();
}	
Пример #13
0
void Main(void)
{
    Port_Init();		//IO端口初始化
	Isr_Init();			//中断初始化

    Uart_Init(0,115200);//串口初始化
    Uart_Select(0);

    Uart_Printf("\n\nDM2410 Experiment System (ADS) Ver1.10\n") ;//打印系统信息
    
    Test_SDI();
    
}
Пример #14
0
void Main(void)
{
	memcpy((unsigned char *)0x0,(unsigned char *)0x30000000,0x1000);
	
	SetSysFclk(FCLK_400M);  //设置系统时钟 400M     
	ChangeClockDivider(2, 1);      //设置分频 1:4:8
	CalcBusClk();           //计算总线频
	
	Uart_Select(0);
	Uart_Init(0, 115200);
	
	Test_Nand();
	while(1);
}
Пример #15
0
void sys_init()// Interrupt,Port and UART
{
    /* enable interrupt */
	rINTMOD=0x0;
	rINTCON=0x1;
    rI_ISPC = 0xffffffff;			/* clear all interrupt pend	*/
	rEXTINTPND = 0xf;				// clear EXTINTPND reg
	Port_Init();					/* Initial 44B0X's I/O port */	

    LED8ADDR = 0 ;
    Led_Display(0xf);
	Delay(0);						/* delay time				*/
	Uart_Init(0,115200);			/* Initial Serial port 1	*/
}
Пример #16
0
void TargetInit(void)
{
	int i;
	U8 key;
	U32 mpll_val=0;

    
	i = 2 ;	//use 400M!
		
	switch ( i ) {
	case 0:	//200
		key = 12;
		mpll_val = (92<<12)|(4<<4)|(1);
		break;
	case 1:	//300
		key = 14;
		mpll_val = (67<<12)|(1<<4)|(1);
		break;
	case 2:	//400
		key = 14;
		mpll_val = (92<<12)|(1<<4)|(1);
		break;
	case 3:	//440!!!
		key = 14;
		mpll_val = (102<<12)|(1<<4)|(1);
		break;
	default:
		key = 14;
		mpll_val = (92<<12)|(1<<4)|(1);
		break;
	}
	
	//init FCLK=400M, so change MPLL first
	ChangeMPllValue((mpll_val>>12)&0xff, (mpll_val>>4)&0x3f, mpll_val&3);
	ChangeClockDivider(key, 12);    

    
	MMU_DisableICache();
	MMU_DisableDCache();
 	Port_Init();
	MMU_Init();
	_init_alloc(0x17fe000, 0x17ff000);/*分配堆的起始地址和结束地址,4k的空间*/
	Delay(0);
	Uart_Init(0,115200);
	Uart_Select(0);
	Uart_SendString("Board init complete.\n");
}
Пример #17
0
void sys_init()// Interrupt,Port and UART
{
	Port_Init();					/* Initial 44B0X's I/O port */	
    /* enable interrupt */
	rINTMOD=0x0;
	rINTCON=0x1;
	
	rEXTINT = 0x22222222;                  // level mode
    rI_ISPC = 0xffffffff;			/* clear all interrupt pend	*/
	rEXTINTPND = 0xf;				// clear EXTINTPND reg
	
    LED8ADDR = 0 ;
    Delay(0);
    Led_Display(0xf);
	Uart_Init(0,115200);			/* Initial Serial port 1	*/

}
Пример #18
0
int main(){
	int muxpin[4] = {19,18,17,16};

	Uart_Init(57600);
	Uart_Print("Uart Inited\n\r");

	SPI_InitMaster(16);
	Mux_Init(&MBMux,20,muxpin);
	Encoder_Init(&MBMux);
	Uart_Print("SPI Encoder Inited\n\r");

	Joystick_Init();
	GPIO_Init(31,OUTPUT);

	Timer_Init(0,100,Timer_Rountine);
	return 0;
}
Пример #19
0
int main()
{
  SystemCoreClockUpdate();
  
  Uart_Init();
  Logging_Init();
  MCP9808_Init();

  Uart_Setup(9600);
 
  while(1)
  {
    Uart_Idle();
    Logging_Idle();
    MCP9808_Idle();
  }
}
Пример #20
0
/********************************************************************
// 语法格式	: void Main(void)
// 功能描述 : DMA操作实验主程序
//            实现功能:
//                实现DMA方式内存到内存的拷贝动作,修改DMA设置
//                并比较其工作效率,实验包括:DMA0-DMA3
// 入口参数		: 无
// 出口参数     : 无
*********************************************************************/
void Main(void)
{
	memcpy((U8 *)0x0,(U8 *)0x30000000,0x1000);
	
	SetSysFclk(FCLK_400M);  			//设置系统时钟 400M
    ChangeClockDivider(2,1);      		//设置分频 1:4:8
	CalcBusClk();           //计算总线频

	Uart_Select(0); 
    Uart_Init(0,115200);
    
	Uart_Printf("\n---DMA操作实验主程序---\n");
	
    Test_DMA();
    
    Uart_Printf("\nDMA测试结束\n");
	while(1);
}
Пример #21
0
int main(void)
{
    ANCON0 = 0XFF;  /*Desactivamos las entradas analogicas*/
    ANCON1 = 0XFF;  /*Desactivamos las entradas analogicas*/

    Gpios_PinDirection(GPIOS_PORTC, 6, GPIOS_OUTPUT); /*pin de tx como salida*/
    Gpios_PinDirection(GPIOS_PORTC, 7, GPIOS_INPUT); /*pin de rx como entrada*/
    (void)Uart_Init(UART_PORT1, 9600);   /*se iniclaiza el puerto serial a 9600 baudios*/
    __ENABLE_INTERRUPTS();               /*habilitamos interrupciones globales*/

    while (1)
    {
        if(gbFlag == 1) /*llego un caracter por teclado*/
        {
            gbFlag = 0; /*limpiamos la bandera*/
            Uart_PutChar(UART_PORT1, gu8RxData);/*lo enviamos de regreso para tener feedback visual*/
        }
    }
}
Пример #22
0
 char Uart()
{
	char id[20]={};
 	char nz[]={0x37,0x34,0x39};
	char sj;
 
 	char x,xx;
 	char y=0;
 	int data;
 	Uart_Init(0,9600);
 	Uart_Select(1);
	bz=0;
	 	
	if(rUTRSTAT1 & 0x1)
	{
		for(y=0;y<8;y++)
 		{
	 		sj=Uart_Getch();
	 		id[y]=sj;
	 	}
	}
	 
	if(id[2]==nz[1])
	{
	 	
	 	bz=1;
	}
	else
	 	bz=0;
	 	
 	if(id[0]!=0)
 	{
 		x = id[1];
 		xx=id[2];
 	 	
 	}

 	

 	return bz;	

}
Пример #23
0
//====================================================
// 语法格式:void Main(void)
// 功能描述: 主函数
// 入口参数: 无
// 出口参数: 无
//====================================================
void Main(void)
{
	memcpy((unsigned char *)0x0,(unsigned char *)0x30000000,0x1000);
    
	SetSysFclk(FCLK_400M);  //设置系统时钟 400M     
	ChangeClockDivider(2, 1);      //设置分频 1:4:8
	CalcBusClk();           //计算总线频
	
	Uart_Select(0);    
	Uart_Init(0, 115200);   //设置端口 波特率115200  无数据流检测   数据位= 8位
	
	Select_Device(IrDA);
	IrDA_Port_Set();
		
	Uart_Printf("\2440 IrDA Test start\n");   
    
    while(1)
    {
		Test_IrDA_Tx();
	}
 }
Пример #24
0
int main(void)
{
    _S08 i8Temp;

    ANCON0 = 0XFF;  /*Desativamos las entradas analógicas*/
    ANCON1 = 0XFF;  /*Desativamos las entradas analógicas*/

    Gpios_PinDirection(GPIOS_PORTD, 0, GPIOS_INPUT);  /*SCL2*/
    Gpios_PinDirection(GPIOS_PORTD, 1, GPIOS_INPUT);  /*SDA2*/
    Gpios_PinDirection(GPIOS_PORTC, 6, GPIOS_OUTPUT); /*puerto de tx uart como salida*/

    (void)Uart_Init(UART_PORT1, 115200);   /*velocidad a 115200 bauds*/
    xdev_out(putChar);                     /*funcion Uart_PutChar como salida estandar*/

    I2c_Init(I2C_PORT2, 100000);           /*puerto I2C 2 a 100KHz de velocidad*/

    while (1)
    {
        i8Temp = Tc74ax_ReadTemp(TC74A5);
        /*mostramos por serial el byte leido el cual tendra el valor de la temp ambiental*/
        xprintf("Temperatura ambiente: %d\r", (_S16)i8Temp);
        Delays_ms(1000);
    }
}
Пример #25
0
void Dvs_Test(void)
{
	volatile int i, n;

	Uart_Printf("Dvs test.\n");

	rGPGCON = (rGPGCON & ~(3<<22)) | (1<<22);	// set GPG11 output for idle state.
	
	rBANKSIZE = (rBANKSIZE & ~(3<<4)) | (0<<4) | (1<<7);	//SCKE_EN, SCLK_EN = disable.

	Uart_Printf("Change core speed to 266MHz.\n");
	#if FIN==12000000
	ChangeClockDivider(13, 12);	// 1:3:6
		#if CPU2440A==1
		ChangeMPllValue(127,2,1);	// 406MHz
		#else						// 2440X
		ChangeMPllValue(127,2,0);	// 406MHz
		#endif
	#else	// 16.9344Mhz
		ChangeClockDivider(13, 12);
		#if CPU2440A==1
		ChangeMPllValue(110,3,1);	// 400MHz
		#else						// 2440X
		ChangeMPllValue(110,3,0);	// 400MHz
		#endif
	#endif
	
	Calc_Clock(1);
	
	UPDATE_REFRESH(Hclk);
	Uart_Init(Pclk, 115200);

	Uart_Printf("Check Clkout0:FCLK, Clkout1:HCLK.\n");
	// Clkout0: FCLK.	
	Clk0_Enable(2);
	// Clkout1: HCLK.
	Clk1_Enable(3);
	
	
#if ADS10==TRUE	
	srand(0);
#endif
	Led_Display(0);	// clear all leds.
	
	Timer_Setting();
	Set_Lcd_Tft_16Bit_240320_Dvs();

	Uart_Printf("Tcnt, Vcnt, Idle_flag.\n");
	Uart_Printf("%8d,%8d,%1d\n", Timer_cnt0, Vcount, Idle_flag);
	
	while(1) {
		//Uart_Printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");
		Uart_Printf("%8d,%8d,%1d\n", Timer_cnt0, Vcount, Idle_flag);
		for(i=0; i<1024*32; i+=4) {
			//*(U32 *)(XADDR+i) = i;
			//*(U32 *)(XADDR+i);
		}
		if(Uart_GetKey()==ESC_KEY) break;
	}

	rINTMSK = BIT_ALLMSK;
}
Пример #26
0
/**
 *  main - main application loop. Sets up platform and then performs simple
 *  transfers (simplex) while incrementing the sequence number for the lifetime 
 *  of execution.
 *
 *    @return   Exit code of the main application, however, this application
 *              should never exit.
 */
int main(void)
{
  RCC_ClocksTypeDef RCC_ClockFreq;
  RCC_GetClocksFreq(&RCC_ClockFreq);
  
  if (SysTick_Config(RCC_ClockFreq.HCLK_Frequency/1000))
  { 
    /* Capture error */ 
    while (1);
  }
  
  Il_Hw_Init(); 
  
  Init_SI4463_Pin();
  
  vRadio_Init(); 
  
  ClkSwitch2HseSystemInit();

  RCC_GetClocksFreq(&RCC_ClockFreq);
  
  if (SysTick_Config(RCC_ClockFreq.HCLK_Frequency/1000))
  { 
    /* Capture error */ 
    while (1);
  }
  
  Il_Hw_Init(); 
  
  Uart_Init();
    
  Init_SI4463_Pin();
  
//TimingBaseInit(50000);
  
//  while(1)
//  {
////  //LedD4StaInvert();  
////    GPIOB->BSRR  = 0x00000040;
////    GPIOB->BRR  = 0x00000040;
//  }
  
  //EXTILine_TimingSync_Config();
  
  //si446x_get_int_status(0u, 0u, 0u);
  uint8_t testBuff[6]={0x05,0xD0,0x01,0x02,0x03,0xD6};
  
  //UartSendByte(testBuff, 6); 
  
  vRadio_StartRX(pRadioConfiguration->Radio_ChannelNumber);
  
  RadioGotoRxSta();
  
  SI4463_Enable_NIRQ_Int();

  if (!ProtocolInit(&gProtocolSetupInfo))
  {
    return false;
  }
  
  while(true)
  {
    if(GetPubRxBufCount()>0x00)
    {
      //UartSendByte(timMark, 1);
      //UartSendByte(uartRxDataBuff, uartRxCount);
      //uartDataProcess();
      PubRxDataProcess();
    }  
    
    if(GetPubTxBufCount()>0x00)
    {
      PubTxDataProcess();
    }  
    
    if (!ProtocolBusy())
    {
      // Increment the sequence number for the next transmission.
      gPacket.seqNum++;
    }
  }
  
//  while (true)
//  {
//    // Perform a simple transfer of the packet.
//    if (!ProtocolSimpleTransfer((unsigned char*)&gPacket, sizeof(struct sPacket)))
//    {
//      // Put the microcontroller into a low power state (sleep). Remain here
//      // until the ISR wakes up the processor.
//      //McuSleep();
//    }
//    
//    /**
//     *  Check if the protocol is busy. If it is, a new transfer cannot occur
//     *  until it becomes ready for the next instruction. Do not increment the
//     *  sequence number until the protocol is ready. This prevents incrementing
//     *  the sequence number more than once between transmissions.
//     */
//    if (!ProtocolBusy())
//    {
//      // Increment the sequence number for the next transmission.
//      gPacket.seqNum++;
//    }
//  }
}
Пример #27
0
void TargetInit(void)
{
    int i;
	U8 key;
	U32 mpll_val=0;
    #if ADS10   
   //_rt_lib_init(0,0); //for ADS 1.0
 
    #endif
    
	i = 2 ;	//use 400M!
		
	switch ( i ) {
	case 0:	//200
		key = 12;
		mpll_val = (92<<12)|(4<<4)|(1);
		break;
	case 1:	//300
		key = 14;
		mpll_val = (67<<12)|(1<<4)|(1);
		break;
	case 2:	//400
		key = 14;
		mpll_val = (92<<12)|(1<<4)|(1);
		break;
	case 3:	//440!!!
		key = 14;
		mpll_val = (102<<12)|(1<<4)|(1);
		break;
	default:
		key = 14;
		mpll_val = (92<<12)|(1<<4)|(1);
		break;
	}
	
	//init FCLK=400M, so change MPLL first
	ChangeMPllValue((mpll_val>>12)&0xff, (mpll_val>>4)&0x3f, mpll_val&3);
	ChangeClockDivider(key, 12);    

    //MMU_EnableICache();
    //MMU_EnableDCache();
    
    MMU_DisableICache();
    MMU_DisableDCache();
  	Port_Init();
    MMU_Init();
	Touch_init();
    Delay(0);
    Uart_Init(0,115200);
    Uart_Select(1);
    //Uart_SendString("hello,FriendlyARM\n");
    /*若使用printf语句,将使目标代码增加很多*/
    // Uart_Printf("hello,qq2440, printf\n");

    
   rGPBCON = 0x00555555;
   rGPBDAT = 0x0000;
//   rGPBDAT = 0x07ff;
	rGPFDAT = 0x00;
	rGPFDAT = 0x00;
 //  Delay(0);
 	
 }
Пример #28
0
/**
 *  main - main application loop. Sets up platform and then goes to sleep for
 *  the lifetime of execution.
 *
 *    @return   Exit code of the main application, however, this application
 *              should never exit.
 */
int main(void)
{
  RCC_ClocksTypeDef RCC_ClockFreq;
  RCC_GetClocksFreq(&RCC_ClockFreq);
  
  if (SysTick_Config(RCC_ClockFreq.HCLK_Frequency/1000))
  { 
    /* Capture error */ 
    while (1);
  }
  
  Il_Hw_Init(); 
  
  Init_SI4463_Pin();
  
  vRadio_Init(); 
  
  ClkSwitch2HseSystemInit();

  RCC_GetClocksFreq(&RCC_ClockFreq);
  
  if (SysTick_Config(RCC_ClockFreq.HCLK_Frequency/1000))
  { 
    /* Capture error */ 
    while (1);
  }
  
  Il_Hw_Init(); 
  
  Uart_Init();
    
  Init_SI4463_Pin();
  
//TimingBaseInit(50000);
  
//  while(1)
//  {
////  //LedD4StaInvert();  
////    GPIOB->BSRR  = 0x00000040;
////    GPIOB->BRR  = 0x00000040;
//  }
  
  //EXTILine_TimingSync_Config();
  
  //si446x_get_int_status(0u, 0u, 0u);
  uint8_t testBuff[6]={0x05,0xD0,0x01,0x02,0x03,0xD6};
  
  //UartSendByte(testBuff, 6); 
  
  vRadio_StartRX(pRadioConfiguration->Radio_ChannelNumber);
  
  RadioGotoRxSta();
  
  SI4463_Enable_NIRQ_Int();

  if (!ProtocolInit(&gProtocolSetupInfo))
  {
    return false;
  }
  
  while(1)
  {
    if(GetPubTxBufCount()>0x00)
    {
      PubTxDataProcess();
    }  
  }  
}
Пример #29
0
/*------------------------------------------------------------------------------

 FUNCTION NAME: Main_Init

 DESCRIPTION: Main init function

 PARAMETERS:
   - INPUT:
   - OUTPUT:

 RETURN:

 NOTES: Don't try to change the order of the function calls!

------------------------------------------------------------------------------*/
void Main_Init (void)
{
t_uchar    Lines[2] = {9,END_OF_LINES};
char    Msg[40];
#ifdef PC_TERMINAL
int     RetVal;
t_uchar    PrinterIndex, NumPrinters, Type, Port, Model;
t_boolean InvertScreen;
int     LCDContrastOffset;
#endif

  /* MAEL Version */
  #if defined (FEDORA_VERSION)
    srand48((long) time(NULL));
  #else

    #if !defined (NT_VERSION)
      /* Standart Random generation init */
      randomize ();
    #else
      /* Seed the random-number generator with current time so that
      * the numbers will be different every time we run.
      */
      srand( (unsigned)time( NULL ) );  
    #endif

  #endif /* MAEL Version */

  /*---------------------------------------------------*/
  /* Set dos verify option to on and other DOS options */
  /*---------------------------------------------------*/
  #if !defined (NT_VERSION)
    #if !defined (FEDORA_VERSION)
    /* In Linux Verify is always on */
    /* And cbreak does nothing */
    setverify (1);
    setcbrk (0);
    #endif /* FEDORA_VERSION */
    /* Set new Ctrl-Break handler */
    #if defined (DOSX286)
      DosSetPassToProtVec (0x1B, (PIHANDLER) Main_HandlerCtrlBreak,
                           &OldCtrlBrkProt, &OldCtrlBrkReal);
      DosSetPassToProtVec (0x23, (PIHANDLER) Main_HandlerCtrlBreak,
                           &OldCtrlCProt, &OldCtrlCReal);
    #else
      #if defined (FEDORA_VERSION)
        signal(SIGINT,SIG_IGN); 
      #else
        ctrlbrk (Main_HandlerCtrlBreak);
      #endif /* MAEL VERSION */
    #endif
  #endif


  /*-------------*/
  /* Nosdos Init */
  /*-------------*/

  /*----------*/
  /* Init. Kb */
  /*----------*/

  #if defined (FEDORA_VERSION)
      Kb_Init (KEYBOARD_STANDART);
  #else
  #if defined (TERMINAL_WT9602)
    Kb_Init (KEYBOARD_WT9602);
  #else
    #if defined (TERMINAL_WT9603)
      Kb_Init (KEYBOARD_WT9603);
    #else
      Kb_Init (KEYBOARD_STANDART);
    #endif
  #endif

  #endif /* MAEL Version */

  /*-----------------------*/
  /* Init. display modules */
  /*-----------------------*/

  #if defined(FEDORA_VERSION)
    #if defined(SVGALIB_MODE) || defined(XLIB_MODE)
      GrphDisp_Init (240, 128, 8);
    #else
      GrphDisp_Init (40, 14, 8);
    #endif
  #else

  #if defined(NT_VERSION)
    GrphDisp_Init (40, 14, 8);
  #else
    GrphDisp_Init (240, 128, 8);
  #endif

  #endif /* MAEL Version */

  GrphText_Init (240, 128, 8);

  #if defined (TERMINAL_WT9602) || defined (TERMINAL_WT9603)
    #if defined (LNSE)
      GrphDisp_SetInvertScreen (FALSE);
    #else
      GrphDisp_SetInvertScreen (TRUE);
    #endif
    Util_SetLCDContrast (INITIAL_LCD_CONTRAST);
  #endif

  /* Init message */
  GrphText_PopUp (54, 0, 240, Lines, TRUE);
  strcpy (Msg, S0252);
  GrphText_Cls (TRUE);
  GrphText_Write (1, (t_uchar) ((40-strlen (Msg))/2*6), Msg, FONT_7X5, (t_uchar) strlen (Msg),
                  TRUE, FALSE);


  /*-------------------------------------------------------*/
  /* Ramdisk init (includes error handler for disk access) */
  /*-------------------------------------------------------*/
  
  RamDisk_Init ();

  /* Init. Error logger */
  Errlog_Init ();

  /*------------*/
  /* Init. UART */
  /*------------*/
  
  Uart_Init ();

  /*----------------------*/
  /* Init. Parallel ports */
  /*----------------------*/

  Parallel_Init ();

  /*-----------------*/
  /* End nosdos Init */
  /*-----------------*/

  /*-----------*/
  /* App. Init */
  /*-----------*/

  /* Database Init */
  DB_InitStaticData ();

  RetVal = DB_LoadDBGlobal ();
  if (RetVal != DB_OK)
  { /* ??? Disk error: ends application ??? */
  } /* endif */
  DB_InitDynamicData ();

  /* Communication Init */
  Comm_Init ();

#if defined (FEDORA_VERSION)
  /* Ping IP address to initialize vpn */
  TCPIP_Init_Tunnel();
  /* Get and Apply last contrast value configured */
  Display_GetAndApplyContrast();
#endif

  /* Comm_Init for backup line if it is configured */
  {
    t_uchar CurrentLineType, OperationMode;

    DB_OperationMode (&OperationMode);
    if (OperationMode == OPERATIONMODE_REALONLINEBACKUP)
    {
      DB_CurrentLineType (&CurrentLineType);
      /* Change current line type to backup line */
      DB_GLOBAL_DYNAMIC.DB_CURRENT_LINETYPE = LINETYPE_BACKUP;
      /* Init backup line */
      Comm_PhysInitComm ();
      /* Restore main line type */
      DB_GLOBAL_DYNAMIC.DB_CURRENT_LINETYPE = CurrentLineType;
    } /* endif */
  }

  /* Comm_Init for main line */
  Comm_PhysInitComm ();

  Comm_CommDeviceInit ();

  /* App. protocol */
  Prot_Init ();

#if defined(ENABLE_HOTLINE)
  /* Init. Answer logger of hotline */
  Hotline_Init ();
#endif

  /* Devices init */
  Devices_Init ();
  /* Enable OMR device */
  Devices_SetState (DEVCODE_OMR, DEVSTATE_ENABLED);

  /*----------------------*/
  /* Init. printer module */
  /*----------------------*/

  DB_NumPrinters (&NumPrinters);

  for (PrinterIndex = 0; PrinterIndex < NumPrinters; PrinterIndex++)
  {
    DB_PrinterInfo (PrinterIndex, &Type, &Port, &Model);
    Printer_Init (PrinterIndex, Type, Port, Model, TRUE);
  } /* endfor */

  /* Invert screen option */
  DB_GetInvertScreen (&InvertScreen);
  GrphDisp_SetInvertScreen (InvertScreen);

  /* LCD Contrast */
  DB_GetLCDContrastOffset (&LCDContrastOffset);
  Util_SetLCDContrast (LCDContrastOffset);

  /*----------------------*/
  /* App. crc error check */
  /*----------------------*/

  DB_ChkAppCrcError ();

  /*---------------*/
  /* End App. Init */
  /*---------------*/

  /* Clear message from virtual display */
  GrphText_Cls (FALSE);
  GrphText_PopDown (FALSE);

} /* Main_Init */
Пример #30
0
void main(void)
{
	register nPage;
	unsigned char *pBuf;
	unsigned char ucDID, ucHID;
	unsigned char nCnt;
	unsigned char uNumOfLoadPage = LOAD_PAGE_SIZE;
	BOOL b4KPage = FALSE;

	// Set up copy section (initialized globals).
	//
	// NOTE: after this call, globals become valid.
	//
//	SetupCopySection(pTOC);

	// Enable the ICache.
	// MMU_EnableICache();

	// Set up all GPIO ports.
	Port_Init();

#ifdef DEBUGUART
	// UART initialize
	Uart_Init();
	//Uart_SendString("\r\n\r\nWince 5.0 1st NAND Bootloader (NBL1) for SMDK2443\r\n");

	// Initialize the NAND flash interface.
	Uart_SendString("NAND Initialize\r\n");
#endif

	NAND_Init();

	Read_DeviceID(0, &ucDID, &ucHID);
#ifdef DEBUGUART
	Uart_SendString("Device ID : 0x");
	Uart_SendBYTE(ucDID, 1);
	Uart_SendString("Hidden ID : 0x");
	Uart_SendBYTE(ucHID, 1);
#endif


	if (   (ucDID == 0xd5 && ucHID == 0x14)
	    || (ucDID == 0xd5 && ucHID == 0x94)
	    || (ucDID == 0xd7 && ucHID == 0x55)
	    || (ucDID == 0xd7 && ucHID == 0xD5)  // for MLC
		|| (ucDID == 0xd3 && ucHID == 0x10))  // for SLC
	{
		b4KPage = TRUE;
		uNumOfLoadPage = LOAD_PAGE_SIZE/2;
	}

	// Turn the LEDs off.
	Led_Display(0x0);

	pBuf = (unsigned char *)LOAD_ADDRESS_PHYSICAL;

	// MLC
	// Page 0, 1 : Steploader
	// Page 2 ~ 5 : empty page
	// Page 6 ~ PAGES_PER_BLOCK-3 : effective page
	// read pages with 0, 1 and 6 to PAGES_PER_BLOCK-3
    nPage = 10;
	for (nCnt = 0; nCnt < uNumOfLoadPage; nCnt++)
	{
#ifdef	OMNIBOOK_VER
		Led_Display(0x1);
#else	//!OMNIBOOK_VER
	    Led_Display(0x2);
#endif	OMNIBOOK_VER
		if (nPage >= (NAND_PAGE_PER_BLOCK-2) || (NAND_Read(0, nPage, pBuf, b4KPage) == FALSE))
		{
#ifdef DEBUGUART
			// Uncorrectable ECC Error
			Uart_SendString("ECC Error @ Page 0x");
			Uart_SendBYTE(nPage, 1);
#endif
#ifdef	OMNIBOOK_VER
			Led_Display(0x0);
#else	//!OMNIBOOK_VER
			Led_Display(0x9);
#endif	OMNIBOOK_VER
			while(1);
		}

		nPage++;

		if (b4KPage == TRUE)
			pBuf += NAND_BYTE_PER_PAGE*2;
		else
			pBuf += NAND_BYTE_PER_PAGE;
#ifdef	OMNIBOOK_VER
		Led_Display(0x2);
#else	//!OMNIBOOK_VER
        Led_Display(0x4);
#endif	OMNIBOOK_VER
	}

	//Uart_SendString("Jump to 2nd Bootloader...\r\n");
//	Uart_SendDWORD(LOAD_ADDRESS_PHYSICAL, 1);

	// Turn the LEDs on.
	//
#ifdef	OMNIBOOK_VER
	Led_Display(0x3);
#else	//!OMNIBOOK_VER
	Led_Display(0x5);
#endif	OMNIBOOK_VER

#ifdef DEBUGUART
	Uart_SendString("Jump to 2nd Bootloader...\r\n");
#endif

	((PFN_IMAGE_LAUNCH)(LOAD_ADDRESS_PHYSICAL))();
}