程序注解 - OMAP-L138 - 嵌入式开发者社区 - 51ele.net
设为首页收藏本站

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 7005|回复: 0
打印 上一主题 下一主题

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。( x  x6 |8 \1 j1 U, X( K. w2 o
#include <linux/init.h>% o$ s1 Q3 O& T2 k( G% D$ `3 c
#include <linux/module.h>3 ]* Z  R# Y& {" ^3 U
#include <linux/kernel.h>: c) o3 i0 ^( [, |3 _" x
#include <linux/types.h>4 h5 ~) {& I" T0 X+ G- u$ O
#include <linux/gpio.h>/ S% P/ S& T3 c* t0 K
#include <linux/leds.h>
" ]4 L+ T( a" B" o#include <linux/platform_device.h>
# i+ s# \! [: p" C6 O1 R' T7 w
2 }, o. o1 S/ x- H8 Q* Z#include <asm/mach-types.h>$ z& Q& T& g' F2 s2 p& V
#include <asm/mach/arch.h>' V, x- B: U7 Z7 Z" Z
#include <mach/da8xx.h>
2 b* A; \* a( t0 T#include <mach/mux.h>
; ~3 V9 E# i, r9 I4 k* @9 E% \% Z) K- p( q9 O
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
+ B" v' r, h2 S5 P9 h& L7 L#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
9 }" r: E; T# ^6 b. u) p1 h#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
" |; S3 o4 Z1 \- ?& K' `#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
0 m# h- r; F- P  H+ v
2 M$ t/ f3 B' C* @7 W5 y/* assign the tl som board LED-GPIOs*/
, {) Q% M& _5 V- Estatic const short da850_evm_tl_user_led_pins[] = {9 r  [% ?$ ]/ y+ {  I6 X
        /* These pins are definition at <mach/mux.h> file */
' w) `8 J1 G# X        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
4 H# K4 e  X0 u) v/ O0 P' v        -1( D  Q. a+ P- C5 m& W/ q
};+ Z+ _8 H' t) w' R" A3 a

% Z. N4 [6 p: A, h+ b6 Pstatic struct gpio_led da850_evm_tl_leds[] = {; D$ J& \) h& ]  r
        {
& u- G6 z+ |9 {( c. |                .active_low = 0,
1 J; e- e7 u9 i7 l1 V                .gpio = DA850_USER_LED0,( g$ o7 ]! A$ `8 W7 g! r
                .name = "user_led0",
" H2 s$ U' S/ k0 f# E                .default_trigger = "default-on",
" q2 X9 u* F1 d0 X) ?        },+ O0 R3 t+ j$ z+ [
        {
0 X' V' o/ ~6 \6 ~+ P/ w7 ~                .active_low = 0,' W6 Q" b* |/ _( t# B/ w
                .gpio = DA850_USER_LED1,- \/ a* z/ k+ P: w) ]0 ?' u; W  [! P
                .name = "user_led1",3 g- A! P& I7 c- r
                .default_trigger = "default-on",! u# b" e# b7 p7 p& k. X
        },
3 V  \) C: [9 E& o4 ~. z/ o        {8 W, a2 b6 J' }9 ^  ~) |% X
                .active_low = 0,
: u+ y! }! G& `* d                .gpio = DA850_USER_LED2,
7 P7 G6 W$ B# l7 o8 v! q                .name = "user_led2",
% V% Z1 e! q# I- J8 Q  t                .default_trigger = "default-on",3 h' l' M1 o8 j! Z' S6 b4 L/ ?. R( D
        },
7 {$ z' Q3 i4 M' }# A. {        {
1 B4 k! [3 R. |: r. ?" j: M- v& e+ Q2 J                .active_low = 0,& ~5 f& {& ~3 t; f8 A4 N
                .gpio = DA850_USER_LED3,
; H9 g2 e: ?* m" M5 M" h                .name = "user_led3",
( r, Y. d1 x  r5 _; n; b( k4 M2 u                .default_trigger = "default-on",
/ m! N4 g  ?" O        },/ M5 m# E, I+ j8 p6 k8 ]
};
9 @' [& K  n$ P9 {  Q
" J) Q$ w# I9 e% }static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {- d* Z/ w/ j# \  [2 Q, F: E' m
        .leds = da850_evm_tl_leds,
; A" V& _1 N3 j$ ?' Y9 ^* S        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
' ~: @: ~- U5 _' b. K1 z};
9 [) Y1 b2 f$ R( }/ R% D2 f* [8 @8 z# v2 u5 m0 n3 x: m. B$ e1 G
static void led_dev_release(struct device *dev)
0 k7 k. G6 M3 d# S0 [% s' [{
$ M1 }7 D6 x, r' h2 t};8 C- D5 v; V3 Z

( F% g! V7 ^7 H1 F& ?; vstatic struct platform_device da850_evm_tl_leds_device = {
2 \; |% X+ \, x, t3 ^        .name                = "leds-gpio",
( Q0 p# B. V# f1 s& m' h        .id                = 1,
* f" C9 L3 x) n+ V2 x        .dev = {
% s9 N7 f$ V! t; _                .platform_data = &da850_evm_tl_leds_pdata,$ w" b$ V: M8 y) l+ }+ D
                .release = led_dev_release,
! q! W6 y" A5 o' e& A/ x8 l' w        }4 c/ a6 i% ]+ w
};
% l7 D& r; \  }3 ^, d
4 s' }0 r0 I, O) \: m% Y# V7 c' xstatic int __init led_platform_init(void)
5 F! E' _3 t6 y3 c5 T9 }1 H( h{, Z, `% l9 L. b# f; L3 T! M- M9 o
        int ret;4 o) |8 a5 \% l' B1 _; c) p7 D4 V
#if 0
1 O7 ]( V6 Q: e4 a4 h% C0 w        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);3 }7 i1 ?+ O; q5 s! a
        if (ret)# Q. p5 I2 \0 k3 x( t  N9 y
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
3 t' I( _/ V* p+ s, e7 X5 V                                "%d\n", ret);
  W1 Q2 H- u# A8 f% F#endif, i0 a5 u$ N+ m
        ret = platform_device_register(&da850_evm_tl_leds_device);: C; Y) L5 K% m; f3 X
        if (ret)# J! `5 \# C8 D
                pr_warning("Could not register som GPIO expander LEDS");1 G( N5 J( s: i8 F* F' u! e) ~. x
        else
. D# p  L, G, T: {" H                printk(KERN_INFO "LED register sucessful!\n");6 w. ?* x0 {+ M8 s7 h" z- {% M- b

* f; E6 y) ]; ?3 v/ m: _# t. v# |        return ret;
; P& r! O5 ^3 W& C( M# N}7 o: S9 Y0 X! g! r& \$ {4 r- u) Y, E
1 ?7 h* W8 y  P. q1 U( f1 |; R8 V
static void __exit led_platform_exit(void)" I# u- \; r' S/ t9 ^8 G
{
' h" k3 \  R+ V! @$ l* c        platform_device_unregister(&da850_evm_tl_leds_device);9 s: ]' g2 Z" f$ K

* l' k. K* I/ s6 B        printk(KERN_INFO "LED unregister!\n");
7 I4 K$ |2 J3 v4 O* i7 g" a}
: ]& ]) L% Y9 n: y  P2 u1 ~% Q2 B
module_init(led_platform_init);
, {  m4 I7 R) d/ f# Qmodule_exit(led_platform_exit);. \3 x) ?6 [3 B- n
$ h; {2 V% a% G- i9 d4 m
MODULE_DESCRIPTION("Led platform driver");
& i" @! ]: V% c7 e+ B* b) M) l( vMODULE_AUTHOR("Tronlong");$ o5 r) h" F' N& c8 s, w
MODULE_LICENSE("GPL");7 A7 z( d+ j1 J$ a9 U& P9 _7 n
$ L: y- w" S6 C5 `
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

QQ|手机版|小黑屋|嵌入式开发者社区 ( 粤ICP备15055271号

GMT+8, 2025-12-7 16:51 , Processed in 0.038735 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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