void Controls::CatchController(const sf::Event &event) { std::string index = ""; if (this->num_play == 1) this->ctrlCu = this->ctrlK1; else this->ctrlCu = this->ctrlK2; if (CheckEvent(event, 850, 1055, 415, 470)) index = "up"; else if (CheckEvent(event, 550, 755, 535, 590)) index = "left"; else if (CheckEvent(event, 850, 1050, 540, 590)) index = "down"; else if (CheckEvent(event, 1225, 1425, 540, 590)) index = "right"; else if (CheckEvent(event, 850, 1050, 660, 710)) index = "bomb"; if (index.size() > 1) { this->ctrlCu[index] = "Key"; this->Display(); this->_Window->display(); KeyInput(index); } }
//***************************************************************************** // @brief Writes one byte to the LSM303. // @param slAddr : slave address LSM_A_ADDRESS or LSM_M_ADDRESS // @param pBuffer : pointer to the buffer containing the data to be written // to the LSM303. // @param WriteAddr : address of the register in which the data will // be written // @retval None //***************************************************************************** static void ByteWrite(uint8_t slAddr, uint8_t* pBuffer, uint8_t WriteAddr) { /* Send START condition */ GenerateSTART(I2C1, ENABLE); /* Test on EV5 and clear it */ while(!CheckEvent(I2C1, I2C_EVENT_MASTER_MODE_SELECT)); /* Send address for write */ Send7bitAddress(I2C1, slAddr, I2C_Direction_Transmitter); /* Test on EV6 and clear it */ while(!CheckEvent(I2C1, I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED)); /* Send the internal address to write to */ SendData(I2C1, WriteAddr); /* Test on EV8 and clear it */ while(!CheckEvent(I2C1, I2C_EVENT_MASTER_BYTE_TRANSMITTED)); /* Send the byte to be written */ SendData(I2C1, *pBuffer); /* Test on EV8 and clear it */ while(!CheckEvent(I2C1, I2C_EVENT_MASTER_BYTE_TRANSMITTED)); /* Send STOP condition */ GenerateSTOP(I2C1, ENABLE); }
void Controls::Run() { sf::Event event; std::string str; this->PlaySound("yay"); this->LoadSprite(RESOURCEPATH"controlBg.png", &this->_Sprite); while (this->_Window->isOpen()) { while (this->_Window->pollEvent(event)) { this->Quit(event); if (event.type == sf::Event::MouseButtonPressed && event.mouseButton.button == sf::Mouse::Left) { if (CheckEvent(event, 1050, 1075, 230, 240) && this->num_play > 1) this->num_play-= 1; if (CheckEvent(event,1175, 1210, 220, 255) && this->num_play < 2) this->num_play+= 1; if (CheckEvent(event,1550, 1900, 960, 1010)) InitKBoards(); if (CheckEvent(event, 15, 285, 970, 1045)) return; this->CatchController(event); } } this->Binding(); this->_Window->clear(); this->Display(); this->_Window->display(); } }
/* * Handle a "special request" */ static errr Term_xtra_xaw(int n, int v) { term_data *td = (term_data*)(Term->data); Widget widget = (Widget)(td->widget); Display *dpy = XtDisplay(widget); /* Handle a subset of the legal requests */ switch (n) { /* Make a noise */ case TERM_XTRA_NOISE: XBell(dpy, 100); return (0); /* Flush the output */ case TERM_XTRA_FRESH: XFlush(dpy); /* Allow flushed events to be showed */ CheckEvent(FALSE); return (0); /* Process random events */ case TERM_XTRA_BORED: return (CheckEvent(0)); /* Process events */ case TERM_XTRA_EVENT: return (CheckEvent(v)); /* Flush events */ case TERM_XTRA_FLUSH: while (!CheckEvent(FALSE)); return (0); /* Clear the window */ case TERM_XTRA_CLEAR: XClearWindow(dpy, XtWindow(widget)); return (0); /* Delay */ case TERM_XTRA_DELAY: usleep(1000 * v); return (0); case TERM_XTRA_REACT: return (Term_xtra_xaw_react()); } /* Unknown */ return (1); }
void EditUpload::okData() { if(!CheckFormat()) { QMessageBox::warning(this,tr("Unsupported Format"), tr("The currently selected export format is unsupported on host ")+edit_station_box->currentText()+"!"); return; } if(QUrl::isRelativeUrl(edit_url_edit->text())|| (edit_url_edit->text().right(1)=="/")) { QMessageBox::warning(this,tr("Invalid URL"),tr("The URL is invalid!")); return; } RDUrl url(edit_url_edit->text()); QString protocol=url.protocol(); if((protocol!="ftp")&&(protocol!="file")&& (protocol!="scp")&&(protocol!="sftp")) { QMessageBox::warning(this, tr("Invalid URL"),tr("Unsupported URL protocol!")); return; } if((protocol=="file")&&(edit_username_edit->text().isEmpty())) { QMessageBox::warning(this,tr("Missing Username"), tr("You must specify a username!")); return; } if(!CheckEvent(false)) { QMessageBox::warning(this,tr("Duplicate Event"), tr("An event with these parameters already exists!")); return; } Save(); done(0); }
/*----------------------------------------------------------------------------- * main */ int main(void) { uint8_t ret; int sioHdl; /* set clock prescaler to 2 (set clock to 7.3928 MHz) */ CLKPR = 1 << CLKPCE; CLKPR = 1; /* get module address from EEPROM */ sMyAddr = eeprom_read_byte((const uint8_t *)MODUL_ADDRESS); GetClientListFromEeprom(); PortInit(); TimerInit(); ButtonInit(); PwmInit(); ApplicationInit(); SioInit(); SioRandSeed(sMyAddr); /* sio for bus interface */ sioHdl = SioOpen("USART1", eSioBaud9600, eSioDataBits8, eSioParityNo, eSioStopBits1, eSioModeHalfDuplex); SioSetIdleFunc(sioHdl, IdleSio1); SioSetTransceiverPowerDownFunc(sioHdl, BusTransceiverPowerDown); BusTransceiverPowerDown(true); BusInit(sioHdl); spBusMsg = BusMsgBufGet(); /* warten for full operation voltage */ while (!POWER_GOOD); /* enable ints before RestorePwm() */ ENABLE_INT; TimerStart(); RestorePwm(); /* ext int for power fail: INT0 low level sensitive */ EICRA &= ~((1 << ISC01) | (1 << ISC00)); EIMSK |= (1 << INT0); ApplicationStart(); /* Hauptschleife */ while (1) { Idle(); ret = BusCheck(); ProcessBus(ret); CheckButton(); PwmCheck(); ApplicationCheck(); CheckEvent(); } return 0; }
void GetEvent(ctr_yaml_context *ctx) { if (!yaml_parser_parse(&ctx->parser, &ctx->event)){ ctx->error = YAML_API_ERROR; return; } CheckEvent(ctx); }
void EditUpload::saveasData() { if(!CheckEvent(true)) { QMessageBox::warning(this,tr("Duplicate Event"), tr("An event with these parameters already exists!")); return; } delete edit_recording; edit_recording=new RDRecording(-1,true); edit_added_events->push_back(edit_recording->id()); Save(); }
void Welcome::Run() { sf::Event event; this->PlaySound("menu"); this->LoadSprite2(RESOURCEPATH"Menu.png", &this->_Sprite); while (this->_Window->isOpen()) { this->_Window->clear(); this->Display(); this->_Window->display(); while (this->_Window->pollEvent(event)) { this->Quit(event); if (event.type == sf::Event::MouseButtonPressed && event.mouseButton.button == sf::Mouse::Left) { if (CheckEvent(event, 755, 1175, 885, 970)) this->_Window->close(); else if (CheckEvent(event, 640, 1215, 775, 855)) this->_Credit->Run(); else if (CheckEvent(event, 690, 1170, 658, 742)) this->_Score->Run(0); else if (CheckEvent(event, 640, 1215, 545, 630)) this->_Option->Run(); else if (CheckEvent(event, 745, 1080, 435, 515)) this->_Load->Run(); else if (CheckEvent(event, 745, 1080, 320, 400)) this->_Mode->Run(); } } } }
void Option::Run() { sf::Event event; this->LoadSprite(RESOURCEPATH"optionBg.png", &this->_Sprite); this->PlaySound("yay"); while (this->_Window->isOpen()) { while (this->_Window->pollEvent(event)) { this->Quit(event); if (event.type == sf::Event::MouseButtonPressed && event.mouseButton.button == sf::Mouse::Left){ std::cout << event.mouseButton.x << /*std::endl;*/ " " << event.mouseButton.y << std::endl; if (CheckEvent(event, 750, 1150, 390, 460)) this->_Controls->Run(); else if (CheckEvent(event, 750, 1050, 510, 560)) this->_Camera->Run(); else if (CheckEvent(event, 1085, 1156, 630, 700) && G_GameSettings->volume >= 0.1) { this->PlaySound("update"); G_GameSettings->volume -= 0.1; } else if (CheckEvent(event,1500, 1545, 610, 645) && G_GameSettings->volume < 1.0) { G_GameSettings->volume += 0.1; this->PlaySound("update"); } else if (CheckEvent(event, 15, 285, 970, 1045)) return; } } // G_GameSettings->volume = this->volume / 10; this->_Window->clear(); this->Display(); this->_Window->display(); } }
/* * Handle a "special request" */ static errr Term_xtra_x11(int n, int v) { /* Handle a subset of the legal requests */ switch (n) { /* Make a noise */ case TERM_XTRA_NOISE: Metadpy_do_beep(); return (0); /* Flush the output XXX XXX */ case TERM_XTRA_FRESH: Metadpy_update(1, 0, 0); return (0); /* Process random events XXX */ case TERM_XTRA_BORED: return (CheckEvent(0)); /* Process Events XXX */ case TERM_XTRA_EVENT: return (CheckEvent(v)); /* Flush the events XXX */ case TERM_XTRA_FLUSH: while (!CheckEvent(FALSE)); return (0); /* Handle change in the "level" */ case TERM_XTRA_LEVEL: return (Term_xtra_x11_level(v)); /* Clear the screen */ case TERM_XTRA_CLEAR: Infowin_wipe(); return (0); /* Delay for some milliseconds */ case TERM_XTRA_DELAY: usleep(1000 * v); return (0); /* React to changes */ case TERM_XTRA_REACT: return (Term_xtra_x11_react()); } /* Unknown */ return (1); }
void CRoomEvent::MainRoom() { // 조건 검색먼저 해야 겠지.. bool bCheck = false, bRunCheck = false; int event_num = m_Logic[m_byLogicNumber-1].sNumber; bCheck = CheckEvent(event_num); if( bCheck ) { event_num = m_Exec[m_byLogicNumber-1].sNumber; bRunCheck = RunEvent( event_num ); if( bRunCheck ) { //wsprintf(notify, "** 알림 : [%d]방이 클리어 되어습니다. **", m_sRoomNumber); //g_pMain->SendSystemMsg(notify, PUBLIC_CHAT); m_byStatus = 3; } } }
void CRoomEvent::MainRoom( float fcurtime ) { // 조건 검색먼저 해야 겠지.. BOOL bCheck = FALSE, bRunCheck = FALSE; int event_num = m_Logic[m_byLogicNumber-1].sNumber; bCheck = CheckEvent( event_num, fcurtime ); if( bCheck ) { event_num = m_Exec[m_byLogicNumber-1].sNumber; bRunCheck = RunEvent( event_num ); if( bRunCheck ) { //wsprintf(notify, "** 알림 : [%d]방이 클리어 되어습니다. **", m_sRoomNumber); //m_pMain->SendSystemMsg( notify, PUBLIC_CHAT, SEND_ALL); m_byStatus = 3; } } }
void EditCartEvent::okData() { if(edit_cart!=NULL) { delete edit_cart; } edit_cart=new RDCart(edit_destination_edit->text().toUInt()); if(!edit_cart->exists()) { QMessageBox:: information(this,tr("Invalid Cart"),tr("That cart doesn't exist!")); return; } if(!CheckEvent(false)) { QMessageBox::warning(this,tr("Duplicate Event"), tr("An event with these parameters already exists!")); return; } Save(); done(0); }
void CRemoteViewTestResources::CreateTestGroupsL() { test.Next(_L("Test for creating a remote view and validating that queued events are received in the correct order.")); TContactViewEvent event; // Create A then "unnanmed", then rename "unnamed" to B test.Next(_L("Test for Create group A, then create group B")); CContactItem* group1 = iDb->CreateContactGroupLC(_L("A")); iViewEventQueue->ListenForEvent(2,event); CheckEvent(event, TContactViewEvent::EItemAdded, 0, group1->Id()); CContactItem* group0 = iDb->CreateContactGroupLC(_L("")); iViewEventQueue->ListenForEvent(2,event); CheckEvent(event, TContactViewEvent::EItemAdded, 1, group0->Id()); CContactItem *group00 = iDb->OpenContactL(group0->Id()); static_cast<CContactGroup*> (group00)->SetGroupLabelL(_L("B")); iDb->CommitContactL(*group00); // Received 3 events, grp changed, removed and added iViewEventQueue->ListenForEvent(2,event); CheckEvent(event, TContactViewEvent::EGroupChanged, 0, group00->Id()); iViewEventQueue->ListenForEvent(2,event); CheckEvent(event, TContactViewEvent::EItemRemoved, 1, group00->Id()); iViewEventQueue->ListenForEvent(2,event); CheckEvent(event, TContactViewEvent::EItemAdded, 1, group00->Id()); // Create D then "unnamed", then rename "unnamed" to C test.Next(_L("Test for Create group D, then create group C")); CContactItem* group2 = iDb->CreateContactGroupLC(_L("D")); iViewEventQueue->ListenForEvent(2,event); CheckEvent(event, TContactViewEvent::EItemAdded, 2, group2->Id()); CContactItem* group3 = iDb->CreateContactGroupLC(_L("")); iViewEventQueue->ListenForEvent(2,event); CheckEvent(event, TContactViewEvent::EItemAdded, 3, group3->Id()); CContactItem *group4 = iDb->OpenContactL(group3->Id()); static_cast<CContactGroup*> (group4)->SetGroupLabelL(_L("C")); iDb->CommitContactL(*group4); // Received 3 events, grp changed, removed and added iViewEventQueue->ListenForEvent(2,event); CheckEvent(event, TContactViewEvent::EGroupChanged, 0, group4->Id()); iViewEventQueue->ListenForEvent(2,event); CheckEvent(event, TContactViewEvent::EItemRemoved, 3, group4->Id()); iViewEventQueue->ListenForEvent(2,event); CheckEvent(event, TContactViewEvent::EItemAdded, 2, group4->Id()); // More complex set of add and deletes. test.Next(_L("Test-Addgroup E, Addgroup F, Addgroup G , RemoveGroup G Addgroup H RenameGroup H as EA")); CContactItem* group5 = iDb->CreateContactGroupLC(_L("E")); CContactItem* group6 = iDb->CreateContactGroupLC(_L("F")); CContactItem* group7 = iDb->CreateContactGroupLC(_L("G")); iDb->DeleteContactL(group7->Id()); CContactItem* group8 = iDb->CreateContactGroupLC(_L("H")); CContactItem *group01 = iDb->OpenContactL(group8->Id()); static_cast<CContactGroup*> (group01)->SetGroupLabelL(_L("EA")); iDb->CommitContactL(*group01); // Should receive events for operations above, order is not important // Should receive events as add for E F EA(H) - In the order E EA(H) F // (none for G as add, then remove) iViewEventQueue->ListenForEvent( 2, event ); CheckEvent( event, TContactViewEvent::EItemAdded, 4, group5->Id() ); iViewEventQueue->ListenForEvent( 2, event ); CheckEvent( event, TContactViewEvent::EItemAdded, 5, group6->Id() ); iViewEventQueue->ListenForEvent( 2, event ); CheckEvent( event, TContactViewEvent::EItemAdded, 6, group8->Id() ); iViewEventQueue->ListenForEvent( 2, event ); CheckEvent( event, TContactViewEvent::EItemAdded, 7, group7->Id() ); iViewEventQueue->ListenForEvent( 2, event ); CheckEvent( event, TContactViewEvent::EItemRemoved, 7, group7->Id() ); iViewEventQueue->ListenForEvent( 2, event ); CheckEvent( event, TContactViewEvent::EGroupChanged, 0, group8->Id() ); // Cleanup delete group01; delete group00; delete group4; CleanupStack::PopAndDestroy(group8); CleanupStack::PopAndDestroy(group7); CleanupStack::PopAndDestroy(group6); CleanupStack::PopAndDestroy(group5); CleanupStack::PopAndDestroy(group3); CleanupStack::PopAndDestroy(group2); CleanupStack::PopAndDestroy(group0); CleanupStack::PopAndDestroy(group1); }
void moveBem(){ //뱀의 맨 앞부분부터 자신의 값을 뒤로 넘기고 머리는 맨 마지막에 값을 변경함 int i=1; int x,y; Bem* Temp; signal(SIGALRM,SIG_IGN); if(reverse==0){ mvaddch(Tail->pos_y,Tail->pos_x,BLANK); Temp = Tail; do{ x=Temp->prev->pos_x; y=Temp->prev->pos_y; Temp->pos_x = x; Temp->pos_y = y; mvaddch(Temp->pos_y,Temp->pos_x,BODYSYMBOL); Temp = Temp->prev; i++; }while(Temp->prev); Head->pos_x += dir_x; Head->pos_y += dir_y; mvaddch(Head->pos_y,Head->pos_x,HEADSYMBOL); } else{ //이곳을 기점으로 아래가 반대로 가는것 위가 똑바로 가는것(뱀의 머리와 꼬리가 바뀌는 아이템을 먹었을때) mvaddch(Head->pos_y,Head->pos_x,BLANK); Temp = Head; do{ x=Temp->next->pos_x; y=Temp->next->pos_y; Temp->pos_x = x; Temp->pos_y = y; mvaddch(Temp->pos_y,Temp->pos_x,BODYSYMBOL); Temp = Temp->next; i++; }while(Temp->next); Tail->pos_x += dir_x; Tail->pos_y += dir_y; mvaddch(Tail->pos_y,Tail->pos_x,HEADSYMBOL); } move(23,79); refresh(); //본인 꼬리 부딛힐 경우 if(CheckBodyColl()) { mvprintw(10,55,"You die. Enter 'x' key"); refresh(); game_result = LOSE; GameOver(); } else { // 시그널 재 등록 signal(SIGALRM,whileBem); //충돌 이벤트 발생 여부 확인 CheckEvent(); } }
static VOID TestEventConcurrent( IN PKEVENT Event, IN EVENT_TYPE Type, IN KIRQL OriginalIrql, PSET_EVENT_FUNCTION SetEvent, KPRIORITY PriorityIncrement, LONG ExpectedState, BOOLEAN SatisfiesAll) { NTSTATUS Status; THREAD_DATA Threads[5]; const INT ThreadCount = sizeof Threads / sizeof Threads[0]; KPRIORITY Priority; LARGE_INTEGER LongTimeout, ShortTimeout; INT i; KWAIT_BLOCK WaitBlock[MAXIMUM_WAIT_OBJECTS]; PVOID ThreadObjects[MAXIMUM_WAIT_OBJECTS]; LONG State; PKTHREAD Thread = KeGetCurrentThread(); LongTimeout.QuadPart = -100 * MILLISECOND; ShortTimeout.QuadPart = -1 * MILLISECOND; KeInitializeEvent(Event, Type, FALSE); for (i = 0; i < ThreadCount; ++i) { Threads[i].Event = Event; Threads[i].Signal = FALSE; Status = PsCreateSystemThread(&Threads[i].Handle, GENERIC_ALL, NULL, NULL, NULL, WaitForEventThread, &Threads[i]); ok_eq_hex(Status, STATUS_SUCCESS); Status = ObReferenceObjectByHandle(Threads[i].Handle, SYNCHRONIZE, PsThreadType, KernelMode, (PVOID *)&Threads[i].Thread, NULL); ok_eq_hex(Status, STATUS_SUCCESS); ThreadObjects[i] = Threads[i].Thread; Priority = KeQueryPriorityThread(Threads[i].Thread); ok_eq_long(Priority, 8L); while (!Threads[i].Signal) { Status = KeDelayExecutionThread(KernelMode, FALSE, &ShortTimeout); ok_eq_hex(Status, STATUS_SUCCESS); } CheckEvent(Event, Type, 0L, FALSE, OriginalIrql, ThreadObjects, i + 1); } /* the threads shouldn't wake up on their own */ Status = KeDelayExecutionThread(KernelMode, FALSE, &ShortTimeout); ok_eq_hex(Status, STATUS_SUCCESS); for (i = 0; i < ThreadCount; ++i) { CheckEvent(Event, Type, 0L, FALSE, OriginalIrql, ThreadObjects + i, ThreadCount - i); State = SetEvent(Event, PriorityIncrement + i, FALSE); ok_eq_long(State, 0L); CheckEvent(Event, Type, ExpectedState, FALSE, OriginalIrql, ThreadObjects + i + 1, SatisfiesAll ? 0 : ThreadCount - i - 1); Status = KeWaitForMultipleObjects(ThreadCount, ThreadObjects, SatisfiesAll ? WaitAll : WaitAny, Executive, KernelMode, FALSE, &LongTimeout, WaitBlock); ok_eq_hex(Status, STATUS_WAIT_0 + i); if (SatisfiesAll) { for (; i < ThreadCount; ++i) { Priority = KeQueryPriorityThread(Threads[i].Thread); ok_eq_long(Priority, max(min(8L + PriorityIncrement, 15L), 8L)); } break; } Priority = KeQueryPriorityThread(Threads[i].Thread); ok_eq_long(Priority, max(min(8L + PriorityIncrement + i, 15L), 8L)); /* replace the thread with the current thread - which will never signal */ if (!skip((Status & 0x3F) < ThreadCount, "Index out of bounds")) ThreadObjects[Status & 0x3F] = Thread; Status = KeWaitForMultipleObjects(ThreadCount, ThreadObjects, WaitAny, Executive, KernelMode, FALSE, &ShortTimeout, WaitBlock); ok_eq_hex(Status, STATUS_TIMEOUT); } for (i = 0; i < ThreadCount; ++i) { ObDereferenceObject(Threads[i].Thread); Status = ZwClose(Threads[i].Handle); ok_eq_hex(Status, STATUS_SUCCESS); } }
static VOID TestEventFunctional( IN PKEVENT Event, IN EVENT_TYPE Type, IN KIRQL OriginalIrql) { LONG State; PKTHREAD Thread = KeGetCurrentThread(); memset(Event, 0x55, sizeof *Event); KeInitializeEvent(Event, Type, FALSE); CheckEvent(Event, Type, 0L, FALSE, OriginalIrql, (PVOID *)NULL, 0); memset(Event, 0x55, sizeof *Event); KeInitializeEvent(Event, Type, TRUE); CheckEvent(Event, Type, 1L, FALSE, OriginalIrql, (PVOID *)NULL, 0); Event->Header.SignalState = 0x12345678L; CheckEvent(Event, Type, 0x12345678L, FALSE, OriginalIrql, (PVOID *)NULL, 0); State = KePulseEvent(Event, 0, FALSE); CheckEvent(Event, Type, 0L, FALSE, OriginalIrql, (PVOID *)NULL, 0); ok_eq_long(State, 0x12345678L); Event->Header.SignalState = 0x12345678L; KeClearEvent(Event); CheckEvent(Event, Type, 0L, FALSE, OriginalIrql, (PVOID *)NULL, 0); State = KeSetEvent(Event, 0, FALSE); CheckEvent(Event, Type, 1L, FALSE, OriginalIrql, (PVOID *)NULL, 0); ok_eq_long(State, 0L); State = KeResetEvent(Event); CheckEvent(Event, Type, 0L, FALSE, OriginalIrql, (PVOID *)NULL, 0); ok_eq_long(State, 1L); Event->Header.SignalState = 0x23456789L; State = KeSetEvent(Event, 0, FALSE); CheckEvent(Event, Type, 1L, FALSE, OriginalIrql, (PVOID *)NULL, 0); ok_eq_long(State, 0x23456789L); Event->Header.SignalState = 0x3456789AL; State = KeResetEvent(Event); CheckEvent(Event, Type, 0L, FALSE, OriginalIrql, (PVOID *)NULL, 0); ok_eq_long(State, 0x3456789AL); /* Irql is raised to DISPATCH_LEVEL here, which kills checked build, * a spinlock is acquired and never released, which kills MP build */ if ((OriginalIrql <= DISPATCH_LEVEL || !KmtIsCheckedBuild) && !KmtIsMultiProcessorBuild) { Event->Header.SignalState = 0x456789ABL; State = KeSetEvent(Event, 0, TRUE); CheckEvent(Event, Type, 1L, TRUE, DISPATCH_LEVEL, (PVOID *)NULL, 0); ok_eq_long(State, 0x456789ABL); ok_eq_uint(Thread->WaitIrql, OriginalIrql); /* repair the "damage" */ Thread->WaitNext = FALSE; KmtSetIrql(OriginalIrql); Event->Header.SignalState = 0x56789ABCL; State = KePulseEvent(Event, 0, TRUE); CheckEvent(Event, Type, 0L, TRUE, DISPATCH_LEVEL, (PVOID *)NULL, 0); ok_eq_long(State, 0x56789ABCL); ok_eq_uint(Thread->WaitIrql, OriginalIrql); /* repair the "damage" */ Thread->WaitNext = FALSE; KmtSetIrql(OriginalIrql); } ok_irql(OriginalIrql); KmtSetIrql(OriginalIrql); }
//***************************************************************************** // @brief Reads a block of data from the LSM303 // @param slAddr : slave address LSM_A_ADDRESS or LSM_M_ADDRESS // @param pBuffer : pointer to the buffer that receives the data read // from the LSM303. // @param ReadAddr : LSM303's internal address to read from. // @param NumByteToRead : number of bytes to read from the LSM303 // ( NumByteToRead > 1 only for the Mgnetometer readinf). // @retval None //***************************************************************************** static void BufferRead(uint8_t slAddr, uint8_t* pBuffer, uint8_t ReadAddr , uint16_t NumByteToRead) { /* While the bus is busy */ while(GetFlagStatus(I2C1, I2C_FLAG_BUSY)); /* Send START condition */ GenerateSTART(I2C1, ENABLE); /* Test on EV5 and clear it */ while(!CheckEvent(I2C1, I2C_EVENT_MASTER_MODE_SELECT)); /* Send address for write */ Send7bitAddress(I2C1, slAddr, I2C_Direction_Transmitter); /* Test on EV6 and clear it */ while(!CheckEvent(I2C1, I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED)); /* Clear EV6 by setting again the PE bit */ Cmd(I2C1, ENABLE); /* Send the internal address to read from */ SendData(I2C1, ReadAddr); /* Test on EV8 and clear it */ while(!CheckEvent(I2C1, I2C_EVENT_MASTER_BYTE_TRANSMITTED)); /* Send STRAT condition a second time */ GenerateSTART(I2C1, ENABLE); /* Test on EV5 and clear it */ while(!CheckEvent(I2C1, I2C_EVENT_MASTER_MODE_SELECT)); /* Send LSM303 address for read */ Send7bitAddress(I2C1, slAddr, I2C_Direction_Receiver); /* Test on EV6 and clear it */ while(!CheckEvent(I2C1, I2C_EVENT_MASTER_RECEIVER_MODE_SELECTED)); /* While there is data to be read */ while(NumByteToRead) { if(NumByteToRead == 1) { /* Disable Acknowledgement */ AcknowledgeConfig(I2C1, DISABLE); /* Send STOP Condition */ GenerateSTOP(I2C1, ENABLE); } /* Test on EV7 and clear it */ if(CheckEvent(I2C1, I2C_EVENT_MASTER_BYTE_RECEIVED)) { /* Read a byte from the sensor */ *pBuffer = ReceiveData(I2C1); /* Point to the next location where the byte read will be saved */ pBuffer++; /* Decrement the read bytes counter */ NumByteToRead--; } } /* Enable Acknowledgement to be ready for another reception */ AcknowledgeConfig(I2C1, ENABLE); }