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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。, S5 X' L% k* L" s
#include <linux/init.h>  D9 s% e; W. u6 S, ^. f: X
#include <linux/module.h>
1 P$ o' t3 B4 c, N- |7 S  Q#include <linux/kernel.h>
- L5 I) |" v5 K: U5 J9 I#include <linux/types.h>& [; @# w: C; _
#include <linux/gpio.h>  e- U+ W! @; K3 M: c7 `* S
#include <linux/leds.h>$ a6 Q9 Z& ]6 O4 P, C: K. d6 }
#include <linux/platform_device.h>- e% r6 l: O9 f& V6 h

( o" L6 w7 a3 a, `, |! h$ _. Z4 k#include <asm/mach-types.h>
3 ]- i/ a4 L* o; a; g# h#include <asm/mach/arch.h>
4 E6 d$ C( w% J- @: @#include <mach/da8xx.h>! I' `5 |1 Z, O4 M2 g
#include <mach/mux.h>
  {) f; t, q2 U: R, v% a$ X. t, p7 m. K0 A# z! O+ I; D
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)5 B- `* _1 R( G! `
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)2 L3 C# t5 G: j, `
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1): V4 U; P- M7 L& @0 |- q* ?" X) `" ?
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2), H2 @5 f3 A) i% P  Z

* X$ I) h0 u4 y) `6 J4 Z/* assign the tl som board LED-GPIOs*/. A' z" Y5 G( O. G8 Q
static const short da850_evm_tl_user_led_pins[] = {# o* c4 A. F% r* p1 y, T' n
        /* These pins are definition at <mach/mux.h> file */$ d5 E" Y; y5 M9 V3 b
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,8 ?; m, V: J: {) Z8 m
        -1/ ]: g6 R- @* H0 I& P
};! f  ^" Q) h, f( M8 O
/ B% w( s5 O& S/ F
static struct gpio_led da850_evm_tl_leds[] = {9 Y+ Z1 Q  N2 H
        {& k& k) P3 H4 U1 A' w
                .active_low = 0,
# V: j; q$ p& ]( q1 Z                .gpio = DA850_USER_LED0,
1 O  j* n. \5 o- }, u! ~; \                .name = "user_led0",' G' o9 ~! z3 t0 x
                .default_trigger = "default-on",# h  q! m. d$ I9 a( b8 \% `
        },
  [# z( A$ D! ?* j/ y        {  m8 h% ^3 y% i( u2 Q
                .active_low = 0,
0 _8 v( g- G" Y1 K; W5 c% T                .gpio = DA850_USER_LED1,: |5 @  z4 ]3 d3 S5 Z8 z
                .name = "user_led1",
5 i) D9 A. o; X/ ]  P4 F& |2 B3 W                .default_trigger = "default-on",
: _0 j9 e1 \) g4 j        },
: a' R8 g! e5 J  V2 _+ L& _        {
2 t: Y, ~+ D5 H% k  ~: K3 B                .active_low = 0,
/ J! }/ i. o/ ?9 R. N5 {! b                .gpio = DA850_USER_LED2," E3 T. d7 j, \9 D8 b1 r5 x% g
                .name = "user_led2",) b* \1 `* n2 }$ y/ y! H
                .default_trigger = "default-on",- x6 t+ W' M6 n4 d/ _
        },
6 R  r/ Y  `: H) U/ ?- y- [. q. @        {. H. S1 G% y. G' Q9 a
                .active_low = 0,
; c0 }' N9 {0 m3 d4 O                .gpio = DA850_USER_LED3,
5 }/ @3 Q  \" X# n7 s                .name = "user_led3",# ]( s& Z' U& u/ F
                .default_trigger = "default-on",' f; x& N4 l) W% Z1 X! z
        },7 G5 \2 [+ B5 P7 I5 w
};
0 p0 N2 z0 W0 o0 M1 }
) D, `% e- z4 P; hstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
7 R4 ?6 Z. ?! A1 i3 X' N0 W        .leds = da850_evm_tl_leds," z) O; z2 `7 Q# g3 O" f
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
+ \1 S  x* ?! o/ G. u};9 f" l/ n" F5 C3 U# y" k' h
% f6 R, m! e+ W6 O4 t& S! d
static void led_dev_release(struct device *dev)
  [  ]1 ?  I) B' v- `, Z{* n. r6 i" D/ w( ?) F9 q
};, |! O$ v+ q; Q) ]1 e
. F  n4 y1 X4 j8 Z) h  r% ?
static struct platform_device da850_evm_tl_leds_device = {
: P+ C* l: z9 ?8 J+ A        .name                = "leds-gpio",2 x1 n4 {5 d# R8 H
        .id                = 1,! A6 m+ b  w# L  l4 M$ o
        .dev = {
3 g9 O' U+ [' _8 N                .platform_data = &da850_evm_tl_leds_pdata,
* }. ?% g+ [1 J1 M% Z                .release = led_dev_release,7 h+ l. G! H$ x9 X& b2 z- I
        }2 F7 \' F  b4 ^  \& ]% Y2 w5 {
};1 W  B/ D- C& H* E

0 t. X6 o' i; Sstatic int __init led_platform_init(void)3 X: S2 P+ E4 Z- A6 X. Q
{
0 y" k% S7 v; d& ?. y- Z$ u/ Q        int ret;/ n) d" m% I/ _/ ]# s4 ^' r
#if 0
& u. ]$ J# r9 I5 G2 T2 }        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
5 ^1 h3 [8 L$ ~+ m& [- u        if (ret)
; ?7 D3 L: p' E( _+ a% |                pr_warning("da850_evm_tl_leds_init : User LED mux failed :". i4 W8 i7 \( p; P
                                "%d\n", ret);& r5 ]5 q6 R+ ~0 |3 u& n  p
