亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? stm32l1xx_spi.c

?? STM32+Grlib
?? C
?? 第 1 頁 / 共 3 頁
字號:
/**
  ******************************************************************************
  * @file    stm32l1xx_spi.c
  * @author  MCD Application Team
  * @version V1.0.0
  * @date    31-December-2010
  * @brief   This file provides firmware functions to manage the following 
  *          functionalities of the Serial peripheral interface (SPI):           
  *           - Initialization and Configuration
  *           - Data transfers functions
  *           - Hardware CRC Calculation
  *           - DMA transfers management
  *           - Interrupts and flags management 
  *           
  *  @verbatim
  *          
  *          The I2S feature is not implemented in STM32L1xx Ultra Low Power
  *          Medium-density devices and will be supported in future products.
  *                    
  *          ===================================================================
  *                                 How to use this driver
  *          ===================================================================
  *          1. Enable peripheral clock using RCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI1, ENABLE)
  *             function for SPI1 or using RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI2, ENABLE)
  *             function for SPI2.
  *
  *          2. Enable SCK, MOSI, MISO and NSS GPIO clocks using RCC_AHBPeriphClockCmd()
  *             function. 
  *
  *          3. Peripherals alternate function: 
  *                 - Connect the pin to the desired peripherals' Alternate 
  *                   Function (AF) using GPIO_PinAFConfig() function
  *                 - Configure the desired pin in alternate function by:
  *                   GPIO_InitStruct->GPIO_Mode = GPIO_Mode_AF
  *                 - Select the type, pull-up/pull-down and output speed via 
  *                   GPIO_PuPd, GPIO_OType and GPIO_Speed members
  *                 - Call GPIO_Init() function
  *        
  *          4. Program the Polarity, Phase, First Data, Baud Rate Prescaler, Slave 
  *             Management, Peripheral Mode and CRC Polynomial values using the SPI_Init()
  *             function.
  *
  *          5. Enable the NVIC and the corresponding interrupt using the function 
  *             SPI_ITConfig() if you need to use interrupt mode. 
  *
  *          6. When using the DMA mode 
  *                   - Configure the DMA using DMA_Init() function
  *                   - Active the needed channel Request using SPI_I2S_DMACmd() function
  * 
  *          7. Enable the SPI using the SPI_Cmd() function.
  * 
  *          8. Enable the DMA using the DMA_Cmd() function when using DMA mode. 
  *
  *          9. Optionally you can enable/configure the following parameters without
  *             re-initialization (i.e there is no need to call again SPI_Init() function):
  *              - When bidirectional mode (SPI_Direction_1Line_Rx or SPI_Direction_1Line_Tx)
  *                is programmed as Data direction parameter using the SPI_Init() function
  *                it can be possible to switch between SPI_Direction_Tx or SPI_Direction_Rx
  *                using the SPI_BiDirectionalLineConfig() function.
  *              - When SPI_NSS_Soft is selected as Slave Select Management parameter 
  *                using the SPI_Init() function it can be possible to manage the 
  *                NSS internal signal using the SPI_NSSInternalSoftwareConfig() function.
  *              -  Reconfigure the data size using the SPI_DataSizeConfig() function  
  *              -  Enable or disable the SS output using the SPI_SSOutputCmd() function  
  *          
  *          10. To use the CRC Hardware calculation feature refer to the Peripheral 
  *              CRC hardware Calculation subsection.
  *
  *  @endverbatim  
  *                                  
  ******************************************************************************
  * @attention
  *
  * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
  * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
  * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
  * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
  * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
  * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
  *
  * <h2><center>&copy; COPYRIGHT 2010 STMicroelectronics</center></h2>
  ******************************************************************************  
  */ 

/* Includes ------------------------------------------------------------------*/
#include "stm32l1xx_spi.h"
#include "stm32l1xx_rcc.h"

/** @addtogroup STM32L1xx_StdPeriph_Driver
  * @{
  */

/** @defgroup SPI 
  * @brief SPI driver modules
  * @{
  */ 

