Beispiel #1
0
/*
** ===================================================================
**     Event       :  Task3_task (module mqx_tasks)
**
**     Component   :  Task3 [MQXLite_task]
**     Description :
**         MQX task routine. The routine is generated into mqx_tasks.c
**         file.
**     Parameters  :
**         NAME            - DESCRIPTION
**         task_init_data  - 
**     Returns     : Nothing
** ===================================================================
*/
void Task3_task(uint32_t task_init_data)
{
	for(;;){
	volatile int16 xr,yr,zr;
	uint16 br;
	static char * st1 ="\n\rAccelerometer x value: "  ;
	static char * st2 ="\n\rAccelerometer y value: " ;
	static char * st3 ="\n\rAccelerometer z value: " ;
	static char * st4 ="\n\rLight Sensor value: " ;
	_lwsem_wait(&i2csem);
	xr=xw, yr=yw, zr=zw, br=bw;
	_lwsem_post(&i2csem);
	Term1_Cls();
	Term1_MoveTo(1,1);
	Term1_SendStr(st1);
	Term1_SendNum(xr);
	Term1_SendStr(st2);
	Term1_SendNum(yr);
	Term1_SendStr(st3);
	Term1_SendNum(zr);
	Term1_SendStr(st4);
	Term1_SendNum(br);
	Term1_SendStr(" ");

	_time_delay_ticks(50);
	}
//Term1_SendStr("\r \n");
	
}
Beispiel #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 */

	bool button=1;

	struct sensor s[6];
	
	int64_t min_avg[6]={23, 14, 15, 15, 18, 23};
	int64_t max_avg[6]={1000, 193, 172, 170, 160, 550};
	int i;
	int64_t error;

  /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
  PE_low_level_init();
  /*** End of Processor Expert internal initialization.                    ***/

  /* Write your code here */
  //Initializeaza timer-ul
  CountTimer_Init((LDD_TUserData *)NULL);
  //Opreste motoarele
  motor(0, 0);
  //Activeaza PWM-ul pentru motoare
  PWM_stanga_Enable();
  PWM_dreapta_Enable();
  
  IR_LED_PutVal(0);
  while(button)
	button=Button_GetVal();
  WAIT1_Waitms(500);
  IR_LED_PutVal(1);

  while(1){
	  
	  readSensors(min_avg, max_avg, s);
	  WAIT1_Waitms(1);
#if DEBUG==TRUE
	  for(i=0; i<6; i++){
		  Term1_SendNum(s[i].value);
		  Term1_SendStr("  ");
	  }
	  for(i=0; i<6; i++){
		  Term1_SendNum(s[i].seen);
		  Term1_SendStr("  ");
	  }
#endif
	  error=propder(s);
#if DEBUG==TRUE
	  Term1_SendNum(error);
	  Term1_SendChar('\n');
	  Term1_SendChar('\r');
#endif
	  drive(error);

  }




  /*** 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!!! ***/
Beispiel #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.                    ***/

  /* Write your code here */
  /* For example: for(;;) { } */
byte r, g, b, charGet = 0;

for(;;){
	Term1_ReadChar(&charGet);
	switch (charGet){
	case 'r' :
		if (r != 255){
			r += 5;
			RedPWM_SetRatio8(r);
		}
		Term1_SendStr("increasing red\n\r");
		break;

	case 'R' :
		if (r != 0){
			r -= 5;
			RedPWM_SetRatio8(r);
		}
		Term1_SendStr("decreasing red\n\r");
		break;

	case 'b' :
		if(b != 255){
			b += 5;
			BluePWM_SetRatio8(b);
		}
		Term1_SendStr("increasing blue\n\r");
		break;

	case 'B' :
		if(b != 0){
			b -= 5;
			BluePWM_SetRatio8(b);
		}
		Term1_SendStr("decreasing blue\n\r");
		break;

	case 'g' :
		if(g != 255){
			g += 5;
			GreenPWM_SetRatio8(g);
		}
		Term1_SendStr("increasing green\n\r");
		break;
	case 'G' :
		if(g != 0){
			g -= 5;
			GreenPWM_SetRatio8(g);
		}
		Term1_SendStr("decreasing green \n\r");
		break;
	}
}
  /*** 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!!! ***/