STM32F3系列固件库模板


根据STM32F1系列建立固件的步骤,自己建了个F3的固件库模板,方便大家使用。里面附带一个DAC输出例程。
资源截图
代码片段和文件信息
#include “bsp_dac.h“

TIM_TimebaseInitTypeDef    TIM_TimebaseStructure;
DAC_InitTypeDef            DAC_InitStructure;
DMA_InitTypeDef            DMA_InitStructure;
const uint16_t Sine12bit[32] = {
                      2047 2447 2831 3185 3498 3750 3939 4056 4095 4056
                      3939 3750 3495 3185 2831 2447 2047 1647 1263  909 
                       599  344  155   38    0   38  155  344  599  909 
                      1263 1647};   
const uint8_t Escalator8bit[6] = {0x0 0x33 0x66 0x99 0xCC 0xFF};
uint8_t Idx = 0;
__IO uint8_t  SelectedWavesForm = 1;
__IO uint8_t WaveChange = 1; 

/* Private function prototypes -----------------------------------------------*/
static void DAC_Config(void);
static void TIM_Config(void);

/**
  * @brief  TIM2 configuration to trigger DAC conversion 

  * @param  None
  * @retval None
  */
static void TIM_Config(void)
{
  TIM_TimebaseInitTypeDef    TIM_TimebaseStructure;
  
  /* TIM2 Periph clock enable */
  RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2 ENABLE);
  
  /* Time base configuration */
  TIM_TimebaseStructInit(&TIM_TimebaseStructure); 
  TIM_TimebaseStructure.TIM_Period = 1000-1;          //100us*1000
  TIM_TimebaseStructure.TIM_Prescaler = 720-1;//7200-1;       //100
  TIM_TimebaseStructure.TIM_ClockDivision = 0x0;    
  TIM_TimebaseStructure.TIM_CounterMode = TIM_CounterMode_Up;  
  TIM_TimebaseInit(TIM2 &TIM_TimebaseStructure);

  /* TIM2 TRGO selection */
  TIM_SelectOutputTrigger(TIM2 TIM_TRGOSource_Update);
  
  /* TIM2 enable counter */
  TIM_Cmd(TIM2 ENABLE);
}

/**
  * @brief  DAC channels configurations (PA4 and PA5 in analog
  *                           enable DAC clock enable DMA2 clock)
  * @param  None
  * @retval None
  */
static void DAC_Config(void)
{
  GPIO_InitTypeDef GPIO_InitStructure;

  /* DMA2 clock enable (to be used with DAC) */
  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA2 ENABLE);

  /* DAC Periph clock enable */
  RCC_APB1PeriphClockCmd(RCC_APB1Periph_DAC ENABLE);

  /* GPIOA clock enable */
  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA ENABLE);
  
  /* Configure PA.05 (DAC_OUT1) as analog */
  GPIO_InitStructure.GPIO_Pin =  GPIO_Pin_5;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
  GPIO_Init(GPIOA &GPIO_InitStructure);
}