/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* SPI registers Masks */
#define CR1_CLEAR_MASK       ((uint16_t)0x3040)

/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/

/** @defgroup SPI_Private_Functions
  * @{
  */

/** @defgroup SPI_Group1 Initialization and Configuration functions
 *  @brief   Initialization and Configuration functions 
 *
@verbatim   
 ===============================================================================
                  Initialization and Configuration functions
 ===============================================================================  

  This section provides a set of functions allowing to initialize the SPI Direction,
  SPI Mode, SPI Data Size, SPI Polarity, SPI Phase, SPI NSS Management, SPI Baud
  Rate Prescaler, SPI First Bit and SPI CRC Polynomial.
  
  The SPI_Init() function follows the SPI configuration procedures for Master mode
  and Slave mode (details for these procedures are available in reference manual
  (RM0038)).
  
@endverbatim
  * @{
  */

/**
  * @brief  Deinitializes the SPIx peripheral registers to their default
  *         reset values.
  * @param  SPIx: where x can be 1 or 2 to select the SPI peripheral.
  * @retval None
  */
void SPI_I2S_DeInit(SPI_TypeDef* SPIx)
{
  /* Check the parameters */
  assert_param(IS_SPI_ALL_PERIPH(SPIx));

  if (SPIx == SPI1)
  {
    /* Enable SPI1 reset state */
    RCC_APB2PeriphResetCmd(RCC_APB2Periph_SPI1, ENABLE);
    /* Release SPI1 from reset state */
    RCC_APB2PeriphResetCmd(RCC_APB2Periph_SPI1, DISABLE);
  }
  else
  {
    if (SPIx == SPI2)
    {
      /* Enable SPI2 reset state */
      RCC_APB1PeriphResetCmd(RCC_APB1Periph_SPI2, ENABLE);
      /* Release SPI2 from reset state */
      RCC_APB1PeriphResetCmd(RCC_APB1Periph_SPI2, DISABLE);
    }
  }
}

/**
  * @brief  Initializes the SPIx peripheral according to the specified 
  *   parameters in the SPI_InitStruct.
  * @param  SPIx: where x can be 1 or 2 to select the SPI peripheral.
  * @param  SPI_InitStruct: pointer to a SPI_InitTypeDef structure that
  *   contains the configuration information for the specified SPI peripheral.
  * @retval None
  */
void SPI_Init(SPI_TypeDef* SPIx, SPI_InitTypeDef* SPI_InitStruct)
{
  uint16_t tmpreg = 0;
  
  /* check the parameters */
  assert_param(IS_SPI_ALL_PERIPH(SPIx));
  
  /* Check the SPI parameters */
  assert_param(IS_SPI_DIRECTION_MODE(SPI_InitStruct->SPI_Direction));
  assert_param(IS_SPI_MODE(SPI_InitStruct->SPI_Mode));
  assert_param(IS_SPI_DATASIZE(SPI_InitStruct->SPI_DataSize));
  assert_param(IS_SPI_CPOL(SPI_InitStruct->SPI_CPOL));
  assert_param(IS_SPI_CPHA(SPI_InitStruct->SPI_CPHA));
  assert_param(IS_SPI_NSS(SPI_InitStruct->SPI_NSS));
  assert_param(IS_SPI_BAUDRATE_PRESCALER(SPI_InitStruct->SPI_BaudRatePrescaler));
  assert_param(IS_SPI_FIRST_BIT(SPI_InitStruct->SPI_FirstBit));
  assert_param(IS_SPI_CRC_POLYNOMIAL(SPI_InitStruct->SPI_CRCPolynomial));

/*---------------------------- SPIx CR1 Configuration ------------------------*/
  /* Get the SPIx CR1 value */
  tmpreg = SPIx->CR1;
  /* Clear BIDIMode, BIDIOE, RxONLY, SSM, SSI, LSBFirst, BR, MSTR, CPOL and CPHA bits */
  tmpreg &= CR1_CLEAR_MASK;
  /* Configure SPIx: direction, NSS management, first transmitted bit, BaudRate prescaler
     master/salve mode, CPOL and CPHA */
  /* Set BIDImode, BIDIOE and RxONLY bits according to SPI_Direction value */
  /* Set SSM, SSI and MSTR bits according to SPI_Mode and SPI_NSS values */
  /* Set LSBFirst bit according to SPI_FirstBit value */
  /* Set BR bits according to SPI_BaudRatePrescaler value */
  /* Set CPOL bit according to SPI_CPOL value */
  /* Set CPHA bit according to SPI_CPHA value */
  tmpreg |= (uint16_t)((uint32_t)SPI_InitStruct->SPI_Direction | SPI_InitStruct->SPI_Mode |
                  SPI_InitStruct->SPI_DataSize | SPI_InitStruct->SPI_CPOL |  
                  SPI_InitStruct->SPI_CPHA | SPI_InitStruct->SPI_NSS |  
                  SPI_InitStruct->SPI_BaudRatePrescaler | SPI_InitStruct->SPI_FirstBit);
  /* Write to SPIx CR1 */
  SPIx->CR1 = tmpreg;
  
/*---------------------------- SPIx CRCPOLY Configuration --------------------*/
  /* Write to SPIx CRCPOLY */
  SPIx->CRCPR = SPI_InitStruct->SPI_CRCPolynomial;
}

