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


C++ write16函数代码示例

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


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

示例1: read16

/**
 *  \brief            Write a 16 bit value to EEPROM after first clearing the memory.
 *  \li               Erase and write time 5ms per manufacturer specification
 *  \li               Manufacturer does not specify max or min erase/write times
 *  \param [in] reg   Address to write to.
 *  \param [in] data  Value to write.
 */
void MLX90614::writeEEProm(uint8_t reg, uint16_t data) {
    uint16_t val;
    reg |= 0x20;

    // read current value, compare to the new value, and do nothing on a match
    // or if there are read errors set the error status flag only
    val = read16(reg);
    if((val != data) && !_rwError) {

        // on any R/W errors it is assumed the memory is corrupted
        // clear the memory and wait Terase (per manufacturer's documentation)
        write16(reg, 0);
        delay(5);

        // if no write errors then write the new value
        if(_rwError) _rwError |= MLX90614_EECORRUPT;
        else {

            // write the data and wait Twrite (per manufacturer's documentation)
            write16(reg, data); 
            delay(5);
            if(_rwError) _rwError |= MLX90614_EECORRUPT;
        }
    }
}
开发者ID:ASelwa,项目名称:EtaVisionSystem,代码行数:32,代码来源:MLX90614.cpp

示例2: intel_extreme_uninit

void
intel_extreme_uninit(intel_info &info)
{
    CALLED();

    if (!info.fake_interrupts && info.shared_info->vblank_sem > 0) {
        // disable interrupt generation
        write16(info, find_reg(info, INTEL_INTERRUPT_ENABLED), 0);
        write16(info, find_reg(info, INTEL_INTERRUPT_MASK), ~0);

        remove_io_interrupt_handler(info.irq, intel_interrupt_handler, &info);

        if (info.use_msi && gPCIx86Module != NULL) {
            gPCIx86Module->disable_msi(info.pci->bus,
                                       info.pci->device, info.pci->function);
            gPCIx86Module->unconfigure_msi(info.pci->bus,
                                           info.pci->device, info.pci->function);
        }
    }

    gGART->unmap_aperture(info.aperture);

    delete_area(info.registers_area);
    delete_area(info.shared_area);
}
开发者ID:rakex,项目名称:haiku,代码行数:25,代码来源:intel_extreme.cpp

示例3: write16

void DSA1Intro::write(ostream& strm) {
    header_size = 20;
    count = entries.size(); // WRONG! Come back later to change it
    u16 truecount = 0;
    write16(strm, count);
    for (u8 i=0; i<0x20-2; i++) write8(strm, 0);

    u32 offset = 0;
    for (u32 i=0; i<count; i++) {
	// Nach Duplikaten suchen und diese markieren
	u32 j = 0;
	for ( ; j<i; j++) {
	    if (entries[i]->name == entries[j]->name) break;
	}
	if (j == i) { // Kein Duplikat gefunden
	    entries[i]->offset = offset;
	    entries[i]->write(strm);
	    offset += entries[i]->size;
	    truecount++;
	} else {      // Duplikat gefunden
	    entries[i]->offset = entries[j]->offset;
	    assert(entries[i]->size == entries[j]->size);
	    entries[i]->write(strm);
	}
    }
    for (u32 i=count; i < 139 ; i++) {
	for (u32 j=0; j < 0x20; j++) write8(strm, 0x00);
    }
    strm.seekp(0);
    write16(strm, truecount-1); // DUMMY nicht mitzählen
}
开发者ID:Henne,项目名称:BrightEyes,代码行数:31,代码来源:dsa1.cpp

示例4: _sci_init

static void _sci_init(
    rtems_device_minor_number minor )
{
    uint16_t  	temp16 ;

    /* Pin function controller initialisation for asynchronous mode */
    if( minor == 0)
    {
        temp16 = read16( PFC_PBCR1);
        temp16 &= ~( PB8MD | PB9MD );
        temp16 |= (PB_TXD0 | PB_RXD0);
        write16( temp16, PFC_PBCR1);
    }
    else
    {
        temp16 = read16( PFC_PBCR1);
        temp16 &= ~( PB10MD | PB11MD);
        temp16 |= (PB_TXD1 | PB_RXD1);
        write16( temp16, PFC_PBCR1);
    }

    /* disable sck-pin */
    if( minor == 0)
    {
        temp16 = read16( PFC_PBCR1);
        temp16 &= ~(PB12MD);
        write16( temp16, PFC_PBCR1);
    }
    else
    {
        temp16 = read16( PFC_PBCR1);
        temp16 &= ~(PB13MD);
        write16( temp16, PFC_PBCR1);
    }
}
开发者ID:kptran,项目名称:rtems,代码行数:35,代码来源:sci.c

