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

C++ HAL_SPI_Init函数代码示例

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

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



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

示例1: uart_init

//------------------------------------------------------------------------------
void uart_init(void)
{
  uart1Handle.Instance = USART1;
  uart1Handle.Init.BaudRate = 9600;
  uart1Handle.Init.WordLength = UART_WORDLENGTH_8B;
  uart1Handle.Init.StopBits = UART_STOPBITS_1;
  uart1Handle.Init.Parity = UART_PARITY_NONE;
  uart1Handle.Init.Mode = UART_MODE_TX_RX;
  uart1Handle.Init.HwFlowCtl = UART_HWCONTROL_NONE;
  uart1Handle.Init.OverSampling = UART_OVERSAMPLING_16;
  uart1Handle.Init.OneBitSampling = UART_ONEBIT_SAMPLING_DISABLED ;
  uart1Handle.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
  HAL_UART_Init(&uart1Handle);

  spi1Handle.Instance = SPI1;
  spi1Handle.Init.Mode = SPI_MODE_SLAVE;
  spi1Handle.Init.Direction = SPI_DIRECTION_2LINES;
  spi1Handle.Init.DataSize = SPI_DATASIZE_8BIT;
  spi1Handle.Init.CLKPolarity = SPI_POLARITY_LOW;
  spi1Handle.Init.CLKPhase = SPI_PHASE_1EDGE;
  spi1Handle.Init.NSS = SPI_NSS_SOFT;
  spi1Handle.Init.FirstBit = SPI_FIRSTBIT_MSB;
  spi1Handle.Init.TIMode = SPI_TIMODE_DISABLED;
  spi1Handle.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLED;
  spi1Handle.Init.CRCPolynomial = 7;
  spi1Handle.Init.CRCLength = SPI_CRC_LENGTH_DATASIZE;
  spi1Handle.Init.NSSPMode = SPI_NSS_PULSE_DISABLED;
  HAL_SPI_Init(&spi1Handle);
  
}
开发者ID:j-a-r-i,项目名称:StmMeasure,代码行数:31,代码来源:main.c


示例2: SPIx_Init

/**
  * @brief SPIx Bus initialization
  * @param None
  * @retval None
  */
static void SPIx_Init(void)
{
  if(HAL_SPI_GetState(&heval_Spi) == HAL_SPI_STATE_RESET)
  {
    /* SPI Config */
    heval_Spi.Instance = EVAL_SPIx;
    /* SPI baudrate is set to 16 MHz (PCLK2/SPI_BaudRatePrescaler = 32/2 = 16 MHz) 
    to verify these constraints:
    HX8347D LCD SPI interface max baudrate is  50MHz for write and 6.66MHz for read
    PCLK1 frequency is set to 32 MHz 
    - SD card SPI interface max baudrate is 25MHz for write/read
    */
    heval_Spi.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_2;
    heval_Spi.Init.Direction = SPI_DIRECTION_2LINES;
    heval_Spi.Init.CLKPhase = SPI_PHASE_2EDGE;
    heval_Spi.Init.CLKPolarity = SPI_POLARITY_HIGH;
    heval_Spi.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
    heval_Spi.Init.CRCPolynomial = 7;
    heval_Spi.Init.DataSize = SPI_DATASIZE_8BIT;
    heval_Spi.Init.FirstBit = SPI_FIRSTBIT_MSB;
    heval_Spi.Init.NSS = SPI_NSS_SOFT;
    heval_Spi.Init.TIMode = SPI_TIMODE_DISABLE;
    heval_Spi.Init.Mode = SPI_MODE_MASTER;
    
    SPIx_MspInit(&heval_Spi);
    HAL_SPI_Init(&heval_Spi);
  }
}
开发者ID:S4mw1s3,项目名称:Nucleo32,代码行数:33,代码来源:stm32l073z_eval.c


示例3: MX_SPI3_Init