#endif0 |" I5 Z% S. O* H$ ?- N; e
        ret = platform_device_register(&da850_evm_tl_leds_device);2 D! h/ p0 M! C6 Z, E( Y8 p  D& U
        if (ret)& V9 w& q* d2 L! P1 L) Z
                pr_warning("Could not register som GPIO expander LEDS");0 {0 k8 {3 O" Q) g/ G
        else
* v" X! ~8 e& W6 k4 H1 w+ v                printk(KERN_INFO "LED register sucessful!\n");
  G( T# g7 F& @& {1 n* c& W- U; f4 t7 ~8 K0 H! m6 Z6 \2 V
        return ret;  r  C  b* z/ G( }, r) k$ R0 H. }
}$ X$ u) L( S: e( s

& k' r9 t# X6 L  d; N9 p# K. y- Fstatic void __exit led_platform_exit(void)
8 A9 X% k1 D/ m. [  z8 W" w{
$ a* f2 D: R3 @        platform_device_unregister(&da850_evm_tl_leds_device);
- b1 e" q" G' B, G" z$ M; y9 w) {' z8 ]3 @
        printk(KERN_INFO "LED unregister!\n");
* g$ I- i9 S$ }  x}% A- L8 }' x/ h  m1 ?; O- ]

" V1 [* n) R- x) e. s. @9 a" Vmodule_init(led_platform_init);' t! Y  H% P( T) W' {( G2 N6 Q' H
module_exit(led_platform_exit);
4 h+ N/ ]$ m( }! o) P" X0 ?! \9 n' _1 y: N
MODULE_DESCRIPTION("Led platform driver");
3 d0 K. V# U% lMODULE_AUTHOR("Tronlong");
6 |) \; _+ V0 X8 c$ dMODULE_LICENSE("GPL");
5 o& J# \/ Y' v6 ]" |! l
) N* p7 W% Y3 k% [% V! A
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-10-1 07:11 , Processed in 0.044361 second(s), 27 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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