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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
5 O5 E9 b+ j% y. z/ A- ~#include <linux/init.h>% Y+ t, c3 Z/ D" ^! G
#include <linux/module.h>
% x5 I* [7 G/ d4 T7 e#include <linux/kernel.h>2 x$ X; @5 R; r+ f. ?
#include <linux/types.h>( w% K9 I) z4 j* L  a
#include <linux/gpio.h>- j5 ^: z! Q% l1 q. X3 \# @
#include <linux/leds.h>
/ f- m% b  Y- O#include <linux/platform_device.h>0 H; \* B- ]+ V5 U, ^, g' {
$ j9 S; ^/ j+ r# S6 r  N  b- `
#include <asm/mach-types.h>0 C8 T1 _% m$ x# U4 j8 i% v8 c
#include <asm/mach/arch.h>, X9 U. ?2 r; Z) I6 [( U
#include <mach/da8xx.h>6 v4 V. C1 ]( z9 F' P; Z
#include <mach/mux.h>
  X, q; J% W4 O( s) [% J/ W5 _4 m& \8 G+ f
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
& D: e* f8 c- A3 K# P  `% t#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
  r5 f# G3 d- m2 q3 I! u#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
8 T  x) `: X. _8 S2 J#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
- T5 l7 W. t8 N  A' ~4 B6 ^- X( m3 D! Z  H& I) E( X
/* assign the tl som board LED-GPIOs*/& \  r+ D" \' W1 k4 M3 d
static const short da850_evm_tl_user_led_pins[] = {* h; T7 k- v; e% a0 @5 a& m
        /* These pins are definition at <mach/mux.h> file */
, Q4 ~" a# c; E" Z/ F! J( }& Z        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
/ S3 |3 N% e9 |9 w        -18 f/ h. Z$ B) \; S% S8 p0 ]
};( J* R# W3 N4 c- U3 c

; J7 g. h* L7 p, @# B. y% [$ v9 O. x0 cstatic struct gpio_led da850_evm_tl_leds[] = {- ]  {9 w5 O) P* K, r
        {* G6 b8 f3 ?" W% Q0 R
                .active_low = 0,5 R8 `- P6 A$ d: S! ]& x
                .gpio = DA850_USER_LED0,
- ~9 V5 f( s- G% S/ ]' M! n                .name = "user_led0",
. t+ d  E  L" j6 J8 q                .default_trigger = "default-on",
  ]  U$ l: o% p+ ~! v        },+ e. O$ i6 M! L9 k9 |" L0 Z
        {. u/ e+ H  e9 H! ~, s
                .active_low = 0,
) n6 P2 T% D1 B) o$ ^$ ]3 |( Q                .gpio = DA850_USER_LED1,+ d, H8 z7 O  b) q1 D9 H: W2 z
                .name = "user_led1",