/* SPI3 init function */
static void MX_SPI3_Init(void)
{

    // The Fpclk is at 36MHz

  hspi3.Instance = SPI3;
  hspi3.Init.Mode = SPI_MODE_MASTER;
  hspi3.Init.Direction = SPI_DIRECTION_1LINE;
  hspi3.Init.DataSize = SPI_DATASIZE_8BIT;
  hspi3.Init.CLKPolarity = SPI_POLARITY_HIGH;
  hspi3.Init.CLKPhase = SPI_PHASE_2EDGE;
  hspi3.Init.NSS = SPI_NSS_HARD_OUTPUT;

  // 36MHz/2 = 18MHz
  // 36MHz/4 = 9MHz
  // 36MHz/8 = 4.5MHz
  // 36MHz/16 = 2.25MHz
  // 36MHz/32 = 1.125MHz
  // 36MHz/64 = 562.5KHz
  // 36MHz/128 = 281.25KHz
  // 36MHz/256 = 140.625KHz

  hspi3.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_64;
  hspi3.Init.FirstBit = SPI_FIRSTBIT_MSB;
  hspi3.Init.TIMode = SPI_TIMODE_DISABLE;
  hspi3.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
  hspi3.Init.CRCPolynomial = 10;
  if (HAL_SPI_Init(&hspi3) != HAL_OK)
  {
    Error_Handler();
  }

}
开发者ID:PaxInstruments,项目名称:PaxInstruments-LabWiz-firmware,代码行数:34,代码来源:labwiz_entry.c


示例4: SPIx_Init

/**
  * @brief  SPIx Bus initialization
  */
static void SPIx_Init(void)
{
  if(HAL_SPI_GetState(&SpiHandle) == HAL_SPI_STATE_RESET)
  {
    /* SPI configuration -----------------------------------------------------*/
    SpiHandle.Instance = DISCOVERY_SPIx;
    /* SPI baudrate is set to 5.6 MHz (PCLK2/SPI_BaudRatePrescaler = 90/16 = 5.625 MHz) 
       to verify these constraints:
       - ILI9341 LCD SPI interface max baudrate is 10MHz for write and 6.66MHz for read
       - l3gd20 SPI interface max baudrate is 10MHz for write/read
       - PCLK2 frequency is set to 90 MHz 
    */  
    SpiHandle.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_16;

    /* On STM32F429I-Discovery, LCD ID cannot be read then keep a common configuration */
    /* for LCD and GYRO (SPI_DIRECTION_2LINES) */
    /* Note: To read a register a LCD, SPI_DIRECTION_1LINE should be set */
    SpiHandle.Init.Direction      = SPI_DIRECTION_2LINES;
    SpiHandle.Init.CLKPhase       = SPI_PHASE_1EDGE;
    SpiHandle.Init.CLKPolarity    = SPI_POLARITY_LOW;
    SpiHandle.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLED;
    SpiHandle.Init.CRCPolynomial  = 7;
    SpiHandle.Init.DataSize       = SPI_DATASIZE_8BIT;
    SpiHandle.Init.FirstBit       = SPI_FIRSTBIT_MSB;
    SpiHandle.Init.NSS            = SPI_NSS_SOFT;
    SpiHandle.Init.TIMode         = SPI_TIMODE_DISABLED;
    SpiHandle.Init.Mode           = SPI_MODE_MASTER;
  
    SPIx_MspInit(&SpiHandle);
    HAL_SPI_Init(&SpiHandle);
  } 
}
开发者ID:bresch,项目名称:STM32F29Discovery_Hello_World_SW4_IDE,代码行数:35,代码来源:stm32f429i_discovery.c


示例5: SharpLcd_Init

/**
 * Initialize Sharp LCD
 * @param void No arguments
 * @return void No return
 */
