当前位置: 首页 > wzjs >正文

返利网一类的网站怎么做永久免费crm客户管理系统

返利网一类的网站怎么做,永久免费crm客户管理系统,策划平台,网络安全专业就业前景目录 1、新建板级支持包 1、usart.c: 2、修改的地方:在usart.c中添加了这些 3、usart.h: 4、在usart.h中添加了这些: 5、dma.c: 6、dma.h: 2、修改main.c文件 1、在main.c文件中添加头文件 2、添加外部变量声明 3、添加简单延时函数 4、添加…

目录

1、新建板级支持包

1、usart.c:

2、修改的地方:在usart.c中添加了这些

3、usart.h:

4、在usart.h中添加了这些:

5、dma.c:

6、dma.h:

2、修改main.c文件

1、在main.c文件中添加头文件

2、添加外部变量声明

3、添加简单延时函数

4、添加应用代码

5、完整代码:

3、程序流程


新建工程的基本操作步骤参考这里:STM32CubeMX学习笔记(7)——DMA接口使用_cubemx dma-CSDN博客


1、新建板级支持包

LED板级支持包直接移植野火的,DMA板级支持包直接使用自动生成的代码在里面稍作修改

1、usart.c:

/* USER CODE BEGIN Header */
/********************************************************************************* @file    usart.c* @brief   This file provides code for the configuration*          of the USART instances.******************************************************************************* @attention** Copyright (c) 2025 STMicroelectronics.* All rights reserved.** This software is licensed under terms that can be found in the LICENSE file* in the root directory of this software component.* If no LICENSE file comes with this software, it is provided AS-IS.********************************************************************************/
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "usart.h"/* USER CODE BEGIN 0 */
uint8_t SendBuff[SENDBUFF_SIZE];
/* USER CODE END 0 */UART_HandleTypeDef huart1;
DMA_HandleTypeDef hdma_usart1_tx;/* USART1 init function */void MX_USART1_UART_Init(void)
{/* USER CODE BEGIN USART1_Init 0 *//* USER CODE END USART1_Init 0 *//* USER CODE BEGIN USART1_Init 1 *//* USER CODE END USART1_Init 1 */huart1.Instance = USART1;huart1.Init.BaudRate = 115200;huart1.Init.WordLength = UART_WORDLENGTH_8B;huart1.Init.StopBits = UART_STOPBITS_1;huart1.Init.Parity = UART_PARITY_NONE;huart1.Init.Mode = UART_MODE_TX_RX;huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;huart1.Init.OverSampling = UART_OVERSAMPLING_16;if (HAL_UART_Init(&huart1) != HAL_OK){Error_Handler();}/* USER CODE BEGIN USART1_Init 2 *//* USER CODE END USART1_Init 2 */}///重定向c库函数printf到串口DEBUG_USART,重定向后可使用printf函数
int fputc(int ch, FILE *f)
{/* 发送一个字节数据到串口DEBUG_USART */HAL_UART_Transmit(&huart1, (uint8_t *)&ch, 1, 1000);	return (ch);
}///重定向c库函数scanf到串口DEBUG_USART,重写向后可使用scanf、getchar等函数
int fgetc(FILE *f)
{int ch;HAL_UART_Receive(&huart1, (uint8_t *)&ch, 1, 1000);	return (ch);
}void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle)
{GPIO_InitTypeDef GPIO_InitStruct = {0};if(uartHandle->Instance==USART1){/* USER CODE BEGIN USART1_MspInit 0 *//* USER CODE END USART1_MspInit 0 *//* USART1 clock enable */__HAL_RCC_USART1_CLK_ENABLE();__HAL_RCC_GPIOA_CLK_ENABLE();/**USART1 GPIO ConfigurationPA9     ------> USART1_TXPA10     ------> USART1_RX*/GPIO_InitStruct.Pin = GPIO_PIN_9;GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);GPIO_InitStruct.Pin = GPIO_PIN_10;GPIO_InitStruct.Mode = GPIO_MODE_AF_INPUT;GPIO_InitStruct.Pull = GPIO_NOPULL;HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);/* USART1 DMA Init *//* USART1_TX Init */hdma_usart1_tx.Instance = DMA1_Channel4;hdma_usart1_tx.Init.Direction = DMA_MEMORY_TO_PERIPH;hdma_usart1_tx.Init.PeriphInc = DMA_PINC_DISABLE;hdma_usart1_tx.Init.MemInc = DMA_MINC_ENABLE;hdma_usart1_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD;hdma_usart1_tx.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD;hdma_usart1_tx.Init.Mode = DMA_NORMAL;hdma_usart1_tx.Init.Priority = DMA_PRIORITY_MEDIUM;if (HAL_DMA_Init(&hdma_usart1_tx) != HAL_OK){Error_Handler();}__HAL_LINKDMA(uartHandle,hdmatx,hdma_usart1_tx);/* USER CODE BEGIN USART1_MspInit 1 *//* USER CODE END USART1_MspInit 1 */}
}void HAL_UART_MspDeInit(UART_HandleTypeDef* uartHandle)
{if(uartHandle->Instance==USART1){/* USER CODE BEGIN USART1_MspDeInit 0 *//* USER CODE END USART1_MspDeInit 0 *//* Peripheral clock disable */__HAL_RCC_USART1_CLK_DISABLE();/**USART1 GPIO ConfigurationPA9     ------> USART1_TXPA10     ------> USART1_RX*/HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9|GPIO_PIN_10);/* USART1 DMA DeInit */HAL_DMA_DeInit(uartHandle->hdmatx);/* USER CODE BEGIN USART1_MspDeInit 1 *//* USER CODE END USART1_MspDeInit 1 */}
}/* USER CODE BEGIN 1 *//* USER CODE END 1 */

