亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? avr309.dpr

?? AVR的USB開發(fā)源代碼 USB-RS232轉(zhuǎn)換
?? DPR
?? 第 1 頁 / 共 3 頁
字號:
        Exit;
      end;
    Result:=DEVICE_NOT_PRESENT;
    OutLength:=1;
    if SendToDriver(FNCNumberDoSetRS232Baud,Lo(BaudRateByte),Hi(BaudRateByte),OutputData,OutLength) then
      Result:=NO_ERROR;
    SetEvent(SerializationEvent);
  end;
//-------------------------------------------------------------------------------------------------------
function DoGetRS232Baud(var BaudRate:integer):integer;  stdcall export;
//;get baud speed of serial line (exact value)
  begin
    if WaitForSingleObject(SerializationEvent,SerializationEventTimeout)=WAIT_TIMEOUT then
      begin
        ShowThreadErrorMessage;
        Result:=DEVICE_NOT_PRESENT;
        Exit;
      end;
    Result:=DEVICE_NOT_PRESENT;
    OutLength:=2;
    if not SendToDriver(FNCNumberDoGetRS232Baud,0,0,OutputData,OutLength) then
      begin
        SetEvent(SerializationEvent);
        Exit;
      end;
    UARTx2Mode:=OutLength>1;
    if not UARTx2Mode then OutputData[1]:=0; // ATmega returns 2 byte answer
    BaudRate:=Round(12e6/(16*(255.0*OutputData[1]+OutputData[0]+1.0)));
    if UARTx2Mode then BaudRate:=BaudRate*2; // ATmega has x2 mode on UART
    Result:=NO_ERROR;
    SetEvent(SerializationEvent);
  end;
//-------------------------------------------------------------------------------------------------------
function DoGetRS232BufferLocal(var RS232Buffer:array of byte; var RS232BufferLength:integer):integer;
//local function to obtain FIFO buffer into buffer
var
  i,j:integer;
  HeaderLength:integer;
  begin
    if RS232BufferLength<=0 then
      begin
        RS232BufferLength:=0;
        Result:=NO_ERROR;
        Exit;
      end;
    if WaitForSingleObject(SerializationEvent,SerializationEventTimeout)=WAIT_TIMEOUT then
      begin
        ShowThreadErrorMessage;
        Result:=DEVICE_NOT_PRESENT;
        RS232BufferLength:=0;
        Exit;
      end;
    Result:=DEVICE_NOT_PRESENT;
    i:=0;
    HeaderLength:=1;
    if UARTx2Mode then inc(HeaderLength);
    repeat
      OutLength:=RS232BufferLength-i+HeaderLength;
      if OutLength>OutputDataLength then
        OutLength:=OutputDataLength;
      if not SendToDriver(FNCNumberDoGetRS232Buffer,0,0,OutputData,OutLength) then
        begin
          RS232BufferLength:=0;
          SetEvent(SerializationEvent);
          Exit;
        end;
      if (OutLength<=1) then
        Break;
      for j:=i to i+OutLength-HeaderLength-1 do
        RS232Buffer[j]:=OutputData[j-i+HeaderLength];
      i:=i+OutLength-HeaderLength;
    until (RS232BufferLength<=i);
    RS232BufferLength:=i;
    Result:=NO_ERROR;
    SetEvent(SerializationEvent);
  end;
//-------------------------------------------------------------------------------------------------------
function DoGetRS232Buffer(var RS232Buffer:array of byte; var RS232BufferLength:integer):integer;  stdcall export;
//;get received bytes from FIFO RS232 buffer
var
  BufferLength,i:integer;
  RS232BufferWriteLocal:integer;
  P:^integer;
