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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。. Q; y3 K2 E1 E5 j* j; w+ j/ E4 B
#include <linux/init.h>* j% ]- C9 j& N2 j$ r$ }; m* a1 j
#include <linux/module.h>
' _" l$ e( |3 m9 i#include <linux/kernel.h>
+ p& B6 |4 J# M$ |, v  O#include <linux/types.h>3 d- H* T) R# `! K# \+ z
#include <linux/gpio.h>
; M7 ?+ E! w% X9 w" |#include <linux/leds.h>
7 T7 O. u5 D9 I+ t#include <linux/platform_device.h>! b0 K* y" x+ e5 G3 F
" O* _' O5 u9 G0 C& h$ [- V
#include <asm/mach-types.h>% [' ~3 _4 H( {- h/ T
#include <asm/mach/arch.h>, J/ i5 q5 f8 i6 p0 @9 m& U
#include <mach/da8xx.h>0 h) |+ S7 s2 E& l, E* v
#include <mach/mux.h>
5 n$ H" T. l" S6 k# j- D. q* p) W# ^# c' G; w; A& Z
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0). i3 ]$ x% s# m# |2 r
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
# `3 C* ~- h7 t3 [2 L#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
. A+ |. b6 e0 l3 [! ~9 l: a5 G5 r* z#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)3 H! e" y+ [; J  ^  N+ t& n# ?

- q: a9 n  e8 s* N7 ~5 _/* assign the tl som board LED-GPIOs*/( z$ \4 {+ H5 X7 _7 f$ M3 ?3 ~
static const short da850_evm_tl_user_led_pins[] = {
2 \/ u  l- T6 M3 G! z+ n+ ]4 c        /* These pins are definition at <mach/mux.h> file */
6 z1 }( Y5 D% E" Q8 R2 R9 X4 m        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
- _* q2 c" L/ a, k. Z        -1- _' r% S( e) _" I+ a! ?
};
- w, J" m3 g* J3 j' {! f/ w7 ~! Z9 J" U( j# N) X+ b7 K) H
static struct gpio_led da850_evm_tl_leds[] = {
5 s7 R2 W* Y$ M0 {) Y/ F1 w/ c        {
% O( i' Q: w4 D; {( f& |                .active_low = 0,2 k! \7 D2 n8 p% {/ S" ?
                .gpio = DA850_USER_LED0,1 j4 u7 p: G: d; u
                .name = "user_led0",
# l' z& A( v9 e" d1 d& ?8 g/ ?                .default_trigger = "default-on",
# {/ ]/ |- x. ?4 o1 B" l+ Q( b8 |        }," T8 d. J- n4 D" _8 b
        {
, S; m& Q+ A2 z' q                .active_low = 0,
8 z) }1 W- @: E6 Q$ \) _! t3 s                .gpio = DA850_USER_LED1,+ L. V2 B( y& |. m1 h% K( W
                .name = "user_led1",- H2 h! B' G7 A1 b6 Z
                .default_trigger = "default-on",+ c$ H& g6 K) I6 u
        },
' S. v8 `: ]& a4 s8 ]  E! ~        {
, ]+ V, e5 \2 G$ ^5 D- L                .active_low = 0,
2 K  [- Z# N. p3 D* p( S( y                .gpio = DA850_USER_LED2,
( a7 d! n& C* a& }                .name = "user_led2",9 u' R' x4 f* M; U2 g* l* A5 Z; _
                .default_trigger = "default-on",
3 v5 H% x* Q4 V0 f( h9 d        }," @$ A) ^8 z& H, ~6 s+ l9 O6 s' H
        {
' T# Z1 m- Z1 W% ?  n$ y1 Y, v( `9 A                .active_low = 0,
7 L7 ?( P: \. v* L* Q                .gpio = DA850_USER_LED3,
4 d5 @+ B: M3 @9 c, h: F                .name = "user_led3",* `% t/ o% |9 w, A& u+ N9 a! {- N
                .default_trigger = "default-on",
+ C8 f6 ?8 n7 P  w        },  M9 j6 k' ~% W
};. J  k# I3 W0 Y' X& P  S
$ V- p6 V$ A2 Q9 k8 ]% J1 k, q
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
; l4 H9 z* b8 `5 r$ F- g        .leds = da850_evm_tl_leds,
! z0 |7 |$ ~" }* T, s+ i        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
( A3 [% `: @. W' c};
) e* J$ o  F& q$ W/ k
( d7 w# k  T; k0 j% J0 I6 Estatic void led_dev_release(struct device *dev)
( t' @) O: Y6 L. M" ^{
8 g& p. K5 ]+ H/ n' S0 U. x/ G};
) E7 c  b( u; J7 q  A' }2 \+ }7 S) V$ E* R, S
static struct platform_device da850_evm_tl_leds_device = {
+ i/ Q8 X. }- v  `        .name                = "leds-gpio",) V" x" S' @' L  O6 c9 v; A
        .id                = 1,
1 u3 `/ p" B. C/ q        .dev = {
9 U! H1 R( u& Q5 }' U1 j7 q( a                .platform_data = &da850_evm_tl_leds_pdata,
* Y! C# [5 w+ G. \. R: q, \! l                .release = led_dev_release,
# G1 S2 |9 n7 q! e( J        }
: a3 {4 K- \# i' s};6 O" Y1 t9 o' h5 P" L! ?

; w$ a$ d/ p+ P" ustatic int __init led_platform_init(void)9 X$ W7 [/ s5 j& m, x$ r# k5 D
{# \; x8 F6 ]" X. A3 H4 ?* ?
        int ret;
% k  G- q% E; f. [: r! C/ w#if 0
" R* S+ s3 y( `/ y7 I        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
" a7 d+ J& z' z9 i. o! ?0 p        if (ret)
6 G5 A& F1 m" ]9 E+ w4 s  `                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"7 O0 l9 g  t2 i. o3 H5 X+ L$ R* b" \
                                "%d\n", ret);
8 u" z( ?8 Y# Z. Y4 i1 k#endif' M0 U: Q) b/ f) f3 h! F
        ret = platform_device_register(&da850_evm_tl_leds_device);
  R$ q* H; b8 l% L        if (ret)0 P/ }; U' d! \- {" m. m
                pr_warning("Could not register som GPIO expander LEDS");
4 m2 U8 X) u: C; D  C- u        else
0 K" [; l* O7 V& O. o: l" i                printk(KERN_INFO "LED register sucessful!\n");3 C' O7 Z# E- l
0 [/ h8 l+ X6 V8 S0 @
        return ret;
/ f% o. s& }1 K3 b}5 @9 [2 }# R+ N0 w8 m, Q
6 ~0 u% `4 T# q4 |
static void __exit led_platform_exit(void); C* F* H3 \4 j) w# ^# j
{% y8 X% b& @$ ]$ w0 k3 u/ @
        platform_device_unregister(&da850_evm_tl_leds_device);
# B8 M  h$ K  ~" L, s0 o) P& X+ a3 e$ x1 V
        printk(KERN_INFO "LED unregister!\n");8 U' [% V$ W, M
}2 A0 U' d5 S7 f, k6 g* o

' k! g. p3 w( p. u: K+ B3 Zmodule_init(led_platform_init);, p; Y  K$ V8 p5 |- n8 z
module_exit(led_platform_exit);8 I/ c+ D) T$ J
4 Z: F# K: s7 W& Y# `7 g
MODULE_DESCRIPTION("Led platform driver");
9 `# z) J& P6 g5 ~MODULE_AUTHOR("Tronlong");
, E2 ?, X. Q4 `; |0 \MODULE_LICENSE("GPL");. B' P* |/ c* |( l0 X: N' l

6 N8 o% K3 c0 ]
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-4-3 19:04 , Processed in 0.039494 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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