2、修改的地方:在usart.c中添加了这些

uint8_t SendBuff[SENDBUFF_SIZE];///重定向c库函数printf到串口DEBUG_USART,重定向后可使用printf函数
int fputc(int ch, FILE *f)
{/* 发送一个字节数据到串口DEBUG_USART */HAL_UART_Transmit(&huart1, (uint8_t *)&ch, 1, 1000);	return (ch);
}///重定向c库函数scanf到串口DEBUG_USART,重写向后可使用scanf、getchar等函数
int fgetc(FILE *f)
{int ch;HAL_UART_Receive(&huart1, (uint8_t *)&ch, 1, 1000);	return (ch);
}

3、usart.h:

/* USER CODE BEGIN Header */
/********************************************************************************* @file    usart.h* @brief   This file contains all the function prototypes for*          the usart.c file******************************************************************************* @attention** Copyright (c) 2025 STMicroelectronics.* All rights reserved.** This software is licensed under terms that can be found in the LICENSE file* in the root directory of this software component.* If no LICENSE file comes with this software, it is provided AS-IS.********************************************************************************/
/* USER CODE END Header */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __USART_H__
#define __USART_H__#ifdef __cplusplus
extern "C" {
#endif/* Includes ------------------------------------------------------------------*/
#include "main.h"/* USER CODE BEGIN Includes */
#include <stdio.h>
/* USER CODE END Includes */extern UART_HandleTypeDef huart1;/* USER CODE BEGIN Private defines */
#define SENDBUFF_SIZE                     		1000//发送的数据量/* USER CODE END Private defines */void MX_USART1_UART_Init(void);/* USER CODE BEGIN Prototypes *//* USER CODE END Prototypes */#ifdef __cplusplus
}
#endif#endif /* __USART_H__ */

4、在usart.h中添加了这些:

#include <stdio.h>extern UART_HandleTypeDef huart1;#define SENDBUFF_SIZE                     		1000//发送的数据量

5、dma.c:

/* USER CODE BEGIN Header */
/********************************************************************************* @file    dma.c* @brief   This file provides code for the configuration*          of all the requested memory to memory DMA transfers.******************************************************************************* @attention** Copyright (c) 2025 STMicroelectronics.* All rights reserved.** This software is licensed under terms that can be found in the LICENSE file* in the root directory of this software component.* If no LICENSE file comes with this software, it is provided AS-IS.********************************************************************************/
/* USER CODE END Header *//* Includes ------------------------------------------------------------------*/
#include "dma.h"/* USER CODE BEGIN 0 *//* USER CODE END 0 *//*----------------------------------------------------------------------------*/
/* Configure DMA                                                              */
/*----------------------------------------------------------------------------*//* USER CODE BEGIN 1 *//* USER CODE END 1 *//*** Enable DMA controller clock*/
void MX_DMA_Init(void)
{/* DMA controller clock enable */__HAL_RCC_DMA1_CLK_ENABLE();/* DMA interrupt init *//* DMA1_Channel4_IRQn interrupt configuration */HAL_NVIC_SetPriority(DMA1_Channel4_IRQn, 0, 0);HAL_NVIC_EnableIRQ(DMA1_Channel4_IRQn);}/* USER CODE BEGIN 2 *//* USER CODE END 2 */

