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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
7 h4 @" O3 m7 ~. G#include <linux/init.h>
9 ?# b+ s. V5 d& D, B8 I8 e#include <linux/module.h>
% ?+ q6 b. n4 `% T# U! c$ f. v#include <linux/kernel.h>2 L7 ^* z7 Z2 z5 J' E
#include <linux/types.h>! z& i: C) g$ x7 _
#include <linux/gpio.h>
' m' M3 U0 s) N; {8 p! m#include <linux/leds.h>
, h( F% J, ]) e, Q9 ]  i#include <linux/platform_device.h>; ]7 k5 Z5 j  u2 j$ }2 ^3 ]
, l  e2 l" u6 y) W6 F
#include <asm/mach-types.h>
* t- K1 Z7 C, P/ `+ H0 T" A, H#include <asm/mach/arch.h>
5 n0 @4 r5 B1 T#include <mach/da8xx.h>
- d6 T! F- |9 }#include <mach/mux.h>( |6 a7 C$ b3 f

4 l& w8 _( U* j7 ^8 G4 ~8 P& f#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)5 j# V0 L7 q$ j; j
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)8 Y* }* e% w/ t# m* u5 E! n  f
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
. D6 p3 D3 x# m3 w; S#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
# q, a; W) Y9 ]6 r$ @" U& l6 ]# _, p1 Z, |, \' T. _8 C) ?
/* assign the tl som board LED-GPIOs*/
6 @1 ~" x5 C% l$ X1 g5 L+ j2 Estatic const short da850_evm_tl_user_led_pins[] = {) X! D* c% X5 T2 e
        /* These pins are definition at <mach/mux.h> file */5 p1 e9 n5 T7 e. s, }+ y7 u
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,# a) @, c- P* H2 e3 _6 s
        -1
" \; J) v/ Z7 N, v9 m* W};
" ~! f: N# ]6 \9 Z
5 W$ S7 N  I9 J  dstatic struct gpio_led da850_evm_tl_leds[] = {0 H. ~# X+ n2 ~$ J- a1 o  A! y$ l
        {6 D, D/ ?( \' P' h( |5 b  l3 H+ R
                .active_low = 0,
/ o" \& r4 o) `6 j$ V                .gpio = DA850_USER_LED0,
0 g  S+ U. e; h: X% }                .name = "user_led0",
" b6 I1 K: B- D3 d# {5 G  x                .default_trigger = "default-on",
) u) `0 U# g* S! O        },4 d" F/ q0 }" c' i' z# k6 E
        {
" h$ i# U- i1 D& E2 g                .active_low = 0,
4 l, l2 R+ t: E$ y, Q  K: }                .gpio = DA850_USER_LED1,5 L- B1 D2 @5 J4 a
                .name = "user_led1",
6 N& O) l; l* s8 o: {                .default_trigger = "default-on",3 B9 G" Y8 P3 O
        },6 c4 U/ C( x) y4 b2 V
        {: C' d* T( x; U/ C
                .active_low = 0,
( [1 W. o8 u7 j- B+ `$ s) L" H                .gpio = DA850_USER_LED2,
6 k3 W1 ~1 n1 y5 S# x8 }4 K                .name = "user_led2",4 r4 p, u9 `0 J0 s
                .default_trigger = "default-on",
