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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
' x8 n3 q0 g# D. R) v& H4 m$ l5 l#include <linux/init.h>
6 W  }( `" Z* d2 f$ L#include <linux/module.h>6 O3 E! |3 m1 t2 o1 `
#include <linux/kernel.h>
$ r. l9 i, @) _2 m#include <linux/types.h>
7 o! }/ {0 R6 @* k, Y2 I#include <linux/gpio.h>
% j& P( A- v! T- }, |#include <linux/leds.h>
  E( O2 q, y$ X% h#include <linux/platform_device.h>8 h1 V+ W1 e9 c: J

1 S& T$ B5 w: q$ U& a6 w% P#include <asm/mach-types.h>) B  R+ y3 y  w: T. X0 w0 m
#include <asm/mach/arch.h>8 H: w1 z  ?( U0 U3 o
#include <mach/da8xx.h>. H6 |# l5 W3 v( [' x
#include <mach/mux.h>
2 ^8 }  W7 Z: z! \8 E4 {: T
; X9 B' v3 N: \) ^; q#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
9 {1 V( h8 x- b) j$ }) f#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)9 z5 R% M. H0 t+ i* m: g
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
# L5 V# O+ c. }2 I- }#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
4 Z. C, P9 i' u) s. v. m) T0 L/ ], @0 r! x
/* assign the tl som board LED-GPIOs*/
0 S1 P" ^' B9 m" e5 c, X3 gstatic const short da850_evm_tl_user_led_pins[] = {4 T! |$ j& c6 g$ w8 F& |
        /* These pins are definition at <mach/mux.h> file */6 }  |6 w5 a( k# {+ G
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
& v! @: \: a2 n% E, T1 c        -1: K$ |, [& D& F6 F! V9 w* x$ g1 K
};. i" k5 s' e6 A

& h( A; q5 y7 D; Astatic struct gpio_led da850_evm_tl_leds[] = {
4 w% T) U) i3 T        {; ?8 C+ m* q8 y- P* W) j
                .active_low = 0,' J) c3 G: D- W' Q- f0 @" d
                .gpio = DA850_USER_LED0,
, U5 l' Y  W/ J) p( ^                .name = "user_led0",3 t; j1 b' w5 l* l2 l
                .default_trigger = "default-on",' o6 K5 `) |' n3 s; x; z
        },
6 ]7 M4 A" G) W/ V: d0 h, P4 n        {
; R: }3 d/ K6 `) F. T# ^                .active_low = 0,
0 v, {$ _) e( E- Q# J# a/ u                .gpio = DA850_USER_LED1,# p8 x! z" g4 M" e
                .name = "user_led1",( o# [- h  h6 a: F9 d- j+ F: Y# X
                .default_trigger = "default-on",
# e- U: z+ l+ U7 L- Y. x        },) a4 d. f$ W' a7 a. X& }
        {$ T' R$ d" i5 ]
                .active_low = 0,
) l$ Z( I2 [& Y9 v# D                .gpio = DA850_USER_LED2,  A4 C7 {8 R8 s) V& _' s
                .name = "user_led2",
- h/ o7 g) z  ?7 A& X8 A                .default_trigger = "default-on",1 L& x3 {/ m# l7 J9 q3 C& ~
        },; o( g* s6 N9 x1 J5 c! |9 g9 O1 l
        {
+ ]" s: N# c' K$ o  m$ j, F                .active_low = 0,1 y8 S+ F  W* X- [
                .gpio = DA850_USER_LED3,3 ^7 J* H) a% X; I
                .name = "user_led3",. @& C. i+ Y6 \8 |9 p4 b( \6 Y2 D
                .default_trigger = "default-on",( Q" A0 r9 W: r" u* v& t$ Y: n
        },
+ N' e: }1 F; @( }' \  s1 Q5 h};
6 t; c% }! w9 F6 G/ G  q5 d6 i" c$ E; L* c  r
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
* \. \: s' Q4 n0 ?3 w        .leds = da850_evm_tl_leds,( N5 p7 p) \3 q5 ]! s5 t& h1 O: f
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),4 A3 t, ]. o( `4 M1 A& T
};
+ I  Y6 \- L3 _+ C2 n2 b8 ^& M& \$ P/ \: S& n) z2 B
static void led_dev_release(struct device *dev)! W8 V2 U+ Y7 b
{
) z1 K0 [2 L! \. S% O% \7 @) ~# ]3 o};2 u% W+ E7 o5 t  j" [1 d# ]