begin
  BufferLength:=0;
  Result:=NO_ERROR;
  if RS232BufferLength>0 then
    for i:=1 to RS232BufferLength do
      begin
        P:=@PGlobalRS232Buffer^[GlobalRS232BufferWritePos];
        RS232BufferWriteLocal:=P^;
        if (RS232BufferRead=RS232BufferWriteLocal) then
          Break;
        RS232Buffer[BufferLength]:=PGlobalRS232Buffer^[RS232BufferRead];
        inc(BufferLength);
        RS232BufferRead:=(RS232BufferRead+1) mod (GlobalRS232BufferEnd+1);
      end;
  RS232BufferLength:=BufferLength;
end;
//-------------------------------------------------------------------------------------------------------
function DoRS232BufferSend(var RS232Buffer:array of byte; var RS232BufferLength:integer):integer;  stdcall export;
//;transmit given RS232 buffer to serial line
var
  BufferLength,i:integer;
begin
  BufferLength:=0;
  Result:=NO_ERROR;
  try
    if RS232BufferLength>0 then
      for i:=1 to RS232BufferLength do
        begin
          if DoRS232Send(RS232Buffer[BufferLength])=DEVICE_NOT_PRESENT then
            begin
              Result:=DEVICE_NOT_PRESENT;
              Break;
            end;
          inc(BufferLength);
        end;
  finally
    RS232BufferLength:=BufferLength;
  end;
end;
//-------------------------------------------------------------------------------------------------------
function DoGetRS232BufferThreadProc(Parameter: Pointer): Integer;
//system unique thread for reading device RS232 FIFO into RS232 buffer
var
  Handles:array[0..1] of integer;
  MutexHandles:array[0..1] of integer;
  BufferLength:integer;
  NewRS232BufferWrite:integer;
  i,j:integer;
  P:^integer;
label
  EndOfBufferThreadProc;
begin
  Handles[0]:=RS232BufferGetEvent;
  Handles[1]:=RS232BufferEndEvent;
  MutexHandles[0]:=RS232MutexHandle;
  MutexHandles[1]:=RS232BufferEndEvent;
  Result:=0;
  j:=0;

  LocalThreadRunningEvent:=CreateEvent(nil,false,false,nil); //event to signal end of execution of this thread

  if IsRS232PrevInst then
  case WaitForMultipleObjects(2,@MutexHandles,false,INFINITE) of
    WAIT_OBJECT_0,WAIT_ABANDONED_0:
      begin
        WaitForSingleObject(RS232MutexHandle,3000);
        IsRS232PrevInst:=false;
        P:=@PGlobalRS232Buffer^[GlobalRS232BufferWritePos];
        RS232BufferWrite:=P^;
      end;
    WAIT_OBJECT_0+1,WAIT_ABANDONED_0+1:
      begin
        SetEvent(LocalThreadRunningEvent);
        Exit;
      end;
  end;

  DoGetRS232BufferTimer:=timeSetEvent(RS232BufferTimerInterval,1, TFNTimeCallBack(RS232BufferGetEvent), 0, TIME_PERIODIC or TIME_CALLBACK_EVENT_SET);
  repeat
    case WaitForMultipleObjects(2,@Handles,false,INFINITE) of
      WAIT_OBJECT_0:
        begin
          repeat
            BufferLength:=GlobalRS232BufferEnd-RS232BufferWrite+1;
            if DoGetRS232BufferLocal(PGlobalRS232Buffer^[RS232BufferWrite], BufferLength)<>NO_ERROR then
              begin
                if WaitForSingleObject(RS232BufferEndEvent,2000)<>WAIT_TIMEOUT then // wait 2 seconds if there is no answer (save bandwidth for non-RS232 buffer devices)
                  begin
                    goto EndOfBufferThreadProc;
                  end;
                Break;
              end;
            NewRS232BufferWrite:=RS232BufferWrite+BufferLength;
            j:=Low(TGlobalRS232Buffer);
            if NewRS232BufferWrite>GlobalRS232BufferEnd then
              begin
                for i:=GlobalRS232BufferEnd+1 to NewRS232BufferWrite do
                  begin
                    PGlobalRS232Buffer^[j]:=PGlobalRS232Buffer^[i];
                    inc(j);
                  end;
                NewRS232BufferWrite:=NewRS232BufferWrite mod (GlobalRS232BufferEnd+1);
              end;
            RS232BufferWrite:=NewRS232BufferWrite;
            P:=@PGlobalRS232Buffer^[GlobalRS232BufferWritePos];
            P^:=RS232BufferWrite;
          until j<=Low(TGlobalRS232Buffer);
        end;
      WAIT_OBJECT_0+1:
        begin
            Break;
        end;
    end;
  until false;