void SharpLcd_Init(void)
{
	// Local variables
	GPIO_InitTypeDef GPIO_InitStruct;

	// Init GPIO
	__GPIOA_CLK_ENABLE();
	__GPIOC_CLK_ENABLE();
	__GPIOD_CLK_ENABLE();

	// Control Pins
	GPIO_InitStruct.Pin = s_SHARPLCD__SCS;
	GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
	GPIO_InitStruct.Pull = GPIO_PULLDOWN;
	GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
	HAL_GPIO_Init(s_SHARPLCD__SCS_PORT, &GPIO_InitStruct);

	GPIO_InitStruct.Pin = s_SHARPLCD__DISP;
	GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
	GPIO_InitStruct.Pull = GPIO_PULLDOWN;
	GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
	HAL_GPIO_Init(s_SHARPLCD__DISP_PORT, &GPIO_InitStruct);

	GPIO_InitStruct.Pin = s_SHARPLCD__EXTCOMIN;
	GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
	GPIO_InitStruct.Pull = GPIO_PULLDOWN;
	GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
	HAL_GPIO_Init(s_SHARPLCD__VCOM_PORT, &GPIO_InitStruct);

	// SPI Pins
	GPIO_InitStruct.Pin = s_SHARPLCD__SCLK | s_SHARPLCD__SI;
	GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
	GPIO_InitStruct.Pull = GPIO_NOPULL;
	GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
	GPIO_InitStruct.Alternate = GPIO_AF6_SPI3;
	HAL_GPIO_Init(s_SHARPLCD__SPI_PORT, &GPIO_InitStruct);

	// Set initial state of GPIO
	s_SHARPLCD__DISP_RESET();
	s_SHARPLCD__SCS_RESET();
	s_SHARPLCD__EXTCOMIN_RESET();

	// Init SPI
	__SPI3_CLK_ENABLE();

	g_SharpLcd_SpiHandle.Instance = SPI3;
	g_SharpLcd_SpiHandle.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_32;
	g_SharpLcd_SpiHandle.Init.Mode = SPI_MODE_MASTER;
	g_SharpLcd_SpiHandle.Init.Direction = SPI_DIRECTION_2LINES;
	g_SharpLcd_SpiHandle.Init.DataSize = SPI_DATASIZE_8BIT;
	g_SharpLcd_SpiHandle.Init.CLKPolarity = SPI_POLARITY_LOW;
	g_SharpLcd_SpiHandle.Init.CLKPhase = SPI_PHASE_1EDGE;
	g_SharpLcd_SpiHandle.Init.NSS = SPI_NSS_SOFT;
	g_SharpLcd_SpiHandle.Init.FirstBit = SPI_FIRSTBIT_LSB;
	g_SharpLcd_SpiHandle.Init.TIMode = SPI_TIMODE_DISABLED;
	g_SharpLcd_SpiHandle.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLED;
	g_SharpLcd_SpiHandle.Init.CRCPolynomial = 10;
	HAL_SPI_Init(&g_SharpLcd_SpiHandle);

}
开发者ID:TBMT14-PPG2,项目名称:blueoxi-device,代码行数:65,代码来源:sharp.c


示例6: MX_SPI1_Init

/**
  * @brief SPI1 Initialization Function
  * @param None
  * @retval None
  */
static void MX_SPI1_Init(void)
{

  /* USER CODE BEGIN SPI1_Init 0 */

  /* USER CODE END SPI1_Init 0 */

  /* USER CODE BEGIN SPI1_Init 1 */

  /* USER CODE END SPI1_Init 1 */
  /* SPI1 parameter configuration*/
  hspi1.Instance = SPI1;
  hspi1.Init.Mode = SPI_MODE_MASTER;
  hspi1.Init.Direction = SPI_DIRECTION_2LINES;
  hspi1.Init.DataSize = SPI_DATASIZE_8BIT;
  hspi1.Init.CLKPolarity = SPI_POLARITY_LOW;
  hspi1.Init.CLKPhase = SPI_PHASE_1EDGE;
  hspi1.Init.NSS = SPI_NSS_SOFT;
  hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_8;
  hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB;
  hspi1.Init.TIMode = SPI_TIMODE_DISABLE;
  hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
  hspi1.Init.CRCPolynomial = 10;
  if (HAL_SPI_Init(&hspi1) != HAL_OK)
  {
    Error_Handler();
  }
  /* USER CODE BEGIN SPI1_Init 2 */

  /* USER CODE END SPI1_Init 2 */

}
开发者ID:heyuanjie87,项目名称:rt-thread,代码行数:37,代码来源:main.c


示例7: MPU9250_SetSpeed

/*====================================================================================================*/
static void MPU9250_SetSpeed( uint8_t SpeedSel )
{
  __HAL_SPI_DISABLE(&SPI_HandleStruct);
  SPI_HandleStruct.Init.BaudRatePrescaler = SpeedSel;
  HAL_SPI_Init(&SPI_HandleStruct);
  __HAL_SPI_ENABLE(&SPI_HandleStruct);
}
开发者ID:zxbing2005,项目名称:RedBeanSprout,代码行数:8,代码来源:module_mpu9250.c


示例8: SPIx_Init

/**
  * @brief  Initializes SPI HAL.
  * @retval None
  */
