程序注解 - OMAP-L138 - 嵌入式开发者社区 - 51ele.net
设为首页收藏本站
点击跳转“创龙科技服务通”

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
- ^, o; l% x' K, F( t  t#include <linux/init.h>
8 U% V4 Q2 u2 [0 Z" O0 @#include <linux/module.h>
8 k9 a, a. B9 J2 k2 u0 Q#include <linux/kernel.h>
% f, ~% K7 b0 W' t8 ?#include <linux/types.h>4 k+ `% X/ g! e/ l2 d
#include <linux/gpio.h>
, `" d- a4 Q) _- g( h& f6 n#include <linux/leds.h>0 a, _$ F* Q* e) @0 P
#include <linux/platform_device.h>0 `  k' B  Y6 i* @% G- C+ L$ W
$ r% I# ~7 |" D  k! d# c
#include <asm/mach-types.h>
" u: @# Y8 g# w7 y#include <asm/mach/arch.h>
; u" |1 T& ?) b, d, L* g0 V#include <mach/da8xx.h>
  F2 U$ K# q! K2 t8 b#include <mach/mux.h>' j! i4 W" e% t% I9 c

2 v+ M5 K& g3 [+ o9 L#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)6 {# k8 ^1 p, Y, k" U
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
5 `" t; W2 e3 D; k#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
- }* z7 K( b3 T2 E* O% O' K#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)4 N7 N6 _" D+ t# w/ z; Y7 @

0 i" ^9 N$ y- c# M& Z% l, a/* assign the tl som board LED-GPIOs*/. M3 O) n/ k2 W2 E7 h  L- m7 R7 G2 w
static const short da850_evm_tl_user_led_pins[] = {
8 l2 s2 v/ ^0 \) |) p5 o        /* These pins are definition at <mach/mux.h> file */
2 Z7 _3 Y- r9 _6 h" v        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
& g/ L: U9 {8 X8 j  U4 Q6 l        -1
* U0 m1 `; s+ u% T; W0 E: c};$ c( `! e  i3 x8 s
! E2 d& d( f1 s+ l
static struct gpio_led da850_evm_tl_leds[] = {+ T7 i  i* p: D; }4 ?: s& W! `
        {
9 u; g( }; G4 I% `                .active_low = 0,. N' f- H5 {" ?4 A
                .gpio = DA850_USER_LED0,
3 u" Q$ f+ \0 H1 H5 O1 w3 {( f                .name = "user_led0",
6 H9 Z2 j$ B7 F/ {                .default_trigger = "default-on",* ?: s4 Q+ ~2 Z" j
        },. `9 I6 r3 i9 c
        {3 S7 g9 h  e% u* @+ I: A
                .active_low = 0,) Y4 C% R( M* P1 j$ @+ ]' z' R1 O
                .gpio = DA850_USER_LED1,5 `3 i/ S8 H) }7 e9 D& p6 ^$ @
                .name = "user_led1",7 f" M% ^, e! h# ]8 r
                .default_trigger = "default-on",$ W  Y# W0 `+ g: u$ |
        },, s6 o5 \9 A) M2 g
        {
1 \3 }1 G* r. N6 R1 k, ?; r$ T                .active_low = 0,
2 T( S8 V- v2 a, d4 ]                .gpio = DA850_USER_LED2,; X  T- g9 t% U; x
                .name = "user_led2",% K1 M, Z8 E" w$ x. i: g4 W0 z, w
                .default_trigger = "default-on",& {- c: n3 Y( O. p/ R( M
        },
7 b, O2 r2 t8 N        {" D) j' p5 \+ [) L
                .active_low = 0,* T; ]# _4 t% f( K# J" c
                .gpio = DA850_USER_LED3,& f. I( Y6 p9 ?. @& ^4 n% M  H3 E
                .name = "user_led3",
* E7 A/ O5 g/ v3 Y" R& B; q% `                .default_trigger = "default-on",! X7 m0 P9 w1 g
        },
0 G. h  x: ]% w! u  H};
! e) m! f1 o2 s, n% L
* O% i4 @  H3 T. Ustatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
' F1 f0 S  X% ~        .leds = da850_evm_tl_leds,
' v! K& S7 r& P$ q( v# ?* Z# ^        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
. p# ]& B8 A7 `% w5 \& j; l};1 d  _8 i. V7 Y: F

