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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
; i' y) g# }. N+ M6 @#include <linux/init.h>$ ^& f0 `0 S% s$ W5 Q
#include <linux/module.h>
: B: R0 b8 j6 v: y#include <linux/kernel.h>/ _& h8 z& S4 _9 }! I4 r1 X+ N
#include <linux/types.h>+ ]+ l( C3 b3 n, d; U' b; Z
#include <linux/gpio.h>
0 X  [1 M& ~; Z#include <linux/leds.h>
/ }9 L( A& m% k+ A. i#include <linux/platform_device.h>
& X3 i; U+ D9 L: O4 s* \( _- W8 e/ S. [/ w9 L
#include <asm/mach-types.h>
* R8 J- z/ ]1 I6 g#include <asm/mach/arch.h>& }8 ?  _- _0 \# ~& [2 u  z$ k
#include <mach/da8xx.h>( f5 |) L: y% k9 |/ e
#include <mach/mux.h>8 I: l8 \3 E  ]" ]0 P8 v

& y6 |* B7 m5 I1 H% [" z6 T#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)" y4 M  g9 C$ ]7 w* J& g: f
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
) F- y. T) b' C2 P. r, V#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
- S8 B2 y1 K  q- l- h/ D) A; j#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)/ g7 @' ^6 i; D( o; ^

8 t2 ?  j, h% i- D7 J/* assign the tl som board LED-GPIOs*/
9 [- i- W# r+ p9 |; k& Tstatic const short da850_evm_tl_user_led_pins[] = {
- ^# j8 v& P* n3 L& A+ P& }        /* These pins are definition at <mach/mux.h> file */; q" o4 s; Q. S/ S/ c/ h
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,2 c% o* T) p! k! F( W+ c3 C% T
        -1
2 s9 C" A  @; @};" T% H- q$ t1 Z0 S8 b1 P0 e

$ M' }! P4 Z5 U/ _static struct gpio_led da850_evm_tl_leds[] = {
8 C1 ]3 j0 `+ ~. B7 a& Q: p        {7 S. i% M3 [, p4 G0 u/ [
                .active_low = 0,
  A: c% D' ?/ r# w) V, d/ B4 K                .gpio = DA850_USER_LED0,! {. c+ w1 W* K1 n$ O" I
                .name = "user_led0",
) B  v( h: |6 x3 {% m7 m1 V7 F                .default_trigger = "default-on",  @! N4 d  M: f8 d# N( C
        }," v7 D$ g8 x- ?4 ?) N
        {
2 u  i0 r6 @* _3 Q                .active_low = 0,4 f' C8 L4 `8 a! r  \( X
                .gpio = DA850_USER_LED1,
* W% C7 E4 Q' K: K6 S7 f                .name = "user_led1",* `* P) I4 e; o% K$ U4 w% X/ A! v2 t
                .default_trigger = "default-on",3 a* [* t; K7 {/ T; O/ \0 c
        },
; W' g5 E/ H+ l3 u        {
2 M; c# m3 n- R  f9 ^                .active_low = 0,& h% x. O& r* D5 x% ?0 ~8 S! V
                .gpio = DA850_USER_LED2,; Y+ u1 a- Y$ T2 Q8 G2 a1 b
                .name = "user_led2",9 Q* F# _- Y+ h+ Y& A8 j3 o
                .default_trigger = "default-on",7 H, @9 Z# X  I5 ]
        },
! Z4 a7 {( Y( Z1 u8 F; O        {
3 c% d8 E- q! k+ [. g% g                .active_low = 0,: @1 O% `  M- W  d; @+ D2 i( A
                .gpio = DA850_USER_LED3,
8 T8 o( Z) `" K$ d7 ^                .name = "user_led3",
$ N1 O0 n; `- u$ Y# \                .default_trigger = "default-on",9 }3 F% ?6 M$ v& ]8 |
        },
$ y" k- F0 \& N3 v9 f; x( C+ \! t7 G/ J7 k};, y! \2 q" Z9 X5 F
; n4 o& z& k( q+ K" H8 _. B
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {* D8 n/ Q% d: ~7 o! V
        .leds = da850_evm_tl_leds,7 _, N3 b; V4 |* v/ V( q4 V
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),' Y( k' m- N2 O( s: W
};. `4 D* i7 q8 h; F
# k  d1 {1 Q! F9 p
static void led_dev_release(struct device *dev)9 W  C1 @7 Q5 T
{
/ ~* N; l2 q' q, u% S& K' B/ ^3 ~4 m};) d+ V5 Z0 J) \) K. [! W' `1 Z
9 Y+ T/ w, y* N0 [/ W
static struct platform_device da850_evm_tl_leds_device = {7 K) s2 B' E/ P, x) f' E- m9 }4 d
        .name                = "leds-gpio",
5 Y% j* f5 C& S        .id                = 1,9 \2 D4 b# L7 m9 L1 ?
        .dev = {
. U; y# V) n8 Y0 d; z: B3 S                .platform_data = &da850_evm_tl_leds_pdata,
1 ^; N- y" i  b! l/ `' ~! T                .release = led_dev_release,
3 Q) k! D0 H) v( i        }
7 e5 s1 W+ t! X  l1 N: ?};
, A  R; N. E$ S2 P. ^8 B" C1 ~) [, a$ |- M
static int __init led_platform_init(void)/ L* _2 G0 d" d# ~! [- e
{+ v6 ]- m' d% `8 T; e
        int ret;
- B, v" Y( V, ]$ `0 K#if 0+ _6 @: b( t0 A
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);- B: F! F/ n4 u6 o. B- _
        if (ret)
. K  A) z& z, i* ?$ X, k                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
, O. `7 E  @' F/ V                                "%d\n", ret);3 u9 n- A, h+ @: c
#endif
0 c. M. b* Y/ r+ H1 q( k        ret = platform_device_register(&da850_evm_tl_leds_device);
, D3 f: S' Y/ u% w' K        if (ret)
9 @# F  O$ J0 N( }( T                pr_warning("Could not register som GPIO expander LEDS");
3 B& q* t0 i8 l! q0 f        else
, P4 L* E; B+ k; [, E' Q                printk(KERN_INFO "LED register sucessful!\n");+ o7 d3 ~* g: _3 ?, ^

) y. u- r. f4 @, {        return ret;1 A. E! m) {9 V7 p
}5 w' p( |) |  x4 V9 a  C  Z4 W# L
  m& Z8 O0 f. `3 N: ]
static void __exit led_platform_exit(void)! p% d3 \$ F4 h+ ~; I
{
9 c; H, m  Z- {) G- P6 _        platform_device_unregister(&da850_evm_tl_leds_device);2 T$ L5 g' W' \/ z
. S1 Z7 B- S/ w/ s
        printk(KERN_INFO "LED unregister!\n");
$ ?' P  e! u7 C}) d/ [( x: w; z2 p
0 v' b5 x0 \6 G
module_init(led_platform_init);
1 o  Z0 Q+ T3 O2 N% x. D; ?" e) qmodule_exit(led_platform_exit);
9 r1 I  b- q7 X0 M" p; `
% Q. k' Z  ~" m& z3 X+ FMODULE_DESCRIPTION("Led platform driver");- @, a' S5 E4 \2 j" U4 q
MODULE_AUTHOR("Tronlong");) K( Y; t5 P9 I3 t
MODULE_LICENSE("GPL");; O. R  Z! p! e

# u  s. X, e' G6 N' N% Z/ i
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-11-21 17:32 , Processed in 0.045970 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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