程序注解 - OMAP-L138 - 嵌入式开发者社区 - 51ele.net
设为首页收藏本站

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。! z. X& n* j% |
#include <linux/init.h>
4 m. n& O1 B* E' V! N0 [* E5 |#include <linux/module.h>4 K* Q& Q- a" k6 Z; D. W6 a  [
#include <linux/kernel.h>
+ R( \: s! \4 P9 }. M  H* m#include <linux/types.h>. Q' a& z3 A  X- V
#include <linux/gpio.h>
" w- T( ^$ y' w, b9 d- D  T* x#include <linux/leds.h>0 W# c9 K2 @2 F4 x1 T% X6 `$ H
#include <linux/platform_device.h>& @( v5 J: X+ d' [) m
' V+ F& P7 D9 _* R2 [
#include <asm/mach-types.h>
& n  I1 j9 b$ L7 H0 ?8 n" c( f#include <asm/mach/arch.h>
1 e0 |5 O/ a* \, v% k#include <mach/da8xx.h>
- z8 P0 l7 S( f/ O9 G#include <mach/mux.h>" t6 h$ ?5 x1 _, h+ h# @

* y5 K  f5 T  s1 d& n  Y' M#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
8 p7 T% s7 g1 r6 E& h7 ?#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)2 H, Q0 s; _" R6 M/ |5 s
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
5 p9 v6 o0 n% y! G' v" @#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)' N# H* O7 F8 S) K

- P& A# r* l) s) E! d/* assign the tl som board LED-GPIOs*// I7 F. h& h2 N4 K$ C8 p
static const short da850_evm_tl_user_led_pins[] = {
! ?4 n; n3 ~8 ^$ R4 @% L7 s' ?        /* These pins are definition at <mach/mux.h> file */- z( y; R4 Z# R- @  M4 _
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
- m! T8 O) {0 i1 I7 \& ]0 o. k7 m8 E        -1
. @7 r" y: q. ?( D/ C" K" [* H! ]};0 q6 E/ x- u6 w9 m' {

4 l9 n# ?4 V# Q: {; r% X5 x# I6 c( X7 mstatic struct gpio_led da850_evm_tl_leds[] = {/ \0 V( H( \% ]
        {
' J4 u# |! Q6 W9 z, _% F. z# ]- U                .active_low = 0,4 e3 K2 _# O" D3 c
                .gpio = DA850_USER_LED0,
- X1 \4 h  T0 o2 n9 F; u# ]6 ]                .name = "user_led0",+ a9 J! M" s, [) a8 ?7 {1 h
                .default_trigger = "default-on",8 O. @5 r" r- Q5 @/ e
        },: P2 @$ T! q4 Y9 q7 j
        {& ?6 a& K" l6 [; l8 s) Z
                .active_low = 0,) p3 |+ B+ L: s5 @9 M. z3 f
                .gpio = DA850_USER_LED1,
( w* U3 ^& L* g5 `8 d, @: N                .name = "user_led1",
6 s- P4 F1 Q" o! a) N1 a                .default_trigger = "default-on",
3 A' q1 ?9 l6 C& i5 N        },1 I% Z, ]3 ?4 q1 m. I9 ~4 w- b; m
        {
8 c4 K. Y) m! g2 {+ Z                .active_low = 0,1 k, l; U* l6 i  L7 T$ g, {
                .gpio = DA850_USER_LED2,
* ?+ a8 H; y/ |0 d                .name = "user_led2",
! B2 v7 r: M( J) p                .default_trigger = "default-on",
* K4 `/ Z9 @3 r0 E        },9 ~- U5 B5 \1 o# H8 w$ t
        {
0 D7 Y8 M' G2 N7 Z2 f; q                .active_low = 0,% V# `. c. K! q
                .gpio = DA850_USER_LED3,0 H/ P. j8 m& r3 f, m, o  p) J
                .name = "user_led3",
6 N% }$ s1 q, \5 G( F- S" r                .default_trigger = "default-on",! q- g, f! K1 Z
        },
