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


C++ spi_read函数代码示例

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


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

示例1: SPI0_Handler

void SPI0_Handler(void) {	
	uint16_t us_data;
	uint32_t us_tx_data;	
			
	uint8_t p_pcs;
	
	uint32_t status = spi_read_status(_spi_base);
		
	if (status & SPI_SR_RDRF) {		
		if ( spi_read( _spi_base, &us_data,	&p_pcs ) == SPI_OK ) {
			// store received byte
			fifo_push_uint8(_this->_spi_rx_fifo_desc, us_data);
			
			// If handler defined - call it with instance and received byte.
			if (_this->_call_back)
			{
				_this->_call_back(_this, (uint8_t)us_data);
			}
		}
	}	
	
	if (status & SPI_SR_TDRE) {
		// more bytes to send?		
		if ( fifo_pull_uint32(_this->_spi_tx_fifo_desc, &us_tx_data) == FIFO_OK ) {
			_spi_base->SPI_TDR = us_tx_data;
		} else {
			// No
			// Disable SPI TX interrupt
			spi_disable_interrupt(_spi_base, SPI_IDR_TDRE);
			_spi_active = 0;
		}
	}
}
开发者ID:scj-devel,项目名称:hvm-scj,代码行数:33,代码来源:iha_spi.c

示例2: bfin_get_num_params

void bfin_get_num_params(volatile u32* num) {
  u16 x;

  app_pause();

  // command 
  spi_selectChip(BFIN_SPI, BFIN_SPI_NPCS);
  spi_write(BFIN_SPI, MSG_GET_NUM_PARAMS_COM);
  spi_unselectChip(BFIN_SPI, BFIN_SPI_NPCS);

  print_dbg("\r\n : spi_write MSG_GET_NUM_PARAMS");

  // read num
  spi_selectChip(BFIN_SPI, BFIN_SPI_NPCS);
  spi_write(BFIN_SPI, 0); //dont care
  spi_read(BFIN_SPI, &x);
  spi_unselectChip(BFIN_SPI, BFIN_SPI_NPCS);  
  *num = (u8)(x & 0xff);

  print_dbg("\r\n : spi_read numparams: ");
  print_dbg_ulong(*num);

  app_resume();

}
开发者ID:bensteinberg,项目名称:aleph,代码行数:25,代码来源:bfin.c

示例3: pfio_read_input

uint8_t pfio_read_input(void)
{
    // XOR by 0xFF so we get the right outputs.
    // before a turned off input would read as 1,
    // confusing developers.
    return spi_read(INPUT_PORT) ^ 0xFF;
}
开发者ID:m15k,项目名称:piface,代码行数:7,代码来源:pfio.c

示例4: platform_wifi_spi_rx_dma_irq

void platform_wifi_spi_rx_dma_irq(void)
{
  uint8_t junk1;
  uint16_t junk2;
  pdc_packet_t pdc_spi_packet = { 0, 1 };
  Pdc* spi_pdc  = spi_get_pdc_base( wifi_spi.port );
  
  uint32_t status = spi_read_status( wifi_spi.port );
  uint32_t mask = spi_read_interrupt_mask( wifi_spi.port );
  
  if ( ( mask & SPI_IMR_RXBUFF ) && ( status & SPI_SR_RXBUFF ) )
  {
    pdc_disable_transfer( spi_pdc, PERIPH_PTCR_RXTDIS | PERIPH_PTCR_TXTDIS );
    pdc_rx_init( spi_pdc, &pdc_spi_packet, NULL );
    pdc_tx_init( spi_pdc, &pdc_spi_packet, NULL );
    spi_disable_interrupt( wifi_spi.port, SPI_IER_RXBUFF );
  }
  
  if ( ( mask & SPI_IMR_ENDTX ) && ( status & SPI_SR_ENDTX ) )
  {
    pdc_disable_transfer( spi_pdc, PERIPH_PTCR_TXTDIS );
    pdc_tx_init( spi_pdc, &pdc_spi_packet, NULL );
    spi_disable_interrupt( wifi_spi.port, SPI_IER_ENDTX );
    /* Clear SPI RX data in a SPI send sequence */
    spi_read( wifi_spi.port, &junk2, &junk1);
  }
  
  mico_rtos_set_semaphore( &spi_transfer_finished_semaphore );
}
开发者ID:OfficeKit,项目名称:OfficeKit_Embed_MiCO,代码行数:29,代码来源:wlan_bus_spi.c

