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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
& e5 {: |+ ?6 _4 i4 f* D5 D#include <linux/init.h>
, }$ Z( F: _! r; W/ Z2 r" M#include <linux/module.h>
4 X6 h4 V% o2 r#include <linux/kernel.h># ~' o1 M" M. `2 ~
#include <linux/types.h>$ |; V; W, [2 i
#include <linux/gpio.h>; [' J" Z+ ~) `' T3 H9 `5 ]
#include <linux/leds.h>$ J3 d3 {3 M) A& [
#include <linux/platform_device.h>
- i6 i! \3 Z3 w3 F7 T
) B0 x7 B3 ?$ M#include <asm/mach-types.h>: f3 d) l* X% N" a0 V" Y. o( e( L
#include <asm/mach/arch.h>
) c, L2 s4 K: a' }6 U* i; g. _0 s#include <mach/da8xx.h>$ G0 }' q+ f. t2 w% t
#include <mach/mux.h>
9 y+ @1 F) C- i7 o5 ]! D! u, H  g% N, e
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)2 z  Y* g+ L. w! }
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)  S, g4 M, H; q
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
+ t  {2 O& U( z" h( p. c#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
# g0 L& ^1 y8 X2 ~. N, r. D7 o" C  J) f8 [7 u( W# P7 n
/* assign the tl som board LED-GPIOs*/% J+ }3 N" W- ^
static const short da850_evm_tl_user_led_pins[] = {
$ k! `" {3 w- W. w) c        /* These pins are definition at <mach/mux.h> file */
/ @9 H% J& z/ X" a- H$ o        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,0 N) l6 [* W+ p$ E' w+ o+ g
        -1
* ~: E2 ]& H3 c};2 a# x& q3 n. d
  x2 D, C# u! h6 k9 d$ g
static struct gpio_led da850_evm_tl_leds[] = {4 R" y1 ]# l- v; W% B
        {6 I6 G8 t) \! F$ U* L
                .active_low = 0,: ^! K3 m, f- F; ]
                .gpio = DA850_USER_LED0,9 C5 r" `. N! F" ], i  y
                .name = "user_led0",
: D2 M" m) h$ t                .default_trigger = "default-on",
7 i4 E, K4 b$ S' P/ y        },% S$ |% C- c% o6 N
        {' E( T: {! K+ u1 B
                .active_low = 0,
, F9 F; j0 t1 J                .gpio = DA850_USER_LED1,
% e1 f  O8 s( H" q  O5 x                .name = "user_led1",
- C8 l$ B8 `# w- L  Z                .default_trigger = "default-on",! S$ \$ p7 f$ F: a5 E
        },
5 j8 F7 [; u$ N        {$ C5 W& O; @& e- \, L3 H
                .active_low = 0,
* m3 P9 ?! Y$ B" `# R# \; |                .gpio = DA850_USER_LED2,  X4 ~: G9 m5 e6 |: h
                .name = "user_led2",
, o. `' ^4 E) d2 n7 o) f                .default_trigger = "default-on",; B# n6 h) c- v$ ?! R
        },: K4 p* p" ~3 f  f
        {, M" _& g; ]7 e% f0 ?% ]
                .active_low = 0,0 ?# x; m% {$ [7 c2 k2 [' P- A$ }
                .gpio = DA850_USER_LED3,5 Q0 b" J. c& `- O0 W7 ]% f% z
                .name = "user_led3",
$ W& k; ^! J0 |2 C/ t. w, G                .default_trigger = "default-on",* E2 W) R4 L* i* Y
        }," y* g( k6 n/ _: D  D
};
0 z+ B' T2 l- @1 }$ [
7 y& z; r0 k% d& ~% Sstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {+ x1 j+ X/ r1 }% j7 I) X* Z
        .leds = da850_evm_tl_leds,
! \. Q. c. b0 y- j! j1 `* O        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
0 d: o3 V- b+ v7 k4 d};. X+ l) A9 ]' ?7 i' b. t

% d% p# m0 j! o7 V: P; T: lstatic void led_dev_release(struct device *dev)
2 S6 g; G: s2 e{2 o4 j7 d1 {! b( ?
};
; A( |8 B0 X! W. I; {& O8 k( |# Y& f) S
static struct platform_device da850_evm_tl_leds_device = {
+ o7 ?4 `; v# {! d! s* }# |' R        .name                = "leds-gpio",
, A4 A6 d  {& L( ]; I6 W        .id                = 1,
# F! n' D; J; C        .dev = {
7 a% q: F$ v- ^2 B$ {0 ]& R; q( u, q  P                .platform_data = &da850_evm_tl_leds_pdata,( Z$ y: f  r5 I/ O
                .release = led_dev_release,' ?' w3 O9 m6 q- v2 k. v$ ~! A; k
        }
/ ]6 W2 M% X1 B9 D" K};
! q6 P- z3 w) H6 `* h8 f# i. D# J! ?) c2 y$ p$ X
static int __init led_platform_init(void); T5 K% |' s6 w2 C* h2 X
{
" L4 n# R: c( x' r% a        int ret;- F. |, w. g# ~4 U
#if 0# Y0 w8 A$ @8 i. |8 l9 O5 l3 k# R
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);6 d8 P7 a  c  v
        if (ret)' J. c' `. K# Z/ h6 U) @% Q' ^
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"3 J7 U6 O9 y/ K: c5 _7 Z
                                "%d\n", ret);
9 D, s$ l2 ?' X6 K#endif
" U0 s6 Z+ m: m        ret = platform_device_register(&da850_evm_tl_leds_device);
: i' R9 Z7 H' a  }- O& t        if (ret)# P2 x5 U' H- g5 s  n8 j: u0 s' D
                pr_warning("Could not register som GPIO expander LEDS");/ l$ y# u6 F, E( E9 T4 k
        else9 Z/ }6 `) u" {
                printk(KERN_INFO "LED register sucessful!\n");
! `$ h7 t  R* Q
4 j3 |3 n" L. T        return ret;4 C: U) v0 r) T+ d% v# i% i3 F; d
}2 Q) p' m( d" g3 A

  E1 x: s) F) E1 A0 M: Qstatic void __exit led_platform_exit(void)
) k0 X$ {  q5 S; Q{7 g- r2 j% }4 E% N/ n# T
        platform_device_unregister(&da850_evm_tl_leds_device);! m+ f/ y- v3 t* g0 I  N6 g+ n* s8 Z

: @$ R8 g  e& P# z* a; f& W- g- k        printk(KERN_INFO "LED unregister!\n");
2 m9 E0 y/ b$ g: z* O}$ G" t4 }; c; g6 b+ C$ I

0 P1 i1 e8 A( S1 Pmodule_init(led_platform_init);$ y1 n- ?5 o  D3 W  W0 C
module_exit(led_platform_exit);
  ~2 Z' B9 ^1 F) V8 j8 q; i
) U4 ^7 L$ J2 {5 IMODULE_DESCRIPTION("Led platform driver");' R4 D- w  `# N# ]: q8 E
MODULE_AUTHOR("Tronlong");
1 i7 U( Q0 i/ O& D% IMODULE_LICENSE("GPL");7 {, B0 I7 V* P% e) ?
( f( B2 ~9 N2 m; w4 D1 Z# R1 D
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-3-23 17:19 , Processed in 0.038805 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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