void DAC_Test_init(void)
{
TIM_Config();
DAC_Config();

          /* DAC channel2 Configuration */
          DAC_DeInit(DAC1); 
          DAC_InitStructure.DAC_Trigger = DAC_Trigger_T2_TRGO;
          DAC_InitStructure.DAC_WaveGeneration = DAC_WaveGeneration_None;
          DAC_InitStructure.DAC_Buffer_Switch = DAC_BufferSwitch_Disable;

          /* DAC Channel2 Init */
          DAC_Init(DAC1 DAC_Channel_2 &DAC_InitStructure);

          /* Enable DAC Channel2 */
          DAC_Cmd(DAC1 DAC_Channel_2 ENABLE);
          
          /* DMA2 channel3 configurati

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        211  2018-09-08 17:13  STM32F3_Templatespincsp_dac.h

     文件       5197  2018-09-09 16:45  STM32F3_Templatespsrcsp_dac.c

     文件     726626  2015-07-08 19:34  STM32F3_TemplateLibrariesCMSISDeviceSTSTM32F30xIncludestm32f30x.h

     文件       2208  2015-07-08 19:34  STM32F3_TemplateLibrariesCMSISDeviceSTSTM32F30xIncludesystem_stm32f30x.h

     文件      24343  2015-07-08 19:34  STM32F3_TemplateLibrariesCMSISDeviceSTSTM32F30xRelease_Notes.html

     文件      23799  2015-07-08 19:34  STM32F3_TemplateLibrariesCMSISDeviceSTSTM32F30xSourceTemplatesarmstartup_stm32f302x8.s

     文件      26343  2015-07-08 19:34  STM32F3_TemplateLibrariesCMSISDeviceSTSTM32F30xSourceTemplatesarmstartup_stm32f303xc.s

     文件      27310  2015-07-08 19:34  STM32F3_TemplateLibrariesCMSISDeviceSTSTM32F30xSourceTemplatesarmstartup_stm32f303xe.s

     文件      26339  2015-07-08 19:34  STM32F3_TemplateLibrariesCMSISDeviceSTSTM32F30xSourceTemplatesarmstartup_stm32f30x.s

     文件      22159  2015-07-08 19:34  STM32F3_TemplateLibrariesCMSISDeviceSTSTM32F30xSourceTemplatesarmstartup_stm32f334x8.s

     文件      13163  2015-07-08 19:34  STM32F3_TemplateLibrariesCMSISDeviceSTSTM32F30xSourceTemplatesgcc_ride7startup_stm32f30x.s

     文件      21190  2015-07-08 19:34  STM32F3_TemplateLibrariesCMSISDeviceSTSTM32F30xSourceTemplatesiarstartup_stm32f302x8.s

     文件      23551  2015-07-08 19:34  STM32F3_TemplateLibrariesCMSISDeviceSTSTM32F30xSourceTemplatesiarstartup_stm32f303xc.s

     文件      24856  2015-07-08 19:34  STM32F3_TemplateLibrariesCMSISDeviceSTSTM32F30xSourceTemplatesiarstartup_stm32f303xe.s

     文件      23547  2015-07-08 19:34  STM32F3_TemplateLibrariesCMSISDeviceSTSTM32F30xSourceTemplatesiarstartup_stm32f30x.s

     文件      21307  2015-07-08 19:34  STM32F3_TemplateLibrariesCMSISDeviceSTSTM32F30xSourceTemplatesiarstartup_stm32f334x8.s

     文件      14043  2015-07-08 19:34  STM32F3_TemplateLibrariesCMSISDeviceSTSTM32F30xSourceTemplatessystem_stm32f30x.c

     文件      11442  2015-07-08 19:34  STM32F3_TemplateLibrariesCMSISDeviceSTSTM32F30xSourceTemplatesTrueSTUDIOstartup_stm32f302x8.s

     文件      12969  2015-07-08 19:34  STM32F3_TemplateLibrariesCMSISDeviceSTSTM32F30xSourceTemplatesTrueSTUDIOstartup_stm32f303xc.s

     文件      13784  2015-07-08 19:34  STM32F3_TemplateLibrariesCMSISDeviceSTSTM32F30xSourceTemplatesTrueSTUDIOstartup_stm32f303xe.s

     文件      12967  2015-07-08 19:34  STM32F3_TemplateLibrariesCMSISDeviceSTSTM32F30xSourceTemplatesTrueSTUDIOstartup_stm32f30x.s

     文件      12054  2015-07-08 19:34  STM32F3_TemplateLibrariesCMSISDeviceSTSTM32F30xSourceTemplatesTrueSTUDIOstartup_stm32f334x8.s

     文件       8440  2015-07-08 19:34  STM32F3_TemplateLibrariesCMSISDSP_LibExamplesarm_class_marks_exampleARMarm_class_marks_example_f32.c

     文件       8440  2015-07-08 19:34  STM32F3_TemplateLibrariesCMSISDSP_LibExamplesarm_class_marks_exampleGCCarm_class_marks_example_f32.c

     文件      11097  2015-07-08 19:34  STM32F3_TemplateLibrariesCMSISDSP_LibExamplesarm_convolution_exampleARMarm_convolution_example_f32.c

     文件      10962  2015-07-08 19:34  STM32F3_TemplateLibrariesCMSISDSP_LibExamplesarm_convolution_exampleARMmath_helper.c

     文件       3085  2015-07-08 19:34  STM32F3_TemplateLibrariesCMSISDSP_LibExamplesarm_convolution_exampleARMmath_helper.h

     文件      11097  2015-07-08 19:34  STM32F3_TemplateLibrariesCMSISDSP_LibExamplesarm_convolution_exampleGCCarm_convolution_example_f32.c

     文件      10962  2015-07-08 19:34  STM32F3_TemplateLibrariesCMSISDSP_LibExamplesarm_convolution_exampleGCCmath_helper.c

     文件       3085  2015-07-08 19:34  STM32F3_TemplateLibrariesCMSISDSP_LibExamplesarm_convolution_exampleGCCmath_helper.h

............此处省略656个文件信息

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)