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


C++ SPI_I2S_SendData函数代码示例

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


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

示例1: hal_spi_raw_master_writeread

extern hal_result_t hal_spi_raw_master_writeread(hal_spi_t id, uint8_t byte, uint8_t* readbyte)
{
    hal_spi_internal_item_t* intitem = s_hal_spi_theinternals.items[HAL_spi_id2index(id)];
    hal_spi_cfg_t* cfg = NULL;
    volatile uint32_t timeout = 0;
    SPI_TypeDef* SPIx = HAL_spi_id2stmSPI(id);
    
    
    if(hal_false == hal_spi_hid_initted_is(id))
    {
        return(hal_res_NOK_generic);
    }
    
    cfg = &intitem->config;    
        
    if(hal_spi_act_raw != cfg->activity)
    {
        return(hal_res_NOK_generic);
    }
    
    // before we write we need to wait for the spi has txe set
    timeout = s_hal_spi_timeout_flag;        
    while(RESET == SPI_I2S_GetFlagStatus(SPIx, SPI_I2S_FLAG_TXE))
    {
        if(0 == (timeout--)) s_hal_spi_timeoutexpired();
    }         
    
    // ok. we send the byte
    SPI_I2S_SendData(SPIx, byte);
    
    // we need to wait for a reply from the slave
    timeout = s_hal_spi_timeout_flag;
    while(RESET == SPI_I2S_GetFlagStatus(SPIx, SPI_I2S_FLAG_RXNE))
    {
        if(0 == (timeout--)) s_hal_spi_timeoutexpired();
    }  
    
    // ok. here it is
    uint8_t rb = SPI_I2S_ReceiveData(SPIx);

    // if we want to retrieve it we copy into return value
    if(NULL != readbyte)   
    {
        *readbyte = rb;
    }  
  
    return(hal_res_OK);     
}
开发者ID:drdanz,项目名称:icub-firmware,代码行数:48,代码来源:hal_periph_spi_minimal.c

示例2: s_hal_spi_read_isr

static void s_hal_spi_read_isr(hal_spi_t id)
{
    hal_spi_internal_item_t* intitem = s_hal_spi_theinternals.items[HAL_spi_id2index(id)]; 
    SPI_TypeDef* SPIx = HAL_spi_id2stmSPI(id);
     
    uint8_t rxbyte = SPI_I2S_ReceiveData(SPIx);
     
    if(intitem->isrrxcounter < intitem->config.sizeofframe)
    {
        intitem->isrrxframe[intitem->isrrxcounter] = rxbyte;
        intitem->isrrxcounter ++;
    }
     
    if(intitem->isrrxcounter == intitem->config.sizeofframe)
    {   // ok. the frame is finished
    
        // 1. stop spi 
        s_hal_spi_periph_disable(id);         // disable periph                                        	     
		s_hal_spi_rx_isr_disable(id); //hal_SPI4ENCODER_IT_RX_DISA(port);   // disable interrupt rx
        
        // set back to zero the frame burst
        intitem->frameburstcountdown = 0;
        // set rx counter to zero again
        intitem->isrrxcounter = 0;
        
        // copy the rxframe into the rx fifo
        
        if(hal_true == hal_utility_fifo_full(&(intitem->fiforx)))
        {
            hal_utility_fifo_pop(&(intitem->fiforx));
        }
        hal_utility_fifo_put(&(intitem->fiforx), intitem->isrrxframe);         
        
        // now manage the callback
        hal_callback_t onframereceiv = intitem->config.onframereceiv;
        void *arg = intitem->config.argonframereceiv;     
        if(NULL != onframereceiv)
        {
            onframereceiv(arg);
        }        
    }
    else
    {
        // transmit one dummy byte to trigger yet another reception
        SPI_I2S_SendData(SPIx, intitem->config.dummytxvalue);    
    }
 
}
开发者ID:drdanz,项目名称:icub-firmware,代码行数:48,代码来源:hal_periph_spi_minimal.c

示例3: GPIO_Configuration_PinB2

