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

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

?? readwritecmdtab.cpp

?? 基于ARM的應用Source6
?? CPP
字號:
/*----------------------------------------------------------------------------
 *  Copyright (c) 2001 by National Semiconductor Corporation
 *  National Semiconductor Corporation
 *  2900 Semiconductor Drive
 *  Santa Clara, California 95051
 *
 *  All rights reserved
 *
 *<<<-------------------------------------------------------------------------
 * File Contents:
 *	readWriteCmdTab.cpp - this class defines Diagnostic GUI tab. The diagnostic settings
 *					 are received from the user and are transfered to the ControlFunc class or
 *					 Uart class
 *
 *  Project: USB Demo Application
 *  Author : Yan Nosovitsky
 *  Date   : Dec 2001
 *----------------------------------------------------------------------->>>*/

// readWriteCmdTab.cpp : implementation file
//

#include "stdafx.h"
#include "Demo.h"
#include "readWriteCmdTab.h"
#include "usbn9603reg.h"
#include "ControlFunc.h"
#include "command_api.h"
#include "USBDriver.h"
#include "uart\Uart.h" 

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// readWriteCmdTab dialog


readWriteCmdTab::readWriteCmdTab(CWnd* pParent /*=NULL*/)
	: CDialog(readWriteCmdTab::IDD, pParent)
{
	//{{AFX_DATA_INIT(readWriteCmdTab)
	//}}AFX_DATA_INIT
	m_bitArray[0] = &m_bit0Edit;
	m_bitArray[1] = &m_bit1Edit;
	m_bitArray[2] = &m_bit2Edit;
	m_bitArray[3] = &m_bit3Edit;
	m_bitArray[4] = &m_bit4Edit;
	m_bitArray[5] = &m_bit5Edit;
	m_bitArray[6] = &m_bit6Edit;
	m_bitArray[7] = &m_bit7Edit;
	COMNum = "Com1";
	UARTChannel = TRUE;
	regIndex = 0;
}


void readWriteCmdTab::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(readWriteCmdTab)
	DDX_Control(pDX, IDC_BIT7, m_bit7Edit);
	DDX_Control(pDX, IDC_BIT6, m_bit6Edit);
	DDX_Control(pDX, IDC_BIT5, m_bit5Edit);
	DDX_Control(pDX, IDC_BIT4, m_bit4Edit);
	DDX_Control(pDX, IDC_BIT3, m_bit3Edit);
	DDX_Control(pDX, IDC_BIT2, m_bit2Edit);
	DDX_Control(pDX, IDC_BIT1, m_bit1Edit);
	DDX_Control(pDX, IDC_BIT0, m_bit0Edit);
	DDX_Control(pDX, IDC_SERIAL_RADIO, m_serialRadio);
	DDX_Control(pDX, IDC_COM_COMBO, m_comList);
	DDX_Control(pDX, IDC_ADDRESS_SPIN, m_addressSpin);
	DDX_Control(pDX, IDC_REG_ADDRESS_EDIT, m_regAddress);
	DDX_Control(pDX, IDC_REG_NAMES_COMBO, m_regName);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(readWriteCmdTab, CDialog)
	//{{AFX_MSG_MAP(readWriteCmdTab)
	ON_CBN_SELENDOK(IDC_REG_NAMES_COMBO, OnSelendokRegNamesCombo)
	ON_EN_CHANGE(IDC_REG_ADDRESS_EDIT, OnChangeRegAddressEdit)
	ON_NOTIFY(UDN_DELTAPOS, IDC_ADDRESS_SPIN, OnDeltaposAddressSpin)
	ON_CBN_SELENDOK(IDC_COM_COMBO, OnSelendokComCombo)
	ON_BN_CLICKED(IDC_SERIAL_RADIO, OnSerialRadio)
	ON_BN_CLICKED(IDC_USB_RADIO, OnUsbRadio)
	ON_BN_CLICKED(IDC_READ_BUTTON, OnReadButton)
	ON_BN_CLICKED(IDC_WRITE_BUTTON, OnWriteButton)
	ON_COMMAND(IDCANCEL, OnCancel)
	ON_COMMAND(IDOK, OnOK)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// readWriteCmdTab message handlers

