Exemple #1
0
/**
 * @brief Application task handler
 */
static void app_task(void)
{
    uint8_t number_of_bytes_to_be_transmitted;
	uint8_t stop_data;
   if(Wireshark_Settings == INIT_STATE)
   {
        uint8_t input_channel = sio_getchar();
        sniffer_config_select(CHANNEL_SELECT_ID,input_channel);
        Wireshark_Settings = SET_START;
   }

   if(Wireshark_Settings == SET_START)
   {
        number_of_bytes_to_be_transmitted = sio_getchar();
        if(number_of_bytes_to_be_transmitted == 0x01)
        {
           sniffer_config_select(START_CAPTURE_ID,number_of_bytes_to_be_transmitted);
           Wireshark_Settings = WS_RESTART;
           sio_rx_data[0] = INIT_VALUE;
        }
   }

   if(Wireshark_Settings == WS_RESTART)
   {
        number_of_bytes_to_be_transmitted = pal_sio_rx(SIO_CHANNEL, sio_rx_data, 1);
        if((number_of_bytes_to_be_transmitted  == 1) && (sio_rx_data[0] == 0x02))
        {
                sio_rx_data[0] = INIT_VALUE;
                Wireshark_Settings = INIT_STATE;
                stop_data = STOP_CAP;
                while((number_of_bytes_to_be_transmitted = pal_sio_tx(SIO_CHANNEL, &stop_data, 1)) !=1);
        }
   }
}
Exemple #2
0
/**
 * Gets a NUL-terminated line of text from the serial console.
 * Ends with a '\n' if a whole line was read. If EOF (CTRL-D) is read, or the
 * buffer is filled, it does not end with a '\n'.
 *
 * NOTE: This routine blocks waiting for input. While this is arguably not
 * allowed in this project, it does not matter, because this routine is never
 * called by the watch program. It is simply included for completeness and
 * debugging.
 *
 * @param buffer to put the read string
 * @param bufsize the maximum number of chars to read, counting the ending NUL.
 * @return the number of characters read, not counting the ending NUL.
 */
