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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。& d# K+ m% x6 Q; i" _9 A; S
#include <linux/init.h>
. x& m, n: o0 i( `#include <linux/module.h>+ ]8 ^* Q) r0 R+ `
#include <linux/kernel.h>
, T8 W2 X# I# w0 N#include <linux/types.h>
* z" ^2 Q& T+ O4 X$ ~# X  W#include <linux/gpio.h>
/ \! n; b6 J( ?7 q. G#include <linux/leds.h>  d0 r! O* h: |9 t+ y1 ^
#include <linux/platform_device.h>
( t3 i1 f0 M0 e6 }' X3 ^+ M3 _7 _+ p, {
( r$ Y) r5 L9 I$ E#include <asm/mach-types.h>
4 n2 J0 }$ j, t# R( V#include <asm/mach/arch.h>
1 I3 h4 P. l. f2 Y4 G#include <mach/da8xx.h>
$ j3 }# |9 \* \7 C$ R2 Y. D; {#include <mach/mux.h>
2 v5 L2 e* m+ }
3 z0 J( v" H# n: q! M#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
6 f  _, x, {: Y5 M  }( \#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
* \/ z1 N$ Y6 \#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
5 F8 ~( ^& T/ M/ ]9 k5 b( W#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
6 W' _: x2 P# i# w' U3 E, I
# w5 j+ ?( h& ?. E3 b/ G3 |7 v/* assign the tl som board LED-GPIOs*/# n7 {9 A' g" o( p8 c0 m; Y
static const short da850_evm_tl_user_led_pins[] = {
% _# J% ^$ K. o        /* These pins are definition at <mach/mux.h> file */1 G! L/ `% s% Y& T
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,  s  e4 _) k/ C
        -18 @: [1 R$ e) \& r
};9 U& ^# i+ Y2 \0 R
: h# u9 P" n7 s- I" v. U  |
static struct gpio_led da850_evm_tl_leds[] = {, m; j1 J2 h1 E2 C2 z/ X$ }, ^- {
        {  `$ k3 Q' |/ p  K) Y' `" B
                .active_low = 0,' |  H7 G" y: }" z
                .gpio = DA850_USER_LED0,$ u6 x, O4 |6 |! Z) a
                .name = "user_led0",8 {" x0 W% Y( `. Y  ~
                .default_trigger = "default-on",
  {3 D) l, B7 Z6 H8 x! w        },5 n2 w% J  f: m2 V0 J; C
        {
" y$ ^2 ^  f/ N7 V# F                .active_low = 0,: G' S  g8 F$ n# n" A/ j
                .gpio = DA850_USER_LED1,
6 n" N: z8 `" O9 d5 C! ]' V( }% ]5 B                .name = "user_led1",6 Z0 X( w; M9 ~" |; e
                .default_trigger = "default-on",
  f7 i. A" x4 T& ~  g7 }# I        },
6 S  K' }7 Y/ z' N* |4 i        {5 {. \) J2 r1 d1 k
                .active_low = 0,
, ], M4 \  ]. |" s                .gpio = DA850_USER_LED2,
9 U5 B8 B9 g; t3 O, C4 e9 f                .name = "user_led2",' B% b( P, Z/ Y. F
                .default_trigger = "default-on",
0 @9 }$ w! p+ C! ^( P9 w        },
# O1 i+ \, \8 v& F1 V. z        {. L: l  p4 \% n  T6 b% |
                .active_low = 0,) |$ a1 t7 c4 I
                .gpio = DA850_USER_LED3,9 h; ~, ?4 w" e; M. G
                .name = "user_led3",# g5 g: f2 X- U0 c+ m
                .default_trigger = "default-on",& d% j& g0 p/ B% u9 R
        },
6 P* G1 w! z* i1 F: I: z% X};* X) m: s* J$ b: q; ~5 u2 T1 l
/ h2 L; J+ f( J2 A# ~) R1 D
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {  V& h0 ~1 V, V7 o4 R
        .leds = da850_evm_tl_leds,0 U- j0 |% e% k/ d* V
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
: S2 ~1 I. u3 P: m# P};
/ s4 M  F6 z# ], r7 l2 n  Z
, }4 ]. L1 [; E8 pstatic void led_dev_release(struct device *dev)
% [1 L( H% w( u{
9 C( o+ g" z6 M( x. ?/ T8 s+ N0 x};
1 P# o$ e' S% B% H; \! T, s: U1 h/ F
static struct platform_device da850_evm_tl_leds_device = {
2 W9 Q- S" N; V0 Q" h        .name                = "leds-gpio",2 [" J5 A# j# _+ R3 X7 b2 s
        .id                = 1,
5 |9 D, z. G/ O" B8 [        .dev = {8 r* o8 D% Z# i
                .platform_data = &da850_evm_tl_leds_pdata,
% m& S$ M2 K" Y                .release = led_dev_release,6 V) w; ]- Z; k) K+ Z! q/ Y  g
        }! v! J* N0 p" A# U8 ]
};
5 ~& @) y+ p: Q* T- L
6 N" v' Y) X, ^! n' M9 Qstatic int __init led_platform_init(void)
, u& R: r' K7 T{7 S% g$ o( a$ g6 `
        int ret;0 V* o. R0 Q/ M; v& r  Y
#if 0
8 v/ Z9 j5 ~6 Y/ }3 U% N# l        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);. z* Q  j/ E8 F' R" A
        if (ret)) t( K  j  Z& S. e8 F# Q. w
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
" w) J( A0 i* t0 F$ v                                "%d\n", ret);
% A# D/ c& N) A" I4 R# e#endif
$ h& x0 |9 P" K        ret = platform_device_register(&da850_evm_tl_leds_device);
: }# p# t& B; }        if (ret)! E1 n. t& l2 `: g3 ~* N' e
                pr_warning("Could not register som GPIO expander LEDS");
! b. y' k; L5 o1 ]        else
5 D  \( i, P* p7 x                printk(KERN_INFO "LED register sucessful!\n");' J% W5 j3 |8 F' e4 P3 @/ L) v

  K) o1 ?0 C: l# i" P7 ]* d        return ret;
0 P& _% w! t* Z: X: v" h( }0 ?8 M}% K2 G& M- }. n5 O* e; a% j0 u' A

* D  T4 J& f/ T# ?. A7 Wstatic void __exit led_platform_exit(void)
* I% p" e1 F/ f/ j+ O5 x{  p9 A! }- d! |$ t& I" x9 u
        platform_device_unregister(&da850_evm_tl_leds_device);
3 j6 c0 u  ?0 G" X4 d; b; t. C$ P
        printk(KERN_INFO "LED unregister!\n");
9 [9 i/ v$ o9 P4 K, [6 B8 Q8 \}
/ D5 y* c" q/ D6 g$ a2 d; N* A2 H3 @% u7 k! k
module_init(led_platform_init);
1 K' E2 N9 D9 I0 c1 }1 }" o3 ]module_exit(led_platform_exit);9 n% x( f) F; E$ q% w5 I

! r; o6 k4 j+ e3 RMODULE_DESCRIPTION("Led platform driver");" @) c" ?8 K4 ?% ?: ~# p2 W
MODULE_AUTHOR("Tronlong");
0 o2 {2 g; `9 y, f) \MODULE_LICENSE("GPL");
: F! \4 I! K1 Z' Q* d9 _! |  E' }# ?; X5 ^
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则


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

GMT+8, 2026-1-13 07:12 , Processed in 0.043287 second(s), 28 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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