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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
5 _6 H( e: b4 y! P, h: p#include <linux/init.h>1 B# t: Y- @2 N- H8 G" |9 K+ W
#include <linux/module.h>
2 T+ H! P6 _6 P% W#include <linux/kernel.h>
# t& k( b  |& `# k* B5 t#include <linux/types.h>
7 s9 R0 F. N& f! u#include <linux/gpio.h>0 e: @3 H8 V/ ^* f
#include <linux/leds.h>
: @/ K% x0 u1 H1 }, ]. O#include <linux/platform_device.h>
; _! e; e- p( z
. W+ X$ N+ t" t. o#include <asm/mach-types.h>. k. N6 {7 N. K& X9 ?
#include <asm/mach/arch.h>8 `/ D  C& _9 S/ H$ C
#include <mach/da8xx.h>
& h0 S' p3 U, ^* |0 e1 \( T#include <mach/mux.h>9 `' C4 ^4 `# q0 {

' p, R) z& h$ q$ W1 }5 K6 x#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)( \# Q. t& _' X: \/ M
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
" h6 M: W% E$ ~' b1 K#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)* }! C$ O. E0 D7 ?& A5 w7 V& x2 V
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
  {1 V% q% U4 n/ O8 |4 P+ R1 p9 @& @, s4 t
/* assign the tl som board LED-GPIOs*/7 _$ u0 v2 _3 P5 a1 b/ z9 n  g+ g# L# h
static const short da850_evm_tl_user_led_pins[] = {: [8 ?$ D6 g! G$ a/ L" O" S8 N
        /* These pins are definition at <mach/mux.h> file */
0 g( x% U) B8 C9 f9 F        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
  u' B3 R! h1 ]" k# N        -11 @" p5 c' b$ ]5 y8 ]" x
};) ?( o( U: o8 F* f6 B2 I- g/ s

" N/ o- A' O+ r: Y# z, e, `2 o- kstatic struct gpio_led da850_evm_tl_leds[] = {
/ N1 ]" l7 _8 H8 }0 P  ]8 ~        {
) B6 l  A7 n% D* C                .active_low = 0,
& k" _- ~" Q7 L2 U8 R$ N) Z                .gpio = DA850_USER_LED0,+ l' ^8 @' W- U( [% ~8 i. J
                .name = "user_led0",# s- P2 T; j9 v, O& Q4 s; x3 X
                .default_trigger = "default-on",
6 E# z2 C. j* _+ u3 G8 ?        },2 K! F5 e% h: Z- M! E- M
        {. [' j& r/ o" |* S' G4 Z% Z! A+ p7 V/ L
                .active_low = 0,
7 K! h" t. V* t5 m- U& Q                .gpio = DA850_USER_LED1,
& J- H8 U9 s! @# a* |                .name = "user_led1",% @8 k. G1 d& }# V
                .default_trigger = "default-on",' g' l' ?" Q: m3 q
        },2 K1 T; e  M; X1 A
        {7 P+ c1 u, v: H, f  c: b
                .active_low = 0,( Y3 \3 N, u! a: g' u7 i
                .gpio = DA850_USER_LED2,
' I3 t7 t' l1 ~8 c# Z3 }                .name = "user_led2",
9 \- m7 p8 |, b$ A. n: X                .default_trigger = "default-on",
0 U1 C2 m+ A# }/ Q* \% @3 E        },
/ m: Q9 e' a5 k5 ]        {( w7 q( S7 ~! s0 [0 I5 ]1 l, u
                .active_low = 0,
; ]# t) S3 Z% [1 T& ~" W) Q+ {                .gpio = DA850_USER_LED3,
! P1 l. `0 ~& R' t' ~3 `  n6 \, G                .name = "user_led3",& {8 Y# L- y, }( f1 z, H
                .default_trigger = "default-on",- _7 G1 K% g/ c1 N' @
        },
; `- t8 z  p& R) H6 C; R; N; c};
. f3 I2 i) X( u5 P; h. N/ Y+ R  K
0 k; X1 c1 }  j$ L; ^" pstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {6 E; f; I& r! i% d% j( G
        .leds = da850_evm_tl_leds,
% l" j9 I7 Q0 g- d+ P* N        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),7 r) B/ A" d: L" M1 i( _6 {
};
' @4 |" @) i$ b4 a' u- r4 U
! ^( y- _; z( Q2 A0 wstatic void led_dev_release(struct device *dev)* Q, H2 L& k  ~& U6 E6 V  P
{# C* {. j4 U7 q# n9 G( t$ u
};! O) q0 w$ m3 n5 r9 v( O. R) W  i

! @2 v8 s7 v5 |7 z$ K' F; I$ jstatic struct platform_device da850_evm_tl_leds_device = {/ w* h7 m, L4 H# ]  o$ t* G
        .name                = "leds-gpio",
5 Y# o5 a& ]: l9 T8 `        .id                = 1,
3 O# y2 F8 ~3 `" j/ W. ^        .dev = {
  U  b  Q0 {& c  n                .platform_data = &da850_evm_tl_leds_pdata,
( G" M1 i* M" u* u  F$ a                .release = led_dev_release," n5 A8 @! ^: A9 k$ w
        }9 d* b& f! c0 Q1 T
};
# ?& _, s! F1 d+ E" W2 ~
% h( H$ E/ L4 |  b' W( Z( Jstatic int __init led_platform_init(void)
0 L* K$ R/ i; }4 T( m9 R! X* v8 p) l{& @; ~5 m* Y; c- l
        int ret;3 `1 c1 i& `; ]  h/ Q/ _* a. A, k) p
#if 0
6 y) l/ r/ ]- Z* ~* _        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
& N- N2 T0 C" ^  R# K        if (ret)% y# `' M8 b2 q/ u9 h
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"( [+ X8 f1 S8 V% n# A" u
                                "%d\n", ret);# Z2 w2 ]& b# V( j! @2 V
