Hal Drive Library Learning-spi

Source: Internet
Author: User

How to use the SPI Library
1 Declare the SPI Hanlde, for example:SPI_HandleTypeDef hspi
2 initializing the underlying resource by implementing the Hal_spi_mspinit () function
The following two must be initialized
A enable SPI clock
b Configuring the SPI Pins
The following is initialized as needed
C NVIC Interrupt Configuration
D DMA Configuration
3 configuration Hspi, including mode, DATASIZE,BAUDRATE,MSB/LSB,CRC, etc.
4 Call the Hal_spi_init () function, initialize the SPI configuration, and the underlying resource (by calling Hal_spi_mspinit ())

Initializing and configuring functions

  
 
    1. Span class= "pun"? Hal_spi_init ()
    2. Span class= "pun"? Hal_spi_deinit ()
    3. Span class= "pun"? Hal_spi_mspinit ()
    4. Span class= "pun"? Hal_spi_mspdeinit ()
    5. Span class= "pun"? hal_spi_initextended ()

Note:
In the SPI, DataSize can specify the 4-16bit data, in the SPI_DR register, whether it is byte or word, data is always right-aligned, when communicating, only bits in the data word range will be output with the clock
For example, only 0-->5 bits on the left will be output, and only 0-->13 bits on the right will be output

 
   
  
  1. 使用单线模式时,主机的MISO,从机的MOSI都可以作为普通IO使用。


From for notes (Wiz)

Hal Drive Library Learning-spi

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.