Exemple #1
1
void print_tc(char d1,char d2){
	UARTCharPut(UART0_BASE,d1);
	UARTCharPut(UART0_BASE,d2);
	UARTCharPut(UART0_BASE,96);
	UARTCharPut(UART0_BASE,'C');
	UARTCharPut(UART0_BASE,' ');
}
Exemple #2
0
void enviaID() {
	
	UARTCharPut(UART_PC_COMM, 0x12);
	UARTCharPut(UART_PC_COMM, 0x34);
	UARTCharPut(UART_PC_COMM, 0x56);
	
}
Exemple #3
0
void UARTIntHandler(void)
{
	uint32_t ui32Status;
	ui32Status = UARTIntStatus(UART0_BASE, true); //get interrupt status
	UARTIntClear(UART0_BASE, ui32Status); //clear the asserted interrupts
	while(UARTCharsAvail(UART0_BASE)) //loop while there are chars
	{
		char x = UARTCharGetNonBlocking(UART0_BASE);
		if(mode == 0 && x == 's') {
			mode = 1;
			UARTStrPut("Enter the temperature : ");
			newSet = 0;
		} else if (mode == 1) {
			if (x == 127 && newSet > 0) { // backspace
				UARTCharPut(UART0_BASE, 127);
				newSet /= 10;
			} else if (x >= 48 && x <= 57) { // digit
				UARTCharPut(UART0_BASE, x);
				newSet = newSet*10 + (x - 48);
			} else if (x == 13) { // new line (enter)
				setTemp = newSet;
				UARTStrPut("\r\nSet Temperature updated to ");
				UARTIntPut(setTemp);
				UARTCharPut(UART0_BASE, 176);
				UARTStrPut("C\r\n");
				mode = 0;
			}
		}
	}
}
Exemple #4
0
//*****************************************************************************
//
//! Print a number to Uart
//!
//!
//! \param UART_Base.
//! \param Num number you want to print.
//!
//! \return None
//
//*****************************************************************************
void UARTPutn(uint32_t UART_Base, long Num)
{
	unsigned long temp = 1;
	long NumTemp;
	NumTemp = Num;
	if (Num == 0)
	{
		UARTCharPut(UART_Base, 48);
	}
	else
	{
		if (Num < 0)
		{
			UARTCharPut(UART_Base, '-');
			Num *= -1;
		}
		while (NumTemp)
		{
			NumTemp /= 10;
			temp *= 10;
		}
		temp /= 10;
		while (temp)
		{
			UARTCharPut(UART_Base,(Num / temp) % 10 + 48);
			temp /= 10;
		}
	
	}
}
Exemple #5
0
//*****************************************************************************
//
//! xuart0301 test execute main body.
//
//! \return None.
//
//*****************************************************************************
static void xuart0301Execute(void)
{
    unsigned char UartData = 0;
    unsigned char i = 0;
    xtBoolean bTmpBoolean = xfalse;

    UART_Print("\r\nPlease wait 1 s then type the follow string\r\n");
    UART_Print("123456789ABCDE\r\n");

    bTmpBoolean = UARTCharsAvail(UART_BASE);
    TestAssert((xfalse == bTmpBoolean),
            "UART 0301: Function UARTCharsAvail failed!\r\n");
    
    while((UartData = UARTCharGet(UART_BASE)) != '\n')
    {
        UARTCharPut(UART_BASE, UartData);
        if(++i >= 15)
        {
            break;
        }
    }
    UARTCharPut(UART_BASE, '\r');
    UARTCharPut(UART_BASE, '\n');

}
Exemple #6
0
/*
 * Function Name: clearscreen
 * Input: none
 * Output: none
 * Description: Clears the screen
 * Example Call: clearscreen();
 */