5 ~3 a9 W  F# K* xstatic struct platform_device da850_evm_tl_leds_device = {
: N5 P3 T; b, P- Q& u$ z" b1 u        .name                = "leds-gpio",
4 _1 _( i$ {0 ], W, t( G+ I        .id                = 1,
4 R  q$ E! A; D  z& |) S        .dev = {# U$ y1 R3 U& V/ y: L( t
                .platform_data = &da850_evm_tl_leds_pdata,& e. X, @+ e) p( U6 ^4 b+ R
                .release = led_dev_release,4 Z: o+ V! b' N/ u3 X# z; Q# d7 o
        }" o) ]) U' s& G5 V
};6 e. t" F9 o- E$ B) n1 ]
; x+ m+ E# `1 x5 @, p9 _+ j
static int __init led_platform_init(void)- D! a: p* x' X3 h
{0 t: {7 }6 |: W( A$ z2 o" [
        int ret;
, C/ R, Z: v1 J& K8 g5 d#if 0+ ?1 o2 q2 Z1 `" b" p( T
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);4 a. |) u  g9 d0 [2 q% P
        if (ret)
4 I. }; k: v. |                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"4 O) `) A. O) }) ?6 d! F* U+ M' V7 l
                                "%d\n", ret);
/ T2 a  z5 L9 k- d( m$ ~#endif: g% H' ]! c4 i) Q0 g& p1 m$ D
        ret = platform_device_register(&da850_evm_tl_leds_device);# `: c% K" d& ^9 M/ t; s9 ?! r# v
        if (ret)% m+ Y* u) L* Z7 d, A
                pr_warning("Could not register som GPIO expander LEDS");
9 h+ H+ K$ i$ Q( T! V5 ^# ?  w        else, u) ]' w; A0 g4 N
                printk(KERN_INFO "LED register sucessful!\n");
: C. o6 Q8 |! |5 L7 \& y* k
. F! a1 v5 C6 j) Y, i        return ret;
; @& A* p4 N5 G4 x' q- l3 N0 I5 P}
4 O, K8 u! o/ ^# x* V# P+ a- @/ e8 @  w' c" r6 P8 r5 m
static void __exit led_platform_exit(void)
$ w6 K; S4 t. d8 ^{
1 K' X+ g* v/ S) n' G        platform_device_unregister(&da850_evm_tl_leds_device);
: z9 F3 d9 ]& L+ m) [4 Z# a" F/ m/ S# ^1 @
        printk(KERN_INFO "LED unregister!\n");
7 }( J0 ?8 o7 C1 @; g5 `  a4 c0 ]}
7 I( b6 w: b9 K5 W3 y
5 |/ t+ F7 J" c  Umodule_init(led_platform_init);( h" R# y1 |8 Q9 u/ {
module_exit(led_platform_exit);
- Y& e9 v( y7 |- u- @; [5 g( C0 e- ?/ D
MODULE_DESCRIPTION("Led platform driver");
; i( S) L' ~& W* }/ _; p4 x' s2 [/ bMODULE_AUTHOR("Tronlong");
! L: v+ @  X* G! [5 }) ]5 EMODULE_LICENSE("GPL");
0 D5 b# t% @2 i3 E6 O6 Y/ t& w( K' N/ c( s: r* q8 w, o
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-1-13 12:23 , Processed in 0.040468 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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