• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ HAL_SPI_Transmit函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: bstdr_burst_read

/*!
 * @brief Generic burst read
 *
 * @param [out] dev_id I2C address, SPI chip select or user desired identifier
 *
 * @return Zero if successful, otherwise an error code
 */
bstdr_ret_t bstdr_burst_read(uint8_t dev_id, uint8_t reg_addr, uint8_t *reg_data, uint32_t len){
  
        uint8_t spi_address_cmd = 0x80;
        HAL_StatusTypeDef hal_res;
        
	/**< Burst read code comes here */
        if (dev_id == 0x1A)     //ACC sensor
        {
          //SPI chip select
          HAL_GPIO_WritePin(GPIOA, ACC_CS_Pin, GPIO_PIN_RESET);
          
          //SPI transcation begin
          spi_address_cmd |= reg_addr;
          
          hal_res = HAL_SPI_Transmit(&hspi3, &spi_address_cmd, 1, 500);
          
          hal_res = HAL_SPI_Receive(&hspi3, reg_data, len, 500);
          
          //SPI transcation end
          
          //SPI chip deselecet
          HAL_GPIO_WritePin(GPIOA, ACC_CS_Pin, GPIO_PIN_SET);
        }
        else if (dev_id == 0x1B) //Gyro sensor
        {
          //SPI chip select
          HAL_GPIO_WritePin(GPIOA, GYRO_CS_Pin, GPIO_PIN_RESET);
          
          //SPI transcation begin
          spi_address_cmd |= reg_addr;
          
          hal_res = HAL_SPI_Transmit(&hspi3, &spi_address_cmd, 1, 500);
          
          hal_res = HAL_SPI_Receive(&hspi3, reg_data, len, 500);
          
         
          //SPI transcation end
          
          //SPI chip deselecet
          HAL_GPIO_WritePin(GPIOA, GYRO_CS_Pin, GPIO_PIN_SET);
        }
        else
        {
          return BSTDR_E_CON_ERROR;
        }
              
        
	return BSTDR_OK;
}
开发者ID:sky8336,项目名称:mn20150714,代码行数:56,代码来源:bstdr_comm_support.c


示例2: Flash_Program

void Flash_Program(uint32_t Addr, uint8_t *Data, uint16_t Size)
{
	uint8_t cmd[4];
	uint8_t i;

	//Check if Erase/Program in progress
	Flash_WaitBusy();

	// Enable write
	Flash_Command(s_FLASH__CMD_WR_ENABLE);

	s_FLASH__SELECT();

	// Prepare command
	cmd[0] = s_FLASH__CMD_PAGE_PROGRAM;
	cmd[1] = (uint8_t)((Addr>>16) & 0xFF);
	cmd[2] = (uint8_t)((Addr>>8) & 0xFF);
	cmd[3] = (uint8_t)(Addr & 0xFF);

	// Send 'Program Page' instruction and address
	HAL_SPI_Transmit(&g_Flash_SpiHandle, cmd, 4, 1000);

	// Send data
	HAL_SPI_Transmit(&g_Flash_SpiHandle, Data, Size, 1000);

	s_FLASH__DESELECT();
}
开发者ID:TBMT14-PPG2,项目名称:blueoxi-device,代码行数:27,代码来源:flash.c


示例3: vfd_write_display_flag

void vfd_write_display_flag(uint8_t addr, uint8_t flag) {
	addr += 0xC0;
	HAL_GPIO_WritePin(SPI_CS_GPIO_Port, SPI_CS_Pin, GPIO_PIN_RESET);
	HAL_SPI_Transmit(&hspi1, &addr, 1, 1000);
	HAL_SPI_Transmit(&hspi1, &flag, 1, 1000);
	HAL_GPIO_WritePin(SPI_CS_GPIO_Port, SPI_CS_Pin, GPIO_PIN_SET);
}
开发者ID:li3p,项目名称:F4-DiscoverFree,代码行数:7,代码来源:main.c


示例4: INVMPU_WriteBytes

/**
* @brief  Write MPU60x0 register
* @param  addr: register address, data: data to write
* @retval None
*/
u8 INVMPU_WriteBytes(u8 addr, u16 len, const u8* data)
{
    MPU_SPISelect();
    if(HAL_SPI_Transmit(MPU_SPI, &addr, 1, 5) == HAL_OK)
    {
        HAL_SPI_Transmit(MPU_SPI, (u8*)data, len, 5);
    }
	MPU_SPIDeselect();
    return 0;
}
开发者ID:navipack,项目名称:navi-panel,代码行数:15,代码来源:inv_mpu_driver.c


