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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。: x9 u2 \9 s) `% ^7 F% j; H
#include <linux/init.h>6 A' ?5 P) }* f6 J( `$ U" `
#include <linux/module.h>
5 l( T/ b# t4 F6 q2 Q#include <linux/kernel.h>
6 h: n8 ~* _0 |9 X! [#include <linux/types.h>
3 f% {$ o2 Z6 G! N4 P! c#include <linux/gpio.h>8 }- {, H; F5 ]2 M( Y2 T
#include <linux/leds.h>
3 I4 n# s7 I" O, x/ K1 F) Z: \9 |#include <linux/platform_device.h>
. H" R0 D$ K9 R  e
5 r9 P8 I* s& n( k/ X# m$ l/ }#include <asm/mach-types.h>8 r2 z9 g- D- d
#include <asm/mach/arch.h>  w4 z/ X5 A) M: |" V
#include <mach/da8xx.h>- ~! C4 ?' K4 Q
#include <mach/mux.h>
7 \. t+ v& O# K8 a2 u- X5 K. o3 G& E$ k( v* ?6 }- K1 y
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
" F* z3 ^6 c' j#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
: R! J0 T/ }/ A& l3 N8 g/ e- _7 ^#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
3 ]4 N' Q6 F& f#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)& _: f% f) t5 m5 k% e9 [% G# u" G

9 f3 Z) A/ r# }: H. J/ Y- A) q5 Y/* assign the tl som board LED-GPIOs*/5 C/ D7 F9 `* c6 m, x- b- q% e
static const short da850_evm_tl_user_led_pins[] = {5 e% P  ?; u% Q9 q# Q4 U
        /* These pins are definition at <mach/mux.h> file */
! Q1 `& f- M" J        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,9 E# T; y" n: G, K/ z  A! R- s2 X
        -1
" ]. I( B' S% N& t( |};, t8 m: W. A% Q- C- E

* w! X: _8 {# h" E. W7 O. r' Gstatic struct gpio_led da850_evm_tl_leds[] = {
9 c. n9 N0 W* |9 K5 O! j        {4 K$ {7 h) w8 c; ~/ k! s& B
                .active_low = 0,
0 N: {- A( t$ N7 Q                .gpio = DA850_USER_LED0,
# [2 ?' n" V) Q+ _                .name = "user_led0",
5 `3 i: s8 c! V7 f# x/ W                .default_trigger = "default-on",7 V1 F+ E5 m% B: S
        },
4 @8 {0 k  C! v$ }        {
4 _& P- Y; j$ N+ w, R: S                .active_low = 0,1 A$ O7 A3 j" X* V! t
                .gpio = DA850_USER_LED1,4 {' N! y* \' s2 o: z" }  ]
                .name = "user_led1",) v1 c' b" e7 p! R# Q( _
                .default_trigger = "default-on",5 D- f/ d3 p) k$ B$ l! S0 W
        },2 P6 [# k, l* L! |- F9 L" b6 r
        {3 L; u; h" D5 l+ N/ T. i
                .active_low = 0,
0 p6 |) V* G( r- J5 L8 z                .gpio = DA850_USER_LED2,& H3 ]" p7 e( Y: G/ g
                .name = "user_led2",- x: p3 I7 |  X6 r
                .default_trigger = "default-on",
; ~8 y! |2 M4 k1 V        },
- W& w; K/ ^4 a9 _        {
  F* G) N$ ]9 j, _# ]) {                .active_low = 0,7 V# R& D; z( o
                .gpio = DA850_USER_LED3,& c9 S& Z, G; G1 D
                .name = "user_led3",3 B. @1 E( T, x& X& t
                .default_trigger = "default-on",$ J5 {# Q1 y7 V$ S2 x# a
        },' o* H: M: y+ P" R, z6 v5 H& n7 }8 l4 K
};3 d2 ^; k! l8 Z

