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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。7 D8 X- I+ f# g- M! v
#include <linux/init.h>& f+ ?5 d# a, u4 i! t
#include <linux/module.h>3 B2 n2 _: `- {  @9 S* B
#include <linux/kernel.h>
: O: k, P# b4 H( U0 ?: I#include <linux/types.h>
2 E, L' \& T% B. _- e#include <linux/gpio.h>: m$ O! a1 t0 U! f& P" [2 D' d6 J0 w
#include <linux/leds.h>
- k% P. E/ s5 R: i. b#include <linux/platform_device.h>- s1 Y' |) U- N, H2 v
2 d4 |6 u# z& Y
#include <asm/mach-types.h>
3 [6 W9 [5 B$ J! i/ n#include <asm/mach/arch.h>
/ k1 A& {) s4 ?8 j' c! _#include <mach/da8xx.h>- m3 K) G8 p$ {/ q
#include <mach/mux.h>
! H0 u8 e- F+ n4 l, Q( [" t/ a
: L9 n1 g  h# p0 F7 T#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
) c: |% X$ V# r- E) n0 {#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)# t4 u( J! a7 L6 q1 g+ w3 {
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
0 z6 P8 ?; E1 w! ^" j#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)$ m# a" X1 g3 a  s. g2 P; a- Y: e- i

8 m- r$ L! |6 X/* assign the tl som board LED-GPIOs*/+ Y! I4 @/ a$ b( S+ m6 R! H2 {, B
static const short da850_evm_tl_user_led_pins[] = {) ?% H5 X# S0 z. ]! C! N
        /* These pins are definition at <mach/mux.h> file */& [0 @5 ~3 n) @7 S) Z/ @/ b  Q
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,; P/ B* s' n, h/ u' y3 B5 g4 {
        -1
* i4 P  n( ~' X1 Q};
2 M/ o, \3 N. p' n7 l
4 C) [2 E5 ]- \( n5 ~0 J! Estatic struct gpio_led da850_evm_tl_leds[] = {
6 D6 e/ G' h: s6 W) _        {5 I) h5 [- }& j* b) Z: l4 H
                .active_low = 0,
4 ?( I" L9 U& M' y9 E                .gpio = DA850_USER_LED0,
* ~. d' K7 b9 i: ?* b7 S! r                .name = "user_led0",# |3 _1 H. q9 V# G! ^8 [$ m- v/ M
                .default_trigger = "default-on",
  g9 e, i7 `* I9 Q  b        },
! U1 j; z2 \$ e% F        {  l3 C$ V- T" b( l* g6 j9 b" n2 v9 i. N
                .active_low = 0,
+ o+ m+ ~' R: _# g% y                .gpio = DA850_USER_LED1," ~( Z& ^& c& a+ b& J. `! [! S
                .name = "user_led1",, ]" g' o3 l8 k0 w3 L: F
                .default_trigger = "default-on",: t- @! I; |  i& f8 G
        },
. x$ G* D: ?2 t2 f$ P3 A9 ^# }  t        {/ m$ E+ y" j4 g
                .active_low = 0,4 z+ q) o+ |: h4 r5 l, W
                .gpio = DA850_USER_LED2,3 h# N: c  B7 E0 B6 T
                .name = "user_led2",7 r- k4 }6 p& n$ U
                .default_trigger = "default-on",; I! j. A) j8 w! N
        },
  `, |$ R  H- u7 W. e5 t5 P: q        {
" b  L- i9 p3 M. V2 t, O6 X                .active_low = 0,
4 U$ w) f# q/ g+ T+ u3 c                .gpio = DA850_USER_LED3,
3 V1 y& {4 b/ r$ @( N4 u3 I                .name = "user_led3",3 a3 V2 [, P9 h/ ^* t0 Q
                .default_trigger = "default-on",
& |# e, M, D' T/ i2 u) I- R; e; f        },
: P$ C: j9 z7 R- E) t' @" R};
9 Y* H0 {6 l3 X) I2 ?% r
: y- l$ I3 R& s5 Q8 A/ Gstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
- o: M1 o- y$ P$ K        .leds = da850_evm_tl_leds,% }9 n9 C6 Y+ {
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),* ]- r- E. G8 @
};/ s1 P- H3 q* m% I

% n+ e0 W  h; c  Cstatic void led_dev_release(struct device *dev)
6 o' I4 v0 w1 g% G7 w4 n+ j{
4 ?* e$ a* I/ q};
* Y( C. d1 i. u, C# k. v! i. x6 _* S
static struct platform_device da850_evm_tl_leds_device = {
( t, B1 X  n2 h3 N) m+ v9 q- u, T, J        .name                = "leds-gpio",
' w  j5 T. N7 M0 F# A0 S+ W7 Q        .id                = 1,: t& N2 S' t; U
        .dev = {! e0 J' T  @' Q# Y: y. r
                .platform_data = &da850_evm_tl_leds_pdata,/ _6 M. ?2 P  Z9 a
                .release = led_dev_release,
7 l1 w4 X" a* r& g) D        }% A, C+ B) q  I, s0 J( o( Z( \/ Q
};
2 r2 A# B  Z( W+ ~( ?5 z% e( y' M. _9 I/ P: `. k; @/ [
static int __init led_platform_init(void)6 O2 J+ u: N/ L' N
{0 i# S  k! G/ m: g9 A- \, O
        int ret;* H( q# w8 U& C" g8 s. b
#if 05 E9 y- w3 G) V* {
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);- R7 {) M8 T# r3 I- U! V! j( d
        if (ret)
5 _* l6 h* Y3 \. g5 ?. E                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"/ V) C+ P! M; n- S
                                "%d\n", ret);( t8 r$ r, r4 d2 ^# k: ^
#endif
: [5 X, V3 u7 _$ c7 E        ret = platform_device_register(&da850_evm_tl_leds_device);' R* s9 E4 c) U
        if (ret)
8 g( Y$ }% A9 |8 d" R. m6 s  _5 e                pr_warning("Could not register som GPIO expander LEDS");
4 B0 v: C' I+ n$ e0 {        else, j: o( ^) p, i; \  T
                printk(KERN_INFO "LED register sucessful!\n");- o  G4 A3 v  w/ L+ Y1 o
2 \  @: B/ h' ^1 R$ T9 R
        return ret;; o4 d0 c8 H4 Q- a0 ?& L; q6 t, C
}5 k* N& J8 _8 A4 s$ ]

3 `: U& E0 Y2 y6 mstatic void __exit led_platform_exit(void)2 S# O2 Z. _& j& C5 ?2 U
{; C. y4 O6 k; t0 @( K
        platform_device_unregister(&da850_evm_tl_leds_device);
1 Z5 W$ K  a5 R; b$ m8 l. Y7 l& J0 _# S8 u% Y
        printk(KERN_INFO "LED unregister!\n");- T2 Q. K. F. r6 b
}5 d$ V  j& p$ L8 s

2 M1 H6 v' h; ]* Pmodule_init(led_platform_init);* e( Y9 f. U$ r# H' a
module_exit(led_platform_exit);
; B2 [9 A' Q* t* @% l3 x( M6 D
MODULE_DESCRIPTION("Led platform driver");
% s; ~+ r) x1 R) oMODULE_AUTHOR("Tronlong");" A: O# M2 D) X' s  M
MODULE_LICENSE("GPL");
8 X& U6 R  P  l( J: P; {5 ?2 y9 K3 O) p' g; h
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-1-30 05:19 , Processed in 0.039444 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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