#endif. Q3 f( P' E- R* B2 {& ~* N: z
        ret = platform_device_register(&da850_evm_tl_leds_device);- I- W  F9 l- d5 P5 Y7 J$ ?- i. K+ L
        if (ret)  V& `0 ]& R0 U5 N1 v! f
                pr_warning("Could not register som GPIO expander LEDS");+ f$ j5 y4 @/ K! @$ x) Q& ?3 D
        else, u4 J* i) k) Z0 X  v
                printk(KERN_INFO "LED register sucessful!\n");0 L* |, ?( M2 @! c3 q

1 N, Q" n1 g- e  \  x5 R        return ret;
: ^1 N1 w5 G- ^% v, l}$ W7 B5 U' P% S2 t" }, W% Q

; V, j& ]0 M4 X) v# X9 {6 O8 Ostatic void __exit led_platform_exit(void)
+ u: K: A1 V( K: h: X{+ b6 i9 b( \, D. ]* Q
        platform_device_unregister(&da850_evm_tl_leds_device);
4 M1 _. Z0 g# G0 Z% x- _! g! a7 I  m0 N. X. j
        printk(KERN_INFO "LED unregister!\n");
; N, S- E) G+ k% F1 T1 G}8 V2 F# Q- i. p

- l- Y: R% W3 U. w1 qmodule_init(led_platform_init);
& ~6 g  Y, a1 f2 b6 G& qmodule_exit(led_platform_exit);
2 X4 ]  \" }0 l" m5 X+ i) y# i2 y. z+ l, ]( z3 B3 Z, [% C8 @3 R( p
MODULE_DESCRIPTION("Led platform driver");! J- D: p% A  r* f" [6 Z
MODULE_AUTHOR("Tronlong");% ~$ H8 k# P1 D  [
MODULE_LICENSE("GPL");4 \! E7 P" A  b( p6 G5 q1 }
% }% X, C3 }$ n- _  O. Z
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-26 20:22 , Processed in 0.057237 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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