/**
  * @brief  Fills each SPI_InitStruct member with its default value.
  * @param  SPI_InitStruct : pointer to a SPI_InitTypeDef structure which will be initialized.
  * @retval None
  */
void SPI_StructInit(SPI_InitTypeDef* SPI_InitStruct)
{
/*--------------- Reset SPI init structure parameters values -----------------*/
  /* Initialize the SPI_Direction member */
  SPI_InitStruct->SPI_Direction = SPI_Direction_2Lines_FullDuplex;
  /* initialize the SPI_Mode member */
  SPI_InitStruct->SPI_Mode = SPI_Mode_Slave;
  /* initialize the SPI_DataSize member */
  SPI_InitStruct->SPI_DataSize = SPI_DataSize_8b;
  /* Initialize the SPI_CPOL member */
  SPI_InitStruct->SPI_CPOL = SPI_CPOL_Low;
  /* Initialize the SPI_CPHA member */
  SPI_InitStruct->SPI_CPHA = SPI_CPHA_1Edge;
  /* Initialize the SPI_NSS member */
  SPI_InitStruct->SPI_NSS = SPI_NSS_Hard;
  /* Initialize the SPI_BaudRatePrescaler member */
  SPI_InitStruct->SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_2;
  /* Initialize the SPI_FirstBit member */
  SPI_InitStruct->SPI_FirstBit = SPI_FirstBit_MSB;
  /* Initialize the SPI_CRCPolynomial member */
  SPI_InitStruct->SPI_CRCPolynomial = 7;
}

/**
  * @brief  Enables or disables the specified SPI peripheral.
  * @param  SPIx: where x can be 1 or 2 to select the SPI peripheral.
  * @param  NewState: new state of the SPIx peripheral. 
  *   This parameter can be: ENABLE or DISABLE.
  * @retval None
  */
void SPI_Cmd(SPI_TypeDef* SPIx, FunctionalState NewState)
{
  /* Check the parameters */
  assert_param(IS_SPI_ALL_PERIPH(SPIx));
  assert_param(IS_FUNCTIONAL_STATE(NewState));
  if (NewState != DISABLE)
  {
    /* Enable the selected SPI peripheral */
    SPIx->CR1 |= SPI_CR1_SPE;
  }
  else
  {
    /* Disable the selected SPI peripheral */
    SPIx->CR1 &= (uint16_t)~((uint16_t)SPI_CR1_SPE);
  }
}

/**
  * @brief  Configures the data size for the selected SPI.
  * @param  SPIx: where x can be 1 or 2  to select the SPI peripheral.
  * @param  SPI_DataSize: specifies the SPI data size.
  *   This parameter can be one of the following values:
  *     @arg SPI_DataSize_16b: Set data frame format to 16bit
  *     @arg SPI_DataSize_8b: Set data frame format to 8bit
  * @retval None
  */
