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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。' O( A5 @7 F/ O. a# E! e: B, A
#include <linux/init.h>2 `- F: v' t, u8 B( b; u' e
#include <linux/module.h>5 f5 J& n6 f1 k6 h% s* X
#include <linux/kernel.h>
7 a# G& S9 Z6 z" K+ q: m) `" q$ L#include <linux/types.h>
: a4 L) g- G0 G#include <linux/gpio.h>' K& b% a% {7 C  U
#include <linux/leds.h>
3 M  E8 A. ]6 R! F( U8 U#include <linux/platform_device.h>
8 s8 G) C- S! n! Z( b% j4 i2 i: [" p, z5 {
#include <asm/mach-types.h>1 g* V0 U: l# ?& Z; m% D( Y
#include <asm/mach/arch.h>
! B( c) u6 l  O% F2 ^#include <mach/da8xx.h>( ?+ |% t! q  z7 ?7 ^- @% V
#include <mach/mux.h>
2 |1 n' Y4 s& ]
' y3 M6 u7 s- z) J5 H; [' r; J3 a#define DA850_USER_LED0        GPIO_TO_PIN(0, 0). t' r" v1 V- n5 h( H
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
' L" i% w6 k0 ^/ P#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
" ]8 O9 z& U' q#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)$ a; m  W/ ~1 \- k  u  j

8 N, t  a2 O9 k# R/* assign the tl som board LED-GPIOs*/" `2 @  H2 o; N9 a' b! A( [' W
static const short da850_evm_tl_user_led_pins[] = {. N  l% T3 y2 h( O
        /* These pins are definition at <mach/mux.h> file */
: ~1 m! B) Z' A+ S" F- e0 w        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
/ X1 E4 M, z1 c" t# _; W! L3 Z        -1
4 a; p0 `5 \9 j$ Y: f: b3 Q3 o};
- {+ j& n) M, f% l+ o- u+ a) `! x3 A
0 c* A: ]8 z( k7 a9 E& lstatic struct gpio_led da850_evm_tl_leds[] = {% K" \) J, w% d& E
        {
) n- S7 U  O, w( ~) U1 V                .active_low = 0,6 }: b# C. ?# C( e5 N' E1 i9 Y, A
                .gpio = DA850_USER_LED0,
6 W* u$ D" z$ O8 p, t                .name = "user_led0",
/ {6 b: J9 G1 U2 j* ^0 y+ U                .default_trigger = "default-on",
$ Q1 S8 N0 I' i+ x, {        },, K- w. G) e8 r+ p
        {
4 F8 |: {% ?( Q4 q                .active_low = 0,8 n0 t# Q' c, G: l! h1 F! K
                .gpio = DA850_USER_LED1,
7 V- m, L) n( i; U( u3 a) d                .name = "user_led1",
9 Z) B( x8 U; M: A" ~0 f8 D                .default_trigger = "default-on",, o4 d) I6 t( ~
        },2 f0 N% W; z$ D. f: U- q: u7 ?
        {
  D/ A) I! ]( |" E$ ]                .active_low = 0,
" D/ R/ R- j6 }                .gpio = DA850_USER_LED2," Y6 q% ]$ c' k$ @& k* H9 A8 y
                .name = "user_led2",2 V3 F) L3 c* x6 h* t
                .default_trigger = "default-on",
8 R2 L; i5 m* ]9 c2 u# j0 ^+ V" j        },
* _$ C( [/ O# O2 [9 f        {
8 s/ p( u: A+ `; s0 o% \                .active_low = 0,
0 k5 S+ R. a* A* R                .gpio = DA850_USER_LED3,
# B1 Q; k4 y% P# U2 k- v2 E6 w; m                .name = "user_led3",
/ G' y. v1 ^. ^$ z6 E& a5 d3 d                .default_trigger = "default-on",
7 U; I9 P( ?) Y4 G" ?' f; X4 P4 X        },
5 S  k3 a9 p) ~0 k0 e2 ~; [6 M2 g};$ n0 X8 [: r: c' Y, U% Q
7 z/ L9 t4 v' s# F6 i7 f
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
) S8 P5 f( Z7 t. u2 w        .leds = da850_evm_tl_leds,/ Z8 s  l: c! E$ {/ i7 `2 S8 x2 A6 ?
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),' H  ~9 C! o* P
};4 U6 {; h' c7 x( _

1 h0 r7 u5 p+ o6 tstatic void led_dev_release(struct device *dev)7 S: v+ ]6 H, f8 @; ?5 V+ q
{
, ?3 k8 w) v. E) D  h+ b4 c6 R};
4 q" U: w8 B7 w5 R) u8 d8 {3 t- A9 F: k0 B0 O7 K% B% X5 a' q0 D
static struct platform_device da850_evm_tl_leds_device = {
( ~, U: w1 E% U! \  f        .name                = "leds-gpio",9 q7 I; Y- z4 z" I( w3 H! W9 h8 K, v! l
        .id                = 1,
  N5 A; f, u( f- t- R        .dev = {- h* X' o6 {. ]. a
                .platform_data = &da850_evm_tl_leds_pdata," [9 h( d. M* {, e; {3 i
                .release = led_dev_release,, n% l. ~* [0 Q0 V* k! T
        }- x# D+ C7 `( t5 c# K0 i% ]. s
};- K+ I7 z% x( B2 T; r

& L- t& \0 K; ~6 m' e# J8 b' {4 fstatic int __init led_platform_init(void)
$ d. ^, ]) ^9 F* L# k; t; \{! C! Z9 V9 N  m& f; R  M% [' f; ?
        int ret;% Q% `4 C. o: r% i( R+ {; [( ^2 l
#if 0- O) ^2 ~2 _6 \1 Q( C
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);4 a' q% r: W* i! }6 i; W0 O
        if (ret)" {0 U, e+ x( O  [% k. }) q' C
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :") g' w0 ^- d0 ~6 L  Q
                                "%d\n", ret);( ]+ y: j2 n$ v# _" Z
#endif
* r/ m2 {$ O, j1 H! h9 h2 n        ret = platform_device_register(&da850_evm_tl_leds_device);
8 [; M7 j  l8 C1 c( C        if (ret)3 C' h0 R9 f+ |/ m
                pr_warning("Could not register som GPIO expander LEDS");
3 S, V/ J9 c3 ?5 @4 |        else( X7 A& _3 R6 \1 r/ q" R" z! I, z: k
                printk(KERN_INFO "LED register sucessful!\n");
1 C" x% W. w5 H  \( ^3 u0 z
- m: I* H. @  L        return ret;
6 j+ V5 z0 k& F4 d3 z5 [$ {}( G8 p. }, h2 `. ]( R9 x, }

- w1 A7 ^6 {& y7 b' R. E/ \# Wstatic void __exit led_platform_exit(void)
+ Z# J, w2 q+ R( |{
/ e! i" W* n9 Z: |        platform_device_unregister(&da850_evm_tl_leds_device);
) R  M+ u) w: X( l
: ~7 G4 _6 |0 W5 ~8 G        printk(KERN_INFO "LED unregister!\n");
: s  o- J6 V9 D1 V* k6 s}+ ]. o. G" U: |# l$ P8 R4 N

; f9 V2 \6 b- ^+ `% Omodule_init(led_platform_init);
9 N2 W; s9 y& u  C3 T/ m8 z4 J* }module_exit(led_platform_exit);
6 G1 U+ g* f0 U' f- B
9 f; O" R) Q( ^) f# `MODULE_DESCRIPTION("Led platform driver");4 I. q: q9 ]3 e. n! @
MODULE_AUTHOR("Tronlong");8 k/ w/ g- u8 p5 ^9 ]+ T1 o
MODULE_LICENSE("GPL");3 s3 C: \6 g; i

+ S( I; O/ E' Z% S& L
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-7 14:04 , Processed in 0.041109 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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