示例5: pixbuf_export_bmp

void pixbuf_export_bmp(const PixBuf *pb, const char *filename) {
  int y;
  uint8_t row[pb->width*4];
  uint8_t header[54];
  const Pixel *pic = pb->array + (pb->height-1)*pb->width;
  FILE *out = fopen(filename, "wb");
  if (!out) {
    perror(filename);
    exit(1);
  }

  write16(header, 19778);
  write32(header + 2, pb->width*pb->height*3+14+40);
  write32(header + 6, 0);
  write32(header + 10, 14+40);

  write32(header + 14, 40);
  write32(header + 18, pb->width);
  write32(header + 22, pb->height);
  write16(header + 26, 1);
  write16(header + 28, 24);
  write32(header + 30, 0);
  write32(header + 34, pb->width*pb->height*3);
  write32(header + 38, 3780);
  write32(header + 42, 3780);
  write32(header + 46, 0x0);
  write32(header + 50, 0x0);

  fwrite(&header, sizeof(header), 1, out);
  for (y = 0; y < pb->height; y++) {
    fwrite(row, rgb_encode(row, pic, pb->width), 1, out);
    pic -= pb->width;
  }
  fclose(out);
}
开发者ID:ysei,项目名称:Atari_ST_Sources,代码行数:35,代码来源:pixbuf.c

示例6: main

int main(int argc, char **argv)
{
	FILE *in = fopen(argv[1], "r");
	FILE *out = fopen(argv[2], "wb");
	fprintf(out, "%s", "RIFF");
	write32(out, 1044);
	fprintf(out, "%s", "PAL ");
	fprintf(out, "%s", "data");
	write32(out, 256*4+8);
	write16(out, 0x0300);
	write16(out, 256);

	int count = 0;
	char buf[1000];

	while (fgets(buf, 1000, in)) {
		int r, g, b;
		if (count < 256) {
			if (sscanf(buf, "%d %d %d ", &r, &g, &b) == 3) {
				count++;
				fputc(r, out);
				fputc(g, out);
				fputc(b, out);
				fputc(0, out);
			}
		}
	}

	for (; count < 256; count++)  {
		write32(out, 0);
	}

	write32(out, 0xd801);
}
开发者ID:LibreGames,项目名称:Nooskewl_Engine,代码行数:34,代码来源:gpl_to_pal.cpp

示例7: load_pi

void load_pi(int p, int i) 
{
    oscommand(WRITE_ENABLE);
    ndelay();
    write16(PID_PGAIN_HI, p);
    ndelay();
    write16(PID_DGAIN_HI, i);
    ndelay();
    oscommand(WRITE_DISABLE);
}
开发者ID:cgrobbelaar,项目名称:svofski,代码行数:10,代码来源:main.cpp

示例8: hudson_set_spi100

void hudson_set_spi100(u16 norm, u16 fast, u16 alt, u16 tpm)
{
	uintptr_t base = hudson_spibase();
	write16((void *)(base + SPI100_SPEED_CONFIG),
				(norm << SPI_NORM_SPEED_NEW_SH) |
				(fast << SPI_FAST_SPEED_NEW_SH) |
				(alt << SPI_ALT_SPEED_NEW_SH) |
				(tpm << SPI_TPM_SPEED_NEW_SH));
	write16((void *)(base + SPI100_ENABLE), SPI_USE_SPI100);
}
开发者ID:canistation,项目名称:coreboot,代码行数:10,代码来源:early_setup.c

示例9: get_data_type

/*****************************************************************************
 * DoWork: convert a buffer
 *****************************************************************************/
