Esempio n. 1
0
/***********************************************************************************************************************
* Function Name: R_MAIN_UserInit
* Description  : This function adds user code before implementing main function.
* Arguments    : None
* Return Value : None
***********************************************************************************************************************/
void R_MAIN_UserInit(void)
{
    /* Start user code. Do not edit comment generated here */
    EI();
    R_TAU0_Channel0_Start();
    /* End user code. Do not edit comment generated here */
}
Esempio n. 2
0
/***************************************************************

   CALL:    Timer_Init()

   INTRO:   This routine initializes the timers used on the
            the repeater.  These timers are maintained by the
            Atmel CPU Periodic Interval Timer (PIT), which is
            designed to drive the system timer.

   INPUT:   nothing
   OUTPUT:  nothing

****************************************************************/
void  Timer_Init( void )
{

   /*---- initialize interval timer hardware ----*/
   R_TAU0_Channel0_Start();
   
   /*---- clear out the 1ms counter to get to 10ms ----*/
   counter_1ms = 0;  

}
Esempio n. 3
0
/***********************************************************************************************************************
* Function Name: main
* Description  : This function implements main function.
* Arguments    : None
* Return Value : None
***********************************************************************************************************************/
void main(void)
{
    R_MAIN_UserInit();
    /* Start user code. Do not edit comment generated here */
	R_ADC_Start();
	R_TAU0_Channel0_Start();
	R_TAU0_Channel2_Start();
	
	while (1U)
	{
		;
	}
    /* End user code. Do not edit comment generated here */
}
Esempio n. 4
0
/***********************************************************************************************************************
* Function Name: main
* Description  : This function implements main function.
* Arguments    : None
* Return Value : None
***********************************************************************************************************************/
void main(void)
{
    R_MAIN_UserInit();
    /* Start user code. Do not edit comment generated here */
   	R_ADC_Start();
	R_TAU0_Channel0_Start();
	R_TAU0_Channel2_Start();
	
	while (1U)
	{
		if(get_speed_change_flag()){
			DI();
			reset_speed_change_flag();
			EI();
			u_calc_step_speed();
		}
	}
    /* End user code. Do not edit comment generated here */
}
void SpeakerON(uint8_t left, uint8_t right)
{
    R_TAU0_Channel0_Start();
    
    PMC1 &= ~(3<<6);
    G_AudioPWMOutCount = 0;
    
    if(!right)
    {
        // Turn off right
        TT0 |= _0002_TAU_CH1_STOP_TRG_ON;
        TOE0 &= ~_0002_TAU_CH1_OUTPUT_ENABLE;
    }
    
    if(!left) 
    {
        // Turn off left
        TT0 |= _0004_TAU_CH2_STOP_TRG_ON;
	    TOE0 &= ~_0004_TAU_CH2_OUTPUT_ENABLE;
    }
}
/***********************************************************************************************************************
* Function Name: main
* Description  : This function implements main function.
* Arguments    : None
* Return Value : None
***********************************************************************************************************************/
void main(void)
{
    R_MAIN_UserInit();
    /* Start user code. Do not edit comment generated here */

    int transmit_count = 0;
	R_UART2_Create();
	R_UART2_Start();
	uart2Status = R_UART2_Receive(&uart2RxBuf[0],1);	// Prime UART2 Rx

	R_TAU0_Create();
	R_TAU0_Channel0_Start();

	R_PORT_Create();

	R_ADC_Create();

	while (1U)
	{
		if(oneSec)
		{
			if(transmit)
				uart2Status = R_UART2_Send(uart2TxBuf, 1);

			counter++;
			oneSec = !oneSec;
		}

		if(uart2RxFlag)
		{
			uart2RxFlag = 0U;

			if(uart2RxBuf[0] == 'b')
			{
				uart2TxBuf[0] = counter;
				transmit_count = convertToNum(uart2TxBuf); //convert the ASCII symbols to integers instead.
				uart2Status = R_UART2_Send(uart2TxBuf, transmit_count);
			}
			else
			if(uart2RxBuf[0] == 'l')
				P7_bit.no7 = !P7_bit.no7;
			else
			if(uart2RxBuf[0] == 'a')
			{
				uint8_t adcvalue = 0;
				R_ADC_Start();
				while(!adc_done_flag); //wait for interrupt
				adc_done_flag = 0;
				R_ADC_Get_Result_8bit(&adcvalue);
				uart2TxBuf[0] = adcvalue;
				transmit_count = convertToNum(uart2TxBuf); //convert the ASCII symbols to integers instead.
				R_ADC_Stop();
				uart2Status = R_UART2_Send(uart2TxBuf, transmit_count);
			}
			else
			if(uart2RxBuf[0] == 't')
				transmit = !transmit;
			else
				uart2TxBuf[0] = uart2RxBuf[0];

			// Prime UART2 Rx
			uart2Status = R_UART2_Receive(uart2RxBuf, 1);
		}

		//If a character has been transmitted
		if (uart2TxFlag)
		{
			// End of UART2 transmit
			uart2TxFlag = 0U;   // clear tx flag
		}
	}

	R_UART2_Stop();
	R_TAU0_Channel0_Stop();
	//R_ADC_Stop();
	/* End user code. Do not edit comment generated here */
}