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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。! B9 d& W' S5 ?9 i# }2 I
#include <linux/init.h>" [7 _2 H: W) }7 `* g
#include <linux/module.h>
7 t* G/ S# D& c$ ]* W#include <linux/kernel.h>, y+ X* W* S. e
#include <linux/types.h>% i5 O8 }/ j8 `3 w1 q' U6 s  A5 w
#include <linux/gpio.h>
( C; I3 @7 U' M$ {) p7 y#include <linux/leds.h>+ F: {0 n, T  \$ ]) S: [
#include <linux/platform_device.h>! I; @/ @, E& q# |

7 v% v% G0 b$ J9 `#include <asm/mach-types.h>
8 X" b+ A0 ?3 r. p, _#include <asm/mach/arch.h>+ c7 H7 a4 K4 Y$ i  l
#include <mach/da8xx.h>
  X  L/ l, S/ \% `) H9 }. q#include <mach/mux.h>: d5 s+ u$ n, t; Y* Q/ Q2 a$ |

, j# ~$ c3 j- r7 r# ~2 l& m3 ]$ |#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
- o" P, s( z$ O9 w#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
  I# X' N+ @$ U  \- c+ p#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
9 I7 M/ {5 m3 [7 D% ~#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)% ~9 v' ?/ n3 y' }1 \

8 ]+ ?0 `* X5 ^0 G9 M7 j/* assign the tl som board LED-GPIOs*/% I$ v% P% K$ i+ u: |3 A9 T
static const short da850_evm_tl_user_led_pins[] = {
: l" G, [* K, J" ~        /* These pins are definition at <mach/mux.h> file */
  e! J% b) S; k8 b/ z+ d        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
# H* {4 B8 |2 J        -1/ N4 E: }8 q" d# Y- Q" K4 @( b
};
( Y* u! h2 I/ [8 P& g7 Y
9 b  n- B7 B7 t/ jstatic struct gpio_led da850_evm_tl_leds[] = {
: }8 l  K8 B; j. U/ j/ r        {. o$ {+ v2 t8 v7 F9 E' f1 w" J# P) ^
                .active_low = 0,
) ]5 h* q2 ?' M8 P                .gpio = DA850_USER_LED0,
2 B1 @' Z0 j# F# E% G; ^) V                .name = "user_led0",) l( Z* y0 ]0 u5 Q  d
                .default_trigger = "default-on",, i2 w2 f1 i6 f3 A. s
        },
! D, P: j# O% u+ L. E* z        {
/ R, ]% w. ]1 w% s5 b! r; i                .active_low = 0,3 K( c" z' y, ]/ x) w0 ]
                .gpio = DA850_USER_LED1,4 i7 j% g0 f% N8 Z3 V5 G1 R+ D. d
                .name = "user_led1",# A* V( a  T4 j% Q% p% V9 H% @
                .default_trigger = "default-on",0 W9 m: R. L5 h3 Y6 j
        },3 ]4 v0 L, r0 ?4 f
        {
; R! `. r' e4 @7 e1 h                .active_low = 0,( n6 S6 q$ U0 H9 o/ @
                .gpio = DA850_USER_LED2,7 e6 E+ e: x7 r9 |
                .name = "user_led2",- G+ o( \8 q+ \' Z9 [
                .default_trigger = "default-on",
5 W( O. P$ x" x) W8 m) p- Q        },0 A5 y) K/ k- }/ L7 V$ ^$ ^8 F& a
        {
" V' |# ]& O+ W2 E9 `$ M$ m" X                .active_low = 0,
4 G& S; M/ z: n# q1 G4 }                .gpio = DA850_USER_LED3,
& a( D$ w9 `4 u                .name = "user_led3",6 R  ~5 [6 Y0 ]8 f
                .default_trigger = "default-on",
! l7 I5 p" V1 u* V8 G9 E        },
, `: i, c2 G% U& g% {9 Q# T};
: t$ f  [" a8 [: m5 I. ], C% x; l% h
; j, @% L  N# W- _1 o8 lstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {+ `: f0 c% `( E: _& Y/ {
        .leds = da850_evm_tl_leds,
3 }. ^9 Q7 N9 j7 N* r        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),& p7 E0 s4 E* S( w# l) N
};
( c; Z  _2 ~7 c0 y# C4 ?7 ~' O) C  S; V$ k+ s
static void led_dev_release(struct device *dev)
% p# Z* ?2 K+ F{
0 T" c4 i3 }) L; s6 r" m};
& s* v2 y* C9 p7 G+ [. e1 T  V# f$ }  Q! Z0 C- O
static struct platform_device da850_evm_tl_leds_device = {- o; V2 D$ B3 Y8 L4 F- s) S5 n
        .name                = "leds-gpio",
" C) k! E6 m$ ]9 Q" Y  ]* @        .id                = 1,
9 @1 |2 n" O$ F; ^5 b        .dev = {
7 o5 [: N7 t  \* `1 B7 x% H                .platform_data = &da850_evm_tl_leds_pdata,# K  @1 I% {- H
                .release = led_dev_release,! t& @$ K0 t4 x! m" d2 I. a
        }
( b8 B/ `: A$ I% r, v* \7 J};
+ M* A* p6 G7 i9 ~) V5 {4 F" h0 }  e; l6 T# b1 G
static int __init led_platform_init(void)
: _' n* U4 f3 @* x{3 ~* }( q8 D2 r- R
        int ret;7 ^* s* l0 ^* r, r# I' l
#if 0* b1 Z- l$ b7 f$ R
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
2 C" X2 _1 }6 l8 E2 T. W        if (ret)
7 X) r. S1 E7 O7 k                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
% u3 d9 K- t, y% B                                "%d\n", ret);
' r, ~. i# V0 G9 O7 Q) s4 r#endif( k$ J2 I% K- Z& E/ o: g5 f, d2 _
        ret = platform_device_register(&da850_evm_tl_leds_device);4 O( [. L: r# `0 a7 r
        if (ret): Z; e6 `5 C; l4 m
                pr_warning("Could not register som GPIO expander LEDS");
, B& j& w1 Y" L; E- f        else
, L/ K% D  Y( Q5 W6 R: y& _: E* q) p                printk(KERN_INFO "LED register sucessful!\n");
" p' p( O+ L$ |1 m$ g
3 k0 i: n' G* h- ]        return ret;
: ?& s% A8 Q) N- R6 \+ Q5 _}
' Y  `; M3 L% f. C* z1 [
; n- |3 T7 L) ?, G. Sstatic void __exit led_platform_exit(void)
; f' D' r" G  O1 z+ D- }+ H/ y{7 ~- J- X2 G/ V3 M% W
        platform_device_unregister(&da850_evm_tl_leds_device);
' P- k/ R- C& ]( N( F, `3 ~
% g3 s: R: U" Z. C8 L! {        printk(KERN_INFO "LED unregister!\n");9 P8 W, A. l/ J, E+ |9 J( {
}
! y% [# ?! I$ J# L6 M! E# ~- x. Z2 l, D4 I
module_init(led_platform_init);' j8 p/ U2 ]/ j' O2 k& h+ c
module_exit(led_platform_exit);3 n' t4 N/ h, z5 B$ y" q. _& H
% k5 ?% I( d# ^# @
MODULE_DESCRIPTION("Led platform driver");
+ m0 @% a! T& v( ~MODULE_AUTHOR("Tronlong");
0 @2 E* Q6 ?: ]! Y4 \% LMODULE_LICENSE("GPL");
3 \1 [9 h* A" X7 J5 \
, X( ~, ~1 p- {3 }* I
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-6-3 02:09 , Processed in 0.038301 second(s), 24 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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