void GPIO_Configuration_PinB2(void){
GPIO_InitTypeDef irq ;
EXTI_InitTypeDef EXTI_InitStructure ;
NVIC_InitTypeDef NVIC_InitStructure ;
irq.GPIO_Pin = GPIO_Pin_2;
irq.GPIO_Speed = GPIO_Speed_10MHz;
irq.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init(GPIOB, &irq);


GPIO_EXTILineConfig(GPIO_PortSourceGPIOB,GPIO_PinSource2);
// Configure EXTI1 line
  EXTI_InitStructure.EXTI_Line = EXTI_Line2;
  EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
  EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;
  EXTI_InitStructure.EXTI_LineCmd = ENABLE;
  EXTI_Init(&EXTI_InitStructure);

  NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0);
  NVIC_InitStructure.NVIC_IRQChannel = EXTI2_IRQn;
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x00;
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x07;
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&NVIC_InitStructure);

    void EXTI1_IRQHandler(void){
        if(EXTI_GetITStatus(EXTI_Line2) != RESET){
               // if(SPI_I2S_IT_TXE==1){
               if(MASK_TX_DS==0){                  //Active low
                    void nRF24L01_SPI_Send_Byte(unsigned char* data,unsigned long sizeof_tx){
                        nRF24L01_SPI_NSS_L();                    		// Set CSN low, init SPI tranaction
                        while(tx_element<=sizeof_tx){
                            tx_element++;
                            /* Send byte through the SPI2 peripheral */
                            SPI_I2S_SendData(SPI2, data[tx_element]);
                            }
                        nRF24L01_SPI_NSS_H();
                        }
                }
                if(MASK_RX_DR==0){
                    void nRF24L01_SPI_receive_Byte(unsigned char* R,unsigned long sizeof_rx){
                        nRF24L01_SPI_NSS_L();                    		// Set CSN low, init SPI tranaction
                            while(rx_element<=sizeof_rx){
                                R[rx_element]=SPI_I2S_ReceiveData(SPI2);
                                rx_element++;
                            }
                        nRF24L01_SPI_NSS_H();
                    }
开发者ID:MohamedHassanHelal,项目名称:MOTSL,代码行数:48,代码来源:IRQnRF24L01P.c

示例4: SPI1_Write

/**
 * @brief	Writes data to the SPI
 * @param	Data: data to be written to the SPI
 * @retval	None
 */
void SPI1_Write(uint8_t Data)
{
#if 0 /* This adds overhead */
	/* Loop while DR register is not empty */
	while (SPI_I2S_GetFlagStatus(SPIx, SPI_I2S_FLAG_TXE) == RESET);
	/* Send byte through the SPIx peripheral */
	SPI_I2S_SendData(SPIx, (uint16_t)Data);
#endif

#if 1 /* This is faster */
	/* Loop while DR register is not empty */
	while ((SPIx->SR & SPI_I2S_FLAG_TXE) == RESET);
	/* Send byte through the SPIx peripheral */
	SPIx->DR = Data;
#endif
}
开发者ID:fwengineer,项目名称:STM32-Libraries,代码行数:21,代码来源:spi1.c

示例5: D_SPI_ReceiveData

/**
  * @brief  Receives 1 Byte that has been send over the SPI Bus
  * @param  None
  * @retval The received Byte
  */
uint8_t D_SPI_ReceiveData(){

	/*!< Wait until the transmit buffer is empty */
	while(SPI_I2S_GetFlagStatus(D_SPI, SPI_I2S_FLAG_TXE) == RESET)
	{
	}

	SPI_I2S_SendData(D_SPI, DUMMYBYTE);

	/*!< Wait to receive a byte*/
	while(SPI_I2S_GetFlagStatus(D_SPI, SPI_I2S_FLAG_RXNE) == RESET)
	{
	}

	return SPI_I2S_ReceiveData(D_SPI);
}
开发者ID:markusk,项目名称:direcs,代码行数:21,代码来源:D_HaLayer.c

示例6: SPI2_IRQHandler

/*******************************************************************************
* Function Name  : SPI2_IRQHandler
* Description    : This function handles SPI2 global interrupt request.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void SPI2_IRQHandler(void)
{
  /* Check the interrupt source */
  if (SPI_I2S_GetITStatus(SPI2, SPI_I2S_IT_TXE) == SET)
  {
    /* Send a data from I2S2 */
    SPI_I2S_SendData(SPI2, I2S2_Buffer_Tx[TxIdx++]);
  }

  /* Check the end of buffer transfer */
  if (RxIdx == 32)
  {
    /* Disable the I2S2 TXE interrupt to end the communication */
    SPI_I2S_ITConfig(SPI2, SPI_I2S_IT_TXE, DISABLE);
  }
}
开发者ID:zaurus04,项目名称:cortexm3,代码行数:23,代码来源:stm32f10x_it.c

示例7: SPIGetChar

/*******************************************************************************
* Function Name  : SPIGetChar
* Description    : Read a byte from the SPI.
* Input          : None.
* Output         : None
* Return         : The received byte.
*******************************************************************************/
u8 SPIGetChar(void)
{
  u8 Data = 0;

  /* Wait until the transmit buffer is empty */
  while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_TXE) == RESET);
  /* Send the byte */
  SPI_I2S_SendData(SPI1, 0xFF);

  /* Wait until a data is received */
  while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_RXNE) == RESET);
  /* Get the received data */
  Data = SPI_I2S_ReceiveData(SPI1);
  /* Return the shifted data */
  return Data;
}
开发者ID:FXRer,项目名称:STM32F4_DISCOVERY,代码行数:23,代码来源:vs1003+(2).c

