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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。; y  V" D. j# y, {* X, Y
#include <linux/init.h>
+ w: s# }* M) m( k$ u#include <linux/module.h>4 U7 o7 |* C% }
#include <linux/kernel.h>0 w+ q8 v! }$ w' u
#include <linux/types.h>: ~5 }& N" i, C3 N, e% s6 B. `# Q+ J
#include <linux/gpio.h>
- j) H6 P5 r' A, E( u#include <linux/leds.h>
7 f$ g/ x0 b" I9 E( V4 o8 ]( d#include <linux/platform_device.h>3 ]# q- O' q  F! {. r# c1 E

, }& G  S4 {+ g6 Z#include <asm/mach-types.h>
$ X" T5 a) b; S) ]3 f9 [# J7 L#include <asm/mach/arch.h>7 a% o/ t0 G& U: K& A& r) D" F1 t
#include <mach/da8xx.h>
% a8 C8 P9 f" r#include <mach/mux.h>7 I+ O0 ?0 V" ?- g" b  K7 k

2 N" G. J6 o1 |3 x  j. Q# U#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
9 y$ i6 ^; K8 i4 z#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
; f: r' n% x* ~) {+ k  B#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
8 I8 u' b+ \8 J" s+ {. w5 l#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)' k1 e& i; G0 y

1 H8 u+ L3 Y/ b. f# e+ f3 f2 A/* assign the tl som board LED-GPIOs*/: {, `* T5 J1 l( ?0 V8 ?
static const short da850_evm_tl_user_led_pins[] = {
) E' n) `: k( X! r        /* These pins are definition at <mach/mux.h> file */
0 n. c# L) d1 i" D+ y        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,9 s7 u2 Z' |! T* B$ E3 ?
        -19 w2 y% B. F. A  @# e
};
9 a) N' _6 Q* k1 n( b% `# t8 H( K# _5 k# U# z' P5 p
static struct gpio_led da850_evm_tl_leds[] = {
$ Z6 L2 b( \6 a! t        {
6 l7 z) t3 C7 ]* K) g                .active_low = 0,; Z2 Y- ~! r. S* [1 Q- u9 l
                .gpio = DA850_USER_LED0,  }' K; f, d5 m6 s
                .name = "user_led0",2 `4 \- \  T0 Q9 Y9 S  I& U. I& w
                .default_trigger = "default-on",1 I: D+ O9 j, d) Q
        },9 J0 n4 j9 a1 {% F
        {2 t0 r# P5 r2 P2 ]# _: Y
                .active_low = 0,
% Z6 a. \  b6 d1 r  w) j                .gpio = DA850_USER_LED1,' p6 J( J( n( _, \' @( [
                .name = "user_led1",- [; W$ o2 B, q/ a
                .default_trigger = "default-on",  P% K7 F% q% X% b* }% ?
        },& o& N2 h/ |1 F4 E! u+ E
        {5 K1 S) W5 u, L
                .active_low = 0,; B: w4 ^# b* x/ P: @( a
                .gpio = DA850_USER_LED2,
+ F/ n3 T5 N0 h+ l                .name = "user_led2",* M6 b: k, n/ s3 ^8 G
                .default_trigger = "default-on",$ K7 s2 N4 z+ ^/ I: I) M. \
        },
0 ]" w0 s* U8 x) o% v3 Y        {
: l& X$ V8 N' F6 [5 L6 H' k& x+ i# v                .active_low = 0,- W. P& T, C. L: n
                .gpio = DA850_USER_LED3,
& N8 X  i5 u6 ?9 h% e                .name = "user_led3",
! e4 T, I6 H; L# f! @                .default_trigger = "default-on",
4 c" @& }1 X4 \2 L  N+ X        },8 v& p* Y3 |( l: m
};
' b; o3 ?( L# g, G, F5 f% i7 Q
: r- Z* R+ W) Y) A9 Dstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {0 ~6 x( f4 T2 h, S
        .leds = da850_evm_tl_leds,/ F/ m  O) Z; l* L1 k, T7 x5 J
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
" @  F% t5 X1 Z0 ^2 L6 O};$ ^' @2 ?8 S! m& }' k3 v
0 M  e" i) Y. u1 i3 F
static void led_dev_release(struct device *dev)
5 X- x% x& s$ N2 V$ d6 \, x' i{8 |$ M3 d/ Y# ?6 B3 y: o
};
& p1 X1 I' j& w0 Y/ ^* K5 O$ g2 z  E) H7 o5 f+ y0 ?* O  K# p
static struct platform_device da850_evm_tl_leds_device = {
$ j  ^8 P2 Z! y$ z; d        .name                = "leds-gpio",  s! V" j% t: x" i
        .id                = 1,
) M2 K$ `4 N* e2 l' a: x" x1 G9 P        .dev = {
% E5 ~5 K% T) K& A: L) j3 A                .platform_data = &da850_evm_tl_leds_pdata,
' @) F' z) v7 r* X. f) q                .release = led_dev_release,
. {- j: l; x1 X        }
* c) o6 D' p6 ]- T};
( }4 P9 a& m6 q' V( {. U/ x1 z) {& F6 G1 }( b5 Q% U4 R% \4 _. U
static int __init led_platform_init(void), J+ q6 @) K8 _4 T" F' }5 z
{  P1 [) H) P9 M( L. r# @0 B0 n. e
        int ret;2 y; D! g% a$ q
#if 0
2 f' X' U8 |+ V6 u        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
4 |8 r0 v+ i' \8 O. T# Z  [        if (ret)& f  u" q% U* b+ w. L
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"+ t1 J2 O+ A9 S: _
                                "%d\n", ret);# B9 o) N9 [. |* [% c3 m
#endif* I, |" U1 @) @& j' |* Y7 c
        ret = platform_device_register(&da850_evm_tl_leds_device);7 r1 K- H$ ?4 O
        if (ret)8 V* K' T# a$ `/ F
                pr_warning("Could not register som GPIO expander LEDS");
# Q1 [$ B# ^* s0 \        else
% b, }4 s' @( z; O                printk(KERN_INFO "LED register sucessful!\n");
7 d' ~3 T- d* C( M
/ v+ Y/ G' r5 z2 y        return ret;
8 B0 N7 p; q* o7 R! P) h& A2 x, A}, h6 ], C/ y4 o. J! M5 x5 V2 J" ^; u

& G# I' ~9 _9 C: ?, {5 [static void __exit led_platform_exit(void)/ s7 }5 K/ X% p) Z
{
& K. C& A) X+ U% E, A6 x        platform_device_unregister(&da850_evm_tl_leds_device);
& U' s% u5 r, H
4 Q4 A1 m9 g7 ~3 R2 L7 s5 u        printk(KERN_INFO "LED unregister!\n");% j0 }  a. {" n. w! @
}$ E2 {0 L9 f+ v3 e

. f' D( o$ P  vmodule_init(led_platform_init);9 I0 O) H/ x" V" m8 A* O  `4 q
module_exit(led_platform_exit);$ k0 d3 j) b* X) p

9 M6 J  p; z: m; I6 PMODULE_DESCRIPTION("Led platform driver");
& C, C. [3 c5 w, RMODULE_AUTHOR("Tronlong");
5 L3 R* e+ N5 F2 L" p# iMODULE_LICENSE("GPL");- a  D- {1 p9 R; n! S

. A# W8 h0 d6 M- U, ?
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-1-23 17:21 , Processed in 0.039990 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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