+ D4 p4 I$ i5 \/ `/ C        },8 V. o8 Z* q2 X9 U
        {
  R7 B# s5 Y# i- S5 g: g                .active_low = 0,
% `2 ~0 ~; d, [2 v                .gpio = DA850_USER_LED3,
3 ?2 n3 s: o0 B2 K                .name = "user_led3",% h% d5 E. s. X8 r! R5 x% n6 Q
                .default_trigger = "default-on",- G1 Y2 v- Y4 ~" U6 Q& E  n/ _& \
        },, W) x( M; ]$ G$ u- ~7 C
};
. e' R7 r/ W) a9 g3 H0 L
& k0 R, Z6 j2 [0 i9 n1 ustatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
  D5 [1 B4 _8 l5 t3 c0 |! N: ~        .leds = da850_evm_tl_leds,
& g) a, l. x! j. N+ M5 V- _        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
* \+ Q) S2 ^! \& {# F, `! G* l};
9 ?2 U* Z/ T9 ^+ E" ?' s  J+ ]' X$ G1 S! m
static void led_dev_release(struct device *dev)
" R- a  d, X# k- M; k{1 U9 q9 e% N& t" j9 ?1 F, V' s
};0 o5 J  f7 `7 x; V3 V8 u2 _
) k' y! ]& K6 n' g! [2 z
static struct platform_device da850_evm_tl_leds_device = {3 X% `- t- J: k5 I7 y" j3 L
        .name                = "leds-gpio",% W0 g# t; _7 F1 e) E( T
        .id                = 1,
7 [7 o- Z3 ~* ]% R& F1 B6 `/ G1 U) ~% ^        .dev = {
% }/ Q- i1 H, d! l0 z( \2 l; h                .platform_data = &da850_evm_tl_leds_pdata," P) A* p& [# }$ B
                .release = led_dev_release,( ]$ y; W$ d* P. o' M, `% [$ s
        }5 _8 C, E: w1 s- g9 h
};2 {3 \, T0 E' W; L, z/ p" j
' A: J& V" v7 [4 E/ h
static int __init led_platform_init(void)
) _* E" `7 f' R4 ]0 I4 K% e9 D{
$ [5 t! Y; ]9 v( j9 h        int ret;
7 M5 G5 h1 u8 E. U8 L6 q#if 0" L2 Y5 i* ^4 r4 k& E' V
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
" \: l. r0 J9 a2 k; J  _        if (ret)3 s0 T0 U) W  N  ]  i1 l  \
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :": j& f! C5 T. p! y- J+ f, I; D
                                "%d\n", ret);
- E/ C$ U) F2 I/ x7 K#endif
5 R! E9 I; Z) n) n5 |- T# @0 Z        ret = platform_device_register(&da850_evm_tl_leds_device);# X, w7 L" ]/ L; i
        if (ret)4 ~5 E- W0 s  o5 N
                pr_warning("Could not register som GPIO expander LEDS");1 t" u; o  E3 r5 P
        else
4 Z% p4 P. s: x; c5 k: X                printk(KERN_INFO "LED register sucessful!\n");5 ^1 M  C. \- q& I+ ?; E( Y

" x- d( d) U1 x. {) Q7 j        return ret;( a. P* ~0 n$ |- D7 X0 N- W) N0 C$ L  _
}! A& f9 G4 v: Z/ v* D4 e- v

$ |  X2 T! U8 {7 A4 Y! Kstatic void __exit led_platform_exit(void)2 I  G' r% C/ `- d! h
{
! S( b; w3 I  z+ x4 [9 ~        platform_device_unregister(&da850_evm_tl_leds_device);& e8 P# {$ q" ]
& F, S6 g2 V- ?! s/ ?
        printk(KERN_INFO "LED unregister!\n");
( X% W6 Z' y4 q( ]* v}; U5 \/ M; ^& F" w0 k( d
' i4 m3 }; L- T9 p2 n3 v
module_init(led_platform_init);
/ c0 c" k( o- J/ H, q& B4 N& Wmodule_exit(led_platform_exit);
4 b& X$ D9 {; k% X; t4 E1 N: ~
( o/ O6 O0 P; }MODULE_DESCRIPTION("Led platform driver");
  A/ \% F! i6 Q' I8 yMODULE_AUTHOR("Tronlong");
0 C6 ]2 Y, ^! U- d. XMODULE_LICENSE("GPL");
, v5 }) p: e7 m8 q% C' {& _
: o! k! a: \" y( R. ^7 M
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-1-31 15:52 , Processed in 0.037743 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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