void initialize_CLS (void)  //Initial PmodCLS setup.
{
	putsUART2 (enable_display);
	putsUART2 (set_cursor);
	putsUART2 (home_cursor);
	putsUART2 (wrap_line);
}
Exemple #2
0
void broadcast_message(const char * message) {
	while(BusyUART2());		// Wait until previous transmission is finished
	putsUART2 ((unsigned int *)message);
	while(BusyUART2());		// Wait until previous transmission is finished

	while(BusyUART1());		// Wait until previous transmission is finished
	putsUART1 ((unsigned int *)message);
	while(BusyUART1());		// Wait until previous transmission is finished
}
int main (void)
{
	unsigned int pb_clock = 0;
	unsigned char message[] = "Ready to receive...", data = '\0';


	// extern inline unsigned int __attribute__((always_inline)) SYSTEMConfigPerformance(unsigned int sys_clock)
	pb_clock = SYSTEMConfigPerformance (SYSTEM_CLOCK);


	setup_ports ();


	//Uncomment if using an additional UART to receive from:
	//setup_UART1 (pb_clock);
	setup_UART2( pb_clock);


	
	initialize_CLS ();


	putsUART2 (message);


	while (1)
	{
		//To receive from another UART and display on PmodCLS: 
		//uncomment and setup receiving UART.
		/*
		if (DataRdyUART1 ()) //Checks if data is available to be read from UART
		{
			data = ReadUART1 (); //Reads one character from UART
			putcUART2 (data); //Displays character onto PmodCLS
		}
		*/
	}


	return 0;
}
Exemple #4
0
// ------------------------------------------------------------------------------------------------
// TaskCapteurs_Main()
// ------------------------------------------------------------------------------------------------
void TaskCapteurs_Main(void *p_arg)
{
	INT8U	Err = 0;				// Var to get error status
	CPU_INT16U  GP2Data;

	putsUART2("OUFFF TEAM 2010 : Capteurs online\n");

	// We set the current color
	OSTimeDlyHMSM(0, 0, 0, 500);
	TaskCapteurs_ReadColor();

	#ifdef _TARGET_STARTER_KIT
		OSTimeDlyHMSM(0, 0, 0, 500);	LED_Off(1);	
		OSTimeDlyHMSM(0, 0, 0, 500);	LED_Off(2);	
		OSTimeDlyHMSM(0, 0, 0, 500);	LED_Off(3);
	#else
	// Comment this part to disable start button detection
		// We're waiting for Start button release
		while(OS_FALSE == TaskCapteurs_IsStartButtonPressed())
			OSTimeDly(1);	// Release proc

		// We're waiting for start button activation
		while(OS_TRUE == TaskCapteurs_IsStartButtonPressed())
			OSTimeDly(1);	// Release proc 
	#endif

	// StartButton has been pressed
	
	OSFlagPost(AppFlags, APP_PARAM_APPFLAG_START_BUTTON, OS_FLAG_SET, &Err); 

	while(OS_TRUE)	// Main task: we check all other sensors
	{
		OSTimeDlyHMSM(0, 0, 0, 10);	

		TaskCapteurs_CheckBumpers();			// Check for bumpers status
		TaskCapteurs_CheckClicClic();			// Check for clic clic

	}
}
int16_t main(void)
{
    int PWM_ON = '0';
    int Sent_Byte = '0';

    /* Configure the oscillator for the device */
    ConfigureOscillator();

    /* Initialize IO ports and peripherals */
    InitApp();

    /* TODO <INSERT USER APPLICATION CODE HERE> */

    while(1)
    {

        if(ten_ms_flag == '11' && Sent_Byte == '0'){
            Sent_Byte = '1';
            while(BusyUART2());
            putsUART2("50");
            while(BusyUART2());
            //OC1CON = 0x0005;
        }

        if (ten_ms_flag == '20' && PWM_ON == '0' ){
            PWM_ON = '1';
            OC1CON = 0x0005;
        }

        if(ten_ms_flag == '25'){
            ten_ms_flag=0;
            PWM_ON = '0';
            Sent_Byte = '0';
            OC1CON = 0x0000;
        }

    }
}
/**************************************************************************************************
  Title: 
    Delay Test
    
  Version: 
    0.1
    
  Filename: 
    delaytest-0.1.c
    
  Author(s): 
    mkobit
    
  Purpose of Program: 
    Test delay protocol for each of the DelayS, DelayMs, and DelayUs
    
  How to build: 
    delay.c
    
  Update History: 
    4/30/12: Having problems testing with the peripheral bus on the PCB, need to figure out what is going on
            * Found out that core timer does not use peripheral bus, it uses system clock
    
**************************************************/
int main(void)
{
  int nc;
  unsigned int pbFreq;
  long int delayed = 0;
  char buffer[50] = "0";

  pbFreq = SYSTEMConfigPerformance(SYSTEM_FREQUENCY);
  //pbFreq = SYSTEM_FREQUENCY;
  OpenUART2(UART_EN | UART_NO_PAR_8BIT | UART_1STOPBIT, UART_RX_ENABLE | UART_TX_ENABLE,
          (pbFreq/16/BAUDRATE) - 1);
  DelayInit(SYSTEM_FREQUENCY);
  putsUART2(CLEAR_VT);
  DelayMs(1500);
  putsUART2("Beginning in 3...\r\n");
  //printf("Hi\n");
  DelayS(1);
  putsUART2("Beginning in 2...\r\n");
  DelayUs(50000);
  DelayMs(995);
  putsUART2("Beginning in 1...\n\r");
  DelayS(1);
  putsUART2("Start!\n\r");
  while(1) {
    DelayMs(770);
    DelayS(2);
    DelayUs(230000);
    DelayMs(2000);
    delayed += 5;
    itoa(buffer, delayed, 10);
    putsUART2(buffer);
    putsUART2(" s\r\n");
  }

  //putsUART2(myHelloStr);

  return nc;
}