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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。% p! I4 t6 ], j
#include <linux/init.h>- t% |! U, T( x$ d9 M) ~
#include <linux/module.h>$ N  V! }# r9 S+ G9 k' x
#include <linux/kernel.h>
1 S" V8 |) l8 f* l$ W6 [6 D#include <linux/types.h>8 h- u8 ^, M; d2 S( |" H
#include <linux/gpio.h>
/ m! {3 f9 L6 C' _  V7 E3 O#include <linux/leds.h>
5 K+ Y$ z( T. o#include <linux/platform_device.h>6 R, K0 J/ V1 J; y/ `

5 F$ W, U! q$ F6 B#include <asm/mach-types.h>* k% k4 B* Q0 i6 k& d
#include <asm/mach/arch.h>, X1 J- [# S9 h3 ?6 W
#include <mach/da8xx.h>
  V; e  O  {( ?7 ^#include <mach/mux.h>
3 L) |% Y$ }* n7 v8 N0 K
% U+ {- [) J- P& V6 O' ?" \#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)) B$ p% }  T* g  w, ^* V) G0 _) s
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)6 {# a0 T8 V& L
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
  d8 x3 F$ \/ Q' K#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
; X) w9 S% r* T) t9 j/ W9 S1 Z2 E. N& |  r2 O. s0 i8 |
/* assign the tl som board LED-GPIOs*/2 z9 y$ }2 V1 L6 o: z' @7 [
static const short da850_evm_tl_user_led_pins[] = {
2 k9 {' B( |% q4 B        /* These pins are definition at <mach/mux.h> file */5 u) K* k# A7 V. D+ Y0 R! G$ A
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
$ q% v% n0 L- o5 |: u        -17 t/ r7 m& a- t7 F6 q. f
};
+ Y0 g! O0 R, C2 y' S$ O) I$ o4 X5 B+ c6 a2 K
static struct gpio_led da850_evm_tl_leds[] = {
, ]8 ~9 ]! F& Z! w: l        {
: z- D$ I7 X/ m2 o- t& a, h; |9 P                .active_low = 0,
; W$ C6 K2 }) K: J                .gpio = DA850_USER_LED0,+ a/ V5 H6 L3 `
                .name = "user_led0",9 O/ n4 U. m* D& A  |4 t2 N( J
                .default_trigger = "default-on",; p- X( {; D" D) |# U/ I
        },, c: n3 i+ ]3 o+ ~" j
        {7 i$ B- p: |4 }
                .active_low = 0,
* r" W) [( J1 Y. ~# J+ s1 Y                .gpio = DA850_USER_LED1,
. e0 ?9 {) H% j  p7 b+ s- t                .name = "user_led1",/ K- l7 o3 S0 X  h+ q
                .default_trigger = "default-on",: s- \; i( N; d4 s' [2 n- d- g3 W
        },
, O7 E) ]  Y4 O3 v  w! `        {
: M% M7 ]  J$ s5 b                .active_low = 0,$ i$ `1 Z; n# m
                .gpio = DA850_USER_LED2,- O. K5 V, H) z
                .name = "user_led2",
9 T. K& A; y1 \                .default_trigger = "default-on",
" w$ K) e0 {/ n        },3 y, L, t- `; ^! B6 M0 {9 ~1 ~
        {" F: e+ s2 A6 K4 e9 w
                .active_low = 0,% r  ^% k1 }3 {+ [, h& o
                .gpio = DA850_USER_LED3,0 }8 |3 F% Z' p, N, D0 Q; C- c# `
                .name = "user_led3",
8 v) b; U8 g* K1 o( I, u                .default_trigger = "default-on",, c0 p1 P6 a. A' p4 }1 Y
        },
. l5 @0 o# v! u};
3 P" P# K1 D+ e
+ L1 @& Q! W& A# F$ L. Ustatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {' y  f' m( E7 K5 q  ]
        .leds = da850_evm_tl_leds,/ R& i& U- u3 o3 X
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
  z. w( Z; |  T0 _# e};
& Q# [$ w) U: T: Y/ |5 w" P6 s" Q- S5 B
static void led_dev_release(struct device *dev)
$ v$ Q, U" l. ^1 ^{! v8 ^, E3 N; w" U9 E  h" u& P
};
1 ?+ Y) \7 N2 R1 J* W  Z/ L4 n! l% L2 T( m/ C2 f" ]+ J0 u
static struct platform_device da850_evm_tl_leds_device = {4 S0 X2 [9 C7 \. m! ~
        .name                = "leds-gpio",
3 d1 ]) M7 ~2 r' p, j7 j        .id                = 1,0 A7 D* V% I- H6 p$ n
        .dev = {
# W, }2 b4 V2 M* o1 t, Q( q                .platform_data = &da850_evm_tl_leds_pdata,0 a+ b: E0 M. k. U3 K6 r9 u
                .release = led_dev_release,
' u6 p% h3 n" M" Q* m4 n+ E        }! }9 a9 ?: H, \. M; J
};
/ d% L' }# y3 Q4 m
! s- y6 B) x! }3 J5 Q4 y" {static int __init led_platform_init(void)
$ }6 ~, Z. B2 W6 t: q( U{% @* b; x% q5 D: h, ]
        int ret;9 G! X. c& ]/ c0 R( F. f, ]1 o- Z. m
#if 0
- E! ]! b4 ?" ?1 S& x        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);% }% _) `4 {" c* h: ?, d9 z1 ^& u
        if (ret)
5 g+ b1 C9 B* e( u' k7 A  m                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
* N! X; j2 ~7 k: j3 k: P/ A* j                                "%d\n", ret);% A7 {9 H- W; o- \
#endif
. R# Z! T( X5 h2 k4 B7 l7 W        ret = platform_device_register(&da850_evm_tl_leds_device);
2 `5 r: W" T% h" R9 C9 l- H: M0 v* b        if (ret)
3 ^$ U4 Y2 |' e2 y' C( l                pr_warning("Could not register som GPIO expander LEDS");
, H: f/ ]/ j" n$ w/ U2 q0 l1 z        else
$ ?4 P4 Z$ e0 V                printk(KERN_INFO "LED register sucessful!\n");. G/ W" n( ?( i' ^5 R
3 v' n' b$ L% K
        return ret;* \$ O8 |4 |' ?
}+ S. ^3 n% d0 Q9 J3 i
. Y2 d' o( J/ [1 Q& |5 c0 C
static void __exit led_platform_exit(void); m2 p. @  d/ h) l* q8 C. ^
{
, z- U2 F% k' N7 G0 {        platform_device_unregister(&da850_evm_tl_leds_device);$ B  h8 H" K: i& G1 X' X* K' ^

& o; G9 O% B& m' |# s: }        printk(KERN_INFO "LED unregister!\n");
* B0 W: y6 e, d}
$ ?+ K2 Q! H9 a; P+ a
3 s7 T3 d" x/ F& lmodule_init(led_platform_init);4 A- n# b/ S5 [) j
module_exit(led_platform_exit);
' C+ P+ \% V! V
2 \- h2 h; q6 n7 b3 nMODULE_DESCRIPTION("Led platform driver");) t1 G6 W- ^8 n
MODULE_AUTHOR("Tronlong");  Y6 N) t$ b4 J* F* C
MODULE_LICENSE("GPL");0 P6 a- G- U' Y. o* E/ M

  H6 U& x( J2 ^, O: q
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-1-24 07:37 , Processed in 0.040018 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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