程序注解 - OMAP-L138 - 嵌入式开发者社区 - 51ele.net
设为首页收藏本站

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。0 |2 B8 i3 x2 M
#include <linux/init.h>3 M" c3 R; x. O3 o5 ]1 h) L* n+ h6 m* |
#include <linux/module.h>
) n8 G: f, l) e! z8 ]#include <linux/kernel.h>* Q6 S% u; m4 }% {' M$ B
#include <linux/types.h>
' G( P5 ~1 [8 G. F#include <linux/gpio.h>" n: z, d' O) r
#include <linux/leds.h>
: K7 M& F% D: y- D#include <linux/platform_device.h>: ^: Q2 I' r7 `/ b4 x8 U: s
7 v8 @- U: {# B+ J
#include <asm/mach-types.h>
3 [1 r* c6 H3 x- l8 L" X" V#include <asm/mach/arch.h>9 o8 z" ~) K) B, k6 g7 ~" B
#include <mach/da8xx.h>
1 o) n7 ~9 Q$ I/ q) r, K#include <mach/mux.h>( J) }+ M) h$ J$ R4 c  M6 t# Q2 C

& d& k3 m$ F2 C' h2 H#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
$ \, j$ U; G2 D% t: {#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
7 o1 m8 t9 k) X9 j. T#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)$ N4 }( q! `  ]* ?! I( c$ G9 Z! c; r
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)7 o$ S/ f+ I- s8 l: H
  w& v. m6 L1 ?7 }4 o3 O
/* assign the tl som board LED-GPIOs*/
7 H( f  K! a. y' b& ^, n, Astatic const short da850_evm_tl_user_led_pins[] = {
; \) m7 ~" X+ V. f3 b        /* These pins are definition at <mach/mux.h> file */
9 ~- S8 e! G% [7 W2 m* K        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,1 U8 [/ n9 g7 i
        -13 U( [" U1 W" E
};# V4 C6 B) p: N

/ @, @) @& ]. h8 v2 X- b" Bstatic struct gpio_led da850_evm_tl_leds[] = {
; x" N$ p1 C5 o6 U: R1 M5 I8 i3 z        {
) P0 n' B1 G8 u2 A, M& ?                .active_low = 0,
; N( T" k: t  \! y/ D/ `  A                .gpio = DA850_USER_LED0,
1 ?# B% G7 D# e: [2 y                .name = "user_led0",3 l. I: }' v- x; M( B" D
                .default_trigger = "default-on",. f6 ]  W9 v" N
        },
6 t3 u( _  `* _% s$ `        {1 P5 d( n% b7 I% h) S- u
                .active_low = 0,) `# Z% [. z9 n# b6 n& @7 {( U
                .gpio = DA850_USER_LED1,7 n: j7 @5 R+ Q% b  x
                .name = "user_led1",
# n( _" `3 T! N' W& y' j0 B                .default_trigger = "default-on",1 N( ?/ X7 z+ @5 p0 {* `: i# d
        },
9 j( k8 J" a& M- A! i7 M        {
& o, O6 G6 A+ b9 O                .active_low = 0,
5 U* F4 P  `9 m& t# [& H$ c                .gpio = DA850_USER_LED2,
1 G  Q5 F0 E0 n4 Y                .name = "user_led2",* o' H' O$ L3 q- k8 x
                .default_trigger = "default-on",+ E* C/ _) E7 L8 |( Q1 T
        },/ ~: k8 V: v' }% ^9 F
        {, y' g8 w  \! m, ]! t1 a8 M
                .active_low = 0,+ O" V0 L5 Y) v/ d' Y/ K
                .gpio = DA850_USER_LED3,
+ \( A& W6 J2 [! [                .name = "user_led3",
0 d/ {- A2 I5 F2 R4 a7 n# u                .default_trigger = "default-on",9 h! }' a8 b# h' s4 {* N! U6 S
        },% [+ t9 i# S$ d0 P2 o6 @
};
7 Z# s9 f, i3 Q5 R
2 ?) h; r6 N) G7 `' v/ {static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {$ y$ A7 D' h6 d3 n
        .leds = da850_evm_tl_leds,
* P: W( y& l6 P! v7 \  v        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),) u$ L; w4 M! s# k! _) y4 o- K
};5 r; S# E0 x" ^, G0 s: _3 O$ F7 _

+ _6 Z9 g& o& L8 xstatic void led_dev_release(struct device *dev)* B7 E1 \# D) |- f& T: ~; N
{
. j7 D% V9 w$ k: H};
  j+ W6 A+ g4 N* r6 m
& _: G- F/ {- @) Qstatic struct platform_device da850_evm_tl_leds_device = {
9 N0 p0 [2 H9 T' `1 D" ]        .name                = "leds-gpio",
6 c& e- Z9 k3 r5 ?8 V        .id                = 1,7 [) k* l) q% \' }+ m( u
        .dev = {
, w- W( `& h+ @                .platform_data = &da850_evm_tl_leds_pdata,
; V4 ]# e1 x0 \& A+ E1 x                .release = led_dev_release,. |0 f3 f, H& d" a* _, l$ K$ a4 q6 X
        }/ q0 N2 c) v( S
};$ C: T" F. B, K0 S* G
( W% {/ ?. x5 S- X& w" ^
static int __init led_platform_init(void)7 Z1 ~4 C9 _5 b  @& ]+ }
{
! |/ ^7 e& Q# U8 e        int ret;3 r7 y1 q: d( Z, r$ X. C
#if 0
8 ]% J+ ^0 W4 b) O        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
; U. o, r! n$ I        if (ret), {( `) D* f/ i' `& U
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
6 o% {" n0 W6 J- h                                "%d\n", ret);! E5 }1 O& z6 z# n& k4 h! W
#endif. x2 f' k! Q. Y4 k# J+ e! K  y
        ret = platform_device_register(&da850_evm_tl_leds_device);
) l2 }$ n( ~* Y; A: s) v        if (ret)
/ k8 V: j1 z: a1 T                pr_warning("Could not register som GPIO expander LEDS");0 N' j& D  k% d( Y4 M
        else: T9 t, |+ m5 C
                printk(KERN_INFO "LED register sucessful!\n");8 `5 g8 j8 A$ f

2 ?8 `) p! v6 s7 ^        return ret;, l* \& N# Y+ I! z
}' D, C) }0 q4 K! `8 ^

2 z8 C$ W! N7 ]8 C) K  i, rstatic void __exit led_platform_exit(void)
; E" V" n8 M7 {- P8 S) o% Q{( m8 F8 p8 c& Y' O$ f" m
        platform_device_unregister(&da850_evm_tl_leds_device);0 ~$ q. Z2 L* z" [6 z( q5 f
2 N# w8 f0 ^+ A& Y9 S
        printk(KERN_INFO "LED unregister!\n");# `' N, o+ N  b$ k2 D5 H
}# q0 F+ i& N+ h: C" ^6 p

% h5 P/ ?2 O7 R9 Fmodule_init(led_platform_init);
" O9 R+ y7 f' ?: c9 e0 kmodule_exit(led_platform_exit);
* D& V( N" e6 H5 A; T9 D7 _; B/ u8 O- J8 X4 {3 o
MODULE_DESCRIPTION("Led platform driver");( n( p, T1 b$ O# ^" A8 D1 V6 j
MODULE_AUTHOR("Tronlong");$ z* o+ L8 O. }$ r2 O
MODULE_LICENSE("GPL");
0 a2 R: v# l5 P1 T. ~4 [7 H% m! z5 C; i# {
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-9-16 11:11 , Processed in 0.037606 second(s), 24 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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