EndOfBufferThreadProc:
  if DoGetRS232BufferTimer<>0 then
    begin
      timeKillEvent(DoGetRS232BufferTimer);
      DoGetRS232BufferTimer:=0;
    end;
  SetEvent(LocalThreadRunningEvent);
end;
//-------------------------------------------------------------------------------------------------------
procedure InitRS232ExclusiveSystemBuffer;
//inicialization of system unique RS232 buffer (memory mapped file)
var
  P:^integer;
begin
  RS232MutexHandle:=CreateMutex(nil, false, RS232BufferMutexName);
  if RS232MutexHandle <> 0 then
    begin
      if GetLastError = ERROR_ALREADY_EXISTS then
        IsRS232PrevInst := TRUE
      else
        IsRS232PrevInst := FALSE;
    end
  else
    begin
      IsRS232PrevInst := FALSE;
    end;
  if not IsRS232PrevInst then
    WaitForSingleObject(RS232MutexHandle,3000);
  RS232BufferFileMappedHND:=CreateFileMapping(MAXDWORD,nil,PAGE_READWRITE or SEC_COMMIT	or SEC_NOCACHE,0,GlobalRS232BufferLength,RS232BufferFileMappedName);
  if RS232BufferFileMappedHND=0 then
    Exit;
  PGlobalRS232Buffer:=MapViewOfFile(RS232BufferFileMappedHND,FILE_MAP_WRITE,0,0,GlobalRS232BufferLength);
  if PGlobalRS232Buffer=nil then
    Exit;
  if IsRS232PrevInst then
    begin
      P:=@PGlobalRS232Buffer^[GlobalRS232BufferWritePos];
      RS232BufferRead:=P^;
    end;
end;
//-------------------------------------------------------------------------------------------------------
procedure CloseRS232ExclusiveSystemBuffer;
//close of system unique RS232 buffer (memory mapped file)
begin
  if PGlobalRS232Buffer<>nil then
    begin
      UnmapViewOfFile(PGlobalRS232Buffer);
    end;
  if RS232BufferFileMappedHND>0 then
    begin
      CloseHandle(RS232BufferFileMappedHND);
    end;
  RS232BufferFileMappedHND:=0;
  if not IsRS232PrevInst then
    ReleaseMutex(RS232MutexHandle);
  CloseHandle(RS232MutexHandle);
