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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
- p7 {0 W( s& A3 D, A- x" Y#include <linux/init.h>
. r2 F5 j- }3 q#include <linux/module.h>
' g- k8 R3 K. [; i0 H( x  n! C#include <linux/kernel.h>6 A: r4 z! @  v# b! L! `
#include <linux/types.h>. k4 B8 S% J# L8 U* E) l& [
#include <linux/gpio.h>
. J9 x$ c3 x* [$ h#include <linux/leds.h>0 W6 g0 G& e8 C6 j# v5 F
#include <linux/platform_device.h>. U/ p6 C4 l6 P

/ Z( I) A8 y5 t$ F3 Z7 l#include <asm/mach-types.h>
' w- c4 Z2 V! k  x: k5 g8 ]#include <asm/mach/arch.h>6 g. q- x1 w8 k5 B! O: v
#include <mach/da8xx.h>
. q; I1 l; u. M- x& I#include <mach/mux.h>
' W3 u% U* j8 G" z4 i8 B
  }% D! N9 n! V8 \#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)  I" d  O4 n+ h6 S3 w% T; ^0 \; h
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
- l/ _5 K' {7 d" Y$ u7 z#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)$ t* W7 A  d0 s( Y; V4 L! t7 o
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)# Z5 p. g' r, ]) |3 C

$ _2 T, o, i7 d, T, \0 o/* assign the tl som board LED-GPIOs*/4 J% F; Z) l# ]7 F  j9 s5 g0 z
static const short da850_evm_tl_user_led_pins[] = {9 i5 o* R5 i3 z2 v( e! k
        /* These pins are definition at <mach/mux.h> file */
3 c1 L3 g# x5 Q$ i' G% A        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,% G4 Q7 g0 e( v
        -1. i) S6 j8 J9 I+ ?& e
};. `5 |7 w" ~) W* x
# f: s: E; v5 p% P" E2 m
static struct gpio_led da850_evm_tl_leds[] = {; E2 s9 y/ p9 T5 G4 ]5 J
        {4 \; {/ D7 u  b$ w3 Q2 B
                .active_low = 0," K: l  }4 N, N1 d% Y, L% D
                .gpio = DA850_USER_LED0,
$ n. _. k  O6 r5 w1 Q' j                .name = "user_led0",8 z5 O# |; T% @) ~( x
                .default_trigger = "default-on",6 K: R/ H" n* x' F' P
        },) t" k5 ~+ s4 A( [8 b) |/ W- ~
        {
" [8 J. d$ P. U9 u9 ~* C                .active_low = 0,
# o3 C1 z7 [* K: U                .gpio = DA850_USER_LED1,
5 P$ r  Q% D+ A3 \. t6 c* Z                .name = "user_led1",
' ]4 h3 x8 {! d* s                .default_trigger = "default-on",( ^. y/ J- r) N- B: M( u
        },
* }+ u* X& y1 Q2 m' Q& J; E        {7 J( {4 h' ]) r- t
                .active_low = 0,
- {3 G5 `5 U1 C8 _$ p8 x                .gpio = DA850_USER_LED2,
  G6 }0 C5 z5 @- N2 I, x6 y# d                .name = "user_led2",
' P3 M$ X# p0 ?- l& f2 y                .default_trigger = "default-on",
! H+ a3 P" D  b! Q0 }3 J4 B        },
( x. M# s) [! E5 i& _        {
4 X( A+ V1 A4 H                .active_low = 0,
/ _* h% J5 c! M                .gpio = DA850_USER_LED3,
: P' W, S; e  l1 }" o" \% [                .name = "user_led3",
8 V' ^9 P# ], {$ g$ L                .default_trigger = "default-on",2 \* x" l5 a" d& D- R. ]: F
        },9 U" p9 K2 S9 a# y& ~( @1 u% W8 h
};& A0 J1 l5 ?. B8 V* D, j
: t3 v7 I  ~( {' z/ b0 y+ ^
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
: J! U; z) `9 B6 g. X7 b) @0 w        .leds = da850_evm_tl_leds,
9 t4 z( n7 e& K/ i/ I        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),3 }+ f7 g* r2 O1 F" I2 t& v9 l  {2 W
};6 Z3 ]; G& q' h6 Z. Z4 J
. U% U* T& ^! {8 Z7 I% x3 Z
static void led_dev_release(struct device *dev)
& _% B3 w% k# J( m0 K! Y; ]2 o{
5 {# d6 d- d; s9 k};$ l4 }% [7 f+ ^3 o& p, p

# e  H* c+ M/ }' G' estatic struct platform_device da850_evm_tl_leds_device = {2 P. [0 e- G; W. }" m
        .name                = "leds-gpio",
7 a' j2 L) q4 X- }. r# L0 H% A, W        .id                = 1,
  A% m/ [* s; k( t        .dev = {& |8 V: B5 X" {% m" b
                .platform_data = &da850_evm_tl_leds_pdata,; E4 z- D( F/ e. H  U* z2 e% N! y) h
                .release = led_dev_release,
& r  P( J# N3 g* H8 ?2 R        }
6 e2 O, w9 A- I};
; k5 B7 A& }! V, F% i" q
) {7 S& x! k# A  istatic int __init led_platform_init(void)1 f7 x+ Y& J& a) K
{
% a- A5 ~2 f  |( L" e# i2 Y        int ret;0 V2 Q! J# T1 |. n  L) A# d
#if 0
- |* Z7 o+ \& d7 q) y9 o% T        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);* c1 H- n4 F/ Q4 G
        if (ret)0 d, g0 ?4 S: g9 w; O- `
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
% P' g/ W7 K- L# {8 ~. M                                "%d\n", ret);
$ v& h3 A1 P4 V#endif( [$ X, N& k% J0 ]- ^- p6 m
        ret = platform_device_register(&da850_evm_tl_leds_device);
8 s! ~6 h& Y0 S        if (ret)1 X  q8 g' ?' Z" V# }
                pr_warning("Could not register som GPIO expander LEDS");( M9 L( ?9 J$ k6 K0 m
        else
) p1 z) ?1 i$ `. z                printk(KERN_INFO "LED register sucessful!\n");! f' |- U2 T! k, f  e

/ H6 V" [$ C, Z1 I        return ret;5 V4 O& |$ N, h5 i% r& C
}! B$ s/ T0 ~% z* }$ |
$ C2 b& {3 b$ a- n& f
static void __exit led_platform_exit(void)
6 I8 x6 y% c  a$ V9 v4 P! Y: ]{
' j# b  o! X% U/ V& g        platform_device_unregister(&da850_evm_tl_leds_device);2 Z5 f! i! z3 Q- _9 t0 d

. [5 p/ w/ N: r  K$ [% x        printk(KERN_INFO "LED unregister!\n");; a% V$ }% @2 A& n# T
}# ]5 _& [5 l0 _

8 ~. E& G$ n' ]" ]module_init(led_platform_init);
% c1 r2 k' Q$ [3 j2 g0 I# {/ Pmodule_exit(led_platform_exit);  i! {& N& t- e0 ^: s
# I* s/ H# y: X4 H+ e
MODULE_DESCRIPTION("Led platform driver");! N0 F# R. e1 R1 V, e/ d  X* C. u
MODULE_AUTHOR("Tronlong");" R, K4 ~/ U4 B2 O6 T* W4 R* S
MODULE_LICENSE("GPL");
: C) H* j5 Z% O: p6 S9 x: {' v8 K* b) p8 k
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-2 08:41 , Processed in 0.039910 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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