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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。' r, W: T0 V5 [0 y$ m+ \
#include <linux/init.h>" M. Q, I2 ]6 t4 W2 M
#include <linux/module.h>
5 w! R( D( S  }  c#include <linux/kernel.h>6 ?0 z' w0 c9 u4 E( U' |$ A% L% e3 `
#include <linux/types.h>
% D* m  R) K/ R' W#include <linux/gpio.h>! {4 A1 L, N  [$ i0 V
#include <linux/leds.h>/ o! W/ S! T5 Z5 _
#include <linux/platform_device.h>- F! O  a5 ~0 j2 h( ^

, G. j  f9 r  l8 r: e; X#include <asm/mach-types.h>& ]0 Z4 w5 s8 r! |4 g* p
#include <asm/mach/arch.h>1 f+ s2 u" X! Q# Z: [
#include <mach/da8xx.h>
& g1 e% l1 o: C* s. [& p, ?#include <mach/mux.h>
7 d3 X/ A2 W8 U* y
) m" a/ y, H0 N#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)! A) u" x* m3 J  z+ l! C7 _
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5): [& S! ]  x) ^+ R" V
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
! a' v# B& [5 d& [  u, _, y; [#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)7 Z- N9 Q: c, c- H$ m$ _. Y
2 p) v/ z1 u- c) @) R9 R) f. U
/* assign the tl som board LED-GPIOs*/
* M# \5 \1 |/ ?2 T9 Istatic const short da850_evm_tl_user_led_pins[] = {
" s4 D; a3 x; ~: ?/ u' `        /* These pins are definition at <mach/mux.h> file */; I  ?  u$ b+ M4 t9 \
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,  I4 l0 m+ C) ^! g8 _. K
        -1- ]/ N" I+ g$ D
};) z1 O$ O' l8 Z; v9 o5 L
9 N# U% ]3 Z+ P1 H3 g
static struct gpio_led da850_evm_tl_leds[] = {
% z" t( z  M4 w        {
' M5 O) ^+ I( F                .active_low = 0,, x: M/ {: r% R8 A: K: t  b; d; Z7 o
                .gpio = DA850_USER_LED0,
, h$ H- j4 _; A                .name = "user_led0",
4 J" u. Q) ~' H  @7 a+ `9 X9 S2 ?                .default_trigger = "default-on",9 v9 }# ]/ @8 z* Y/ ^5 j5 L
        },
