Exemplo n.º 1
0
void SYSC_CLKInform(void)
{
	u32 uTTT0, uTTT1;

	SYSC_CtrlCLKOUT( eCLKOUT_APLLOUT, 4);


	SYSC_GetClkInform();
	UART_InitDebugCh(0, 115200);
		
	uTTT0 = SYSC_RdLockDetect(eAPLL);
	uTTT1= SYSC_RdLockDetect(eMPLL);
	
	
	UART_Printf("\n\n");
	UART_Printf("***************************************************\n");
	UART_Printf("*       S3C6410 - Test firmware v0.1              *\n");
	UART_Printf("***************************************************\n");
	UART_Printf("System ID : Revision [%d], Pass [%d]\n", g_System_Revision, g_System_Pass);
	UART_Printf("ARMCLK: %.2fMHz  HCLKx2: %.2fMHz  HCLK: %.2fMHz  PCLK: %.2fMHz\n",(float)g_ARMCLK/1.0e6, (float)g_HCLKx2/1.0e6, (float)g_HCLK/1.0e6, (float)g_PCLK/1.0e6);
	UART_Printf("SYNC Mode : %d\n", g_SYNCACK);
	UART_Printf("APLL Lock :  %d,  MPLL_Lock: %d\n", uTTT0, uTTT1);
	UART_Printf("AMPLL: %.2fMHz  \n",(float)g_MPLL/1.0e6);
	UART_Printf("\n");    

	
}	
Exemplo n.º 2
0
int init() {
    // unselect all SPI devices first
    SDCARD_Unselect();
    ST7735_Unselect();

    // initialize SD-card as fast as possible, it glitches otherwise
    // (this is important only if SPI bus is shared by multiple devices)
    int code = SDCARD_Init();
    if(code < 0) {
        UART_Printf("SDCARD_Init() failed, code = %d\r\n", code);
        return -1;
    }

    ST7735_Init();
    ST7735_FillScreen(ST7735_BLACK);

    // mount the default drive
    FRESULT res = f_mount(&fs, "", 0);
    if(res != FR_OK) {
        UART_Printf("f_mount() failed, res = %d\r\n", res);
        return -2;
    }
    UART_Printf("f_mount() done!\r\n");

    return 0;
}
Exemplo n.º 3
0
void SYSC_Test(void)
{
	u32 i;
	s32 uSel;

	UART_Printf("[SYSC_Test]\n\n");

	Outp32Inform(0,0);
	Outp32Inform(1,0);
	Outp32Inform(2,0);
	Outp32Inform(3,0);
	Outp32Inform(4,0);
	Outp32Inform(5,0);
	Outp32Inform(6,0);
	Outp32Inform(7,0);
	
	while(1)
	{
		for (i=0; (u32)(sysc_menu[i].desc)!=0; i++)
			UART_Printf("%2d: %s\n", i, sysc_menu[i].desc);

		UART_Printf("\nSelect the function to test : ");
		uSel =UART_GetIntNum();
		UART_Printf("\n");
		if(uSel == -1) 
			break;

		if (uSel>=0 && uSel<(sizeof(sysc_menu)/8-1))
			(sysc_menu[uSel].func) ();
	}
}	
Exemplo n.º 4
0
static void My_LPT(void* pvParameters)
{
    unsigned char LowPrio;
	
	LED_PORT = 	LED_My_LPT;	  /* Led to indicate the execution of My_LPT*/

	LowPrio = uxTaskPriorityGet(LPT_Handle);
	UART_Printf("\n\rLPT:%d,Acquiring semaphore",LowPrio);

	xSemaphoreTake(Sem_A,portMAX_DELAY);

    UART_Printf("\n\rLPT: Creating HPT");
	xTaskCreate( My_HPT, ( signed char * )"HighTask", configMINIMAL_STACK_SIZE, NULL, 3, &HPT_Handle );

	LED_PORT = 	LED_My_LPT;	  /* Led to indicate the execution of My_LPT*/
	LowPrio = uxTaskPriorityGet(LPT_Handle);
	UART_Printf("\n\rLPT:%d Creating MPT",LowPrio);
	xTaskCreate( My_MPT, ( signed char * )"MidTask", configMINIMAL_STACK_SIZE, NULL, 2, &MPT_Handle );

	LED_PORT = 	LED_My_LPT;	  /* Led to indicate the execution of My_LPT*/
	LowPrio = uxTaskPriorityGet(LPT_Handle);
	UART_Printf("\n\rLPT:%d Releasing Semaphore",LowPrio);
	xSemaphoreGive(Sem_A);

	LED_PORT = 	LED_My_LPT;	  /* Led to indicate the execution of My_LPT*/
    LowPrio = uxTaskPriorityGet(LPT_Handle);
	UART_Printf("\n\rFinally Exiting LPT:%d",LowPrio);
	vTaskDelete(LPT_Handle);
}
void rtc_test()
{
    rtc_t rtc;
    UART_Printf("\n\rConnections SCL->PC.3 SDA->PC.4");
    UART_Printf("\n\r Make connections and hit 'k' to test! ");
    while(UART_RxChar()!='k');   

    RTC_Init();
    rtc.hour = 0x10; //  10:40:20 am
    rtc.min =  0x40;
    rtc.sec =  0x00;

    rtc.date = 0x01; //1st Jan 2016
    rtc.month = 0x01;
    rtc.year = 0x16;
    rtc.weekDay = 5; // Friday: 5th day of week considering monday as first day.




    /*##### Set the time and Date only once. Once the Time and Date is set, comment these lines
         and reflash the code. Else the time will be set every time the controller is reset*/
    RTC_SetDateTime(&rtc);  //  10:40:20 am, 1st Jan 2016


    /* Display the Time and Date continuously */
    while(1)
    {
        RTC_GetDateTime(&rtc);
        UART_Printf("\n\rtime:%2x:%2x:%2x  \nDate:%2x/%2x/%2x",(uint16_t)rtc.hour,(uint16_t)rtc.min,(uint16_t)rtc.sec,(uint16_t)rtc.date,(uint16_t)rtc.month,(uint16_t)rtc.year);
    }
}
Exemplo n.º 6
0
void rtc_test()
{
    unsigned char sec,min,hour,day,month,year;
    UART_Printf("\n\rConnections SCL->P0.6 SDA->P0.7");
	UART_Printf("\n\r Make connections and hit 'k' to test! ");
    while(UART_RxChar()!='k');   

	RTC_Init();

	
 /*##### Set the time and Date only once. Once the Time and Date is set, comment these lines
         and reflash the code. Else the time will be set every time the controller is reset*/
    RTC_SetTime(0x10,0x40,0x00);  //  10:40:20 am
    RTC_SetDate(0x01,0x01,0x15);  //  1st Jan 2015

   /* Display the Time and Date continuously */ 
   while(1)
    {
        RTC_GetTime(&hour,&min,&sec);      
        RTC_GetDate(&day,&month,&year);        
        UART_Printf("\n\rtime:%2x:%2x:%2x  \nDate:%2x/%2x/%2x",(uint16_t)hour,(uint16_t)min,(uint16_t)sec,(uint16_t)day,(uint16_t)month,(uint16_t)year);
     }
    
   
}
Exemplo n.º 7
0
void I2S_PCMDataOutIntr(AUDIO_PORT rhs_ePort)
{
	UART_Printf("\nListen to Sound via Speak Out Connector.\n");
	UART_Printf("Press any key to play.\n");
	UART_Getc();
	
	if ((g_oI2SInfor[rhs_ePort].m_CLKSRC != I2S_EXTERNALCDCLK) && (g_oI2SInfor[rhs_ePort].m_eOpMode == Master)) 
	{
		I2S_CDCLKOut(rhs_ePort);											
	}
	else if ((g_oI2SInfor[rhs_ePort].m_CLKSRC == I2S_FIN) && (g_oI2SInfor[rhs_ePort].m_eOpMode == Slave)) 
	{
		I2S_CDCLKOut(rhs_ePort);										//12MHz Out
	}
	else if ((g_oI2SInfor[rhs_ePort].m_CLKSRC != I2S_EXTERNALCDCLK) && (g_oI2SInfor[rhs_ePort].m_CLKSRC != I2S_FIN) && (g_oI2SInfor[rhs_ePort].m_eOpMode == Slave)) 
	{
		if ( g_oI2SInfor[rhs_ePort].m_dSamplingFreq % 11025)
			I2S_SetEpllCDCLKOut(rhs_ePort, I2S_USERCLKOUT2);			// 11.2896MHz Out
		else
			I2S_SetEpllCDCLKOut(rhs_ePort, I2S_USERCLKOUT1);			// 12.288MHz Out
	}

	#if (I2S_CODEC == WM8753)
		WM8753_CodecInitPCMOut(g_oI2SInfor[rhs_ePort].m_eDataFormat, (u32) g_oI2SInfor[rhs_ePort].m_dSamplingFreq, 
										g_oI2SInfor[rhs_ePort].m_eOpMode,  g_oI2SInfor[rhs_ePort].m_eWordLength, SMDK_I2S);
	#elif (I2S_CODEC == WM8990)
		WM8990_CodecInitPCMOut(g_oI2SInfor[rhs_ePort].m_eDataFormat, (u32) g_oI2SInfor[rhs_ePort].m_dSamplingFreq,
										g_oI2SInfor[rhs_ePort].m_eOpMode,  g_oI2SInfor[rhs_ePort].m_eWordLength, SMDK_I2S);
	#elif (I2S_CODEC == WM8580)
		WM8580_CodecInitPCMOut(g_oI2SInfor[rhs_ePort].m_eDataFormat, (u32) g_oI2SInfor[rhs_ePort].m_dSamplingFreq, 
								g_oI2SInfor[rhs_ePort].m_eOpMode,  g_oI2SInfor[rhs_ePort].m_eWordLength, SMDK_I2S);
	#endif
	I2SMOD_SetTXR(rhs_ePort, TXOnly);
	I2S_DataOutIntr(rhs_ePort);
}
Exemplo n.º 8
0
static void MyTask3(void* pvParameters)
{

	LED_PORT = 	LED_Task3;	  /* Led to indicate the execution of Task3*/	
	UART_Printf("\n\rTask3, creating new tasks 2 and 4");

    /* Create two new tasks 2, 4 */
	xTaskCreate( MyTask2, ( signed char * )"Task2", configMINIMAL_STACK_SIZE, NULL, 2, &TaskHandle_2);
	xTaskCreate( MyTask4, ( signed char * )"Task4", configMINIMAL_STACK_SIZE, NULL, 4, &TaskHandle_4);

	LED_PORT = 	LED_Task3;	  /* Led to indicate the execution of Task3*/
	UART_Printf("\n\rBack in Task3, Creating Task5");

	xTaskCreate( MyTask5, ( signed char * )"Task5", configMINIMAL_STACK_SIZE, NULL, 5, &TaskHandle_5);

	LED_PORT = 	LED_Task3;	  /* Led to indicate the execution of Task3*/
	UART_Printf("\n\rBack in Task3, Waiting for some time");
	
	vTaskDelay(200);
	LED_PORT = 	LED_Task3;	  /* Led to indicate the execution of Task3*/
	UART_Printf("\n\rFinally in Task3");	

	vTaskDelete(TaskHandle_3);

}
Exemplo n.º 9
0
//////////
// Function Name : OtgDev_Test
// Function Desctiption : test function of the OTG DEV
// Input : NONE
// Output : NONE
// Version :
void OtgDev_Test(void)
{
	s32 i, sel;
			
	const testFuncMenu menu[]=
	{
		Download_Only,			"Donwload Only",
		Upload_Only,			"Upload Only",
		Select_OpMode,			"Select Op Mode",
		0,                      0
	};
	
	while(1)
	{
		UART_Printf("\n");
		for (i=0; (int)(menu[i].desc)!=0; i++)
			UART_Printf("%2d: %s\n", i, menu[i].desc);

		UART_Printf("\nSelect the function to test : ");
		sel = UART_GetIntNum();
		UART_Printf("\n");

		if (sel == -1)
			break;
		else if (sel>=0 && sel<(sizeof(menu)/8-1))
			(menu[sel].func)();
	}
}
Exemplo n.º 10
0
//////////
// Function Name : Select_OpMode
// Function Description : This function selects an operation mode of USB OTG of CPU or DMA mode.
// Input : NONE
// Output : NONE
// Version : 
void Select_OpMode(void)
{
	int iSel;
	
	UART_Printf(" Current Op Mode : ");
	if(eOpMode == USB_CPU)
	{
		UART_Printf("CPU mode\n");
	}
	else if(eOpMode== USB_DMA)
	{
		UART_Printf("DMA mode\n");
	}

	UART_Printf(" Enter the op. mode (0: CPU_MODE, 1: DMA_MODE) : ");
	iSel = UART_GetIntNum();

	if (iSel != -1) 
	{
		if (iSel == 0)
			eOpMode = USB_CPU;
		else if (iSel == 1)
			eOpMode = USB_DMA;
		else
			UART_Printf("Invalid selection\n");
	}
}
Exemplo n.º 11
0
void Capture_XY(void)
{
	//u32 uXDat = 0;
	//u32 uYDat = 0;

	UART_Printf("\n\n[ADCTS touch screen Tracking test.]\n");

	ADCTS_Init();

	g_oADCTSInform.ucTouchStatus	=	ADCTS_TOUCH_INIT;
	ADC_InitADCCON();
	ADCTS_SetDelay(50000);

	ADCTS_SetMeasureMode(eADCTS_MEASURE_FOR_STYLUS);

	Delay(10000);

	INTC_SetVectAddr(NUM_PENDNUP, ADCTS_ISR);
	INTC_Enable(NUM_PENDNUP);

    	UART_Printf("\nPress any key to exit!!!\n");
    	UART_Printf("\nStylus Down, please...... \n");

//	while(!GetKey())
//	{
		if (g_oADCTSInform.ucTouchStatus == ADCTS_TOUCH_DOWN)
		{
			while( ADCTS_GetXPStylusIntState() == STYLUS_DOWN )
			{
				ADC_InitADCCON();
				ADCTS_SetMeasureMode(eADCTS_MEASURE_AUTO_SEQ);

				ADC_EnableStart(ENABLE);

				while(! (ADC_IsAfterStartup() )) ;	//	Wait for begin sampling
				while (! (ADC_IsEOCFlag()));		//	Wait for the EOC

				uXDat	= ADCTS_GetXPData();
				uYDat	= ADCTS_GetYPData();

				UART_Printf("X : %f, Y : %f\n",uXDat,uYDat);
				ADCTS_SetMeasureMode(eADCTS_MEASURE_FOR_STYLUS);
				ADCTS_SetStylusDetectMode(STYLUS_UP);
				Delay(300);
			}
		}
//		else if (g_oADCTSInform.ucTouchStatus == ADCTS_TOUCH_UP)
//		{
//			if ( ADCTS_GetXPStylusIntState() == STYLUS_UP )
//			{
//				ADCTS_SetMeasureMode(eADCTS_MEASURE_FOR_STYLUS);
//			}
//		}
//	}

//	INTC_Disable(NUM_PENDNUP);
	UART_Printf("\n\n[ADCTS touch screen Tracking test End.]\n");	

}
void gpio_test()
{ 
   unsigned char i;
   UART_Printf("\n\rConnect any IO Pins to buzzer, relays, leds ");
   UART_Printf("\n\rMake connections and hit 'k' to test ");
   while(UART_RxChar()!='k');
   ADCON0 = 0x00;
   ADCON1 = 0x07;
   TRISA = C_PortOutput_U8;
   TRISB = C_PortOutput_U8;
   TRISC = C_PortOutput_U8;
   TRISD = C_PortOutput_U8;
   TRISE = C_PortOutput_U8;
  while(1)
    {
      for(i=0;i<2;i++)
      {
	 /* Turn On all the leds and wait for one second */ 
	   PORTA = 0xff; 
       PORTB = 0xff;
       PORTC = 0xff;
       PORTD = 0xff;
       PORTE = 0xff;
	   DELAY_ms(500);
       
	 /* Turn off all the leds and wait for one second */
	   PORTA = 0x00; 
       PORTB = 0x00;
       PORTC = 0x00;
       PORTD = 0x00;
       PORTE = 0x00;
	   DELAY_ms(500);
      }
      
      for(i=1;i;i=i<<1)
      {
       PORTA = i; 
       PORTB = i;
       PORTC = i;
       PORTD = i;
       PORTE = i;
	   DELAY_ms(100);
      }
      
      for(i=0x80;i;i=i>>1)
      {
       PORTA = i; 
       PORTB = i;
       PORTC = i;
       PORTD = i;
       PORTE = i;
	   DELAY_ms(100);
      }
    }
}
Exemplo n.º 13
0
void CompareData(void)
{
	u32 uCnt;
	u32 uBCnt;
	u32 uFcnt=0;


		// Clear Check Data ----------------START
		pIrDA_CKBUFFER=(u8 *)MemoryCk;
		for (uCnt=0; uCnt<0x100000; uCnt++)
			{
	//		*pIrDA_CKBUFFER++ = 'U';
			*pIrDA_CKBUFFER++ = 0x0;			// for Performance test(to check signal)
//			*pIrDA_CKBUFFER++ = uCnt;
			}
		pIrDA_CKBUFFER=(u8 *)MemoryCk;
		// Clear Check Data -----------------END

	

	UART_Printf("\nCount Number : ");
	uBCnt=UART_GetIntNum();
	UART_Printf("\n");

		// Initialize Check Data ----------------START
		pIrDA_CKBUFFER=(u8 *)MemoryCk;
		for (uCnt=0; uCnt<uBCnt; uCnt++)
			{
	//		*pIrDA_CKBUFFER++ = 'U';
	//		*pIrDA_CKBUFFER++ = 0x0;			// for Performance test(to check signal)
			*pIrDA_CKBUFFER++ = uCnt;
			}
		pIrDA_CKBUFFER=(u8 *)MemoryCk;
		// Initialize Check Data -----------------END
	

	
	pIrDA_RXBUFFER=(u8 *)MemoryRx;

		for (uCnt=0; uCnt<=uBCnt; uCnt++)
			{
			if(*pIrDA_CKBUFFER != *pIrDA_RXBUFFER)
				uFcnt++;

			*pIrDA_CKBUFFER++;
			*pIrDA_RXBUFFER++;			
			}

		UART_Printf("Rx data Check Done!!\n");
		UART_Printf("%d times have been failed\n",uFcnt);
		
		

}
Exemplo n.º 14
0
static void MyTask5(void* pvParameters)
{
	LED_PORT = 	LED_Task5;	  /* Led to indicate the execution of Task4*/
	UART_Printf("\n\rIn Task5, waiting for some time");
	vTaskDelay(200);

	LED_PORT = 	LED_Task5;	  /* Led to indicate the execution of Task4*/
	UART_Printf("\n\rBack in Task5");
	
	vTaskDelete(TaskHandle_5);
}
Exemplo n.º 15
0
AUDIO_PORT I2S_ChangePort(void)
{	
	AUDIO_PORT eSelPort;
	
	UART_Printf("Which Port do you controll?\n");
	UART_Printf("0. Port 0	1. Port 1 \n");
	eSelPort = (AUDIO_PORT)UART_GetIntNum();
	if (eSelPort == 1)
		return AUDIO_PORT1;
	else
		return AUDIO_PORT0;	
}
Exemplo n.º 16
0
static void MyTask1(void* pvParameters)
{
	LED_PORT = 	LED_Task1;	  /* Led to indicate the execution of Task1*/
	UART_Printf("\n\rIn Task1, Deleting all tasks");
	vTaskDelete(TaskHandle_2);
	vTaskDelete(TaskHandle_3);
	vTaskDelete(TaskHandle_4);
	vTaskDelete(TaskHandle_5);
	UART_Printf("\n\rExiting task1");

	vTaskDelete(TaskHandle_1);
}
Exemplo n.º 17
0
static void MyTask2(void* pvParameters){

    char TxBuffer[MaxElementsPerQueue]={"Hello world"};

	UART_Printf("\n\rTask2, Filling the data onto queue");

	xQueueSend(MyQueueHandleId,TxBuffer,100);

	UART_Printf("\n\rExiting task2");

	vTaskDelete(TaskHandle_2);
}
Exemplo n.º 18
0
/***************************************************KEYPAD *****************************************
 				Displays keys pressed on 4x4 keypad on the uart
*****************************************************TEST*******************************************/
void keypad_test()
{
uint8_t key;
UART_Printf("\n\rConnections: Port 2");
UART_Printf("\n\rMake connections and hit 'k' to test!");
while(UART_RxChar()!='k');
KEYPAD_Init();
while(1)
{
  key = KEYPAD_GetKey();
  UART_Printf("\n\r Key:%c", key);
}
}
/***************************************************KEYPAD *****************************************
 				Displays keys pressed on 4x4 keypad on the uart
*****************************************************TEST*******************************************/
void keypad_test()
{
uint8_t key;
UART_Printf("\n\rConnections: PORTD");
UART_Printf("\n\rMake connections and hit 'k' to test!");
while(UART_RxChar()!='k');
KEYPAD_Init(PD_0,PD_1,PD_2,PD_3,PD_4,PD_5,PD_6,PD_7);
while(1)
{
  key = KEYPAD_GetKey();
  UART_Printf("\n\r Key:%c", key);
}
}
Exemplo n.º 20
0
static void MyTask1(void* pvParameters){

    char RxBuffer[MaxElementsPerQueue];
	UART_Printf("\n\rTask1, Reading the data from queue");

	xQueueReceive(MyQueueHandleId,RxBuffer,100);

	UART_Printf("\n\rBack in task1, Received data is:");
	tx_string(RxBuffer);


	vTaskDelete(TaskHandle_1);

}
Exemplo n.º 21
0
void Irda_Fifo_Int_Tx(u32 MODE,u32 PREAMBLE,u32 STARTFLAG,u32 TXFL,u32 TXTRIG)
{
	u32	uCnt;


	UART_Printf("Data length to transmit (multiple of %d): ",IrDA_TxBUFLEN);
	g_uIrDA_TxCnt = 0;
	g_uIrDA_TxNum = UART_GetIntNum();
	if (g_uIrDA_TxNum == -1) g_uIrDA_TxNum = IrDA_TxBUFLEN; //data length

	// Initilize IrDA with the FRAME SIZE given by user.
	IrDA_Init(MODE, PREAMBLE, STARTFLAG, TXFL, TXTRIG);


		
	// Initialize Check Data ----------------START
	pIrDA_CKBUFFER=(u8 *)MemoryCk;
	for (uCnt=0; uCnt<g_uIrDA_TxNum; uCnt++) {
//		*pIrDA_CKBUFFER++ = 'U';
//		*pIrDA_CKBUFFER++ = 0x0;			// for Performance test(to check signal)
		*pIrDA_CKBUFFER++ = uCnt;
	}
	pIrDA_CKBUFFER=(u8 *)MemoryCk;
	// Initialize Check Data -----------------END

	g_uIrDA_TxDone = 0;

	IrDA_EnRx(0);
	IrDA_EnTx(1);
	
	
	IrDA_SetIER(1,1,1,1,1,1,1,1);
	
	IrDA_EnInt(1);


	while(!g_uIrDA_TxDone);

	while(!(IrDA_ReadLSR() & 0x80));			//Check Tx FIFO empty
	UART_Printf("Tx buffer is empty!!, Tx Done!!\n");

	UART_Printf("[Tx String :\n");
	pIrDA_CKBUFFER  = (u8 *)MemoryCk;	

	UART_Printf("\t");
	for(uCnt=0; uCnt<g_uIrDA_TxNum ; uCnt++)
	{
		UART_Printf("[D:%3d] ", *pIrDA_CKBUFFER++);
		if(!((uCnt+1)%64)) UART_Printf("\n");
		if(!((uCnt+1)%8)) UART_Printf("\n\t");
	}
	UART_Printf("\n");

	IrDA_SetIER(0,0,0,0,0,0,0,0);

	IrDA_EnInt(0);


}	
Exemplo n.º 22
0
void gpio_test()
{   
   UART_Printf("\n\rConnect any IO Pins to buzzer, relays, leds ");
   UART_Printf("\n\rMake connections and hit 'k' to test ");
   while(UART_RxChar()!='k');
  while(1)
    {
	 /* Turn On all the leds and wait for one second */ 
	   P0= P1 = P2 =P3= 0xff;	   
	   DELAY_sec(1);
	 /* Turn off all the leds and wait for one second */
	  P0= P1 = P2 =P3= 0x00;;
	   DELAY_sec(1);
    }
}
Exemplo n.º 23
0
/***************************************************EEPROM*****************************************
 				Writes and Reads a character to and from EEPROM
*****************************************************TEST*****************************************/
void eeprom_test()
{
	 unsigned char eeprom_address=0x00, write_char = 'X', read_char;
	 
	UART_Printf("Connections SCL->P0.6 SDA->P0.7");
	UART_Printf("Make connections and hit 'k' to test! ");
        while(UART_RxChar()!='k');
	 UART_TxString("\n\rEeprom Write: ");      //Print the message on UART
	 UART_TxChar(write_char);			         //Print the char to be written 
	 EEPROM_WriteByte(eeprom_address,write_char);	// Write the data at memoryLocation	0x00

	 UART_TxString("  Eeprom Read: ");            //Print the message on UART
	 read_char = EEPROM_ReadByte(eeprom_address);	// Read the data from memoryLocation 0x00
	 UART_TxChar(read_char);	
}
Exemplo n.º 24
0
/* start the main program */
void main() 
{
   unsigned char sec,min,hour,day,month,year;

  /* Initilize the Uart before Transmiting/Reaceiving any data */
    UART_Init(9600);

  /* Initilize the RTC(ds1307) before reading or writing time/date */
    RTC_Init();

	UART_TxString(" Testing RTC ");
 /*##### Set the time and Date only once. Once the Time and Date is set, comment these lines
         and reflash the code. Else the time will be set every time the controller is reset*/
    RTC_SetTime(0x10,0x40,0x00);  //  10:40:20 am
    RTC_SetDate(0x01,0x01,0x15);  //  1st Jan 2015



   /* Display the Time and Date continuously */ 
   while(1)
    {
	   /* Read the Time from RTC(ds1307) */ 
        RTC_GetTime(&hour,&min,&sec);      
		
	    /* Read the Date from RTC(ds1307) */ 
        RTC_GetDate(&day,&month,&year);        
	 
        UART_Printf("\n\r the time is :%2x:%2x:%2x  \nDate:%2x/%2x/%2x",(uint16_t)hour,(uint16_t)min,(uint16_t)sec,(uint16_t)day,(uint16_t)month,(uint16_t)year);
	  }		

  }