示例5: MPU9255_Write_Reg

//SPIд¼Ä´æÆ÷
//reg:Ö¸¶¨µÄ¼Ä´æÆ÷µØÖ·
//value:дÈëµÄÖµ
uint8_t MPU9255_Write_Reg(uint8_t reg,uint8_t value)
{
	uint8_t status;
	SPI_MPU9255_CS_L;											  //ʹÄÜSPI´«Êä
	status = HAL_SPI_Transmit(&hspi1, &reg, 1, 0xFFFF);
	status = HAL_SPI_Transmit(&hspi1, &value, 1, 0xFFFF);
	SPI_MPU9255_CS_H;										  	//½ûÖ¹MPU9255
	Delay(0xFFF);
	return(status);													//·µ»Ø״ֵ̬
}
开发者ID:PaulingZhou,项目名称:RM2016_0X3_SystemBoard,代码行数:13,代码来源:mpu9255.c


示例6: spiTransfer

bool spiTransfer(SPI_TypeDef *instance, uint8_t *out, const uint8_t *in, int len)
{
    SPIDevice device = spiDeviceByInstance(instance);
    HAL_StatusTypeDef status;

#define SPI_DEFAULT_TIMEOUT 10

    if(!out) // Tx only
    {
        status = HAL_SPI_Transmit(&spiHardwareMap[device].hspi, (uint8_t *)in, len, SPI_DEFAULT_TIMEOUT);
    }
    else if(!in) // Rx only
    {
        status = HAL_SPI_Receive(&spiHardwareMap[device].hspi, out, len, SPI_DEFAULT_TIMEOUT);
    }
    else // Tx and Rx
    {
        status = HAL_SPI_TransmitReceive(&spiHardwareMap[device].hspi, (uint8_t *)in, out, len, SPI_DEFAULT_TIMEOUT);
    }

    if( status != HAL_OK)
        spiTimeoutUserCallback(instance);

    return true;
}
开发者ID:savaga,项目名称:betaflight-sirinfpv,代码行数:25,代码来源:bus_spi_hal.c


示例7: ds3234_get_reg

void ds3234_get_reg(uint8_t addr, uint8_t* val) {
	addr &= 0x7F;
	HAL_GPIO_WritePin(DS3234_CS_GPIO_Port, DS3234_CS_Pin, GPIO_PIN_RESET);
	HAL_SPI_Transmit(&hspi2, &addr, 1, 1000);
	HAL_SPI_Receive(&hspi2, val, 1, 1000);
	HAL_GPIO_WritePin(DS3234_CS_GPIO_Port, DS3234_CS_Pin, GPIO_PIN_SET);
}
开发者ID:li3p,项目名称:F4-DiscoverFree,代码行数:7,代码来源:main.c


示例8: DRV8301_readSpi

uint16_t DRV8301_readSpi(DRV8301_Handle handle, const DRV8301_RegName_e regName)
{

  // Actuate chipselect
  HAL_GPIO_WritePin(handle->nCSgpioHandle, handle->nCSgpioNumber, GPIO_PIN_RESET);
  osDelay(1);

  // Do blocking read
  uint16_t zerobuff = 0;
  uint16_t controlword = (uint16_t)DRV8301_buildCtrlWord(DRV8301_CtrlMode_Read, regName, 0);
  uint16_t recbuff = 0xbeef;
  HAL_SPI_Transmit(handle->spiHandle, (uint8_t*)(&controlword), 1, 1000);

  // Datasheet says you don't have to pulse the nCS between transfers, (16 clocks should commit the transfer)
  // but for some reason you actually need to pulse it.
  // Actuate chipselect
  HAL_GPIO_WritePin(handle->nCSgpioHandle, handle->nCSgpioNumber, GPIO_PIN_SET);
  osDelay(1);
  // Actuate chipselect
  HAL_GPIO_WritePin(handle->nCSgpioHandle, handle->nCSgpioNumber, GPIO_PIN_RESET);
  osDelay(1);

  HAL_SPI_TransmitReceive(handle->spiHandle, (uint8_t*)(&zerobuff), (uint8_t*)(&recbuff), 1, 1000);
  osDelay(1);

  // Actuate chipselect
  HAL_GPIO_WritePin(handle->nCSgpioHandle, handle->nCSgpioNumber, GPIO_PIN_SET);
  osDelay(1);

  assert(recbuff != 0xbeef);

  return(recbuff & DRV8301_DATA_MASK);
}  // end of DRV8301_readSpi() function
开发者ID:FrankMuenzner,项目名称:ODriveFirmware,代码行数:33,代码来源:drv8301.c


