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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
: i" N8 A, D% d6 `6 Q, j5 n#include <linux/init.h>
5 F5 |7 v9 c+ b$ u5 R1 C#include <linux/module.h>
! p7 m5 O* a3 _+ _, |2 w#include <linux/kernel.h>
3 [" ~* v/ G9 p- Q' D  L# o#include <linux/types.h>
) Q8 `2 a9 P# N& q+ V' m- ~#include <linux/gpio.h>! a5 F% X" S" V+ Q" T3 L$ F
#include <linux/leds.h>
  H( \! r$ L: |$ {#include <linux/platform_device.h>
" _" J. z0 ]0 _% u
  ~; j$ a* `) _9 K#include <asm/mach-types.h>
. J: H# {! n  {) [; T#include <asm/mach/arch.h>2 V  ~. p* E' L3 y. N
#include <mach/da8xx.h>
9 M0 s7 J5 d) p* {#include <mach/mux.h>
2 S, \/ I7 E7 x, [" H- @' ~. v$ t. b3 ?- B9 M; h7 U" V
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
9 @  a3 i: ^8 ]6 A7 M: ~* L5 a2 I#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
8 \' L4 E8 `' R% ^/ D$ _2 J#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
: w( t. u; b" n& x4 ]9 A#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)" g. \& {- C0 y( O" [6 ]8 v
, Q# x; I# Y# V% T
/* assign the tl som board LED-GPIOs*/
5 c/ q6 `( Q  vstatic const short da850_evm_tl_user_led_pins[] = {
6 v7 F5 v8 W; l; u. M        /* These pins are definition at <mach/mux.h> file */
$ A6 D/ w. U$ c+ Y        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
% n9 @+ C! J( [! ^/ Y- J2 w/ }        -1
9 C2 b+ m7 J( g- U  B};2 R& L. |4 ]5 V% Q6 w9 z  x- [& |6 [
) E' S  x5 K- R: e0 Z3 l
static struct gpio_led da850_evm_tl_leds[] = {
# i( Z9 X3 J% A7 A( I        {
) ]5 ]% h, y% {4 u/ y0 _                .active_low = 0,
, a  x( G4 f) N& K  N- R  a+ J                .gpio = DA850_USER_LED0,; {5 O4 Y: J. X# L0 C# C# }
                .name = "user_led0",, b  O" W, o, A/ U2 T
                .default_trigger = "default-on",
" s) @" T! ~( v        },
, A7 U% f$ O* {        {
" [/ T; m0 g1 T: h, X, z; f                .active_low = 0,
, o( S# E# K) F9 r! c8 P                .gpio = DA850_USER_LED1,
2 W2 f- N  ]% c8 X& @7 H. `7 s& D9 w                .name = "user_led1",% |8 B, `' C3 k2 X0 g9 Q" o
                .default_trigger = "default-on",
8 Z# h: h" q7 p( c1 y        },
% o7 n, A' l" K7 {. k        {
; G/ V( i) i& M$ @( w( f8 I                .active_low = 0,
! ]! T4 h! |# k, l                .gpio = DA850_USER_LED2,! c8 R* L' y- C' ]9 S2 J! N
                .name = "user_led2",
- y! r+ {& m5 O: \" B; V                .default_trigger = "default-on",' Y7 E! u! A) p2 T8 T+ k! B
        },
: Z! Y# L) G; B  }* A5 ?        {
& ]( [/ F0 q: c( p6 _& N! ]& k: f                .active_low = 0,
2 [( r9 `' ]0 r: w                .gpio = DA850_USER_LED3,% W+ c8 K, L# ^. a# k
                .name = "user_led3",
) E4 T* I7 @6 `$ J                .default_trigger = "default-on",
0 x6 m2 N1 [* f& c, v- v$ L        },
: Y. f, ~, Y! i: D};* v5 ~( |! I9 X; p! X- l
: n4 d4 y2 g, T2 O- l* F; D
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {& r0 @* R# a# {8 R# H
        .leds = da850_evm_tl_leds,
& [* T4 A! U2 T$ f: V) a  Q9 K        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),5 {" P3 i6 O$ N0 R. g8 t
};6 P1 u; O3 {3 y8 ?$ y- y2 r6 h; p/ F
* L& s; R7 I. N& O
static void led_dev_release(struct device *dev)7 P9 P% Z1 p! c% `, x" V4 R" ^; ^
{1 n% C/ o" l- [. T
};8 E% t6 l% L0 J2 m

" @+ N' I2 m+ b# ^: J/ J4 @$ l" R* B( Pstatic struct platform_device da850_evm_tl_leds_device = {& ~( J, b# N8 Q  d9 B
        .name                = "leds-gpio",/ F$ ]/ z6 g: d8 E. o# Q% J3 ^* c3 @
        .id                = 1,
3 S" X; b% P: r        .dev = {
* ]5 \" f" [5 [                .platform_data = &da850_evm_tl_leds_pdata,3 Z2 v( s. V8 Q% Q- L
                .release = led_dev_release,
! g% \/ M" `) o% d        }
3 r( U- D9 d4 @& d7 W' o};
' G  T; b; n0 Y. h# v1 e& @) r* Y; {& ~( ]- h4 g
static int __init led_platform_init(void)/ h' m8 }, b6 n8 {; @6 o- X
{+ O1 {0 y$ l/ B6 T
        int ret;
8 T5 ]1 |9 `" `8 S3 r- X#if 0' _# L/ Q' Q: ^0 S
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);6 C8 u- v  [5 ^6 a7 [& C( J$ Y: |
        if (ret)8 }5 j. V' d" ?2 Q, p+ \' h1 @
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
" q6 d0 F) J9 l+ b2 }                                "%d\n", ret);$ T0 E! f( P* w! d
#endif- _4 r, h5 V% Y& J
        ret = platform_device_register(&da850_evm_tl_leds_device);
# D& c; N8 g- p$ b# n        if (ret), ]3 f% ~8 c8 V+ j
                pr_warning("Could not register som GPIO expander LEDS");- k( [5 K2 d# f& y
        else
/ @7 B( B. H( f" P4 S- b                printk(KERN_INFO "LED register sucessful!\n");) K: y' k4 M4 ]: s

2 t. B! J; n% x2 d        return ret;
; x2 }# c' ~$ N6 O1 W}# R) P/ M6 E! q6 q/ v8 `
4 |& @( P3 ~; O5 a' t+ ~
static void __exit led_platform_exit(void), I. V! g  }- I% Z/ k
{
+ w; m7 s' i  |' l! G% ]$ }        platform_device_unregister(&da850_evm_tl_leds_device);2 P, I* [9 ?! U% i6 \6 @

; @! I5 z/ g1 @3 O& U! n        printk(KERN_INFO "LED unregister!\n");! |1 T$ Q+ \: N5 [* |" l
}
, p% @( z, }; X2 r. J( ~  {1 A' {. ]) S+ k: N* }/ @" g$ q
module_init(led_platform_init);
2 n! }" V8 n( |; Amodule_exit(led_platform_exit);5 `# k& l" _; Q0 z/ r
6 d4 \7 T2 M1 B
MODULE_DESCRIPTION("Led platform driver");
5 ^5 l: j# ~: O$ pMODULE_AUTHOR("Tronlong");
  g9 X4 K$ u9 o9 R/ |5 _: _" eMODULE_LICENSE("GPL");
) q$ n! K4 j2 f9 p
/ z# w! M0 g; q
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-21 21:54 , Processed in 0.038422 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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