示例#1
0
// Purpose:       Turn a pixel on a graphic LCD on or off
// Inputs:        x - the x coordinate of the pixel
//                y - the y coordinate of the pixel
//                color - ON or OFF
// Output:        1 if coordinate out of range, 0 if in range
void glcd_pixel(int x, int y, int1 color)
{
   BYTE data;
   BYTE chip = GLCD_CS1;  // Stores which chip to use on the LCD

   if(x > 63)  // Check for first or second display area
   {
      x -= 64;
      chip = GLCD_CS2;
   }

   output_low(GLCD_DI);                                     // Set for instruction
   bit_clear(x,7);                                          // Clear the MSB. Part of an instruction code
   bit_set(x,6);                                            // Set bit 6. Also part of an instruction code
   glcd_writeByte(chip, x);                                 // Set the horizontal address
   glcd_writeByte(chip, (y/8 & 0b10111111) | 0b10111000);   // Set the vertical page address
   output_high(GLCD_DI);                                    // Set for data
   data = glcd_readByte(chip);

   if(color == ON)
      bit_set(data, y%8);        // Turn the pixel on
   else                          // or
      bit_clear(data, y%8);      // turn the pixel off
   output_low(GLCD_DI);          // Set for instruction
   glcd_writeByte(chip, x);      // Set the horizontal address
   output_high(GLCD_DI);         // Set for data
   glcd_writeByte(chip, data);   // Write the pixel data
}
示例#2
0
void isr_int2()
{
	UBYTE temp;
	temp=TMR0;
	TMR0=0;
	if (bit_test(INTCON2,4))
	{
		bit_clear(INTCON2,4);
		if (temp>	35)
		{
			n_pwm_data=0;
		}
	}else
	{
		high_time=temp;
		n_pwm_data++;
		n_pwm_data=n_pwm_data & 0x07;
		pwm_data=pwm_data<<1;
		if (temp<=15)
		{
			pwm_data=pwm_data | 0x01;
		}
				
		bit_set(INTCON2,4);
	}
	bit_clear(INTCON3,1);
}
示例#3
0
void tone(float frequency, float length)

{

    pokeword(0x26, (int)(1E6 / frequency));

    bit_set(0x1020, 0b00000001);

    sleep(length);

    bit_clear(0x1020, 0b00000001);



    /*  following is important to reduce # of interrupts

	when tone is off  */

    pokeword(0x26, 0);



    bit_clear(0x1000, 8);

}
示例#4
0
文件: mainmod.c 项目: gromms/MiniSumo
int main(void)
{
	// clock prescaler
	CLKPR = BIT(CLKPCE); // enable prescaler change
	CLKPR = BITS(0b0000, CLKPS0); // divider 1

	// disable JTAG - control F port
	MCUCR = BIT(JTD);
	MCUCR = BIT(JTD);

	// LED outputs
	bit_set(DDRF, LEDS);
	bit_set(PORTF, LEDS);

	// button inputs
	bit_clear(DDRD, BIT(BTN1) | BIT(BTN2));

	// IO inputs
	bit_clear(DDRB, BIT(IO1));
	bit_clear(DDRC, BIT(IO2));

	// initialize comms
	usb_init();
	usart_init();

	// wait for USB configuration
	// while (!usb_configured());
	_delay_ms(1000);

	// heartbeat timer (timer0)
	TCCR0A = BITS(0b10, WGM00); // CTC mode (mode 2)
	TCCR0B = BITS(0b101, CS00); // divider 1024
	TIMSK0 = BIT(OCIE0A); // enable compare A on timer0
	OCR0A = 250; // 62.5Hz
	TCNT0 = 0;

	sei(); // enable interrupts

	bit_clear(PORTF, BIT(LED2G));

	/*uint8_t n;
	char buf[16];*/

	while (1)
	{
		usart_write("3:s1\n");
		usart_write("4:s-1\n");

		_delay_ms(3000);


		usart_write("3:s-1\n");
		usart_write("4:s1\n");

		_delay_ms(3000);
	}
}
示例#5
0
文件: bml_busy.c 项目: 5HT/mumps
uint4 bml_busy(uint4 setbusy, sm_uc_ptr_t map)
{
	uint4	ret, ret1;

	setbusy *= BML_BITS_PER_BLK;
	ret = bit_clear(setbusy, map);
	ret1 = bit_clear(setbusy + 1, map);
	/* Assert that only a RECYCLED or FREE block gets marked as BUSY (dse is an exception) */
	assert((ret && ret1) || (ret && !ret1) || dse_running);
	return ret;
}
示例#6
0
文件: task_state.c 项目: HPCNow/slurm
/*
 * Update the state of a specific task ID in a specific task_state structure
 */
