Exemple #1
0
/*
** ===================================================================
**     Method      :  CLS1_SendNum16s (component Shell)
**     Description :
**         Sends a 16bit signed number to the given I/O
**     Parameters  :
**         NAME            - DESCRIPTION
**         val             - number to print
**         io              - I/O callbacks to be used for printing.
**     Returns     : Nothing
** ===================================================================
*/
void CLS1_SendNum16s(int16_t val, CLS1_StdIO_OutErr_FctType io)
{
  unsigned char buf[sizeof("-12345")];

  UTIL1_Num16sToStr(buf, sizeof(buf), val);
  CLS1_SendStr(buf, io);
}
Exemple #2
0
static void TURN_PrintStatus(const CLS1_StdIOType *io) {
  unsigned char buf[32];

  CLS1_SendStatusStr((unsigned char*)"turn", (unsigned char*)"\r\n", io->stdOut);

#if PL_HAS_QUADRATURE
  UTIL1_Num16uToStr(buf, sizeof(buf), TURN_Steps90);
  UTIL1_strcat(buf, sizeof(buf), (unsigned char*)" steps\r\n");
  CLS1_SendStatusStr((unsigned char*)"  steps90", buf, io->stdOut);

  UTIL1_Num16uToStr(buf, sizeof(buf), TURN_StepsFwBw);
  UTIL1_strcat(buf, sizeof(buf), (unsigned char*)" steps\r\n");
  CLS1_SendStatusStr((unsigned char*)"  stepsfw", buf, io->stdOut);

  UTIL1_Num16sToStr(buf, sizeof(buf), Q4CLeft_GetPos());
  UTIL1_strcat(buf, sizeof(buf), (unsigned char*)", ");
  UTIL1_strcatNum16u(buf, sizeof(buf), Q4CLeft_NofErrors());
  UTIL1_strcat(buf, sizeof(buf), (unsigned char*)" errors\r\n");
  CLS1_SendStatusStr((unsigned char*)"  left pos", buf, io->stdOut);
  
  UTIL1_Num16sToStr(buf, sizeof(buf), Q4CRight_GetPos());
  UTIL1_strcat(buf, sizeof(buf), (unsigned char*)", ");
  UTIL1_strcatNum16u(buf, sizeof(buf), Q4CRight_NofErrors());
  UTIL1_strcat(buf, sizeof(buf), (unsigned char*)" errors\r\n");
  CLS1_SendStatusStr((unsigned char*)"  right pos", buf, io->stdOut);
#else
  UTIL1_Num16uToStr(buf, sizeof(buf), TURN_DutyPercent);
  UTIL1_strcat(buf, sizeof(buf), (unsigned char*)"%\r\n");
  CLS1_SendStatusStr((unsigned char*)"  duty", buf, io->stdOut);

  UTIL1_Num16uToStr(buf, sizeof(buf), TURN_Time90ms);
  UTIL1_strcat(buf, sizeof(buf), (unsigned char*)" ms\r\n");
  CLS1_SendStatusStr((unsigned char*)"  time90", buf, io->stdOut);

  UTIL1_Num16uToStr(buf, sizeof(buf), TURN_StepFwBwMs);
  UTIL1_strcat(buf, sizeof(buf), (unsigned char*)" ms\r\n");
  CLS1_SendStatusStr((unsigned char*)"  timefw", buf, io->stdOut);
#endif
}
Exemple #3
0
/*lint -save  -e970 Disable MISRA rule (6.3) checking. */
int main(void)
/*lint -restore Enable MISRA rule (6.3) checking. */
{
  /* Write your local variable definition here */

  /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
  PE_low_level_init();
  /*** End of Processor Expert internal initialization.                    ***/
  //printf("HOLA MUNDO");
  /* Write your code here */
  /* For example: for(;;) { } */
  byte MPU_PWR=0x6B;
  int16_t AcX,AcY,AcZ,GcX,GcY,GcZ,temp;
  char buffer[15];
  uint8_t aux[15];
  //Inicializando la comunicacion I2C
  GI2C1_Init();
  GI2C1_SelectSlave(MPU);
  GI2C1_WriteByteAddress8(MPU,MPU_PWR,0);
  //Inicializando la comunicacion LCD
  LCD1_UseDisplay(1);
  LCD1_Clear();

    for(;;) {
      //Lectura de los Valores del Acelerometro
	  GI2C1_ReadByteAddress8(MPU,0x3B,&buffer[1]);
	  mywait_Waitms(2);
	  GI2C1_ReadByteAddress8(MPU,0x3C,&buffer[2]);
	  mywait_Waitms(2);
	  AcX=buffer[1];
	  AcX=AcX<<8;
	  AcX=AcX | buffer[2];

	  GI2C1_ReadByteAddress8(MPU,0x3D,&buffer[3]);
	  mywait_Waitms(2);
	  GI2C1_ReadByteAddress8(MPU,0x3E,&buffer[4]);
	  mywait_Waitms(2);
	  AcY=buffer[3];
	  AcY=AcY<<8;
	  AcY=AcY | buffer[4];

      GI2C1_ReadByteAddress8(MPU,0x3F,&buffer[5]);
	  mywait_Waitms(2);
	  GI2C1_ReadByteAddress8(MPU,0x40,&buffer[6]);
	  mywait_Waitms(2);
	  AcZ=buffer[5];
	  AcZ=AcZ<<8;
	  AcZ=AcZ | buffer[6];
	  printf("Acelerometro\nX=%d\tY=%d\tZ=%d\n", AcX,AcY,AcZ);
	  LCD1_WriteLineStr(1,"Acelerometro:   ");
	  UTIL1_Num16sToStr(aux, sizeof(aux), AcX);
	  LCD1_WriteLineStr(2,"                ");
	  LCD1_GotoXY(2,1);
	  LCD1_WriteString("X=");
	  LCD1_GotoXY(2,4);
	  LCD1_WriteString((char*)aux);
	  mywait_Waitms(2000);
	  UTIL1_Num16sToStr(aux, sizeof(aux), AcY);
	  LCD1_WriteLineStr(2,"                ");
	  LCD1_GotoXY(2,1);
	  LCD1_WriteString("Y=");
	  LCD1_GotoXY(2,4);
	  LCD1_WriteString((char*)aux);
	  mywait_Waitms(2000);
	  UTIL1_Num16sToStr(aux, sizeof(aux), AcZ);
	  LCD1_WriteLineStr(2,"                ");
	  LCD1_GotoXY(2,1);
	  LCD1_WriteString("Z=");
	  LCD1_GotoXY(2,4);
	  LCD1_WriteString((char*)aux);
	  mywait_Waitms(2000);

	  //Capturando los valores del Giroscopio
	  GI2C1_ReadByteAddress8(MPU,0x43,&buffer[7]);
	  mywait_Waitms(10);
	  GI2C1_ReadByteAddress8(MPU,0x44,&buffer[8]);
	  mywait_Waitms(10);
	  GcX=buffer[7];
	  GcX=GcX<<8;
	  GcX=GcX | buffer[8];

	  GI2C1_ReadByteAddress8(MPU,0x45,&buffer[9]);
	  mywait_Waitms(10);
	  GI2C1_ReadByteAddress8(MPU,0x46,&buffer[10]);
	  mywait_Waitms(10);
	  GcY=buffer[9];
	  GcY=GcY<<8;
	  GcY=GcY | buffer[10];

	  GI2C1_ReadByteAddress8(MPU,0x47,&buffer[11]);
	  mywait_Waitms(10);
	  GI2C1_ReadByteAddress8(MPU,0x48,&buffer[12]);
	  mywait_Waitms(10);
	  GcZ=buffer[11];
	  GcZ=GcZ<<8;
	  GcZ=GcZ | buffer[12];
	  printf("Giroscopio\nGX=%d\tGY=%d\tGZ=%d\n", GcX,GcY,GcZ);
	  LCD1_WriteLineStr(1,"Giroscopio:     ");
	  UTIL1_Num16sToStr(aux, sizeof(aux), GcX);
	  LCD1_WriteLineStr(2,"                ");
	  LCD1_GotoXY(2,1);
	  LCD1_WriteString("Gx=");
	  LCD1_GotoXY(2,5);
	  LCD1_WriteString((char*)aux);
	  mywait_Waitms(2000);
	  UTIL1_Num16sToStr(aux, sizeof(aux), GcY);
	  LCD1_WriteLineStr(2,"                ");
	  LCD1_GotoXY(2,1);
	  LCD1_WriteString("Gy=");
	  LCD1_GotoXY(2,5);
	  LCD1_WriteString((char*)aux);
	  mywait_Waitms(2000);
	  UTIL1_Num16sToStr(aux, sizeof(aux), GcZ);
	  LCD1_WriteLineStr(2,"                ");
	  LCD1_GotoXY(2,1);
	  LCD1_WriteString("Gz=");
	  LCD1_GotoXY(2,5);
	  LCD1_WriteString((char*)aux);
	  mywait_Waitms(2000);

	  //Capturando los valores de temperatura
	  GI2C1_ReadByteAddress8(MPU,0x41,&buffer[13]);
	  mywait_Waitms(10);
	  GI2C1_ReadByteAddress8(MPU,0x42,&buffer[14]);
	  mywait_Waitms(10);
	  temp=buffer[13];
	  temp=temp<<8;
	  temp=temp | buffer[14];
	  temp=(temp/340)+37;
	  printf("Temperatura = %d\n", temp);
	  LCD1_WriteLineStr(1,"Temperatura:   ");
	  UTIL1_Num16sToStr(aux, sizeof(aux), temp);
	  LCD1_WriteLineStr(2,"                ");
	  LCD1_GotoXY(2,5);
	  LCD1_WriteString((char*)aux);
	  mywait_Waitms(2000);


	  //Recibiendo los datos de GPS del Bluetooth
	  myserial_RecvBlock(btbuffer,sizeof(btbuffer),&rx);
	  strcpy(auxbuffer, btbuffer);
	  char *token;
	  token = strtok(auxbuffer, ",");
	  int i = 0;
	  while(token != NULL)
	  {
		  if(i==0)
		  {
			  if(token==99)
			  {
				  token = NULL;
			  }
		  }
		  if(i == 2){
			printf( "Latitud: %s\n", token );
			LCD1_WriteLineStr(1,"Latitud:   ");
			LCD1_WriteLineStr(2,"                ");
			LCD1_WriteLineStr(2,token);
			mywait_Waitms(2000);
		  }
		  if(i == 3){
			printf( "Longitud: %s\n", token );
			LCD1_WriteLineStr(1,"Longitud:  ");
			LCD1_WriteLineStr(2,"                ");
			LCD1_WriteLineStr(2,token);
			mywait_Waitms(2000);
		  }
		  if(i == 4){
			token=strtok(token,">");
			printf( "Altura: %s\n", token );
			LCD1_WriteLineStr(1,"Altura:    ");
			LCD1_WriteLineStr(2,"                ");
			LCD1_WriteLineStr(2,token);
			mywait_Waitms(2000);
		  }
		  token = strtok(NULL, ",");
		  i++;
	  }
  	  WAIT1_Waitms(1000);
    }

  /*** Don't write any code pass this line, or it will be deleted during code generation. ***/
  /*** RTOS startup code. Macro PEX_RTOS_START is defined by the RTOS component. DON'T MODIFY THIS CODE!!! ***/
  #ifdef PEX_RTOS_START
    PEX_RTOS_START();                  /* Startup of the selected RTOS. Macro is defined by the RTOS component. */
  #endif
  /*** End of RTOS startup code.  ***/
  /*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/
  for(;;){}
  /*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/
} /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/