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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。! r5 I8 c, h, k. {6 P8 y; D9 G
#include <linux/init.h>
: J, _# T) D, A5 e- ?: a# r$ [6 ], w6 ^#include <linux/module.h>
  F3 e7 W( _& C  b$ v#include <linux/kernel.h>- T4 J) i+ o8 j+ |
#include <linux/types.h>+ S) J) n$ ~- d3 k( _
#include <linux/gpio.h>
. K3 `- s& |0 i0 a6 s8 [/ L; z#include <linux/leds.h>
0 W: H) F  c( Q# Q) J' Z1 ], Y; f#include <linux/platform_device.h>+ X  P: X5 S* e! U+ {, @- ]' a
5 g; m$ b% ?2 \
#include <asm/mach-types.h>
& R& v  @/ m4 U: N# g) M#include <asm/mach/arch.h>9 L+ a$ t) `% \2 T, Q% q
#include <mach/da8xx.h>
- @- s2 |7 P4 Q4 o, D#include <mach/mux.h>
) N5 j/ C9 k  l" l: ~! A  P+ i* F& O/ a
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)- Z8 Z  |) M6 @9 d" g1 |9 ]: W
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5). R7 X, n2 y) S7 q% h# M# Q
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
( s1 `- g# p5 t* b* A: o# j) ?$ i#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)  S- {* k" v% [3 C8 v

8 D9 q9 H+ I( r. a; N, c0 l/* assign the tl som board LED-GPIOs*/
" f, U+ f* g' Tstatic const short da850_evm_tl_user_led_pins[] = {
; z7 g* L" J: K, ^        /* These pins are definition at <mach/mux.h> file */
& y0 T% ]2 F3 g7 z        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
- [$ X1 Q8 C. q2 {        -15 _# q- `5 V) K; t: c
};' Z  ~" O9 d% k# h! v) }
+ ?! X" \3 W8 I
static struct gpio_led da850_evm_tl_leds[] = {
" D! ^0 K5 u6 {        {4 k; g- ~' \0 ]1 r5 h, G
                .active_low = 0,
% t$ R- ~+ Y  h  U4 m) S% T                .gpio = DA850_USER_LED0,
: v3 H9 o+ R8 Q, x& @$ E                .name = "user_led0",
% d& D( i- A- r- {7 W4 u& h7 U                .default_trigger = "default-on",0 W: _' b. i9 X& z8 f: y1 S
        },3 v" p" N5 R& L+ q& h
        {
  b& o' [  b* V7 {/ I# Z' c1 f                .active_low = 0,# c# o# V! c4 U2 ^0 Q
                .gpio = DA850_USER_LED1,
& J/ Z+ q6 K# _% E/ h; s% u" r8 Z. [3 ?                .name = "user_led1",6 y% i5 A3 ^4 W! S
                .default_trigger = "default-on",
/ i; ?8 t$ `8 z" Y        },  T. L. ~9 u9 b9 U* Z! A( L$ P( P
        {; f8 p6 \. s+ u8 `  t, S4 U: o& D
                .active_low = 0,
  _0 G% y9 X; o6 I  j( j                .gpio = DA850_USER_LED2," A% N% L. j, J6 c
                .name = "user_led2",% ^) m( r* W4 h3 C( o
                .default_trigger = "default-on",
; O. X) [6 d& O# s: ^& U3 w, @        },+ F, _! J9 s' F
        {
+ y# O& x0 G& \9 y                .active_low = 0,- O+ G, a- `$ z. b& u* |& b
                .gpio = DA850_USER_LED3,
6 ?; y2 _" ]# |9 ?" P/ N. p/ q7 {                .name = "user_led3",
' q& [0 U# @' Y                .default_trigger = "default-on",; |, X6 c0 h* X( V9 R( _; a) B* [
        },6 t+ N* R7 s) D' o: w
};
9 }, w/ c* f1 h5 i& [& u; Z& [7 D+ l9 i% D/ C9 v9 q6 x
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {# G+ p. f$ e6 |* R
        .leds = da850_evm_tl_leds,- Y6 M+ L+ o3 @4 x5 r2 E
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
* f2 k2 _; M2 k" u* K5 t+ W5 s};
2 ~3 L' \% k& O! |1 E, x6 A2 [# J1 W& O- F* v* S0 Q( l' U- h
static void led_dev_release(struct device *dev)5 z0 i0 f0 `! I  w
{
9 y) }  D, o9 _};
7 g% b" x2 q' w4 e; n4 k7 J5 b! K5 K4 y" A0 h, l6 l  ^. s
static struct platform_device da850_evm_tl_leds_device = {
9 K* a7 t/ O" m% r6 e) s5 X        .name                = "leds-gpio",
: A& o# ~9 F4 A5 ]        .id                = 1,* h/ M2 R4 Z3 u( l9 T8 e
        .dev = {6 B3 S9 w7 K9 k  ]
                .platform_data = &da850_evm_tl_leds_pdata,
, z1 P) i+ N$ h5 Y2 k                .release = led_dev_release," F6 d  i! |/ }; b3 v( d# u
        }
1 Z, C  A- N) k! X};
# r" ]3 R, S( R& ^! Y
( p3 @1 ~, g5 F& v- istatic int __init led_platform_init(void)$ y2 a6 n% v% f( F5 k1 Y
{  |- d( O3 k* [1 ]( h
        int ret;
) S7 r- c# Y7 e" T, X# M#if 03 y% b; _4 F9 r! [2 w
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);8 v  n7 e( s/ z5 Z4 o
        if (ret)
3 A. ?7 V7 p+ d                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"- w* H2 w  l/ y# x- h9 K
                                "%d\n", ret);
; u# r' f( ^2 G6 }7 g5 Y% _- X#endif
1 U( l( R* _# t6 x( A, O4 y0 A        ret = platform_device_register(&da850_evm_tl_leds_device);
9 E3 _* X. B. P9 u2 Z4 J% d2 y3 r- V        if (ret)
) b  E" K: @$ ~) P# w+ D                pr_warning("Could not register som GPIO expander LEDS");2 b) d; ]- E* G& ~- @5 d6 ^
        else
$ h+ f& K: x) z" l$ a* ~4 C                printk(KERN_INFO "LED register sucessful!\n");
/ H; X* M( s9 {; o) ]; p$ z' ^, }0 e3 E: S( }4 r6 F
        return ret;2 g) q6 K' c0 b) A; W9 _# ?3 h
}* Q% ~2 F0 o8 t. R) Z; x# I2 h

/ b+ j; L. r& J/ d' }static void __exit led_platform_exit(void)
4 L$ j' Y2 P; |8 ]{$ S6 s+ F' S6 F( t! h7 B! ?( g
        platform_device_unregister(&da850_evm_tl_leds_device);1 H( z" A0 d7 X! Y
" G0 p. h2 U9 s% _: G5 r9 ?/ _( }! d
        printk(KERN_INFO "LED unregister!\n");* S6 m) G; Z+ i3 g
}
$ X, N! m7 F( }  k) ?! ?, B2 a" h; I3 e- _
module_init(led_platform_init);+ O* g. }5 H2 a) M8 t2 d
module_exit(led_platform_exit);: s* O- c* E5 O. y/ ?7 Y# U
0 ~: X! H: _/ S  r- C# {
MODULE_DESCRIPTION("Led platform driver");
0 F  K% ^, n/ a4 ^% R9 f. z/ cMODULE_AUTHOR("Tronlong");
5 k7 I+ v7 T: o* a- t; V" z# WMODULE_LICENSE("GPL");
$ ], V1 X+ a: l* @+ [  `' n! I& e& W6 i/ d
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-4-7 23:54 , Processed in 0.040192 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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