Exemplo n.º 1
0
static void US_PrintStatus(const CLS1_StdIOType *io) {
  uint8_t buf[16];
  uint16_t cm;
  
  cm = US_usToCentimeters(usDevice.lastValue_us, 22);
  CLS1_SendStatusStr((unsigned char*)"ultrasonic", (unsigned char*)"\r\n", io->stdOut);
  UTIL1_Num16uToStr(buf, sizeof(buf), usDevice.lastValue_us);
  UTIL1_strcat(buf, sizeof(buf), (unsigned char*)"\r\n");
  CLS1_SendStatusStr((unsigned char*)"  us", buf, io->stdOut);
  UTIL1_Num16uToStr(buf, sizeof(buf), cm);
  UTIL1_strcat(buf, sizeof(buf), (unsigned char*)"\r\n");
  CLS1_SendStatusStr((unsigned char*)"  cm", buf, io->stdOut);
}
Exemplo n.º 2
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.                    ***/
  /* Write your code here */
  /* For example: for(;;) { } */

  /*** 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(;;){
	  
	  (void)AD1_Measure(TRUE); /* do conversion and wait for the result */
	  (void)AD1_GetValue16(&value); /* get the result into value variable */
	  UTIL1_Num16uToStr(buf, sizeof(buf), value); /* transform into string */
	  i=0;
	  while(buf[i]!=0) {
	  RxBuf_Put(buf[i]); /* write string */
	  i++;
	  }
	  APP_Run();
  }
  /*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/
} /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/
Exemplo n.º 3
0
/* 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);
  }
}
Exemplo n.º 4
0
/*
** ===================================================================
**     Method      :  CLS1_SendNum16u (component Shell)
**     Description :
**         Sends a 16bit unsigned 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_SendNum16u(uint16_t val, CLS1_StdIO_OutErr_FctType io)
{
  unsigned char buf[sizeof("12345")];

  UTIL1_Num16uToStr(buf, sizeof(buf), val);
  CLS1_SendStr(buf, io);
}
Exemplo n.º 5
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.                    ***/

  /* 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!!! ***/
Exemplo n.º 6
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
}
Exemplo n.º 7
0
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);
  }
}