extern void task_state_update(task_state_t ts, int task_id, task_state_type_t t)
{
	xassert(ts != NULL);
	xassert(task_id >= 0);
	xassert(task_id < ts->n_tasks);

	if (ts->pack_group == NO_VAL) {
		debug3("%s: step=%u.%u task_id=%d, %s", __func__,
		       ts->job_id, ts->step_id, task_id,
		       _task_state_type_str(t));
	} else {
		debug3("%s: step=%u.%u pack_group=%u task_id=%d, %s", __func__,
		       ts->job_id, ts->step_id, ts->pack_group, task_id,
		       _task_state_type_str(t));
	}

	switch (t) {
	case TS_START_SUCCESS:
		bit_set (ts->running, task_id);
		ts->n_started++;
		break;
	case TS_START_FAILURE:
		bit_set (ts->start_failed, task_id);
		break;
	case TS_NORMAL_EXIT:
		bit_clear(ts->running, task_id);
		if (bit_test(ts->normal_exit, task_id) ||
		    bit_test(ts->abnormal_exit, task_id)) {
			error("Task %d reported exit for a second time.",
			      task_id);
		} else {
			bit_set (ts->normal_exit, task_id);
			ts->n_exited++;
		}
		break;
	case TS_ABNORMAL_EXIT:
		bit_clear(ts->running, task_id);
		if (bit_test(ts->normal_exit, task_id) ||
		    bit_test(ts->abnormal_exit, task_id)) {
			error("Task %d reported exit for a second time.",
			      task_id);
		} else {
			bit_set (ts->abnormal_exit, task_id);
			ts->n_exited++;
			ts->n_abnormal++;
		}
		break;
	}

	xassert((bit_set_count(ts->abnormal_exit) +
		 bit_set_count(ts->normal_exit)) == ts->n_exited);
}
示例#7
0
void beeper_off()

