8_STM32cubeIDE_GitHub代碼託管,功耗計算器,ADC

1_GitHub代碼託管


請參考這個視頻git

GitHub倉庫裏的圖片
github.com/ 你的用戶名 / 你的項目名 / raw / 分支名 / 存放圖片的文件夾 / 該文件夾下的圖片github

https://github.com/modi12jin/stm32_github/raw/master/images/2.gif
複製代碼

第1步

安裝下載git並配置我的的用戶名稱和電子郵件地址
git下載地址
$ git config --global user.name "runoob"
$ git config --global user.email test@runoob.combash

第2步

註冊github帳號app

第3步

在github上面新建一個倉庫 ide

後面幾步請看視頻

最後效果

2_功耗計算器


請參考這個視頻oop

3_ADC


#include "main.h"

/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */

/* USER CODE END Includes */

/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */

/* USER CODE END PTD */

/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */

/* USER CODE END PD */

/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */

/* USER CODE END PM */

/* Private variables ---------------------------------------------------------*/
ADC_HandleTypeDef hadc1;

UART_HandleTypeDef huart1;

/* USER CODE BEGIN PV */

/* USER CODE END PV */

/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_ADC1_Init(void);
static void MX_USART1_UART_Init(void);
/* USER CODE BEGIN PFP */

/* USER CODE END PFP */

/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */

/* USER CODE END 0 */

/**
  * @brief  The application entry point.
  * @retval int
  */
int main(void)
{
  /* USER CODE BEGIN 1 */
uint16_t ADC_Value;
  /* USER CODE END 1 */
  

  /* MCU Configuration--------------------------------------------------------*/

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

  /* USER CODE BEGIN Init */

  /* USER CODE END Init */

  /* Configure the system clock */
  SystemClock_Config();

  /* USER CODE BEGIN SysInit */

  /* USER CODE END SysInit */

  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_ADC1_Init();
  MX_USART1_UART_Init();
  /* USER CODE BEGIN 2 */

  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
    /* USER CODE END WHILE */

    /* USER CODE BEGIN 3 */
	  HAL_ADC_Start(&hadc1);
	  HAL_ADC_PollForConversion(&hadc1, HAL_MAX_DELAY);
	  ADC_Value=HAL_ADC_GetValue(&hadc1);
	  HAL_UART_Transmit(&huart1,(uint8_t *)&ADC_Value,sizeof(ADC_Value),HAL_MAX_DELAY);
	  HAL_Delay(500);
  }
  /* USER CODE END 3 */
}
複製代碼

相關文章
相關標籤/搜索