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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。* E) R. w0 F) p; L: B2 L
#include <linux/init.h>
3 b+ b2 q  _( }; f2 c6 d+ P#include <linux/module.h>) W0 u( c. e! O- j! L1 ]) j' A8 U
#include <linux/kernel.h>
3 R9 ~1 w9 C1 j& q; T' `; k' }#include <linux/types.h>! p% d  f, s% \% `4 [8 x
#include <linux/gpio.h>6 W! F/ [5 x: H! t1 [  E
#include <linux/leds.h>, B6 U& Z: ^6 K
#include <linux/platform_device.h>
) |( _7 o! B1 W
. O/ T; i( A9 ~* S% _#include <asm/mach-types.h>5 w, T# k  x0 `. T( l( r3 H% f/ B
#include <asm/mach/arch.h>
+ c3 l1 U; g4 v& i#include <mach/da8xx.h>+ [. @& Y4 H& W! {9 z% I
#include <mach/mux.h>
% ?% q/ t9 a; H1 v. n0 ~- X
! J0 J% o. S1 _/ M% b#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)1 Z' l$ o' |% |) n  ]: G
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
: i3 q+ K$ f; v' l1 }$ G. f4 `#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
; u2 d6 W9 F* h9 _#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)- n1 V/ B4 `) `
1 |4 \$ [5 j. d5 ^& t/ k  P( [8 K& R
/* assign the tl som board LED-GPIOs*/6 @7 @# A, \- b& e1 w8 A
static const short da850_evm_tl_user_led_pins[] = {
2 j9 c! G. S2 @7 o# E( h# L. z        /* These pins are definition at <mach/mux.h> file */7 @3 R) I2 L- i
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
7 M' w5 y- Z7 p  u& u+ a        -1
' v  [% a9 y. k* ^/ W" w};2 w2 A2 D) h1 K  ^  }
2 C9 |& m; b* K9 T
static struct gpio_led da850_evm_tl_leds[] = {) o, Y, ~, U* M& c% S
        {
" k0 g7 U1 Y, r+ L, l4 R4 H                .active_low = 0,0 e, Z0 E; O, ?
                .gpio = DA850_USER_LED0,( Z* K: @6 k* }! k) R! h$ E! E; F" M
                .name = "user_led0",5 D: p5 A+ n3 b; M; C) ]: n
                .default_trigger = "default-on",
. w# g& A  u1 h( M        },
! N/ d+ z5 t  E        {
& p% H" R) H% }3 y* }                .active_low = 0,
  N. X0 K4 h" a  N5 S                .gpio = DA850_USER_LED1,
9 X9 i# K& J3 i& D                .name = "user_led1",
- X& C; P  g) }: t' Q                .default_trigger = "default-on",1 o1 j7 \  k  {% @: n
        },
. o& T, x, Y5 b5 c5 |2 a1 D  s        {
) _) S. ]: D) X# f8 b                .active_low = 0,
, C1 e2 K/ }* w) t                .gpio = DA850_USER_LED2,( F' i, ^% s9 [7 n% K' E  ]+ c
                .name = "user_led2",
7 G) g/ a/ s1 S% A  p                .default_trigger = "default-on",
$ ~4 D+ r4 ~. j: [        },
6 ?5 L# P: }) y" W5 U0 n  J        {
  l# W# _# P4 D8 c  h5 A! c1 C2 D                .active_low = 0,
) h- F) R8 d9 ~& e7 B                .gpio = DA850_USER_LED3,
# l; Z# K& S8 S. {4 k  U/ Q6 b% U                .name = "user_led3",
; F, n7 h/ Z0 E9 r% O$ f                .default_trigger = "default-on",0 Y! d4 b) M: g  _# V7 Y2 }
        },
2 l' L7 `, T6 T' Z! G2 G};& e* o3 z, q3 J, L  G
/ i" B, f4 g. J
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
2 W4 k, K  W$ k5 @$ ?+ ^        .leds = da850_evm_tl_leds,
1 o3 q7 d) v5 z0 b. |        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
- G& o3 ^3 ~0 C1 q};  G" g! ^4 c" S2 S7 M& B1 Q
* {5 g/ Z" }  u) D  e7 M& l
static void led_dev_release(struct device *dev)2 r# V' D; M1 ^% M) r* p, @( l+ ?
{9 [2 x: U' c2 o6 q" D
};* }3 e; o5 B) q: V7 ?% I7 Q
+ j& K6 ?, K, r1 |
static struct platform_device da850_evm_tl_leds_device = {0 p3 ~. J0 c/ R" @1 d5 g
        .name                = "leds-gpio",
- n( J, _) {. X5 @  B1 z' S3 c( m        .id                = 1,0 r; x1 B' b% k3 `: O3 C; h4 M; u- v
        .dev = {
! ?3 _6 d9 Q, s2 [8 \. r                .platform_data = &da850_evm_tl_leds_pdata,3 G" l! O2 W0 u* d* e
                .release = led_dev_release,
/ v# A( K7 C8 {        }8 m. F+ L/ d  c2 ^/ f5 D3 G3 z
};; o' w$ [7 V" ^+ q3 y3 W; w3 ?

+ i" J( P* ?. Astatic int __init led_platform_init(void)
/ h6 _0 Y8 S$ @6 Z: f; a! e% J{& F1 m. I4 _  Q0 H
        int ret;
3 e& W4 h& X" g1 [3 q! T#if 0
4 r* c& f8 I! o8 M6 D        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);3 z/ f+ i' G3 V
        if (ret)6 N! H5 `6 v2 H- t. c
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
& X" C, o, |! N                                "%d\n", ret);
6 S; Z2 f' H+ u#endif6 K  ^. _1 f4 E% |
        ret = platform_device_register(&da850_evm_tl_leds_device);
$ T. T; r- m# [: S4 b        if (ret)* W5 v/ f9 s9 J
                pr_warning("Could not register som GPIO expander LEDS");! j" P" Q4 ~. }+ [6 j
        else0 _" q# Z; X/ q/ L$ N7 M4 W
                printk(KERN_INFO "LED register sucessful!\n");
2 W3 s5 T7 l& \- d6 g
. t. J* P* {! A2 p; S" o        return ret;
9 o' ^+ Z8 D/ |: k  q* t8 V7 A( Z' l}. w  I* s: r( W' r
0 M; ~# O- _; t8 f: L
static void __exit led_platform_exit(void)
0 z3 f, D3 u8 a/ R" d$ h{
4 u; i, [& D( K: v        platform_device_unregister(&da850_evm_tl_leds_device);, W, J  G% [: T+ x/ m
7 O2 M. O5 S. U& n4 ]5 S
        printk(KERN_INFO "LED unregister!\n");
) L7 T8 c9 t% ^+ f}
. V/ X7 S% g  ~" Z! }) N7 n) T0 f" n2 K: M3 z9 j
module_init(led_platform_init);* J* |" ]( j/ V/ k% i
module_exit(led_platform_exit);. T- z# z' l$ R+ C5 Z7 M$ x/ O3 I

# l$ `6 X# |% k2 P% E/ C2 LMODULE_DESCRIPTION("Led platform driver");1 _% o# C3 P. z; s4 V% s
MODULE_AUTHOR("Tronlong");
# A6 J1 X9 |2 \8 {MODULE_LICENSE("GPL");
5 f! K# m5 N4 T4 O/ i: W$ z( @, B) D% T. C( V1 c% R0 y
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-16 17:36 , Processed in 0.038465 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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