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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。# z  K0 U5 g: f; s' U8 g6 `
#include <linux/init.h>
+ g; r! N1 U: Z- n) `- @#include <linux/module.h>
, Q8 W2 `' ^2 o# q#include <linux/kernel.h>
6 P0 y+ M+ ^1 F4 a8 W#include <linux/types.h>6 r* b6 `6 B, x' ~1 H9 Q! z6 z% e
#include <linux/gpio.h>8 H1 y8 M0 w: s3 u1 o( N! }* b
#include <linux/leds.h>
/ d) J* f9 |  E9 i3 ?+ {3 @3 r' b#include <linux/platform_device.h>
/ C. u; V' H: ^6 C- G  y3 ]* _; S5 y& Y8 M$ z+ I' q/ Q; e+ \
#include <asm/mach-types.h>
% d8 o. ?# k6 \: X. f  z; X8 t#include <asm/mach/arch.h>
' |! T$ }9 K. [; G* r  a( Z/ v#include <mach/da8xx.h>
, Y7 {# m6 w: P& c5 }#include <mach/mux.h>" W6 }) s1 P$ R7 n
5 l3 J" Z# F6 Z0 H7 @4 b
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)# z' S* k# C1 Z+ b, Y5 m
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
! q& ?. S. A5 N! \% y% v1 s+ z#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)1 k, d1 W  W' v0 S
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
2 f# M. ^: ~+ T2 i7 f+ }6 t% c3 q" Z
/* assign the tl som board LED-GPIOs*/
+ B; u3 u! I! F+ `2 Qstatic const short da850_evm_tl_user_led_pins[] = {# Z9 b; x3 Z2 \3 C0 U
        /* These pins are definition at <mach/mux.h> file */
* L3 k' {+ }: G, c* r        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,/ F2 b; C6 A# Q6 M" [8 ]- n9 I
        -1! R8 M! g+ m8 j  j! S
};
9 I0 V$ T0 U8 O" ]* P# |
  `6 D" D+ @' a% Vstatic struct gpio_led da850_evm_tl_leds[] = {8 ]7 N% A2 R- c. O3 S& T, s3 L
        {
0 |! S* M& ]2 Z1 u# W                .active_low = 0,
+ ?. t# p% _5 X  k2 u1 [                .gpio = DA850_USER_LED0,
9 S0 _; R! l1 {" M9 w                .name = "user_led0",0 U- ]4 T+ L" `2 G
                .default_trigger = "default-on",
& [  S( a) j" r" t* o9 @% u        },
# U- j) T& H/ j6 N1 @        {/ }) N, D# D7 L- W2 C! y0 V
                .active_low = 0,& D. m8 e0 X7 m) J) {5 V
                .gpio = DA850_USER_LED1,
+ }. q( Z. _7 m                .name = "user_led1",; X' \& x+ @' J- c
                .default_trigger = "default-on",$ y- N) f' d5 t1 g2 }8 d
        },/ W' Q$ y) g9 m; T# x
        {
# b! D: X# L) ]: g* f  K                .active_low = 0,) U* E( D  {3 q! H
                .gpio = DA850_USER_LED2,! z& L9 `& C( P6 D. v
                .name = "user_led2",
  p$ f4 \: x% D7 ]8 F                .default_trigger = "default-on",
$ J$ M5 N, Q- n. U' x        },0 X. f. m( z& D7 e0 M
        {) c5 E9 H' O- r3 q# E% b" u
                .active_low = 0,7 h) Z' B% T- J. Y) E
                .gpio = DA850_USER_LED3,( V$ a! r- K1 n$ @* b# h  }. t
                .name = "user_led3",7 \. b, r" k+ G" R: i6 i
                .default_trigger = "default-on",7 M' `* W9 U+ _; q# c
        },% {: J. d! [  _  A, F  O5 k
};2 H0 g6 E! {. w8 [

, L( U. L" J  A9 e! J' cstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {$ P9 f2 p5 k1 ?
        .leds = da850_evm_tl_leds,
  S3 _" X, d( b        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
* ^* S( L$ E) ~* g: ]};) ]' ]! o% h+ ]& J: L0 X6 a

9 y* u" y% K: Cstatic void led_dev_release(struct device *dev); N5 p6 E& ?) C* c/ M* x0 @: b$ ?! k; I
{
! b: s- h8 Q3 U: Q( T4 S};
; P& D+ R' k8 h, ]" w% [# {) e; A5 ]! _6 i/ z; `2 s2 A
static struct platform_device da850_evm_tl_leds_device = {7 F! d: p2 _. Z0 r- e
        .name                = "leds-gpio",% m7 F/ R% E! @& K/ @) w6 F7 X+ A+ z
        .id                = 1,6 y3 @, ?# f. }- q* X2 Q
        .dev = {
2 S% e" K+ t" u; N  s: G                .platform_data = &da850_evm_tl_leds_pdata,' y( J: e& f1 T7 s9 k6 K
                .release = led_dev_release,
2 p: b9 g! ?# \# }        }
- L: c8 J3 L. u  s( g8 W" H! j. Z* l};$ e% D7 F6 X: {7 m7 V5 x* Y

# E7 ~! e* Y5 I5 v$ @7 Lstatic int __init led_platform_init(void): Y( x5 n1 d4 `1 `
{
( m" F0 U5 m7 v+ g' A) Y8 G        int ret;
7 t' E7 V, C  h4 r#if 0
9 ^! A8 f. Q) r( y        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);3 M/ r9 t2 x+ x7 j8 G+ L
        if (ret)* n1 b7 J' S0 t, k0 k% S1 A
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
4 m9 ?! }* `! D4 m* n                                "%d\n", ret);
9 V9 I2 N7 N- Q: ~8 Y4 n#endif7 D8 Q& g0 m+ D, Y" ~% }
        ret = platform_device_register(&da850_evm_tl_leds_device);
# I+ d1 c% U  N  }8 L        if (ret), d6 `" D, j, K. D4 F4 l! }0 O! d
                pr_warning("Could not register som GPIO expander LEDS");
2 q+ [3 h. E% G( ?; O0 s8 U        else
+ N% A0 W4 y  ?: N% n& Y0 w8 @# _+ T                printk(KERN_INFO "LED register sucessful!\n");' ~0 K7 }; |' O8 T  |
( \  g7 d/ F* ~! G4 m5 k2 @
        return ret;. C; _; n4 M9 X& Y! v
}
3 A9 b7 q) [4 m+ U, q) O' R/ D$ f, I, P( R0 C: o* X+ `
static void __exit led_platform_exit(void)
% I4 E# y% ]* m& Z{6 }+ `8 M" ?+ s, P) c" G3 I! p4 r
        platform_device_unregister(&da850_evm_tl_leds_device);
* C' i' {" q& l3 K( X. c( U1 J: J; q( B* X. W  N/ U+ y+ t
        printk(KERN_INFO "LED unregister!\n");% o- P0 l/ b9 X* |$ P) u
}
& p. q5 {( J4 b3 S8 f- A0 X) r% ^+ C8 y3 D. q" T6 t
module_init(led_platform_init);% G4 R+ u8 _% S& J
module_exit(led_platform_exit);
; y0 H6 O0 y8 t% ~9 J
* L$ b1 x! G4 ]; o# O8 BMODULE_DESCRIPTION("Led platform driver");% ^& d- u( D6 @6 _
MODULE_AUTHOR("Tronlong");
3 ?; ~3 P' i7 I3 a9 e4 ~MODULE_LICENSE("GPL");
# U5 Z& u. b8 j; z- e+ o' ]# N
7 o0 r2 _" F* I, I4 M5 E. K
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-17 11:01 , Processed in 0.038691 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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