程序注解 - OMAP-L138 - 嵌入式开发者社区 - 51ele.net
设为首页收藏本站

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
9 B- {& \$ G9 T! @. g#include <linux/init.h>5 B) ~$ T  m: ]# o5 x) T
#include <linux/module.h>
2 B. o1 K' p1 P#include <linux/kernel.h>$ q) ]4 d2 e# l; u5 _' m0 y2 W) X; s7 U
#include <linux/types.h>
( R- I6 C& K- \3 \  v) x#include <linux/gpio.h>( g  _1 F' H( Y. j4 `4 Z
#include <linux/leds.h>
% v" g: J: p# M+ i5 A* j3 [/ e#include <linux/platform_device.h>+ E: |; ^0 Z$ [
; i$ ]1 n  a; U! S- ?( r. t
#include <asm/mach-types.h>5 K) b" \9 P2 D0 |& l# o6 y1 m
#include <asm/mach/arch.h>
4 i+ Y  ]& s# ^! J  q/ M: B#include <mach/da8xx.h>
* C0 {; `7 H4 B: z8 y4 v0 X#include <mach/mux.h>5 S) m8 }- }( Y: \

3 \! y! Y8 I1 a#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)' }+ x# g* @1 c; p. v4 A$ z$ [
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)7 j$ M2 ]" C2 O* Q8 e  g6 x, g9 E
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)' |6 s2 N( U: \' d! h
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
. }' `) z) S9 c( s2 @( i+ W1 j9 o& M! R& c
/* assign the tl som board LED-GPIOs*/
0 v, I& Z' M+ }% a: L' Lstatic const short da850_evm_tl_user_led_pins[] = {
  i; \0 U9 r% a& {. Y4 v$ n( n3 r6 g        /* These pins are definition at <mach/mux.h> file */
9 Q* F: [  r5 r! C5 }3 w0 x9 g5 v        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
' d! E0 K* q5 O) C        -1
( h# \7 J) G5 h7 B8 @" v};7 t2 B* c3 E6 Y  c$ G) f
9 {4 j1 n0 L# g+ W6 [
static struct gpio_led da850_evm_tl_leds[] = {0 h2 Q/ S/ f" L  ]1 e. N7 M
        {
; {7 m( K8 u9 P* c% U. R1 z                .active_low = 0,% t: R6 M* O3 L  Y6 S! T2 \6 o5 f3 E
                .gpio = DA850_USER_LED0,
4 U5 n$ N& \7 g3 V& T6 U& S0 y+ w                .name = "user_led0",
7 a, D8 i* T5 @7 V$ _5 s* f7 [& q9 P                .default_trigger = "default-on",- ?( C. ^6 s8 D' G# ]5 A( K
        }," ~' m+ E/ y) A. U1 `( c/ u
        {6 b. }. n( A4 t8 J
                .active_low = 0,
, C3 k: z9 M" ~1 q8 @% d                .gpio = DA850_USER_LED1,0 F: w" m* T& u8 F" ?, {3 C
                .name = "user_led1",5 s5 E* Z9 _5 L6 c. |
                .default_trigger = "default-on",
) v, p) i* ^; N: I/ ~+ l        },; S0 k$ @, Z; I2 G& ^0 I
        {
: Y4 a+ f8 B6 d) ^. ^: e                .active_low = 0,' D$ t6 g! q1 V
                .gpio = DA850_USER_LED2,0 @. m+ @/ f  o5 @+ }6 a
                .name = "user_led2",
* q, ^7 J% y0 m1 @8 a2 a$ J/ E4 S                .default_trigger = "default-on",
1 K* L# e9 a+ S1 l& J4 p        },9 Y4 ]6 W, M/ Y
        {
$ e5 m+ P; K2 T# z/ B                .active_low = 0,; F3 G( [% S) o) h7 N" }! F
                .gpio = DA850_USER_LED3,6 t; N; P; y2 n, d
                .name = "user_led3",
0 b- y: v- G& Z' q+ v                .default_trigger = "default-on",8 J. j( f0 Q* G! }" T
        },4 c( b. Z0 r2 n$ {7 S
};
) I0 e6 D; c. d  r7 a$ g6 J1 b3 ?' R
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
8 f4 x8 ]2 h; P7 e2 Q6 q  `6 f        .leds = da850_evm_tl_leds,, S  j: F: T/ y; \
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),4 ~: u6 O" l- Y; A" x1 A. H1 ?0 a
};6 k8 S# i  n  h- X
; C3 s# w. }" f- h1 R
static void led_dev_release(struct device *dev)6 p2 k$ Y0 e# a) y2 y
{. |# ^1 G9 H4 k& R4 X
};9 X6 Y: {: q7 A$ N+ Y
8 {9 D9 D* o9 @& A: f
static struct platform_device da850_evm_tl_leds_device = {# _. N. z- z2 e% w! E" ~4 x
        .name                = "leds-gpio",
- W$ J9 V) O: i: q4 ^        .id                = 1,5 V% Q% x0 {) Z$ }; _" v) ~! P6 s4 {
        .dev = {
6 Y! F0 U! }9 X  o# j. Y                .platform_data = &da850_evm_tl_leds_pdata,
( L3 c) {4 u0 L# }) G                .release = led_dev_release,
6 T' a& }1 D8 x( ]* P        }$ r  R  H- e; z4 q9 Q
};, c6 s) P9 c! m! H
9 k" w, ~- G6 Q! C5 @; [. E
static int __init led_platform_init(void)
! W% I: q1 w6 e, I% v+ D$ M{/ C; k1 Z. n: s" S" L
        int ret;- Q1 P6 {. n- w; P" ]4 n
#if 0
% m( w! i2 @. G        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
# X/ N- P& L' n" }/ H        if (ret)) g% D! d! n/ u- Y
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"5 a6 u( F; V6 I$ P0 r4 g+ T: ~- |8 K
                                "%d\n", ret);
5 T- K& @9 H) q  ]$ ?# M# v#endif( T% ?5 g$ O; z5 K: P" A# B' S
        ret = platform_device_register(&da850_evm_tl_leds_device);, b/ _1 m! E6 @5 N" j3 ]
        if (ret)/ a% j. G* Z1 [' W, i
                pr_warning("Could not register som GPIO expander LEDS");
0 p! l. J7 O& r7 R: D1 o! d+ o7 O        else
# }" ?& @) Q4 @                printk(KERN_INFO "LED register sucessful!\n");3 E/ _: D4 t& z) y4 |
) V% J4 O, t; @& ^% E
        return ret;( E! }! l/ s2 X; x+ m
}% q- N5 t9 p% n+ G3 l' K
) J: @3 P/ H$ @3 N# i, c0 }
static void __exit led_platform_exit(void)7 y" N8 o4 D; }' X* V5 l
{( s- g4 V) i' R% o, ~9 W
        platform_device_unregister(&da850_evm_tl_leds_device);8 U% v; }0 Y' [* z9 m/ C; I
0 e" e0 o& _3 b% U$ K. I) {
        printk(KERN_INFO "LED unregister!\n");
' x0 v5 r2 r+ y6 `; u}
0 A% h( A) x/ x4 u
4 R+ p4 i% y8 R. w8 z! W1 {) gmodule_init(led_platform_init);9 Y/ f2 T% \  C( i
module_exit(led_platform_exit);
% u4 g- r  I6 T: f4 o
3 W9 X, i. I4 N$ A$ S) lMODULE_DESCRIPTION("Led platform driver");$ C5 M! v7 k/ [/ o. H! s  B
MODULE_AUTHOR("Tronlong");) c$ N( c6 B8 N0 H
MODULE_LICENSE("GPL");
5 @( L" ]3 W/ L3 L2 S1 k$ I, k- I  y7 _
: h) p" H7 @% g) t( S9 ^
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-14 07:37 , Processed in 0.037371 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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