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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
% p8 I' T6 Y( d# q6 v! n#include <linux/init.h>
1 U- Y  G6 ~3 u#include <linux/module.h>/ W: i$ n1 E$ L! y7 i
#include <linux/kernel.h>/ Q4 |" C1 c' s3 d0 l/ ~5 Q( m
#include <linux/types.h>
) H2 S- F/ H% h6 y' U! U0 U8 B#include <linux/gpio.h>
- v, ]$ R9 H) P5 \8 m2 ~* J#include <linux/leds.h>+ F  W0 I( ^: g; E' z& v( o
#include <linux/platform_device.h>
3 X" S" r% e$ P7 @6 I) i6 j( i7 s6 }* U) t9 F4 |! l) J
#include <asm/mach-types.h>
& V* u% o$ G3 r/ U9 N#include <asm/mach/arch.h>
; V$ d$ r1 J5 \2 o; \8 w#include <mach/da8xx.h>
  K1 ?3 O6 Y; ~8 B; V# ~#include <mach/mux.h>% r% L+ d) d' I5 a7 B0 e* f! F
2 c6 d* c0 c4 u+ P: g$ e
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)/ I/ K( p- m) l) M+ m2 q5 F
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
! y6 S+ w: v: O; k#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
. F' O, \4 e! v* \#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
. }3 R  t% i! }7 f2 a) H( ^6 ]1 }3 y% k; L
/* assign the tl som board LED-GPIOs*/) N! b+ Q" x# ]- h1 W0 ]1 M' F
static const short da850_evm_tl_user_led_pins[] = {+ ?( I7 e0 X* ~  o
        /* These pins are definition at <mach/mux.h> file */
8 H2 y; T' q( G) k+ i        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
6 f/ C2 S/ I/ [# Z5 B- L2 X        -1- b; V' K% @; i" [3 N* Q
};! X( `5 N9 m! Z7 j! _* G. Z6 A% n

3 P1 J, a& t8 y( H4 Gstatic struct gpio_led da850_evm_tl_leds[] = {" q+ M( w& b5 K) _$ V
        {/ Z, k8 r! N9 E5 w6 x" {- U
                .active_low = 0,
3 G5 z& K% W5 m0 F7 J1 V  }                .gpio = DA850_USER_LED0,
$ P: \' x3 p8 N) a8 A+ y                .name = "user_led0",
3 F. U9 X% b* V# c, Q                .default_trigger = "default-on",
4 E7 j5 k/ T4 C3 V8 s; V        },
$ h* J" y# i4 v4 V        {
9 o9 {, l8 V3 a6 e( {. z( W                .active_low = 0,
; R& q  e* k. t6 Z* X                .gpio = DA850_USER_LED1,! y  E) t* m& x" [
                .name = "user_led1",
1 F7 T, c& C9 O9 f                .default_trigger = "default-on",! N, S' {6 k3 ~. R% Z1 {+ N' m
        },
9 J$ M) W& W; q8 l# N! k; Q        {/ |5 l. B$ P2 Y' [5 O. a+ [
                .active_low = 0,3 i; q2 K) F1 L# ?
                .gpio = DA850_USER_LED2,
8 i3 j3 q9 E2 g7 r0 {                .name = "user_led2",
8 h0 m; d; E- A; R                .default_trigger = "default-on",
' \! d1 U7 H) m' w# v! i        },
" D+ C; I6 @/ w% Q: c$ g' N        {# A  k9 w0 S; v- R" }6 i7 }
                .active_low = 0,& i4 ]* [' u1 o; I: O
                .gpio = DA850_USER_LED3,1 t+ e' x0 a: j/ |" Y0 p
                .name = "user_led3",
9 t: l! W: _3 B8 S  s                .default_trigger = "default-on",% r" @. d6 L  t8 f
        },- t+ c* s& A4 E: L- _8 w$ U
};: w. |: [( L* |7 h+ a

' J: \" m: w& k) t  ?! Dstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
  [; w# i2 J7 ]. r$ Z2 ]% d4 E& Y! p/ D+ ?# D        .leds = da850_evm_tl_leds,
& K: s/ S. m' f7 c. _        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
& s: Z" A/ p3 _: J; S7 Q# W  B};3 P4 T, y* G9 R7 c1 R

' ], L; i! @# x6 H3 E/ U- Tstatic void led_dev_release(struct device *dev)
0 A% u9 ?2 Q( r/ z3 N2 Y{
* n+ H, k% c" @  G8 {4 a; I};( F* u) Y' `, M6 @7 V: M4 `

  B/ t" J) j* @; _5 nstatic struct platform_device da850_evm_tl_leds_device = {
8 o0 B$ O# z* ?$ O& X        .name                = "leds-gpio",) p) H9 T& R5 I1 t7 M
        .id                = 1,
/ A- \5 C! u+ p% _+ `5 I0 H$ m; x0 O        .dev = {7 c# [8 a0 c! b) r
                .platform_data = &da850_evm_tl_leds_pdata,; u; n7 y* E/ Y3 V' N
                .release = led_dev_release,! M: U7 n6 L/ _8 S
        }: Z: y+ r$ O/ i7 x
};
( z( b8 i8 K5 t
$ Y+ y# x6 g3 ^' l/ }5 ^static int __init led_platform_init(void)' A1 h; l8 l2 s. l$ k' H
{
5 J) H& ^& \2 r/ {$ X4 M, G        int ret;) a  m1 m( h7 c$ I5 @1 S- Q8 H+ r
#if 0; ?$ W6 L6 M, U6 X/ O+ O
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);/ G; q$ Q. G! l' ^7 ?' d- O
        if (ret)
: e! v+ Z" X9 a8 ]$ d' B. [                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
9 a9 i: @1 n7 D" V; K# n: j                                "%d\n", ret);" P, S. U; e* v& K8 [8 b& w/ m* n: }. ]
#endif: Q' a( j: m! H# O% [
        ret = platform_device_register(&da850_evm_tl_leds_device);9 b2 [  _4 ~$ b0 L1 {
        if (ret)
2 j! l& u8 G% ^# N& }" Z  k$ n                pr_warning("Could not register som GPIO expander LEDS");
3 `; E; ~, S, w+ }        else
6 ^5 c' V( V7 N1 X! `' K. Q                printk(KERN_INFO "LED register sucessful!\n");  [2 k7 M4 h# s" o! G. p

7 q" q2 v8 ?+ D, U5 s: S        return ret;: {9 o0 @  z  T0 q) @
}
$ C* E, s' ?( k+ |
+ @- L9 P# }1 @2 v+ j& ystatic void __exit led_platform_exit(void)' x: ^6 r  O+ n" H$ K9 U+ c, S4 n
{
, R0 D% [  ]% z. J( }        platform_device_unregister(&da850_evm_tl_leds_device);8 n2 _( B: t, }3 }8 y* `, N
& R- Z' ?5 i; ~* V
        printk(KERN_INFO "LED unregister!\n");
$ o6 {6 X% N, s6 v* l8 K}/ p/ v1 Y  O3 O0 V& Z% m

/ T$ d9 l$ t# `  w3 omodule_init(led_platform_init);
+ v  C! o& z5 z+ j5 ^module_exit(led_platform_exit);
! H, A. s( T0 l1 t0 v
+ e6 U* h9 G" I! xMODULE_DESCRIPTION("Led platform driver");
4 _6 e6 K0 M% C9 R' m8 MMODULE_AUTHOR("Tronlong");) C) g) u) K' ?+ U
MODULE_LICENSE("GPL");7 b8 C1 ?7 f2 c2 y% |  Y

# r- ?! j. P! o
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-1-13 15:36 , Processed in 0.041552 second(s), 28 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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