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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
5 n! t. E# _# [/ M0 v9 W; e1 z#include <linux/init.h>/ y8 S7 W5 c' Y& t" l$ K  {
#include <linux/module.h>* e0 N3 f+ G! P, o$ i4 {
#include <linux/kernel.h>" }7 z. G' x: M
#include <linux/types.h>
4 k, X' M5 s- I  h/ K- g% Q5 D#include <linux/gpio.h>
( t* T8 k  \) x5 _; V#include <linux/leds.h>
8 E- g! d( q6 W#include <linux/platform_device.h>5 ^; k* R' i) w1 S  J! {" o
, j! R( }2 M2 D9 W) W% V
#include <asm/mach-types.h>; f2 K) i9 c) B8 c5 _, [) Z
#include <asm/mach/arch.h>
* d2 ^. S+ j; Y* S" p( `#include <mach/da8xx.h>4 v8 i9 R0 Z/ Y* Z# z. T
#include <mach/mux.h>
; ^6 Y, S- Y4 c- O; w
5 S/ L9 q7 F' z) O- h; \#define DA850_USER_LED0        GPIO_TO_PIN(0, 0); I: @3 F+ ^4 R5 `, s- I  _
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
8 o! X4 q* ?/ G, n0 }$ v#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)/ B, N3 B2 y7 \4 V
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)) i9 b+ l6 X; [6 B

1 `, U1 X3 j( B  \& r! A, c3 r6 T/* assign the tl som board LED-GPIOs*/( N  L: G+ y6 Z! v# a0 u7 }% O
static const short da850_evm_tl_user_led_pins[] = {
4 Y6 d6 r, Z* Q0 H; e! E0 j        /* These pins are definition at <mach/mux.h> file */
9 E4 E; G; ^/ }4 v9 s& q" h        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
6 y" ^  `" r+ q0 O        -1
( K0 [$ E- i2 G) l4 k; ~0 R};
+ @3 X/ i( Z5 c. A: _6 {  ^: s1 j( W5 n1 |4 ]: i7 N
static struct gpio_led da850_evm_tl_leds[] = {3 C. D, F' N) h% C5 B! B
        {6 z) p  ~6 S' b4 k
                .active_low = 0,' }) U! Z0 V1 {+ x
                .gpio = DA850_USER_LED0,
2 X* w% G* [6 t                .name = "user_led0",/ Q( \% `, L" U( p, M( _
                .default_trigger = "default-on",0 w. X1 ]2 }; v
        },
) \+ }! |/ L. `        {& {9 \5 |2 _! y2 T/ Z" w
                .active_low = 0,0 f, A# ~* ~* b  `# ^! r
                .gpio = DA850_USER_LED1,9 o& z$ k7 I: K
                .name = "user_led1",. h/ a2 T8 p+ Z$ I7 I1 C4 J
                .default_trigger = "default-on"," q4 v% g- Q5 r$ ^, W7 M* z
        },5 v& d# U8 `; I4 ?5 o  e9 n
        {
8 y* H7 O) {8 A# y* h                .active_low = 0,
* K) I5 f- N0 x                .gpio = DA850_USER_LED2,
" c( ?" I, U$ k$ F( _" p: m. i                .name = "user_led2",: D6 P2 @' `) g: p5 `# S/ _2 ?% O
                .default_trigger = "default-on",! n6 U  E2 y# k% [! j7 l: ~
        },
$ s4 B1 e. U5 X: P2 G: l        {. H- q  F5 s  o/ e2 k& `
                .active_low = 0,8 ]/ E6 D1 |2 b" r% p" U
                .gpio = DA850_USER_LED3,* X5 q3 A2 M' Y3 ^# ]) V
                .name = "user_led3",
& f7 ^9 D# }/ `' X' T$ X                .default_trigger = "default-on",) l$ k: t+ A8 Q& w5 V2 z
        },
* e$ |& f. Y+ _( [# i};
  `. s3 B4 |3 Q( a1 a& ~
7 Q/ T2 ~  k' Z+ D6 K- ostatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {0 R  e/ ]3 Q4 d- }0 G  y' L+ A
        .leds = da850_evm_tl_leds,
: w6 o9 \( k2 X2 @, C" Z( w# ^        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
; c3 k. n+ A7 L- x};
; @+ H- U. C; E9 Y& i" O% P* }3 U6 n& ~6 C1 }4 ]
static void led_dev_release(struct device *dev)
) g. K% H( m/ c' _{
4 @, d/ W5 w/ q, P( B};  P* F4 k4 Z0 [" ?5 }0 k

5 r8 M, {2 @$ [$ H6 Hstatic struct platform_device da850_evm_tl_leds_device = {
" ?3 l1 H; x" y. `3 L' n        .name                = "leds-gpio",' w/ Q5 V! Y, u( H- S- y
        .id                = 1,
/ t3 E& o" J9 ]; l3 Q: P( u' Q        .dev = {
8 L% O1 u1 B7 {/ ~- V8 ^                .platform_data = &da850_evm_tl_leds_pdata,8 A# T& D. l, N( l  b& @: F' E
                .release = led_dev_release,8 \' I+ p1 z( c# Q7 Z) P
        }
3 O% H" `7 g+ m! Y+ f6 F};4 U% U3 X) ?' ]( o# d2 ]

- F# B* |% l9 z: n5 z/ i0 l: Q9 \static int __init led_platform_init(void)
5 e; c0 a/ X. m( ?$ X& \8 K{
: u' r/ _; H" }: s8 Z        int ret;( P2 z* _1 ?7 F9 a
#if 06 w5 G$ c3 s; J1 ~" G+ v0 y
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);# A, o3 H2 L1 J3 W" r+ T) c
        if (ret)
  y% |9 {. G9 e& _* m5 r2 z                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
7 q$ J) q7 u8 d" f% O8 S                                "%d\n", ret);
+ b5 y( d4 C) S! I+ N#endif
! r8 M3 r( T# U8 A5 Y0 _1 u" d6 d        ret = platform_device_register(&da850_evm_tl_leds_device);; U- l9 K! i) B2 u, h6 z
        if (ret)
. @6 T. n4 W  p0 \" \% F1 q                pr_warning("Could not register som GPIO expander LEDS");4 l& S, q* y) b9 t3 d+ q2 O$ q! R
        else8 b" q4 ?" }0 E# k# T0 d, k
                printk(KERN_INFO "LED register sucessful!\n");
: E2 }8 ]: Q1 I7 J" h7 i/ h
( [& b1 }: [6 y0 _! q$ A        return ret;
7 h1 D7 J* V) k" i8 ?5 q}
1 ^9 e% X9 Q. J3 P' u& s; q) |, V. O
$ I( Y# p+ B" F, Estatic void __exit led_platform_exit(void)& U# O: N( }* C% h. L
{: E7 Y6 F4 z/ \! Z$ B
        platform_device_unregister(&da850_evm_tl_leds_device);1 y- l9 \+ I+ D' O
- M( o$ O* h+ m1 f. B7 x+ ]2 H! H
        printk(KERN_INFO "LED unregister!\n");- B" V2 W! `: z% q/ G3 \) i3 o
}
9 G( g) T. @6 H9 R0 C$ Q: |4 e# I5 {& S  u+ r
module_init(led_platform_init);% k4 w+ E3 _3 I, E
module_exit(led_platform_exit);) }4 O% U; T$ U
4 v/ Y) n- c7 a
MODULE_DESCRIPTION("Led platform driver");; w, Q5 D- a4 v0 I; Y1 j# u5 _
MODULE_AUTHOR("Tronlong");! G& ^6 L, X4 U* D/ O) i' M/ Q" J
MODULE_LICENSE("GPL");
1 @) o$ m& S% D/ k! H% a# D7 [: t4 r3 k, ?
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-1-24 20:13 , Processed in 0.045387 second(s), 28 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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