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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。: t; D% E5 b9 k& k4 V
#include <linux/init.h>9 p2 T$ i1 L" M/ b: X& @  \: P! g
#include <linux/module.h>9 q4 o) y: @' S
#include <linux/kernel.h>7 ?* n5 G+ C0 ~1 I
#include <linux/types.h># Y, L  F: k+ F& f  s
#include <linux/gpio.h>
% a$ a) Z, i6 h7 o& g#include <linux/leds.h>6 L+ A  F, i9 c8 ]* Z" I3 z
#include <linux/platform_device.h>
! c: F2 G+ O3 x' }9 M# |3 H+ ?9 ^; c0 ?0 x2 p- r! }% T
#include <asm/mach-types.h>
! q) k, Q$ X8 L+ Z$ ]! u6 ?#include <asm/mach/arch.h>" S/ R" g% u% d( L2 m; T, K
#include <mach/da8xx.h>2 I+ \8 Q5 X4 j
#include <mach/mux.h>: w) q% I& t  P# P! B. x. b+ h5 |& N

8 i# X2 {# Z9 b; n& V#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
" D: ^7 g9 n& {* C6 E3 w#define DA850_USER_LED1        GPIO_TO_PIN(0, 5): L! Y9 |+ h  ?3 p8 K+ N) x
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
( @6 P. x7 u; j* e6 t0 @! c#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
# w$ z$ o! r+ Z' j  B
7 P' L! o  _, _0 ]/* assign the tl som board LED-GPIOs*/
6 z- F$ a' ?0 e& {static const short da850_evm_tl_user_led_pins[] = {
+ a! e2 W, P) C        /* These pins are definition at <mach/mux.h> file */- z* o; P& D# ?" o
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,* G# ?$ e5 v# g" s) f0 k
        -16 C. \# O( c7 c
};
1 W* C" h9 K) g0 \  [* {9 \% E" x8 {* ]! D& h7 W4 o- |
static struct gpio_led da850_evm_tl_leds[] = {7 h1 ^5 K( h! o) K: j
        {( I  O* A' ?* m0 `# o
                .active_low = 0,/ n. L3 L0 V0 K  w
                .gpio = DA850_USER_LED0,
/ R2 N9 w8 F! v2 A" y1 d, F                .name = "user_led0",
" Y0 O- r! x4 |9 a                .default_trigger = "default-on",
' s  p4 H( h/ ]; G% R: U5 S% ]        },3 e4 Z3 M! R; ~. ?
        {' o/ e( g, p4 j. E& R9 s: F" u: v
                .active_low = 0,
( K$ D7 @/ H& Q5 M- ?8 w                .gpio = DA850_USER_LED1,
5 x# ?) D1 {6 d                .name = "user_led1",7 p# i3 j' S7 d. a, @7 e( V
                .default_trigger = "default-on",
0 {. u. x7 ]& S7 n3 [        },. D8 }, S% t/ u+ t2 ?' @
        {0 t& H0 B/ \+ _' F- c
                .active_low = 0,
0 z2 [' f% [' I3 m                .gpio = DA850_USER_LED2,
8 I* S& u% Z3 h4 S" v7 g                .name = "user_led2",# S" ^) [5 |0 N2 X  K* x
                .default_trigger = "default-on",
# s1 z+ n: Z2 [5 c        },
4 X, F. S$ U( [        {5 q: h/ e0 ]# \/ i6 }
                .active_low = 0,; R+ m2 t  k' k& c2 H
                .gpio = DA850_USER_LED3,
1 s3 ]9 ~, g: @" o7 i                .name = "user_led3",8 P: D! |+ k' A  n
                .default_trigger = "default-on",
% v) i. ?" F: I& Q/ G        },* d) g: }* K' y. T
};- z! R; ]1 g/ l

: p" G) E- I. s; ^4 I0 |; ustatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
8 l4 Q( w  m& |+ \        .leds = da850_evm_tl_leds,6 u1 f0 t& ~8 o' ?' E: y
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
) G0 q+ j6 N4 _( I};" `. d, `' M; ~2 }
2 T; J6 R  m; v3 J- n
static void led_dev_release(struct device *dev)( {& N, u4 c* l) B
{
6 ~$ `- E8 x# B! u' u};  c& y% R& |# n5 F* M9 @! S+ k
7 U2 z/ ~3 z, f- K
static struct platform_device da850_evm_tl_leds_device = {
/ z+ `9 a4 D) m7 J0 |4 P/ i0 y$ x; C; H) B3 u        .name                = "leds-gpio",
; L6 m5 b+ ~- t8 ]        .id                = 1,
, N* j6 h( ^$ w8 {! M& ]2 ~        .dev = {5 h- Z* p) u- R" _; A1 T
                .platform_data = &da850_evm_tl_leds_pdata,6 i3 z0 Q4 @/ t
                .release = led_dev_release,, y9 B8 }/ W, I6 L5 U. h5 e! D
        }
4 J1 _) F$ a* B. H1 u};: q$ {( H: _2 Y" a  ?8 ^
+ p& X0 p+ S% d5 U
static int __init led_platform_init(void)
0 E1 A, v# q# g: J{
0 s" v' n# [0 R; r' Q        int ret;
2 M7 x4 w8 Q5 H& F0 z' M# l5 {#if 02 W1 |0 W2 a9 o  |! ?7 {% ]
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
8 F" ]! q5 l: V        if (ret)* o% J$ ?0 n; r
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"7 `- n$ f+ r; W
                                "%d\n", ret);
1 N( s+ i# d2 a#endif
# {+ ~) d% J( y& d! D) Y        ret = platform_device_register(&da850_evm_tl_leds_device);* U" {5 @* H& {& i
        if (ret)  l6 D1 [# `  a6 y
                pr_warning("Could not register som GPIO expander LEDS");( k* X) B  e% h# F6 k
        else$ \& W# z8 M9 P2 A6 \
                printk(KERN_INFO "LED register sucessful!\n");8 L7 z' F7 ]$ {8 N2 m6 @( _1 [
" q' T. z9 B0 h. m2 O) e
        return ret;
8 K- {. S$ ^) l8 i' i) T}1 B0 }$ o  w! ~, w4 R# f. ?& A, F
, s+ A0 N: z7 W# Q# J5 p/ t3 i
static void __exit led_platform_exit(void): {! e& |2 P  `: K. m; _0 Z) M6 U
{' E% G+ o% r& j
        platform_device_unregister(&da850_evm_tl_leds_device);
5 d! c# O! ^# m) N
) y0 g5 C( v3 Y8 r  z        printk(KERN_INFO "LED unregister!\n");( I7 s. d3 j# I% e7 O  V( a/ ~
}
3 U2 _' ~  g. j! u; n5 C# ~" [: x  L3 b$ N0 b- E
module_init(led_platform_init);
; [/ ?, K) C' n! c# hmodule_exit(led_platform_exit);# X) s& l( c: v8 f! o% O
) ]( j; S$ g$ }1 r$ h; }! @
MODULE_DESCRIPTION("Led platform driver");
3 A) o7 z% X7 e" m; M$ _MODULE_AUTHOR("Tronlong");% P+ z: g9 {7 l
MODULE_LICENSE("GPL");
9 |, ?" U; c+ M/ w+ l; b' z+ r7 D" B2 J4 y' D3 _
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-27 07:37 , Processed in 0.038648 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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