void readWriteCmdTab::OnSelendokRegNamesCombo() 
{
	int index = m_regName.GetCurSel();

	/* Find reg. address */

	int i = index - 1;

	if (index == 0)
		i=0;

	while (USBReg[i++].listIndex != index) {}

	/* update address field */
	regIndex = i - 1;
	CString address;
	if (USBReg[i-1].address < 0x10)
		address.Format("0x000%x",USBReg[regIndex].address);
	else
		address.Format("0x00%x",USBReg[regIndex].address);
	m_regAddress.SetWindowText(address);
	m_addressSpin.SetPos(USBReg[regIndex].address);
	ClearBits();
	
}



void readWriteCmdTab::OnChangeRegAddressEdit() 
{
	// TODO: If this is a RICHEDIT control, the control will not
	// send this notification unless you override the CDialog::OnInitDialog()
	// function and call CRichEditCtrl().SetEventMask()
	// with the ENM_CHANGE flag ORed into the mask.
	
	// TODO: Add your control notification handler code here
	
}



void readWriteCmdTab::BuildRegList()
{
	int i = 0;
	int index = 1;

	m_regName.AddString("Reserved");
		for(; i<= LAST_REG; i++)
		{
			if (!(USBReg[i].type&NO_USE))
			{/* add to the list */
				m_regName.AddString(USBReg[i].name);
				USBReg[i].listIndex = index++;;
			}
			else
				USBReg[i].listIndex = 0;
		}
	m_regName.SetCurSel(1);
}

void readWriteCmdTab::OnDeltaposAddressSpin(NMHDR* pNMHDR, LRESULT* pResult) 
{
	NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;

	int index = pNMUpDown->iPos + pNMUpDown->iDelta;
		
	*pResult = 0;

	if ((index >= 0)&&(index <= LAST_REG))
		regIndex = index;
	else
	{
		CString address;
		if (index == -1)
		{
			regIndex = LAST_REG;
//			address = "0x0000";
//			m_addressSpin.SetPos(0);
		}
		else
		{
			regIndex = LAST_REG;
//			address = "0x003F";
//			m_addressSpin.SetPos(LAST_REG);
		}
//		m_regAddress.SetWindowText(address);
	}


	m_regName.SetCurSel(USBReg[regIndex].listIndex);
	ClearBits();
}

void readWriteCmdTab::OnSelendokComCombo() 
{
	COMNum.Format(_T("Com%d"),(m_comList.GetCurSel() + 1));
	
}

void readWriteCmdTab::OnSerialRadio() 
{
	m_comList.EnableWindow(TRUE);
	UARTChannel = TRUE;
}

void readWriteCmdTab::OnUsbRadio() 
{
	m_comList.EnableWindow(FALSE);
	UARTChannel = FALSE;
}

void readWriteCmdTab::ClearBits()
{
	int i = 0;

	for (; i < BIT_NUM ; i++)
		m_bitArray[i]->SetWindowText("");

}

