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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。! @+ L5 Q; i: }% H
#include <linux/init.h>
  ~4 C! V5 o+ ~/ H+ N. ^: y& [  W#include <linux/module.h>
& L  e# m3 p% {#include <linux/kernel.h>! ?+ T0 V$ {; f" W/ ]/ c; K7 H
#include <linux/types.h>
- I" f2 r5 Y9 [% e0 u' i7 {4 A#include <linux/gpio.h>9 K" t4 N& E, [9 Y: G$ i1 o: w; }' ^
#include <linux/leds.h>' @$ X* n& I3 X8 j; _
#include <linux/platform_device.h>
( m% M5 m+ G* E; }- Q0 Z0 j/ z4 Y9 g+ O
#include <asm/mach-types.h>" Q* x4 J& Y6 i) q
#include <asm/mach/arch.h>
6 ~- ]" ?! e% y9 ^, _$ x' _#include <mach/da8xx.h>: H5 O' C9 r# |/ N$ @) @
#include <mach/mux.h>
0 ^) b, g) Z( l( \
# L. f+ M, X/ i% V* C; n! s#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)* ^/ G2 a3 K$ H: Z0 m
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
  o& ^- L- j- j2 ]! t/ g#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
6 F. W: T) V) z9 e1 d#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)# `( E+ P% ?1 z1 D5 ^1 p
" V! A" v; p, k  q7 j' U, m
/* assign the tl som board LED-GPIOs*/% U+ q& W  {' I4 ?0 n
static const short da850_evm_tl_user_led_pins[] = {1 Y, n8 g% `/ C8 [
        /* These pins are definition at <mach/mux.h> file */6 u# K, T: h3 V1 e3 E) {
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
  w: Q/ {* \- `* Z& x        -1; i6 t4 x0 m) }$ Y8 d7 _
};1 c0 R4 u/ V9 E/ B$ H$ g: p, g; K

! v5 N& o0 X" Astatic struct gpio_led da850_evm_tl_leds[] = {
$ |# x% Y1 y9 g9 N, o# J! t/ I4 U        {2 f' h2 q- l$ Z3 \$ [% R( D0 j( N
                .active_low = 0,
+ w3 _3 {- X+ ]6 M1 G/ u                .gpio = DA850_USER_LED0,
% X4 ]; x3 H/ H' R1 m) m                .name = "user_led0",- H) R8 k0 V) J
                .default_trigger = "default-on",3 r; O6 r/ s  n- L  R& m4 D
        },
, U' A! z. m+ |        {
5 j2 h. m) L7 j9 W                .active_low = 0," f! w9 ^: w$ O1 D, ~
                .gpio = DA850_USER_LED1,
2 K% w- r; f3 k' F/ j' ]                .name = "user_led1",
) |% s; r8 u# K: S* b                .default_trigger = "default-on",3 \5 Z, m& A4 Z( `" @
        },& X' g- \6 `  I' @
        {  M) H/ N4 I" Y8 ?
                .active_low = 0,/ o% g) _  h, `9 ?
                .gpio = DA850_USER_LED2,
6 Y. D8 S) y, }2 i5 h! ]                .name = "user_led2",# C; `, [" b0 ^; y* Z% \& D" a6 N
                .default_trigger = "default-on",
4 Q" g) f) H! S0 b" e! h3 D4 E! _  M        },$ Z; B$ k+ G! @% t7 n2 O3 K2 A
        {2 P- W8 b8 ?! k. K( ]( _
                .active_low = 0,
8 f* k+ A  L; u) z1 T                .gpio = DA850_USER_LED3,/ N5 k1 F5 x+ j. H# }
                .name = "user_led3",
* z* U$ ]$ f( x0 [- r1 ?                .default_trigger = "default-on",& h; O) G+ e5 h- U  X% A
        },