示例5: w25qxx_probe

//芯片探测
int w25qxx_probe(void)
{
    uint32_t i;
    uint16_t id;
    uint8_t buf[4];
    buf[0] = W25X_ManufactDeviceID;
    buf[1] = 0;
    buf[2] = 0;
    buf[3] = 0;
    /* read id */
    spi_write(&device, buf, 4, false);
    spi_read(&device, buf, 2, true);
    id = ((buf[0]<<8) + buf[1]);
    W25QXX_TRACE("ID:%d\r\n", id);
    //see if we find a match
    for(i = 0; i< ARRAY_SIZE(w25qxx_attr_table);i++)
    {
        if(w25qxx_attr_table[i].id == id)
        {
            // find a match
            w25qxx_type.name = w25qxx_attr_table[i].name;
            w25qxx_type.id = w25qxx_attr_table[i].id;
            w25qxx_type.size = w25qxx_attr_table[i].size;
            w25qxx_power_up();
            buf[0] = w25qxx_read_sr();
            W25QXX_TRACE("SR:0x%X\r\n", buf[0]);
            buf[0] = w25qxx_read_sr2();
            W25QXX_TRACE("SR2:0x%X\r\n", buf[0]);
            // enable full access to all memory regin, something like unlock chip.
            w25qxx_write_sr(0x00);
            return SPI_EOK; 
        }
    }
    return SPI_ERROR;
}
开发者ID:liubins313,项目名称:rt-thread-1.2.0-k60,代码行数:36,代码来源:w25qxx.c

示例6: eeprom_get_status_reg

/*----------------------------------------------------------------------*/
static void eeprom_get_status_reg(u8 *status) 
{
	spi_chip_select(ENABLE);
	spi_write(RDSR_CMD);
	*status = spi_read();		
	spi_chip_select(DISABLE);
}
开发者ID:stas2z,项目名称:linux-3.10-witi,代码行数:8,代码来源:spi_drv.c

示例7: spi_eeprom_read

