#include "STM32Lib\\stm32f10x.h" #include "main.h" //extern MFL_UART MFL_UART_1; extern MFL_PARA MFL_PARA_A; extern UART_PARA Uart1_BTcom; extern UART_PARA Uart3_Debug; #define SRC_USART1_DR (&(USART1->DR)) //串口接收寄存器作为源头 #define SRC_USART3_DR (&(USART3->DR)) //串口接收寄存器作为源头 #define ADC1_DR_Address ((u32)0x4001244C) /******************************************************************************* * Function Name : GPIO_Configuration *******************************************************************************/ void GPIO_Configuration(void) { GPIO_InitTypeDef GPIO_InitStructure; USART_InitTypeDef USART_InitStructure; USART_ClockInitTypeDef USART_ClockInitStructure; SPI_InitTypeDef SPI_InitStructure; DMA_InitTypeDef DMA_InitStructure; ADC_InitTypeDef ADC_InitStructure; TIM_TimeBaseInitTypeDef TIM_TimeBaseInitStruct; //EXTI_InitTypeDef EXTI_InitStructure; //I2C_InitTypeDef I2C_InitStructure; //DAC_InitTypeDef DAC_InitStructure; /*允许总线CLOCK,在使用GPIO之前必须允许相应端的时钟.*/ RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE); RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE); RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE); RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD, ENABLE); RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE); RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE); RCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI1, ENABLE); RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE); RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE); //RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI2,ENABLE); //RCC_APB1PeriphClockCmd(RCC_APB1Periph_I2C1, ENABLE); RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE); GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE); GPIO_PinRemapConfig(GPIO_Remap_USART1, ENABLE); ////////////////////////////////模拟输入////////////////////////////////// //PC0--CUR PC1--TEMP PC3--VREF GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_3; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN; GPIO_Init(GPIOC, &GPIO_InitStructure); //PA0--COM PA1--VOM GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN; GPIO_Init(GPIOA, &GPIO_InitStructure); ////////////////////////////////输入////////////////////////////////// //PA2--TMP_INT PA11 PA12 PA15--K0,K1,K2 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2 | GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_15; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; //上拉输入 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //50M时钟速度 GPIO_Init(GPIOA, &GPIO_InitStructure); // //PB0-PB2--IN1,IN2,IN3 PB3--K7 PB4--IO2 PB5--IO1 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; //上拉输入 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //50M时钟速度 GPIO_Init(GPIOB, &GPIO_InitStructure); // //PC4--ADC_DRDY PC10-PC12--K3,K4,K5 PC13-PC14--S1,S2 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 | GPIO_Pin_10 | GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; //上拉输入 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //50M时钟速度 GPIO_Init(GPIOC, &GPIO_InitStructure); // //PD2--K6 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; //上拉输入 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //50M时钟速度 GPIO_Init(GPIOD, &GPIO_InitStructure); // ////////////////////////////////输出////////////////////////////////// //PA3-PA4 PA8-PA10 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //推挽输出 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //50M时钟速度 GPIO_Init(GPIOA, &GPIO_InitStructure); //复位值为0 GPIO_SetBits(GPIOA, GPIO_Pin_3); GPIO_SetBits(GPIOA, GPIO_Pin_4); //PB8--SCL PB9--SDA GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_9; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_OD; //开漏输出 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //50M时钟速度 GPIO_Init(GPIOB, &GPIO_InitStructure); //复位值为0 //PB12-PB15 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //推挽输出 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //50M时钟速度 GPIO_Init(GPIOB, &GPIO_InitStructure); //复位值为0 GPIO_ResetBits(GPIOB, GPIO_Pin_4); GPIO_ResetBits(GPIOB, GPIO_Pin_5); //PC2--PWM PC5-PC9 PC15 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2 | GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_15; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //推挽输出 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //50M时钟速度 GPIO_Init(GPIOC, &GPIO_InitStructure); //复位值为0 ////////////////////////////IIC1配置///////////////////////////////////// /*GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_Init(GPIOB, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_OD; GPIO_Init(GPIOB, &GPIO_InitStructure);*/ /*// PB6,7 SCL and SDA GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_OD; GPIO_Init(GPIOB, &GPIO_InitStructure); I2C_DeInit(I2C1); I2C_InitStructure.I2C_Mode = I2C_Mode_I2C; I2C_InitStructure.I2C_DutyCycle = I2C_DutyCycle_2; I2C_InitStructure.I2C_OwnAddress1 = 0x00; I2C_InitStructure.I2C_Ack = I2C_Ack_Enable; I2C_InitStructure.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit; I2C_InitStructure.I2C_ClockSpeed =100000;//100K?? I2C_Cmd(I2C1, ENABLE); I2C_Init(I2C1, &I2C_InitStructure); I2C_AcknowledgeConfig(I2C1, ENABLE);*/ ////////////////////////////SPI1配置///////////////////////////////////// //PA5-SCK1,PA6-MISO1, PA7-MOSI1 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_7; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; //复用推挽输出 GPIO_Init(GPIOA, &GPIO_InitStructure); //SPI1 configuration SPI_Cmd(SPI1, DISABLE); //必须先禁能,才能改变MODE SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex; //两线全双工 SPI_InitStructure.SPI_Mode = SPI_Mode_Master; //主 SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b; //8位 SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low; //CPOL=0 时钟悬空高 SPI_InitStructure.SPI_CPHA = SPI_CPHA_2Edge; //CPHA=1 数据捕获第2个 模式1 SPI_InitStructure.SPI_NSS = SPI_NSS_Soft; //软件NSS SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_256; //16分频2.25M,AD最高5M SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB; //高位在前 SPI_InitStructure.SPI_CRCPolynomial = 7; //CRC7 SPI_Init(SPI1, &SPI_InitStructure); SPI_Cmd(SPI1, ENABLE); ////////////////////////////串口1(蓝牙通信)配置///////////////////////////////////// //PB6 USART1_Tx GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_Init(GPIOB, &GPIO_InitStructure); //PB7 USART1_Rx GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; GPIO_Init(GPIOB, &GPIO_InitStructure); USART_InitStructure.USART_BaudRate = 9600; USART_InitStructure.USART_WordLength = USART_WordLength_8b; USART_InitStructure.USART_StopBits = USART_StopBits_1; USART_InitStructure.USART_Parity = USART_Parity_No; USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; USART_ClockInitStructure.USART_Clock = USART_Clock_Disable; USART_ClockInitStructure.USART_CPOL = USART_CPOL_Low; USART_ClockInitStructure.USART_CPHA = USART_CPHA_2Edge; USART_ClockInitStructure.USART_LastBit = USART_LastBit_Disable; USART_ClockInit(USART1, &USART_ClockInitStructure); USART_Init(USART1, &USART_InitStructure); USART_Cmd(USART1, ENABLE); USART_ClearFlag(USART1, USART_FLAG_TC); /* 清发送外完成标志,Transmission Complete flag */ ////////////////////////////UART1 DMA串口接收配置 DMA1-5///////////////////////////////////// DMA_DeInit(DMA1_Channel5); DMA_InitStructure.DMA_PeripheralBaseAddr = (u32)SRC_USART1_DR; //源头BUF DMA_InitStructure.DMA_MemoryBaseAddr = (u32)Uart1_BTcom.UART_DMA_RXD_BUF_TEMP; //目标BUF DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC; //外设作源头 DMA_InitStructure.DMA_BufferSize = UART_RXD_BUF_SIZE; //BUF大小 DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; //外设地址寄存器不递增 DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; //内存地址递增 DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte; //外设字节为单位 DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte; //内存字节为单位 DMA_InitStructure.DMA_Mode = DMA_Mode_Circular; //循环模式 DMA_InitStructure.DMA_Priority = DMA_Priority_High; //4优先级之一的(高优先) DMA_InitStructure.DMA_M2M = DMA_M2M_Disable; //非内存到内存 DMA_Init(DMA1_Channel5, &DMA_InitStructure); //DMA_ITConfig(DMA1_Channel5, DMA_IT_TC, ENABLE); //DMA5传输完成中断 USART_DMACmd(USART1, USART_DMAReq_Rx, ENABLE); //串口接收器DMA DMA_Cmd(DMA1_Channel5, ENABLE); //正式允许DMA Uart1_BTcom.UART_RXD_FINISH = 0; Uart1_BTcom.UART_RXD_EN = 0; Uart1_BTcom.UART_RXD_NUM_NOW = DMA_GetCurrDataCounter(DMA1_Channel5); Uart1_BTcom.UART_RXD_NUM_LAST = DMA_GetCurrDataCounter(DMA1_Channel5); Uart1_BTcom.UART_RXD_BEGIN_POST = 0; Uart1_BTcom.UART_RXD_END_POST = 0; Uart1_BTcom.UART_RXD_LENTH = 0; ////////////////////////////UART1 DMA串口发送配置 DMA1-4///////////////////////////////////// DMA_DeInit(DMA1_Channel4); DMA_InitStructure.DMA_PeripheralBaseAddr = (u32)SRC_USART1_DR; //源头BUF DMA_InitStructure.DMA_MemoryBaseAddr = (u32)Uart1_BTcom.UART_DMA_TXD_BUF; //目标BUF DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralDST; //内存作源头 DMA_InitStructure.DMA_BufferSize = UART_TXD_BUF_SIZE; //BUF大小 DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; //外设地址寄存器不递增 DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; //内存地址递增 DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte; //外设字节为单位 DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte; //内存字节为单位 DMA_InitStructure.DMA_Mode = DMA_Mode_Normal; //循环模式 DMA_InitStructure.DMA_Priority = DMA_Priority_High; //4优先级之一的(高优先) DMA_InitStructure.DMA_M2M = DMA_M2M_Disable; //非内存到内存 DMA_Init(DMA1_Channel4, &DMA_InitStructure); //DMA_ITConfig(DMA1_Channel5, DMA_IT_TC, ENABLE); //DMA5传输完成中断 USART_DMACmd(USART1, USART_DMAReq_Tx, ENABLE); //串口发送器DMA //DMA_Cmd(DMA1_Channel4, ENABLE); ////////////////////////////串口3配置///////////////////////////////////// /* PB10 USART3_Tx */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; //推挽输出-TX GPIO_Init(GPIOB, &GPIO_InitStructure); /* PB11 USART3_Rx */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;//浮空输入-RX GPIO_Init(GPIOB, &GPIO_InitStructure); USART_InitStructure.USART_BaudRate = 9600; USART_InitStructure.USART_WordLength = USART_WordLength_8b; USART_InitStructure.USART_StopBits = USART_StopBits_1; USART_InitStructure.USART_Parity = USART_Parity_No; USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; USART_ClockInitStructure.USART_Clock = USART_Clock_Disable; USART_ClockInitStructure.USART_CPOL = USART_CPOL_Low; USART_ClockInitStructure.USART_CPHA = USART_CPHA_2Edge; USART_ClockInitStructure.USART_LastBit = USART_LastBit_Disable; USART_ClockInit(USART3, &USART_ClockInitStructure); USART_Init(USART3, &USART_InitStructure); USART_Cmd(USART3, ENABLE); USART_ClearFlag(USART3, USART_FLAG_TC); /* ???????,Transmission Complete flag */ ////////////////////////////UART3 DMA?????? DMA1-3///////////////////////////////////// DMA_DeInit(DMA1_Channel3); DMA_InitStructure.DMA_PeripheralBaseAddr = (u32)SRC_USART3_DR; //??BUF DMA_InitStructure.DMA_MemoryBaseAddr = (u32)Uart3_Debug.UART_DMA_RXD_BUF_TEMP; //??BUF DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC; //????? DMA_InitStructure.DMA_BufferSize = UART_RXD_BUF_SIZE; //BUF?? DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; //?????????? DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; //?????? DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte; //??????? DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte; //??????? DMA_InitStructure.DMA_Mode = DMA_Mode_Circular; //???? DMA_InitStructure.DMA_Priority = DMA_Priority_High; //4??????(???) DMA_InitStructure.DMA_M2M = DMA_M2M_Disable; //?????? DMA_Init(DMA1_Channel3, &DMA_InitStructure); //DMA_ITConfig(DMA1_Channel3, DMA_IT_TC, ENABLE); //DMA5?????? USART_DMACmd(USART3, USART_DMAReq_Rx, ENABLE); //?????DMA DMA_Cmd(DMA1_Channel3, ENABLE); //????DMA Uart3_Debug.UART_RXD_FINISH = 0; Uart3_Debug.UART_RXD_EN = 0; Uart3_Debug.UART_RXD_NUM_NOW = DMA_GetCurrDataCounter(DMA1_Channel3); Uart3_Debug.UART_RXD_NUM_LAST = DMA_GetCurrDataCounter(DMA1_Channel3); Uart3_Debug.UART_RXD_BEGIN_POST = 0; Uart3_Debug.UART_RXD_END_POST = 0; Uart3_Debug.UART_RXD_LENTH = 0; ////////////////////////////UART3 DMA?????? DMA1-2///////////////////////////////////// DMA_DeInit(DMA1_Channel2); DMA_InitStructure.DMA_PeripheralBaseAddr = (u32)SRC_USART3_DR; //??BUF DMA_InitStructure.DMA_MemoryBaseAddr = (u32)Uart3_Debug.UART_DMA_TXD_BUF; //??BUF DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralDST; //????? DMA_InitStructure.DMA_BufferSize = UART_TXD_BUF_SIZE; //BUF?? DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; //?????????? DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; //?????? DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte; //??????? DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte; //??????? DMA_InitStructure.DMA_Mode = DMA_Mode_Normal; //???? DMA_InitStructure.DMA_Priority = DMA_Priority_High; //4??????(???) DMA_InitStructure.DMA_M2M = DMA_M2M_Disable; //?????? DMA_Init(DMA1_Channel2, &DMA_InitStructure); //DMA_ITConfig(DMA1_Channel2, DMA_IT_TC, ENABLE); //DMA5?????? USART_DMACmd(USART3, USART_DMAReq_Tx, ENABLE); //?????DMA //DMA_Cmd(DMA1_Channel2, ENABLE); ////////////////////////////////TIM3////////////////////////////////// TIM_DeInit(TIM3); TIM_TimeBaseInitStruct.TIM_ClockDivision = TIM_CKD_DIV1;//?????? TIM_TimeBaseInitStruct.TIM_CounterMode = TIM_CounterMode_Up;//?????? TIM_TimeBaseInitStruct.TIM_Prescaler = 5;// TIM_TimeBaseInitStruct.TIM_Period = 23999;// 500Hz TIM_TimeBaseInit(TIM3, &TIM_TimeBaseInitStruct); TIM_SelectOutputTrigger (TIM3, TIM_TRGOSource_Update); ////////////////////////////////ADC1////////////////////////////////// /* Configure ADCCLK such as ADCCLK = PCLK2/8 */ RCC_ADCCLKConfig(RCC_PCLK2_Div8); //HQ 72/8=9M //ADC1 ADC_DeInit(ADC1); ADC_InitStructure.ADC_Mode = ADC_Mode_Independent; //???? ADC_InitStructure.ADC_ScanConvMode = ENABLE; //??????? ADC_InitStructure.ADC_ContinuousConvMode = ENABLE; //???? //ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None; //???? ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_T3_TRGO; //20201229 ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right; //??? ADC_InitStructure.ADC_NbrOfChannel = 5; //?????? ADC_Init(ADC1, &ADC_InitStructure); /* ADC1 Regular Channel1 Configuration */ //TEMP CUR ADC_RegularChannelConfig(ADC1, ADC_Channel_10, 1, ADC_SampleTime_239Cycles5); //???????,239.5??? ADC_RegularChannelConfig(ADC1, ADC_Channel_11, 2, ADC_SampleTime_239Cycles5); //???????,239.5??? ADC_RegularChannelConfig(ADC1, ADC_Channel_13, 3, ADC_SampleTime_239Cycles5); //???????,239.5??? ADC_RegularChannelConfig(ADC1, ADC_Channel_0, 4, ADC_SampleTime_239Cycles5); //???????,239.5??? ADC_RegularChannelConfig(ADC1, ADC_Channel_1, 5, ADC_SampleTime_239Cycles5); //???????,239.5??? /* Enable ADC1 DMA */ ADC_DMACmd(ADC1, ENABLE); /* Enable ADC1 */ ADC_Cmd(ADC1, ENABLE); /* Enable ADC1 reset calibaration register */ ADC_ResetCalibration(ADC1); /* Check the end of ADC1 reset calibration register */ while(ADC_GetResetCalibrationStatus(ADC1)); /* Start ADC1 calibaration */ ADC_StartCalibration(ADC1); /* Check the end of ADC1 calibration */ while(ADC_GetCalibrationStatus(ADC1)); //////////////////////////////DMA??///////////////////////////////////////// /* DMA channel1 configuration ----------------------------------------------*/ DMA_DeInit(DMA1_Channel1); DMA_InitStructure.DMA_PeripheralBaseAddr = ADC1_DR_Address; DMA_InitStructure.DMA_MemoryBaseAddr = (u32)MFL_PARA_A.Ad_Data_Temp; DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC; DMA_InitStructure.DMA_BufferSize = 2500; //HQ DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord; DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord; DMA_InitStructure.DMA_Mode = DMA_Mode_Circular; DMA_InitStructure.DMA_Priority = DMA_Priority_High; DMA_InitStructure.DMA_M2M = DMA_M2M_Disable; DMA_Init(DMA1_Channel1, &DMA_InitStructure); //DMA_ITConfig(DMA1_Channel1, DMA_IT_TC, ENABLE); // /* Enable DMA channel1 */ DMA_Cmd(DMA1_Channel1, ENABLE); /* Start ADC1 Software Conversion */ // ADC_SoftwareStartConvCmd(ADC1, ENABLE); //HQ ???? ADC_ExternalTrigConvCmd(ADC1, ENABLE); TIM_Cmd(TIM3, ENABLE); //使能TIM3 20210306 } /*定义 fputc 此函数为printf所用*/ int fputc(int ch) { USART_SendData(USART1, (u8) ch); /* Loop until the end of transmission */ while(USART_GetFlagStatus(USART3, USART_FLAG_TXE) == RESET); return ch; }