static void SPIx_Init(void)
{
  if(HAL_SPI_GetState(&hnucleo_Spi) == HAL_SPI_STATE_RESET)
  {
    /* SPI Config */
    hnucleo_Spi.Instance = NUCLEO_SPIx;
      /* SPI baudrate is set to 8 MHz maximum (PCLK2/SPI_BaudRatePrescaler = 64/8 = 8 MHz) 
       to verify these constraints:
          - ST7735 LCD SPI interface max baudrate is 15MHz for write and 6.66MHz for read
            Since the provided driver doesn't use read capability from LCD, only constraint 
            on write baudrate is considered.
          - SD card SPI interface max baudrate is 25MHz for write/read
          - PCLK2 max frequency is 32 MHz 
       */
    hnucleo_Spi.Init.BaudRatePrescaler  = SPI_BAUDRATEPRESCALER_8;
    hnucleo_Spi.Init.Direction          = SPI_DIRECTION_2LINES;
    hnucleo_Spi.Init.CLKPhase           = SPI_PHASE_1EDGE;
    hnucleo_Spi.Init.CLKPolarity        = SPI_POLARITY_LOW;
    hnucleo_Spi.Init.CRCCalculation     = SPI_CRCCALCULATION_DISABLE;
    hnucleo_Spi.Init.CRCPolynomial      = 7;
    hnucleo_Spi.Init.DataSize           = SPI_DATASIZE_8BIT;
    hnucleo_Spi.Init.FirstBit           = SPI_FIRSTBIT_MSB;
    hnucleo_Spi.Init.NSS                = SPI_NSS_SOFT;
    hnucleo_Spi.Init.TIMode             = SPI_TIMODE_DISABLE;
    hnucleo_Spi.Init.Mode               = SPI_MODE_MASTER;
    
    SPIx_MspInit();
    HAL_SPI_Init(&hnucleo_Spi);
  }
}
开发者ID:cnoviello,项目名称:stm32-nucleof1,代码行数:34,代码来源:stm32f1xx_nucleo.c


示例9: SPIx_Init

/**
  * @brief SPIx Bus initialization
  * @param None
  * @retval None
  */
static void SPIx_Init(void)
{
  if(HAL_SPI_GetState(&SpiHandle) == HAL_SPI_STATE_RESET)
  {
    /* SPI Config */
    SpiHandle.Instance = DISCOVERY_SPIx;
    /* SPI baudrate is set to 5.6 MHz (PCLK2/SPI_BaudRatePrescaler = 90/16 = 5.625 MHz)
      to verify these constraints:
      ILI9341 LCD SPI interface max baudrate is 10MHz for write and 6.66MHz for read
      l3gd20 SPI interface max baudrate is 10MHz for write/read
      PCLK2 frequency is set to 90 MHz
  */
    SpiHandle.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_16;
    SpiHandle.Init.Direction = SPI_DIRECTION_2LINES;
    SpiHandle.Init.CLKPhase = SPI_PHASE_1EDGE;
    SpiHandle.Init.CLKPolarity = SPI_POLARITY_LOW;
    SpiHandle.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLED;
    SpiHandle.Init.CRCPolynomial = 7;
    SpiHandle.Init.DataSize = SPI_DATASIZE_8BIT;
    SpiHandle.Init.FirstBit = SPI_FIRSTBIT_MSB;
    SpiHandle.Init.NSS = SPI_NSS_SOFT;
    SpiHandle.Init.TIMode = SPI_TIMODE_DISABLED;
    SpiHandle.Init.Mode = SPI_MODE_MASTER;

    SPIx_MspInit(&SpiHandle);
    HAL_SPI_Init(&SpiHandle);
  }
}
开发者ID:afconsult-south,项目名称:dragonfly-fcb,代码行数:33,代码来源:stm32f3_discovery.c


示例10: SpiInit

void SpiInit( Spi_t *obj, PinNames mosi, PinNames miso, PinNames sclk, PinNames nss )
{
    __HAL_RCC_SPI1_FORCE_RESET( );
    __HAL_RCC_SPI1_RELEASE_RESET( );

    __HAL_RCC_SPI1_CLK_ENABLE( );

    obj->Spi.Instance = ( SPI_TypeDef *) SPI1_BASE;

    GpioInit( &obj->Mosi, mosi, PIN_ALTERNATE_FCT, PIN_PUSH_PULL, PIN_PULL_DOWN, GPIO_AF5_SPI1 );
    GpioInit( &obj->Miso, miso, PIN_ALTERNATE_FCT, PIN_PUSH_PULL, PIN_PULL_DOWN, GPIO_AF5_SPI1 );
    GpioInit( &obj->Sclk, sclk, PIN_ALTERNATE_FCT, PIN_PUSH_PULL, PIN_PULL_DOWN, GPIO_AF5_SPI1 );

    if( nss != NC )
    {
        GpioInit( &obj->Nss, nss, PIN_ALTERNATE_FCT, PIN_PUSH_PULL, PIN_PULL_UP, GPIO_AF5_SPI1 );
    }
    else
    {
        obj->Spi.Init.NSS = SPI_NSS_SOFT;
    }

    if( nss == NC )
    {
        SpiFormat( obj, SPI_DATASIZE_8BIT, SPI_POLARITY_LOW, SPI_PHASE_1EDGE, 0 );
    }
    else
    {
        SpiFormat( obj, SPI_DATASIZE_8BIT, SPI_POLARITY_LOW, SPI_PHASE_1EDGE, 1 );
    }
    SpiFrequency( obj, 10000000 );

    HAL_SPI_Init( &obj->Spi );
}
开发者ID:ARMmbed,项目名称:LoRaMac-node,代码行数:34,代码来源:spi-board.c