/*----------------------------------------------------------------------*/
unsigned char spi_eeprom_read(u16 address, u16 nbytes, u8 *dest)
{
	u8	status;
	u16	cnt = 0;
	int i = 0;

	do {
		i++;
		eeprom_get_status_reg(&status);		
	}
	while((status & (1<<RDY)) && (i < max_ee_busy_loop));

	if (i == max_ee_busy_loop)
		return (status);

	/* eeprom ready */
	if (!(status & (1<<RDY))) {	
		spi_chip_select(ENABLE);
		/* read op */
		spi_write(READ_CMD);
		spi_write((u8)(address >> 8));		/* MSB byte First */
		spi_write((u8)(address & 0x00FF));	/* LSB byte */

		while (cnt < nbytes) {
			*(dest++) = spi_read();
			cnt++;
		}
		status = 0;
		/* deassert cs */
		spi_chip_select(DISABLE);
	} 
开发者ID:StephenMacras,项目名称:dsl-n55u-bender,代码行数:32,代码来源:spi_drv.c

示例8: main

int main(void)
{
	int counter = 0;
	uint16_t rx_value = 0x42;

/* Setup Rx/Tx buffers for USART */
	buffer_init(send_buffer,BUFFER_SIZE);
	buffer_init(receive_buffer,BUFFER_SIZE);

	clock_setup();
	gpio_setup();
	usart_setup();
    usart_print_string("SPI-DMA Test\n\r");
	spi_setup();

	while (1) {

        gpio_toggle(GPIOA, GPIO1);

#ifdef LOOPBACK
/* Print what is going to be sent on the SPI bus */
		usart_print_string("Sending  packet ");
        usart_print_int(counter);
        usart_print_string("\n\r");
		spi_send(SPI1, (uint8_t) counter);
		rx_value = spi_read(SPI1);
		usart_print_string("Received  packet ");
        usart_print_int(rx_value);
        usart_print_string("\n\r");
        counter++;
#else
/* This is a 1-byte "reset" command to SD card */
		spi_send(SPI1, 0x40);
		spi_send(SPI1, 0x00);
		spi_send(SPI1, 0x00);
		spi_send(SPI1, 0x00);
		spi_send(SPI1, 0x00);
		spi_send(SPI1, 0x95);
	/* Read the byte that just came in (use a loopback between MISO and MOSI
	 * to get the same byte back)
	 */
		rx_value = spi_read(SPI1);
#endif
	}

	return 0;
}
开发者ID:JamesLinus,项目名称:ARM-Ports,代码行数:47,代码来源:spi1-test.c

示例9: bfin_get_param

// get parameter value
s32 bfin_get_param(u8 idx) {
  ParamValueCommon pval;
  u16 x;
  
  app_pause();

  // command
  spi_selectChip(BFIN_SPI, BFIN_SPI_NPCS);
  spi_write(BFIN_SPI, MSG_GET_PARAM_COM);
  spi_unselectChip(BFIN_SPI, BFIN_SPI_NPCS);

  // idx
  spi_selectChip(BFIN_SPI, BFIN_SPI_NPCS);
  spi_write(BFIN_SPI, idx);
  spi_unselectChip(BFIN_SPI, BFIN_SPI_NPCS);

  /// read value
  spi_selectChip(BFIN_SPI, BFIN_SPI_NPCS);
  spi_write(BFIN_SPI, 0); // don't care
  spi_read(BFIN_SPI, &x);
  spi_unselectChip(BFIN_SPI, BFIN_SPI_NPCS);
  pval.asByte[0] = (u8)x;

  spi_selectChip(BFIN_SPI, BFIN_SPI_NPCS);
  spi_write(BFIN_SPI, 0); // don't care
  spi_read(BFIN_SPI, &x);
  spi_unselectChip(BFIN_SPI, BFIN_SPI_NPCS);
  pval.asByte[1] = (u8)x;

  spi_selectChip(BFIN_SPI, BFIN_SPI_NPCS);
  spi_write(BFIN_SPI, 0); // don't care
  spi_read(BFIN_SPI, &x);
  spi_unselectChip(BFIN_SPI, BFIN_SPI_NPCS);
  pval.asByte[2] = (u8)x;

  spi_selectChip(BFIN_SPI, BFIN_SPI_NPCS);
  spi_write(BFIN_SPI, 0); // don't care
  spi_read(BFIN_SPI, &x);
  spi_unselectChip(BFIN_SPI, BFIN_SPI_NPCS);
  pval.asByte[3] = (u8)x;

  app_resume();

  return pval.asInt;
  
}
开发者ID:bensteinberg,项目名称:aleph,代码行数:47,代码来源:bfin.c

示例10: w25qxx_read_sr2

//芯片读
static uint8_t w25qxx_read_sr2(void)
{
    uint8_t buf[1];
    buf[0] = W25X_ReadStatusReg2;
    spi_write(&device, buf, 1, false); //false = 保持片选,继续发送
    spi_read(&device, buf, 1, true);
    return buf[0];
}
开发者ID:liubins313,项目名称:rt-thread-1.2.0-k60,代码行数:9,代码来源:w25qxx.c

示例11: accel_sensor_write_reg

static void accel_sensor_write_reg(spi_chip_t * chip, uint8_t reg_base) {
	if (spi_lock_dev(chip->spi_dev) <0)
		return;
	spi_write(chip, reg_base);
	//printf("Writing %#x\r\n", ((reg_base + 1) << 8) | 0x8000 | ((value >> 8) & 0xff));
	spi_read(chip);
	spi_unlock_dev(chip->spi_dev);
}
开发者ID:rtr14,项目名称:libfsw_sensor,代码行数:8,代码来源:accel_sensor.c

示例12: spi_get

ssize_t spi_get(struct spi_driver_t *self_p,
                uint8_t *data_p)
{
    ASSERTN(self_p != NULL, EINVAL);
    ASSERTN(data_p != NULL, EINVAL);

    return (spi_read(self_p, data_p, 1));
}
开发者ID:eerimoq,项目名称:simba,代码行数:8,代码来源:spi.c

示例13: ms5611_convert_pressure

static inline uint32_t ms5611_convert_pressure(void)
{
	uint32_t data;
	spi_select();
	spi_write(0x48);	//highest resolution option
	spi_deselect();
	//delay_ms(10);
	delay_ms(10);
	spi_select();
	spi_write(0x00);
	data = ((uint32_t)spi_read())<<16;
	data+= ((uint32_t)spi_read())<<8;
	data+= ((uint32_t)spi_read());
	spi_deselect();
	delay_ms(1);
	return data;
}
开发者ID:melsabae,项目名称:shc_one_month,代码行数:17,代码来源:ms5611.c

示例14: as3935_set_tuning_capacitor

void ICACHE_FLASH_ATTR as3935_set_tuning_capacitor(uint8_t cap){
	HSPI_INIT_STUF;
	as3935.x8.d8=spi_read(8);
	as3935.x8.a8.TUN_CAP=cap;
	
	os_printf("\nsetting tun cap to: %d, %d\n",tuncaplookuptable[cap],cap );
	spi_write(8,as3935.x8.d8);		
}
开发者ID:na1pir,项目名称:as3935_esp8266_iot,代码行数:8,代码来源:as3935.c

示例15: adc_convert

// perform a conversion on all 4 channels
static void adc_convert(u16 (*dst)[4]) {
#if 1
#else
  u16 cmd, val;

  // data into AD7923 is a left-justified 12-bit value in a 16-bit word
  // so, always lshift the command before sending
  cmd = ( AD7923_CMD_BASE ) << 4;
  spi_selectChip(ADC_SPI, ADC_SPI_NPCS);
  spi_write(ADC_SPI, cmd);
  spi_unselectChip(ADC_SPI, ADC_SPI_NPCS);

  // get channel 0, setup channel 1
  cmd = ( AD7923_CMD_BASE | AD7923_CTL_ADD0 ) << 4;
  spi_selectChip(ADC_SPI, ADC_SPI_NPCS);
  spi_write(ADC_SPI, cmd);
  spi_read(ADC_SPI, &val);
  spi_unselectChip(ADC_SPI, ADC_SPI_NPCS);
  (*dst)[0] = val & 0xfff; 

  // get channel 1, setup channel 2
  cmd = ( AD7923_CMD_BASE | AD7923_CTL_ADD1 ) << 4;
  spi_selectChip(ADC_SPI, ADC_SPI_NPCS);
  spi_write(ADC_SPI, cmd);
  spi_read(ADC_SPI, &val);
  spi_unselectChip(ADC_SPI, ADC_SPI_NPCS);
  (*dst)[1] = val & 0xfff;

  // get channel 2, setup channel 3
  cmd = ( AD7923_CMD_BASE | AD7923_CTL_ADD1 | AD7923_CTL_ADD0 ) << 4;
  spi_selectChip(ADC_SPI, ADC_SPI_NPCS);
  spi_write(ADC_SPI, cmd);
  spi_read(ADC_SPI, &val);
  spi_unselectChip(ADC_SPI, ADC_SPI_NPCS);
  (*dst)[2] = val & 0xfff;

  // get channel 3, dummy write
  cmd = ( AD7923_CMD_BASE ) << 4;
  spi_selectChip(ADC_SPI, ADC_SPI_NPCS);
  spi_write(ADC_SPI, cmd);
  spi_read(ADC_SPI, &val);
  spi_unselectChip(ADC_SPI, ADC_SPI_NPCS);
  (*dst)[3] = val & 0xfff;

#endif
}
开发者ID:Someone101,项目名称:aleph,代码行数:47,代码来源:adc.c


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