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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。* Y4 }7 b  ]; }# Y- r
#include <linux/init.h>
& V4 j- m& @. N: Z& u* E#include <linux/module.h>
# S0 M3 k$ p/ P6 K6 e#include <linux/kernel.h>
" q8 |; B; e8 ?* u0 s#include <linux/types.h>: v# V6 W. x. L, X* H) o: W7 [9 S
#include <linux/gpio.h>5 g: Y; J. Y1 T8 M5 u" P3 U$ p/ [. E
#include <linux/leds.h>
. R" Y+ K$ t8 T) K2 U#include <linux/platform_device.h>! U# B+ a  f' N" ?

' ?6 g+ x* G# A$ V( c. ?3 B+ x#include <asm/mach-types.h>: V" l1 ]! B+ ]( d, K
#include <asm/mach/arch.h>
) f6 C) J9 r- j6 }5 b" [, ^8 {#include <mach/da8xx.h>
! g1 b( z2 B! D5 ]; ~" w9 ^#include <mach/mux.h>
0 n3 s$ @; o  Q4 ?$ w. e& I" _  M/ X% w- t$ d! @; Y& o( j) u: ?
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
0 c# S+ h% Q* s- w1 }! f! \4 R#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
6 G" h, A5 `+ }' L" R6 v#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)5 ?5 a: X3 N& `) Y! k
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)% E+ W3 q4 g2 b) m( Q5 U

4 \  i& X3 r' U% A! V/* assign the tl som board LED-GPIOs*/
: d  d. B; |$ n& N3 i' ystatic const short da850_evm_tl_user_led_pins[] = {; E6 K7 o# @3 K6 K
        /* These pins are definition at <mach/mux.h> file */' j" f( c6 I% Z1 _
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
0 a% {. c: ~$ d) b4 H        -1
# t  U# E& }8 v) m  m% r};
: S' Y8 z* `( @) h
2 X- q  h. `$ `1 P2 Q; `  M- T8 Wstatic struct gpio_led da850_evm_tl_leds[] = {
+ i; K9 R4 Q9 G' ~4 a$ j, l- A        {' w4 X" v4 f. D& D  I( A
                .active_low = 0,3 F  E6 x, B5 S+ m" q) E4 F  |
                .gpio = DA850_USER_LED0,$ Q8 O: _; R$ R6 ]2 }$ e5 F: d
                .name = "user_led0",) }% H* g( k6 k1 @0 T
                .default_trigger = "default-on",
0 t, B1 `5 J7 c, ?# R5 w% A! _3 T        },- `$ W( S3 s  \
        {
' t" S4 }$ E0 h; R, ]                .active_low = 0," u: m0 C! T! @; c" A8 Q
                .gpio = DA850_USER_LED1,/ W# g' u" `" t3 S
                .name = "user_led1",
. G6 h* w/ b+ T2 s9 X0 H                .default_trigger = "default-on",
" v) E; M' H/ @& d* e  i        },0 g; l0 k8 V; e  S' O, k9 X
        {9 _( [2 o0 D+ a' x5 k' K, l( `
                .active_low = 0,
" m) y: V7 o# `" r                .gpio = DA850_USER_LED2," N" C' B' U8 H6 s: t, G% m
                .name = "user_led2",
. w8 D7 D* x+ b7 X                .default_trigger = "default-on",% H9 E0 _( W) d+ }
        },
' {8 y4 H# _3 D4 Z        {8 ~/ s5 a( b$ P( W* v! l
                .active_low = 0,
2 G/ O7 |8 Y) h) D" H4 L9 ^                .gpio = DA850_USER_LED3,4 y4 S" }3 K8 H- u: _
                .name = "user_led3",$ l' O+ M6 c' J& T& y" E: }
                .default_trigger = "default-on",
& J/ k6 `7 R# X6 L/ ~; N0 R. w        },
0 W8 W6 w5 @6 F" y+ K9 H* l};2 z- @/ ~4 h! V+ e

2 r3 [/ j4 ^# Y5 V: Bstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {6 L$ P1 D* q! ]* @% ~
        .leds = da850_evm_tl_leds,
0 ]8 k( J: q5 i        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),# }$ Y4 v; F; H( m
};
7 N( |8 r) n" t7 u( M
- U3 B6 S6 x6 C" N  y( ustatic void led_dev_release(struct device *dev)
3 i  s8 V/ d* X" W3 h{
: R) R" Q* z, e- u  }};5 }5 Q1 I: u- q# x# B
/ ?2 C/ @6 {- @% G/ y0 Q. ~0 q
static struct platform_device da850_evm_tl_leds_device = {$ G4 q, U2 ?+ D& W: s' R1 p
        .name                = "leds-gpio",
3 t2 M; L- r! V4 R7 A        .id                = 1,4 o7 t: ]# w3 F/ z
        .dev = {
) M- @# l  S! M" T0 b0 _                .platform_data = &da850_evm_tl_leds_pdata,! c/ r& Y, m" F. U/ p; u: P6 g' A- A
                .release = led_dev_release," n4 I# D  W" O1 _6 O0 e
        }
$ V/ U2 `$ k: ^0 g- u4 S0 H5 d. ~};! x/ S5 u4 r7 e. {; K+ s
7 @3 c6 m# C1 i3 a- k
static int __init led_platform_init(void)2 J: e2 v* `# ?/ Y( m( I
{* x" h& V( K3 z2 s+ r, x; p
        int ret;6 r  E; x' D: V# v
#if 0
, ?* F1 c5 N; q9 _        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);5 k5 W" N8 P' k3 `
        if (ret), ~5 _3 I! _" T/ Q' `. y0 d
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"% f  T& e+ p( m, x
                                "%d\n", ret);! b' {. [) }% ]