void readWriteCmdTab::OnReadButton() 
{
	
	USBDriver *curUSBDriver = USBDriver::GetUSBDriver();
	if (curUSBDriver->IsUSBDriverHaveError())
	{
		MessageBox(curUSBDriver->GetErrorDescriptor(),"Error",MB_ICONERROR | MB_OK);
		return;
	}

	if (curUSBDriver->IsBulkOutTestRun())
	{
		/* Bulk OUT test run */
		MessageBox("Cannot process current command.\nWait until Bulk OUT test is finished.","Error",MB_ICONERROR | MB_OK);
		return;
	}
	
	/* check reg. type */
	if (!(USBReg[regIndex].type & READ_ONLY) &&
		!(USBReg[regIndex].type & CLEARED_READ) && 
		!(USBReg[regIndex].type & NO_LIMIT) &&
		!(USBReg[regIndex].type & NO_USE))
	{
		/* Not readable register */
		MessageBox("The selected register is write only","Error",MB_ICONERROR | MB_OK);
		return;
	}
	
	if (USBReg[regIndex].type & CLEARED_READ)
	{
		if (MessageBox("Some bits of the selected register will be cleared on read.\nReading this register may change the firmware behavior.\nDo you want to continue?\n",
			"Warning",MB_ICONWARNING|MB_YESNO ) == IDNO)
				   return;
	}

	if (USBReg[regIndex].type & NO_USE)
	{
		if (MessageBox("The selected address is reserved.\nResult of reading this address is unpredictable.\nDo you want to continue?\n",
			"Warning",MB_ICONWARNING|MB_YESNO ) == IDNO)
				   return;
	}

	if (UARTChannel)
	{
		/* Use UART */
		Uart  uart;
		BYTE	   buffer[2];

		if (!uart.OpenUART(COMNum))
		{
			MessageBox("Cannot open communication channel.","Error",MB_ICONERROR | MB_OK);
			return;
		}
		
		buffer[0] = READ_USB_REG;
		buffer[1] = USBReg[regIndex].address;
		if (!uart.WriteData(buffer,2))
		{
			MessageBox("Cannot write to communication channel.","Error",MB_ICONERROR | MB_OK);
			uart.CloseUART();
			return;
		}
		
		if(uart.ReadData(&regValue,1,100) != 1)
		{
			MessageBox("Cannot read register from USB device using " + COMNum,"Error",MB_ICONERROR | MB_OK);
			uart.CloseUART();
			return;
		}

		uart.CloseUART();

	}
	else
	{
		/* Use USB conrol */
		if (!ControlFunc::SendSetupPacketIn(READ_USB_REG, USBReg[regIndex].address,0,1,&regValue))
		{
		/* Can't send setup packet */
			MessageBox("Cannot read register from USB device.","Error",MB_ICONERROR | MB_OK);
			return;
		}

	}

	/* Update bits field */

	int i = 0;
	CString bit;

	for (; i < BIT_NUM ; i++)
	{
		bit.Format(_T("%d"),(regValue>>i)&0x1);
		m_bitArray[i]->SetWindowText(bit);
	}

}

