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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。& p+ q) v( ~( w
#include <linux/init.h>
$ ?: [% d2 A" {5 x) L#include <linux/module.h>
/ S! V* K' S0 p' |2 w#include <linux/kernel.h>  c( l2 \, M5 b5 ^+ [. d# K
#include <linux/types.h>
2 I, y3 M# v1 B1 m2 H! X#include <linux/gpio.h>
  d+ @. q3 I3 s9 b7 }- d  {#include <linux/leds.h>
( R* _& k0 S  ?' ^#include <linux/platform_device.h>8 q, U, c7 O0 f4 H

# I9 W/ L; s( ^4 v; w! c  Z1 t#include <asm/mach-types.h>! F. U- L/ O; Y( u
#include <asm/mach/arch.h>
4 F9 Y7 F" K8 E# f4 G3 H0 R#include <mach/da8xx.h>& z8 j, d" c+ h
#include <mach/mux.h>; [. D: Y3 e" q
6 z9 h; p6 U! o& H
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)6 M5 l( b% a. d& }% ?5 D
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)( T6 W5 Q3 x, @  {8 m! m; u
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
5 o- X8 q0 _0 r8 O: p#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
" E: b- D+ N# J3 l# E8 C5 y- }  T! `2 V9 t/ K9 Z
/* assign the tl som board LED-GPIOs*/+ _. l6 ~8 O! K" t( R
static const short da850_evm_tl_user_led_pins[] = {8 w" U! f3 P! g5 Z5 J
        /* These pins are definition at <mach/mux.h> file */) p0 n+ {" S% A+ v& c
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
% M" b$ C& t- m( _2 R        -1
$ h! h7 `. T0 I7 c};
+ L% e8 K9 C; z1 H8 b
, P" d8 F6 G. ~2 ]  p+ Dstatic struct gpio_led da850_evm_tl_leds[] = {! b. @8 S, w# n2 _: R& @  R
        {
5 k- }8 v5 t# ^( c                .active_low = 0,
1 S2 E* K1 q/ \- \3 @5 K! B                .gpio = DA850_USER_LED0,
3 Z0 @" y2 a: w& b                .name = "user_led0",/ H* v% a3 K5 ^; f4 t, p
                .default_trigger = "default-on",0 n( b9 @: A/ {7 G
        },
6 z; [7 |; W1 @: W3 E8 H3 }7 y        {
5 K9 Q* \9 W2 u9 v2 `) g                .active_low = 0,
: j  l4 B5 S) d) N. O                .gpio = DA850_USER_LED1,
- n6 U9 f0 B+ n+ p% J                .name = "user_led1",
6 f- ?' l+ i; b* P; ?                .default_trigger = "default-on",$ P+ K% y( A! A. l% h. u1 W
        },: ?( ~9 F% J$ V, @8 p# J* X( A% `
        {5 c1 a( ?& r- x
                .active_low = 0,
6 i) ]& J9 A* I6 W% g# E- i# C: g# x                .gpio = DA850_USER_LED2,
! Z$ W5 h/ o9 o2 u# j/ v                .name = "user_led2",# A. r( l4 [, _! b1 x
                .default_trigger = "default-on",! D+ a% Z! i5 F/ B  w' c4 Y) \3 {
        },
* N7 }. J2 s" r! m3 w        {# A( g2 V" a' o, L" H! {
                .active_low = 0,
: e# ?2 p, Z/ L% q' Y) |+ V5 G6 c                .gpio = DA850_USER_LED3,# z* o9 `' n5 t( g2 C8 C
                .name = "user_led3",
" I5 W! M* t1 m6 C! W1 k                .default_trigger = "default-on",. L7 g- ^4 Y' K7 ~& @( L! T  p( e
        },
3 b; H8 q" E3 Z5 l; c};
3 R% ~! q7 u3 e! y
8 g. f3 S6 |2 Istatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
+ Z( |+ O' K% _7 H1 @9 H" \        .leds = da850_evm_tl_leds,
" }* B7 E9 ^* e$ I1 F1 w        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),+ ]7 Q6 D, D$ o
};6 E: G/ x6 y( B5 ^& R, H3 |

, O! I8 U4 |4 U5 fstatic void led_dev_release(struct device *dev)
  ^6 h3 u% _/ `! d/ k1 @0 K{' N8 @. l2 d% B" F
};
! V9 I5 ?, e* v" n$ F1 b! |. d/ ~/ k$ R3 x) K* Z6 _$ y: j
static struct platform_device da850_evm_tl_leds_device = {( a9 }4 \- e4 \8 s" G0 I
        .name                = "leds-gpio",
5 v1 i+ m& w( P0 ^# G3 u1 a        .id                = 1,$ X- h) o7 K4 g' C
        .dev = {- a2 P  h7 b1 X4 ?3 G
                .platform_data = &da850_evm_tl_leds_pdata,
0 K9 t. ]  F: G                .release = led_dev_release,
9 o: t# i9 N1 e- h' s        }* [! T. K( P) J6 j/ w, X0 Q9 {* k
};  G  ?  O5 e! E/ `4 G

" f! }* {/ x0 G9 H: l. Zstatic int __init led_platform_init(void); F/ ?/ N7 L' a9 e
{' e! g+ g6 o' b- y5 y7 q
        int ret;7 a+ z- h9 {* _- {: L
#if 0( ]/ j8 r8 y$ j  D
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);3 m1 A$ Z' ~, Z( y% X
        if (ret)
: I8 t1 `; K; s: \                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"$ C0 w( M! ]7 q9 a3 k; H& g
                                "%d\n", ret);4 x4 v2 {9 E% h; m1 y( f& F5 ]
#endif6 s- [) j* [9 l9 T- P4 K! O
        ret = platform_device_register(&da850_evm_tl_leds_device);
% q! D/ V* L3 x+ ~9 P        if (ret)8 e/ i. {8 S, d5 p  I
                pr_warning("Could not register som GPIO expander LEDS");6 i6 N! J& ~# ]& S8 ^" p
        else. L9 j* n$ U  T7 m4 x# }; `; z+ r
                printk(KERN_INFO "LED register sucessful!\n");
$ ~( c( s% {4 A$ s# ]5 Q4 i! Z, _0 e% u
        return ret;+ B$ t8 S' A1 q1 u; W. X9 t
}
6 X2 e/ j' N1 v: M3 j$ [2 P; o1 m2 ^3 o3 ^8 {7 a
static void __exit led_platform_exit(void)
9 ?& g! k! d4 x3 S{
7 }; j5 U/ Z( ?/ @# H) v" \        platform_device_unregister(&da850_evm_tl_leds_device);
+ y( T& z/ L; O
) M. k- s  w" U: J+ U+ R& ]        printk(KERN_INFO "LED unregister!\n");
. c) U- u* a8 j2 D7 ?* @8 w4 e; @! v}
6 S9 H5 _6 i5 @( d8 q/ I3 ?* l4 X' p; q7 o5 O
module_init(led_platform_init);
7 f4 P1 t$ k) i4 d7 emodule_exit(led_platform_exit);
0 {/ n: j! r% z) @
) J- Y, \# k4 W  M3 s4 OMODULE_DESCRIPTION("Led platform driver");" d- J$ z% ]% T% i9 \
MODULE_AUTHOR("Tronlong");
0 y6 a( |# ~: |. ^MODULE_LICENSE("GPL");' p" I. \) A* V
' W' L; j! \$ L' E/ {, I) G$ X* P  r
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-3-6 16:17 , Processed in 0.043287 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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