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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。: t1 G! P' K1 U" _8 F# h
#include <linux/init.h>6 W! J0 i. N* k/ w" @# W
#include <linux/module.h>
, d5 J4 d2 N* L3 p* o/ L#include <linux/kernel.h>$ \/ t* e! b0 V! q" b/ l" p
#include <linux/types.h>1 B7 _8 e# b1 I8 `2 k
#include <linux/gpio.h>6 k6 a: l) A: v
#include <linux/leds.h>. h# U" s4 n; J& H
#include <linux/platform_device.h>
( s. H8 P( l* p2 w7 R. D7 U
) b3 G% s9 v$ N' w#include <asm/mach-types.h>
' p  H" L* r! U; \6 P' r0 `#include <asm/mach/arch.h>" Y( f- W$ R2 ]  F! w+ S& B, Q
#include <mach/da8xx.h>4 f: E- y! A  L( f) |% t
#include <mach/mux.h>
" Y* Y' S2 D6 C3 L9 U6 e# K5 g8 R) x5 f5 Q/ H1 i2 ]
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)8 X* H/ O4 ?% l0 g4 v
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5); u2 a$ E4 @) R, k+ u7 D4 i
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
3 ]. ]& M: v8 v# p+ V, G#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)$ U3 F$ ^( L! p) G  E, Y% H
. s- T) d, m8 ]: r5 ^/ b7 x. }6 W! n5 `
/* assign the tl som board LED-GPIOs*/: }/ ^% `% p% g* z8 b5 N' l2 d: G6 M
static const short da850_evm_tl_user_led_pins[] = {
7 O0 x1 w( X0 f0 S- f9 v& u! ]        /* These pins are definition at <mach/mux.h> file */" @1 P+ u; `) d7 T% _
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,# ^* V4 C7 u, F8 x# P
        -1
8 F+ W6 N& |& N% ~9 E% v" m, ~};' W- Y* E2 H% @

( Z+ ^: Y- Y4 F- ?static struct gpio_led da850_evm_tl_leds[] = {, i$ b# Y" o3 `$ Y5 U' A3 y
        {& g" v, n( p9 Y' ]/ P, H7 i
                .active_low = 0,: I; F+ ~& D; O" Y5 w6 J
                .gpio = DA850_USER_LED0,
, L" ^, a! C' D3 A( }                .name = "user_led0",( p4 K* [. B+ [1 U6 n( v
                .default_trigger = "default-on",8 @6 h4 \2 h0 J9 _
        },
( P5 n. u/ P# U        {" l& Q) H5 r% o. V* J; y
                .active_low = 0,
' F" g5 F, W0 L) [/ g& k                .gpio = DA850_USER_LED1,
. T+ p7 a# a! B! V! |' t6 c  T                .name = "user_led1",) ^% ^6 t3 ?# [) I
                .default_trigger = "default-on",4 Q. S% O3 e: _% P+ E
        },
9 q. f0 d0 H) p9 @8 B% `        {
' `; Y1 k, J0 [) T% A- z                .active_low = 0,
8 ]  L" W$ W4 Y; l6 r) N                .gpio = DA850_USER_LED2,
4 s! C) B% C) |2 u7 O5 h3 h                .name = "user_led2",
& o- N+ _% \3 |6 Z% @0 d                .default_trigger = "default-on",
# P* T" s' @, j        },
: a; T" m7 c" E) q# ~+ @        {
1 m; Z# [# P3 o* K/ Q4 |8 Y                .active_low = 0,! g& U3 a5 J* V. N# x+ Q: F* H8 M3 A8 }
                .gpio = DA850_USER_LED3,
( f1 u, M! z$ _! r                .name = "user_led3",
5 o$ G3 \# L' v. C5 X                .default_trigger = "default-on",0 r: W7 e% ?& ^" |( F' x. N, X0 C
        },# {2 R% d5 n! Q9 ]8 H6 _' Y) `. |
};% y, k/ T; ^7 g4 ~$ f2 w

