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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
) L. d" B1 f! q; r" f#include <linux/init.h>0 \1 b( ~: t; C# z, |" T
#include <linux/module.h>6 ~$ S; Q" @, h' b4 q# i) \  y, r; S
#include <linux/kernel.h>
2 m9 g) Y) b9 s1 Z# v: F% Z#include <linux/types.h>
2 q5 I# T) Y) l6 B: ~#include <linux/gpio.h>
) L/ d" ~) H5 M/ h#include <linux/leds.h>
* q6 Y, G8 n0 N! t. i6 _: h, h#include <linux/platform_device.h>
' [" I' N' Q1 T7 q- v9 C1 E2 {# N- K, ]
#include <asm/mach-types.h>% F. A, H) h& T! ?3 g# V8 j1 J! v
#include <asm/mach/arch.h>$ y! g: i1 H! M( v5 Q' p; ?( a1 t
#include <mach/da8xx.h>
) z: e) x) m3 f1 c#include <mach/mux.h>
5 v: b7 C/ u0 w7 V& F2 K& Z/ \
! K$ n  N$ ]$ x/ ?: x0 D: Q7 f7 c#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
5 u: K) U3 L+ U) {2 X5 G#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)9 s: U8 L6 S  e& C8 Y- \4 {
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)- x) X/ V6 }) M7 i
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)+ G8 v' X5 b  @3 v. D" Z# U, k
. v/ _1 T3 v3 j
/* assign the tl som board LED-GPIOs*/
) W* e& O; g4 ^: ~  [/ C- Y, fstatic const short da850_evm_tl_user_led_pins[] = {
# V, l* K7 P+ d2 D: e3 V# S        /* These pins are definition at <mach/mux.h> file *// E1 p& z: G/ Y4 @+ c
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,- `3 B1 [/ t$ d2 x0 i) }$ g& o
        -1" v$ B( \- C! Q0 W1 u
};
  R6 E2 E6 h# s" ?$ G: {
7 T: `( w3 j1 w8 K2 kstatic struct gpio_led da850_evm_tl_leds[] = {
8 a% g7 u$ f. v; X9 m5 f        {
" Q0 ?; [2 s) x$ k  @6 L7 `                .active_low = 0,
, F" N2 L( O+ d# x5 {+ B/ {6 o                .gpio = DA850_USER_LED0,- s' z0 A1 e9 N0 j, P0 M
                .name = "user_led0",  I; U! P7 ^! \6 d
                .default_trigger = "default-on",% D8 S* x; I! H+ k$ ^' T3 k" Y1 F
        },
1 M& p; s7 S. R2 f  o- s+ l8 P        {5 L1 A2 r6 {& J, ]. J0 O6 L
                .active_low = 0,. \4 Z, w+ s9 v$ W6 B+ y" z
                .gpio = DA850_USER_LED1,
& G4 u+ G" {' N& |* U! U- v                .name = "user_led1",
: V2 V' e9 A9 }                .default_trigger = "default-on",4 V) ^/ }! P; f% R' j' a! P' d
        },
/ T, y. |8 U& L& x% @        {# Z$ D5 Q4 Z  l  r7 ~* _
                .active_low = 0,
8 B- d4 V5 g" a$ x& e5 J                .gpio = DA850_USER_LED2,1 b3 m& U% s* L1 S; ^
                .name = "user_led2",
) r0 S! G& L1 W, O. D                .default_trigger = "default-on",0 v9 d5 V5 O$ S* D. k3 [. B$ M
        },
  u2 q' [* S9 q: }+ P6 G        {- F, r/ N. N' \1 j4 h) L; P6 B) D
                .active_low = 0,
/ w& t5 A$ A  i7 z/ b/ z; X                .gpio = DA850_USER_LED3,
& q! Y3 F, N8 O! {                .name = "user_led3",5 n3 t  m9 Y8 h$ y6 C
                .default_trigger = "default-on",
9 B$ s  _2 ^2 _. p        },
4 X5 m, N9 N* M- c. W: d6 I2 @. [};) S1 \9 B* u% B& ~. F

. T1 H* E4 _" g2 \% g  Qstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {9 \. K9 n! E' y3 }: ]1 E) C1 Q
        .leds = da850_evm_tl_leds,8 i) z/ D% ]4 ~/ a$ i. r5 }
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
7 {+ K8 ]- j+ p0 W8 z, |" \8 t};
! g& E. L5 W8 c" i! E. n" c( N0 F+ a$ U' e1 _# n+ M
static void led_dev_release(struct device *dev)
4 ~5 R9 r- L: @+ E{! J0 Q# t+ w! n! l) F
};4 W6 l. m6 _1 T( @$ C( @& r
) B; O+ c% J# \& f! q* {
static struct platform_device da850_evm_tl_leds_device = {
4 a, }: Y; P( u4 h' m, N0 b        .name                = "leds-gpio",
7 Z+ [8 z/ w2 D) B7 b6 I2 B& Q        .id                = 1,* J! Q8 P2 ]. f9 y, l, [# C
        .dev = {! B1 K2 F. K- f, C# d1 G
                .platform_data = &da850_evm_tl_leds_pdata,& v3 Y- n* b0 i* n  I
                .release = led_dev_release,
  a& |& s7 Z2 }% H2 T# V- a        }# x# ^* \0 E6 e7 l( |0 u3 f
};% h, O" _8 W: i4 N$ T& h6 H2 Y

( m* p2 s5 a2 h3 E, \! bstatic int __init led_platform_init(void). J% B: u4 _2 x. E( K8 I
{9 s" p6 ~; W) @
        int ret;* s' d, F# ^, l5 a$ `
#if 0
0 j! u9 i$ z6 l# k, S" L" Z        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);- N# D# D. |2 g% H+ j
        if (ret)- |* @8 `& u7 u. A' Z: m- p
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
( `8 b  I  Z4 A+ {                                "%d\n", ret);  N8 j/ o) m! @- k; T
#endif5 W: n0 S" t+ ]' s, ^
        ret = platform_device_register(&da850_evm_tl_leds_device);7 t, Z  D$ p! s5 f* k+ x
        if (ret)6 B# Y3 w% X2 n4 \+ s3 W
                pr_warning("Could not register som GPIO expander LEDS");/ O% c7 W& e' p8 S% x
        else& y7 M8 x- h4 z5 Z% c6 e
                printk(KERN_INFO "LED register sucessful!\n");4 d& k$ x' \( n8 u: K. l" n

) S. m! m! u2 b2 u) J+ R! ~! E% i        return ret;
0 \& M* L6 f5 C+ D}: ?: P# y# ~* _+ Y

. Z& n! ?. Q, _2 b) W- n: o7 n! Nstatic void __exit led_platform_exit(void)$ M. X1 h4 Y7 H7 h% J
{
4 z. f! s8 [7 g/ N0 W4 v+ k5 I& U        platform_device_unregister(&da850_evm_tl_leds_device);
& z# k7 s) [5 X+ D
( v' H: Q, K; l        printk(KERN_INFO "LED unregister!\n");) v2 K3 o& q6 j0 X! `* S2 B
}* ?. L; u& ^" ]* W; u3 H# p

* X  K9 R2 P7 i7 @% d- Cmodule_init(led_platform_init);
7 S( i. L3 k4 k) smodule_exit(led_platform_exit);
) E7 K( n+ g$ V. ~8 B; b9 M2 Z/ _& S0 j, w9 m6 S' |( M9 T/ N
MODULE_DESCRIPTION("Led platform driver");: L2 M% R7 \4 p; d- Z2 f
MODULE_AUTHOR("Tronlong");
/ K# c$ T5 B6 P# Q) UMODULE_LICENSE("GPL");0 Q8 g5 N, i- _7 @
6 |1 A5 g- U' r. c* m6 ^
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-1-20 14:55 , Processed in 0.040799 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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