Changeset 112


Ignore:
Timestamp:
Feb 6, 2011, 11:27:09 PM (14 years ago)
Author:
demin
Message:

use usleep for jbi_delay and remove unused includes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sandbox/JamPlayerUSB/jbistub.c

    r111 r112  
    2727/****************************************************************************/
    2828
    29 #include <windows.h>
    30 
    3129#include <stdio.h>
    32 #include <stdlib.h>
    3330#include <string.h>
    34 #include <io.h>
    35 #include <fcntl.h>
    36 #include <process.h>
     31#include <unistd.h>
    3732#include <malloc.h>
     33#include <ctype.h>
     34#include <sys/stat.h>
     35
    3836#define POINTER_ALIGNMENT sizeof(BYTE)
    39 #include <time.h>
    40 #include <conio.h>
    41 #include <ctype.h>
    42 #include <sys/types.h>
    43 #include <sys/stat.h>
    4437
    4538#include "jbiexprt.h"
     
    5447long file_length = 0L;
    5548
    56 /* delay count for one millisecond delay */
    57 long one_ms_delay = 0L;
     49/******************************************************************/
     50
     51#include <windows.h>
     52#include "ftd2xx.h"
    5853
    5954BOOL jtag_hardware_initialized = FALSE;
    6055
    61 /* function prototypes to allow forward reference */
    62 extern void delay_loop(long count);
    63 
    6456BOOL verbose = FALSE;
    6557
    66 /******************************************************************/
    67 
    68 #include "ftd2xx.h"
    69 
    7058static FT_HANDLE ftdih = NULL;
    71 
    72 BYTE usb_buf[64];
    73 int usb_buf_pos;
    7459
    7560/******************************************************************/
     
    116101
    117102    FT_STATUS status;
    118 
    119     usb_buf_pos = 0;
    120103
    121104    if ((status = FT_OpenEx("USB-Blaster", FT_OPEN_BY_DESCRIPTION, &ftdih)) != FT_OK)
     
    429412void jbi_delay(long microseconds)
    430413{
    431         delay_loop(microseconds *
    432                 ((one_ms_delay / 1000L) + ((one_ms_delay % 1000L) ? 1 : 0)));
     414        usleep(microseconds);
    433415}
    434416
     
    451433                free(ptr);
    452434        }
    453 }
    454 
    455 void calibrate_delay(void)
    456 {
    457         one_ms_delay = 0L;
    458435}
    459436
     
    508485        int exit_code = 0;
    509486        int format_version = 0;
    510         time_t start_time = 0;
    511         time_t end_time = 0;
    512         int time_delta = 0;
    513487        char *workspace = NULL;
    514488        char *action = NULL;
     
    680654                {
    681655                        /*
    682                         *       Calibrate the delay loop function
    683                         */
    684                         calibrate_delay();
    685 
    686                         /*
    687656                        *       Check CRC
    688657                        */
     
    786755                                *       Execute the Jam STAPL ByteCode program
    787756                                */
    788                                 time(&start_time);
    789757                                exec_result = jbi_execute(file_buffer, file_length, workspace,
    790758                                        workspace_size, action, init_list, reset_jtag,
    791759                                        &error_address, &exit_code, &format_version);
    792                                 time(&end_time);
    793760
    794761                                if (exec_result == JBIC_SUCCESS)
     
    858825                                        printf("Unknown error code %d\n", exec_result);
    859826                                }
    860 
    861                                 /*
    862                                 *       Print out elapsed time
    863                                 */
    864                                 if (verbose)
    865                                 {
    866                                         time_delta = (int) (end_time - start_time);
    867                                         printf("Elapsed time = %02u:%02u:%02u\n",
    868                                                 time_delta / 3600,                      /* hours */
    869                                                 (time_delta % 3600) / 60,       /* minutes */
    870                                                 time_delta % 60);                       /* seconds */
    871                                 }
    872827                        }
    873828                }
     
    881836        return (exit_status);
    882837}
    883 
    884 void delay_loop(long count)
    885 {
    886         while (count != 0L) count--;
    887 }
Note: See TracChangeset for help on using the changeset viewer.