end;
//-------------------------------------------------------------------------------------------------------
procedure DLLMain(Reason : DWORD);
begin
  case Reason of
    DLL_PROCESS_ATTACH: //next application starts using DLL
      begin
        //All buffers, threads, events and synchronization object create
        InitRS232ExclusiveSystemBuffer; //create RS232 buffer (memory mapped file)
        SerializationEvent:=CreateEvent(nil,false,true,SerializationEventName);// serialization event for device access
        {$IFDEF DemoVersion}
          DemoOK:=MessageBox(0,'Please register!','Free version!',MB_OK or MB_ICONINFORMATION or MB_TASKMODAL or MB_TOPMOST);
        {$ENDIF}
        HookHandle:=SetWindowsHookEx(WH_GETMESSAGE,FNHookProc,0,GetCurrentThreadID); //install Hook function (WM_QUIT message)
        RS232BufferGetEvent:=CreateEvent(nil,false,false,nil); //event for start reading device FIFO
        RS232BufferEndEvent:=CreateEvent(nil,false,false,nil); //event to finish FIFO reading thread
        RS232BufferThreadHND:=BeginThread(nil,0,DoGetRS232BufferThreadProc,nil,CREATE_SUSPENDED,Cardinal(RS232BufferThreadId)); //create FIFO reading thread (suspended)
        SetThreadPriority(RS232BufferThreadHND,THREAD_PRIORITY_TIME_CRITICAL); //highest priority for FIFO reading thread
        ResumeThread(RS232BufferThreadHND); //start FIFO reading thread
      end;
    DLL_PROCESS_DETACH: //next application ends using DLL
      begin
        if HookHandle<>0 then UnhookWindowsHookEx(HookHandle); //uninstall Hook function (WM_QUIT message)
        if RS232BufferThreadHND<>0 then //if Hook function not unistalls thread - then uninstall it
          begin
            if DoGetRS232BufferTimer<>0 then
              begin
                timeKillEvent(DoGetRS232BufferTimer);
                DoGetRS232BufferTimer:=0;
              end;
            SetEvent(RS232BufferEndEvent);
            if LocalThreadRunningEvent<>0 then
              begin
                WaitForSingleObject(LocalThreadRunningEvent,5000);
                WaitForSingleObject(RS232BufferThreadHND,10);
                CloseHandle(RS232BufferEndEvent);
                LocalThreadRunningEvent:=0;
              end
            else
              WaitForSingleObject(RS232BufferThreadHND,400);
            CloseHandle(RS232BufferThreadHND);
          end;
        if LocalThreadRunningEvent<>0 then
          begin
            CloseHandle(RS232BufferEndEvent);
            LocalThreadRunningEvent:=0;
          end;
        CloseHandle(RS232BufferGetEvent); //free event for start reading device FIFO
        CloseHandle(RS232BufferEndEvent); //free event to finish FIFO reading thread
        CloseHandle(SerializationEvent); //free serialization event for device access
        CloseRS232ExclusiveSystemBuffer; //free RS232 buffer (memory mapped file)
        {$IFDEF DemoVersion}
          DemoOK:=MessageBox(0,'Please register!','Free version!',MB_OK or MB_ICONINFORMATION or MB_TASKMODAL or MB_TOPMOST);
        {$ENDIF}
      end;
    DLL_THREAD_ATTACH: //next thread starts using DLL
      begin
        {$IFDEF DemoVersion}
          if Trunc(DemoOK+0.123)<>(abs(OKDemoValue)-1) then Halt; // for bad cracking error
        {$ENDIF}
      end;
    DLL_THREAD_DETACH: //next thread ends using DLL
      begin
      end;
  end;
end;//DLLMain
//-------------------------------------------------------------------------------------------------------
exports
  //exported functions:
  //DoSetInfraBufferEmpty,		//;restart of infra reading (if was stopped by RAM reading)
  DoGetInfraCode,			//;transmit of receved infra code (if some code in infra buffer)
  DoSetDataPortDirection,		//;set direction of data bits
  DoGetDataPortDirection,		//;get direction of data bits
  DoSetOutDataPort,			//;set data bits (if are bits as input, then set theirs pull-ups)
  DoGetOutDataPort,			//;get data bits (if are bits as input, then get theirs pull-ups)
  DoGetInDataPort,			//;get data bits - pin reading
  DoEEPROMRead,				//;read EEPROM from given address
  DoEEPROMWrite,			//;write data byte to EEPROM to given address
  DoRS232Send, 				//;send one data byte to RS232 line
  DoRS232Read,				//;read one data byte from serial line (only when FIFO not implemented in device)
  DoSetRS232Baud,			//;set baud speed of serial line
  DoGetRS232Baud,			//;get baud speed of serial line (exact value)
  DoGetRS232Buffer,                     //;get received bytes from FIFO RS232 buffer
  DoRS232BufferSend,                    //;transmit given RS232 buffer to serial line
  DoSetRS232DataBits,                   //;set number of data bits of serial line
  DoGetRS232DataBits,                   //;get number of data bits of serial line
  DoSetRS232Parity,                     //;set parity of serial line
  DoGetRS232Parity,                     //;get parity of serial line
  DoSetRS232StopBits,                   //;set stopbits of serial line
  DoGetRS232StopBits,                   //;get stopbits of serial line

  DoSetDataPortDirections,		//;set directions of data bits
  DoGetDataPortDirections,		//;get directions of data bits
  DoSetOutDataPorts,			//;set data bits (if are bits as input, then set theirs pull-ups)
  DoGetOutDataPorts,			//;get data bits (if are bits as input, then get theirs pull-ups)
  DoGetInDataPorts;			//;get data bits - pin reading