/ F1 h* b1 t% G8 _1 K. v8 H6 y9 jstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {$ Q: V3 Y4 D5 n% F* O4 K
        .leds = da850_evm_tl_leds,) }. E9 U/ T% F2 f
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),' M0 M# t/ j& \5 ^
};
0 {0 e" w- u# c
) ^- r3 b. j, ~  M0 X% A* e+ B  Ustatic void led_dev_release(struct device *dev). t; g5 d! o& K4 L8 `7 M' a2 s
{
- g- P; r6 e. K# B3 p};
  j$ o% g* G: r
, }/ r; ^* i3 [4 {3 u. K! Z" }static struct platform_device da850_evm_tl_leds_device = {
0 M& S: w4 R0 Y3 W4 g( {4 p        .name                = "leds-gpio",* ]$ y" `! n, _$ K. e3 `
        .id                = 1,. w* K4 A6 F1 w: c' y
        .dev = {
0 K2 Y) X8 |. i) h                .platform_data = &da850_evm_tl_leds_pdata,
9 W9 s- C' {/ n; j                .release = led_dev_release,
) @6 t4 o( _* _0 U        }4 i* l: h$ g* X$ q! V/ w* ~
};8 v/ n/ Z6 v# p2 z0 B2 I

  B" ~) ^3 m7 v# l& z" k" p4 L# Rstatic int __init led_platform_init(void)7 [0 X* l4 U3 b
{
, q! G6 f+ f: K) W) s0 u. u/ Y        int ret;
8 }+ X: h0 k3 ]5 ?0 a( {#if 07 ~0 d4 H) d# m9 |6 l
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
+ i& W4 x* z: z% n9 Y. m; H        if (ret)
2 |. F6 q2 N. |; W0 [                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"3 H7 {. S+ i2 s2 W. Y, K
                                "%d\n", ret);5 Q4 s8 k1 a( }- x' W3 P: s9 n
#endif+ H; v! \* {; o  a; N
        ret = platform_device_register(&da850_evm_tl_leds_device);
0 p8 t, l' Q: e        if (ret)
9 O3 J/ [' X# c  O, S                pr_warning("Could not register som GPIO expander LEDS");
' f& \9 Y- `6 a' G3 n$ K( c; t) w* ]        else
8 a7 J( r) c( R) p8 a                printk(KERN_INFO "LED register sucessful!\n");
! T* W' e, Z" |( Z5 w; f0 a1 M; n% n0 {2 G0 z
        return ret;# L8 A* R( M/ s" j9 w- E
}
7 q5 N" p) {& U+ {- N# W+ k% s+ C1 N* B  U* @8 s$ ~
static void __exit led_platform_exit(void)' ^  c! j. ]5 E* n
{
  z2 W; E, |% ~1 U2 E" P        platform_device_unregister(&da850_evm_tl_leds_device);% a. s, a! J' u9 W

5 F' Z1 T! d! L        printk(KERN_INFO "LED unregister!\n");
- q* o8 M$ u" ?4 l) P}" _& |# ?: e+ x9 d  r

# e3 x' o. F: l- }& k. i9 K! t4 Omodule_init(led_platform_init);
2 K$ ~7 B: K$ f, W- X9 r3 Gmodule_exit(led_platform_exit);
2 i  _9 W8 i8 t2 ], N! g( J: z# Y/ |5 [5 Q
MODULE_DESCRIPTION("Led platform driver");
: m: J! {$ W/ e8 o; h6 I1 w" dMODULE_AUTHOR("Tronlong");- n0 E" H4 ]2 S7 N' L
MODULE_LICENSE("GPL");& N  f2 s" w5 F8 ^8 ~  m
  a! ^/ w7 C: B9 C* s7 R
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-4-4 12:39 , Processed in 0.039557 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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