示例8: spi_flash_send_byte

/**
* @brief  Sends a byte through the SPI interface and return the byte
*   received from the SPI bus.
* @param byte : byte to send.
* @retval : The value of the received byte.
*/
unsigned char spi_flash_send_byte(unsigned char byte)
{
         volatile short			i = 0;
	/* Loop while DR register in not emplty */
	while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_TXE) == RESET);

	/* Send byte through the SPI1 peripheral */
	SPI_I2S_SendData(SPI1, byte);

	/* Wait to receive a byte */
	//while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_RXNE) == RESET);
        for(i=0; i<10; i++);

	/* Return the byte read from the SPI bus */
	return SPI_I2S_ReceiveData(SPI1);
}
开发者ID:joe3501,项目名称:BlueRing,代码行数:22,代码来源:spi_flash.c

示例9: spi_flash_send_halfword

/**
* @brief  Sends a Half Word through the SPI interface and return the
*         Half Word received from the SPI bus.
* @param HalfWord : Half Word to send.
* @retval : The value of the received Half Word.
*/
unsigned short spi_flash_send_halfword(unsigned short HalfWord)
{
        volatile short			i = 0;
	/* Loop while DR register in not emplty */
	while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_TXE) == RESET);

	/* Send Half Word through the SPI1 peripheral */
	SPI_I2S_SendData(SPI1, HalfWord);

	/* Wait to receive a Half Word */
	//while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_RXNE) == RESET);
        for(i=0; i<10; i++);
        
	/* Return the Half Word read from the SPI bus */
	return SPI_I2S_ReceiveData(SPI1);
}
开发者ID:joe3501,项目名称:BlueRing,代码行数:22,代码来源:spi_flash.c

示例10: l3gd20_SendHalfWord

/**
  * @brief  Sends a Half Word through the SPI interface and return the Half Word
  *         received from the SPI bus.
  * @param  HalfWord: Half Word to send.
  * @retval The value of the received Half Word.
  */
uint16_t l3gd20_SendHalfWord(uint16_t HalfWord)
{
	/* Loop while DR register in not empty */
	while (SPI_I2S_GetFlagStatus(SPIx, SPI_I2S_FLAG_TXE) == RESET);
	l3gd20_CS_LOW();

	/* Send Half Word through the sFLASH peripheral */
	SPI_I2S_SendData(SPIx, HalfWord);

	/*!< Wait to receive a Half Word */
	while (SPI_I2S_GetFlagStatus(SPIx, SPI_I2S_FLAG_RXNE) == RESET);
	l3gd20_CS_HIGH();

	/* Return the Half Word read from the SPI bus */
	return SPI_I2S_ReceiveData(SPIx);
}
开发者ID:wmRosy,项目名称:Flow,代码行数:22,代码来源:gyro.c

