久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 3945|回復: 0
收起左側

SPI-W25QXX STM32F746I源碼

[復制鏈接]
ID:309009 發表于 2018-4-16 11:50 | 顯示全部樓層 |閱讀模式
SPI-W25QXX
0.jpg
Configuration        STM32F746I
STM32CubeMX         4.12.0
MCU        STM32F746IGTx


PERIPHERALS        MODES        FUNCTIONS        PINS
RCC        Crystal/Ceramic Resonator        RCC_OSC_IN        PH0/OSC_IN
RCC        Crystal/Ceramic Resonator        RCC_OSC_OUT        PH1/OSC_OUT
SPI1        Full-Duplex Master        SPI1_MISO        PA6
SPI1        Full-Duplex Master        SPI1_MOSI        PA7
SPI1        Full-Duplex Master        SPI1_SCK        PA5
USART1        Asynchronous        USART1_RX        PA10
USART1        Asynchronous        USART1_TX        PA9

Pin Nb        PINs        FUNCTIONs        LABELs
29        PH0/OSC_IN        RCC_OSC_IN        
30        PH1/OSC_OUT        RCC_OSC_OUT        
50        PA4        GPIO_Output        CS
51        PA5        SPI1_SCK        
52        PA6        SPI1_MISO        
53        PA7        SPI1_MOSI        
120        PA9        USART1_TX        
121        PA10        USART1_RX        
SOFTWARE PROJECT

Project Settings :
Project Name : STM32F746I
Project Folder : C:\Users\Administrator\Desktop\20.SPI-AT45DBXX
Toolchain / IDE : MDK-ARM V5
Firmware Package Name and Version : STM32Cube FW_F7 V1.3.0

Code Generation Settings :
STM32Cube Firmware Library Package : Copy all used libraries into the project folder
Generate peripheral initialization as a pair of '.c/.h' files per IP : Yes
Backup previously generated files when re-generating : No
Delete previously generated files when not re-generated : Yes
Set all free pins as analog (to optimize the power consumption) : No

Toolchains Settings :
Compiler Optimizations : Balanced Size/Speed