Exemplo n.º 25
0
//////////
// Function Name : Download_Only
// Function Description : This function downloads a image file thru DNW.
//						You can configure the address to downlad in DNW "Configuration-Options" menu.
// Input : NONE
// Output : NONE
// Version : 
static void Download_Only(void)
{
	u8 *pucDownloadAddr;
	
    UART_Printf("Enter the download address(0x...):");
    pucDownloadAddr=(u8 *)UART_GetIntNum();
    if(pucDownloadAddr==(u8 *)0xffffffff)
    {
    	pucDownloadAddr=(u8 *)DefaultDownloadAddress;
    }
    
    UART_Printf("The temporary download address is 0x%x.\n\n",pucDownloadAddr);
    
    DownloadImageThruUsbOtg(pucDownloadAddr);
	
}
void seg_test()
{  
 unsigned char seg_code[]={0xC0,0xF9,0xA4,0xB0}; 
 UART_TxString("\n\r Segment DataBus: PORTD    Seg select: S1->PB.0 S2->PB.1 S3->PB.2 S4->PB.3");
 UART_Printf("\n\rMake connections and hit 'k' to test! ");
 while(UART_RxChar()!='k');
 SegValueDirnReg = C_PortOutput_U8;
 SegSelectDirnReg = C_PortOutput_U8;

	while(1)
	{  
	   SegmentSlection=SegOne;
	   SegmentValue = seg_code[0];
	   DELAY_us(10); 
	   SegmentSlection=SegTwo;
	   SegmentValue = seg_code[1];
	   DELAY_us(10);
	   SegmentSlection=SegThree;
	   SegmentValue = seg_code[2];
	   DELAY_us(10);	
	   SegmentSlection=SegFour;  
	   SegmentValue = seg_code[3];
	   DELAY_us(10);
	 }  
}
/***************************************************EEPROM*****************************************
 				Writes and Reads a character to and from EEPROM
*****************************************************TEST*****************************************/
void eeprom_test()
{	 
    unsigned char eeprom_address = 0x00, write_char = 'X', read_char;

    for(write_char='A';write_char<='Z';write_char++) /* Eeprom Write and read A-Z */
    {
        UART_Printf("\n\rEeprom Write: %c    ",write_char); //Print the message on UART
        EEPROM_WriteByte(eeprom_address, write_char); // Write the data at memoryLocation	0x00


        read_char = EEPROM_ReadByte(eeprom_address);  // Read the data from memoryLocation 0x00
        UART_Printf("Eeprom Read: %c",read_char); //Print the message on UART
    }
    
    while (1);
}
Exemplo n.º 28
0
static void MyIdleTask(void* pvParameters)
{	
	while(1)
	{
	    LED_PORT = 	LED_IdleTask;		 /* Led to indicate the execution of Idle Task*/
		UART_Printf("\n\rIn idle state");
	}									 
}
Exemplo n.º 29
0
/***************************************************ADC *****************************************
 				Reads and displays ADC data from on board sensors.
*****************************************************TEST*****************************************/
void adc_test()
{ 
 uint16_t temp,light,pot;
 UART_Printf("\n\rConnections: DataBus P1 Control: adc_A->P0.0 adc_B->P0.1 adc_C->P0.2 adc_ALE->P.3 adc_Start->P.4 adc_EOC->P1.5 adc_OE->P1.6");
 UART_Printf("\n\rMake connections and hit 'k' to test!");
 while(UART_RxChar()!='k');
 ADC_Init();

 while(1)
 {
   temp = ADC_GetAdcValue(0);
   pot = ADC_GetAdcValue(1);
   light = ADC_GetAdcValue(2);
   UART_Printf("\n\rtemp:%3d pot:%3d light:%3d", temp,pot,light);

 }
}
Exemplo n.º 30
0
//////////
// Function Name : CF_SetEBI
// Function Description : 
//   This function sets EBI of Syscon for CF controller.
// Input : NONE
// Output : NONE
// Version : v0.1 
void CF_SetEBI(u8 ucOpMode)
{
	SYSC_CtrlCSMEM0(eCS_SROMC, eCS_SROMC, eCS_CFC, eCS_CFC);		// bank4_cfg->CF,bank5_cfg->CF 
	// Set Buffer Direction pin 
//	GPIO_SetFunctionEach(eGPIO_M, eGPIO_5, 3);	// Set XhiINTR pin as CF Data Direction
	GPIO_SetFunctionEach(eGPIO_B, eGPIO_4, 4);	// Set XirSDBW pin as CF Data Direction

 	if (ucOpMode == DIRECT_MODE)	
 	{
		UART_Printf(" * CF EBI MODE : Direct Mode\n\n");
		SYSC_IndepCF();		// select dedicated CF path (direct path)
 	}
	else
	{
		UART_Printf(" * CF EBI MODE : InDirect Mode\n\n");
		SYSC_EBICF();		// select EBI path (for Indirect path)
	}
}