“TIM Linux driver”的版本间的差异
来自百问网嵌入式Linux wiki
(未显示同一用户的3个中间版本) | |||
第48行: | 第48行: | ||
== How to trace and debug == | == How to trace and debug == | ||
− | + | Linux驱动程序“ TIM”<ref name="TIM internal peripheral"/> 可以通过REGMAP访问定时器寄存器。 | |
+ | |||
+ | 它带有debugfs <ref name="debugfs">[[Debugfs]]</ref>条目,这些条目允许转储寄存器: | ||
+ | |||
− | |||
− | |||
$ ls | $ ls | ||
40004000.timer 44000000.timer | 40004000.timer 44000000.timer | ||
第63行: | 第64行: | ||
... | ... | ||
− | + | 它还带有tracepoints <ref name="ftrace">[[Ftrace]]</ref>: | |
$ cd /sys/kernel/debug/tracing | $ cd /sys/kernel/debug/tracing | ||
$ cat available_events | grep regmap | $ cat available_events | grep regmap | ||
第71行: | 第72行: | ||
== Source code location == | == Source code location == | ||
− | + | TIM Linux驱动程序源代码包括: | |
− | * {{CodeSource | Linux kernel | drivers/mfd/stm32-timers.c | stm32-timers.c MFD driver}} | + | * {{CodeSource | Linux kernel | drivers/mfd/stm32-timers.c | stm32-timers.c MFD driver}} 处理常见资源:寄存器,时钟,dmas。 |
− | * {{CodeSource | Linux kernel | drivers/pwm/pwm-stm32.c | pwm-stm32.c PWM driver}} | + | * {{CodeSource | Linux kernel | drivers/pwm/pwm-stm32.c | pwm-stm32.c PWM driver}} 要处理PWM通道,请执行以下操作. |
− | * {{CodeSource | Linux kernel | drivers/iio/trigger/stm32-timer-trigger.c | stm32-timer-trigger.c IIO driver}} | + | * {{CodeSource | Linux kernel | drivers/iio/trigger/stm32-timer-trigger.c | stm32-timer-trigger.c IIO driver}} 来处理其他内部外设和正交编码器接口的触发源。 |
− | * {{CodeSource | Linux kernel | include/linux/mfd/stm32-timers.h}} and {{CodeSource | Linux kernel | include/linux/iio/timer/stm32-timer-trigger.h}} | + | * {{CodeSource | Linux kernel | include/linux/mfd/stm32-timers.h}} and {{CodeSource | Linux kernel | include/linux/iio/timer/stm32-timer-trigger.h}} 头文件 |
==References== | ==References== | ||
<references /> | <references /> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− |
2020年11月10日 (二) 10:41的最新版本
目录
Article purpose
本文介绍了用于TIM内部外围设备的TIM Linux® 驱动程序[1]:
- 驱动程序支持哪些TIM功能
- 如何配置,使用和调试驱动程序
- 驱动程序的结构是什么,以及在哪里可以找到源代码。
Short description
Linux驱动程序(内核空间)“ TIM” [1] 基于 PWM 和 IIO 框架。 它提供了几种功能:
MFD驱动程序:
- 处理寄存器,时钟和DMA[2]资源
- 检测TIM计数器分辨率,例如 16或32位。
PWM驱动器:
- 检测TIM通道数。
- 处理PWM输出通道。
- 处理PWM捕捉通道(输入)。 请注意,PWM捕获依赖于由MFD内核处理的DMA。
IIO 驱动程序:
Configuration
Kernel configuration
使用Linux Menuconfig工具在内核配置中激活TIM驱动程序[1]Menuconfig or how to configure kernel.
启用以下配置(及其依赖项)
- CONFIG_MFD_STM32_TIMERS
- CONFIG_PWM_STM32
- CONFIG_IIO_STM32_TIMER_TRIGGER
Device Drivers ---> -> Multifunction device drivers ---> <*> Support for STM32 Timers -> Pulse-width modulation (PWM) support ---> <*> STMicroelectronics STM32 PWM -> Industrial I/O support ---> -> Triggers - standalone ---> <*> STM32 timer trigger
Device tree
配置TIM Linux内核驱动程序时,请参阅TIM device tree configuration 文章。
How to use
How to use PWM with sysfs interface
How to set up a TIM or LPTIM trigger using the sysfs interface
How to trace and debug
Linux驱动程序“ TIM”[1] 可以通过REGMAP访问定时器寄存器。
它带有debugfs [7]条目,这些条目允许转储寄存器:
$ ls 40004000.timer 44000000.timer $ cd 44000000.timer $ cat registers 000: 00000081 004: 00000000 008: 00000000 00c: 00000000 ...
它还带有tracepoints [8]:
$ cd /sys/kernel/debug/tracing $ cat available_events | grep regmap ... regmap:regmap_reg_read regmap:regmap_reg_write
Source code location
TIM Linux驱动程序源代码包括:
- drivers/mfd/stm32-timers.c | |}} stm32-timers.c MFD driver 处理常见资源:寄存器,时钟,dmas。
- drivers/pwm/pwm-stm32.c | |}} pwm-stm32.c PWM driver 要处理PWM通道,请执行以下操作.
- drivers/iio/trigger/stm32-timer-trigger.c | |}} stm32-timer-trigger.c IIO driver 来处理其他内部外设和正交编码器接口的触发源。
- include/linux/mfd/stm32-timers.h| |}} include/linux/mfd/stm32-timers.h and include/linux/iio/timer/stm32-timer-trigger.h| |}} include/linux/iio/timer/stm32-timer-trigger.h 头文件
References
- ↑ 1.01.11.21.3 TIM internal peripheral
- ↑ DMA_internal_peripheral
- ↑ ADC internal peripheral
- ↑ DAC internal peripheral
- ↑ DFSDM internal peripheral
- ↑ Incremental encoder Incremental encoder overview
- ↑ 调试文件系统(debugfs)
- ↑ Ftrace