{

    bit_clear(0x1022, 0b00001000);

    bit_clear(0x1020, 0b00000001);

    pokeword(0x26, 0);

    bit_clear(0x1000, 0b00001000);	/* turn power to spkr off */

}
示例#8
0
void RFHardwareSerial::end()
{
  // wait for transmission of outgoing data
  while (_tx_buffer->head != _tx_buffer->tail)
    ;

  bit_clear(*_ucsrb, _rxen);
  bit_clear(*_ucsrb, _txen);
  bit_clear(*_ucsrb, _rxcie);  
  bit_clear(*_ucsrb, _udrie);
  
  // clear any received data
  _rx_buffer->head = _rx_buffer->tail;
}
示例#9
0
/* The various register bits accessed here are detailed in the
   PIC18F8722 datasheet.
*/
void set_usart_int()
{
  sleep_mode = TRUE;       // Code var for USART int fired/not fired
  
  clear_interrupt(INT_RDA);        // Serial
     
  bit_clear(RCON,IPEN);    // Disable priority on interrupts
  bit_clear(PIR1,RC1IF);   // Clear USART Receive Interrupt Flag bit
  //      var,bit = addr,bit
  bit_set(PIE1,RC1IE);     // Set USART Receive Interrupt Enable bit
  bit_set(BAUDCON1,WUE);   // USART1 wake-up enable
  bit_set(INTCON,PEIE);    // Set Peripheral Interrupt Enable bit
  //bit_set(INTCON,GIE);     // Set Global Interrupt Enable bit
}
示例#10
0
/* power_job_reboot - Reboot compute nodes for a job from the head node */
extern int power_job_reboot(struct job_record *job_ptr)
{
	int rc = SLURM_SUCCESS;
	int i, i_first, i_last;
	struct node_record *node_ptr;
	bitstr_t *wake_node_bitmap = NULL;
	time_t now = time(NULL);
	char *nodes, *features = NULL;

	wake_node_bitmap = bit_alloc(node_record_count);
	i_first = bit_ffs(job_ptr->node_bitmap);
	i_last = bit_fls(job_ptr->node_bitmap);
	for (i = i_first; i <= i_last; i++) {
		if (!bit_test(job_ptr->node_bitmap, i))
			continue;
		node_ptr = node_record_table_ptr + i;
		resume_cnt++;
		resume_cnt_f++;
		node_ptr->node_state &= (~NODE_STATE_POWER_SAVE);
		node_ptr->node_state |=   NODE_STATE_POWER_UP;
		node_ptr->node_state |=   NODE_STATE_NO_RESPOND;
		bit_clear(power_node_bitmap, i);
		bit_clear(avail_node_bitmap, i);
		node_ptr->last_response = now + resume_timeout;
		bit_set(wake_node_bitmap,    i);
		bit_set(resume_node_bitmap,  i);
	}

	nodes = bitmap2node_name(wake_node_bitmap);
	if (nodes) {
#if _DEBUG
		info("power_save: reboot nodes %s", nodes);
#else
		verbose("power_save: reboot nodes %s", nodes);
#endif
		if (job_ptr->details && job_ptr->details->features)
			features = xlate_features(job_ptr->details->features);
		_run_prog(resume_prog, nodes, features);
		xfree(features);
	} else {
		error("power_save: bitmap2nodename");
		rc = SLURM_ERROR;
	}
	xfree(nodes);
	FREE_NULL_BITMAP(wake_node_bitmap);
	last_node_update = now;

	return rc;
}
示例#11
0
int16 mcp3208_read(int8 ch) {
	int16 value;
	int8 i;
	int8 c;

	output_low(MCP3208_CLK);
	output_high(MCP3208_DIN);
	output_low(MCP3208_NCS);
	
	if ( 0 == ch ) 
		c=0b00011;
	else if ( 1 == ch ) 
		c=0b10011;
	else if ( 2 == ch ) 
		c=0b01011;
	else if ( 3 == ch ) 
		c=0b11011;
	else if ( 4 == ch )
		c=0b00111;
	else if ( 5 == ch ) 
		c=0b10111;
	else if ( 6 == ch )
		c=0b01111;
	else
		c=0b11111;

	/* select out channel and start the conversion */
	for ( i=0 ; i<5 ; i++ ) {
		output_low(MCP3208_CLK);
		output_bit(MCP3208_DIN,c&1);
		c=c>>1;
		output_high(MCP3208_CLK);
	}


	value=0;
	for ( i=0 ; i<14 ; i++ ) {
		output_low(MCP3208_CLK);
		shift_left(&value,2,input(MCP3208_DOUT));
		output_high(MCP3208_CLK);
	}

	bit_clear(value,13);
	bit_clear(value,12);

	output_high(MCP3208_NCS);

	return value;
}
示例#12
0
// Purpose:    Turn a pixel on a graphic LCD on or off
// Inputs:     1) x - the x coordinate of the pixel
//             2) y - the y coordinate of the pixel
//             3) color - ON or OFF
void glcd_pixel(unsigned int8 x, unsigned int8 y, int1 color)
#ifdef FAST_GLCD
{
   unsigned int8* p;
   unsigned int16 temp;
   temp =  y/8;
   temp *= 64;
   temp += x;

   if(x > 63)
   {
      p = displayData.right + temp - 64;
   }
   else
   {
      p = displayData.left + temp;
   }

   if(color)
   {
      bit_set(*p, y%8);
   }
   else
   {
      bit_clear(*p, y%8);
   }
}
void FakeSMCKeyStore::releaseGPUIndex(UInt8 index)
{
    //REVIEW_REHABMAN: lock required?
    if (index <= 0xf) {
        bit_clear(vacantGPUIndex, BIT(index));
    }
}
示例#14
0
文件: geiger.c 项目: Ttl/geiger
void sleep1ms(void) {
    /* Disable analog comparator to save power */
    ACSR = 0b11000000;

    sleep_over = 0;

    set_sleep_mode(SLEEP_MODE_IDLE);
    /* Set compare register to interrupt in 1ms */
    OCR0A = TCNT0 + 15;
    /*  Enable OCR0A interrupt */
    bit_set(TIMSK0, 1);
    /*  Loop to continue sleeping if any other interrupt wakes CPU */
    do {
        sleep_enable();
        sleep_cpu();
    } while(sleep_over == 0);
    /*  Done, disable sleep */
    sleep_disable();

    /*  Disable OCR0A interrupt */
    bit_clear(TIMSK0, 1);

    /* Enable analog comparator */
    ACSR = 0b01000000;
    return;
}
示例#15
0
/**
 *  Decode buffer considering it's a floating point encoded value of an SMC key
 *
 *  @param type     SMC type name will be used to determine decoding rules
 *  @param size     Encoded value buffer size
 *  @param data     Pointer to a encoded value buffer
 *  @param outValue Decoded float value will be returned
 *
 *  @return True on success False otherwise
 */