static block_t *DoWork( filter_t * p_filter, block_t *p_in_buf )
{
    size_t i_length = p_in_buf->i_buffer;
    uint8_t * p_in = p_in_buf->p_buffer;
    block_t *p_out_buf = NULL;

    uint16_t i_data_type = get_data_type( p_filter, p_in_buf );
    if( i_data_type == 0 || ( i_length + 8 ) > AOUT_SPDIF_SIZE )
        goto out;

    size_t i_out_length = p_in_buf->i_nb_samples * 4;
    p_out_buf = block_Alloc( i_out_length );
    if( !p_out_buf )
        goto out;
    uint8_t *p_out = p_out_buf->p_buffer;

    /* Copy the S/PDIF headers. */
    void (*write16)(void *, uint16_t) =
        ( p_filter->fmt_out.audio.i_format == VLC_CODEC_SPDIFB )
        ? SetWBE : SetWLE;

    write16( &p_out[0], 0xf872 ); /* syncword 1 */
    write16( &p_out[2], 0x4e1f ); /* syncword 2 */
    write16( &p_out[4], i_data_type ); /* data type */
    write16( &p_out[6], i_length * 8 ); /* length in bits */

    bool b_input_big_endian = is_big_endian( p_filter, p_in_buf );
    bool b_output_big_endian =
        p_filter->fmt_out.audio.i_format == VLC_CODEC_SPDIFB;

    if( b_input_big_endian != b_output_big_endian )
    {
        swab( p_in, p_out + 8, i_length & ~1 );

        /* If i_length is odd, we have to adjust swapping a bit... */
        if( i_length & 1 && ( i_length + 9 ) <= i_out_length )
        {
            p_out[8 + i_length - 1] = 0;
            p_out[8 + i_length] = p_in[i_length-1];
            i_length++;
        }
    } else
        memcpy( p_out + 8, p_in, i_length );

    if( 8 + i_length < i_out_length ) /* padding */
        memset( p_out + 8 + i_length, 0, i_out_length - i_length - 8 );

    p_out_buf->i_dts = p_in_buf->i_dts;
    p_out_buf->i_pts = p_in_buf->i_pts;
    p_out_buf->i_nb_samples = p_in_buf->i_nb_samples;
    p_out_buf->i_buffer = i_out_length;
out:
    block_Release( p_in_buf );
    return p_out_buf;
}
开发者ID:BossKing,项目名称:vlc,代码行数:58,代码来源:tospdif.c

示例10: WriteCmd

void ILI9341_kbv::setAddrWindow(int16_t x, int16_t y, int16_t x1, int16_t y1)
{
    CS_ACTIVE;
    WriteCmd(ILI9341_CMD_COLUMN_ADDRESS_SET);
    write16(x);
    write16(x1);
    WriteCmd(ILI9341_CMD_PAGE_ADDRESS_SET);
    write16(y);
    write16(y1);
    CS_IDLE;
}
开发者ID:prenticedavid,项目名称:TFT_SPI_kbv,代码行数:11,代码来源:ILI9341_kbv.cpp

示例11: rma1_wdt_ping

static int rma1_wdt_ping(int irq, void *data)
{
	/* kicking the dog */
	write16(RWTCNT0, 0x5a00);

	/* interrupt clear & setting next timeout */
	write16(TMU(0, TCR01), 0x0000);
	write32(TMU(0, TCNT01), read32(TMU(0, TCOR01)));
	write16(TMU(0, TCR01), 0x20);

	return 0;
}
开发者ID:miettal,项目名称:armadillo420_standard_linux314,代码行数:12,代码来源:rma1_wdt.c

示例12: saveBitmap

