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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
9 ~2 o3 i  ]$ d7 n, c7 O! t1 J#include <linux/init.h>. r& J. |. L9 w+ [, P0 T
#include <linux/module.h>6 c* f3 ?+ \* c! K
#include <linux/kernel.h>
4 P# U8 ^3 y6 s8 ^$ {$ s, q; B1 N! C#include <linux/types.h>
5 `8 H  `  o- ^3 l/ i#include <linux/gpio.h>
! l( ]& R/ A+ \! t7 V: t8 I( a#include <linux/leds.h>
8 e- O! D8 S  n& {, I: M#include <linux/platform_device.h>& e6 D6 z) d  `( ^

7 }) k# \; R* C- @#include <asm/mach-types.h>
0 s! b+ q2 B! i#include <asm/mach/arch.h>, k. l& ~! e2 q5 u" K4 E
#include <mach/da8xx.h>9 O$ P7 B6 A' S* `  W# D* C6 a
#include <mach/mux.h># {% q0 \. l6 _4 [  i
1 ^# s- P1 a- ^- Q2 s& r2 B2 F; l
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
0 G$ O8 ^; @: F) N  q. M. f2 b#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)& F: X' e( I+ B* h9 W+ u
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
9 [# ?% m8 G# }4 |7 U( N; ~#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)2 z4 s: T: `' }3 g$ p2 \5 `
# V8 x" H. U8 |, [+ Q* `, A6 [/ h
/* assign the tl som board LED-GPIOs*/" L" f: M2 r9 b
static const short da850_evm_tl_user_led_pins[] = {
- n# _8 R, i, Q, R) n- Q        /* These pins are definition at <mach/mux.h> file */8 I% }/ n9 N4 r  D7 ^
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
) |+ t. S3 Z1 _) p2 d        -17 J8 j4 V  n7 A
};2 X" m( M+ ^, T* L
7 Y" d* r! T. y# h7 M
static struct gpio_led da850_evm_tl_leds[] = {9 @, \! n  x; e! T
        {
. ~* O9 T' O. Z( C# V5 J' ^                .active_low = 0,5 R- E& r' d9 F/ E) K/ d2 d% f
                .gpio = DA850_USER_LED0,4 h" a6 U2 n& I: Q
                .name = "user_led0",. C, ]% J: g- e8 N
                .default_trigger = "default-on",
; W( J% \& T) W( z' O        },
& Q5 B  E' h0 Y, }5 C8 U) a        {
% ^& j$ z9 }: {- d0 J  k$ n                .active_low = 0,: x/ }6 |( \. C' s% M, c
                .gpio = DA850_USER_LED1,
9 y# [5 Y; A1 u4 T                .name = "user_led1",
" p; l6 \0 Z, ^' ?! {- m& W, g                .default_trigger = "default-on",8 V3 Y8 I1 ~* B- }
        },& ?5 _  C9 i" g
        {
& }: i  W5 h5 f  w                .active_low = 0,
/ m" S, L$ c- c                .gpio = DA850_USER_LED2,% b3 ^# o6 Q- ]0 G4 A/ }
                .name = "user_led2",: a- ?: y" v: S% R; Y) `
                .default_trigger = "default-on",1 B3 J/ G4 L9 K5 p5 l
        },
/ y6 S: N: n. t! S  ~8 w        {
' f5 F3 r0 b  I6 t) P0 J) I. M                .active_low = 0,/ u  c7 F1 B8 l1 f8 F
                .gpio = DA850_USER_LED3,( T" G* H6 ^" V; l. J7 I" h
                .name = "user_led3",
1 d  D  x# F# f+ T" z6 _7 J                .default_trigger = "default-on",2 f2 O2 d) k" I5 b) x& n+ g
        },
5 a* Z# p' U% w! W9 G9 g};& W2 i' L! J( |' v7 T
: K  |0 _# [3 ^* ]) |0 D1 I
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
. e8 U- a! p& d  l% p( u4 N1 B        .leds = da850_evm_tl_leds,* u- e- V- U7 H1 T8 M+ C
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
/ v2 ~9 I' L& _. X# V};
( L$ s; ?5 A, |  H6 q- t1 Z- X; D: W' o% u4 X* B
static void led_dev_release(struct device *dev)
$ q) t2 Y9 m) G{: H- j3 r0 {7 `8 N5 V
};4 |6 {% _6 ^& O4 G  r4 T' e
/ y  K  \& p1 a
static struct platform_device da850_evm_tl_leds_device = {7 `, l: l( V4 ]: y
        .name                = "leds-gpio",
+ P# ?' @! i- R* S, R        .id                = 1,
; B! I+ J! s6 H: S1 Q        .dev = {- T' n9 ~3 h4 P
                .platform_data = &da850_evm_tl_leds_pdata,* S0 |) J$ P4 j! m/ u9 ~8 |
                .release = led_dev_release,
9 }% _" y. c1 F9 b" v2 |1 e( W6 |        }( R6 F3 Z- I, ?5 N4 w6 u+ ~# [6 P; f" g
};' y8 b& n; C0 s8 C
! m( e- ], ]) c$ Z; b& t2 [3 i" l
static int __init led_platform_init(void)
5 Q- T! T( O/ ~4 o; E* D7 F{
* T) k# M$ C% A9 l5 ~        int ret;
: P0 \" c4 t  ~#if 0
* G; Y1 F) E- b- M6 V4 A        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
% T9 m% f; _% U  ~        if (ret)
$ r1 n3 m" V% n. T1 o, g$ S                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
4 r0 C: c7 r$ p! Z. ]                                "%d\n", ret);
* d1 i, t. \& a4 P) `2 g#endif
, R( ~- G8 @5 m; x; N" Q1 z, w        ret = platform_device_register(&da850_evm_tl_leds_device);/ ~+ |( h3 U% K8 Q
        if (ret)
. I' u5 q% }: M2 X- T& [7 y                pr_warning("Could not register som GPIO expander LEDS");+ }4 f$ @) M) L. d
        else8 E: K, ^7 F% f/ y
                printk(KERN_INFO "LED register sucessful!\n");0 g) x, Y2 w, p5 L7 w
  u+ ^3 G7 x9 ?4 u5 j
        return ret;1 z& C3 M. ^# T1 j9 I% ?9 G* T3 O
}6 |# V# i7 B( R

3 O& ]7 S* l9 y1 }1 A" ~0 [static void __exit led_platform_exit(void)/ L: w# p& U& P6 D
{
5 q2 t, f& {: P! M        platform_device_unregister(&da850_evm_tl_leds_device);" x0 A1 |) e. @1 ^2 Y0 N5 q! k

! M6 k7 \& E: n0 N) ^        printk(KERN_INFO "LED unregister!\n");
: O3 T* U5 k3 v' p; _0 m4 V0 F: v}
7 L. H% }: r, J6 K* ~) \' I; i; ^8 A$ f, ]% W; s( O
module_init(led_platform_init);- p* j8 \4 f+ D5 }6 U, O) ^
module_exit(led_platform_exit);/ t7 M5 P: Y( U( n
6 k, O) O: {: E' n: ^4 P6 ^
MODULE_DESCRIPTION("Led platform driver");0 |* M, u5 ~# s! q3 B. a
MODULE_AUTHOR("Tronlong");
, G3 F! `  l; K+ tMODULE_LICENSE("GPL");
! n9 t! Q+ n9 V/ \: J0 I) ~
: M# f/ C9 D7 v$ c! @
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-15 11:50 , Processed in 0.041740 second(s), 24 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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