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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
: U9 o; ?( E  p#include <linux/init.h>2 x& F+ f/ ?$ c  I
#include <linux/module.h>
# k# V$ _: w- T0 w2 ^) A5 ?#include <linux/kernel.h>
" H! F# b5 h, B- w( [# S: ]#include <linux/types.h>1 B% Y/ u0 l$ D/ r; O: f, H
#include <linux/gpio.h>" [$ a& X% a+ O$ \9 @1 F% Y* @
#include <linux/leds.h>
7 l2 o$ K) c/ X# X! [# D- o, k#include <linux/platform_device.h>
7 _4 b" J1 L9 k- _
" H. @* {/ W0 {#include <asm/mach-types.h>
" [! e  a7 O0 g#include <asm/mach/arch.h>
' D' c$ L/ _7 @5 i- U8 G#include <mach/da8xx.h>0 }2 n% h0 W3 Z- ]6 A$ y- V4 S( \
#include <mach/mux.h>
7 l0 H6 {8 e4 o  W6 J4 Z: u  ], L" T& r9 p7 l9 w) @3 J2 @! |
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
% _6 B9 }: @+ }' k/ m8 r#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)2 ?1 D. T" Y+ D
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
3 U/ O, M! n* R% W) L" R#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
1 z& `8 f) F5 u* q8 p- Z! h
8 J7 ?+ V( M' [7 z/* assign the tl som board LED-GPIOs*/4 a. v- T/ c; S$ `1 F+ H& N9 g
static const short da850_evm_tl_user_led_pins[] = {
( F) K# p0 s& D+ c$ L1 ^        /* These pins are definition at <mach/mux.h> file *// @/ J$ Y& t. e! A3 ~
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,7 V( J) r! w8 G+ a
        -1
+ ~! u! W  @+ Z9 L* ~0 w, V( `};8 C& {" x8 E- x: {* {4 Z& K- `) d. h

' f% z; i8 s7 x* p2 lstatic struct gpio_led da850_evm_tl_leds[] = {
( M# F# R* b; n& F& t, ^! w1 b        {6 z2 i" _8 ^4 V4 t# [; }
                .active_low = 0,$ R5 K+ T- ~; u; d4 J' \
                .gpio = DA850_USER_LED0,. j# B" I* w, a* q+ t/ a7 ~  q8 Z
                .name = "user_led0",4 T# f+ _4 J! {5 f" P
                .default_trigger = "default-on",$ V, \$ g& R* {0 D1 ~
        },
" H. w  ^" ~; ]1 l! J* z$ M        {
$ C: N. Y: T) ?' [- ?                .active_low = 0,, d$ {" x# J) w6 b1 _7 [4 o/ ?* Y
                .gpio = DA850_USER_LED1,* ?" `5 T4 L% ]7 @" y5 P' @
                .name = "user_led1",, I7 c7 u- w0 U4 v# U( R
                .default_trigger = "default-on",
0 ^1 g9 X! ^' M1 `2 Z3 i; c        },) x2 F" L* Q3 v9 j
        {
+ W3 q0 c7 h$ M                .active_low = 0,! y& i7 |9 R0 J6 h
                .gpio = DA850_USER_LED2,
, [/ A# C4 z0 \" k+ R6 ^( y                .name = "user_led2",
. |4 C! h6 d$ q+ @                .default_trigger = "default-on",6 ^4 Y4 z$ {9 k: w7 A
        },
6 s6 Z3 A* ^3 ~: V2 n        {
) P# {. P1 L3 |4 [" W2 d/ H3 i                .active_low = 0,# J" v( C% ^7 \& a! z) x
                .gpio = DA850_USER_LED3,( T+ B  O8 G; _
                .name = "user_led3",9 [' B: S* ~9 P
                .default_trigger = "default-on",) R3 V# |8 r( w8 I# \+ P
        },
% X" x' l% Z0 ?4 J1 e};
/ x5 T4 g+ M8 n) W0 C; s' i: d- y% F) C$ S
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
9 \& K/ S6 ~6 D, d( L2 t" @        .leds = da850_evm_tl_leds,
/ g, b2 l% I% Q& P; G  k        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
/ T) c" b6 M' n9 X};
' T, L" O- t1 m0 b
3 o  W" u' ?6 j2 Z6 ?% zstatic void led_dev_release(struct device *dev): h) Q, j7 |1 h1 B
{
- ]4 ~7 |0 L- v& F5 Q3 t/ r% E};
" n- c- h- P0 G
1 h" u# g) Z; R) ?static struct platform_device da850_evm_tl_leds_device = {. o2 x( @- K+ Z( b; s, x
        .name                = "leds-gpio",
& s7 A4 i6 Q$ X' a* e        .id                = 1,
! \! ?/ }. ^$ G) F        .dev = {1 \2 c4 l1 ]- L* y
                .platform_data = &da850_evm_tl_leds_pdata,; X5 [/ R2 ~* ~' ^
                .release = led_dev_release,# _7 k. ^' N8 G: q
        }
9 I  C2 k3 p* F7 v};7 l2 [& m. ]6 m: ?7 Q$ o

6 t% d. |2 o6 F1 V9 {static int __init led_platform_init(void): ]! g" y9 D( J: c/ S
{4 N2 b) ]' Y5 r; P' z
        int ret;6 ]" }: G7 h7 T/ \
#if 00 G; p& @' o- c7 S, L# P) g7 B! I
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
7 D, ?+ t) d: n        if (ret)
' Q0 y  s  |5 t2 Y                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
) Z) u: ~/ k( o* M6 M' _8 G' K                                "%d\n", ret);
7 @$ a6 ~1 }) J. ~#endif: G1 w: Q% u7 H5 J" c( y) U
        ret = platform_device_register(&da850_evm_tl_leds_device);
  e; l; Z6 R8 g( g' }* a3 Y        if (ret). E3 }, S  _( ~
                pr_warning("Could not register som GPIO expander LEDS");, G: H& s' ^6 k2 w! C" N; n
        else
# J  |6 W' S  `! g                printk(KERN_INFO "LED register sucessful!\n");* c/ _7 p6 o! c3 X
; ?/ K9 f) u% l/ q9 j7 c  B& _! V8 w7 l2 m
        return ret;
$ r: E6 F3 J4 v2 t* D: Q}: O; Q; l- |9 n
4 V. q+ Y# I5 f1 i. u
static void __exit led_platform_exit(void)
. Q) G% n% x6 N; l' s6 `{/ ^: x) j* w/ ?6 T! w! k  ~/ z
        platform_device_unregister(&da850_evm_tl_leds_device);' ~* L3 u  D; K- N8 U/ M5 \

3 Q' j3 {& W+ h; ~( X. v0 p        printk(KERN_INFO "LED unregister!\n");$ q* |' U! t( A; H6 \7 I) h/ a2 @; m
}3 V0 Z! [4 n0 d! S" J
5 B$ h2 v" C. Q( ^  W5 D
module_init(led_platform_init);; G% N4 y' ?( M* [' @6 G
module_exit(led_platform_exit);, P5 G8 ~2 N' r7 w; t1 Z! n
4 q3 h9 m0 D+ ~5 n3 |
MODULE_DESCRIPTION("Led platform driver");
4 @3 Z3 M: w! U. {3 f0 \5 v" MMODULE_AUTHOR("Tronlong");
* r7 c5 L+ E0 dMODULE_LICENSE("GPL");; _+ I4 {$ m6 k5 L& |8 k3 {
: l; J* L" V% ?4 n9 q9 R
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-11-12 17:23 , Processed in 0.062583 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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