. y: }% |! r: D! ?% J$ a5 bstatic void led_dev_release(struct device *dev)
/ d% b: h8 F' H$ o* Y{! W( S# ~8 @" j5 Z
};
1 X+ L* q  U+ ^1 q; }" v2 `9 i- Z1 t- h# c
static struct platform_device da850_evm_tl_leds_device = {- f( h  [* d8 D/ ?
        .name                = "leds-gpio",# @& u0 r5 D; U
        .id                = 1,, v: M/ p3 V( ]  w  }
        .dev = {
! n* d- b! t0 P& H8 h                .platform_data = &da850_evm_tl_leds_pdata,# k  X% L/ s6 n5 {' C, ]1 c1 A
                .release = led_dev_release,; m' L" U7 _- d# x
        }# c5 s: X& s( Z0 @" [; ~
};6 z  b4 K/ c) ?7 \

$ d5 A/ G( b. X8 c& Vstatic int __init led_platform_init(void)$ w! x$ e2 r' U0 d. m4 i! L
{
9 y/ k3 n6 K$ S5 {* ~: Q' {        int ret;! J; d' V- ^: J. l+ w" E
#if 06 k. |3 u2 q+ [6 w
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);7 R% x' n& s) z$ s/ w0 N
        if (ret)
( Q! n+ p/ S" M+ U9 E! [7 ]- K+ {3 f                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
: ]4 O5 ?& h9 G- F: b                                "%d\n", ret);
6 r& q/ L+ z5 z. e9 j#endif
, Q  X3 [3 u4 Z" l% J) V- r        ret = platform_device_register(&da850_evm_tl_leds_device);3 c; W- |! A5 g
        if (ret)
$ J6 f/ i' {- d. Q) t                pr_warning("Could not register som GPIO expander LEDS");
) @  Q& y& R4 `- |0 T        else- \6 a7 H- i) T3 F( b( T6 ^
                printk(KERN_INFO "LED register sucessful!\n");
" z" ?% _2 o- H& f; t/ c( p
" K# n1 j! F, ]% e" @+ z        return ret;1 A# c9 y0 G/ `8 a/ ?2 u- ^) k- J5 j
}9 r' n, i0 S/ i  V5 A* m" u

5 ]! f: F* q" I6 w' D- P8 ?6 Sstatic void __exit led_platform_exit(void)
, D% P5 R9 \; J  H0 [. o) t, J) E{5 |8 C6 B7 p8 T- l
        platform_device_unregister(&da850_evm_tl_leds_device);
3 R+ k  N" K+ X# D1 n- J
& l2 @$ v2 a$ @* Q- W        printk(KERN_INFO "LED unregister!\n");
. ~& i1 R) }- _& e5 M0 ~+ h}
8 q: Z4 P7 Z2 U  j  o8 {( {* I! V7 P5 G, I) ]1 u
module_init(led_platform_init);. i3 E" I' i2 s, M
module_exit(led_platform_exit);
8 \, V2 q' d9 N- M5 }0 Z) k5 }( \1 t" Y/ @- R9 T( u8 ~
MODULE_DESCRIPTION("Led platform driver");
% c6 h& q% j8 ]MODULE_AUTHOR("Tronlong");$ D! m/ x% t9 i
MODULE_LICENSE("GPL");
3 Y: R# {1 I4 H1 b4 Z9 Q# O
! j- ?% R5 a2 I' Z$ S
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

点击跳转“创龙科技服务通”

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

GMT+8, 2026-1-15 12:07 , Processed in 0.039367 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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