Пример #1
0
int main(void) {
    CPU_PRESCALE(0);

    GBA_DDR &= ~(1<<MISO_BIT);
    GBA_DDR |= (1<<MOSI_BIT) | (1<<CLK_BIT);
    CLK_HIGH();

    usb_init();
    while (!usb_configured());
    _delay_ms(1000);

    INIT_TIMER();

    while (1) {
        if (usb_serial_available() >= 4) {
            uint32_t data = 0;
            data |= (uint32_t)usb_serial_getchar()<<24;
            data |= (uint32_t)usb_serial_getchar()<<16;
            data |= (uint32_t)usb_serial_getchar()<<8;
            data |= (uint32_t)usb_serial_getchar();
            xfer(&data);
            usb_serial_putchar((data>>24) & 0xff);
            usb_serial_putchar((data>>16) & 0xff);
            usb_serial_putchar((data>>8) & 0xff);
            usb_serial_putchar(data & 0xff);
            usb_serial_flush_output();
        }
    }
Пример #2
0
/* delay(milliseconds)
 * Pauses for (at least) the requested number of milliseconds.
 */
static cell AMX_NATIVE_CALL n_delay(AMX *amx, const cell *params)
{
  unsigned long stamp;

  (void)amx;
  assert(params[0]==(int)sizeof(cell));

  INIT_TIMER();
  stamp=gettimestamp();
  while (gettimestamp()-stamp < (unsigned long)params[1])
    /* nothing */;
  return 0;
}
Пример #3
0
/* tickcount(&granularity)
 * Returns the number of milliseconds since start-up. For a 32-bit cell, this
 * count overflows after approximately 24 days of continuous operation.
 */
static cell AMX_NATIVE_CALL n_tickcount(AMX *amx, const cell *params)
{
  cell *cptr;

  assert(params[0]==(int)sizeof(cell));

  INIT_TIMER();
  cptr=amx_Address(amx,params[1]);
  #if defined __WIN32__ || defined _WIN32 || defined WIN32
    *cptr=1000;               	/* granularity = 1 ms */
  #else
    *cptr=(cell)CLOCKS_PER_SEC;	/* in Unix/Linux, this is often 100 */
  #endif
  return gettimestamp() & 0x7fffffff;
}
Пример #4
0
void test_function_four(co_stream s_in, co_stream s_out)
{
    int i;
    int hi = 10000000;
	int32   	err;
	
    co_stream_open(s_in, O_RDONLY, INT_TYPE(32));
    co_stream_open(s_out, O_WRONLY, INT_TYPE(32));

#if defined(XPAR_MICROBLAZE_ID)
    printf ("\r\n===================Running on MicroBlaze================\r\n");
    INIT_TIMER();
    StartIF_TS = XTmrCtr_GetValue (&TimerInst, 0);
#endif

    HW_STREAM_WRITE(test_function_four, s_out, hi);
    
#if defined(XPAR_MICROBLAZE_ID)
    FinishIF_TS = XTmrCtr_GetValue (&TimerInst, 0);
    Time_Com = (FinishIF_TS - StartIF_TS)/TIMER_FREQ_MILLI; 
#endif

#if defined(XPAR_MICROBLAZE_ID)
    StartIF_TS = XTmrCtr_GetValue (&TimerInst, 0);
#endif
   	HW_STREAM_READ(test_function_four, s_in, hi, err);

    printf("Rez = %d\n", hi);	
#if defined(XPAR_MICROBLAZE_ID)

    FinishIF_TS = XTmrCtr_GetValue (&TimerInst, 0);

	/* Print timpul de comunicatie */
	printf("%d\n", 	Time_Com);

	/* Print timpul de executie */
	TimeSA = (FinishIF_TS - StartIF_TS)/TIMER_FREQ_MILLI; 
	printf("%d\n", 	TimeSA);

    printf("SERIALSTOP");		   

#endif
   
    HW_STREAM_CLOSE(test_function_four, s_in);
    HW_STREAM_CLOSE(test_function_four, s_out);
}
Пример #5
0
void default_clock()
{
    clock_enabled = 0;
    time1_format = NULL;
    time1_timezone = NULL;
    time2_format = NULL;
    time2_timezone = NULL;
    INIT_TIMER(clock_timer);
    time_tooltip_format = NULL;
    time_tooltip_timezone = NULL;
    clock_lclick_command = NULL;
    clock_mclick_command = NULL;
    clock_rclick_command = NULL;
    clock_uwheel_command = NULL;
    clock_dwheel_command = NULL;
    time1_has_font = FALSE;
    time1_font_desc = NULL;
    time2_has_font = FALSE;
    time2_font_desc = NULL;
    buf_time[0] = 0;
    buf_date[0] = 0;
    buf_tooltip[0] = 0;
}
Пример #6
0
int main()
{
	int out; 

	printf("Microblaze:\n");
    INIT_TIMER();
    StartIF_TS = XTmrCtr_GetValue (&TimerInst, 0);

    function_eight(10000000, 10000000, &out);
	
	printf("Rez = %d\n", out);

    FinishIF_TS = XTmrCtr_GetValue (&TimerInst, 0);
    TimeSA = (FinishIF_TS - StartIF_TS)/TIMER_FREQ_MILLI; 
	/* Timp comunicatie */	
	printf("0\n");

	/* Timp executie */
    printf ("%d\n", TimeSA);

    printf("SERIALSTOP");	
    return 0;
}
Пример #7
0
void main(void)
{

	sei();
	INIT_IO();
	INIT_USART();
	INIT_TIMER();
	
	
	
	DDRB=0xff;
	DDRD=0x30;
	
	PORTB=0x06;
	PORTC=0xff;
	
	ADMUX=0x60;
	ADCSRA=0xcc;
	while(1)
	{
		
			
			while(calib_flg)
			{
				calibration();
			}
			
			
			sensing();
			Catch_position();
			OCR1A=position_R[position];
			OCR1B=position_L[position];
		
	}

}
Пример #8
0
#include <sys/time.h>
#include <time.h>
#include <signal.h>
#include <string.h>
#include <stdlib.h>

#include "common.h"
#include "property.h"
#include "signal.h"
#include "exec.h"
#include "global.h"


static int kill_sig=0;
static bool had_tmr=FALSE;
static WTimer queue=INIT_TIMER(NULL);

#define TIMEVAL_LATER(a, b) \
	((a.tv_sec > b.tv_sec) || \
	((a.tv_sec == b.tv_sec) && \
	 (a.tv_usec > b.tv_usec)))


static void do_set_timer()
{
	struct itimerval val={{0, 0}, {0, 0}};
	
	if(queue.next==NULL){
		setitimer(ITIMER_REAL, &val, NULL);
		return;
	}
Пример #9
0
int main ( int argc, char **argv )
{
    int status, length;
    io_channel chan;
    struct rpc_msg msg;

	char *CApath=NULL,*CAfile=NULL;
	int badop=0;
	int ret=1;
	int client_auth=0;
	int server_auth=0;
	SSL_CTX *s_ctx=NULL;
    /*
     * Confirm logical link with initiating client.
     */
    LIB$INIT_TIMER();
    status = SYS$ASSIGN ( &sysnet, &chan, 0, 0, 0 );
    printf("status of assign to SYS$NET: %d\n", status );
    /*
     * Initialize standard out and error files.
     */
	if (bio_err == NULL)
		if ((bio_err=BIO_new(BIO_s_file())) != NULL)
			BIO_set_fp(bio_err,stderr,BIO_NOCLOSE);
	if (bio_stdout == NULL)
		if ((bio_stdout=BIO_new(BIO_s_file())) != NULL)
			BIO_set_fp(bio_stdout,stdout,BIO_NOCLOSE);
    /*
     * get the preferred cipher list and other initialization
     */
	if (cipher == NULL) cipher=getenv("SSL_CIPHER");
	printf("cipher list: %s\n", cipher ? cipher : "{undefined}" );

	SSL_load_error_strings();
	OpenSSL_add_all_algorithms();

/* DRM, this was the original, but there is no such thing as SSLv2()
	s_ctx=SSL_CTX_new(SSLv2());
*/
	s_ctx=SSL_CTX_new(SSLv2_server_method());

	if (s_ctx == NULL) goto end;

	SSL_CTX_use_certificate_file(s_ctx,TEST_SERVER_CERT,SSL_FILETYPE_PEM);
	SSL_CTX_use_RSAPrivateKey_file(s_ctx,TEST_SERVER_CERT,SSL_FILETYPE_PEM);
	printf("Loaded server certificate: '%s'\n", TEST_SERVER_CERT );

    /*
     * Take commands from client until bad status.
     */
    LIB$SHOW_TIMER();
    status = doit ( chan, s_ctx );
    LIB$SHOW_TIMER();
    /*
     * do final cleanup and exit.
     */
end:
	if (s_ctx != NULL) SSL_CTX_free(s_ctx);
    LIB$SHOW_TIMER();
    return 1;
}
Пример #10
0
/*{{{ Resize timer */


static void tmr_end_resize(WTimer *unused)
{
	WThing *holder;
	if(!resize_mode){
		return;
	}
	holder=grab_get_holder(resize_handler);
	assert(holder && WTHING_IS(holder, WWindow));
	
	end_resize((WWindow*)holder);
}

static WTimer resize_timer=INIT_TIMER(tmr_end_resize);


/*}}}*/


/*{{{ Rubberband and size display */


static void res_draw_rubberband(WScreen *scr, WRectangle geom)
{
	if(rtmp.startnode!=NULL){
		if(WOBJ_IS(rtmp.startnode, WWindow))
			geom=((WWindow*)rtmp.startnode)->geom;
		else
			geom=((WWsSplit*)rtmp.startnode)->geom;