当前位置: 首页>>代码示例>>C++>>正文


C++ EndCritical函数代码示例

本文整理汇总了C++中EndCritical函数的典型用法代码示例。如果您正苦于以下问题:C++ EndCritical函数的具体用法?C++ EndCritical怎么用?C++ EndCritical使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了EndCritical函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: OS_AddThread

// -------------------------- OS_AddThread ---------------------------
int OS_AddThread(void(*task)(void), unsigned long stackSize, unsigned long priority){
  long status;
	int i = 0;
	
  status = StartCritical();
  
	while((thread[i].id != 0) && (i < NUMTHREADS)){
		i++;
	};
	
	if (thread[i].id != 0){
		EndCritical(status);
		return 0;
	}
	
	SetInitialStack(i, task);
	thread[i].id = i + 1;
	thread[i].priority = priority;
	thread[i].blockSt = 0;
	thread[i].sleepSt = 0;
	
	linkTCB(&Actives, &thread[i]);
	
  EndCritical(status);
  return 1;   //successfully added thread
}
开发者ID:c0lin91,项目名称:EE445M,代码行数:27,代码来源:OS.c

示例2: Task_WindOut

void Task_WindOut(void)
{
	BSET(AWS_DDR, AWS_PIN);
	BeginCritical();
	// Fast PWM 8 bit
	TCCR1A = BV(COM1A1) | BV(COM1B1) | BV(WGM10);
	TCCR1B = BV(WGM12) | BV(CS11);
	// Enable PWM pins
	AWA_DDR |= BV(AWA_DDR_COS) | BV(AWA_DDR_SIN);
	EndCritical();

   for (;;) {
		delay_ms(80);
		//
		// Dimension for 5 ms pulses (100 Hz) at 60 Kts 
		// 60 kts - 100 revs /
		if (Nav_AWS < 5)
			windPulse = 0;
		else
			windPulse = 2000 / Nav_AWS;

		register int deg = Nav_AWA/10;
		BeginCritical();
		AWA_SIN = trigint_sin8u(deg * 45 + (deg * 51 / 100));
		deg = (90 - deg + 360) % 360;
		AWA_COS = trigint_sin8u(deg * 45 + (deg * 51 / 100));
		EndCritical();
	}
}
开发者ID:themadsens,项目名称:compactor,代码行数:29,代码来源:WindOut.c

示例3: OS_AddThread

int OS_AddThread(void(*task)(void), unsigned long stackSize, unsigned long priority) {

  long status;
  int i;
  int index;

  status = StartCritical();

  if(NumThreads == 0) {
    // First thread no TCBs yet
    tcbs[0].next = &tcbs[0];
    tcbs[0].prev = &tcbs[0];
    Head = &tcbs[0];
    Tail = &tcbs[0];
    index = 0;
  } else {

    // Look for open spot in tcbs array
    for(i = 0; i < MAXTHREADS; i++) {
      if(tcbs[i].valid == INVALID) {
        index = i;
        i = MAXTHREADS; // Exit loop
      } else {
        index = -1; // Sentinel to detect no invalid spots
      }
    }

    if(index == -1) {
      EndCritical(status);
      return FAILURE; // No space in tcbs
    }

    tcbs[index].next = Head; // New tcb points to head
    tcbs[index].prev = Tail; // Point back to current tail
    (*Tail).next = &tcbs[index]; // Tail now points to new tcb
    Tail = &tcbs[index]; // New tcb becomes the tail
    (*Head).prev = &tcbs[index]; // Head now points backwards to new tcb
  }

  // Initilizing the stack for debugging
  setInitialStack(index);

  // Set PC for stack to point to function to run
  tcbs[index].stack[STACKSIZE - 2] = (long) (task);

  // Set inital values for sleep status and id
  tcbs[index].sleepState = 0;
  tcbs[index].priority = priority;
  tcbs[index].blockedState = '\0';
  tcbs[index].id = index;
  tcbs[index].valid = VALID;
  NumThreads++;

  EndCritical(status);

  return SUCCESS;
}
开发者ID:tach4455,项目名称:EE345M,代码行数:57,代码来源:OS.c

示例4: uartRx

uint8_t uartRx(uint8_t uartId, bool block) {
	uint8_t recvd = 0xFF;
	StartCritical();
	while((cBufGetChar(&rxBuffer[uartId], (char *)&recvd) > 0) && block) {
		EndCritical();
		//give the interrupt a chance to run
		StartCritical();
	}
	EndCritical();
	return recvd;
}
开发者ID:SpexGuy,项目名称:Micro2048,代码行数:11,代码来源:uart.c