bool fakeSMCPluginDecodeFloatValue(const char *type, const UInt8 size, const void *data, float *outValue)
{
    if (type && data && outValue) {

        size_t typeLength = strnlen(type, 4);

        if (typeLength >= 3 && (type[0] == 'f' || type[0] == 's') && type[1] == 'p' && size == 2) {
            UInt16 encoded = 0;

            bcopy(data, &encoded, 2);

            UInt8 i = fakeSMCPluginGetIndexFromChar(type[2]);
            UInt8 f = fakeSMCPluginGetIndexFromChar(type[3]);

            if (i + f != (type[0] == 's' ? 15 : 16) )
                return false;

            UInt16 swapped = OSSwapBigToHostInt16(encoded);

            bool signd = type[0] == 's';
            bool minus = bit_get(swapped, BIT(15));

            if (signd && minus) bit_clear(swapped, BIT(15));

            *outValue = ((float)swapped / (float)BIT(f)) * (signd && minus ? -1 : 1);

            return true;
        }
    }

    return false;
}
示例#16
0
文件: filemem.c 项目: brunof/eepromfs
short eepromfs_setBlockIdentifiers(int8 blockNmr, struct blockIdentifiers * identIn)
{
   int8 aux81,aux82;
   int16 aux161,aux162,aux163;

   aux82=blockNmr;
   //get FREE BLOCK START ADDRESS
   aux161=eepromfs_getAddress(FREE_BLOCK_START_ADDR);

   while(aux82>7)
   {
      aux161++;
      aux82-=8;
   }

   //get 8 block info...
   aux81=read_ext_eeprom(aux161);

   if((*identIn).state) bit_set(aux81,aux82); else bit_clear(aux81,aux82);
   
   //write result...
   write_ext_eeprom(aux161,aux81);
   
   //get BLOCK SIZE
   aux162=eepromfs_getAddress(BLOCK_SIZE_ADDR);

   //calculate selected empty block address...
   aux163=eepromfs_getBlockAddress(blockNmr);                               //data block start address + (block size * empty block finded)                                      
   //add real block size...
   //aux163+=aux162-BLOCK_IDENTIFIER_SIZE;                                           //jump to identifiers zone
   write_page_ext_eeprom(aux163+aux162-BLOCK_IDENTIFIER_SIZE,&(*identIn).control,BLOCK_IDENTIFIER_SIZE);
   return TRUE;
}
示例#17
0
文件: pagepool.c 项目: bigbes/btree
/**
 * @brief     Free previously allocate page
 *
 * @param pp  PagePool instance
 * @param pos Number of page to be freed
 *
 * @return    Status
 */
