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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。7 t  W0 i6 Y0 A5 }( x8 I9 ~6 n) ^, g
#include <linux/init.h>6 A: S6 H2 R6 P7 |* p
#include <linux/module.h>: O" W1 s7 B& J4 X( k# f1 N- Y, T: O
#include <linux/kernel.h>! t- u4 a6 `+ L( |  B3 K
#include <linux/types.h>, Q4 }9 u; H7 d
#include <linux/gpio.h>
0 w# q! U3 S* u1 G+ @$ p, G, P0 A#include <linux/leds.h>
, W: l9 C1 ?$ x2 l# j# A#include <linux/platform_device.h>
0 D( D" {3 R8 f7 ?0 F. j8 w. _! o  o7 \
#include <asm/mach-types.h>
# C7 e- c& b% s6 a- @" N#include <asm/mach/arch.h>, m& j, y) d$ E6 ]* g/ ^; h. G# w1 v
#include <mach/da8xx.h>5 z7 M; J& W. `# H6 f
#include <mach/mux.h>
* N3 F5 ?+ F# C$ |9 K
  h/ g; y. P/ @1 J1 C; r#define DA850_USER_LED0        GPIO_TO_PIN(0, 0): B2 E; c1 y* s: _* b! X
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
9 }( {  E4 ]* l% ^3 {0 `- P6 [#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)3 X, N! z6 K5 D% y
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
# O' z1 o" j1 f4 B# ^! }8 O" T) S5 H1 K1 O0 i7 s( j; D: m1 S
/* assign the tl som board LED-GPIOs*/1 Y9 C3 ^4 w/ h/ Y: d
static const short da850_evm_tl_user_led_pins[] = {
0 n' G( B  h9 P" u; g/ `; ]& ^! C# n        /* These pins are definition at <mach/mux.h> file */
9 i1 M/ q# L" f        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,# q9 A3 l& \) d( O. @4 b
        -1
  z" U/ R! V2 [2 @};
4 P% a4 ?, x7 x  ]; H/ ~8 \& r1 G# ~9 N5 N" S1 \3 i
static struct gpio_led da850_evm_tl_leds[] = {
& E: ?3 _  c5 A; F( G3 S" S        {5 @. @* P, K" m; m4 d. @+ V
                .active_low = 0,
4 K4 b) l' |- L$ }                .gpio = DA850_USER_LED0,
- l) Z- \' J& l. g8 d8 R' E                .name = "user_led0",6 e$ S; N; A! j6 f( s
                .default_trigger = "default-on",+ j" N8 s; ~! y( R
        },6 y* O" x! L+ n  f$ _0 ]( q4 Y
        {+ j8 B, r8 m7 i! j; _
                .active_low = 0,
* a% N) L+ V( I* C" U4 v                .gpio = DA850_USER_LED1,
( `+ X' c8 l* N* B1 {                .name = "user_led1",) p5 w# a$ d; _# H( I9 Y: ~
                .default_trigger = "default-on",
6 G5 M- L& w1 D" L* ]2 x        },
3 C8 G* ^' C+ g        {
5 ~1 f/ U5 F" c- E2 @2 j                .active_low = 0,4 L6 C& C" f7 D2 T+ h1 p
                .gpio = DA850_USER_LED2,0 e3 c+ x) Q0 M! A" O% I0 o
                .name = "user_led2",
, j" b' `9 X# c. u4 d' s( ]                .default_trigger = "default-on",
/ q5 \+ m$ X7 P: f( s+ d; h9 ^        },
8 m5 ]! K9 [5 y        {/ S* a4 q/ K+ C( v- B
                .active_low = 0,0 J" A+ b8 k% z1 n1 o, D4 v# _
                .gpio = DA850_USER_LED3,+ Q: w( \& t8 A
                .name = "user_led3",
( D) ^# ^+ h( x0 s8 m" b: {3 y                .default_trigger = "default-on",
& M) W7 e' ~3 j  A2 ?9 f        },
# ?; J) [4 g) F( y0 n: y};
( L1 C; [: O1 d/ T0 U. l9 q& Q2 }! R$ c) r0 D/ o: G0 ~# e- r
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
; |; @, b. g4 T% ?. {        .leds = da850_evm_tl_leds,
! }$ L) W# V+ [' ~* _) t  B        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),7 p. L4 m( F( u* n* C/ Q. w$ i
};
) z& ?' i* B+ z1 K* x/ ^. u0 ?- s" {* m: Z4 e# z% Y" a
static void led_dev_release(struct device *dev)
! E% W6 g) B3 F& a5 Q( y{
& I# I" y+ Z9 v};; H4 ]8 @: r5 @' A; P* p

5 D8 P6 ~# ]) tstatic struct platform_device da850_evm_tl_leds_device = {
5 n5 i/ V' N" D; ~$ {* q        .name                = "leds-gpio",
$ m" h- F( X, Q, ]        .id                = 1,
$ Q8 r( [; l! M# e/ s; M6 t        .dev = {' |9 G, [7 ?/ t) G" G3 W# W
                .platform_data = &da850_evm_tl_leds_pdata,
& f) ?, Z% U% E( Y                .release = led_dev_release,6 I8 d0 s. s8 C7 p. u) s( q/ b
        }
  p3 h5 R$ w. y; _! R};2 J1 B+ o5 ?3 _7 m1 j

: o' p8 v! h' _7 \5 j" Kstatic int __init led_platform_init(void)
% r! F8 h1 K' f" G{
6 g. e, G2 b5 P* r% @        int ret;. f% ?/ o) L/ w- a0 y
#if 0
4 g# H; m5 W/ I& \: z4 ]        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);2 J+ e/ H0 x# H* Q- l( R' K/ X9 [
        if (ret). P0 M" P# S: w" D* ~' i- ~
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
) Y1 o+ U# v% ~! V                                "%d\n", ret);0 a( a- b8 @$ z# Z3 G: t+ f
#endif
7 Z7 @& g4 i# _% W1 O0 X        ret = platform_device_register(&da850_evm_tl_leds_device);  E- f) T$ r3 [; l& f2 H% E
        if (ret)* ~; K0 z$ R, n: q6 I4 C, E( ]. l+ U
                pr_warning("Could not register som GPIO expander LEDS");0 c5 G! p2 R' A+ T- i
        else