示例5: OS_InitSemaphore

// ----------------------- OS_InitSemaphore --------------------------
void OS_InitSemaphore(Sema4Type *semaPt, long value){
  long status; 
  status = StartCritical();
  (*semaPt).Value = value;
	semaPt->Blocked = 0;
  EndCritical(status);
}
开发者ID:c0lin91,项目名称:EE445M,代码行数:8,代码来源:OS.c

示例6: Timer5A_Handler

void Timer5A_Handler(void){ 
	unsigned long sr;
	
	TIMER5_ICR_R = TIMER_ICR_TATOCINT;// acknowledge timer2A timeout
	
	if(counter == 50)
	{
		counter = 1;
		
		sr = StartCritical();
//		GPIO_PORTB_AFSEL_R &= ~0x40; // regular port function
//		GPIO_PORTB_DIR_R |= 0x40;    // make PD3-0 out
//		GPIO_PORTB_PCTL_R = (GPIO_PORTB_PCTL_R&0xF0FFFFFF)+0x00000000;
//		PB7 = 0x00;
//		PB7 = 0x80;
//		Timer4A_Wait(800);	// 10 us
//		PB7 = 0x00;
		PA0 = 0x00;
		PA0 = 0x40;
		Timer4A_Wait(800);	// 10 us
		PA0 = 0x00;		
//		GPIO_PORTB_DIR_R &= ~0x40;       // make PB6 in
//		GPIO_PORTB_AFSEL_R |= 0x40;      // enable alt funct on PB6
//		GPIO_PORTB_PCTL_R = (GPIO_PORTB_PCTL_R&0xF0FFFFFF)+0x07000000;
		
		EndCritical(sr);
	}
	else {
		counter++;
	}
}
开发者ID:shirhatti,项目名称:RTOS-robot,代码行数:31,代码来源:InputOutput.c

示例7: Init_Timer5A

void Init_Timer5A(uint32_t period) {
	long sr;
	volatile unsigned long delay;
	
	sr = StartCritical();
	counter = 0;
  SYSCTL_RCGCTIMER_R |= 0x20;
	
  delay = SYSCTL_RCGCTIMER_R;
	delay = SYSCTL_RCGCTIMER_R;
	
  TIMER5_CTL_R &= ~TIMER_CTL_TAEN; // 1) disable timer1A during setup
                                   // 2) configure for 32-bit timer mode
  TIMER5_CFG_R = TIMER_CFG_32_BIT_TIMER;
                                   // 3) configure for periodic mode, default down-count settings
  TIMER5_TAMR_R = TIMER_TAMR_TAMR_PERIOD;
  TIMER5_TAILR_R = period - 1;     // 4) reload value
                                   // 5) clear timer1A timeout flag
  TIMER5_ICR_R = TIMER_ICR_TATOCINT;
  TIMER5_IMR_R |= TIMER_IMR_TATOIM;// 6) arm timeout interrupt
								   // 7) priority shifted to bits 31-29 for timer2A
  NVIC_PRI23_R = (NVIC_PRI23_R&0xFFFFFF00)|(1 << 5);	
  NVIC_EN2_R = NVIC_EN2_INT92;     // 8) enable interrupt 23 in NVIC
  TIMER5_TAPR_R = 0;
  TIMER5_CTL_R |= TIMER_CTL_TAEN;  // 9) enable timer2A
	//page 155
	//page 104 //interrupt number 92 = priority 23
  EndCritical(sr);
}
开发者ID:shirhatti,项目名称:RTOS-robot,代码行数:29,代码来源:InputOutput.c

示例8: linkTCB

void linkTCB(tcbList* list, tcbPt target){
	tcbPt head = *list;
	tcbPt current;
	long status;
	
	status = StartCritical();
	
	if (head == 0){
		*list = target;
		target->next = target;
		target->prev = target;
	} else {
		current = head;
		
		if (target->priority < head->priority){
			*list = target;
		} else {
			current = current->next;
			while ((target->priority >= current->priority) && (current != head)){
				current = current->next;
			}
		}
		(current->prev)->next = target;
		target->prev = current->prev;  
		target->next = current;
		current->prev = target;
	}

	EndCritical(status);
}
开发者ID:c0lin91,项目名称:EE445M,代码行数:30,代码来源:OS.c