int pool_dealloc(struct PagePool *pp, pageno_t pos) {
	log_info("Freeing page %zd", pos);
	if (bitmask_check(pp, pos)) return -1;
	bit_clear(pp->bitmask, pos);
	bitmask_dump(pp);
	return 0;
}
示例#18
0
文件: SPI.cpp 项目: leventesen/Cosa
void
SPI::begin(Driver* dev)
{
  // Acquire the driver controller
  uint8_t key = lock(m_sem);
  m_dev = dev;
 
#if defined(SPDR)
  // Initiate SPI hardware with device settings
  SPCR = dev->m_spcr;
  SPSR = dev->m_spsr;
#else
  // Set clock polarity
  if (dev->m_cpol & 0x02)
    bit_set(PORT, Board::SCK);
  else
    bit_clear(PORT, Board::SCK);
#endif

  // Enable device
  if (dev->m_pulse < PULSE_LOW) dev->m_cs.toggle();

  // Disable all interrupt sources on SPI bus
  for (dev = spi.m_list; dev != NULL; dev = dev->m_next)
    if (dev->m_irq != NULL) dev->m_irq->disable();

  unlock(key);
}
void A498x_sendStep(){	
	
	_delay_us(100);
	bit_set(MOTOR_PORT,STEP_PIN);
	_delay_us(100);
	bit_clear(MOTOR_PORT,STEP_PIN);
}
示例#20
0
void AP_ADC_ADS7844::read(uint32_t tnow)
{
	uint8_t ch;

	bit_clear(PORTC, 4);							// Enable Chip Select (PIN PC4)
	ADC_SPI_transfer(adc_cmd[0]);						// Command to read the first channel

	for (ch = 0; ch < 8; ch++) {
		uint16_t v;

		v = ADC_SPI_transfer(0) << 8;	         // Read first byte
		v |= ADC_SPI_transfer(adc_cmd[ch + 1]);  // Read second byte and send next command

		if (v & 0x8007) {
			// this is a 12-bit ADC, shifted by 3 bits.
			// if we get other bits set then the value is
			// bogus and should be ignored
			continue;
		}

		if (++_count[ch] == 0) {
			// overflow ... shouldn't happen too often
			// unless we're just not using the
			// channel. Notice that we overflow the count
			// to 1 here, not zero, as otherwise the
			// reader below could get a division by zero
			_sum[ch] = 0;
			_count[ch] = 1;
		}
		_sum[ch] += (v >> 3);
	}

	bit_set(PORTC, 4);					// Disable Chip Select (PIN PC4)

}
示例#21
0
文件: ports.c 项目: BYUHPC/slurm
/*
 * Function: release_port
 * Description:
 *  Release the port.
 *
 * Returns:
 *  0 on success and -1 on failure.
 */
int release_port(uint32_t real_port)
{

	uint32_t port;

	if ((real_port < MIN_PORT) || (real_port >= MAX_PORT)) {
		CRAY_ERR("Port %" PRIu32 " outside of valid range %" PRIu32
			 " : %" PRIu32, real_port, MIN_PORT, MAX_PORT);
		return -1;
	}

	port = real_port - MIN_PORT;

	pthread_mutex_lock(&port_mutex);
	if (bit_test(port_resv, port)) {
		bit_clear(port_resv, port);
		pthread_mutex_unlock(&port_mutex);
	} else {
		CRAY_ERR("Attempting to release port %d,"
			 " but it was not reserved.", real_port);
		pthread_mutex_unlock(&port_mutex);
		return -1;
	}
	return 0;
}
示例#22
0
static int
shutdown (sdla_t *card)
{
	int err=0;

	if (card->state == WAN_UNCONFIGURED) {
		return 0;
	}
	card->state = WAN_UNCONFIGURED;

	bit_set((u_int8_t*)&card->critical, PERI_CRIT);

	/* In case of piggibacking, make sure that
         * we never try to shutdown both devices at the same
         * time, because they depend on one another */

	card->state = WAN_UNCONFIGURED;

	/* Release Resources */
	release_hw(card);

        /* only free the allocated I/O range if not an S514 adapter */
	if (!card->configured) {
		card->hw = NULL;
		if (card->same_cpu) {
			card->same_cpu->hw = NULL;
			card->same_cpu->same_cpu = NULL;
			card->same_cpu=NULL;
		}
	}

	bit_clear((u_int8_t*)&card->critical, PERI_CRIT);

	return err;
}
示例#23
0
文件: SPI.cpp 项目: rsd1987/Meshwork
SPI::Driver::Driver(Board::DigitalPin cs, uint8_t pulse,
		    Clock rate, uint8_t mode, Order order,
		    Interrupt::Handler* irq) :
  m_irq(irq),
  m_cs(cs, (pulse == 0)),
  m_pulse(pulse),
  m_cpol(mode)
{
  // USI command for hardware supported bit banging 
  m_usicr = (_BV(USIWM0) | _BV(USICS1) | _BV(USICLK) | _BV(USITC));
  if (mode == 1 || mode == 2) m_usicr |= _BV(USICS0);

  // Attach driver to SPI bus controller device list
  m_next = spi.m_list;
  spi.m_list = this;

  // Set ports
  synchronized {
    bit_set(DDR, Board::MOSI);
    bit_set(DDR, Board::SCK);
    bit_clear(DDR, Board::MISO);
    bit_set(PORT, Board::MISO);
    USICR = m_usicr;
  }
}
示例#24
0
char *test_set_clear_not()
{
    int i;
    bit_set(a, 1, 1);
    mu_assert(bit_get(a, 1)==1, "bit_set did not set correctly.\n");
    bit_set(a, 10, 80);
    for (i = 10; i <= 80; i++) {
        mu_assert(bit_get(a, i) == 1, "bit_set did not set correctly.\n");
    }

    bit_clear(a, 24, 50);
    for (i = 24; i <= 50; i++) {
        mu_assert(bit_get(a, i) == 0, "bit_clear did not set correctly.\n");
    }

    bit_not(a, 10, 80);
    for (i = 10; i < 24; i++) {
        mu_assert(bit_get(a, i) == 0, "bit_not did not set bits correctly.\n");
    }
    for (i = 24; i <= 50; i++) {
        mu_assert(bit_get(a, i) == 1, "bit_not did not set bits correctly.\n");
    }
    for (i = 51; i <= 80; i++) {
        mu_assert(bit_get(a, i) == 0, "bit_not did not set bits correctly.\n");
    }

    return NULL;
}
void Disparar(int ang){
   switch (ang){
      case 0 : 
               bit_set(PORTD,0);
         break;
      case 1 : delay_ms(1);
               bit_set(PORTD,0);
         break;
      case 2 : delay_ms(2);
               bit_set(PORTD,0);
         break;
      case 3 : delay_ms(3);
               bit_set(PORTD,0);
         break;
      case 4 : delay_ms(4);
               bit_set(PORTD,0);
         break;
      case 5 : delay_ms(5);
               bit_set(PORTD,0);
         break;
      case 6 : delay_ms(6);
               bit_set(PORTD,0);
         break;
      case 7 : delay_ms(7);
               bit_set(PORTD,0);
         break;
   }
      delay_ms(1);
      bit_clear(PORTD,0);
}
示例#26
0
/*
 * Remove job from full-length core_bitmap
 * IN job_resrcs_ptr - resources allocated to a job
 * IN/OUT full_bitmap - bitmap of available CPUs, allocate as needed
 * IN bits_per_node - bits per node in the full_bitmap
 * RET 1 on success, 0 otherwise
 */