+ L* e( B+ z! h6 E7 L9 b                printk(KERN_INFO "LED register sucessful!\n");
3 K- @6 e! O! C4 j/ f0 h% ?- S, ]0 P, T
        return ret;4 i6 w+ c$ o& |: Z
}4 G6 q' k# t! E2 L

' U+ Z7 k9 u- |$ W. K% Xstatic void __exit led_platform_exit(void). b% ^% Q: o* ~- `
{" S- R/ a" p! P& ]. {
        platform_device_unregister(&da850_evm_tl_leds_device);7 s6 l" h: Y( H4 k: \
1 M8 @% t" n4 P: l3 j/ a7 F: L
        printk(KERN_INFO "LED unregister!\n");( i% [- o) ~: b% e
}2 Z, d8 t. n) v" g5 H6 R

. \. E7 U6 e9 b/ i/ E- c3 e3 H& pmodule_init(led_platform_init);
, e6 Y, W" g1 S0 `) |/ \1 d: gmodule_exit(led_platform_exit);5 @, c2 h1 N& n2 ^

9 @/ `' G6 W2 G7 mMODULE_DESCRIPTION("Led platform driver");0 e1 |7 T$ W  e$ U/ p, N
MODULE_AUTHOR("Tronlong");: Z# r/ k8 a- S1 Z: r! O
MODULE_LICENSE("GPL");
1 Z  u2 C0 {8 q/ T8 d
5 J, j* [5 N/ }( i3 a, K
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-10-28 16:55 , Processed in 0.040952 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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