void readWriteCmdTab::OnWriteButton() 
{
	int i;
	CString bit;
	CString error;
	byte curBit;
	
	USBDriver *curUSBDriver = USBDriver::GetUSBDriver();
	if (curUSBDriver->IsUSBDriverHaveError())
	{
		MessageBox(curUSBDriver->GetErrorDescriptor(),"Error",MB_ICONERROR | MB_OK);
		return ;
	}

	if (curUSBDriver->IsBulkOutTestRun())
	{
		/* Bulk OUT test run */
		MessageBox("Cannot process current command.\nWait until Bulk OUT test is finished.","Error",MB_ICONERROR | MB_OK);
		return;
	}
	regValue = 0;
	/* read bits field */
	for (i = 0; i< BIT_NUM; i++)
	{
		m_bitArray[i]->GetWindowText(bit);
		if (bit.IsEmpty())
		{
			error.Format(_T("Bit %d value is not specified"),i); 
			MessageBox(error,"Error",MB_ICONERROR | MB_OK);
			return;
		}

		sscanf(bit.GetBuffer(bit.GetLength()),"%d",&curBit);

		if ((curBit!= 0)&&(curBit!=1))
		{
			error.Format(_T("Bit %d value should be binary (0 or 1)"),i); 
			MessageBox(error,"Error",MB_ICONERROR | MB_OK);
			return;
		}

		regValue |= (curBit<<i);
	}
	
	
	/* check reg. type */
	if (!(USBReg[regIndex].type & WRITE_ONLY) &&
		!(USBReg[regIndex].type & CLEARED_WRITE) && 
		!(USBReg[regIndex].type & NO_LIMIT) &&
		!(USBReg[regIndex].type & NO_USE))
	{
		/* Not readable register */
		MessageBox("The selected register is read only","Error",MB_ICONERROR | MB_OK);
		return;
	}

	if (USBReg[regIndex].type & NO_USE)
	{
		if (MessageBox("The selected address is reserved.\nResult of writing to this address is unpredictable.\nDo you want to continue?\n",
			"Warning",MB_ICONWARNING|MB_YESNO ) == IDNO)
				   return;
	}

	else
	{
		if (USBReg[regIndex].type & CLEARED_WRITE)
		{
			if (MessageBox("Some bits of the selected register will be cleared on write.\nWriting to this register may change the firmware behavior.\nDo you want to continue?\n",
				"Warning",MB_ICONWARNING|MB_YESNO ) == IDNO)
					   return;
		}
		else
		if ((USBReg[regIndex].type & READ_ONLY)||(USBReg[regIndex].type & CLEARED_READ))
		{
			if (MessageBox("Some bits of the selected register are read only.\nWriting to these bits has no effect.\nDo you want to continue?\n",
				"Warning",MB_ICONWARNING|MB_YESNO ) == IDNO)
					   return;
		}
	}


	if (UARTChannel)
	{
		/* Use UART */
		Uart	   uart;
		BYTE	   buffer[3];

		if (!uart.OpenUART(COMNum))
		{
			MessageBox("Cannot open communication channel.","Error",MB_ICONERROR | MB_OK);
			return;
		}
		
		buffer[0] = WRITE_USB_REG;
		buffer[1] = USBReg[regIndex].address;
		buffer[2] = regValue;
		if (!uart.WriteData(buffer,3))
		{
			MessageBox("Cannot write to communication channel.","Error",MB_ICONERROR | MB_OK);
			uart.CloseUART();
			return;
		}
		

		uart.CloseUART();
	}
	else
	{
		/* Use USB conrol */
		if (!ControlFunc::SendSetupPacketOut(WRITE_USB_REG, USBReg[regIndex].address,regValue,0))
		{
		/* Can't send setup packet */
			MessageBox("Write register failed.","Error",MB_ICONERROR | MB_OK);		    
		}

	}


}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日本一区二区在线不卡| 亚洲国产一区二区a毛片| a在线播放不卡| 午夜精品一区二区三区免费视频| 国产农村妇女精品| 午夜欧美一区二区三区在线播放| 成人av影视在线观看| 粗大黑人巨茎大战欧美成人| 国产精品一区久久久久| 视频一区视频二区在线观看| 天天影视色香欲综合网老头| 99精品在线观看视频| 欧洲视频一区二区| 99精品国产一区二区三区不卡| 日韩精品中文字幕在线不卡尤物| 欧美视频你懂的| 欧美日韩亚洲综合一区二区三区| 色999日韩国产欧美一区二区| 色老头久久综合| 国产精品污网站| 一区2区3区在线看| 亚洲福中文字幕伊人影院| 成人动漫一区二区| 国产精品日日摸夜夜摸av| 国产揄拍国内精品对白| 高清视频一区二区| 91成人看片片| 亚洲人成精品久久久久| 亚洲国产精品人人做人人爽| 波多野结衣在线一区| 国产欧美视频一区二区| 国产精品一区二区在线看| 精品国产91乱码一区二区三区| 久久精品无码一区二区三区| 成人欧美一区二区三区在线播放| 亚洲最色的网站| 97久久精品人人做人人爽| 国产精品国产成人国产三级| 视频在线观看国产精品| 欧美精品欧美精品系列| 国产午夜亚洲精品羞羞网站| 国产精品一二三四五| 久久久久久黄色| 肉丝袜脚交视频一区二区| 欧美日韩国产三级| 国产女主播视频一区二区| 国产成人av网站| 欧美一区二区三区四区久久| 欧美激情一区在线| 同产精品九九九| 日韩你懂的电影在线观看| 国产一区不卡在线| 中文字幕av在线一区二区三区| 不卡的看片网站| 亚洲在线观看免费| 成人免费av在线| 综合欧美一区二区三区| 国产精品影视天天线| 国产精品私人自拍| 欧美日韩国产一区| 国产伦精一区二区三区| 中文字幕在线免费不卡| 欧美日精品一区视频| 国产一区二区三区四区五区美女| 中文字幕成人av| 欧美精品成人一区二区三区四区| 精品一区二区三区视频在线观看 | 亚洲香肠在线观看| 4438x成人网最大色成网站| 亚洲欧美综合另类在线卡通| 欧美日韩精品电影| 国产乱码精品一区二区三区忘忧草 | 国产精品传媒视频| 欧美老肥妇做.爰bbww视频| 久久99精品国产麻豆婷婷洗澡| 中文一区二区完整视频在线观看| 欧美亚一区二区| 国产一区美女在线| 亚洲一区精品在线| 欧美国产精品专区| 欧美酷刑日本凌虐凌虐| 成人国产免费视频| 美女一区二区三区在线观看| 欧美午夜片在线看| 高清shemale亚洲人妖| 亚洲1区2区3区4区| 欧美色涩在线第一页| 国产乱码精品一区二区三区av | 欧美一区二区视频在线观看| 国产成人亚洲精品狼色在线| 天天色综合成人网| 亚洲欧美日韩国产成人精品影院| 久久久久久久av麻豆果冻| 91精品久久久久久久91蜜桃| 色综合天天做天天爱| 国产精品沙发午睡系列990531| 欧美日韩久久久一区| 色呦呦一区二区三区| 亚洲国产欧美一区二区三区丁香婷| 久久精品视频在线看| 欧美电视剧免费全集观看| 精品视频资源站| 欧洲精品在线观看| 91免费观看在线| 亚洲电影在线播放| 亚洲美女视频在线| 亚洲图片激情小说| 国产精品免费视频网站| 亚洲国产精品精华液ab| 国产丝袜在线精品| 国产亚洲美州欧州综合国| 日韩欧美在线1卡| 成人国产视频在线观看| 国产精品亚洲成人| 国产成人av网站| a在线播放不卡| 91一区二区三区在线观看| gogogo免费视频观看亚洲一| 菠萝蜜视频在线观看一区| 色偷偷一区二区三区| 色欧美片视频在线观看在线视频| 色屁屁一区二区| 欧美剧情片在线观看| 制服视频三区第一页精品| 欧美一区二区在线播放| 日韩午夜在线影院| 久久人人97超碰com| 欧美国产综合色视频| 国产精品成人一区二区艾草| 一区二区三区**美女毛片| 爽好多水快深点欧美视频| 日韩福利视频导航| 亚洲人成小说网站色在线| 亚洲自拍偷拍av| 天堂午夜影视日韩欧美一区二区| 美女国产一区二区三区| 国产麻豆成人传媒免费观看| 成人国产精品免费观看视频| 色呦呦国产精品| 精品免费国产二区三区| 在线观看一区不卡| 欧美一区二区三区免费| 国产日产亚洲精品系列| 日韩一区有码在线| 男人操女人的视频在线观看欧美| 一区二区视频在线| 欧美激情在线观看视频免费| 亚洲精品国产精华液| 日韩成人免费电影| 成人久久视频在线观看| 在线视频欧美精品| 久久精品免费在线观看| 一区二区三区在线播| 另类调教123区| 蜜桃免费网站一区二区三区| 国产一区二区福利视频| 欧美色图片你懂的| 日本一区二区电影| 久久精品久久99精品久久| 不卡的av电影| 久久蜜臀精品av| 偷拍与自拍一区| 97久久久精品综合88久久| 亚洲精品一区二区三区四区高清| 亚洲女爱视频在线| 国产精选一区二区三区| 欧美高清性hdvideosex| 自拍偷拍欧美激情| 国产一区二区三区在线观看免费视频 | 91麻豆精品国产综合久久久久久| 国产日韩精品一区二区三区在线| 婷婷综合另类小说色区| 91小视频免费看| 国产欧美日韩在线| 麻豆91免费看| 欧美三区在线视频| 亚洲欧美日韩综合aⅴ视频| 国产激情偷乱视频一区二区三区| 欧美丰满高潮xxxx喷水动漫| 一区在线观看免费| 国产成人在线看| 精品精品欲导航| 日韩经典中文字幕一区| 欧美在线观看18| 亚洲精品视频在线看| 成人ar影院免费观看视频| 久久麻豆一区二区| 韩国理伦片一区二区三区在线播放| 国产成人丝袜美腿| 精品黑人一区二区三区久久| 日韩不卡一二三区| 欧美丰满嫩嫩电影| 青草国产精品久久久久久| 欧美日韩国产影片| 亚洲国产一区二区视频| 欧美日韩视频不卡| 午夜精彩视频在线观看不卡| 欧美中文字幕一区二区三区亚洲| 亚洲日本在线a| 欧美中文字幕一区|