單片機源程序如下:
  1. /**
  2.   ******************************************************************************
  3.   * File Name          : main.c
  4.   * Description        : Main program body
  5.   ******************************************************************************
  6.   *
  7.   * COPYRIGHT(c) 2015 STMicroelectronics
  8.   *
  9.   * Redistribution and use in source and binary forms, with or without modification,
  10.   * are permitted provided that the following conditions are met:
  11.   *   1. Redistributions of source code must retain the above copyright notice,
  12.   *      this list of conditions and the following disclaimer.
  13.   *   2. Redistributions in binary form must reproduce the above copyright notice,
  14.   *      this list of conditions and the following disclaimer in the documentation
  15.   *      and/or other materials provided with the distribution.
  16.   *   3. Neither the name of STMicroelectronics nor the names of its contributors
  17.   *      may be used to endorse or promote products derived from this software
  18.   *      without specific prior written permission.
  19.   *
  20.   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  21.   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  22.   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  23.   * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  24.   * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  25.   * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  26.   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  27.   * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  28.   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  29.   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30.   *
  31.   ******************************************************************************
  32.   */
  33. /* Includes ------------------------------------------------------------------*/
  34. #include "stm32f7xx_hal.h"
  35. #include "spi.h"
  36. #include "usart.h"
  37. #include "gpio.h"

  38. /* USER CODE BEGIN Includes */
  39. #include <string.h>
  40. #include "W25Qx.h"
  41. /* USER CODE END Includes */

  42. /* Private variables ---------------------------------------------------------*/

  43. /* USER CODE BEGIN PV */
  44. /* Private variables ---------------------------------------------------------*/
  45. uint8_t wData[0x100];
  46. uint8_t rData[0x100];
  47. uint32_t i;
  48. /* USER CODE END PV */

  49. /* Private function prototypes -----------------------------------------------*/
  50. void SystemClock_Config(void);

  51. /* USER CODE BEGIN PFP */
  52. /* Private function prototypes -----------------------------------------------*/
  53. static void Error_Handler(void);
  54. /* USER CODE END PFP */

  55. /* USER CODE BEGIN 0 */

  56. /* USER CODE END 0 */

  57. int main(void)
  58. {

  59.   /* USER CODE BEGIN 1 */
  60.         uint8_t ID[4];
  61.         int i;
  62.   /* USER CODE END 1 */

  63.   /* MCU Configuration----------------------------------------------------------*/

  64.   /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  65.   HAL_Init();

  66.   /* Configure the system clock */
  67.   SystemClock_Config();

  68.   /* Initialize all configured peripherals */
  69.   MX_GPIO_Init();
  70.   MX_SPI1_Init();
  71.   MX_USART1_UART_Init();

  72.   /* USER CODE BEGIN 2 */
  73.         printf("\r\n SPI-W25Qxxx Example \r\n\r\n");

  74.         /*##-1- Read the device ID  ########################*/
  75.         BSP_W25Qx_Init();
  76.         BSP_W25Qx_Read_ID(ID);
  77.         printf("W25Qxxx ID is : ");
  78.         for(i=0;i<2;i++)
  79.         {
  80.                 printf("0x%02X ",ID[i]);
  81.         }
  82.         printf("\r\n\r\n");
  83.         
  84.         /*##-2- Erase Block ##################################*/
  85.         if(BSP_W25Qx_Erase_Block(0) == W25Qx_OK)
  86.                 printf(" QSPI Erase Block ok\r\n");
  87.         else
  88.                 Error_Handler();
  89.         
  90.         /*##-2- Written to the flash ########################*/
  91.         /* fill buffer */
  92.         for(i =0;i<0x100;i ++)
  93.         {
  94.                         wData[i] = i;
  95.                   rData[i] = 0;
  96.         }
  97.         
  98.         if(BSP_W25Qx_Write(wData,0x00,0x100)== W25Qx_OK)
  99.                 printf(" QSPI Write ok\r\n");
  100.         else
  101.                 Error_Handler();

  102.         /*##-3- Read the flash     ########################*/
  103.         if(BSP_W25Qx_Read(rData,0x00,0x100)== W25Qx_OK)
  104.                 printf(" QSPI Read ok\r\n\r\n");
  105.         else
  106.                 Error_Handler();
  107.         
  108.         printf("QSPI Read Data : \r\n");
  109.         for(i =0;i<0x100;i++)
  110.                 printf("0x%02X  ",rData[i]);
  111.         printf("\r\n\r\n");
  112.         
  113.         /*##-4- check date          ########################*/         
  114.         if(memcmp(wData,rData,0x100) == 0 )
  115.                 printf(" W25Q128FV QuadSPI Test OK\r\n");
  116.         else
  117.                 printf(" W25Q128FV QuadSPI Test False\r\n");
  118.   /* USER CODE END 2 */

  119.   /* Infinite loop */
  120.   /* USER CODE BEGIN WHILE */
  121.   while (1)
  122.   {
  123.   /* USER CODE END WHILE */

  124.   /* USER CODE BEGIN 3 */

  125.   }
  126.   /* USER CODE END 3 */

  127. }

  128. /** System Clock Configuration
  129. */
  130. void SystemClock_Config(void)
  131. {

  132.   RCC_OscInitTypeDef RCC_OscInitStruct;
  133.   RCC_ClkInitTypeDef RCC_ClkInitStruct;
  134.   RCC_PeriphCLKInitTypeDef PeriphClkInitStruct;

  135.   __PWR_CLK_ENABLE();

  136.   __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);

  137.   RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
  138.   RCC_OscInitStruct.HSEState = RCC_HSE_ON;
  139.   RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
  140.   RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
  141.   RCC_OscInitStruct.PLL.PLLM = 4;
  142.   RCC_OscInitStruct.PLL.PLLN = 200;
  143.   RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
  144.   RCC_OscInitStruct.PLL.PLLQ = 2;
  145.   HAL_RCC_OscConfig(&RCC_OscInitStruct);

  146.   HAL_PWREx_ActivateOverDrive();

  147.   RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
  148.                               |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
  149.   RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
  150.   RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
  151.   RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
  152.   RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;
  153.   HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_6);

  154.   PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_USART1;
  155.   PeriphClkInitStruct.Usart1ClockSelection = RCC_USART1CLKSOURCE_PCLK2;
  156.   HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct);

  157.   HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000);

  158.   HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK);

  159.   /* SysTick_IRQn interrupt configuration */
  160.   HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);
  161. }

  162. /* USER CODE BEGIN 4 */
  163. /**
  164.   * @brief  This function is executed in case of error occurrence.
  165.   * @param  None
  166.   * @retval None
  167.   */
  168. static void Error_Handler(void)
  169. {
  170.         printf("something wrong ....\r\n");
  171.   /* User may add here some code to deal with this error */
  172.   while(1)
  173.   {
  174.   }
  175. }
  176. /* USER CODE END 4 */

  177. #ifdef USE_FULL_ASSERT

  178. /**
  179.    * @brief Reports the name of the source file and the source line number
  180.    * where the assert_param error has occurred.
  181.    * @param file: pointer to the source file name
  182.    * @param line: assert_param error line source number
  183.    * @retval None
  184.    */
  185. void assert_failed(uint8_t* file, uint32_t line)
  186. {
  187.   /* USER CODE BEGIN 6 */
  188.   /* User can add his own implementation to report the file name and line number,
  189.     ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
  190.   /* USER CODE END 6 */

  191. }

  192. #endif

  193. /**
  194.   * @}
  195.   */

  196. /**
  197.   * @}
  198. */

  199. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
復制代碼


所有資料51hei提供下載:
10.SPI-W25QXX.7z (1.37 MB, 下載次數: 38)

評分

參與人數 1黑幣 +30 收起 理由
zhai1461961500 + 30 很給力!

查看全部評分

回復

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規則

手機版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術交流QQ群281945664

Powered by 單片機教程網

快速回復 返回頂部 返回列表
主站蜘蛛池模板: 日韩一级 | 91免费在线播放 | 亚洲综合成人网 | 日韩成人在线一区 | 日韩欧美亚洲 | 中文字幕在线精品 | 欧美一区二区三区在线 | 亚洲国产视频一区二区 | 91porn成人精品 | 亚洲国产精品成人久久久 | 亚洲国产视频一区二区 | 欧美在线看片 | 午夜国产| 日韩网站在线 | 91精品国产乱码久久蜜臀 | 日韩www | 日韩av免费在线电影 | 国产综合精品一区二区三区 | 黄色一级大片在线免费看产 | 天天草av | 国产精品久久久久久久粉嫩 | 中文字幕免费视频 | 天天色av| 在线国产一区二区 | 99久久精品免费看国产高清 | 精品综合久久 | 国产高清毛片 | 国产精品v | www.免费看片.com | 91在线网| 国产97在线看 | 操操日| 免费在线一区二区 | 日韩精品免费 | 久久国产精品一区 | 全免费a级毛片免费看视频免费下 | 成人h视频在线 | av大全在线 | 日韩在线国产 | 九九热这里 | 国产 欧美 日韩 一区 |