示例9: TimerCapture_Init3

  void TimerCapture_Init3(void){long sr;  //Timer 3 (Clock thing)
	
  sr = StartCritical();
	
	P10SEL0 |= 0x10;
  P10SEL1 &= ~0x10;                 // configure P10.4 as TA0CCP0
  P10DIR &= ~0x10;                  // make P10.4 in
	
	P8SEL0 |= 0x04;
  P8SEL1 &= ~0x04;                 // configure 8.2 as TA0CCP
  P8DIR &= ~0x04; 
	
  TA3CTL &= ~0x0030;               // halt Timer A3
	TA3CTL = 0x0200;

	TA3CCTL0 = 0x8910;
	TA3CCTL2 = 0x49C0;
  TA3EX0 &= ~0x0007;       // configure for input clock divider /1
  NVIC_IPR3 |= (NVIC_IPR3&0xFFFFFF00)|0x04040000; // priority 2
// interrupts enabled in the main program after all devices initialized
  NVIC_ISER0 |= 0x00006000; // enable interrupt 8 in NVIC
  TA3CTL |= 0x0024;        // reset and start Timer A1 in continuous up mode
		
  EndCritical(sr);
}
开发者ID:JamesMusselman,项目名称:Sonar_Robot,代码行数:25,代码来源:InputCapture.c

示例10: OS_ClearMsTime

// ******** OS_ClearMsTime ************
// sets the system time to zero from Lab 1)
// Inputs:  none
// Outputs: none
// You are free to change how this works
void OS_ClearMsTime(void){
	int status;
	status=StartCritical();
	TIMELORD=0;
	EndCritical(status);
return;
}
开发者ID:AustinBlackstone,项目名称:EE345M-S2012,代码行数:12,代码来源:os.c

示例11: TimerCapture_Init01

void TimerCapture_Init01(void(*task)(uint16_t time), void(*task2)(uint16_t time)){long sr; //Timer 1 (Wheel encoders)
	
  sr = StartCritical();
  CaptureTask = task;              // user function
	CaptureTask2 = task2;              // user function

	P8SEL0 |= 0x01;
  P8SEL1 &= ~0x01;                 // configure P8.0 as TA0CCP0
  P8DIR &= ~0x01;                  // make P8.0 in RIGHT?
	
	P7SEL0 |= 0x10;
  P7SEL1 &= ~0x10;                 // configure P7.4 as TA0CCP0
  P7DIR &= ~0x10;                  // make P7.4 in LEFT?
	
  TA1CTL &= ~0x0030;               // halt Timer A1
	TA1CTL = 0x0200; 

	TA1CCTL0 = 0x4910;
	TA1CCTL4 = 0x4910;
  TA1EX0 &= ~0x0003;       // configure for input clock divider /1
  NVIC_IPR2 |= (NVIC_IPR2&0xFFFFFF00)|0x04040000; // priority 2
// interrupts enabled in the main program after all devices initialized
  NVIC_ISER0 = 0x00000C00; // enable interrupt 8 in NVIC
  TA1CTL |= 0x0024;        // reset and start Timer A1 in continuous up mode
		// these also work NVIC_IPR2 |= (NVIC_IPR2&0xFFFFFF00)|0x00000040; NVIC_ISER0 |= 0x00000100;
  EndCritical(sr);
}
开发者ID:JamesMusselman,项目名称:Sonar_Robot,代码行数:27,代码来源:InputCapture.c

示例12: OS_bSignal

// ******** OS_bSignal ************
// set semaphore to 1, wakeup blocked thread if appropriate
// input:  pointer to a binary semaphore
// output: none
void OS_bSignal(Sema4Type *semaPt) {

  long status;
  tcbType (*tempPt);

  status = StartCritical();

  if((*semaPt).Value != 1) {

	(*semaPt).Value++;

    if((*semaPt).Value <= 0) {

	  tempPt = RunPt;

	  while((*tempPt).blockedState != semaPt) {
	    tempPt = (*tempPt).next;
	  }

	  (*tempPt).blockedState = '\0';

      }
  }

  EndCritical(status);
}
开发者ID:tach4455,项目名称:EE345M,代码行数:30,代码来源:OS.c

示例13: CAN0_Open