. V7 K1 e: c* d5 Y8 V- f1 tstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
! q* U& h! h8 l' ~& {5 ]3 S        .leds = da850_evm_tl_leds,: g& h' J7 D: D) R2 W5 k9 p
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
# C7 ^' s3 N2 B  V0 M9 k/ q};
/ n7 ]' e; R3 X  G) M! e( N/ N) ~+ n9 V) b8 h/ |5 Q0 i# J" ?! Z( v
static void led_dev_release(struct device *dev)3 N) I; T& A" @/ R, X) ]% \
{
$ [  _2 W" A$ c( q2 e, z5 A; i& Z};6 Q. Q9 B$ I( }: `6 V, P

% S' h- R3 }1 v* e" N1 hstatic struct platform_device da850_evm_tl_leds_device = {# {, x$ X9 G! v4 K9 d, B
        .name                = "leds-gpio",
  M! h+ {; ^2 _9 n# h9 y- ^$ g        .id                = 1,
% c$ \8 [; Q) z6 I$ y$ x+ ?# v: B        .dev = {: M8 E$ w3 H/ i3 M/ |9 t
                .platform_data = &da850_evm_tl_leds_pdata,
4 Y  y1 O- b4 e$ U                .release = led_dev_release,8 z. U! u" O$ d, B6 H9 @* O
        }
/ W* F4 W! O* g9 ]};& E; r0 g  B3 }/ c/ t) m# v6 r
. U4 y4 a" H6 _0 h) @& e% `
static int __init led_platform_init(void)
' M. @- W, d8 A! w0 z# X{- C3 J& [- B9 Q+ O7 n' w& U) V
        int ret;! h" p8 b1 }) k- u5 ~5 k
#if 0. L, ^* @/ l+ A4 {4 S7 Z( D
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
( t4 j- ]0 E2 ]! j( }6 U        if (ret)1 c4 \, a% ]# _/ f
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
, m7 k3 R' P7 e6 x- }( _                                "%d\n", ret);' f" ]# X& x( ?. E% }; X
#endif
, R% L4 \8 p2 @: e! L        ret = platform_device_register(&da850_evm_tl_leds_device);
' d& Q' M. l/ b6 A* R, @        if (ret)
* j5 L) P7 A1 x9 G8 M                pr_warning("Could not register som GPIO expander LEDS");
7 ~: U8 o3 b$ ]5 {        else/ R# S2 ?( y" {$ E  b0 a
                printk(KERN_INFO "LED register sucessful!\n");
9 d7 V8 j7 |, S7 e2 E/ W6 [5 }+ @# g
6 n- R& |$ y* {$ Z8 D2 `        return ret;
$ Y( W. g& Z& X. ~% f5 ^3 C}
' V5 [0 a" T8 t8 c0 z. W- w& x, _1 T9 \
static void __exit led_platform_exit(void)8 N! N; c3 F# ~8 y. Z6 B
{5 i; c8 y5 H4 L5 R
        platform_device_unregister(&da850_evm_tl_leds_device);$ s* ?* r$ l5 {, |/ W! f6 o
+ w; @$ j! F4 b1 l" ^
        printk(KERN_INFO "LED unregister!\n");0 K: D. H; r. l* B" ^  A
}  }  J9 S$ V! J0 M. A* W% I

: ?9 j' ~9 D3 d' G0 }+ Wmodule_init(led_platform_init);
- }# N* R' g" cmodule_exit(led_platform_exit);! ?+ p  _3 f9 b. x4 [4 p  i
! c* H# r8 @- r0 N: q8 g, H
MODULE_DESCRIPTION("Led platform driver");, c5 W  ^! J; |2 A
MODULE_AUTHOR("Tronlong");% c1 N; t  ?6 D% h0 y. z3 X
MODULE_LICENSE("GPL");" J% r8 Z8 m4 \9 U# g$ T: |

& i' N- j8 L9 r1 O
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-7 01:45 , Processed in 0.038653 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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