extern void remove_job_from_cores(job_resources_t *job_resrcs_ptr,
			     bitstr_t **full_core_bitmap,
			     const uint16_t *bits_per_node)
{
	int full_node_inx = 0;
	int job_bit_inx  = 0, full_bit_inx  = 0, i;

	if (!job_resrcs_ptr->core_bitmap)
		return;

	/* add the job to the row_bitmap */
	if (*full_core_bitmap == NULL) {
		uint32_t size = 0;
		for (i = 0; i < node_record_count; i++)
			size += bits_per_node[i];
		*full_core_bitmap = bit_alloc(size);
		if (!*full_core_bitmap)
			fatal("add_job_to_cores: bitmap memory error");
	}

	for (full_node_inx = 0; full_node_inx < node_record_count;
	     full_node_inx++) {
		if (bit_test(job_resrcs_ptr->node_bitmap, full_node_inx)) {
			for (i = 0; i < bits_per_node[full_node_inx]; i++) {
				if (!bit_test(job_resrcs_ptr->core_bitmap,
					      job_bit_inx + i))
					continue;
				bit_clear(*full_core_bitmap, full_bit_inx + i);
			}
			job_bit_inx += bits_per_node[full_node_inx];
		}
		full_bit_inx += bits_per_node[full_node_inx];
	}
}
示例#27
0
void hfree(void *ptr)
{
    unsigned long addr = (unsigned long)ptr;
    unsigned long index = (addr - heap_start) / HALLOC_CHUNK_SIZE;
    int e = (int)(index / BITS_PER_ENTRY);
    int b = (int)(index % BITS_PER_ENTRY);
    
    kthread_mutex_lock(&heap_mutex);
    
    bit_clear(e, b);
    if (cur_last_bitmap_entry > e) {
        goto done;
    }
    
    // Resize the heap
    for (; e; e--) {
        if (entry_inuse(e)) {
            cur_last_bitmap_entry = e;
            break;
        }
    }
    
    resize_heap();
    
done:
atomic_membar();
    kthread_mutex_unlock(&heap_mutex);
}
/*
 * Remove job from full-length core_bitmap
 * IN job_resrcs_ptr - resources allocated to a job
 * IN/OUT full_bitmap - bitmap of available CPUs, allocate as needed
 * IN bits_per_node - bits per node in the full_bitmap
 * RET 1 on success, 0 otherwise
 */