6、dma.h:

/* USER CODE BEGIN Header */
/********************************************************************************* @file    dma.h* @brief   This file contains all the function prototypes for*          the dma.c file******************************************************************************* @attention** Copyright (c) 2025 STMicroelectronics.* All rights reserved.** This software is licensed under terms that can be found in the LICENSE file* in the root directory of this software component.* If no LICENSE file comes with this software, it is provided AS-IS.********************************************************************************/
/* USER CODE END Header */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __DMA_H__
#define __DMA_H__#ifdef __cplusplus
extern "C" {
#endif/* Includes ------------------------------------------------------------------*/
#include "main.h"/* DMA memory to memory transfer handles -------------------------------------*//* USER CODE BEGIN Includes *//* USER CODE END Includes *//* USER CODE BEGIN Private defines *//* USER CODE END Private defines */void MX_DMA_Init(void);/* USER CODE BEGIN Prototypes *//* USER CODE END Prototypes */#ifdef __cplusplus
}
#endif#endif /* __DMA_H__ */

2、修改main.c文件

1、在main.c文件中添加头文件

#include "stm32f1xx.h"
#include "./led/bsp_led.h"

2、添加外部变量声明

extern UART_HandleTypeDef huart1;
extern DMA_HandleTypeDef hdma_usart1_tx;
extern uint8_t SendBuff[SENDBUFF_SIZE];

3、添加简单延时函数

static void Delay(__IO uint32_t nCount)	 //简单的延时函数
{for(; nCount != 0; nCount--);
}

4、添加应用代码

