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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。; p& O0 Z* P* L9 A" y$ F4 M
#include <linux/init.h>( L* S# M/ A2 F" b
#include <linux/module.h>
5 i. R" p9 w( |: f: f#include <linux/kernel.h>
; v. y4 r8 N* O. y2 @9 \#include <linux/types.h>
2 ^8 ?7 t+ |& J( \#include <linux/gpio.h>4 A; q9 Y' S( `0 O$ G% _& w
#include <linux/leds.h>9 `4 J. h9 I" z8 v  J# _
#include <linux/platform_device.h>
! w) |- f7 A( s+ v0 ?2 y/ M: [6 b" I# n8 e
#include <asm/mach-types.h>7 K8 y8 |% N4 Q/ n
#include <asm/mach/arch.h>8 x" B! n( s5 d8 q
#include <mach/da8xx.h>% n$ m* o# ]/ O7 Q( f
#include <mach/mux.h># j- I% l% P) M

- @' ]- k" D7 c' L5 R) O#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
5 F. V$ W/ l: j$ u: H/ C#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)  F& U/ l9 d8 l" n
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
- B5 Y$ _( m* C/ n#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)0 P. F" P" k2 E  x1 ~

8 g: {' O4 u- Y" Z+ Z4 `/* assign the tl som board LED-GPIOs*/
  S5 C) w/ j7 Pstatic const short da850_evm_tl_user_led_pins[] = {
: G( ]$ U% Y$ w9 ?' r. ~        /* These pins are definition at <mach/mux.h> file *// }( k/ ]- U$ W' s  b% d
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,8 J6 Z( X6 z" }% e" U( S
        -1
7 {* F8 F6 @% U6 @2 F5 s- U/ ]};+ j9 d4 D+ l# \' V- _* c' j& ?, W9 w

+ E4 x: X2 m* c) astatic struct gpio_led da850_evm_tl_leds[] = {
: d2 B5 S9 _9 D5 x: [8 j, r        {
7 G6 [7 Y. h' L7 [+ k                .active_low = 0,% Y3 u: H# z3 ~4 k& r- L' O3 M1 W
                .gpio = DA850_USER_LED0,6 }5 S* e( M" N; _  G) _) Z
                .name = "user_led0",  C" `6 B0 O* m  K! N2 X
                .default_trigger = "default-on",% F) O- a3 |7 R
        },1 k3 u- ~* `- A, ^0 v8 X0 k
        {
; g( c% V  Y# Q2 D2 M- G) Q$ U3 b                .active_low = 0,
, c, |4 s. r& z- @0 s                .gpio = DA850_USER_LED1,8 g! n/ R0 g8 e9 E3 b# |
                .name = "user_led1",$ F* Z5 s, ?! M/ ?' y7 n0 k
                .default_trigger = "default-on",
; `+ S: \; s. ?* X9 ~        },+ H1 w: y  s% m4 }
        {
0 `1 p! P2 t/ y- D                .active_low = 0,- K! F( F. Q. k- z6 E! f+ C
                .gpio = DA850_USER_LED2,3 \: R4 Z, ~  Q! D& ^' ^
                .name = "user_led2",, A& k) C- b  o. O$ ~
                .default_trigger = "default-on",% s8 Z; Q% x4 k, f" ]
        },
, Z7 ]' h' @' c( Y; S  G4 y        {
+ q$ \+ r# U0 Q" c0 i! U9 z: L                .active_low = 0,3 A: m( F: D- }* K
                .gpio = DA850_USER_LED3,
+ S0 k! ~9 D- ]& G0 f0 W                .name = "user_led3",/ x! w3 g/ T8 _; F
                .default_trigger = "default-on",- y( r# w+ {1 z7 I( I3 g' q
        },
5 {, G, z2 \8 x7 |: p! j, H, c};
4 {$ @. V6 G3 U$ o  A4 b* ?& \( C9 Y) S
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {1 _$ j7 Q0 X/ m! P% F& |
        .leds = da850_evm_tl_leds,: ^7 f7 c8 ~) q# P
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
0 H4 q8 z6 k& _7 l! w; |};
2 q3 N& A7 T' r! k4 u3 s8 V* y& Z; v2 {. Q
static void led_dev_release(struct device *dev)
, J8 r1 f' i# G* f& F- B& }{
/ `: h( W* g/ K  _};( X* w; M% M8 l" H. |9 F4 N

/ F$ h7 S  m1 N2 E9 Lstatic struct platform_device da850_evm_tl_leds_device = {
  J, ?) x+ m' S9 Z( H, T        .name                = "leds-gpio",' ^  X1 G2 Z( B# w9 q. H7 p
        .id                = 1,
# ]7 e* D8 R5 m& Q$ O& @        .dev = {; _' `: l1 l6 }' @  C$ e
                .platform_data = &da850_evm_tl_leds_pdata,
. X6 \5 B- |2 X5 c" X8 u                .release = led_dev_release,4 e; t) N7 u3 n
        }5 a) G9 w8 ?/ ]! T4 A
};5 j7 h: r8 x: e
5 _  L1 s) \8 G* c+ Z2 X
static int __init led_platform_init(void)5 n6 Y( _' G7 |0 X! E
{
* w3 R8 ]( C" `9 i        int ret;
# ^4 W6 {4 u, G# X& L#if 0
) X) V4 V: g  `6 Y9 t        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);! q5 m8 T& J4 z- G+ t1 @  @) H3 i
        if (ret)
$ z# c: q- H' m! M                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
3 D) R9 A# [( ~# u: M! |7 n4 P9 K3 k                                "%d\n", ret);
; }& a4 ]4 _* v( ]3 k#endif
. {, m$ D1 t" U( s' S# n        ret = platform_device_register(&da850_evm_tl_leds_device);
! i6 d" }: z( `% o9 e/ {% h        if (ret)
. B# ?- L8 f# Y                pr_warning("Could not register som GPIO expander LEDS");
! K5 X7 l7 K. l; s( L- G+ K8 |5 Y        else) E5 T/ v5 Z  t
                printk(KERN_INFO "LED register sucessful!\n");
4 t' u6 b1 p6 K# w) i, l' ~( v" Z' E9 M8 [" _
        return ret;
  Q/ W' ?5 H! w( s}: X9 f  S. C/ n+ @7 e

6 Y" w5 b  Q6 ]static void __exit led_platform_exit(void)
- q, [/ M. E1 d( Z, \{
  ~3 ?: S0 t6 \0 C6 _        platform_device_unregister(&da850_evm_tl_leds_device);3 s' u5 ^2 E  z" I- ~
! s1 L% g1 ?3 j- T4 N
        printk(KERN_INFO "LED unregister!\n");
3 b, U/ D3 I6 Y+ A0 Z7 H}
( q1 ^3 s) L( ~9 |! P- o- x' v7 `; J+ ~# H
module_init(led_platform_init);
3 W4 R/ e$ c" H% J5 x( Fmodule_exit(led_platform_exit);: p9 C, e' g6 w) K8 @9 p
' ]( E7 v9 Q! H6 Q% q6 W& O
MODULE_DESCRIPTION("Led platform driver");* y' ^$ O( t6 L/ C2 @4 m
MODULE_AUTHOR("Tronlong");
( j5 e5 r9 I6 g0 GMODULE_LICENSE("GPL");+ t+ i  `) q  w) o7 p3 A% R

* x7 y! g, i' D8 X
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-10 21:31 , Processed in 0.038189 second(s), 24 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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