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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
: p2 X4 h9 q2 [- K; }& \* F#include <linux/init.h>
6 [9 n/ H/ |7 u1 R; Y7 Z/ h. M#include <linux/module.h>
. c" Q% r: v5 A" {#include <linux/kernel.h>
4 d$ j' z) n& [! B( i4 N% s) `#include <linux/types.h>
: w& w) J, R  u; S, s7 [#include <linux/gpio.h>( y8 J- o. i/ ]( w
#include <linux/leds.h>. g2 K# B8 v: ~5 z+ i; o
#include <linux/platform_device.h>2 E! t; K, K8 o2 F9 p9 _

4 Z( w. h+ t- v7 U#include <asm/mach-types.h>
: {9 C- J( U, M#include <asm/mach/arch.h>
% b& j3 t# z" D, J/ i) x+ H#include <mach/da8xx.h>
5 }8 z7 c7 J/ n( R#include <mach/mux.h>
$ |+ o6 v  y- b0 X6 |9 J# l. ~
4 r: e/ h" K% x, _1 t* x/ s) Z- F0 i#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)( ?! X5 [$ F/ `& L, }7 J4 G
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5). A4 g& @. ]$ Q
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
3 I4 {0 f& Z" A( u& V5 `#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)9 a' f5 ^- L+ Z& b
+ t! T$ G; A4 X* y1 s; p
/* assign the tl som board LED-GPIOs*/
% V; }- l- V) ^" y, xstatic const short da850_evm_tl_user_led_pins[] = {0 d) j' f( d" _! \* v+ W  a  B9 N
        /* These pins are definition at <mach/mux.h> file */
6 h/ K' d  k. f2 c5 l        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,0 |( E! `" n4 C/ c5 h4 X- d7 w1 w
        -1
9 X% D& G1 N7 H) @};
, G9 F: J4 V% }# z1 K9 t5 a/ B
. g3 M1 O$ U( {* C! g- }/ Astatic struct gpio_led da850_evm_tl_leds[] = {) G- f/ E5 V7 B+ k$ L" w
        {
% C7 x* j7 b2 E. ]- s1 v4 C8 b                .active_low = 0,
5 _, p) F- i. c2 \$ L2 M0 J                .gpio = DA850_USER_LED0,
: j  Z4 S: T/ R% N                .name = "user_led0",
( L! W; h' `0 Z: q, x0 [0 K                .default_trigger = "default-on",! x4 T+ j) |8 e& M
        },1 V8 h, D) a1 T8 H& c3 B5 q/ {
        {8 R4 f$ g1 i# p) [1 n% g8 P5 e
                .active_low = 0,% E4 D2 N) s3 ]3 s1 a5 @
                .gpio = DA850_USER_LED1,1 x* _; K- u9 h; s( e
                .name = "user_led1",
5 ]4 J5 v% l- Y) P9 F                .default_trigger = "default-on",* W' T1 L( }) y1 ^- A1 A; A
        },
8 \: o% }3 n1 Q6 u0 D        {
% y# `; n' J" t6 T. P                .active_low = 0,
/ k1 |' i; Y' @) u1 r                .gpio = DA850_USER_LED2,
# f$ g- [- C% g. a                .name = "user_led2",* @* C$ p/ O) }. u+ ]
                .default_trigger = "default-on",
% a& ^/ h) n/ v5 k! V        },  T9 o+ J: p3 F& K/ e5 a5 g8 i. h
        {% p- h* q; k2 m; b& Q
                .active_low = 0,( m  q) y( ^. f1 O/ I
                .gpio = DA850_USER_LED3,
! R+ ^0 d; m$ l                .name = "user_led3",+ B) a2 x4 p' m0 p: q# G$ \2 k: O2 A: p
                .default_trigger = "default-on",
  S6 Y# X7 h# E. j3 {        },
5 H" Y& s( K( @% M0 q4 Y3 d( D4 M};8 W: K/ r  j7 Z5 p! [6 E+ u2 R- G/ ~2 u
, A+ t: H( K; G
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {4 t5 u  j& A/ h) ]1 x
        .leds = da850_evm_tl_leds,& W! E8 @5 s# _2 d8 _
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
7 z3 B# E; E! W: ~3 @; j};, Z# s$ l- b5 X% C

$ c( k5 m5 a/ g) s" Estatic void led_dev_release(struct device *dev)
$ b' w" e: n' D  \: ^8 B! P{
6 t! K6 t% F$ U6 }9 Y% l};
: X% c9 G! J9 |1 u- a- l
6 L4 j# o( M- ^3 ~static struct platform_device da850_evm_tl_leds_device = {
% R3 f6 v. d) ~9 a5 e4 ~        .name                = "leds-gpio",
' W, \5 u2 V  ?8 I# C# H        .id                = 1,
" k8 e9 r- H, n* P        .dev = {
* O& u. O: Y( B6 T) k; z                .platform_data = &da850_evm_tl_leds_pdata,7 {% |$ Q- l3 b/ ~/ v( A
                .release = led_dev_release,
. ]! L/ r* O$ `9 ?1 l        }- f( {6 ?  f& f: E: y+ R& Y9 r  \
};' w& G- v/ r( {# S) K) M

( J) T" m/ O5 W. f$ S, j# \static int __init led_platform_init(void)0 ~: y- R$ F! ^/ P' }0 y/ h. L
{. d! g: C' H  p  ?  L
        int ret;0 p) y* X1 ]* ]% l8 B
#if 0
( P/ R/ t- V* |! Y        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);8 g& n) ]& ~; g+ z
        if (ret)
+ g4 B2 ?; z$ k                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
3 E. V, U3 h$ ?. b! c2 `: s                                "%d\n", ret);
, p" K; S0 ~1 M1 H% ?#endif
+ C7 W/ }$ Q- h. p* Y3 L7 ~1 X& ~* R        ret = platform_device_register(&da850_evm_tl_leds_device);4 [! u8 X& j' d$ b1 `+ }0 B4 u
        if (ret)5 j3 I1 y1 K5 b$ ^" Z
                pr_warning("Could not register som GPIO expander LEDS");: G% u) `% e' W2 I/ `
        else
5 w9 z; n. D/ z0 j                printk(KERN_INFO "LED register sucessful!\n");
# a! h# i5 e. y
: v5 O5 Y  X& E# }+ t        return ret;* ~9 [  h+ |" _* G
}
# Q# G8 D* f6 L5 K9 R& I5 u2 w
0 m( i4 k4 B8 x  Qstatic void __exit led_platform_exit(void)! U$ l# E) M; O. J' K0 s. V
{9 R8 s9 y, ]$ k5 n; ?! p
        platform_device_unregister(&da850_evm_tl_leds_device);8 m: u7 _- ?1 C# `9 @' e% F
- P$ H+ l' G4 m  o& h
        printk(KERN_INFO "LED unregister!\n");* x( |9 F  G# Q( N
}
1 j# f7 n4 A' P+ c* s$ T6 y% X  e. }; o( w7 K, U
module_init(led_platform_init);
1 Q5 E+ k9 \/ w/ Q7 h( w4 N7 zmodule_exit(led_platform_exit);6 r2 e# F- \1 x3 o5 F  u

: }& i7 q: e( Z# V# ?. n6 @MODULE_DESCRIPTION("Led platform driver");% B: @' _! E  D6 @* p
MODULE_AUTHOR("Tronlong");
" \$ {8 M6 u6 h6 C- ^( S' QMODULE_LICENSE("GPL");% ~# f. z5 {1 n- V" X! e

, a# {' S& Z' [6 s, W
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-24 23:28 , Processed in 0.041053 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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