示例11: MPU9250_SetSpeed

/*====================================================================================================*/
void MPU9250_SetSpeed( uint8_t speedSel )
{
  __HAL_SPI_DISABLE(&MPUPx_InitStruct);
  MPUPx_InitStruct.Init.BaudRatePrescaler = speedSel;
  HAL_SPI_Init(&MPUPx_InitStruct);
  __HAL_SPI_ENABLE(&MPUPx_InitStruct);
}
开发者ID:KitSprout,项目名称:RedBeanSprout,代码行数:8,代码来源:module_mpu9250.c


示例12: _bus

Spi::Spi(Bus bus, const Config& config)
        : _bus(bus), _txCallback(0), _rxCallback(0), _txrxCallback(0), _txArgs(0),
          _rxArgs(0), _txrxArgs(0) {
    bzero(&_spi, sizeof(_spi));
    _spi.Instance = _busMap[bus];
    _spi.Init.Mode = config.mode == Master ? SPI_MODE_MASTER : SPI_MODE_SLAVE;
    _spi.Init.Direction = _dirMap[config.dir];
    _spi.Init.DataSize = config.size == S8 ? SPI_DATASIZE_8BIT : SPI_DATASIZE_16BIT;
    _spi.Init.CLKPolarity = config.polarity == LOW ? SPI_POLARITY_LOW : SPI_POLARITY_HIGH;
    _spi.Init.CLKPhase = config.phase == Rising ? SPI_PHASE_1EDGE : SPI_PHASE_2EDGE;
    _spi.Init.NSS = config.ss == SOFTWARE ? SPI_NSS_SOFT
            : (config.ss == HARD_OUTPUT ? SPI_NSS_HARD_OUTPUT : SPI_NSS_HARD_INPUT);
    _spi.Init.BaudRatePrescaler = clkdivs[config.div];
    _spi.Init.FirstBit = config.order == MSB_FIRST ? SPI_FIRSTBIT_MSB : SPI_FIRSTBIT_LSB;
    _spi.Init.TIMode = SPI_TIMODE_DISABLE;
    _spi.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
    _spi.Init.CRCPolynomial = 10;
    HAL_SPI_Init(&_spi);

    // Enable interrupts to allow async transmit/receive
    HAL_NVIC_SetPriority(irqMap[bus], 15 /* low preempt priority */, 0 /* high sub-priority*/);
    HAL_NVIC_EnableIRQ(irqMap[bus]);

    // Keep track of Spi instance
    spiMap[bus] = this;
}
开发者ID:jaggies,项目名称:matchbox,代码行数:26,代码来源:spi.cpp


示例13: SPI1_Init

/*********************************************************************
 * @fn		 SPI1_Init
 *
 * @brief 	 SPIx Bus initialization
 *
 * @param 	None
 *
 * @return	void
 */
void SPI1_Init(void)
{
  SX1276.Spi.Spi = ( SPI_TypeDef* )SPI1_BASE;

  if(HAL_SPI_GetState(&SpiHandle) == HAL_SPI_STATE_RESET)
  {
    /* SPI Config */
    SpiHandle.Instance = SPIx;

    /* On STM32L0538-DISCO, EPD ID cannot be read then keep a common configuration */
    /* for EPD (SPI_DIRECTION_2LINES) */
    /* Note: To read a register a EPD, SPI_DIRECTION_1LINE should be set */
    SpiHandle.Init.Mode               = SPI_MODE_MASTER;
    SpiHandle.Init.Direction          = SPI_DIRECTION_2LINES;
    SpiHandle.Init.BaudRatePrescaler  = SPI_BAUDRATEPRESCALER_8;
    SpiHandle.Init.DataSize           = SPI_DATASIZE_8BIT;
    SpiHandle.Init.CLKPhase           = SPI_PHASE_1EDGE;//SPI_PHASE_2EDGE;
    SpiHandle.Init.CLKPolarity        = SPI_POLARITY_LOW;//SPI_POLARITY_HIGH;SPI_POLARITY_LOW
    SpiHandle.Init.FirstBit           = SPI_FIRSTBIT_MSB;
    SpiHandle.Init.NSS                = SPI_NSS_SOFT;
    SpiHandle.Init.CRCCalculation     = SPI_CRCCALCULATION_DISABLED;
    SpiHandle.Init.CRCPolynomial      = 7;
    SpiHandle.Init.TIMode             = SPI_TIMODE_DISABLED;

    SPI1_MspInit(&SpiHandle);
    HAL_SPI_Init(&SpiHandle);
  }
}
开发者ID:Aline1029,项目名称:NPLink-Mote-STM32-SDK,代码行数:37,代码来源:spi_board.c


