parent
7def734dd6
commit
79a2af59e1
Binary file not shown.
@ -0,0 +1,81 @@ |
||||
/**
|
||||
****************************************************************************** |
||||
* File Name : ADC.h |
||||
* Description : This file provides code for the configuration |
||||
* of the ADC instances. |
||||
****************************************************************************** |
||||
** This notice applies to any and all portions of this file |
||||
* that are not between comment pairs USER CODE BEGIN and |
||||
* USER CODE END. Other portions of this file, whether
|
||||
* inserted by the user or by software development tools |
||||
* are owned by their respective copyright owners. |
||||
* |
||||
* COPYRIGHT(c) 2017 STMicroelectronics |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without modification, |
||||
* are permitted provided that the following conditions are met: |
||||
* 1. Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, |
||||
* this list of conditions and the following disclaimer in the documentation |
||||
* and/or other materials provided with the distribution. |
||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors |
||||
* may be used to endorse or promote products derived from this software |
||||
* without specific prior written permission. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
* |
||||
****************************************************************************** |
||||
*/ |
||||
/* Define to prevent recursive inclusion -------------------------------------*/ |
||||
#ifndef __adc_H |
||||
#define __adc_H |
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
/* Includes ------------------------------------------------------------------*/ |
||||
#include "stm32l0xx_hal.h" |
||||
#include "main.h" |
||||
|
||||
/* USER CODE BEGIN Includes */ |
||||
|
||||
/* USER CODE END Includes */ |
||||
|
||||
extern ADC_HandleTypeDef hadc; |
||||
|
||||
/* USER CODE BEGIN Private defines */ |
||||
|
||||
/* USER CODE END Private defines */ |
||||
|
||||
extern void _Error_Handler(char *, int); |
||||
|
||||
void MX_ADC_Init(void); |
||||
|
||||
/* USER CODE BEGIN Prototypes */ |
||||
|
||||
/* USER CODE END Prototypes */ |
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
#endif /*__ adc_H */ |
||||
|
||||
/**
|
||||
* @} |
||||
*/ |
||||
|
||||
/**
|
||||
* @} |
||||
*/ |
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@ -0,0 +1,78 @@ |
||||
/**
|
||||
****************************************************************************** |
||||
* File Name : dma.h |
||||
* Description : This file contains all the function prototypes for |
||||
* the dma.c file |
||||
****************************************************************************** |
||||
** This notice applies to any and all portions of this file |
||||
* that are not between comment pairs USER CODE BEGIN and |
||||
* USER CODE END. Other portions of this file, whether
|
||||
* inserted by the user or by software development tools |
||||
* are owned by their respective copyright owners. |
||||
* |
||||
* COPYRIGHT(c) 2017 STMicroelectronics |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without modification, |
||||
* are permitted provided that the following conditions are met: |
||||
* 1. Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, |
||||
* this list of conditions and the following disclaimer in the documentation |
||||
* and/or other materials provided with the distribution. |
||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors |
||||
* may be used to endorse or promote products derived from this software |
||||
* without specific prior written permission. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
* |
||||
****************************************************************************** |
||||
*/ |
||||
/* Define to prevent recursive inclusion -------------------------------------*/ |
||||
#ifndef __dma_H |
||||
#define __dma_H |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
/* Includes ------------------------------------------------------------------*/ |
||||
#include "stm32l0xx_hal.h" |
||||
#include "main.h" |
||||
|
||||
/* DMA memory to memory transfer handles -------------------------------------*/ |
||||
extern void _Error_Handler(char*, int); |
||||
|
||||
/* 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 */ |
||||
|
||||
/**
|
||||
* @} |
||||
*/ |
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@ -0,0 +1,81 @@ |
||||
/**
|
||||
****************************************************************************** |
||||
* File Name : TIM.h |
||||
* Description : This file provides code for the configuration |
||||
* of the TIM instances. |
||||
****************************************************************************** |
||||
** This notice applies to any and all portions of this file |
||||
* that are not between comment pairs USER CODE BEGIN and |
||||
* USER CODE END. Other portions of this file, whether
|
||||
* inserted by the user or by software development tools |
||||
* are owned by their respective copyright owners. |
||||
* |
||||
* COPYRIGHT(c) 2017 STMicroelectronics |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without modification, |
||||
* are permitted provided that the following conditions are met: |
||||
* 1. Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, |
||||
* this list of conditions and the following disclaimer in the documentation |
||||
* and/or other materials provided with the distribution. |
||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors |
||||
* may be used to endorse or promote products derived from this software |
||||
* without specific prior written permission. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
* |
||||
****************************************************************************** |
||||
*/ |
||||
/* Define to prevent recursive inclusion -------------------------------------*/ |
||||
#ifndef __tim_H |
||||
#define __tim_H |
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
/* Includes ------------------------------------------------------------------*/ |
||||
#include "stm32l0xx_hal.h" |
||||
#include "main.h" |
||||
|
||||
/* USER CODE BEGIN Includes */ |
||||
|
||||
/* USER CODE END Includes */ |
||||
|
||||
extern TIM_HandleTypeDef htim2; |
||||
|
||||
/* USER CODE BEGIN Private defines */ |
||||
|
||||
/* USER CODE END Private defines */ |
||||
|
||||
extern void _Error_Handler(char *, int); |
||||
|
||||
void MX_TIM2_Init(void); |
||||
|
||||
/* USER CODE BEGIN Prototypes */ |
||||
|
||||
/* USER CODE END Prototypes */ |
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
#endif /*__ tim_H */ |
||||
|
||||
/**
|
||||
* @} |
||||
*/ |
||||
|
||||
/**
|
||||
* @} |
||||
*/ |
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@ -0,0 +1,173 @@ |
||||
/**
|
||||
****************************************************************************** |
||||
* File Name : ADC.c |
||||
* Description : This file provides code for the configuration |
||||
* of the ADC instances. |
||||
****************************************************************************** |
||||
** This notice applies to any and all portions of this file |
||||
* that are not between comment pairs USER CODE BEGIN and |
||||
* USER CODE END. Other portions of this file, whether
|
||||
* inserted by the user or by software development tools |
||||
* are owned by their respective copyright owners. |
||||
* |
||||
* COPYRIGHT(c) 2017 STMicroelectronics |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without modification, |
||||
* are permitted provided that the following conditions are met: |
||||
* 1. Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, |
||||
* this list of conditions and the following disclaimer in the documentation |
||||
* and/or other materials provided with the distribution. |
||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors |
||||
* may be used to endorse or promote products derived from this software |
||||
* without specific prior written permission. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
* |
||||
****************************************************************************** |
||||
*/ |
||||
|
||||
/* Includes ------------------------------------------------------------------*/ |
||||
#include "adc.h" |
||||
|
||||
//#include "gpio.h"
|
||||
#include "dma.h" |
||||
|
||||
/* USER CODE BEGIN 0 */ |
||||
|
||||
/* USER CODE END 0 */ |
||||
|
||||
ADC_HandleTypeDef hadc; |
||||
DMA_HandleTypeDef hdma_adc; |
||||
|
||||
/* ADC init function */ |
||||
void MX_ADC_Init(void) |
||||
{ |
||||
ADC_ChannelConfTypeDef sConfig; |
||||
|
||||
/**Configure the global features of the ADC (Clock, Resolution, Data Alignment and number of conversion)
|
||||
*/ |
||||
hadc.Instance = ADC1; |
||||
hadc.Init.OversamplingMode = DISABLE; |
||||
hadc.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV2; |
||||
hadc.Init.Resolution = ADC_RESOLUTION_12B; |
||||
hadc.Init.SamplingTime = ADC_SAMPLETIME_12CYCLES_5; |
||||
hadc.Init.ScanConvMode = ADC_SCAN_DIRECTION_FORWARD; |
||||
hadc.Init.DataAlign = ADC_DATAALIGN_RIGHT; |
||||
hadc.Init.ContinuousConvMode = DISABLE; |
||||
hadc.Init.DiscontinuousConvMode = DISABLE; |
||||
hadc.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_RISING; |
||||
hadc.Init.ExternalTrigConv = ADC_EXTERNALTRIGCONV_T2_TRGO; |
||||
hadc.Init.DMAContinuousRequests = DISABLE; |
||||
hadc.Init.EOCSelection = ADC_EOC_SINGLE_CONV; |
||||
hadc.Init.Overrun = ADC_OVR_DATA_PRESERVED; |
||||
hadc.Init.LowPowerAutoWait = DISABLE; |
||||
hadc.Init.LowPowerFrequencyMode = DISABLE; |
||||
hadc.Init.LowPowerAutoPowerOff = DISABLE; |
||||
if (HAL_ADC_Init(&hadc) != HAL_OK) |
||||
{ |
||||
_Error_Handler(__FILE__, __LINE__); |
||||
} |
||||
|
||||
/**Configure for the selected ADC regular channel to be converted.
|
||||
*/ |
||||
sConfig.Channel = ADC_CHANNEL_1; |
||||
sConfig.Rank = ADC_RANK_CHANNEL_NUMBER; |
||||
if (HAL_ADC_ConfigChannel(&hadc, &sConfig) != HAL_OK) |
||||
{ |
||||
_Error_Handler(__FILE__, __LINE__); |
||||
} |
||||
|
||||
} |
||||
|
||||
void HAL_ADC_MspInit(ADC_HandleTypeDef* adcHandle) |
||||
{ |
||||
|
||||
GPIO_InitTypeDef GPIO_InitStruct; |
||||
if(adcHandle->Instance==ADC1) |
||||
{ |
||||
/* USER CODE BEGIN ADC1_MspInit 0 */ |
||||
|
||||
/* USER CODE END ADC1_MspInit 0 */ |
||||
/* ADC1 clock enable */ |
||||
__HAL_RCC_ADC1_CLK_ENABLE(); |
||||
|
||||
/**ADC GPIO Configuration
|
||||
PA0 ------> ADC_IN0
|
||||
*/ |
||||
GPIO_InitStruct.Pin = GPIO_PIN_1; |
||||
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; |
||||
GPIO_InitStruct.Pull = GPIO_NOPULL; |
||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); |
||||
|
||||
/* ADC1 DMA Init */ |
||||
/* ADC Init */ |
||||
hdma_adc.Instance = DMA1_Channel1; |
||||
hdma_adc.Init.Request = DMA_REQUEST_0; |
||||
hdma_adc.Init.Direction = DMA_PERIPH_TO_MEMORY; |
||||
hdma_adc.Init.PeriphInc = DMA_PINC_DISABLE; |
||||
hdma_adc.Init.MemInc = DMA_MINC_ENABLE; |
||||
hdma_adc.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD; |
||||
hdma_adc.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD; |
||||
hdma_adc.Init.Mode = DMA_NORMAL; |
||||
hdma_adc.Init.Priority = DMA_PRIORITY_HIGH; |
||||
if (HAL_DMA_Init(&hdma_adc) != HAL_OK) |
||||
{ |
||||
_Error_Handler(__FILE__, __LINE__); |
||||
} |
||||
|
||||
__HAL_LINKDMA(adcHandle,DMA_Handle,hdma_adc); |
||||
|
||||
/* USER CODE BEGIN ADC1_MspInit 1 */ |
||||
|
||||
/* USER CODE END ADC1_MspInit 1 */ |
||||
} |
||||
} |
||||
|
||||
void HAL_ADC_MspDeInit(ADC_HandleTypeDef* adcHandle) |
||||
{ |
||||
|
||||
if(adcHandle->Instance==ADC1) |
||||
{ |
||||
/* USER CODE BEGIN ADC1_MspDeInit 0 */ |
||||
|
||||
/* USER CODE END ADC1_MspDeInit 0 */ |
||||
/* Peripheral clock disable */ |
||||
__HAL_RCC_ADC1_CLK_DISABLE(); |
||||
|
||||
/**ADC GPIO Configuration
|
||||
PA0 ------> ADC_IN0
|
||||
*/ |
||||
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_1); |
||||
|
||||
/* ADC1 DMA DeInit */ |
||||
HAL_DMA_DeInit(adcHandle->DMA_Handle); |
||||
/* USER CODE BEGIN ADC1_MspDeInit 1 */ |
||||
|
||||
/* USER CODE END ADC1_MspDeInit 1 */ |
||||
} |
||||
}
|
||||
|
||||
/* USER CODE BEGIN 1 */ |
||||
|
||||
/* USER CODE END 1 */ |
||||
|
||||
/**
|
||||
* @} |
||||
*/ |
||||
|
||||
/**
|
||||
* @} |
||||
*/ |
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
File diff suppressed because one or more lines are too long
@ -0,0 +1,25 @@ |
||||
/*
|
||||
* audio.h |
||||
* |
||||
* Created on: Dec 31, 2017 |
||||
* Author: ondra |
||||
*/ |
||||
|
||||
#ifndef SRC_AUDIO_H_ |
||||
#define SRC_AUDIO_H_ |
||||
|
||||
#include <stdint.h> |
||||
#include <stdbool.h> |
||||
|
||||
|
||||
/** A detected peak struct */ |
||||
struct peak { |
||||
float position; // precise position, unit is 1 bin
|
||||
float magnitude; // precise magnitude
|
||||
float weight; // sorting weight (internal use)
|
||||
}; |
||||
|
||||
void audio_capture(struct peak *peaks, uint32_t pcount, float *noise, float *totalpower) ; |
||||
|
||||
|
||||
#endif /* SRC_AUDIO_H_ */ |
@ -0,0 +1,81 @@ |
||||
/**
|
||||
****************************************************************************** |
||||
* File Name : dma.c |
||||
* Description : This file provides code for the configuration |
||||
* of all the requested memory to memory DMA transfers. |
||||
****************************************************************************** |
||||
** This notice applies to any and all portions of this file |
||||
* that are not between comment pairs USER CODE BEGIN and |
||||
* USER CODE END. Other portions of this file, whether
|
||||
* inserted by the user or by software development tools |
||||
* are owned by their respective copyright owners. |
||||
* |
||||
* COPYRIGHT(c) 2017 STMicroelectronics |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without modification, |
||||
* are permitted provided that the following conditions are met: |
||||
* 1. Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, |
||||
* this list of conditions and the following disclaimer in the documentation |
||||
* and/or other materials provided with the distribution. |
||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors |
||||
* may be used to endorse or promote products derived from this software |
||||
* without specific prior written permission. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
* |
||||
****************************************************************************** |
||||
*/ |
||||
/* 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_Channel1_IRQn interrupt configuration */ |
||||
HAL_NVIC_SetPriority(DMA1_Channel1_IRQn, 0, 0); |
||||
HAL_NVIC_EnableIRQ(DMA1_Channel1_IRQn); |
||||
|
||||
} |
||||
|
||||
/* USER CODE BEGIN 2 */ |
||||
|
||||
/* USER CODE END 2 */ |
||||
|
||||
/**
|
||||
* @} |
||||
*/ |
||||
|
||||
/**
|
||||
* @} |
||||
*/ |
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@ -0,0 +1,124 @@ |
||||
/**
|
||||
****************************************************************************** |
||||
* File Name : TIM.c |
||||
* Description : This file provides code for the configuration |
||||
* of the TIM instances. |
||||
****************************************************************************** |
||||
** This notice applies to any and all portions of this file |
||||
* that are not between comment pairs USER CODE BEGIN and |
||||
* USER CODE END. Other portions of this file, whether
|
||||
* inserted by the user or by software development tools |
||||
* are owned by their respective copyright owners. |
||||
* |
||||
* COPYRIGHT(c) 2017 STMicroelectronics |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without modification, |
||||
* are permitted provided that the following conditions are met: |
||||
* 1. Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, |
||||
* this list of conditions and the following disclaimer in the documentation |
||||
* and/or other materials provided with the distribution. |
||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors |
||||
* may be used to endorse or promote products derived from this software |
||||
* without specific prior written permission. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
* |
||||
****************************************************************************** |
||||
*/ |
||||
|
||||
/* Includes ------------------------------------------------------------------*/ |
||||
#include "tim.h" |
||||
|
||||
/* USER CODE BEGIN 0 */ |
||||
|
||||
/* USER CODE END 0 */ |
||||
|
||||
TIM_HandleTypeDef htim2; |
||||
|
||||
/* TIM2 init function */ |
||||
void MX_TIM2_Init(void) |
||||
{ |
||||
TIM_ClockConfigTypeDef sClockSourceConfig; |
||||
TIM_MasterConfigTypeDef sMasterConfig; |
||||
|
||||
htim2.Instance = TIM2; |
||||
htim2.Init.Prescaler = 10; |
||||
htim2.Init.CounterMode = TIM_COUNTERMODE_UP; |
||||
htim2.Init.Period = 54; |
||||
htim2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; |
||||
if (HAL_TIM_Base_Init(&htim2) != HAL_OK) |
||||
{ |
||||
_Error_Handler(__FILE__, __LINE__); |
||||
} |
||||
|
||||
sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL; |
||||
if (HAL_TIM_ConfigClockSource(&htim2, &sClockSourceConfig) != HAL_OK) |
||||
{ |
||||
_Error_Handler(__FILE__, __LINE__); |
||||
} |
||||
|
||||
sMasterConfig.MasterOutputTrigger = TIM_TRGO_UPDATE; |
||||
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; |
||||
if (HAL_TIMEx_MasterConfigSynchronization(&htim2, &sMasterConfig) != HAL_OK) |
||||
{ |
||||
_Error_Handler(__FILE__, __LINE__); |
||||
} |
||||
|
||||
} |
||||
|
||||
void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* tim_baseHandle) |
||||
{ |
||||
|
||||
if(tim_baseHandle->Instance==TIM2) |
||||
{ |
||||
/* USER CODE BEGIN TIM2_MspInit 0 */ |
||||
|
||||
/* USER CODE END TIM2_MspInit 0 */ |
||||
/* TIM2 clock enable */ |
||||
__HAL_RCC_TIM2_CLK_ENABLE(); |
||||
/* USER CODE BEGIN TIM2_MspInit 1 */ |
||||
|
||||
/* USER CODE END TIM2_MspInit 1 */ |
||||
} |
||||
} |
||||
|
||||
void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* tim_baseHandle) |
||||
{ |
||||
|
||||
if(tim_baseHandle->Instance==TIM2) |
||||
{ |
||||
/* USER CODE BEGIN TIM2_MspDeInit 0 */ |
||||
|
||||
/* USER CODE END TIM2_MspDeInit 0 */ |
||||
/* Peripheral clock disable */ |
||||
__HAL_RCC_TIM2_CLK_DISABLE(); |
||||
/* USER CODE BEGIN TIM2_MspDeInit 1 */ |
||||
|
||||
/* USER CODE END TIM2_MspDeInit 1 */ |
||||
} |
||||
}
|
||||
|
||||
/* USER CODE BEGIN 1 */ |
||||
|
||||
/* USER CODE END 1 */ |
||||
|
||||
/**
|
||||
* @} |
||||
*/ |
||||
|
||||
/**
|
||||
* @} |
||||
*/ |
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
Loading…
Reference in new issue