void SPI_DataSizeConfig(SPI_TypeDef* SPIx, uint16_t SPI_DataSize)
{
  /* Check the parameters */
  assert_param(IS_SPI_ALL_PERIPH(SPIx));
  assert_param(IS_SPI_DATASIZE(SPI_DataSize));
  /* Clear DFF bit */
  SPIx->CR1 &= (uint16_t)~SPI_DataSize_16b;
  /* Set new DFF bit value */
  SPIx->CR1 |= SPI_DataSize;
}

/**
  * @brief  Selects the data transfer direction in bidirectional mode for the specified SPI.
  * @param  SPIx: where x can be 1 or 2  to select the SPI peripheral.
  * @param  SPI_Direction: specifies the data transfer direction in bidirectional mode. 
  *   This parameter can be one of the following values:
  *     @arg SPI_Direction_Tx: Selects Tx transmission direction
  *     @arg SPI_Direction_Rx: Selects Rx receive direction
  * @retval None
  */
void SPI_BiDirectionalLineConfig(SPI_TypeDef* SPIx, uint16_t SPI_Direction)
{

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久综合九色欧美综合狠狠| 国产亚洲成年网址在线观看| 国产精品资源在线看| 亚洲美女精品一区| 久久青草国产手机看片福利盒子 | 国产成人综合在线| 黄色精品一二区| 亚洲国产aⅴ成人精品无吗| 日韩精品影音先锋| 2021久久国产精品不只是精品| 一区二区三区四区不卡在线 | 色婷婷激情一区二区三区| 国产精品18久久久久久久网站| 在线观看日产精品| 欧美日韩国产美女| 欧美精品第一页| 欧美一激情一区二区三区| 精品捆绑美女sm三区| 欧美国产激情一区二区三区蜜月| 日韩电影网1区2区| 国产精品久久久久久久久图文区| 久久久99精品免费观看不卡| 日韩成人午夜电影| 欧美视频精品在线观看| 欧美一级二级三级蜜桃| 亚洲高清在线精品| 欧美在线视频全部完| 亚洲视频在线一区观看| 亚洲日本在线a| 成人av电影在线| 国产精品亚洲成人| 久久久久久日产精品| 精品亚洲成av人在线观看| 99精品国产99久久久久久白柏| 91美女福利视频| 日韩一区二区在线看| 日韩电影在线观看一区| 91精品婷婷国产综合久久性色 | 欧美性感一类影片在线播放| 亚洲人精品一区| 色综合亚洲欧洲| 日韩视频免费直播| 久久er99热精品一区二区| 99久久久精品| 亚洲精品日韩一| 国产一区二区精品久久99| 在线亚洲+欧美+日本专区| 亚洲va国产天堂va久久en| 国产精品综合在线视频| 国产日产亚洲精品系列| 午夜精品爽啪视频| 成a人片国产精品| 亚洲最新在线观看| 在线综合视频播放| 国产成人99久久亚洲综合精品| 欧美高清www午色夜在线视频| 日本麻豆一区二区三区视频| 精品日韩欧美在线| 白白色 亚洲乱淫| 久久免费视频一区| fc2成人免费人成在线观看播放| 一区二区三区av电影 | 国产精品免费人成网站| 蜜桃一区二区三区在线观看| 在线观看日韩国产| 毛片一区二区三区| 亚洲码国产岛国毛片在线| 制服丝袜在线91| 国产99久久精品| 日韩经典一区二区| 在线观看日韩高清av| 久99久精品视频免费观看| 中文字幕一区二区三区av| 成人久久久精品乱码一区二区三区 | 豆国产96在线|亚洲| 又紧又大又爽精品一区二区| 久久综合久久久久88| 色欧美88888久久久久久影院| 国内精品嫩模私拍在线| 夜夜揉揉日日人人青青一国产精品| 精品久久久久久久久久久久久久久 | 3atv在线一区二区三区| 成人av电影免费在线播放| 美女视频一区二区三区| 亚洲女与黑人做爰| 日本一区二区三区国色天香| 欧美一级一级性生活免费录像| 香蕉影视欧美成人| 国产精品高清亚洲| 久久综合久久99| 精品久久久久久久久久久久久久久久久 | 3d成人h动漫网站入口| 99久久99精品久久久久久| 另类综合日韩欧美亚洲| 亚洲国产精品一区二区久久| 国产精品免费网站在线观看| 精品国产伦一区二区三区观看方式 | 欧美日韩精品一区二区在线播放| 高潮精品一区videoshd| 麻豆精品国产91久久久久久| 亚洲chinese男男1069| 亚洲欧美一区二区三区极速播放| 久久精品人人做人人综合| 日韩视频在线你懂得| 欧美日韩在线一区二区| 另类综合日韩欧美亚洲| 日韩精品欧美成人高清一区二区| 一区二区三区蜜桃| 怡红院av一区二区三区| 亚洲日本成人在线观看| 亚洲视频 欧洲视频| 中文字幕视频一区| 亚洲免费观看高清完整版在线| 中文av字幕一区| 国产精品成人在线观看| 国产精品福利影院| 中文字幕一区二区在线播放| 亚洲欧美在线aaa| 亚洲免费在线视频| 亚洲精品va在线观看| 一区二区三区日韩| 亚洲在线观看免费视频| 久久久久久久久久电影| www久久精品| 国产精品黄色在线观看| 亚洲精品日韩一| 午夜精品福利一区二区三区av| 天堂成人免费av电影一区| 免费成人美女在线观看| 亚洲免费在线观看视频| 亚洲电影第三页| 免费久久99精品国产| 国产乱对白刺激视频不卡| 成人91在线观看| 欧美日韩在线综合| 精品久久久久久综合日本欧美| 久久久不卡网国产精品一区| 亚洲视频一区在线| 午夜精品福利一区二区三区蜜桃| 精品夜夜嗨av一区二区三区| 成人理论电影网| 3atv在线一区二区三区| 国产精品五月天| 亚洲高清不卡在线观看| 国产黑丝在线一区二区三区| 色爱区综合激月婷婷| eeuss鲁片一区二区三区| 91国偷自产一区二区开放时间 | 亚洲欧美日本韩国| 无码av免费一区二区三区试看 | 91精品婷婷国产综合久久性色 | 精品sm在线观看| 最新不卡av在线| 毛片av一区二区| 91九色最新地址| 久久久久久久精| 婷婷久久综合九色综合伊人色| 国产乱子轮精品视频| 欧美私人免费视频| 久久精品亚洲精品国产欧美| 亚洲午夜久久久久久久久电影院| 国产一区在线视频| 欧美日韩另类国产亚洲欧美一级| 久久久精品一品道一区| 偷拍一区二区三区| 91丨porny丨在线| 久久精品一区二区三区不卡牛牛| 亚洲国产人成综合网站| 成人免费看视频| 欧美va天堂va视频va在线| 一区二区在线观看免费 | 欧美亚洲高清一区| 国产精品免费av| 激情久久五月天| 欧美男男青年gay1069videost| 国产精品久久久久婷婷| 韩国精品主播一区二区在线观看 | 国产精品久久久久影院| 美女视频黄频大全不卡视频在线播放| 91在线国产福利| 中文字幕av不卡| 极品少妇xxxx精品少妇| 91精品久久久久久久91蜜桃| 亚洲一区二区在线免费看| 成人综合婷婷国产精品久久免费| 精品国产一区二区三区久久影院| 一级精品视频在线观看宜春院| 99麻豆久久久国产精品免费| 中文av一区二区| 不卡视频免费播放| 国产精品久久毛片| av成人动漫在线观看| 欧美国产一区在线| 国产成都精品91一区二区三| 久久久91精品国产一区二区精品 | 亚洲同性gay激情无套| 成人国产电影网| 中文字幕亚洲欧美在线不卡| 国产91精品一区二区麻豆亚洲| 国产视频在线观看一区二区三区|