int main(void)
{/* USER CODE BEGIN 1 */uint16_t i;/* 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_DMA_Init();MX_USART1_UART_Init();/* USER CODE BEGIN 2 *//* 配置RGB彩色灯 */LED_GPIO_Config();printf("\r\n USART1 DMA TX 测试 \r\n");/*填充将要发送的数据*/for(i=0;i<SENDBUFF_SIZE;i++){SendBuff[i]	 = 'A';}/* USART1 向 DMA发出TX请求 */HAL_UART_Transmit_DMA(&huart1, (uint8_t *)SendBuff ,SENDBUFF_SIZE);/* USER CODE END 2 *//* Infinite loop *//* USER CODE BEGIN WHILE */while (1){/* USER CODE END WHILE *//* 此时CPU是空闲的,可以干其他的事情 */  //例如同时控制LEDLED1_TOGGLEDelay(0xFFFFF);/* USER CODE BEGIN 3 */}/* USER CODE END 3 */
}

5、完整代码:

/* USER CODE BEGIN Header */
/********************************************************************************* @file           : main.c* @brief          : Main program body******************************************************************************* @attention** Copyright (c) 2025 STMicroelectronics.* All rights reserved.** This software is licensed under terms that can be found in the LICENSE file* in the root directory of this software component.* If no LICENSE file comes with this software, it is provided AS-IS.********************************************************************************/
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "main.h"
#include "dma.h"
#include "usart.h"
#include "gpio.h"/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "stm32f1xx.h"
#include "./led/bsp_led.h"
/* USER CODE END Includes *//* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */
extern UART_HandleTypeDef huart1;
extern DMA_HandleTypeDef hdma_usart1_tx;
extern uint8_t SendBuff[SENDBUFF_SIZE];
static void Delay(__IO uint32_t nCount); /* 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 ---------------------------------------------------------*//* USER CODE BEGIN PV *//* USER CODE END PV *//* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(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 i;/* 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_DMA_Init();MX_USART1_UART_Init();/* USER CODE BEGIN 2 *//* 配置RGB彩色灯 */LED_GPIO_Config();printf("\r\n USART1 DMA TX 测试 \r\n");/*填充将要发送的数据*/for(i=0;i<SENDBUFF_SIZE;i++){SendBuff[i]	 = 'A';}/* USART1 向 DMA发出TX请求 */HAL_UART_Transmit_DMA(&huart1, (uint8_t *)SendBuff ,SENDBUFF_SIZE);/* USER CODE END 2 *//* Infinite loop *//* USER CODE BEGIN WHILE */while (1){/* USER CODE END WHILE *//* 此时CPU是空闲的,可以干其他的事情 */  //例如同时控制LEDLED1_TOGGLEDelay(0xFFFFF);/* USER CODE BEGIN 3 */}/* USER CODE END 3 */
}static void Delay(__IO uint32_t nCount)	 //简单的延时函数
{for(; nCount != 0; nCount--);
}/*** @brief System Clock Configuration* @retval None*/
void SystemClock_Config(void)
{RCC_OscInitTypeDef RCC_OscInitStruct = {0};RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};/** Initializes the RCC Oscillators according to the specified parameters* in the RCC_OscInitTypeDef structure.*/RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;RCC_OscInitStruct.HSEState = RCC_HSE_ON;RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1;RCC_OscInitStruct.HSIState = RCC_HSI_ON;RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9;if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK){Error_Handler();}/** Initializes the CPU, AHB and APB buses clocks*/RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK){Error_Handler();}
}/* USER CODE BEGIN 4 *//* USER CODE END 4 *//*** @brief  This function is executed in case of error occurrence.* @retval None*/
void Error_Handler(void)
{/* USER CODE BEGIN Error_Handler_Debug *//* User can add his own implementation to report the HAL error return state */__disable_irq();while (1){}/* USER CODE END Error_Handler_Debug */
}#ifdef  USE_FULL_ASSERT
/*** @brief  Reports the name of the source file and the source line number*         where the assert_param error has occurred.* @param  file: pointer to the source file name* @param  line: assert_param error line source number* @retval None*/
void assert_failed(uint8_t *file, uint32_t line)
{/* USER CODE BEGIN 6 *//* User can add his own implementation to report the file name and line number,ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) *//* USER CODE END 6 */
}
#endif /* USE_FULL_ASSERT */

3、程序流程

1、HAL库函数初始化

2、系统时钟初始化

3、GPIO  DMA  USART  LED  初始化

4、打印提示信息

5、填充将要发送的数据

6、USART1向DMA发出TX请求,开始DMA数据传输

7、同时CPU控制LED翻转

http://www.dtcms.com/wzjs/331457.html

相关文章:

  • 青浦专业做网站友情链接的获取途径有哪些
  • 深圳做网站要多少济宁百度推广电话
  • 该网站正在建设中 马上就来2022拉人头最暴利的app
  • 做怎么网站河南网站seo费用
  • 专注网站建设与制作关键词的优化方法
  • 阿里云php网站建设教程如何在网上推广产品
  • 做网站的私活企业网站的搜索引擎推广与优化
  • 网站做快照谷歌搜索引擎香港免费入口
  • 网页设计网站怎么放到域名里百度识图在线使用
  • 广州市住房城乡建设局网站优化英文
  • 比较好的海报设计网站xp优化大师
  • 列出网站开发建设的步骤广州百度关键词排名
  • 惠州专业网站设计公司免费外网加速器
  • 平台网站建设在哪里短期的技能培训有哪些
  • 低代码开发appseo团队
  • 网站建设百科湖南靠谱关键词优化
  • 广东官网网站建设品牌网站流量查询
  • 移动端模板网站建设歌尔股份砍单
  • 网站的基本布局百度竞价渠道代理商
  • 百度一直不收录网站网络优化大师手机版
  • 视频拍摄和剪辑怎么学北京网站seo服务
  • 长春网站建设找新生科技seo技巧是什么意思
  • 易记域名网站大全网络广告营销的概念
  • 怎么看网站是什么时候做的最新的疫情信息
  • 长沙专业建设网站企业青岛seo推广专员
  • 做网站用的主机多少合适市场营销计划
  • 网站建设灯百度下载免费
  • 公司如何做网站建设百度指数是怎么计算的
  • 免费自创网站百度站内搜索提升关键词排名
  • 浏览器编程语言曲靖seo建站