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

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 5475|回復: 1
打印 上一主題 下一主題
收起左側

BMP180驅動程序,基于STM32f103ZET6 庫版本:HAL

[復制鏈接]
跳轉到指定樓層
樓主
BMP180 驅動程序,基于 STM32f103ZET6 ,開發平臺:Keil 5 ,庫版本:HAL
(BMP180 driver, based on STM32f103ZET6, development platform: Keil 5, library version: HAL.)

使用硬件IIC的方式,讀取 BMP180 中的寄存器值(0xAA)

利用LPME1函數修改,硬件IIC可完成目標,但不規范

開發平臺:Keil 5


單片機源程序如下:
  1. /**
  2.   ******************************************************************************
  3.   * File Name          : main.c
  4.   * Description        : Main program body
  5.   ******************************************************************************
  6.   *
  7.   * COPYRIGHT(c) 2018 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 "stm32f1xx_hal.h"
  35. #include "i2c.h"
  36. #include "spi.h"
  37. #include "usart.h"
  38. #include "gpio.h"

  39. /* USER CODE BEGIN Includes */

  40. #include "bmp180.h"

  41. /* USER CODE END Includes */

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

  43. /* USER CODE BEGIN PV */
  44. /* Private variables ---------------------------------------------------------*/

  45. /* USER CODE END PV */

  46. /* Private function prototypes -----------------------------------------------*/
  47. void SystemClock_Config(void);
  48. void Error_Handler(void);

  49. /* USER CODE BEGIN PFP */
  50. /* Private function prototypes -----------------------------------------------*/

  51. /* USER CODE END PFP */

  52. /* USER CODE BEGIN 0 */

  53. /* USER CODE END 0 */

  54. int main(void)
  55. {

  56.     /* USER CODE BEGIN 1 */

  57.     /* USER CODE END 1 */

  58.     /* MCU Configuration----------------------------------------------------------*/

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

  61.     /* Configure the system clock */
  62.     SystemClock_Config();

  63.     /* Initialize all configured peripherals */
  64.     MX_GPIO_Init();
  65.     MX_I2C1_Init();
  66.     //MX_SPI1_Init();
  67.     MX_USART1_UART_Init();

  68.     /* USER CODE BEGIN 2 */
  69.     float Temp = 10.0;
  70.     float data[2] = {0};
  71.     /* USER CODE END 2 */

  72.     /* Infinite loop */
  73.     /* USER CODE BEGIN WHILE */
  74.     while (1)
  75.     {
  76.     /* USER CODE END WHILE */

  77.     /* USER CODE BEGIN 3 */
  78.         //for(int i = 1000; i > 0; i--);
  79.         //lpme1_example();
  80.         lpme1_get_acc(data);

  81.         //printf("Temperature: %.1f \r\n", Temp);


  82.     }
  83.     /* USER CODE END 3 */

  84. }

  85. /** System Clock Configuration
  86. */
  87. void SystemClock_Config(void)
  88. {

  89.     RCC_OscInitTypeDef RCC_OscInitStruct;
  90.     RCC_ClkInitTypeDef RCC_ClkInitStruct;

  91.     RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
  92.     RCC_OscInitStruct.HSEState = RCC_HSE_ON;
  93.     RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1;
  94.     RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
  95.     RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
  96.     RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9;
  97.     if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
  98.     {
  99.         Error_Handler();
  100.     }

  101.     RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
  102.                               |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
  103.     RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
  104.     RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
  105.     RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
  106.     RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
  107.     if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)
  108.     {
  109.         Error_Handler();
  110.     }

  111.     HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000);

  112.     HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK);

  113.     /* SysTick_IRQn interrupt configuration */
  114.     HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);
  115. }

  116. /* USER CODE BEGIN 4 */

  117. /* USER CODE END 4 */

  118. /**
  119.   * @brief  This function is executed in case of error occurrence.
  120.   * @param  None
  121.   * @retval None
  122.   */
  123. void Error_Handler(void)
  124. {
  125.   /* USER CODE BEGIN Error_Handler */
  126.   /* User can add his own implementation to report the HAL error return state */
  127.   while(1)
  128.   {
  129.   }
  130.   /* USER CODE END Error_Handler */
  131. }

  132. #ifdef USE_FULL_ASSERT

  133. /**
  134.    * @brief Reports the name of the source file and the source line number
  135.    * where the assert_param error has occurred.
  136.    * @param file: pointer to the source file name
  137.    * @param line: assert_param error line source number
  138. ……………………

  139. …………限于本文篇幅 余下代碼請從51黑下載附件…………
復制代碼

所有資料51hei提供下載:
Cube_Demo_2_BMP180.zip (3.71 MB, 下載次數: 70)




分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享淘帖 頂 踩
回復

使用道具 舉報

沙發
ID:73118 發表于 2018-7-31 14:18 | 只看該作者
下載下來了,意義不大,只有幾句代碼,沒注釋,沒按數據手冊校準,讀出的數據也不知道為啥是float類型,算了還是對照數據手冊重新做吧。

YJXVPQ77U$34CZFHFN`DZNO.png (60.45 KB, 下載次數: 99)

YJXVPQ77U$34CZFHFN`DZNO.png
回復

使用道具 舉報

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

本版積分規則

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

Powered by 單片機教程網

快速回復 返回頂部 返回列表
主站蜘蛛池模板: 一区二区在线 | 亚洲成人精品 | 国产中文| 亚洲黄色av网站 | 欧美黄a| 国产精品美女www爽爽爽 | 91久久精品一区二区三区 | 免费成年网站 | 在线一区| 国产美女自拍视频 | 另类视频在线 | 亚洲综合区 | 成人精品一区二区三区中文字幕 | 中文字幕欧美一区 | 亚洲www| 久草电影网| av资源中文在线 | 91精品在线看 | 999久久精品 | 九九热这里 | 国产精品123区 | 国产精品麻| 亚洲国产成人精品久久久国产成人一区 | 亚洲91| 日韩一二区在线观看 | 国产精品久久久久久吹潮 | 午夜免费在线电影 | 在线国产精品一区 | 一区日韩| 综合色播 | 国产91久久精品一区二区 | 国产精品成人一区二区三区夜夜夜 | 精品一区二区观看 | 成人在线国产 | 久久久精品一区二区三区 | 午夜影院在线免费观看视频 | 国产日韩欧美在线 | 五月婷婷 六月丁香 | 高清久久久 | 色视频网站在线观看 | 亚洲欧洲一区二区 |