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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
. u" c% P, {! V% m; K4 ]8 j#include <linux/init.h>
3 `* c9 x, e, ]8 Z0 @1 k#include <linux/module.h>
; a2 |# a2 F4 R8 G2 w; ?#include <linux/kernel.h>
' N/ X: r$ \: `3 V* q+ J1 a#include <linux/types.h>! @! a9 b. T( X. U+ D: ?
#include <linux/gpio.h>
+ n+ W3 d$ G& u" P#include <linux/leds.h>2 c, o" E; p, C. ]7 v2 n
#include <linux/platform_device.h>! x- F* K" j  g$ D# r
0 G1 v" b; e* w! x  v) C) ~4 c
#include <asm/mach-types.h>
3 `# U$ _/ k) e% V% x6 w#include <asm/mach/arch.h>
( U& }) X7 m, E% ?% e* d#include <mach/da8xx.h>
3 y* u: f# d3 u  C7 a#include <mach/mux.h>! P4 \1 B7 o% w  @- o5 ]: c* ]0 w

# @2 i' o) I  w  P, i" }9 W#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
$ c8 l6 S& m/ x6 L#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)# H* ~5 u4 `. ^; G& f
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
0 r$ V: U/ @. u: d9 _$ c; }#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
8 I7 q5 O: ]* U8 T6 y- R4 i0 f3 B+ v# C% W
/* assign the tl som board LED-GPIOs*/
' Q! Z" ^: V" n' ^* `# Zstatic const short da850_evm_tl_user_led_pins[] = {
, n: x7 i. E+ M/ V: Q/ g( ]. g& |/ s        /* These pins are definition at <mach/mux.h> file */4 V" w" S- }$ O( A
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,8 D+ Y& K. z8 d! E+ t4 u& l1 [
        -1
. [& ]8 y- Y6 w};7 W. Z2 U0 Z. S: P7 e

' }* }. F  e2 `3 A! T$ o' P- ~8 ~static struct gpio_led da850_evm_tl_leds[] = {
  ]' ^6 p5 \5 W- ~; m" t, {) {        {% u/ T# U! e6 {  w0 M' [# x( ^
                .active_low = 0,
1 Y& l" D' H. i" R1 f( r                .gpio = DA850_USER_LED0,/ a7 w( b0 ~; Y5 Q  z0 b  S
                .name = "user_led0",
6 O4 k. p0 ?( K8 T+ l                .default_trigger = "default-on",
% Q" t, l! O8 v1 H  s! A1 G        },6 w+ b6 a, i' T  ~8 z  n0 Z
        {0 X# O) S7 z3 u# a+ |5 h2 F
                .active_low = 0,) V) b3 |3 k, l4 O
                .gpio = DA850_USER_LED1,
7 V. I" P) ^" T& Y/ g! s7 {4 l                .name = "user_led1",
) z0 A% C) M3 c                .default_trigger = "default-on",. S5 W3 ?! A  ~) j4 Q0 ~
        },
. U5 H* C3 U9 ?' k        {2 k- d& i" h0 ^6 `. |
                .active_low = 0,  K7 I& |& c; f% N7 |/ O0 E8 J
                .gpio = DA850_USER_LED2,$ b' G$ a& E$ @6 U
                .name = "user_led2",