// Initialize CAN port
void CAN0_Open(void){
	uint32_t volatile delay;
	int32_t sr;
	
	sr = StartCritical();
  MailFlag = false;

  SYSCTL_RCGCCAN_R |= 0x00000001;  // CAN0 enable bit 0
  SYSCTL_RCGCGPIO_R |= 0x00000010;  // RCGC2 portE bit 4
  for(delay=0; delay<10; delay++){};
  GPIO_PORTE_AFSEL_R |= 0x30; //PORTE AFSEL bits 5,4
// PORTE PCTL 88 into fields for pins 5,4
  GPIO_PORTE_PCTL_R = (GPIO_PORTE_PCTL_R&0xFF00FFFF)|0x00880000;
  GPIO_PORTE_DEN_R |= 0x30;
  GPIO_PORTE_DIR_R |= 0x20;
      
  CANInit(CAN0_BASE);
  CANBitRateSet(CAN0_BASE, 80000000, CAN_BITRATE);
  CANEnable(CAN0_BASE);
// make sure to enable STATUS interrupts
  CANIntEnable(CAN0_BASE, CAN_INT_MASTER | CAN_INT_ERROR | CAN_INT_STATUS);
// Set up filter to receive these IDs
// in this case there is just one type, but you could accept multiple ID types
  CAN0_Setup_Message_Object(Ping1_ID, MSG_OBJ_RX_INT_ENABLE, 4, NULL, Ping1_ID, MSG_OBJ_TYPE_RX);
	CAN0_Setup_Message_Object(Ping2_ID, MSG_OBJ_RX_INT_ENABLE, 4, NULL, Ping2_ID, MSG_OBJ_TYPE_RX);
	CAN0_Setup_Message_Object(Ping3_ID, MSG_OBJ_RX_INT_ENABLE, 4, NULL, Ping3_ID, MSG_OBJ_TYPE_RX);
	CAN0_Setup_Message_Object(Ping4_ID, MSG_OBJ_RX_INT_ENABLE, 4, NULL, Ping4_ID, MSG_OBJ_TYPE_RX);
	CAN0_Setup_Message_Object(Button1_ID, MSG_OBJ_RX_INT_ENABLE, 4, NULL, Button1_ID, MSG_OBJ_TYPE_RX);
	CAN0_Setup_Message_Object(Button2_ID, MSG_OBJ_RX_INT_ENABLE, 4, NULL, Button2_ID, MSG_OBJ_TYPE_RX);
	CAN0_Setup_Message_Object(IR_ID, MSG_OBJ_RX_INT_ENABLE, 4, NULL, IR_ID, MSG_OBJ_TYPE_RX);
  NVIC_EN1_R = (1 << (INT_CAN0 - 48)); //IntEnable(INT_CAN0);
		
	EndCritical(sr);
  return;
}
开发者ID:shirhatti,项目名称:RTOS-robot,代码行数:36,代码来源:can0.c

示例14: OS_Wait

// ******** OS_Wait ************
// decrement semaphore and spin/block if less than zero
// input:  pointer to a counting semaphore
// output: none
void OS_Wait(Sema4Type *s){
//new way  (Lab3)
	long status; //the i bit, used to save and reload it
	status=StartCritical();	  	//Save Ibit
	s->Value = s->Value-1;		//Decriment semaphore counter
	if(s->Value < 0){			//If counter < 0 block
	//BLOCK!!!
		NUMBLOCKEDTHREADS++;
		RUNPT->blockedOn=s;			//set in TCB what sema4 its blocked on (for debug info)
		if(s->blockedThreads[(s->bIndex+1)%NUMTHREADS]==EMPTY){
			s->bIndex=(s->bIndex+1)%NUMTHREADS;
			s->blockedThreads[(s->bIndex)%NUMTHREADS]=RUNPT;	//add thread to array of blocked threads
			NVIC_ST_CURRENT_R = 0;
			//EndCritical(status);
			OS_SysTick_Handler();		//trigger thread switch
		}
	
	}
	
	EndCritical(status);		//Reenable I bit

//old way  (Lab2)
/*	DisableInterrupts()
	while( s->Value <= 0){
		//TODO: implement Blocking
		EnableInterrupts();
		DisableInterrupts();
	}
	s->Value--;
	EnableInterrupts();
*/
}
开发者ID:AustinBlackstone,项目名称:EE345M-S2012,代码行数:36,代码来源:os.c

示例15: OS_Signal

// ******** OS_Signal ************
// increment semaphore, wakeup blocked thread if appropriate 
// input:  pointer to a counting semaphore
// output: none
void OS_Signal(Sema4Type *s){
	long status;
	status=StartCritical();
  s->Value++;
	EndCritical(status);
	//TODO: wakeup blocked thread
}
开发者ID:AustinBlackstone,项目名称:EE345M-S2012,代码行数:11,代码来源:os.c


注:本文中的EndCritical函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。