int saveBitmap(const char* filename, u8* buffer, u32 w, u32 h)
{
	u8* temp=(u8*)malloc(w*h*3+sizeof(INFOHEADER)+sizeof(HEADER));

	HEADER* header=(HEADER*)temp;
	INFOHEADER* infoheader=(INFOHEADER*)(temp+sizeof(HEADER));

	write16(&header->type, 0x4D42);
	write32(&header->size, w*h*3+sizeof(INFOHEADER)+sizeof(HEADER));
	write32(&header->offset, sizeof(INFOHEADER)+sizeof(HEADER));
	write16(&header->reserved1, 0);
	write16(&header->reserved2, 0);

	write16(&infoheader->bits, 24);
	write32(&infoheader->size, sizeof(INFOHEADER));
	write32(&infoheader->compression, 0);
	write32(&infoheader->width, w);
	write32(&infoheader->height, h);
	write16(&infoheader->planes, 1);
	write32(&infoheader->imagesize, w*h*3);
	write32(&infoheader->xresolution, 0);
	write32(&infoheader->yresolution, 0);
	write32(&infoheader->importantcolours, 0);
	write32(&infoheader->ncolours, 0);
	int y,x;
	for(y=0;y<h;y++)
	{
		for(x=0;x<w;x++)
		{
			temp[((y*w)+x)*3+sizeof(INFOHEADER)+sizeof(HEADER)]=buffer[(x*h+y)*3+0];
			temp[((y*w)+x)*3+1+sizeof(INFOHEADER)+sizeof(HEADER)]=buffer[(x*h+y)*3+1];
			temp[((y*w)+x)*3+2+sizeof(INFOHEADER)+sizeof(HEADER)]=buffer[(x*h+y)*3+2];
		}
	}

	Handle file;
	Result ret=FSUSER_OpenFile(NULL, &file, configuration.sdmc, FS_makePath(PATH_CHAR, filename), FS_OPEN_WRITE|FS_OPEN_CREATE, FS_ATTRIBUTE_NONE);
	if(ret){svcCloseHandle(file); return -2;}

	u32 size=w*h*3+sizeof(INFOHEADER)+sizeof(HEADER);
	u32 bytesWritten=0;

	ret=FSFILE_Write(file, &bytesWritten, 0, temp, size, FS_WRITE_FLUSH);
	if(ret || bytesWritten!=size)return -2;

	FSFILE_Close(file);
	svcCloseHandle(file);
	free(temp);

	return 0;
}
开发者ID:UltiNaruto,项目名称:3dscraft,代码行数:51,代码来源:screenshot.c

示例13: write_2338

static void
write_2338 (u32 edx, u32 val)
{
	read_2338 (edx);
	write16 (DEFAULT_RCBA + 0x2338, (read16 (DEFAULT_RCBA + 0x2338)
					 & 0x1ff) | 0x600);
	wait_2338 ();

	write32 (DEFAULT_RCBA + 0x2334, val);
	wait_2338 ();
	write16 (DEFAULT_RCBA + 0x2338,
		 (read16 (DEFAULT_RCBA + 0x2338) & 0x1ff) | 0x600);
	read8 (DEFAULT_RCBA + 0x2338);
}
开发者ID:AdriDlu,项目名称:coreboot,代码行数:14,代码来源:early_pch.c

示例14: pch_pcr_write

/*
 * Write PCR register. (This is internal function)
 * It returns PCR register and size in 1/2/4 bytes.
 * The offset should not exceed 0xFFFF and must be aligned with size
 */
static int pch_pcr_write(u8 pid, u16 offset, u32 size, u32 data)
{
	if ((offset & (size - 1)) != 0) {
		printk(BIOS_DEBUG,
			"PchPcrWrite error. Invalid Offset: %x Size: %x",
			offset, size);
		return -1;
	}
	/* Write the PCR register with provided data
	 * Then read back PCR register to prevent from back to back write.
	 */
	switch (size) {
	case 4:
		write32(pcr_reg_address(pid, offset), (u32) data);
		break;
	case 2:
		write16(pcr_reg_address(pid, offset), (u16) data);
		break;
	case 1:
		write8(pcr_reg_address(pid, offset), (u8) data);
		break;
	default:
		return -1;
	}
	/* Ensure the writes complete. */
	complete_write();

	return 0;
}
开发者ID:AdriDlu,项目名称:coreboot,代码行数:34,代码来源:pcr.c

示例15: pl022_txrx16

static void pl022_txrx16(struct spi_chip *chip, uint16_t *wdat,
	uint16_t *rdat, size_t num_txpkts, size_t *num_rxpkts)
{
	size_t i = 0;
	size_t j = 0;
	struct pl022_data *pd = container_of(chip, struct pl022_data, chip);

	pd->gpio->ops->set_value(pd->cs_gpio_pin, GPIO_LEVEL_LOW);

	while (i < num_txpkts) {
		if (read8(pd->base + SSPSR) & SSPSR_TNF)
			/* tx 1 packet */
			write16(wdat[i++], pd->base + SSPDR);
	}

	do {
		while ((read8(pd->base + SSPSR) & SSPSR_RNE)
			&& (j < *num_rxpkts))
			/* rx 1 packet */
			rdat[j++] = read16(pd->base + SSPDR);
	} while ((read8(pd->base + SSPSR) & SSPSR_BSY) && (j < *num_rxpkts));

	*num_rxpkts = j;

	pd->gpio->ops->set_value(pd->cs_gpio_pin, GPIO_LEVEL_HIGH);
}
开发者ID:elektrischermoench,项目名称:optee_os,代码行数:26,代码来源:pl022_spi.c


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