& X( V/ o$ ?. b                .default_trigger = "default-on",) D# ?# n8 j$ I8 f$ P6 K8 i
        },1 ]9 B8 Y7 R" T4 M' [2 u2 g2 q1 y5 \( i
        {
0 {1 H& G2 o( I( S+ S; B$ C                .active_low = 0,
1 p1 B; k, P+ ]9 \                .gpio = DA850_USER_LED3,& F9 M. @+ S& C6 H
                .name = "user_led3",
2 U) o& [  B5 u2 M) p" j                .default_trigger = "default-on",
' k0 z) ]! a% K* B" ^7 R' P        },
! y" x: j+ _- f/ i};
) H! ?; H$ _9 ~( a/ l) [; Q' h8 ^& K# h) h' z9 `% [. ?
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
) R4 h1 k2 @* F) }, J( Q        .leds = da850_evm_tl_leds,
7 u- Z1 S% a. q+ Q        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),) m9 F+ z2 }) \7 S4 z% b
};
0 \: m( V5 R) E' n6 q) r5 u- X0 i
: j$ q0 e' w3 {2 fstatic void led_dev_release(struct device *dev)3 L- Y/ Y- `8 I3 [6 @* d8 b3 Z
{$ j8 G7 S* H1 O' D2 V- I* ]9 [
};: k) g0 b& R1 F# E# }" r
  b( n2 y$ V% H! c% d5 a0 R
static struct platform_device da850_evm_tl_leds_device = {
3 j4 M7 L2 N2 b0 w# y3 N        .name                = "leds-gpio",3 z, |$ E6 h! J, N$ n- a
        .id                = 1,
" R/ a5 i2 E! P' J8 m# N6 n- M        .dev = {
; I# a2 Y* Q  u* d" K% X; k+ T* |0 \                .platform_data = &da850_evm_tl_leds_pdata,, Z% c4 U3 i# o0 o! y4 z8 D
                .release = led_dev_release,
3 R; S# ]" t0 B* K4 t7 f5 d2 s% c# k        }
' Z7 f" V! L% d( ?! G7 ~3 N3 a  q4 J) ]};
" T1 X; b, H! q! o2 V) _! k% }& Q) m) Q' _. N
static int __init led_platform_init(void)
, J2 u+ Z2 }5 j2 k* A0 L. j) v{
/ B% Z6 s) W* N8 _/ D7 R        int ret;, |% H# K, c1 T" ?, c9 L; Q: j2 ~
#if 04 L4 R, ]  j. E3 q( ]
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
- @" X% V4 ~) a1 _6 w8 e4 U        if (ret). b8 U1 V3 L, O6 G
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
9 H) a  L9 n) D3 M, l                                "%d\n", ret);
9 j) Z3 e) q; U* M  o# n* c. J#endif
! T( I( c& Y' t1 M& T6 N        ret = platform_device_register(&da850_evm_tl_leds_device);; a6 r- |* O( A3 l' J( D& W
        if (ret)9 [% R) T/ c5 [% p
                pr_warning("Could not register som GPIO expander LEDS");) _/ Y- U) x" b& c5 _9 |) m9 g
        else
, V* X8 S% p# ]6 y; @7 h                printk(KERN_INFO "LED register sucessful!\n");
8 F! v) _4 o3 y* I( P3 ]% E9 i0 s
4 g& U2 X; ~) o$ l0 n        return ret;; O( K# X8 l! w3 x' h) o
}
1 }* u1 Y: R* e! o5 @3 v/ p4 O% E' b- w. m, M1 V6 X
static void __exit led_platform_exit(void)
+ m% V2 w/ j2 M: U; b2 U" t: c7 P{
2 X* [0 Z  i5 S& s8 s        platform_device_unregister(&da850_evm_tl_leds_device);
* f- ~, D0 a, u9 d4 ^0 o
5 w% j5 h9 O, E5 ]. D$ P" S/ C        printk(KERN_INFO "LED unregister!\n");. }( e( b& u  g8 ^8 c" |# N
}
) c9 x" P% x# U; g$ l7 e- p# x
# C  A7 ~6 F. H2 ], S( U2 kmodule_init(led_platform_init);
4 U0 N: K3 p9 Rmodule_exit(led_platform_exit);; z. h: ~1 ?' _9 B0 I/ M: q3 O
5 y, c; q& f0 m$ o
MODULE_DESCRIPTION("Led platform driver");
# L& i5 M( @- AMODULE_AUTHOR("Tronlong");
: l: |0 K; t! u* F$ i) ]) U) L- lMODULE_LICENSE("GPL");
/ ~4 k7 a3 N: M9 J/ w) [$ m3 V& P$ e2 C+ `
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-9 07:38 , Processed in 0.038887 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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