OpenEdv-开源电子网

 找回密码
 立即注册
正点原子全套STM32/Linux/FPGA开发资料,上千讲STM32视频教程免费下载...
查看: 2165|回复: 3

初学STM32,想请教下一般程序库函数中的函数是怎么调用的,写程序时怎么知道需要对应外设库中的那些函数?

[复制链接]

2

主题

4

帖子

0

精华

新手上路

积分
25
金钱
25
注册时间
2018-6-23
在线时间
3 小时
发表于 2018-6-23 16:11:09 | 显示全部楼层 |阅读模式
1金钱

        TIM_TimeBaseStructure.TIM_Period = arr; //设置在下一个更新事件装入活动的自动重装载寄存器周期的值         80K
        TIM_TimeBaseStructure.TIM_Prescaler =0; //设置用来作为TIMx时钟频率除数的预分频值  不分频
        TIM_TimeBaseStructure.TIM_ClockDivision =0; //设置时钟分割:TDTS = Tck_tim
        TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;  //TIM向上计数模式
        TIM_TimeBaseInit(TIM1, &TIM_TimeBaseStructure); //根据TIM_TimeBaseInitStruct中指定的参数初始化TIMx的时间基数单位




        比如定时器的配置,你们怎么调用这些代码的?

最佳答案

查看完整内容[请看2#楼]

《STM32固件库使用手册的中文翻译版》,原子的开发板资料已经有。 写多了之后很多就不用再看手册了。比如stm32f10x_gpio.h文件末尾, void GPIO_DeInit(GPIO_TypeDef* GPIOx); void GPIO_AFIODeInit(void); void GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_InitTypeDef* GPIO_InitStruct); void GPIO_StructInit(GPIO_InitTypeDef* GPIO_InitStruct); uint8_t GPIO_ReadInputDataBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin); u ...
正点原子逻辑分析仪DL16劲爆上市
回复

使用道具 举报

0

主题

28

帖子

0

精华

中级会员

Rank: 3Rank: 3

积分
319
金钱
319
注册时间
2017-6-19
在线时间
64 小时
发表于 2018-6-23 16:11:10 | 显示全部楼层
《STM32固件库使用手册的中文翻译版》,原子的开发板资料已经有。
写多了之后很多就不用再看手册了。比如stm32f10x_gpio.h文件末尾,
void GPIO_DeInit(GPIO_TypeDef* GPIOx);
void GPIO_AFIODeInit(void);
void GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_InitTypeDef* GPIO_InitStruct);
void GPIO_StructInit(GPIO_InitTypeDef* GPIO_InitStruct);
uint8_t GPIO_ReadInputDataBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);
uint16_t GPIO_ReadInputData(GPIO_TypeDef* GPIOx);
uint8_t GPIO_ReadOutputDataBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);
uint16_t GPIO_ReadOutputData(GPIO_TypeDef* GPIOx);
void GPIO_SetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);
void GPIO_ResetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);
void GPIO_WriteBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, BitAction BitVal);
void GPIO_Write(GPIO_TypeDef* GPIOx, uint16_t PortVal);
void GPIO_PinLockConfig(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);
void GPIO_EventOutputConfig(uint8_t GPIO_PortSource, uint8_t GPIO_PinSource);
void GPIO_EventOutputCmd(FunctionalState NewState);
void GPIO_PinRemapConfig(uint32_t GPIO_Remap, FunctionalState NewState);
void GPIO_EXTILineConfig(uint8_t GPIO_PortSource, uint8_t GPIO_PinSource);
void GPIO_ETH_MediaInterfaceConfig(uint32_t GPIO_ETH_MediaInterface);
可以调用的函数的声明都在这里了,进去看GPIO_Init函数本体,注释会告诉你怎么填参数。

/**
  * @brief  Initializes the GPIOx peripheral according to the specified
  *         parameters in the GPIO_InitStruct.
  * @param  GPIOx: where x can be (A..G) to select the GPIO peripheral.
  * @param  GPIO_InitStruct: pointer to a GPIO_InitTypeDef structure that
  *         contains the configuration information for the specified GPIO peripheral.
  * @retval None
  */
void GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_InitTypeDef* GPIO_InitStruct)
回复

使用道具 举报

2

主题

168

帖子

0

精华

中级会员

Rank: 3Rank: 3

积分
336
金钱
336
注册时间
2018-5-14
在线时间
69 小时
发表于 2018-6-23 16:48:07 | 显示全部楼层
有一种东西,叫做数据手册。
据说,程序员看了它,就能无所不知。
回复

使用道具 举报

31

主题

1954

帖子

3

精华

论坛元老

Rank: 8Rank: 8

积分
4510
金钱
4510
注册时间
2018-5-11
在线时间
944 小时
发表于 2018-6-23 17:13:00 | 显示全部楼层
除了楼上说的数据手册以外,
还有一种就是多看别人现成的代码,
你也可以抄用,天下文章一大抄,不过,最好抄的同时,知其所以然。
到最后你实然发现,你自己也会编了。
所谓熟读唐诗三百首,不会XX也会X
我的开源链接 https://github.com/ShuifaHe/STM32.git  请关注,点赞支持哦。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则



关闭

原子哥极力推荐上一条 /2 下一条

正点原子公众号

QQ|手机版|OpenEdv-开源电子网 ( 粤ICP备12000418号-1 )

GMT+8, 2025-5-26 02:43

Powered by OpenEdv-开源电子网

© 2001-2030 OpenEdv-开源电子网

快速回复 返回顶部 返回列表