extern void remove_job_from_cores(job_resources_t *job_resrcs_ptr,
				  bitstr_t **full_core_bitmap,
				  const uint16_t *bits_per_node)
{
	int full_node_inx = 0, job_node_cnt;
	int job_bit_inx  = 0, full_bit_inx  = 0, i;

	if (!job_resrcs_ptr->core_bitmap)
		return;

	/* add the job to the row_bitmap */
	if (*full_core_bitmap == NULL) {
		uint32_t size = 0;
		for (i = 0; i < node_record_count; i++)
			size += bits_per_node[i];
		*full_core_bitmap = bit_alloc(size);
	}

	job_node_cnt = bit_set_count(job_resrcs_ptr->node_bitmap);
	for (full_node_inx = bit_ffs(job_resrcs_ptr->node_bitmap);
	     job_node_cnt > 0; full_node_inx++) {
		if (bit_test(job_resrcs_ptr->node_bitmap, full_node_inx)) {
			full_bit_inx = cr_node_cores_offset[full_node_inx];
			for (i = 0; i < bits_per_node[full_node_inx]; i++) {
				if (!job_resrcs_ptr->whole_node &&
				    !bit_test(job_resrcs_ptr->core_bitmap,
					      job_bit_inx + i))
					continue;
				bit_clear(*full_core_bitmap, full_bit_inx + i);
			}
			job_bit_inx += bits_per_node[full_node_inx];
			job_node_cnt --;
		}
	}
}
示例#29
0
文件: Cowshed.c 项目: vmouse/Cowshed
void OutDataPort(uint8_t data) {
	data=~data; // в этой версии включаем нулями, поэтому инвертируем
	for (uint8_t i=0;i<8;i++) {
		bit_clear(PortControl, BIT(PCshift)); // взвели строб в 1
		bit_write(data & 0x80, PortControl, BIT(PCdata)); // вывели бит данных
//		_delay_us(3);
		bit_set(PortControl, BIT(PCshift)); // послали строб сдвига
//		_delay_us(3);
		data <<= 1;
	}
	// работаем по переднему фронту
	bit_clear(PortControl,BIT(PClatch));
	_delay_us(3);
	bit_set(PortControl,BIT(PClatch)); // послали строб записи в выходы
	bit_write(1, PortControl, BIT(PCdata)); // выставляем 1 на вход данных, т.е. в случшае помех по шине строба мы будем выключать устройства, а не включать
	bit_clear(PortControl,BIT(PClatch));
}
示例#30
0
/* Habilita los sensores segun corresponda para comenzar la lectura*/
void startReading(int sensors)
{
	// Sensor1
	if (bit_test(sensors, 0) == 1)
		sensor1 = SENSOR_ON;

	// Sensor2
	if (bit_test(sensors, 1) == 1)
		sensor2 = SENSOR_ON;

	// Sensor3
	if (bit_test(sensors, 2) == 1)
		sensor3 = SENSOR_ON;

	// Sensor4
	if (bit_test(sensors, 3) == 1)
		sensor4 = SENSOR_ON;

	// Sensor5
	if (bit_test(sensors, 4) == 1)
		sensor5 = SENSOR_ON;

	// Sensor6
#if TRIGGER_TYPE == ULTRASONIC_SENSOR
	// Sensor6 -> ULTRASONIC_SENSOR
	if (bit_test(sensors, 5) == 1)
	{
		// Comienza el pulso de habilitacion -> TRIGGER como escritura
		bit_clear(trisB_value, 0);
		set_tris_b(trisB_value);
		// Pin en estado habilitado -> envio del pulso INIT
		trigger = 1;
		delay_us(ULTRASONIC_INIT_PULSE_WIDTH_US);
		trigger = 0;
		// Termina el pulso de habilitacion -> TRIGGER como lectura
		bit_set(trisB_value, 0);
		set_tris_b(trisB_value);
		// Setea la interrupcion sobre RB0 en flanco ascendente
		ext_int_edge(L_TO_H);
		// Seteo el estado actual del pulso del sensor de ultrasonido
		usonic_state = USONIC_STATE_START;
		// Habilita la interrupcion
		enable_interrupts(INT_EXT);
	}
#elif TRIGGER_TYPE == SWITCH_SENSOR
	// Sensor6 -> SWITCH_SENSOR
	if (bit_test(sensors, 5) == 1)
	{
		if (trigger == 1)
			values[5] = 0xFFFF;
		else
			values[5] = 0;		
	} 
#endif

	return;
}