, P+ s; _  ~6 [6 E7 K& Y; u% w+ y};
+ W- n1 W' e/ C8 k4 h3 e8 t% V% f' a  U3 b3 g% z, R( D! j
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {" |6 Q6 I' |  Q# Z6 Z
        .leds = da850_evm_tl_leds,/ h5 N# t3 R2 H  c8 x  L
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),2 K) M! Z% u2 ~, F# W, u
};
( b1 {. A/ l# A( y! i9 r+ b# g  M$ ^( T7 M
static void led_dev_release(struct device *dev)
& Y$ N0 }- D& l* \) s# g{( Z- P1 p; M! q& e1 ~! j
};
2 p* }5 c" ^& e3 M1 n& N2 a( P) s, I& D  `. i0 V5 ^
static struct platform_device da850_evm_tl_leds_device = {5 T+ M5 S- o4 _5 {/ z3 H2 \
        .name                = "leds-gpio",/ S  W" ]1 B; E' ?' b; K/ L7 X
        .id                = 1,- B, M/ K0 A! L, ?# k' ]
        .dev = {( h5 x" s& S) J  R' l8 t
                .platform_data = &da850_evm_tl_leds_pdata,2 P9 A1 X/ F+ V- w: q9 V. l3 |. R
                .release = led_dev_release,
4 p, e. Z) q1 A        }( y- T3 G6 p: h) f/ p# [$ m
};
9 t% R2 P/ T4 G& p' p( s) H/ J( J* i0 n/ r6 I# J- b' g
static int __init led_platform_init(void)
, [" ~. _# s+ Q. K{/ T5 G8 t3 g* q9 D- r8 @: a3 W
        int ret;
  o% t" q" p. u6 O2 }) ?6 Y* y' a/ k4 H#if 0
2 i0 x4 y9 x$ z        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);. [2 i0 S) p5 L: F
        if (ret)7 U7 C% [) K) k
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :", ?8 N, G" Q1 g, J3 S
                                "%d\n", ret);
; _- i. @/ v# |0 j#endif
7 q# U' l# ~2 N" e% M0 D+ f        ret = platform_device_register(&da850_evm_tl_leds_device);8 G8 M# h. H6 ^
        if (ret)1 S. {/ g7 Y" n6 {: Z3 a
                pr_warning("Could not register som GPIO expander LEDS");& s9 l  B+ l! q8 f/ J1 a- v; u
        else0 f2 z  O7 X2 i: l
                printk(KERN_INFO "LED register sucessful!\n");
1 i" u# o+ S- P. Y: U& o  w! h! K  i$ f* P
        return ret;
6 ?, D* c: N" s& v* C* M, e* g. \}
5 O4 }' T8 ~2 j  P- m% w$ {6 v) N" z9 i3 E  r
static void __exit led_platform_exit(void)
. E4 J2 J" @0 y{
4 \% K1 g5 ]& x% Q9 x3 T" B% \" S        platform_device_unregister(&da850_evm_tl_leds_device);1 N; h; A  S1 L/ ]7 K/ {

6 V: h7 @0 ?2 G7 J8 V1 r8 K        printk(KERN_INFO "LED unregister!\n");
+ W& X9 h2 W5 G$ V: E8 V}
% T3 A: ]. h: }; U# b# s/ b1 |, X) L# C( D2 ]- I9 @$ F
module_init(led_platform_init);) ^" C8 z5 d$ |+ [8 Q, `% B
module_exit(led_platform_exit);" k5 l' C) d3 X
( Z) u# Y+ E6 \# d/ q
MODULE_DESCRIPTION("Led platform driver");
0 }3 l' t& B8 p" hMODULE_AUTHOR("Tronlong");
6 c, A) }1 [  s8 HMODULE_LICENSE("GPL");# c4 T" n  S* t7 L% P3 h
8 S; u4 c0 A" r' T
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则


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

GMT+8, 2026-1-11 05:06 , Processed in 0.045186 second(s), 28 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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