int sio_gets( char *buffer, unsigned int bufsize ) {
	char	*bp = buffer;

	/*
	** Loop as long as there is space in the buffer, leaving room for
	** the terminating null byte.
	*/
	while( bufsize > 1 ) {
		char	ch = 0;

		/*
		** Get a character and see if it was a CTRL-D
		*/
		while(!(ch = sio_getchar()))
		{
			sleep();
		}
		if( ch == EOF ) {
			/* Activate without storing anything */
			break;
		}

		/* Store in the caller's buffer */
		*bp++ = ch;
		bufsize -= 1;

		/* If this is a newline, activate */
		if( ch == '\n' ) {
			break;
		}
	}

	/* Null-terminate the buffer and return */
	*bp = '\0';
	return bp - buffer;
}
Exemple #3
0
void
main(void)
{
        char inkey;

	*LED = 0;

	TIMER[TC_INCREMENT] = 1;
	TIMER[TC_APPLY] = (1<<TC_INCREMENT);

#if 1
	TIMER[TC_OCP1_START] = 0;
	TIMER[TC_OCP1_STOP]  = (1<<(TIMER_BITS-2))-1;
	TIMER[TC_OCP2_START] = (1<<(TIMER_BITS-2));
	TIMER[TC_OCP2_STOP]  = (1<<(TIMER_BITS-1))-1;
#else
	TIMER[TC_OCP1_START] = 0;
	TIMER[TC_OCP1_STOP]  = (1<<(TIMER_BITS-1))-1;
	TIMER[TC_OCP2_START] = (1<<(TIMER_BITS-1));
	TIMER[TC_OCP2_STOP]  = (1<<(TIMER_BITS-0))-1;
#endif

#if 0
        /* icp in the same time window as ocp */
	TIMER[TC_ICP1_START] = 0;
	TIMER[TC_ICP1_STOP]  = (1<<(TIMER_BITS-2))-1;
	TIMER[TC_ICP2_START] = (1<<(TIMER_BITS-2));
	TIMER[TC_ICP2_STOP]  = (1<<(TIMER_BITS-1))-1;
#else
        /* icp wide open window */
	TIMER[TC_ICP1_START] = 0;
	TIMER[TC_ICP1_STOP]  = (1<<(TIMER_BITS))-1;
	TIMER[TC_ICP2_START] = 0;
	TIMER[TC_ICP2_STOP]  = (1<<(TIMER_BITS))-1;
#endif
	TIMER[TC_INC_MIN]    = 300;
	TIMER[TC_INC_MAX]    = 600;
	
	TIMER[TC_ICP1]       = 173; // setpoint ICP1
	TIMER[TC_ICP2]       = 689; // setpoint ICP2

	TIMER[TC_CONTROL] = (1<<TCTRL_AND_OR_OCP1) | (1<<TCTRL_AND_OR_OCP2)
	                  | (1<<TCTRL_AND_OR_ICP1) | (1<<TCTRL_AND_OR_ICP2)
	                  | (1<<TCTRL_IE_OCP1)     | (1<<TCTRL_IE_OCP2)
	                  | (1<<TCTRL_IE_ICP1)     | (1<<TCTRL_IE_ICP2)
	                  | (1<<TCTRL_AFCEN_ICP1)  | (0<<TCTRL_AFCINV_ICP1)
	                  | (0<<TCTRL_AFCEN_ICP2)  | (0<<TCTRL_AFCINV_ICP2)
	                  | (1<<TCTRL_XOR_OCP1)    | (1<<TCTRL_XOR_OCP2)
	                  | (1<<TCTRL_XOR_ICP1)    | (1<<TCTRL_XOR_ICP2)
	                  | (1<<TCTRL_ENABLE_OCP1) | (1<<TCTRL_ENABLE_OCP2)
	                  | (1<<TCTRL_ENABLE_ICP1) | (1<<TCTRL_ENABLE_ICP2)
	                  ;

        TIMER[TC_APPLY] = (1<<TC_CONTROL)
                        | (1<<TC_OCP1_START) | (1<<TC_OCP1_STOP) 
                        | (1<<TC_OCP2_START) | (1<<TC_OCP2_STOP)
                        | (1<<TC_ICP1_START) | (1<<TC_ICP1_STOP) 
                        | (1<<TC_ICP2_START) | (1<<TC_ICP2_STOP)
                        | (1<<TC_INC_MIN)    | (1<<TC_INC_MAX)
                        | (1<<TC_ICP1)       | (1<<TC_ICP2)
                        ;

        /* isr_register_handler(interrput number, *isr_link) */
        /* 2 is frame interrupt 
        ** 3 is serial interrupt
        ** 4 is timer interrupt
        */
	isr_register_handler(4, &timer_isr); 
	asm("ei");

        for(;;)
	{
		DELAY(2000000);
		inkey = sio_getchar(0);
		switch(inkey)
		{
		  case 3:
		      exit(0); /* CTRL+C */
                  case '-':
                      TIMER[TC_INCREMENT] -= 1;
                      TIMER[TC_APPLY] = (1<<TC_INCREMENT);
                      break;
                  case '+':
                      TIMER[TC_INCREMENT] += 1;
                      TIMER[TC_APPLY] = (1<<TC_INCREMENT);
                      break;
                  case ',':
                      TIMER[TC_INCREMENT] -= 100;
                      TIMER[TC_APPLY] = (1<<TC_INCREMENT);
                      break;
                  case '.':
                      TIMER[TC_INCREMENT] += 100;
                      TIMER[TC_APPLY] = (1<<TC_INCREMENT);
                      break;
                }
                switch(inkey)
                {
                  case '\r':
                  case '-':
                  case '+':
                  case ',':
                  case '.':
                      print_timer();
                      break;
                }

	}
}
Exemple #4
0
int
UARTClass::read(void)
{

  return (sio_getchar(1));
}