示例14: init_spi6

//SPI6 peripheral initialization. SPI6 is available on the Expansion connector
void init_spi6(void)
{

	//Configure SPI6 in Mode 0, Master
	//CPOL = 0 --> clock is low when idle
	//CPHA = 0 --> data is sampled at the first edge

	spi6_handle.Instance = SPI6;
	spi6_handle.Init.Direction = SPI_DIRECTION_2LINES; 				// Full duplex
	spi6_handle.Init.Mode = SPI_MODE_MASTER;     					// Master
	spi6_handle.Init.DataSize = SPI_DATASIZE_8BIT; 					// 8bits words
	spi6_handle.Init.CLKPolarity = SPI_POLARITY_LOW;        		// clock is low when idle (CPOL = 0)
	spi6_handle.Init.CLKPhase = SPI_PHASE_1EDGE;      				// data sampled at first (rising) edge (CPHA = 0)
	spi6_handle.Init.NSS = SPI_NSS_HARD_OUTPUT; 					// uses hardware slave select
	spi6_handle.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_4; 	// SPI frequency is APB2 frequency / 4	****ToDo Adjust!
	spi6_handle.Init.FirstBit = SPI_FIRSTBIT_MSB;					// data is transmitted MSB first
	spi6_handle.Init.TIMode = SPI_TIMODE_DISABLED;					//
	spi6_handle.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLED;
	spi6_handle.Init.CRCPolynomial = 7;

	if(HAL_SPI_Init(&spi6_handle) != HAL_OK)
	{
		flexsea_error(SE_INIT_SPI);
	}
}
开发者ID:haosu-robotics,项目名称:FlexSEA,代码行数:26,代码来源:fm_spi.c


示例15: IMU_Config

/**
 *  @brief  IMU_Config
 */
void IMU_Config( void )
{
  hImu.pTxBuf = IMU_TX_BUFFER;
  hImu.pRxBuf = IMU_RX_BUFFER;

#if defined(__MPU9250_H)
  MPU92_Config();
#endif

#if defined(__LPS22HB_H)
  LPS22_Config();
#endif

  /* SPI Init ****************************************************************/
  hImu.handle->Instance               = IMU_SPIx;
  hImu.handle->Init.Mode              = SPI_MODE_MASTER;
  hImu.handle->Init.Direction         = SPI_DIRECTION_2LINES;
  hImu.handle->Init.DataSize          = SPI_DATASIZE_8BIT;
  hImu.handle->Init.CLKPolarity       = SPI_POLARITY_HIGH;
  hImu.handle->Init.CLKPhase          = SPI_PHASE_2EDGE;
  hImu.handle->Init.NSS               = SPI_NSS_SOFT;
  hImu.handle->Init.BaudRatePrescaler = IMU_SPIx_SPEED_LOW;
  hImu.handle->Init.FirstBit          = SPI_FIRSTBIT_MSB;
  hImu.handle->Init.TIMode            = SPI_TIMODE_DISABLE;
  hImu.handle->Init.CRCCalculation    = SPI_CRCCALCULATION_ENABLE;
  hImu.handle->Init.CRCPolynomial     = 7;
  HAL_SPI_Init(hImu.handle);

  __HAL_SPI_ENABLE(hImu.handle);
}
开发者ID:Hom-Wang,项目名称:SmartIMU,代码行数:33,代码来源:imu.c


示例16: IMU_SetSpeed

/*====================================================================================================*/
void IMU_SetSpeed( uint8_t speedSel )
{
  __HAL_SPI_DISABLE(&IMU_HandleStruct);
  IMU_HandleStruct.Init.BaudRatePrescaler = speedSel;
  HAL_SPI_Init(&IMU_HandleStruct);
  __HAL_SPI_ENABLE(&IMU_HandleStruct);
}
开发者ID:SUCHUANZHEN,项目名称:SU_SmartIMU,代码行数:8,代码来源:module_imu.c


