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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。# @! o) x4 J' h4 N+ {! Z$ Y' N
#include <linux/init.h>! X, f* L2 w. l
#include <linux/module.h>0 P9 ^  p2 ^3 F/ y# G
#include <linux/kernel.h>
" \2 K1 j9 B& a' a1 v' R# ^#include <linux/types.h>; }4 f" \) u* K! S3 u8 q
#include <linux/gpio.h>4 U6 u. Y1 G9 u; c$ |
#include <linux/leds.h>% E6 D# M7 c# k3 }
#include <linux/platform_device.h>1 J$ R9 e7 _# g4 @2 V9 r9 {; M

2 w5 m3 o! ~: D; E# M% m$ R#include <asm/mach-types.h>
$ ]3 {9 `7 N  T/ j% k4 k#include <asm/mach/arch.h>+ h6 Z2 X9 @2 V; S2 O( o
#include <mach/da8xx.h>
$ P$ `8 ^4 F' D2 D8 G7 Q#include <mach/mux.h>
; C- U8 `4 `0 w; c/ R
9 d; O! f* g, \: \. E$ v4 u#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
7 H0 W" z2 N0 K" v5 Y" a& k2 D#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
! V# i5 C% Z( F/ ^2 F4 y) M#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)4 ^# n8 y  b: v. H
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)9 J! `; B( [$ t* X8 ~. W2 a1 O
& ]: E( r% Q3 ?) M# S
/* assign the tl som board LED-GPIOs*/( m/ G! t* F" Z
static const short da850_evm_tl_user_led_pins[] = {
+ L4 p7 @2 M# h3 `- k9 r        /* These pins are definition at <mach/mux.h> file */
. ^( B9 m/ d6 z1 j8 T        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
! m8 A) |( ^8 r, L        -1
9 j* x- k" X& h1 P" u: N* n5 x};) [# q! b6 R% y+ ?
% v/ C# N- [# g
static struct gpio_led da850_evm_tl_leds[] = {. o, F0 B7 I. Y
        {0 N+ E" K* t! n  t9 i, L
                .active_low = 0,$ y5 E1 u9 V. K) \
                .gpio = DA850_USER_LED0,' f. ]: b3 n1 t) S+ W( N
                .name = "user_led0",  R3 L2 N3 I  P9 {1 P9 X) g
                .default_trigger = "default-on",
6 g* }1 r5 {' j$ m' E# A        },: w+ n  z& k, m# ^2 q+ z7 `% b. x
        {6 J  I7 e% v, Z) r! X4 c; d# k
                .active_low = 0,$ X5 y) b0 ?: G& b
                .gpio = DA850_USER_LED1,. f% `) R4 r8 a
                .name = "user_led1",8 f5 k5 g! I7 b6 x$ k
                .default_trigger = "default-on",  `  y, w5 f4 A, O7 `2 C
        },
8 ?  q; X" L9 \% N* r; n        {8 u" l# R1 J7 r8 E; v
                .active_low = 0,4 K) y/ w% N% P  B; d( U) J$ n/ E0 f
                .gpio = DA850_USER_LED2,
+ z/ d5 ?& c" r                .name = "user_led2",+ y, s0 [* w0 g! @7 |: W: y
                .default_trigger = "default-on",- u& I  A* D" z8 y2 F* _; _
        },* A* C4 g/ |  Y6 P2 S# m( q
        {
' ~1 h: D3 G; [: j1 A5 y                .active_low = 0," O3 U$ L& t- T- C" Y1 M# }
                .gpio = DA850_USER_LED3,
2 ^4 O) e& q& n* Z4 X$ C, r                .name = "user_led3",  H8 G; J0 _. P- T
                .default_trigger = "default-on",
3 H0 k5 R  g9 O        },
" b- \9 |. J0 ]};
) p7 F  {( b0 x  m
0 |/ l+ H$ k. rstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
- o3 o6 k3 O- W        .leds = da850_evm_tl_leds,4 ?4 ]  P0 o: t- \3 H
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),) V  p  _8 N; L2 O- M
};! O! K: N0 j, ?# p; s  M
: ^, S! c6 V8 K1 I$ r
static void led_dev_release(struct device *dev)8 Z' B* x8 J# }8 ^3 j& w
{- i; }5 Z1 O* K$ Z0 M; f
};" d( ?% t0 f8 x' K! Z

+ [# A  M8 e( Vstatic struct platform_device da850_evm_tl_leds_device = {
5 g$ ]2 |; O. ~        .name                = "leds-gpio",
7 C5 m- {" i* I1 g% }) ]        .id                = 1,
- M6 V4 @* f) m5 x: b        .dev = {3 X6 L; e# h" [8 a4 O8 C+ s
                .platform_data = &da850_evm_tl_leds_pdata,% X' J6 {; O: d& l
                .release = led_dev_release,
: e+ Q7 u0 n" U2 r; t7 r2 ?4 D, o- R        }
$ t( Z0 R, L# u2 J};
6 S* l1 k  M9 p  w, f' E$ c1 S- L; _7 s3 ~% ~3 ^
static int __init led_platform_init(void)- g% g2 L/ r. b; P; p8 A7 g0 O. t
{
- L4 ]9 U4 E% Y        int ret;
6 Y4 R( x  x  J% r  r  Z9 k#if 0& \. ?& R% n3 G$ ?6 Y" y4 D+ s
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
0 y- m+ Z3 ]& _        if (ret)
( n5 ~. o5 b' ~- }                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
/ J2 X0 c& M% j$ N( u7 ^8 k  }                                "%d\n", ret);- }1 \5 l! b& T" j" G- G) D
#endif
8 i1 P0 d/ Z0 t( k        ret = platform_device_register(&da850_evm_tl_leds_device);
9 }& W1 }7 L) w: ^        if (ret)0 Q" S6 j6 m" a; K$ [) k
                pr_warning("Could not register som GPIO expander LEDS");
9 Y( x; i' w! o* k        else% b" b7 J1 ]  M- x
                printk(KERN_INFO "LED register sucessful!\n");
- O" x, v" ?3 Z3 F( {& Q4 j1 T6 n% l' n- ?, s5 B' `
        return ret;1 F5 I4 ]+ L9 T( {
}
7 X/ L4 O( q# X) N% [4 f0 Z" K# t4 I4 p  G
static void __exit led_platform_exit(void)
2 n* C7 A, ^- _) `{
: R% F# N1 \6 m# s        platform_device_unregister(&da850_evm_tl_leds_device);  S8 K1 `- [' x# M5 m. t- ~. Q8 l

8 X. [" k) [/ U7 g: w7 M/ R        printk(KERN_INFO "LED unregister!\n");  U7 Z; e# H6 d+ G* {! x) o5 A3 a
}6 F3 w3 }& t0 k. o

5 u( i; X" n# X, Omodule_init(led_platform_init);; d/ {9 f2 S: b  S* @
module_exit(led_platform_exit);
- C5 c4 {+ h2 J* d; t
# D1 ?2 U9 W9 RMODULE_DESCRIPTION("Led platform driver");' N' x6 Z/ a: x: g3 E
MODULE_AUTHOR("Tronlong");0 J3 t# s! C: Q' q8 P% y5 O, n
MODULE_LICENSE("GPL");, @. w5 n$ k7 e. E# g

% T  a, R% \# m" J5 ^7 j
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-21 11:15 , Processed in 0.039259 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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