void clearscreen(void) {
	int i;
	for (i = 0; i < 50; i++) {
		UARTCharPut(UART0_BASE, ' ');
	}
	UARTCharPut(UART0_BASE, '\r');
}
int UARTPrint_uint32_t(uint32_t value)
{
	// unexpected crash at variable assignments. could not fix.
	int i = 0; // iterator
	int written = 0;
	uint32_t temp = value;
	char buffer[100];

	if (value == 0) {
		UARTCharPut(UART0_BASE, '0');
		return 1;
	}

	// Convert to string
	while (temp != 0) // count the number of digits
	{
		i++;
		temp /= 10;
	}
	buffer[i] = '\0';
	i--;
	for (; i >= 0; i--) // convert digits to chars, and store in buffer
			{
		buffer[i] = value % 10 + '0';
		value /= 10;
	}
	while (buffer[i] != '\0') {
		UARTCharPut(UART0_BASE, buffer[i]);
		written++;
	}
	return written;
}
Exemple #8
0
void enviarDelta_t(int delta_t) {

	enviaID();
	UARTCharPut (UART_PC_COMM, MESSAGE_TYPE_DELTA_T);
		
	UARTCharPut(UART_PC_COMM, ((delta_t & 0xFF00) >> 8));
	UARTCharPut (UART_PC_COMM, delta_t & 0xFF);

}
// definition of fputc for debugging over virtual COM port11
int fputc (int ch, FILE *f)  {
  /* Debug output to serial port. */

  if (ch == '\n')  {
    UARTCharPut (UART0_BASE, '\r');          /* output CR */
  }
  UARTCharPut (UART0_BASE, ch);
  return (ch);
}
Exemple #10
0
void print_temc(void){
	print("Current Temperature ");
	get_temp();
	UARTCharPut(UART0_BASE, ui32TempValueC/10 + 48);
	UARTCharPut(UART0_BASE, ui32TempValueC%10 + 48);
	UARTCharPut(UART0_BASE, 96);
	UARTCharPut(UART0_BASE, 'C');
	UARTCharPut(UART0_BASE, ' ');
}
Exemple #11
0
void clrscr(){
	uint32_t i;
	for(i=0;i<MAX_STRING_LENGTH;i++)
			UARTCharPut(UART0_BASE,'\b');
	for(i=0;i<MAX_STRING_LENGTH;i++)
		UARTCharPut(UART0_BASE,' ');
	for(i=0;i<MAX_STRING_LENGTH;i++)
		UARTCharPut(UART0_BASE,'\b');
}
void UARTdeleteLastEntry(int length) {
	int i;

	for (i = 0; i < length; i++) {
		UARTCharPut(UART0_BASE, '\b');
		UARTCharPut(UART0_BASE, ' ');
		UARTCharPut(UART0_BASE, '\b');
	}
}
//##### INTERNAL BEGIN #####
//*****************************************************************************
//
// Send a wakup packet to the remote network processors UART interface.
//
// This function will send a NULL character to the UART interface repeatedly
// in order to awaken the RNP and cause it to start listening for UART packets.
//
// \return None.
//
//*****************************************************************************
void
RemoTIUARTWake(void)
{
#if 0
    bool bIntState;
    uint32_t ui32Ticks;

    //
    // Disable Master interrupts.  Record previous interrupt state to properly
    // restore it later.
    //
    bIntState = IntMasterDisable();

    //
    // Tick counter for tracking how many times we send the NULL character set.
    //
    ui32Ticks = 0;

    //
    // If the TX interrupt is enabled.  If it is assume UART is already
    // awake.  If it is not then wake up the UART on the RNP with a null char.
    //
    if((HWREG(g_ui32UARTBase + UART_O_IM) & 0x20) != UART_IM_TXIM);
    {
        do
        {
            //
            // Send consecutive NULL characters.
            //
            UARTCharPut(g_ui32UARTBase, 0);
            UARTCharPut(g_ui32UARTBase, 0);
            UARTCharPut(g_ui32UARTBase, 0);
            UARTCharPut(g_ui32UARTBase, 0);

            //
            // Delay 10 milliseconds to allow time for RNP to process and wake.
            //
            SysCtlDelay(SysCtlClockGet() / (100 * 3));
            ui32Ticks++;

        //
        // Send the NULL character set until we get a character back or we have
        // tried 10 times to get a response.
        //
        } while((ui32Ticks < 10) & (UARTCharsAvail(g_ui32UARTBase) == 0));
    }

    //
    // Restore the master interrupt enable to it previous state.
    //
    if(!bIntState)
    {
        IntMasterEnable();
    }
#endif // 0
}
Exemple #14
0
void enviarDadosSonares() {
	
	enviaID();
	UARTCharPut(UART_PC_COMM, MESSAGE_TYPE_DADOS_SONAR);
	
	for (int i = 1; i <= 6; i++) {
		UARTCharPut(UART_PC_COMM, ((ultimaLeitura[i] & 0xFF00) >> 8));
		UARTCharPut(UART_PC_COMM, (ultimaLeitura[i] & 0xFF));
	}
}
Exemple #15
0
void sendMotorVelocity(int id_motor, int vel, int comp) {
	
	enviaID();
	
	UARTCharPut(UART_PC_COMM, MESSAGE_TYPE_DEBUG_VELOCIDADE_MOTOR);
	
	UARTCharPut(UART_PC_COMM, (char)(id_motor & 0xFF));
	UARTCharPut(UART_PC_COMM, (char)(vel & 0xFF));
	UARTCharPut(UART_PC_COMM, (char)(comp & 0xFF));
}
Exemple #16
0
int main(void) {
	settemp = 25;
	uint32_t ui32ADC0Value[4];
	SysCtlClockSet(
			SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN
					| SYSCTL_XTAL_16MHZ);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
	ADCSequenceConfigure(ADC0_BASE, 1, ADC_TRIGGER_PROCESSOR, 0);
	ADCSequenceStepConfigure(ADC0_BASE, 1, 0, ADC_CTL_TS);
	ADCSequenceStepConfigure(ADC0_BASE, 1, 1, ADC_CTL_TS);
	ADCSequenceStepConfigure(ADC0_BASE, 1, 2, ADC_CTL_TS);
	ADCSequenceStepConfigure(ADC0_BASE,1,3,ADC_CTL_TS|ADC_CTL_IE|ADC_CTL_END);
	ADCSequenceEnable(ADC0_BASE, 1);
	GPIOPinConfigure(GPIO_PA0_U0RX);
	GPIOPinConfigure(GPIO_PA1_U0TX);
	GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
	GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3);
	UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), 115200,
			(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));
	IntMasterEnable();
	IntEnable(INT_UART0);
	UARTIntEnable(UART0_BASE, UART_INT_RX | UART_INT_RT);
	while(1){
		ADCIntClear(ADC0_BASE, 1);
		ADCProcessorTrigger(ADC0_BASE, 1);
		while(!ADCIntStatus(ADC0_BASE, 1, false))
		{
		}
		ADCSequenceDataGet(ADC0_BASE, 1, ui32ADC0Value);
		ui32TempAvg = (ui32ADC0Value[0] + ui32ADC0Value[1] + ui32ADC0Value[2] + ui32ADC0Value[3] + 2)/4;
		ui32TempValueC = (1475 - ((2475 * ui32TempAvg)) / 4096)/10;
		ui32TempValueF = ((ui32TempValueC * 9) + 160) / 5;
		char m[] = "Current Temperature is    *C, Set Temperature is    *C";
		m[23]=(ui32TempValueC/10 % 10) + '0';
		m[24]=(ui32TempValueC%10) + '0';
		m[49]=(settemp/10 % 10) + '0';
		m[50]=(settemp%10) + '0';
		int i;
		for(i=0;m[i];i++){
			UARTCharPut(UART0_BASE, m[i]);
		}
		if(ui32TempValueC < settemp){
			GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3,8);
		}
		else{
			GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3,2);
		}
		UARTCharPut(UART0_BASE, '\r');
		UARTCharPut(UART0_BASE, '\n');
		SysCtlDelay(1000000);
	}
}
Exemple #17
0
void Timer0IntHandler(void)
{
	int i;
	// Limpia el flag de interrupcion
	TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT);

