程序注解 - OMAP-L138 - 嵌入式开发者社区 - 51ele.net
设为首页收藏本站

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。/ ]: J9 A0 H8 ~8 @8 k* @
#include <linux/init.h>
0 P" Z6 @+ r0 w#include <linux/module.h>
& f9 E2 r- S+ i5 J1 D. @#include <linux/kernel.h>* J; W! n* W' M9 Z; R
#include <linux/types.h>
$ f! K5 t9 M; `" z#include <linux/gpio.h>
" }5 T, r( p: q0 T6 g& _9 V$ y3 \#include <linux/leds.h>
( h" L$ U* E! X0 @/ b. _#include <linux/platform_device.h>
) B8 a7 P/ a" ?2 |3 w) [
8 f% b! h; Y  l  J#include <asm/mach-types.h>
% z) i7 Y# ~7 r5 y/ ~8 l#include <asm/mach/arch.h># r- K/ V$ a0 v* z: y4 @
#include <mach/da8xx.h>
  e, d4 I' m/ \#include <mach/mux.h>$ }+ [" H: C2 I* _

: C4 {2 W& y! o) A5 M* ~#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
4 j. H, l  c, E4 ~/ h#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)/ }! [7 P# S& i* c: e2 S9 R
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
, ]8 ?2 i: d3 E  d1 n#define DA850_USER_LED3        GPIO_TO_PIN(0, 2), y1 X3 `* g& d5 o$ _
0 e, Y/ {" l/ R& t/ C$ T; D
/* assign the tl som board LED-GPIOs*/+ S: ^* {  b0 s1 F
static const short da850_evm_tl_user_led_pins[] = {
5 }! q: E  z9 H+ u        /* These pins are definition at <mach/mux.h> file */
2 ~  p+ Y0 T% p% O2 H% f( h7 M, u        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,5 ?- I6 J% D8 t4 u
        -14 b8 F0 Y3 I, ]5 _
};
/ X% f9 O/ R- u- \6 Z! u( ^$ v; h0 J: g" V* {4 Z
static struct gpio_led da850_evm_tl_leds[] = {
6 a+ p, n+ `. X0 N( n% `        {
3 s8 J6 J. D8 I2 }6 V                .active_low = 0,
+ g6 i8 }# Q$ w0 g4 J                .gpio = DA850_USER_LED0,' S; z0 O' E; N% o) p1 W% H
                .name = "user_led0",5 A: t; q% d% i- I! b0 U
                .default_trigger = "default-on",, m+ s6 C5 _1 l: L! h; M/ U
        },: p4 J6 R+ S, p4 @9 X! ^( Q8 ?) |
        {6 ^4 h3 z) V) ?, o0 R$ ]6 k
                .active_low = 0,7 ~. K+ Z7 X( x( [2 O* @2 C2 K
                .gpio = DA850_USER_LED1,
6 E( e* D% H. P                .name = "user_led1",
5 c( G/ d) ?+ P, U  C0 i                .default_trigger = "default-on",' ?1 x$ X; a6 m" U
        },
9 t$ [6 L* @5 ~. a/ F- ]; j        {
% B6 a8 Q3 s0 v0 m0 `& m                .active_low = 0,
, E! Z$ A7 X9 U                .gpio = DA850_USER_LED2,9 H4 H2 q$ D6 i5 f2 D$ S
                .name = "user_led2",- ]$ Z# ^" L0 o+ l! W) @
                .default_trigger = "default-on",
$ u* Z5 }$ e: w0 D3 v5 J5 M        },
# K$ G3 c/ u: l. [; c; }: B" o        {2 L7 x4 O) i! O# q9 t9 `1 g
                .active_low = 0,3 D$ ]& T5 i8 F: C+ m1 J
                .gpio = DA850_USER_LED3,
+ l* X9 c2 p+ D9 N; `5 [                .name = "user_led3",
8 _. j5 P7 {& J" p+ q7 W5 N                .default_trigger = "default-on",$ W3 ?8 h5 i3 Z/ d; K7 M5 R
        },
: E7 P6 z  e. H) Q) K$ H( X};8 L+ I' M, M3 P  J7 m* ~
. d' n# Z4 J; s! Y5 Y0 w' J
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
1 I/ S& B7 F# `+ C        .leds = da850_evm_tl_leds,: A' W& `' W; f- l
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
; S# u! Z3 q6 u  F4 ?' }};  q, D! G; i: u1 c, L' s0 O, s
1 y0 Q! S! B& Y# h  J4 E
static void led_dev_release(struct device *dev)
. C+ a( W$ k8 ~) H* o1 I{
: I) r* e  Y2 W};
3 q! j1 s, Q0 ]+ _1 z  V& t0 ^3 ~+ n# J% C6 f+ [: r
static struct platform_device da850_evm_tl_leds_device = {/ `+ o8 z% _1 h+ M5 ?+ |
        .name                = "leds-gpio",
. X( v' y1 X: r8 E" S0 t        .id                = 1,- n  \8 h" K5 }. d( o/ f
        .dev = {
( J: ]- F( z9 o. f- Y- g                .platform_data = &da850_evm_tl_leds_pdata,
+ h, q6 L9 U+ T: h                .release = led_dev_release,# P) I% @0 c9 @5 m5 @6 E/ H* w
        }) _- @0 t9 {' G9 P1 |6 S
};
8 J; L/ P$ x* A% X3 S, |4 A3 {: M8 b" {
static int __init led_platform_init(void)
. R; F% k; v5 |  ^: X3 J{
; y- b% l$ p8 Y# @  U/ A        int ret;
8 Z- H3 d6 `' J+ D; P1 U8 l: o2 H# Y#if 0
- E. `+ i- h* ^; S& W        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);2 x+ r8 o* T4 a
        if (ret)6 m+ l9 w, s4 a2 S0 R$ c
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
" @/ n6 i4 C# \- |5 c, }                                "%d\n", ret);
7 i) n9 H, J( t6 ~- O3 [; m#endif
' T4 S9 P$ E: T( C0 Z        ret = platform_device_register(&da850_evm_tl_leds_device);7 L/ B( d! m5 c& O
        if (ret)  X& Q1 Y1 E" W$ y
                pr_warning("Could not register som GPIO expander LEDS");
& X* W6 q/ {4 f        else
% G) u# A* U% S2 W9 A6 c* v, ?                printk(KERN_INFO "LED register sucessful!\n");
0 k5 W1 ~3 u- K  A9 C
  T, E1 y0 X# m5 n& F: E  A& }        return ret;; V& \, x. u$ E4 Y+ m
}" t7 H; a9 I1 `/ }1 ~5 A

9 s  ]& [7 |6 M( }8 g% {static void __exit led_platform_exit(void)% L, b0 ~- r( \, i# q/ F) u
{
; s9 o7 A5 A+ Y1 N; k( b        platform_device_unregister(&da850_evm_tl_leds_device);
$ ?! f( I7 ^' F! W2 i" r
, H, v0 j- l  |# b0 u! X3 G% h        printk(KERN_INFO "LED unregister!\n");
( k$ P5 X* ~7 H& l( J( N2 k0 g}2 F, `4 u. A" L
! ^# S' K, A6 _% Z
module_init(led_platform_init);( S6 B( T; p/ f) w
module_exit(led_platform_exit);6 ?! j, b- q( S" V' J
+ p' a  |' X6 \( i
MODULE_DESCRIPTION("Led platform driver");
7 u2 o5 C8 t* tMODULE_AUTHOR("Tronlong");+ O% Q0 @4 P/ M: w
MODULE_LICENSE("GPL");/ H6 P; S  ~+ b  q
2 u! m: h$ W0 ~  e4 o
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-2 18:50 , Processed in 0.038066 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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