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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。' y# I- q! `, v) o
#include <linux/init.h>
9 l# v' c( p3 i# f$ c#include <linux/module.h>: m  u) c1 d* t9 _; z) N
#include <linux/kernel.h>) ]" m9 c* ^/ y  C+ l, Y
#include <linux/types.h>& a2 m9 P) H+ o  a7 c! |% i
#include <linux/gpio.h>- M  H2 d* |* H. M/ z7 Q4 g1 x( [9 @$ p
#include <linux/leds.h>3 p  O) I! M  ?
#include <linux/platform_device.h>% I' R% W$ M  Y: x6 p6 |4 m

' S$ A$ s4 u6 O4 W2 _" n#include <asm/mach-types.h>7 T7 S, f+ H! G5 i$ m9 o. [) w3 H; w
#include <asm/mach/arch.h>
% {7 W8 ]( m% m1 n* _4 h#include <mach/da8xx.h>
1 z4 a/ N' P; F#include <mach/mux.h>
4 X0 V: v  [5 N3 s! Q+ @1 E, M, \0 K
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)7 _$ }8 b# x3 q& d- e8 x
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5). @% Y1 H: t$ h# a8 W
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
% [9 a9 x/ J! n#define DA850_USER_LED3        GPIO_TO_PIN(0, 2); ?7 V- M/ }# o9 ?* K1 h
9 E1 X  q6 V: @8 L: E' f' |3 f6 s
/* assign the tl som board LED-GPIOs*/7 w( I  Y4 I  d# T7 I
static const short da850_evm_tl_user_led_pins[] = {
8 Q* p6 e+ H8 w9 E1 o. Y        /* These pins are definition at <mach/mux.h> file */
" e5 E& D, V$ Z* T, C: ?; g        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
7 H; n; L# g. m& C        -1; S; t+ ^& V, C$ A9 L+ g+ S
};+ \% }, m! H- A' d$ j# j; m

0 L# B# e- L% x, Dstatic struct gpio_led da850_evm_tl_leds[] = {
* r+ m' l. f, t        {
% K% }* [  N" [+ B" b% s  P                .active_low = 0,2 }) ]0 B- O5 P7 M: k
                .gpio = DA850_USER_LED0,, |- C$ |; L  {' u- }0 u. o  `
                .name = "user_led0",
" `$ f% x2 x' a& g8 b# G, ?# n                .default_trigger = "default-on",9 m* Y5 p7 }3 g+ x! o2 U
        },
2 `8 n2 N; D4 J% [- t        {
+ v/ b' F: C4 H- ?                .active_low = 0,4 R/ Q* q' g) V+ e
                .gpio = DA850_USER_LED1,6 T/ ~' w, p; P9 G
                .name = "user_led1",+ l# k) r9 D. D: `
                .default_trigger = "default-on",  x+ T  L5 W) k; Z% C) Y! P  E
        },2 q' S+ u/ A$ |4 k" X2 f
        {
7 v# e/ ]7 n8 q  T$ H; A& o                .active_low = 0," D6 t- g; e6 K0 a
                .gpio = DA850_USER_LED2,
% l9 |8 [, ^8 F' g6 `8 v                .name = "user_led2",- @. W( J; N1 Y; ?
                .default_trigger = "default-on",
; \6 h1 u* p% l3 k7 {6 t        },, g# e4 l$ D/ H: Z% e7 r
        {* J. M# p$ {* _8 b
                .active_low = 0,
  b# L$ i. a. v7 f6 N                .gpio = DA850_USER_LED3,
3 f  M) e" q: h: T                .name = "user_led3",
' E9 s6 P5 {4 z6 q                .default_trigger = "default-on",7 G4 @- A3 `1 U" L( k0 J( ]
        },
: k. ~5 ]* c, O+ r& F8 n};, U* U- A6 a7 [0 x" B* K7 K& l9 i

6 Z5 t( h+ u7 r0 e4 Wstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
6 q. V. H% \$ [( o        .leds = da850_evm_tl_leds,
0 |$ z" U2 `5 ~6 O: g. h( M0 S        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
6 u" ^- U0 _# S% y* `};& X8 @& Y6 V' h' c$ j+ m

) x! w' w, ^% }8 I* @. j  n1 u4 Fstatic void led_dev_release(struct device *dev)
4 |. V. s* A& d1 C( ~: v5 x5 Z5 \{
, W  K" I. m% H5 h: W$ z};
& w6 e* _; o) T$ e
+ w4 o! p/ K  F+ h+ T- Sstatic struct platform_device da850_evm_tl_leds_device = {
9 u/ w+ m5 |' o        .name                = "leds-gpio",
3 ?: t' ]! i; g4 `4 M$ Q        .id                = 1,
& S1 I; K4 _. n7 p( ?5 `        .dev = {
- w# K( N# f. B- e                .platform_data = &da850_evm_tl_leds_pdata,
" c5 y& p) L; k: J                .release = led_dev_release,* m. e! F- g' L! Y% C' n. o
        }
" D. o5 k3 F2 u* K) y- v6 t};# z# u3 S" e/ e4 a
: a8 d" H% I) G2 j9 U
static int __init led_platform_init(void)& D% c. _! |" r. z& z1 V" K% f3 N
{6 g! {0 `  A& [
        int ret;
- G3 }9 A5 ]5 a7 Y1 N#if 0
* }* j/ |4 F/ \. d. ^7 ]; `        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
3 U5 t+ ]; U+ v3 O, D7 V0 o) x3 Q        if (ret)
1 O. \9 {7 Z4 u7 M0 q, P                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
8 Q) n- L  Q: D" u9 a                                "%d\n", ret);4 D' ~1 u. }" e
#endif
8 `, F- e! t+ T0 u# d' }        ret = platform_device_register(&da850_evm_tl_leds_device);8 \1 w! m5 k7 r* l0 G7 H
        if (ret)
. a+ h: c$ ^/ {, `3 t6 @$ A                pr_warning("Could not register som GPIO expander LEDS");7 T" g) ~* U8 w- C3 }) C
        else3 U( Y( a* q: I, R% `
                printk(KERN_INFO "LED register sucessful!\n");
1 H' V$ E4 [$ |2 s" S8 u. q1 U$ t9 Z' z/ ]
        return ret;# F1 D1 V- R4 Q+ t
}" j4 t4 F- `% ?! {

2 s9 u& X$ \, x/ h# fstatic void __exit led_platform_exit(void)
3 e2 Z: P) q! p, @+ u9 |3 H/ N7 k' H: x{4 x7 K  c; S* y0 n5 y! w
        platform_device_unregister(&da850_evm_tl_leds_device);
- n  w, F- Y  i3 I) o/ h8 L
0 K0 |( E' k, p! i) R& Q5 t3 F4 x        printk(KERN_INFO "LED unregister!\n");
$ O8 V" _5 h3 n9 w( o6 x0 X- Z}/ X7 S4 R6 x& a% F$ s4 M, N, l
3 c+ l5 A" ^; y9 j/ G
module_init(led_platform_init);3 q5 U# k/ `- k
module_exit(led_platform_exit);
5 D! R8 G- w/ ?1 a! W$ J8 P! G& q. m3 s4 G$ b9 n
MODULE_DESCRIPTION("Led platform driver");9 i; x1 p$ F9 y6 [0 Q5 }
MODULE_AUTHOR("Tronlong");
" D* r! Z* Q9 U+ K% a7 B7 mMODULE_LICENSE("GPL");
; P; Y6 I$ n' G2 D7 E/ g: d. P. F/ e; l+ F4 d+ \8 o- l# L
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-18 10:57 , Processed in 0.039592 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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