+ C+ y! c$ J) \  [, ^1 J; |        {- c. {3 L% `; W) W+ {: u( T$ b+ o2 A% X! N
                .active_low = 0,9 d# t: ^: U- }5 @, e9 s
                .gpio = DA850_USER_LED1,8 d' v. z/ V: O
                .name = "user_led1",# V1 j7 A- q( d7 p' ^
                .default_trigger = "default-on",) [  q- P& ]9 i8 Q4 E
        },3 {$ o% V, |$ ^; w5 Q" D
        {% Y( v; s( k! i* F8 V. a
                .active_low = 0,1 B7 E$ B9 n1 s( S$ Y" r9 O+ H
                .gpio = DA850_USER_LED2,
( P7 X" ?% s* f9 ^                .name = "user_led2",
; z& f2 K! Q2 v2 o6 r5 S9 T                .default_trigger = "default-on",( Q; k0 u/ q$ `7 H  R! Z1 f1 R3 y( d
        },
+ v" M. q/ S) c1 r) I% C; U        {
1 R! j# A' \+ H/ k, a/ q! v                .active_low = 0,. r* K% A: W9 x6 Q2 I+ n  b! H
                .gpio = DA850_USER_LED3,; C0 a7 h' p7 {% k
                .name = "user_led3",: {0 M' X! \) C6 T: I7 U% V( \
                .default_trigger = "default-on",0 z; e! y/ @9 x7 i7 F" Z
        },
, a* L. z  |) |9 U};3 O/ ?  {" p4 g6 T
2 M- @. d! b' u' k& Z' e) U, r3 e( S
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {/ o. l% ?0 H' l5 X% o* Z- ?
        .leds = da850_evm_tl_leds,
6 V$ `0 X9 c; e0 k2 F# d, y% e        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),# v7 ]4 i5 @  t
};0 |$ W- g! t# ^' q9 B* R

0 n0 X6 p1 F4 @1 l, }9 e; P5 F. Dstatic void led_dev_release(struct device *dev)
; P9 E8 V4 u/ q5 t3 g9 B{
0 E' s9 z, r& m! @};
* K0 i# Q+ Q! i+ u2 o
* g5 Z8 `- q: n. r8 zstatic struct platform_device da850_evm_tl_leds_device = {
6 Z4 `( ^; ?  b% _1 {        .name                = "leds-gpio",+ a5 G- {$ c& E- Y: e  V$ _+ I
        .id                = 1,- J! G- z) A" U5 H2 h* {
        .dev = {
; p, p! E$ K1 a2 e( K7 o& \                .platform_data = &da850_evm_tl_leds_pdata,1 \) P, p) f+ c9 J) o( ?
                .release = led_dev_release,
# c$ [) C$ d* U& A& L        }
& }2 t- C' i1 x, ^+ V1 }};) _. i/ ?0 S. ]- I: o; a  Q5 u0 V
" M  ?; g% w4 j3 Q) q, Y$ T3 a  \
static int __init led_platform_init(void)  ]* t, S8 J( d( e
{. s' |. n/ y; z2 J7 l1 Y: `: Z
        int ret;  W5 F% D/ E: g  |
#if 02 ~, n. D1 Y$ E; j2 R
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
. {5 o" p& x  N# g7 b3 f" H' d        if (ret)
1 ?* l. o1 C/ v" A! [0 K  m                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
) a# ]! F! j  k: t4 G) u                                "%d\n", ret);' ]/ _, Z5 x( l( |* a
#endif
7 L9 M6 `8 T. W8 N2 ^6 r        ret = platform_device_register(&da850_evm_tl_leds_device);
/ K0 q  S# @& D7 C* i        if (ret)  E$ N; h! |8 s$ Z) f* g3 H/ d
                pr_warning("Could not register som GPIO expander LEDS");. l+ |4 U3 z  C) H: t
        else$ j' A- o9 \$ u1 e( W! Y( u1 n
                printk(KERN_INFO "LED register sucessful!\n");$ |: e! u7 ]" C, z1 F9 D
1 e: C  Q( y+ s6 w. h7 s% C+ D
        return ret;+ W: F' o9 ]7 V4 R$ Z
}
% l0 v! L" M: j) _1 H5 G3 z1 g$ t! }4 T0 a' ?* R$ o# a
static void __exit led_platform_exit(void)" |7 }" l; d: `/ D1 y
{) }& t( C: F9 _; ~0 G/ e" M
        platform_device_unregister(&da850_evm_tl_leds_device);2 T0 B0 c- P+ H- J/ M

: D  l$ U5 G2 u& n        printk(KERN_INFO "LED unregister!\n");" o7 h6 a) Z* [9 V& @/ v
}6 l7 j" X; p3 |

" X" h! d0 o* K; D' Q6 M/ ]module_init(led_platform_init);
: ~1 a& Q" x1 I  \) Bmodule_exit(led_platform_exit);, C  W6 b- ?2 G1 |3 S+ c% j

* u8 U" s# Q$ h6 y3 nMODULE_DESCRIPTION("Led platform driver");4 m: y* B: a! o& b) F) [
MODULE_AUTHOR("Tronlong");
( |1 n8 {# i, g6 G/ rMODULE_LICENSE("GPL");8 X( q0 d0 y) d6 h7 D# ^0 m

, E! O4 x* q( Z' I6 t
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-8 04:33 , Processed in 0.035884 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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