示例9: spi_rw

static sint8 spi_rw(uint8 *tx_buf, uint8 *rx_buf, uint16 u16Sz)
{
	sint8 result = M2M_SUCCESS;

	// Start SPI transfer
    // TODO: Use DMA

    __disable_irq();
    SPI_ASSERT_CS();
    if (tx_buf != 0) {
        if (HAL_SPI_Transmit(&SPI_HANDLE, tx_buf, u16Sz, SPI_TIMEOUT) != HAL_OK) {
            result = M2M_ERR_BUS_FAIL;
        }
	} else {
        tx_buf = rx_buf;
        memset(tx_buf, 0, u16Sz);
        if (HAL_SPI_TransmitReceive(&SPI_HANDLE, tx_buf, rx_buf, u16Sz, SPI_TIMEOUT) != HAL_OK) {
            result = M2M_ERR_BUS_FAIL;
        }

    }
	SPI_DEASSERT_CS();
    __enable_irq();

	return result;
}
开发者ID:MaurinElectroTextile,项目名称:openmv,代码行数:26,代码来源:nm_bus_wrapper.c


示例10: spi_test

static int spi_test(void) {
	uint8_t res = 0;
	uint8_t data = 0x23;

	printf("SPI test\n");

	while(1) {
		spi_delay(1000000);
		res = 0;
		// sync
		spi_sync();
		printf(">> synchronized\n");
		// data from master
		if (HAL_SPI_Receive(&SpiHandle, &res, 1, SPI_TIMEOUT_MAX) != HAL_OK) {
			printf("HAL_SPI_Receive error 1\n");
			return -1;
		}
		if (res != 0x57) {
			printf("HAL_SPI_Receive recieved not 0x57 but %x\n", res);
		}
		// request data
		if (HAL_SPI_Transmit(&SpiHandle, &data, 1, SPI_TIMEOUT_MAX) != HAL_OK) {
			printf("HAL SPI Transmit error\n");
			return -1;
		}
	}

	return 0;
}
开发者ID:AleksandraButrova,项目名称:embox,代码行数:29,代码来源:spi_slave.c


示例11: MAX_Init

void MAX_Init(){
	// MX_SPI2_Init();
	// __HAL_SPI_ENABLE(&hspi2);

#if 0	
	dataOut[0] = (17<<3) | 2;
	dataOut[1] = 0x10;

	cs_low;
	HAL_SPI_Transmit(&hspi2, dataOut, 2, 1000);
	cs_high;

	Hwreg(rUSBIEN, bmOSCOKIE);
	Hrreg(rUSBIEN);
	Hrreg(18<<3);
#endif
	
	// MAX3421E: Full duplex mode, INTLEVEL=0, POSINT=1 for pos edge interrupt pin
	Hwreg(rPINCTL,(bmFDUPSPI|bmPOSINT)); 
	MAX_Reset();

	// MAX3421E EVB
	Hwreg(rIOPINS1,0x00);		// seven-segs off
	Hwreg(rIOPINS2,0x00);		// and Vbus OFF (in case something already plugged in)
	HAL_Delay(200);
	VBUS_ON;
}
开发者ID:jbkim,项目名称:USB_Host_Max3421,代码行数:27,代码来源:MAX3421E.c


示例12: writeReg

static void writeReg(SPI_HandleTypeDef *const handle, const uint8_t &adr, const uint8_t val) {
//	HAL_I2C_Mem_Write(handle, 0x82, adr, 1, (uint8_t*)&val, 1, 0x0F);
	uint8_t buff[] = { adr, val };
	BSP_Gpio_SetPin(GPIO_MEMS_CS, false);
	HAL_SPI_Transmit(handle, buff, 2, 0x0F);
	BSP_Gpio_SetPin(GPIO_MEMS_CS, true);
}
开发者ID:schapa,项目名称:GraphicSceen,代码行数:7,代码来源:L3GD20.cpp


示例13: LCD_WR_DATA8

