/* LCD Demo with an LCD having two E lines (E1 and E2): that makes 2x2 lines */ static void LCD_Demo1(void) { uint8_t cnt; uint8_t buf[5]; LCD1_UseDisplay(1); /* switch to upper/first display */ LCD1_Clear(); LCD1_WriteLineStr(1, "LCD Line 1"); LCD1_WriteLineStr(2, "LCD Line 2"); LCD1_UseDisplay(2); /* switch to second display */ LCD1_Clear(); LCD1_WriteLineStr(1, "Hello LCD 3"); LCD1_WriteLineStr(2, "Hello LCD 4"); cnt = 0; for(;;) { UTIL1_Num16uToStr(buf, sizeof(buf), cnt); LCD1_UseDisplay(1); /* switch to first display */ LCD1_GotoXY(2,1); LCD1_WriteString((char*)buf); LCD1_UseDisplay(2); /* switch to second display */ LCD1_GotoXY(2,1); LCD1_WriteString((char*)buf); cnt++; WAIT1_Waitms(100); } }
/*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. ***/ /* Write your code here */ /* For example: for(;;) { } */ LCD1_Clear(); WAIT1_Waitms(1000); LCD1_WriteLineStr(1, "Hello FRDM-KL25z"); for(;;) { uint8_t cnt; uint8_t buf[5]; LCD1_GotoXY(2,1); UTIL1_Num16uToStr(buf, sizeof(buf), cnt); LCD1_WriteString((char*)buf); cnt++; WAIT1_Waitms(100); } /*** 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!!! ***/
static void LCD_Demo1(void) { uint8_t cnt; uint8_t buf[5]; LCD1_Clear(); LCD1_WriteLineStr(1, "Hello FRDM-KL25Z"); cnt = 0; for(;;) { LCD1_GotoXY(2,1); UTIL1_Num16uToStr(buf, sizeof(buf), cnt); LCD1_WriteString((char*)buf); cnt++; WAIT1_Waitms(100); } }
/*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!!! ***/