WORD GetPixel(SHORT x, SHORT y) { DWORD address; WORD result; #if (DISP_ORIENTATION == 0) address = (long)LINE_MEM_PITCH * y + x; #else y = GetMaxY() - y; address = (long)LINE_MEM_PITCH * x + y; #endif CS_LAT_BIT = 0; SetAddress(address); // Temporary change wait cycles for reading (250ns = 4 cycles) #if defined(__C30__) PMMODEbits.WAITM = 4; #elif defined(__PIC32MX__) PMMODEbits.WAITM = 8; #else #error Need wait states for the device #endif RS_LAT_BIT = 1; // First RD cycle to move data from GRAM to Read Data Latch result = PMDIN1; while(PMMODEbits.BUSY); // Second RD cycle to get data from Read Data Latch result = PMDIN1; while(PMMODEbits.BUSY); // Disable LCD CS_LAT_BIT = 1; // Disable PMP PMCONbits.PMPEN = 1; // Read result result = PMDIN1; // Restore wait cycles for writing (60ns) #if defined(__dsPIC33F__) || defined(__PIC24H__) PMMODEbits.WAITM = 2; #else PMMODEbits.WAITM = 1; #endif // Enable PMP PMCONbits.PMPEN = 1; return (result); }
/********************************************************************* * Function: WORD GetPixel(SHORT x, SHORT y) * * PreCondition: none * * Input: x,y - pixel coordinates * * Output: pixel color * * Side Effects: none * * Overview: returns pixel color at x,y position * * Note: none * ********************************************************************/ WORD GetPixel(SHORT x, SHORT y){ DWORD_VAL address; WORD_VAL result; #ifdef USE_PORTRAIT address.Val = (long)LINE_MEM_PITCH*y + x; #else y = GetMaxY() - y; address.Val = (long)LINE_MEM_PITCH*x + y; #endif CS_LAT_BIT = 0; SetAddress(address.v[2],address.v[1],address.v[0]); // Temporary change wait cycles for reading (250ns = 4 cycles) PMMODEbits.WAITM = 4; RS_LAT_BIT = 1; // First RD cycle to move data from GRAM to Read Data Latch result.v[1] = PMDIN1; while(PMMODEbits.BUSY); // Second RD cycle to move data from GRAM to Read Data Latch result.v[1] = PMDIN1; while(PMMODEbits.BUSY); // First RD cycle to get data from Read Data Latch // Read previous dummy value result.v[1] = PMDIN1; while(PMMODEbits.BUSY); // Second RD cycle to get data from Read Data Latch // Read MSB result.v[1] = PMDIN1; while(PMMODEbits.BUSY); // Disable LCD CS_LAT_BIT = 1; // Disable PMP PMCONbits.PMPEN = 1; // Read LSB result.v[0] = PMDIN1; // Restore wait cycles for writing (60ns = 1 cycle) PMMODEbits.WAITM = 1; // Enable PMP PMCONbits.PMPEN = 1; return result.Val; }
void VirtualMachineGUI::LeaveRunMode() { SetContinueFlag(false); _pThread->Wait(); delete _pThread; _pThread = NULL; SetMode(MODE_Program); SetAddress(0x00); //DoNotifyRegisterChange(); }
/********************************************************************* * Function: void ClearDevice(void) * * PreCondition: none * * Input: none * * Output: none * * Side Effects: none * * Overview: clears screen with current color * * Note: none * ********************************************************************/ void ClearDevice(void){ DWORD counter; CS_LAT_BIT = 0; SetAddress(0); for(counter=0; counter<(DWORD)(GetMaxX()+1)*(GetMaxY()+1); counter++){ WriteData(_color); } CS_LAT_BIT = 1; }
bool TCPIPPort::SetAddress(const String &address) { IPAddress listeningAddress; if (!listeningAddress.TryParse(address)) return false; SetAddress(listeningAddress); return true; }
//----------------------------------------------------------------------------------- // Purpose : // Return : //----------------------------------------------------------------------------------- // Called by Worker TH ( IOCP ) //----------------------------------------------------------------------------------- int CNtlConnection::CompleteAccept(DWORD dwTransferedBytes) { FUNCTION_BEGIN(); UNREFERENCED_PARAMETER( dwTransferedBytes ); SOCKADDR_IN * pLocalAddr = NULL; SOCKADDR_IN * pRemoteAddr = NULL; int nLocalAddrLen = 0; int nRemoteAddrLen = 0; m_socket.GetAcceptExSockaddrs( m_recvContext.wsabuf.buf, 0, sizeof(SOCKADDR_IN) + 16, sizeof(SOCKADDR_IN) + 16, (SOCKADDR**) &pLocalAddr, &nLocalAddrLen, (SOCKADDR**) &pRemoteAddr, &nRemoteAddrLen); SetAddress( pLocalAddr, pRemoteAddr ); ZeroMemory( m_recvContext.wsabuf.buf, sizeof(SOCKADDR_IN) + 16 + sizeof(SOCKADDR_IN) + 16 ); m_bConnected = true; int rc = m_pNetworkRef->Associate( this, true ); if( NTL_SUCCESS != rc ) { NTL_LOGDL( LOG_NETWORK, "Session[%X] Associate Error[%d:%s]", this, rc, NtlGetErrorMessage(rc) ); return rc; } SetStatus( STATUS_ACTIVE ); m_dwConnectTime = GetTickCount(); m_pAcceptorRef->OnAccepted(); m_pNetworkRef->PostNetEventMessage( (WPARAM)NETEVENT_ACCEPT, (LPARAM)this ); rc = PostRecv(); if( NTL_SUCCESS != rc ) { return rc; } //NTL_PRINT(PRINT_SYSTEM, "Session[%X]\tCompleteAccept Called Local[%s:%u] Remote[%s:%u]", pSession, GetLocalIP(), GetLocalPort(), GetRemoteIP(), GetRemotePort()); return NTL_SUCCESS; }
void CodeViewWidget::OnFollowBranch() { const u32 addr = GetContextAddress(); u32 branch_addr = GetBranchFromAddress(addr); if (!branch_addr) return; SetAddress(branch_addr, SetAddressUpdate::WithUpdate); }
/********************************************************************* * Function: void PutImage16BPP(SHORT left, SHORT top, FLASH_BYTE* image, BYTE stretch) * * PreCondition: none * * Input: left,top - left top image corner, image - image pointer, * stretch - image stretch factor * * Output: none * * Side Effects: none * * Overview: outputs hicolor image starting from left,top coordinates * * Note: image must be located in flash * ********************************************************************/ void PutImage16BPP(SHORT left, SHORT top, FLASH_BYTE *image, BYTE stretch) { register DWORD address; register FLASH_WORD *flashAddress; register FLASH_WORD *tempFlashAddress; WORD sizeX, sizeY; register WORD x, y; WORD temp; register BYTE stretchX, stretchY; // Move pointer to size information flashAddress = (FLASH_WORD *)image + 1; // Set start address address = BUF_MEM_OFFSET + (long)LINE_MEM_PITCH * top + left; // Read image size sizeY = *flashAddress; flashAddress++; sizeX = *flashAddress; flashAddress++; DisplayEnable(); for(y = 0; y < sizeY; y++) { tempFlashAddress = flashAddress; for(stretchY = 0; stretchY < stretch; stretchY++) { flashAddress = tempFlashAddress; SetAddress(address); for(x = 0; x < sizeX; x++) { // Read pixels from flash temp = *flashAddress; flashAddress++; // Set color SetColor(temp); // Write pixel to screen for(stretchX = 0; stretchX < stretch; stretchX++) { DeviceWrite(SETCOLOR_HIBYTE(_color)); DeviceWrite(SETCOLOR_LOWBYTE(_color)); } } address += LINE_MEM_PITCH; } } DisplayDisable(); }
/* rcode 0 if no errors. rcode 01-0f is relayed from HRSL */ uint8_t USB::outTransfer(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t* data) { EpInfo *pep = NULL; uint16_t nak_limit = 0; uint8_t rcode = SetAddress(addr, ep, &pep, nak_limit); if(rcode) return rcode; return OutTransfer(pep, nak_limit, nbytes, data); }
/* rcode 0 if no errors. rcode 01-0f is relayed from dispatchPkt(). Rcode f0 means RCVDAVIRQ error, fe USB xfer timeout */ uint8_t USB::inTransfer(uint8_t addr, uint8_t ep, uint16_t *nbytesptr, uint8_t* data) { EpInfo *pep = NULL; uint16_t nak_limit = 0; uint8_t rcode = SetAddress(addr, ep, &pep, nak_limit); if (rcode) { //printf("SetAddress Failed"); return rcode; } return InTransfer(pep, nak_limit, nbytesptr, data); }
LRESULT CMainFrame::OnMDIActivate (WPARAM wParam, LPARAM lPAram) { m_wndClientArea.SendMessage (WM_MDIACTIVATE, wParam, lPAram); CHtmlView* pView = GetActiveHTML (); if (pView != NULL) { SetAddress (pView->GetLocationURL ()); } return 0L; }
void BNetworkAddress::SetTo(const in6_addr& inet6Address, uint16 port) { memset(&fAddress, 0, sizeof(sockaddr_storage)); fAddress.ss_family = AF_INET6; fAddress.ss_len = sizeof(sockaddr_in6); SetAddress(inet6Address); SetPort(port); fStatus = B_OK; }
bool ToSaMeshNode::Init(uint16_t newaddr) { if (!SetAddress(newaddr)) return false; while (addr == TOSA_MESH_NOADDRESS) { SendDhcpRequest(); unsigned long resubmit = millis() + 15000; // ToDo : variable resubmit delay - here 15 seconds while ((addr == TOSA_MESH_NOADDRESS) && (millis() < resubmit)) { TickRx(); } } return true; }
/* rcode 0 if no errors. rcode 01-0f is relayed from dispatchPkt(). Rcode f0 means RCVDAVIRQ error, fe USB xfer timeout */ uint8_t UsbHost_::inTransfer( uint8_t addr, uint8_t ep, uint16_t *nbytesptr, uint8_t* data) { EpInfo *pep = NULL; uint16_t nak_limit = 0; uint8_t rcode = SetAddress(addr, ep, &pep, nak_limit); if (rcode) return rcode; return InTransfer(pep, nak_limit, nbytesptr, data); }
/********************************************************************* * Function: void ClearDevice(void) * * PreCondition: none * * Input: none * * Output: none * * Side Effects: none * * Overview: clears screen with current color * * Note: none * ********************************************************************/ void ClearDevice(void) { DWORD counter; DisplayEnable(); SetAddress(0); for(counter = 0; counter < (DWORD) (GetMaxX() + 1) * (GetMaxY() + 1); counter++) { WritePixel(_color); } DisplayDisable(); }
/********************************************************************* * Function: void ClearDevice(void) * * PreCondition: none * * Input: none * * Output: none * * Side Effects: none * * Overview: clears screen with current color * * Note: none * ********************************************************************/ void ClearDevice(void) { DWORD counter; DeviceSelect; SetAddress(0, 0); for(counter = 0; counter < (DWORD) (GetMaxX() + 1) * (GetMaxY() + 1); counter++) { WritePixel(_color); } DeviceDeselect; }
/* rcode 0 if no errors. rcode 01-0f is relayed from dispatchPkt(). Rcode f0 means RCVDAVIRQ error, fe USB xfer timeout */ uint8_t USB::inTransfer(uint8_t addr, uint8_t ep, uint16_t *nbytesptr, uint8_t* data, uint8_t bInterval /*= 0*/) { EpInfo *pep = NULL; uint16_t nak_limit = 0; uint8_t rcode = SetAddress(addr, ep, &pep, &nak_limit); if (rcode) { USBTRACE3("(USB::InTransfer) SetAddress Failed ", rcode, 0x81); USBTRACE3("(USB::InTransfer) addr requested ", addr, 0x81); USBTRACE3("(USB::InTransfer) ep requested ", ep, 0x81); return rcode; } return InTransfer(pep, nak_limit, nbytesptr, data, bInterval); }
void CSocket::Connect(const char *strAddress,WORD port) { sockaddr_in tcp_address = SetAddress(strAddress, port); int nRet = connect(m_CurSocket, (LPSOCKADDR)&tcp_address, sizeof(SOCKADDR_IN)); if(SOCKET_ERROR == nRet) { assert("[Error]Connect fail!"); Release(); } else { m_State = TCP_ONLINE; FD_SET(m_CurSocket, &m_SocketSet);//把Clinet的SOCKET放到fd_set中 } }
/********************************************************************* * Function: void ClearDevice(void) * * PreCondition: none * * Input: none * * Output: none * * Side Effects: none * * Overview: clears screen with current color * * Note: none * ********************************************************************/ void ClearDevice(void) { DWORD counter; DisplayEnable(); SetAddress(0x018000); for(counter = 0; counter < (DWORD) (GetMaxX() + 1) * (GetMaxY() + 1); counter++) { DeviceWrite(SETCOLOR_HIBYTE(_color)); DeviceWrite(SETCOLOR_LOWBYTE(_color)); } DisplayDisable(); MoveTo(0, 0); }
void SetAddress(const std::string &address) { Clear(); // parse quint32 ip = 0; if ( !ParseIp4(address, ip) ) { m_isCorrectIpString = false; return; } // set SetAddress(ip); }
int Connections::CompleteAccept(DWORD TransferedBytes) { FUNCTION_BEGIN(); UNREFERENCED_PARAMETER(TransferedBytes); SOCKADDR_IN* LocalAddr = NULL; SOCKADDR_IN* RemoteAddr = NULL; int LocalAddrLen = 0; int RemoteAddrLen = 0; _socket.GetAcceptExSockaddrs(_recvContext.wsabuf.buf, 0, sizeof(SOCKADDR_IN) + 16, sizeof(SOCKADDR_IN) + 16, (SOCKADDR**)&LocalAddr, &LocalAddrLen, (SOCKADDR**)&RemoteAddr, &RemoteAddrLen); SetAddress(LocalAddr, RemoteAddr); ZeroMemory(_recvContext.wsabuf.buf, sizeof(SOCKADDR_IN) + 16 + sizeof(SOCKADDR_IN) + 16); _IsConnected = true; int rc = _NetworkRef->Associate(this, true); if (0 != rc) { Logger::Log("Session[%X] Associate Error[%d]\n", this, rc); return rc; } SetStatus(CONNSTATUS_ACTIVE); _ConnectTime = GetTickCount(); Logger::Log("Client connected %s:%d [%d]\n", GetRemoteIP(), GetRemotePort(), this); _AcceptorRef->OnAccepted(); _NetworkRef->PostNetEventMessage((WPARAM)NETEVENT_ACCEPT, (LPARAM)this); rc = PostRecv(); if (0 != rc) { return rc; } return 0; }
void CEC_LogicalDevice::Initialize(CEC_DEVICE_TYPE type) { CEC_Electrical::Initialize(); _deviceType = type; if (MonitorMode) { _primaryState = CEC_READY; } else if (_physicalAddress == 0) {//we are a TV! _logicalAddress = 0; SetAddress(_logicalAddress); _primaryState = CEC_READY; DbgPrint("Logical address assigned: %d\r\n", _logicalAddress); DbgPrint("Physical addresss used: %d\r\n", _physicalAddress); } }
EHCIDevice::EHCIDevice(EHCIController& controller) : _controller(controller), _pControlQH(controller.CreateDeviceQueueHead(64, 0, 0)), _bFirstBulkRead(true), _bFirstBulkWrite(true) { if(!SetAddress()) throw upan::exception(XLOC, "SetAddress Failed"); USBStandardDeviceDesc devDesc; if(!GetDeviceDescriptor(&devDesc)) throw upan::exception(XLOC, "GetDevDesc Failed"); devDesc.DebugPrint(); char bConfigValue = 0; if(!GetConfigValue(bConfigValue)) throw upan::exception(XLOC, "GetConfigVal Failed") ; printf("\n ConfifValue: %d", bConfigValue) ; if(!CheckConfiguration(bConfigValue, devDesc.bNumConfigs)) throw upan::exception(XLOC, "CheckConfig Failed"); if(!GetConfigDescriptor(devDesc.bNumConfigs, &_pArrConfigDesc)) throw upan::exception(XLOC, "GeConfigDesc Failed"); USBDataHandler_CopyDevDesc(&_deviceDesc, &devDesc, sizeof(USBStandardDeviceDesc)) ; if(GetStringDescriptorZero()) SetLangId(); else // throw upan::exception(XLOC, "GetStringDescZero Failed"); printf("\n String DESC not supported!"); _iConfigIndex = 0 ; for(int i = 0; i < devDesc.bNumConfigs; i++) { if(_pArrConfigDesc[ i ].bConfigurationValue == bConfigValue) { _iConfigIndex = i; break ; } } GetDeviceStringDesc(_manufacturer, _deviceDesc.indexManufacturer); GetDeviceStringDesc(_product, _deviceDesc.indexProduct); GetDeviceStringDesc(_serialNum, _deviceDesc.indexSerialNum); PrintDeviceStringDetails(); }
/********************************************************************* * Function: void ClearDevice(void) * * PreCondition: none * * Input: none * * Output: none * * Side Effects: none * * Overview: clears screen with current color * * Note: none * ********************************************************************/ void ClearDevice(void) { DWORD counter; DeviceSelect(); SetAddress(0, 0); DeviceSetCommand(); DeviceWrite(CMD_WRITE); DeviceSetData(); for(counter = 0; counter < (DWORD) (GetMaxX() + 1) * (GetMaxY() + 1); counter++) { DeviceWrite(_color.v[1]); DeviceWrite(_color.v[0]); } DeviceDeselect(); }
int CClient::Init() { // make sure everythings is fine for windows #ifdef _WIN32 WSADATA wsaData; if (WSAStartup (MAKEWORD (1, 1), &wsaData) != 0) { CConsole::Print("Client: Failed to init (WSAStartup)!\n"); return -1; } #endif if(SetAddress() == -1) return -1; char aIP[INET6_ADDRSTRLEN]; struct addrinfo *pP; for(pP = m_pServInfo; pP != NULL; pP = pP->ai_next) { if ((m_Sockfd = socket(pP->ai_family, pP->ai_socktype, pP->ai_protocol)) == -1) { continue; } if (connect(m_Sockfd, pP->ai_addr, pP->ai_addrlen) == -1) { close(m_Sockfd); continue; } break; } if (pP == NULL) { CConsole::Print("Client: Failed to init (connect)!\n"); freeaddrinfo(m_pServInfo); return -1; } #ifdef _WIN32 getnameinfo((struct sockaddr *)pP->ai_addr, sizeof (struct sockaddr), aIP, sizeof aIP, 0, NI_MAXSERV, NI_NUMERICSERV); #else inet_ntop(pP->ai_family, GetInAddr((struct sockaddr *)pP->ai_addr), aIP, sizeof aIP); #endif CConsole::Print("Client: connecting to %s\n\n", aIP); freeaddrinfo(m_pServInfo); return 0; }
/********************************************************************* * Function: void PutPixel(SHORT x, SHORT y) * * PreCondition: none * * Input: x,y - pixel coordinates * * Output: none * * Side Effects: none * * Overview: puts pixel * * Note: none * ********************************************************************/ void PutPixel(SHORT x, SHORT y){ DWORD address; if(_clipRgn){ if(x<_clipLeft) return; if(x>_clipRight) return; if(y<_clipTop) return; if(y>_clipBottom) return; } address = (DWORD)(GetMaxX( ) +1)*y + x; SetAddress(address); CS_LAT_BIT = 0; WriteData(_color); CS_LAT_BIT = 1; }
/********************************************************************* * Function: WORD Bar(SHORT left, SHORT top, SHORT right, SHORT bottom) * * PreCondition: none * * Input: left,top - top left corner coordinates, * right,bottom - bottom right corner coordinates * * Output: For NON-Blocking configuration: * - Returns 0 when device is busy and the shape is not yet completely drawn. * - Returns 1 when the shape is completely drawn. * For Blocking configuration: * - Always return 1. * * Side Effects: none * * Overview: draws rectangle filled with current color * * Note: none * ********************************************************************/ WORD Bar(SHORT left, SHORT top, SHORT right, SHORT bottom) { DWORD address; register SHORT x, y; #ifndef USE_NONBLOCKING_CONFIG while(IsDeviceBusy() != 0); /* Ready */ #else if(IsDeviceBusy() != 0) return (0); #endif if(_clipRgn) { if(left < _clipLeft) left = _clipLeft; if(right > _clipRight) right = _clipRight; if(top < _clipTop) top = _clipTop; if(bottom > _clipBottom) bottom = _clipBottom; } address = BUF_MEM_OFFSET + (DWORD) LINE_MEM_PITCH * top + left; DisplayEnable(); for(y = top; y < bottom + 1; y++) { SetAddress(address); for(x = left; x < right + 1; x++) { DeviceWrite(SETCOLOR_HIBYTE(_color)); DeviceWrite(SETCOLOR_LOWBYTE(_color)); } address += LINE_MEM_PITCH; } DisplayDisable(); return (1); }
/********************************************************************* * Function: void PutPixel(SHORT x, SHORT y) * * PreCondition: none * * Input: x,y - pixel coordinates * * Output: none * * Side Effects: none * * Overview: puts pixel * * Note: none * ********************************************************************/ void PutPixel(SHORT x, SHORT y) { if(_clipRgn) { if(x < _clipLeft) return; if(x > _clipRight) return; if(y < _clipTop) return; if(y > _clipBottom) return; } CS_LAT_BIT = 0; SetAddress(x, y); WriteData(_color); CS_LAT_BIT = 1; }
/********************************************************************* * Function: void PutPixel(SHORT x, SHORT y) * * PreCondition: none * * Input: x,y - pixel coordinates * * Output: none * * Side Effects: none * * Overview: puts pixel * * Note: none * ********************************************************************/ void PutPixel(SHORT x, SHORT y) { if(_clipRgn) { if(x < _clipLeft) return; if(x > _clipRight) return; if(y < _clipTop) return; if(y > _clipBottom) return; } DeviceSelect; SetAddress(x, y); WritePixel(_color); DeviceDeselect; }
/********************************************************************* * Function: void PutPixel(SHORT x, SHORT y) * * PreCondition: none * * Input: x,y - pixel coordinates * * Output: none * * Side Effects: none * * Overview: puts pixel * * Note: none * ********************************************************************/ void PutPixel(SHORT x, SHORT y) { if(_clipRgn) { if(x < _clipLeft) return; if(x > _clipRight) return; if(y < _clipTop) return; if(y > _clipBottom) return; } DisplayEnable(); SetAddress(x, y); WritePixel(_color); DisplayDisable(); }