, l" g; j; U( C, l};
7 h4 H7 @/ X/ G. a* h
8 x# C# L& \' o: k8 t* q% @static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
; M% Y, B6 b; a7 |. i+ B        .leds = da850_evm_tl_leds,
9 A3 [$ a9 z( G  G  C: S        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),1 ^+ g! A$ n3 t% n
};8 S$ ]; \. N  w$ P! `' k9 C
3 R- W$ s- b" m. b* {7 U
static void led_dev_release(struct device *dev)
3 R! V4 ?- t7 I6 |: Q{" {  W) b- \' \2 w- L
};
0 u; w( R/ e( b( e, Z: J% f, p4 z4 o" l% `' x4 x1 j1 }3 a2 ^3 \, B& Z4 ~
static struct platform_device da850_evm_tl_leds_device = {$ n7 p' S3 G6 S! X9 V; B1 I2 k& l
        .name                = "leds-gpio",
) f$ f0 @. J4 ]0 k7 F        .id                = 1,
  P1 B6 p2 V0 {3 q" J% O' B$ Z4 |8 H        .dev = {
7 f' _9 }4 p7 u* g7 M                .platform_data = &da850_evm_tl_leds_pdata,
2 [) ]4 q4 `: J2 e                .release = led_dev_release,
  {/ I: ]/ @9 L( H6 C! |2 x0 E/ o        }5 X* L- e5 w; i, W  o
};
. [/ |( q- \5 |" t3 J
0 G. O' V+ j6 O* v9 `% istatic int __init led_platform_init(void)2 }6 U; q1 d* U; K& U+ B! d
{2 s6 }) B6 ]: ^. p. s# P  T- c% x
        int ret;
/ t' s3 [; ~( h3 I- Y2 m) {#if 0
' ]& R- y( o: K; ?2 D        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
' o( b. I2 @" p. M" i. b        if (ret)
- ]" v" k+ {( A) Q1 P, C$ |                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
/ C5 G( B, F- E  j* P/ z. i                                "%d\n", ret);
& v8 D/ F% ~# H, B8 e#endif
5 a% l6 Y+ |: p        ret = platform_device_register(&da850_evm_tl_leds_device);# d; G( ?5 _2 k
        if (ret)
- ]. H7 o) G! v& Z: }# }) g9 S                pr_warning("Could not register som GPIO expander LEDS");
  p3 _9 z2 ]: z, s9 |! g        else, t' J! C5 b) Z5 f- s) b9 K
                printk(KERN_INFO "LED register sucessful!\n");
/ ]3 N3 c$ `- z' K( c- m- {1 P3 o5 j& ^$ i7 \3 O- u; q/ L
        return ret;6 A0 l4 U, \( i4 Q8 _5 ^9 s( [
}( O, e: R7 V: e' e# e: B

; r+ ~7 z3 \( o. Jstatic void __exit led_platform_exit(void)
$ x' g1 Z. d- Z* B* W* V{/ t3 t& l7 Q! s, Y# |: H9 c. j
        platform_device_unregister(&da850_evm_tl_leds_device);
# ?/ g- v" `' r2 H
( o' I/ Y) w  @; b* S: L        printk(KERN_INFO "LED unregister!\n");1 i4 k9 ^5 n% L2 A# ^
}4 V2 r8 p. a/ R2 y9 f- G

( o7 M  O! Z+ t" omodule_init(led_platform_init);
( n. @/ S# h  V- ^& C4 D1 Dmodule_exit(led_platform_exit);
2 ?3 v& P# M- Z
4 C2 h) g" M: Y+ K4 O" ]1 eMODULE_DESCRIPTION("Led platform driver");1 I- w. e" i+ F! \
MODULE_AUTHOR("Tronlong");: t' I' N) K2 O  O1 A! ^$ q
MODULE_LICENSE("GPL");6 f! i! E- {- p6 o* T( _& K
' K, R% ?; M$ F. J' M
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-4-1 09:39 , Processed in 0.044802 second(s), 27 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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