void LCD_WR_DATA8(uint8_t da)   //写8位数据
{
	SPILCD_CS_RESET;  //LCD_CS=0
	SPILCD_RS_SET;				    	   
	HAL_SPI_Transmit(&hspi1, &da, 1 , 100);
	SPILCD_CS_SET;  //LCD_CS=1   			 
}					   
开发者ID:uestc-maddog,项目名称:cubeMXLCD,代码行数:7,代码来源:lcd.c


示例14: send_SPI

// I/O
void send_SPI(uint8_t * inBuf, uint8_t inLength, uint8_t * outBuf, uint8_t outLength)
{
	HAL_GPIO_WritePin(COMP_CS_P, COMP_CS, GPIO_PIN_RESET);
	HAL_SPI_Transmit(&hspi1, outBuf, outLength, 1000);
	HAL_SPI_Receive(&hspi1, inBuf, inLength, 1000);
	HAL_GPIO_WritePin(COMP_CS_P, COMP_CS, GPIO_PIN_SET);
}
开发者ID:merida20,项目名称:SeniorDesign,代码行数:8,代码来源:main.c


示例15: HAL_SPI_TransmitNew

HAL_StatusTypeDef HAL_SPI_TransmitNew(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size, uint32_t Timeout){
   HAL_StatusTypeDef returnvar;
   HAL_GPIO_WritePin(GPIOD,GPIO_PIN_8,GPIO_PIN_RESET);
	 returnvar = HAL_SPI_Transmit(hspi,pData,Size,Timeout);
	 HAL_GPIO_WritePin(GPIOD,GPIO_PIN_8,GPIO_PIN_SET);
	 return returnvar;

}
开发者ID:shikharshrestha,项目名称:Stanford_TOF,代码行数:8,代码来源:modulation.c


示例16: Flash_Command

void Flash_Command(uint8_t Cmd)
{
	s_FLASH__SELECT();

	HAL_SPI_Transmit(&g_Flash_SpiHandle, &Cmd, 1, 100);

	s_FLASH__DESELECT();
}
开发者ID:TBMT14-PPG2,项目名称:blueoxi-device,代码行数:8,代码来源:flash.c


示例17: glcd_spi_write

void glcd_spi_write(uint8_t c)
{

	GLCD_SELECT();
	//todo: add block write with DMA, use SPI_TIMEOUT_VALUE
	HAL_SPI_Transmit(&hspi1, &c, 1, 10);
	GLCD_SELECT();
}
开发者ID:martinclausen2,项目名称:glcd,代码行数:8,代码来源:STM32F10x.c


示例18: LCD_WR_DATA

//写LCD数据
//data:要写入的值
void LCD_WR_DATA(uint16_t data)
{
 	SPILCD_CS_RESET;  //LCD_CS=0
	SPILCD_RS_SET;	
	
	HAL_SPI_Transmit(&hspi1, (uint8_t*)&data, 2, 20);
	
	SPILCD_CS_SET;  //LCD_CS=1		
}
开发者ID:uestc-maddog,项目名称:cubeMXLCD,代码行数:11,代码来源:lcd.c


示例19: comm_out

void comm_out(unsigned char j) //Command Output Serial Interface
{
 HAL_GPIO_WritePin(SPI1_CS_GPIO_Port, SPI1_CS_Pin, GPIO_PIN_RESET);
 HAL_GPIO_WritePin(SPI1_A0_GPIO_Port, SPI1_A0_Pin, GPIO_PIN_RESET);

 HAL_SPI_Transmit(&hspi1, &j, 1, 200);

 HAL_GPIO_WritePin(SPI1_CS_GPIO_Port, SPI1_CS_Pin, GPIO_PIN_SET);
}
开发者ID:angst7,项目名称:nhd-12832-driver,代码行数:9,代码来源:nhd_c12832.c


示例20: data_out

void data_out(unsigned char i) //Data Output Serial Interface
{
 HAL_GPIO_WritePin(SPI1_CS_GPIO_Port, SPI1_CS_Pin, GPIO_PIN_RESET);
 HAL_GPIO_WritePin(SPI1_A0_GPIO_Port, SPI1_A0_Pin, GPIO_PIN_SET);

 HAL_SPI_Transmit(&hspi1, &i, 1, 200);

 HAL_GPIO_WritePin(SPI1_CS_GPIO_Port, SPI1_CS_Pin, GPIO_PIN_SET);
}
开发者ID:angst7,项目名称:nhd-12832-driver,代码行数:9,代码来源:nhd_c12832.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ HAL_STATUS_SUCCESS函数代码示例发布时间:2022-05-30
下一篇:
C++ HAL_SPI_Init函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap