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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。  {# x9 O9 h# u& C3 C1 O
#include <linux/init.h>
3 E, p5 B# U" }2 T5 \( T#include <linux/module.h>; @9 b5 s, |5 }0 J; j- g+ X
#include <linux/kernel.h>
- |: o4 M0 }8 J7 W) v& o#include <linux/types.h>
; U: V# ~5 P" y& [! b# Z, j4 V#include <linux/gpio.h>9 o% r4 ~/ Z# h% X
#include <linux/leds.h>1 _( B7 H+ l/ j% i( T
#include <linux/platform_device.h>' E9 ]: j" J: ^& o5 X. H) j
9 L5 T' D: N. ^9 ~: h% d: j% h4 N
#include <asm/mach-types.h>0 f/ v  D/ k" V) H
#include <asm/mach/arch.h>/ k% W8 n5 G4 L" J
#include <mach/da8xx.h>' ^7 x/ _; @5 s' f
#include <mach/mux.h>
% `* I6 d7 o: `7 G
5 ~' b. H% \& k1 w3 R0 r#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
+ G4 ~" f* o6 n* x2 p7 D7 o8 f. `2 Z' U#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
' E; U" _5 U9 I* C0 t+ n( o#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)( D" @: _  T; u6 J) U& L. H$ u
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)' ?1 e: }! W. O

+ P9 x" X; G  \1 R/ g/* assign the tl som board LED-GPIOs*/
8 ^  ]; {0 I3 o! t, Ustatic const short da850_evm_tl_user_led_pins[] = {0 o( i0 q2 q7 P* S4 U
        /* These pins are definition at <mach/mux.h> file */
* [! ?9 O% N$ Z. S* O- ^  f        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,: j6 Z4 h2 B/ H" s1 g; K
        -17 e; K6 f1 b# }( D/ F
};
0 R4 N2 t. d7 }+ o: S
5 l' _; q& I. x2 r  rstatic struct gpio_led da850_evm_tl_leds[] = {, G) t8 e' o; G5 Q7 L" l! ]
        {; j, e& Z2 {- W
                .active_low = 0,
2 l& D4 x& h* p                .gpio = DA850_USER_LED0,8 H1 i  X/ d3 ^$ U1 I& M
                .name = "user_led0",. i+ W) U3 o3 |: @2 D& x+ M- B
                .default_trigger = "default-on",
3 o. d3 N% s* t1 ]/ H, y        },
/ [2 ]: f- V7 x        {
0 J8 q/ A, c$ f7 |" C0 N                .active_low = 0,3 V$ K2 T% B9 a
                .gpio = DA850_USER_LED1,* z, E+ j: u' e1 `1 G) c
                .name = "user_led1",
& E* c$ w/ P: [  \                .default_trigger = "default-on",
2 |, e$ P2 K, f% ~        },
" l( s& F, L8 G- r7 c( X4 O        {- C5 Z7 ^1 a. S  h, E  v2 }
                .active_low = 0,
) c: H# n& z6 ~5 w                .gpio = DA850_USER_LED2,
" K0 G. U5 P) U                .name = "user_led2",0 V6 G9 m! {5 Y
                .default_trigger = "default-on",
6 h$ v% V  l$ ~. o6 v        },
) D- \! }( }' h# R! Z        {
# T+ c( B3 I) P! T. z1 r                .active_low = 0,
: K* S9 i7 x- c1 V3 G7 \2 P$ m                .gpio = DA850_USER_LED3,/ e6 O, {! s9 Q, ~
                .name = "user_led3",; \. m3 A% K% ]
                .default_trigger = "default-on",% t, ~1 @& X! N4 w5 P
        },- j0 r! r( t. m3 ]. K' y3 U, y: U
};
6 I* ^8 T( t* T+ r2 U2 [9 [2 C9 B2 ^0 ?" B3 ~
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {, O1 x; m  A: d* \
        .leds = da850_evm_tl_leds," C/ w; l3 h7 l$ Y0 a1 O2 G
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
3 v2 l; p+ Z1 ~/ F8 R};
1 [. T" {% ^/ m$ U/ L! o1 `6 C. \8 i2 Z6 o2 c
static void led_dev_release(struct device *dev)
$ Q1 G9 C3 |' C- C1 ~5 a# A2 C{
5 ?  S4 {% A; X. ]9 ?' Z};
6 S, J1 u1 J( I' y/ M" A
( r; G. n, j3 J; a+ r" \static struct platform_device da850_evm_tl_leds_device = {
; h5 E; w3 f" \3 N+ g' E4 R1 R        .name                = "leds-gpio",
- B; Z6 V) j0 _; l+ P$ _5 P        .id                = 1,
# O5 l) b& w3 T4 S# J        .dev = {9 `; B% e5 E; w, c; t9 K3 c
                .platform_data = &da850_evm_tl_leds_pdata,
) e4 N7 y8 [2 I- R                .release = led_dev_release,
. w, V) @& e/ W+ M, H9 `7 c: M/ U        }, ~3 L- Z6 j: J6 C, Q- R/ @
};
4 D3 T- H0 \% w9 o3 o
7 v( M$ M8 \1 P" {; _: @& r: vstatic int __init led_platform_init(void)7 d, o! D/ i: g# c" k' O3 |
{
4 {4 U8 I4 `6 M8 S- |4 v- t        int ret;
* i1 v* P1 `# i1 r: N* j6 k#if 0# O3 ]. X+ N' d5 l
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
3 Y: J2 }' V- b2 ?+ K' O* p        if (ret)* d8 z' w" @+ I1 C! w" l5 r
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
' @# R  E" a5 t- d8 E                                "%d\n", ret);
9 P3 x6 N0 \" F#endif% x% w5 Z! s6 t' c/ @+ ^
        ret = platform_device_register(&da850_evm_tl_leds_device);
' D, x6 Y+ s  w  [7 Y; _        if (ret)
. [1 g8 U# h' J  g' `8 I% v: p                pr_warning("Could not register som GPIO expander LEDS");0 V  n& n, x1 A$ V5 a- t
        else
# n( ]8 C' G2 d0 l* H                printk(KERN_INFO "LED register sucessful!\n");0 s5 ^, C! E( V
# i+ F- m2 \) |, s% ?# x
        return ret;( w) \7 F  g# C6 u. x' S, U+ T3 G
}2 L* n/ V7 k- u# A. {0 f
0 T( W+ J+ a1 j6 ]' A
static void __exit led_platform_exit(void)
1 K' `3 a5 ~' A8 X{2 n, E' I: l4 v( e5 T5 V
        platform_device_unregister(&da850_evm_tl_leds_device);! g6 `3 t' g& |. B& J% M; q
( }4 L3 I8 x6 j3 T2 H0 I! G
        printk(KERN_INFO "LED unregister!\n");+ t5 `! G9 v2 @7 [+ f. ?- e
}
+ Q7 m; J3 H- h8 J
! F7 }. b- A; c8 f" ?module_init(led_platform_init);
" F1 n! f; d5 x' f3 p/ ]module_exit(led_platform_exit);
& s4 C5 x6 V6 W/ ~
+ y: m* z2 n' W0 sMODULE_DESCRIPTION("Led platform driver");
4 ~% a; ]+ z$ z* X, r, N& e: xMODULE_AUTHOR("Tronlong");# G$ t; o1 S8 _/ T
MODULE_LICENSE("GPL");
2 `4 S/ `  y* H9 \
1 `9 x& x2 l. m
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-4-6 16:46 , Processed in 0.039037 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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