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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
* h! A( x- M4 |7 j+ |#include <linux/init.h>
. X: f- B5 }3 g; f#include <linux/module.h>* S8 W' P! i  l  e+ Q: U: p
#include <linux/kernel.h>
0 C% ?  D: M5 {3 i! e0 K, Q#include <linux/types.h>- Q9 l) H% Z) [0 s
#include <linux/gpio.h>1 ]* k* V* ?1 B  Y. v7 Y& z, p
#include <linux/leds.h>
5 u2 C( Z% P6 ]7 U% S8 M0 G#include <linux/platform_device.h>! H" U3 {" }' K
: z* m( s1 P* g9 O3 H: r
#include <asm/mach-types.h>- S4 Z; _( ]9 ~
#include <asm/mach/arch.h>
: u2 x! t0 E% M8 \% [5 }5 a#include <mach/da8xx.h>
1 w% u, }. i. Q. s#include <mach/mux.h>
( p% Z8 g. f/ m$ f
, D1 o  r5 _. s' @5 S#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)% ?: V  @5 m$ l' C% Z; J/ X# h
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)( z8 s4 J% f# F$ Y) E# h0 v
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
* A0 _& }5 |- t" e- k- g* @" t#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)# o' `6 ]5 G1 M( ^

! q  r6 k' ^$ _( |8 ]1 \/* assign the tl som board LED-GPIOs*/
! c8 g: d- ?0 }4 H* Rstatic const short da850_evm_tl_user_led_pins[] = {
9 r( }$ j1 ~  Y* a5 `        /* These pins are definition at <mach/mux.h> file */
% D1 `! O% w5 L0 M8 p: u) d        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,9 U6 ~$ |; N+ B5 q( T3 o
        -1# H/ l* X6 Q2 n! G& R
};7 Y4 h  R* g, Q) |

& J: Q% |* D$ h& m) I9 rstatic struct gpio_led da850_evm_tl_leds[] = {
" U5 A1 l5 P) f9 y" x        {, v- o% p# K% ~# ~0 T3 }
                .active_low = 0,# R; e! A7 x: Q+ a' C+ X" b: M
                .gpio = DA850_USER_LED0,8 d2 w; P9 @5 o. ^2 U
                .name = "user_led0",
( R$ t" k/ z$ c9 W$ M                .default_trigger = "default-on",! j: G# b3 L; W& X. d8 u4 |$ {
        },
" o) x' e+ H: [& h1 R        {( @  t9 ^9 b: N
                .active_low = 0,9 C9 k$ j0 u/ |1 Z+ R
                .gpio = DA850_USER_LED1,
% K+ U$ u( w5 H% p8 k                .name = "user_led1",
! s. Y) i3 g7 X& _8 j' Q( i2 G2 ?                .default_trigger = "default-on",
. e" Z* o7 h$ S) Q  s+ T. R* V! y" r        },
7 {4 b4 D8 d" q1 }        {
4 ~; a# M% ?4 V6 q  P                .active_low = 0,
! U0 a5 D3 q' }                .gpio = DA850_USER_LED2,
6 _% I; h/ O7 m, i6 I                .name = "user_led2",
7 O$ W0 A! I! V8 }                .default_trigger = "default-on",  [- U! g. H0 k) n/ U8 j2 }6 y9 @* R
        },
6 N! V# R: w6 J4 s" g; x        {
" k) R3 F2 |1 h9 ~* `7 b                .active_low = 0,5 z1 n) W8 R0 l( D9 E' W
                .gpio = DA850_USER_LED3,
( e; k3 C+ i! O9 n. T# {7 I                .name = "user_led3",
  O9 N4 ?- h, @9 P# d' ^* m! V                .default_trigger = "default-on",
& i/ M! T' F% t% d# y        },
, o& _9 U1 ]3 R, \+ x4 J+ H};
. a: t' |8 I! T1 g* y4 c/ }
2 {0 H8 F7 M+ l* V7 C6 i; L  p* estatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
4 P: u) [/ P8 S& u7 @$ A) ?        .leds = da850_evm_tl_leds,
; M! s7 S/ c2 d7 r: ~7 t        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
4 x* j! S( m# {$ D$ f# t4 @# k- r};
% \1 r. Q- z% h; e$ y/ @4 R
+ U* Z2 g/ ]* |# f: E! \0 M8 xstatic void led_dev_release(struct device *dev)* {$ R- C# A# q) ~! V  M) R
{+ T: C) `( H. p; z! \6 r% F
};) Z8 s, d( R3 P2 B3 u1 l5 o
7 w) q1 p$ U6 L6 G
static struct platform_device da850_evm_tl_leds_device = {
2 p( Y, a" @1 ?1 s0 N$ u" Z. U0 y        .name                = "leds-gpio",+ w) |: d# E  P! [: j
        .id                = 1,
! `+ ~2 J# E- g6 [        .dev = {
3 ~$ Q# }. K  @% m9 w1 Z$ k% [# k1 q                .platform_data = &da850_evm_tl_leds_pdata,6 H+ s; S  D# ^3 s9 [0 ^
                .release = led_dev_release,
2 x! o: P- {* w5 B9 c4 ~/ c        }
7 d4 c* }" q2 q7 ?3 \# E8 _# i: c};+ J# I5 \4 M" L# M
# i& _" t! |, {( \
static int __init led_platform_init(void)  k5 M/ H+ x6 ^$ q/ l+ V8 ~' J
{
3 i) K: I6 T7 k  g! c        int ret;- o: R/ e- t$ _, H8 h  o
#if 0
# L4 H5 S; b, N& v% W5 B' l        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);& S  J. ^% e& [) C
        if (ret)  q& H% n+ M" e  D8 a' G4 R" n
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"! u2 L2 ]) Q3 _3 I+ V# n
                                "%d\n", ret);
& }% E0 e& ^2 }. X1 u5 }0 s$ v#endif3 F9 E  P6 g, K' w+ U: K" Z+ t
        ret = platform_device_register(&da850_evm_tl_leds_device);0 m$ v2 l7 _; o% y- X) x. d, O
        if (ret)0 n' N2 U& l* F/ A+ f
                pr_warning("Could not register som GPIO expander LEDS");
, E) k2 s$ _/ @% k3 H( g  [# ^        else0 i' y7 y5 ^- n: G# r
                printk(KERN_INFO "LED register sucessful!\n");
8 w& I" w2 n( r  t, C: O& m$ b
  h* b7 U- Y8 s$ |1 Z$ L  F        return ret;
( a' N* _6 Y/ R' G: f$ {  e}
' I. J$ x1 U4 T, w; B: K6 r% o- x$ F& K+ D
static void __exit led_platform_exit(void)
$ Q! D4 b* n+ g) K9 i{1 X  e2 P; ]5 n" X  H
        platform_device_unregister(&da850_evm_tl_leds_device);
) M; I0 P7 a" C. q4 @& {" N/ ~8 f) s* U
        printk(KERN_INFO "LED unregister!\n");2 V4 k# S3 ~: K
}( a( f- T: g" N6 L* \

- f0 Q! f) D5 i2 J9 N) ?module_init(led_platform_init);
" g5 b) Z% a& lmodule_exit(led_platform_exit);# E7 o6 }3 j* \  \: N7 K

+ s* B' J7 k& {' bMODULE_DESCRIPTION("Led platform driver");
4 C; [. B1 ~: l( l3 @MODULE_AUTHOR("Tronlong");
; w7 |% F0 q/ k; i6 eMODULE_LICENSE("GPL");
6 s9 Y6 Z3 d. |# P9 T! m
2 J! \% s/ y0 h  @$ p3 z
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-3-29 08:46 , Processed in 0.042342 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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