#endif
, B: H! a: s5 m: L4 U; N        ret = platform_device_register(&da850_evm_tl_leds_device);
( O1 g' w+ e+ J* V* h) E7 W, T& m* @/ e: q        if (ret). i& e  J; V: f& f9 g9 q
                pr_warning("Could not register som GPIO expander LEDS");
3 |$ _% u! V% v2 r4 t        else6 E8 u7 q9 {0 F% ^7 ]: o
                printk(KERN_INFO "LED register sucessful!\n");
2 n& c5 |/ n6 }! K
1 L8 ^9 R- W- [# F7 L9 u, f* O        return ret;
7 j1 I6 H% v% L/ N}
' V8 l( V2 Y* C8 I/ ~2 t
- _. L, c$ F7 ^( o5 U3 k9 ]. w2 \/ rstatic void __exit led_platform_exit(void)0 I  v0 g" q6 K, o' Y: v
{
8 m/ r- o6 w* u, E$ z. l        platform_device_unregister(&da850_evm_tl_leds_device);: @! ]1 j7 Y# b. t8 u0 V

& `8 F5 H$ ^. P- h) E        printk(KERN_INFO "LED unregister!\n");
/ y2 H4 z' j2 o# _2 }}
! ?  e8 ?) u, F+ G
& J7 t2 W* a% C9 _2 Rmodule_init(led_platform_init);2 N7 `0 U+ Z8 m' r/ ]5 q
module_exit(led_platform_exit);
  |- A- i2 R9 A9 B0 p# U
) J9 o  ~0 h, @$ }4 C8 H( EMODULE_DESCRIPTION("Led platform driver");9 G2 f# a5 R1 X: b
MODULE_AUTHOR("Tronlong");9 C. d, f8 ^7 C1 A5 D$ x9 A
MODULE_LICENSE("GPL");2 D6 ]% n# ~$ j0 T3 e$ @

, B, \7 _. @% k( u) f$ c' L" ?
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-21 09:12 , Processed in 0.040288 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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