示例11: oled_blit

// Blit a sprite to screen
void oled_blit(uint8_t x, uint8_t y, uint8_t w, uint8_t h, void *buffer) {
  oled_window(x, y, x + w - 1, y + h - 1);

  pin_clear(OLED_NCS);

  pin_clear(OLED_A0);
  SPI_I2S_SendData(OLED_SPI, 0xC);
  oled_wait_spi();
  pin_set(OLED_A0);

  oled_dma((uint8_t*)buffer, (w * h) << 1);
  oled_wait_dma();
  oled_wait_spi();

  pin_set(OLED_NCS);
}
开发者ID:KryoStoffer,项目名称:SmartWatch_Toolchain,代码行数:17,代码来源:driver_display.c

示例12: SPI1_Transmit

/**
 * @brief Transmit data on SPI1
 * @param data Sent data
 * @return Received data
 * @warning Blocking function!
 */
uint8_t SPI1_Transmit(uint8_t data) {

  uint8_t i;

  // Loop while transmit register in not empty
  while(SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_TXE) == RESET);

  SPI_I2S_SendData(SPI1, data); // Send byte (start transmit)

  // Wait for new data (transmit end)
  while(SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_RXNE) == RESET);

  i = SPI_I2S_ReceiveData(SPI1); // Received data

  return i;
}
开发者ID:kvp7206,项目名称:STM32F4_SD,代码行数:22,代码来源:spi1.c

示例13: HCMS3907_putBufferPolled

void HCMS3907_putBufferPolled(char *buf, uint8_t len) {
  HCMS3907_DATA();
  HCMS3907_SELECT();
  while (len) {
    // always make sure the transmit buffer is free
    while (SPI_I2S_GetFlagStatus(SPI_PORT, SPI_I2S_FLAG_TXE) == RESET);
    SPI_I2S_SendData(SPI_PORT, *buf++);
    len--;
  }
  // be sure the last byte is sent to the shift register
  while (SPI_I2S_GetFlagStatus(SPI_PORT, SPI_I2S_FLAG_TXE) == RESET);
  // and then wait until it goes over the wire
  while (SPI_I2S_GetFlagStatus(SPI_PORT, SPI_I2S_FLAG_BSY) == SET);
  HCMS3907_DESELECT();

}
开发者ID:BackupTheBerlios,项目名称:ledcube-svn,代码行数:16,代码来源:HCMS3907.c

示例14: spiTransfer

bool spiTransfer(uint8_t *out, uint8_t *in, int len)
{
    uint8_t b;
    SPI2->DR;
    while (len--) {
        b = in ? *(in++) : 0xFF;
        while (SPI_I2S_GetFlagStatus(SPI2, SPI_I2S_FLAG_TXE) == RESET);
        SPI_I2S_SendData(SPI2, b);
        while (SPI_I2S_GetFlagStatus(SPI2, SPI_I2S_FLAG_RXNE) == RESET);
        b = SPI_I2S_ReceiveData(SPI2);
        if (out)
            *(out++) = b;
    }

    return true;
}
开发者ID:lit1088,项目名称:baseflight,代码行数:16,代码来源:drv_spi.c

示例15: DRV_Spi_RW_Byte

unsigned short DRV_Spi_RW_Byte( DRV_Spi_Handle Handle , unsigned char ucOut)
{
	Spi_Device_Data *pSpiData = (Spi_Device_Data *) Handle ;

	if( pSpiData == NULL)
		return 0;

	/* Send byte through the SPI peripheral */
	SPI_I2S_SendData(pSpiData->pCfg->pDevice, ucOut);

	/* Wait to receive a byte */
	while (SPI_I2S_GetFlagStatus(pSpiData->pCfg->pDevice, SPI_I2S_FLAG_RXNE) == RESET) { ; }

	/* Return the byte read from the SPI bus */
	return SPI_I2S_ReceiveData(pSpiData->pCfg->pDevice);
}
开发者ID:St0rmingBr4in,项目名称:wallig,代码行数:16,代码来源:DRV_Spi_Stm32.c


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