/*	//Escribo el comando en el YEI
	for(i=0; i<sizeof(todos_normalizados); i++){
				UARTCharPut(UART4_BASE, todos_normalizados[i]);}*/

/*	//Escribo el comando en el YEI
	for(i=0; i<sizeof(giroscopo); i++){
				UARTCharPut(UART4_BASE, giroscopo[i]);}*/

	//Escribo el comando en el YEI
	for(i=0; i<sizeof(aceleracion); i++){
				UARTCharPut(UART4_BASE, aceleracion[i]);}

/*	//Escribo el comando en el YEI
	for(i=0; i<sizeof(magnetometro); i++){
				UARTCharPut(UART4_BASE, magnetometro[i]);}*/

	//Escribo el comando en el YEI
		for(i=0; i<sizeof(orientacion); i++){
					UARTCharPut(UART4_BASE, orientacion[i]);}

	cThisChar='0';
	int contador2=0;
	int contador_end_lines=0;

					do{

			    	cThisChar=UARTCharGet(UART4_BASE);
			    	BuffYEI[contador2]=cThisChar;
			    	contador2=contador2+1;
			    		if((cThisChar == '\n'))
			    			contador_end_lines=contador_end_lines+1;

						} while(contador_end_lines != 2);

		rc = f_open(&Fil, "BuffGPS.TXT", FA_WRITE | FA_OPEN_ALWAYS);	//abre o crea un archivo
		rc = f_lseek(&Fil, Fil.fsize);
		rc = f_write(&Fil, &BuffYEI, contador2, &bw);
		rc = f_sync(&Fil);
		rc = f_close(&Fil);

		if(GPIOPinRead(GPIO_PORTF_BASE, GPIO_PIN_2))
		{
			GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3, 0);
		}
		else
		{
			GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, 4);
		}
}
int Uart0Send(u8 send_data)
{
#ifdef _GLOBAL_DEBUG_ENABLE
	if(send_data == '\n')
		{
		UARTCharPut(UART0_BASE, '\r');
		}
#endif
	UARTCharPut(UART0_BASE, send_data);
	return send_data;
}
void print_str(char a[], int x)
{
	int i=0;
	while(a[i]!='\0')
	{
		if(x == 0)UARTCharPut(UART0_BASE, a[i]);
		if(x == 2)UARTCharPut(UART2_BASE, a[i]);
		if(x == 3)UARTCharPut(UART3_BASE, a[i]);
		i++;
	}
}
Exemple #20
0
//============================================================================//
//==                            整型数发送函数                              ==//
//============================================================================//
//==入口参数: *SArray         指向需要发送的整型数数组                      ==//
//==          Num             整型数据个数                                  ==//
//==出口参数: 无                                                            ==//
//==返回值:   无                                                            ==//
//============================================================================//
void ShortSend(unsigned short *SArray, unsigned int Num)
{
  unsigned int i;
  unsigned char a[2] = {0};
  
  
  for (i=0; i<Num; i++)
  {
    Short2Char(SArray[i], a);
    UARTCharPut(UART_USE_BASE, a[0]);   //低字节放在低地址,先发送低字节
    UARTCharPut(UART_USE_BASE, a[1]);
  }
}
Exemple #21
0
int main(void)
{
	char cThisChar;

	SysCtlClockSet(SYSCTL_SYSDIV_5 | SYSCTL_USE_PLL |SYSCTL_XTAL_16MHZ| SYSCTL_OSC_MAIN );

	//Para el SW1
	/*SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
	GPIODirModeSet(GPIO_PORTF_BASE, 0xFF, GPIO_DIR_MODE_IN);
	GPIOPinIntEnable(GPIO_PORTB_BASE, 0xFF);
	IntEnable(INT_GPIOF);*/

	SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);

	SysCtlPeripheralEnable(SYSCTL_PERIPH_UART1);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);

	GPIOPinConfigure(GPIO_PA0_U0RX);
	GPIOPinConfigure(GPIO_PA1_U0TX);

	GPIOPinConfigure(GPIO_PB0_U1RX);
	GPIOPinConfigure(GPIO_PB1_U1TX);

	GPIOPinTypeUART(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1);
	GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);

	UARTConfigSetExpClk(UART1_BASE, SysCtlClockGet(), 9600,
			(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
					UART_CONFIG_PAR_NONE));

	UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), 9600,
	                        (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
	                         UART_CONFIG_PAR_NONE));

	UARTFIFOLevelSet(UART1_BASE,UART_FIFO_TX7_8,UART_FIFO_RX7_8);
	UARTIntClear(UART1_BASE, UART_INT_TX | UART_INT_RX);
	UARTIntEnable(UART1_BASE, UART_INT_RX);
	UARTFIFOEnable(UART1_BASE);
	IntMasterEnable();
	UARTEnable(UART1_BASE);
	IntEnable(INT_UART1);

		for(n=0; n<sizeof(buferA); n++){
					UARTCharPut(UART1_BASE, buferA[n]);}

		for(m=0; m<sizeof(buferC); m++){
						UARTCharPut(UART1_BASE, buferC[m]);}

	while(1){;}
}
Exemple #22
0
void enviarDadosMPU6050() {
	
	enviaID();
	UARTCharPut(UART_PC_COMM, MESSAGE_TYPE_DADOS_MPU6050);
	
		
		UARTCharPut(UART_PC_COMM, ((((int)roll) & 0xFF00) >> 8));
		UARTCharPut(UART_PC_COMM, (((int)roll) & 0xFF));
	
		UARTCharPut(UART_PC_COMM, ((((int)pitch) & 0xFF00) >> 8));
		UARTCharPut(UART_PC_COMM, (((int)pitch) & 0xFF));
			
		UARTCharPut(UART_PC_COMM, ((((int)yaw) & 0xFF00) >> 8));
		UARTCharPut(UART_PC_COMM, (((int)yaw) & 0xFF));
}
int main(void) 
{
   SetClock();
   ConfigPins();
   SetBaud();
   UARTCharPut(UART0_BASE, 'H');
   UARTCharPut(UART0_BASE, 'I');
    
    while (1)
    {
    	CheckReceivedBits();
    	
	}

}
Exemple #24
0
//============================================================================//
//==                          长整型数发送函数                              ==//
//============================================================================//
//==入口参数: *LArray         指向需要发送的长整型数数组                    ==//
//==          Num             长整型数据个数                                ==//
//==出口参数: 无                                                            ==//
//==返回值:   无                                                            ==//
//============================================================================//
void LongSend(unsigned long *LArray, unsigned int Num)
{
  unsigned int i;
  unsigned char a[4] = {0};
  
  
  for (i=0; i<Num; i++)
  {
    Long2Char(LArray[i], a);
    UARTCharPut(UART_USE_BASE, a[0]);   //低字节放在低地址,先发送低字节
    UARTCharPut(UART_USE_BASE, a[1]);
    UARTCharPut(UART_USE_BASE, a[2]);
    UARTCharPut(UART_USE_BASE, a[3]);
  }
}
//*****************************************************************************
//
// This is the code that gets called when the processor receives a fault
// interrupt.  This simply enters an infinite loop, preserving the system state
// for examination by a debugger.
//
//*****************************************************************************
static void
FaultISR(void)
{
    //
    // Enter an infinite loop.
    //
   UARTCharPut( UART0_BASE, '#' );       
   UARTCharPut( UART0_BASE, '#' );       
   UARTCharPut( UART0_BASE, '#' );       
   UARTCharPut( UART0_BASE, '#' );       
   UARTCharPut( UART0_BASE, '#' );            
   while(1)
   { 
   }
}
Exemple #26
0
void enviarDiagnostico(){
	
	enviaID();
	
	UARTCharPut(UART_PC_COMM, MESSAGE_TYPE_DIAGNOSTICO);
	
	char c = 0x00;
	
	if(motoresInicializados == true){
		
		c |= DIAGNOSTIC_READY;
	}
	
	UARTCharPut(UART_PC_COMM, c);
}
Exemple #27
0
//============================================================================//
//==                           浮点数发送函数                               ==//
//============================================================================//
//==入口参数: *Farray		指向需要发送的浮点数数组                    ==//
//==	      Num		浮点数个数				    ==//
//==出口参数: 无                                                            ==//
//==返回值:   无                                                            ==//
//============================================================================//
void FloatSend(float *FArray, unsigned int Num)
{
  unsigned int i;
  unsigned char a[4] = {0};
  
  
  for (i=0; i<Num; i++)
  {
    Float2Char(FArray[i], a);
    UARTCharPut(UART_USE_BASE, a[0]);
    UARTCharPut(UART_USE_BASE, a[1]);
    UARTCharPut(UART_USE_BASE, a[2]);
    UARTCharPut(UART_USE_BASE, a[3]);
  }
}
//*****************************************************************************
//
// The UART0 interrupt handler.
//
//*****************************************************************************
void
UART0IntHandler(void)
{
    uint32_t ui32Status;

    //
    // Get the interrrupt status.
    //
    ui32Status = ROM_UARTIntStatus(UART0_BASE, true);

    //
    // Clear the asserted interrupts.
    //
    ROM_UARTIntClear(UART0_BASE, ui32Status);

    //
    // Loop while there are characters in the receive FIFO.
    //
    while(ROM_UARTCharsAvail(UART0_BASE))
    {
        //
        // Read the next character from UART0 and sent it to UART3.
        //
        UARTCharPut(UART3_BASE, UARTCharGetNonBlocking(UART0_BASE));
    }
}
void UARTIntHandler(void)
{
	//	UARTCharPut(UART0_BASE, 'a');
	uint32_t ui32Status;
	ui32Status = UARTIntStatus(UART3_BASE, true); //get interrupt status
	//	UARTCharPut(UART0_BASE, 'a');
	UARTIntClear(UART3_BASE, ui32Status); //clear the asserted interrupts

	//	UARTCharPut(UART0_BASE, 'a');
	while(UARTCharsAvail(UART3_BASE)) //loop while there are chars
	{
		//		UARTCharPut(UART0_BASE, 'a');
		char x = UARTCharGetNonBlocking(UART3_BASE);
		UARTCharPut(UART0_BASE, x);
		buf[it++] = x;
	}
	buf[it]='\0';
	char *ptr = strstr(buf,"OK\r\n");
	if(ptr != NULL) {
		SIM908_status = true;
	}
	//	UARTCharPutNonBlocking(UART0_BASE, 'a');
	//  buf[it]='\0';
	//
	//  if(strncmp(buf, "OK", 2) == 0) SIM908_status = true;
	//  else if(strncmp(buf,  "ERROR", 5) == 0) {
	//
	//  }
	//  else {
	//
	//  }
}
Exemple #30
0
//*****************************************************************************
//
//! Print a string to Uart
//!
//!
//! \param UART_Base.
//! \param *s name of string.
//!
//! \return None
//
//*****************************************************************************
void UARTPuts(uint32_t UART_Base, const char *s)
{
	while(*s)
	{
		UARTCharPut(UART_Base, *s++);
	}
}