begin
  DLLProc:=@DllMain;
  DllMain(DLL_PROCESS_ATTACH);
end.

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
成人精品国产一区二区4080| 欧美疯狂做受xxxx富婆| 精品无人码麻豆乱码1区2区| 日本成人在线视频网站| 精品午夜久久福利影院| 国产成人在线色| 精品污污网站免费看| 在线一区二区三区做爰视频网站| 豆国产96在线|亚洲| 成人网在线播放| 色婷婷精品久久二区二区蜜臂av | 中文字幕亚洲不卡| 欧美精品一区二区精品网| 在线观看视频91| 777午夜精品视频在线播放| 日韩欧美一区在线观看| 久久久蜜臀国产一区二区| 久久先锋影音av鲁色资源| 中文字幕av一区二区三区免费看| 99视频在线精品| 亚洲图片欧美一区| 9久草视频在线视频精品| 欧美放荡的少妇| 亚欧色一区w666天堂| 日本电影亚洲天堂一区| 国产婷婷色一区二区三区在线| 激情六月婷婷综合| 国产亚洲精品免费| a在线播放不卡| 亚洲精品国产成人久久av盗摄 | 国产精品一区专区| 久久久亚洲精品一区二区三区| 日韩极品在线观看| 欧美精品一区二区三区久久久| 日韩av中文在线观看| 欧美精品v日韩精品v韩国精品v| 视频一区在线视频| 精品视频123区在线观看| 蜜桃传媒麻豆第一区在线观看| 欧美日韩精品一区二区| 久久国产精品99精品国产| 国产精品沙发午睡系列990531| 97久久超碰国产精品| 亚洲国产日韩精品| 久久综合av免费| 欧美日韩在线播放三区四区| 亚洲精品国产a久久久久久| 国产精品美女www爽爽爽| 免费欧美高清视频| 91麻豆精品国产自产在线观看一区| 午夜精品久久久久久久99樱桃| aaa亚洲精品一二三区| 久久久久久久久久久久久久久99| 青青草国产成人av片免费| 日韩视频免费观看高清在线视频| 免费美女久久99| 精品欧美黑人一区二区三区| 福利一区在线观看| 亚洲精品国产无套在线观| 精品一区二区免费视频| 中文字幕亚洲区| 欧美在线观看视频一区二区三区 | 欧美日韩精品一区二区三区蜜桃 | 日韩av成人高清| 日韩一区二区三区精品视频| 亚洲一区二区三区四区在线观看| 欧美一级二级三级乱码| 国产亚洲视频系列| 国产综合久久久久影院| 亚洲精品免费播放| 精品日韩一区二区| 日韩小视频在线观看专区| 6080午夜不卡| 日韩欧美一级二级三级久久久| 欧美午夜电影一区| 91色乱码一区二区三区| 色综合天天综合色综合av| 欧美精品一区二区三区蜜臀| 国产一级精品在线| 久久尤物电影视频在线观看| 日本韩国一区二区| 国产精品18久久久久久久久 | 亚洲激情成人在线| 欧美一区二区三区四区久久| 免费高清在线一区| 一色桃子久久精品亚洲| 在线一区二区三区四区五区| 精品一区二区三区免费| 三级久久三级久久久| 日韩美女视频一区二区| 国产日韩欧美高清| 国产午夜精品一区二区三区嫩草 | 久久精品日产第一区二区三区高清版| 成人高清视频在线| 久久66热re国产| 成人免费视频在线观看| 91精品国产一区二区三区| 欧美电影一区二区三区| 91在线观看视频| 国产美女在线观看一区| 国产原创一区二区| 粉嫩av亚洲一区二区图片| 国内外成人在线| 国产精品白丝av| 91丝袜呻吟高潮美腿白嫩在线观看| 国产99久久久国产精品免费看 | 日韩va欧美va亚洲va久久| 亚洲视频一区在线| 成人免费在线观看入口| 最新成人av在线| 亚洲一区二区成人在线观看| 一区二区国产视频| 日本免费在线视频不卡一不卡二| 午夜精品一区二区三区电影天堂| 天天色天天操综合| 国产福利一区二区| 亚洲欧美自拍偷拍色图| 亚洲成av人片一区二区| 国产激情一区二区三区四区| 欧美肥大bbwbbw高潮| 亚洲视频图片小说| 国产一区二区福利| 91精品国产综合久久久久久久| 最近中文字幕一区二区三区| 国产在线精品一区二区不卡了| 欧美日韩免费电影| 免费精品视频最新在线| 欧美优质美女网站| 亚洲精品美国一| 欧美系列一区二区| 美女视频黄久久| www日韩大片| 波多野结衣中文字幕一区二区三区| 欧美tickling网站挠脚心| 国产在线精品不卡| 国产精品久久久久久久久图文区| 国产精品一卡二卡| 欧美国产日韩a欧美在线观看| 狠狠色丁香九九婷婷综合五月| 精品三级在线观看| 国模冰冰炮一区二区| 日韩精品中文字幕在线一区| 免费人成网站在线观看欧美高清| 日韩美女视频在线| 99re视频这里只有精品| 亚洲午夜电影在线观看| 久久综合给合久久狠狠狠97色69| 国产99久久久国产精品潘金 | 99久久er热在这里只有精品66| 一区二区三区在线免费| 久久综合99re88久久爱| 欧洲av一区二区嗯嗯嗯啊| 国产精品亚洲人在线观看| 一区二区三区不卡视频在线观看 | 韩国精品在线观看| 亚洲午夜免费电影| 国产精品人成在线观看免费| 欧美亚洲丝袜传媒另类| 久久国产精品99久久久久久老狼 | 1区2区3区国产精品| 69久久夜色精品国产69蝌蚪网| 福利一区二区在线| 国内精品写真在线观看| 日韩国产精品久久久久久亚洲| 国产精品久久久久久久久动漫 | 亚洲国产另类av| 久久精品亚洲精品国产欧美| 欧美日韩一级片网站| 成人蜜臀av电影| 国产精品一区二区x88av| 亚洲成人综合网站| 最新成人av在线| 国产欧美精品一区二区三区四区| 在线观看91视频| 成人99免费视频| 成人一区二区三区视频在线观看| 污片在线观看一区二区 | 亚洲一区在线视频| 亚洲视频综合在线| 中文字幕av一区二区三区高 | 亚洲图片一区二区| 视频一区欧美精品| 免费高清在线视频一区·| 久久国产精品露脸对白| 国产伦精品一区二区三区视频青涩| 日韩高清不卡一区二区三区| 日韩伦理免费电影| 日韩av中文在线观看| 国产美女一区二区| 在线视频国产一区| 日韩亚洲欧美中文三级| 国产欧美一区二区在线| 亚洲影视在线观看| 国产在线精品一区在线观看麻豆| 成人av在线播放网址| 欧美日产在线观看| 国产精品白丝在线| 久久99久久99小草精品免视看| av一区二区三区| 欧美xxxxxxxxx|