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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
: k( E5 Q5 z& V9 d9 \0 }9 }4 G1 h#include <linux/init.h>6 `' C9 o2 w  y, e% ^
#include <linux/module.h>, n: k" [) |9 b9 k* {
#include <linux/kernel.h>4 w2 \0 c8 q/ P; `0 w  t
#include <linux/types.h>
' b2 N8 \% q: n- c* T, x1 _#include <linux/gpio.h>: G9 s, e# T$ ?" {
#include <linux/leds.h>
# O" C9 V) H) O5 E' c1 P4 R#include <linux/platform_device.h>
! C2 ~: |* r- r: C1 @( x* ^- g) Q8 `5 s
#include <asm/mach-types.h>1 Z4 v: I6 r' z8 P3 h' w  J' q  L( ?
#include <asm/mach/arch.h>9 b7 v' F8 y; I% [" R* R' G
#include <mach/da8xx.h>
. A! H6 ~+ h3 Y8 }" l#include <mach/mux.h>% L% d8 Z: U) K5 ^
# r# Q; m' p9 J' Q3 W
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)' L2 i' ~2 r& q5 e
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
& X* @9 v9 e( @$ R2 ^3 f#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
! l0 m. Q3 ~" q7 C' J4 d( _#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
5 S6 n$ U: }4 f9 g: h5 h" |. n' k2 U4 ?2 A0 A" f; S# {5 F5 o- E
/* assign the tl som board LED-GPIOs*/
3 G6 U" m. f+ s: X& i& H; p: f  \static const short da850_evm_tl_user_led_pins[] = {
4 ?4 @" \+ V5 Y        /* These pins are definition at <mach/mux.h> file */
: U9 g0 H3 v) {9 G0 Q        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,$ q0 ?6 v3 N) n) x! O; i- m
        -15 o2 _6 b# N. u5 y! d! W" F/ P
};
9 ]( h4 t* C4 m: p" p1 S# v" J1 E; {  _
static struct gpio_led da850_evm_tl_leds[] = {  L4 U4 D3 H6 S2 h: p. S/ D
        {3 H+ b0 f* b( ~! m2 e
                .active_low = 0,
# x2 z8 `$ n9 X                .gpio = DA850_USER_LED0,
& P; V) V% k# [. h: {0 @                .name = "user_led0",2 G2 R: }8 U) P' M# b
                .default_trigger = "default-on",
5 a, `9 u1 L& {) u        },
0 V" X7 y; Q# O; M        {1 H6 o, c! }) [2 @+ V) E
                .active_low = 0,
4 M4 I/ ^0 z& `, p8 N% L! r$ I                .gpio = DA850_USER_LED1,: \& p0 T+ [5 q! f: h! q& {
                .name = "user_led1",- m* S0 g9 V+ U7 A) [5 t+ Y
                .default_trigger = "default-on",5 }: e7 n+ p4 s
        },
4 Q: j9 T* c9 r2 \, c* h        {
( S4 L% B. x4 r5 r0 w                .active_low = 0,* p* R% C9 @* `
                .gpio = DA850_USER_LED2,
) p7 ?* A# \- S- b                .name = "user_led2",% ], `- x  \9 F; X3 h' g; @- I
                .default_trigger = "default-on",
" z* ]6 d# \; U$ S2 Y; o' n( g        },
% ]; ~! g; ], J( t! r        {% h2 m+ y8 e& J$ ]: m/ r; q9 z
                .active_low = 0,- ?9 ^1 n0 @* G
                .gpio = DA850_USER_LED3,+ q6 J% p0 p  ?( h" @! d2 l
                .name = "user_led3",$ S; Z) w% j! x- v# R/ @
                .default_trigger = "default-on",) U+ I: ?8 j+ ~0 _; m
        },
" e- G# }8 y$ F" M9 S( c};
8 b5 H  q; g' D7 K' P2 [% W7 |! K% O: P0 N
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
/ e( M7 o( ^) x        .leds = da850_evm_tl_leds,
' ?/ X5 Q: Z, r: `; D8 L        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
8 G' K0 {( i' O$ |' p8 v};. o6 {! e+ g3 x) m& @1 r
6 [+ K9 K2 H8 D( w0 ^8 K
static void led_dev_release(struct device *dev); d3 x: ^5 L$ b' J+ I2 Q+ v
{1 s8 w, U! j0 z5 M
};8 b+ @7 j% ]  J$ N4 R7 D. C
8 b  B7 ^" I, z+ _
static struct platform_device da850_evm_tl_leds_device = {: f# r( f% {! r4 O
        .name                = "leds-gpio",- |4 e2 t: }9 g" x, z: x# K9 N8 P
        .id                = 1,9 }# p5 C1 R7 m+ G
        .dev = {& L% l& w; u3 T7 Z. N+ y
                .platform_data = &da850_evm_tl_leds_pdata,
* {* i4 E; m6 X5 F# @' a8 ]1 y  l                .release = led_dev_release,, L3 L5 w" C) H4 w3 I; v( z/ _
        }, H' Y8 b' t- X
};% |9 Z4 k, W. M2 s9 u

5 g- h+ Q" t  x* f8 S( `static int __init led_platform_init(void)
  N) r$ r/ E9 ~& W" y# d{
. i' E* C' \! x, w0 o8 W) A        int ret;; d: x; c) _- l" E$ ]
#if 0
7 \$ n" G0 o. _# u! b        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
# [7 w% z9 f5 C2 u* [; A% k" `        if (ret)5 }7 q; a5 ~1 T  _4 n
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
6 B! r3 f2 {5 k$ H                                "%d\n", ret);8 J( f, ^2 ~' H
#endif. ], V+ V% K' Y  T
        ret = platform_device_register(&da850_evm_tl_leds_device);; d) p6 j7 s/ k3 q9 E# l% P6 V
        if (ret)
& W! k: e# x4 U) d9 E                pr_warning("Could not register som GPIO expander LEDS");( T: u2 q. K# g
        else
& g9 h; r1 O3 h* V; c& x+ z                printk(KERN_INFO "LED register sucessful!\n");, E7 b0 a- Z# @6 i% E0 V3 R& w/ e8 @

! E# {; p1 ^. w2 \6 Y4 q        return ret;5 P. P, ~; K4 j( X  K7 K  L' p
}
+ \9 k  d  X. [) ^
( S4 I9 X8 {, I) o9 ustatic void __exit led_platform_exit(void)& X+ x( o( I9 d
{
6 |' ]$ L- u  {5 ]        platform_device_unregister(&da850_evm_tl_leds_device);3 o4 v+ y6 O! B- T
5 _- z! I. V0 |$ H* l& b
        printk(KERN_INFO "LED unregister!\n");9 E9 \6 Y( |' P4 P4 r, s) I
}2 U; b* B( u: a3 D- V
/ u# f7 K! Y0 D7 Q2 O
module_init(led_platform_init);
4 u, J) m0 F" a4 ~4 d" }9 [module_exit(led_platform_exit);' f, |! p$ G/ A3 S" q
8 y5 v5 ], ~& L: ~  \) P
MODULE_DESCRIPTION("Led platform driver");
; c# ^# q& m4 k$ w) Z+ ~) J, p" XMODULE_AUTHOR("Tronlong");
5 j4 ~6 W- I- BMODULE_LICENSE("GPL");
9 r* i5 I: a2 X
+ \7 g, q& R8 U" d
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-1-27 16:50 , Processed in 0.042336 second(s), 28 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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