示例17: LIS3DSH_init

/**
 * @brief  Configures LIS3DSH
 * @param  InitTypeDef: Specifies the configuration.
 * @retval None
 */
void LIS3DSH_init(LIS3DSH_InitTypeDef li) {

	GPIO_InitTypeDef GPIO_InitStructure;

	/* Configure the LIS3DSH Control pins --------------------------------*/
	/* Enable CS GPIO clock and configure GPIO pin for LIS3DSH Chip select */
	LIS3DSH_SPI_CS_GPIO_CLK_ENABLE();

	/* Configure GPIO PIN for LIS Chip select */
	GPIO_InitStructure.Pin = LIS3DSH_SPI_CS_PIN;
	GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
	GPIO_InitStructure.Pull = GPIO_NOPULL;
	GPIO_InitStructure.Speed = GPIO_SPEED_MEDIUM;
	HAL_GPIO_Init(LIS3DSH_SPI_CS_GPIO_PORT, &GPIO_InitStructure);

	/* Deselect: Chip Select high */
	/* SPI start when the chip select is low */
	LIS3DSH_CS_HIGH();

	/* Configure the SPI1 to communicate with the accelerometer */
	if (HAL_SPI_GetState(&SpiHandle) == HAL_SPI_STATE_RESET)
	{
		/* SPI configuration -----------------------------------------------------*/
		SpiHandle.Instance = LIS3DSH_SPI;
		SpiHandle.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_16;
		SpiHandle.Init.Direction = SPI_DIRECTION_2LINES;
		SpiHandle.Init.CLKPhase = SPI_PHASE_1EDGE;
		SpiHandle.Init.CLKPolarity = SPI_POLARITY_LOW;
		SpiHandle.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLED;
		SpiHandle.Init.CRCPolynomial = 7;
		SpiHandle.Init.DataSize = SPI_DATASIZE_8BIT;
		SpiHandle.Init.FirstBit = SPI_FIRSTBIT_MSB;
		SpiHandle.Init.NSS = SPI_NSS_SOFT;
		SpiHandle.Init.TIMode = SPI_TIMODE_DISABLED;
		SpiHandle.Init.Mode = SPI_MODE_MASTER;

		/* SPI low level configuration */
		/* Enable the SPI peripheral */
		LIS3DSH_SPI_CLK_ENABLE();

		/* Enable SCK, MOSI and MISO GPIO clocks */
		LIS3DSH_SPI_GPIO_CLK_ENABLE();

		/* SPI SCK, MOSI, MISO pin configuration */
		GPIO_InitStructure.Pin = (LIS3DSH_SPI_SCK_PIN | LIS3DSH_SPI_MISO_PIN
				| LIS3DSH_SPI_MOSI_PIN);
		GPIO_InitStructure.Mode = GPIO_MODE_AF_PP;
		GPIO_InitStructure.Pull = GPIO_PULLDOWN;
		GPIO_InitStructure.Speed = GPIO_SPEED_FAST;
		GPIO_InitStructure.Alternate = LIS3DSH_SPI_AF;
		HAL_GPIO_Init(LIS3DSH_SPI_GPIO_PORT, &GPIO_InitStructure);

		HAL_SPI_Init(&SpiHandle);
	}

	/* Configures the inner register of the accelerometer */
	LIS3DSH_writeRegister(LIS3DSH_CTRL_REG4_ADDR, li.OutputDataRate | li.Axes_Enable | li.BlockDataUpdate);
	LIS3DSH_writeRegister(LIS3DSH_CTRL_REG5_ADDR, li.FullScale);
}
开发者ID:giovadifiore,项目名称:iot-home-automation,代码行数:64,代码来源:stm32f4xx_helper_lis3dsh.c


示例18: spiInit