5 o8 ]- _  ?4 ^: M% X4 [/ _* V1 h                .default_trigger = "default-on",- E! T9 M8 U+ X1 }
        },  l" u. C$ L# V1 k: s8 m& q/ J
        {. N9 B8 ^$ Y: x/ m! e% E, v
                .active_low = 0,
$ o0 Q$ t& U/ m4 g                .gpio = DA850_USER_LED2,
" ]5 h- l+ ?5 a5 u2 ?                .name = "user_led2",1 @+ \2 S5 }- c! p% z% E
                .default_trigger = "default-on",
: l( w' b: U$ p5 K; L% y5 J, V        },& o! w: _7 ~% t+ O
        {, Y" A1 K7 {8 ~1 q+ x# S
                .active_low = 0,( p, U% D" q  `' A! D, @. \# ?8 F
                .gpio = DA850_USER_LED3,9 [& C! c! c. y9 a- g$ s; D
                .name = "user_led3",/ e$ e1 o+ w* ?6 t: Y+ [0 z8 u
                .default_trigger = "default-on",
% O$ B! J7 d* k: k) @5 h: ]        },
! g% w1 N% v7 K6 [, }4 x( m- [};
# N6 t- n3 R) B0 U# c# E/ ]( H4 Y3 Q" }; `
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {: x, W  W% d, w; O. E/ \  }
        .leds = da850_evm_tl_leds,
2 N1 c1 [$ o" c2 I. k; ]        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),+ p' t+ p) f2 P
};
' T- p( c( c% K& v: U, m1 M
5 s5 |1 L/ V% Fstatic void led_dev_release(struct device *dev), n+ R# j- S+ T
{
. F6 _- k4 @9 z6 |};
9 }9 G* ~: |4 x: G5 B- I% ?. k2 L
$ B, Y: r9 Z* ]' Qstatic struct platform_device da850_evm_tl_leds_device = {
0 ^1 X) Q" O4 {  J        .name                = "leds-gpio",9 r% d$ d: X4 J; g
        .id                = 1,
& o7 u" `" U9 ~) @; d. I5 r        .dev = {
3 P+ W, ~: y' ^! n( a; j4 t; c                .platform_data = &da850_evm_tl_leds_pdata,4 v$ R/ B. a7 ^- N& y: H; z: q6 A
                .release = led_dev_release,$ W5 l  S3 p8 [5 r
        }
$ c0 {9 [8 u# O' z+ Y4 u6 R! a};
( f  |( n$ p; }6 H$ p# }0 v% R. p3 I5 C: ?  }- @5 t- [0 n
static int __init led_platform_init(void)2 m9 t4 p$ q5 t' ~; I
{
0 N& U% |7 D3 k- `        int ret;
/ w) S. ?0 g8 V#if 07 A% A3 |0 R' K6 O6 T% F# m' W
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
+ t) r2 A5 z/ R& v) M) i        if (ret)
8 h% X" D! Z  A* M4 N                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"3 Y( L0 |3 j2 Q: T4 k0 ]
                                "%d\n", ret);5 b; k3 _- O4 c7 `8 w) L9 C% ?' Q
#endif3 H+ _: x0 z" w; ?: o
        ret = platform_device_register(&da850_evm_tl_leds_device);0 G0 s, ~+ k# B- a. b& u
        if (ret)
' R0 f$ k3 ^% E  [" r+ q6 U: x                pr_warning("Could not register som GPIO expander LEDS");
" ^& n( e4 p2 H* `+ f% ?7 u        else
$ s# o0 N+ p: V: X1 ^                printk(KERN_INFO "LED register sucessful!\n");% O+ i- F4 f2 l/ t% |: |

0 O1 x2 [2 t; w5 l' A        return ret;
/ H2 z% g* K) T$ j5 Y}
  U, h- M, `/ r
$ {, b7 N2 G7 V7 ~( G) V/ Ustatic void __exit led_platform_exit(void)
" m& D* }: Q. e7 c: Y2 ?+ X' v{
- p& m$ @3 t7 j  a- H4 y6 ^" ^        platform_device_unregister(&da850_evm_tl_leds_device);
& C0 T5 a; L1 q' f' {+ q; y$ V1 x2 j# U3 P
        printk(KERN_INFO "LED unregister!\n");  D% j8 ~9 n8 k5 S; U; `+ H
}
6 |4 b2 B' i/ T* z; C' B4 b" a- F5 u. c& @: u
module_init(led_platform_init);% E7 E$ x) r- U# g4 ?' W
module_exit(led_platform_exit);3 D2 q  d: k* x3 e9 H" N! g

. l7 O$ Y7 S$ i" F# C2 q7 bMODULE_DESCRIPTION("Led platform driver");
/ ^( T& e% y! R; Z& M  g  T/ xMODULE_AUTHOR("Tronlong");
0 I% f. ^& J' r9 g  S0 M' G4 Y+ }# OMODULE_LICENSE("GPL");
. ]1 P1 o% j# Y, O5 f
5 V2 c4 B+ W  N1 V7 x
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-1-27 12:15 , Processed in 0.048437 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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