void spiInit(void)
{
    SIGNAL_TIMER_CHANNEL_GPIO_PORT();
    SPI_CLK_ENABLE();

    GPIO_InitTypeDef spiGpioInit = { 0 };

    // SPI has GPIOB 3..5
    spiGpioInit.Pin  = GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_5;
    spiGpioInit.Mode = GPIO_MODE_AF_PP;
    spiGpioInit.Pull = GPIO_NOPULL;
    HAL_GPIO_Init(SPI_GPIO_PORT, &spiGpioInit);

    // Initialize SPI1 module
    g_spiInit.Instance = SPI;
    g_spiInit.Init.BaudRatePrescaler   = SPI_BAUDRATEPRESCALER_8;
    g_spiInit.Init.CLKPhase            = SPI_PHASE_1EDGE;
    g_spiInit.Init.CLKPolarity         = SPI_POLARITY_LOW;
    g_spiInit.Init.CRCCalculation      = SPI_CRCCALCULATION_DISABLE;
    g_spiInit.Init.DataSize            = SPI_DATASIZE_8BIT;
    g_spiInit.Init.FirstBit            = SPI_FIRSTBIT_MSB;
    g_spiInit.Init.Mode                = SPI_MODE_MASTER;
    g_spiInit.Init.NSS                 = SPI_NSS_SOFT;
    g_spiInit.Init.TIMode              = SPI_TIMODE_DISABLE;
    if (HAL_SPI_Init(&g_spiInit) != HAL_OK)
    {
        ERROR_SPI(ED_SPI_FAILED_TO_INITIALIZE_SPI);
    }

    // Initialize DMA for SPI1
    g_dmaSpiRx.Instance                 = SPI_DMA_RX_INSTANCE;
    g_dmaSpiRx.Init.Request             = DMA_REQUEST_1;
    g_dmaSpiRx.Init.Direction           = DMA_PERIPH_TO_MEMORY;
    g_dmaSpiRx.Init.PeriphInc           = DMA_PINC_DISABLE;
    g_dmaSpiRx.Init.MemInc              = DMA_MINC_ENABLE;
    g_dmaSpiRx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
    g_dmaSpiRx.Init.MemDataAlignment    = DMA_MDATAALIGN_BYTE;
    g_dmaSpiRx.Init.Mode                = DMA_NORMAL;
    g_dmaSpiRx.Init.Priority            = DMA_PRIORITY_MEDIUM;
    if (HAL_DMA_Init(&g_dmaSpiRx) != HAL_OK)
    {
        ERROR_SPI(ED_SPI_FAILED_TO_INITIALIZE_SPI);
    }

    g_dmaSpiTx.Instance                 = SPI_DMA_TX_INSTANCE;
    g_dmaSpiTx.Init.Request             = DMA_REQUEST_1;
    g_dmaSpiTx.Init.Direction           = DMA_MEMORY_TO_PERIPH;
    g_dmaSpiTx.Init.PeriphInc           = DMA_PINC_DISABLE;
    g_dmaSpiTx.Init.MemInc              = DMA_MINC_ENABLE;
    g_dmaSpiTx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
    g_dmaSpiTx.Init.MemDataAlignment    = DMA_MDATAALIGN_BYTE;
    g_dmaSpiTx.Init.Mode                = DMA_NORMAL;
    g_dmaSpiTx.Init.Priority            = DMA_PRIORITY_MEDIUM;
    if (HAL_DMA_Init(&g_dmaSpiTx) != HAL_OK)
    {
        ERROR_SPI(ED_SPI_FAILED_TO_INITIALIZE_SPI);
    }
}
开发者ID:far-far-away-science,项目名称:hab-v2,代码行数:58,代码来源:spi.c


示例19: SPI2_InitForFpgaConfig

/**
 * @brief   Initializes the SPI2 for use with FPGA config
 * @param   None
 * @retval  None
 */
ErrorStatus SPI2_InitForFpgaConfig()
{
  /* Init SPI */
  SPI_Handle.Init.FirstBit = SPI_FIRSTBIT_LSB;
  SPI_CLK_ENABLE();
  HAL_SPI_Init(&SPI_Handle);

  return SUCCESS;
}
开发者ID:hampussandberg,项目名称:HexConnect,代码行数:14,代码来源:spi2.c


示例20: HAL_SPI_RxCpltCallback

//------------------------------------------------------------------------------------------------------------------------------------------------------
void HAL_SPI_RxCpltCallback(SPI_HandleTypeDef* handleSPI)
{
    if (!Panel_ProcessingCommandFromPIC(dataSPIfromPanel))
    {
        HAL_SPI_DeInit(handleSPI);
        HAL_SPI_Init(handleSPI);
    }

    SPI1->DR = Panel_NextData();
}
开发者ID:Sasha7b9,项目名称:Osci,代码行数:11,代码来源:Panel.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ HAL_SPI_Transmit函数代码示例发布时间:2022-05-30
下一篇:
C++ HAL_RTC_SetDate函数代码示例发布时间: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