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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。; S0 o! f3 e! M' t/ Q; Y
#include <linux/init.h>
, z9 o& \/ A, W9 K# ?$ M* h2 W#include <linux/module.h>0 k8 A( b1 |3 K
#include <linux/kernel.h>2 d. l1 i8 x4 l8 j* @
#include <linux/types.h>  g9 m% v+ L# [; C" A! B$ T
#include <linux/gpio.h>
; I2 s* g7 E* O2 j6 ~#include <linux/leds.h># }2 }% S) E$ k  R! n* Y% X0 Q* ?0 l
#include <linux/platform_device.h>) z& p3 a' c5 Q( s* \

+ h0 T- K' R3 A/ g' O! P* i7 k#include <asm/mach-types.h>" W4 H/ S1 B& J$ [
#include <asm/mach/arch.h>
- T; u3 ?) f- v& c: n6 e1 y" T#include <mach/da8xx.h>
8 }+ o5 t7 d5 V) q- B% ?#include <mach/mux.h>* J0 ]1 ?' `' ~

$ n) u2 p- j/ O' T#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
9 d0 T: U8 o1 s, d- ^#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
, ?+ H& `9 y7 D) w; Z, F#define DA850_USER_LED2        GPIO_TO_PIN(0, 1). i* g) {; b9 T7 g! f( W; a! h
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)3 E8 n  `, X; Y: U# p* [
3 A% a) `  f. G
/* assign the tl som board LED-GPIOs*/: P) F. R# C' A$ o7 n- o9 V
static const short da850_evm_tl_user_led_pins[] = {, k) h* \+ t; I# d/ V
        /* These pins are definition at <mach/mux.h> file */
3 d0 F  u9 C! N8 M% }, T- K# f$ k# z        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,$ |: F/ h# ~3 t2 U! t( z
        -1, G( U$ U% w0 E* y) g: a9 i
};% X' y" b2 U0 r( E9 B

! R) b, C) v8 h" nstatic struct gpio_led da850_evm_tl_leds[] = {. R- a3 }- B! @0 Q$ _" @+ ]5 M: t/ ~
        {
$ p# O1 s' S2 m  k7 J& f+ z                .active_low = 0,
, Q+ y" ^3 }: h- l! D7 b                .gpio = DA850_USER_LED0,- @: Y9 A" `4 a  N
                .name = "user_led0",% _5 w3 r/ M  S! ^
                .default_trigger = "default-on",8 L) G4 ]1 U' o  a* I( z
        },
) H9 j7 [6 b- E, u3 M' Z& S        {) X6 Y0 K( R/ f* H# L
                .active_low = 0,
$ ?) B3 |1 X! B- S7 I: O6 }                .gpio = DA850_USER_LED1,1 w' R/ a6 G2 q8 i: H* a
                .name = "user_led1",9 E6 Z& [6 C  R7 A& c
                .default_trigger = "default-on",
2 r* ?) S/ V- w  ]3 a: i6 q        },8 N+ c$ K4 r$ t0 [; _
        {
( D: J- f+ o1 w                .active_low = 0,
3 M- s0 w3 T# ]4 \' K. m' D5 e4 y                .gpio = DA850_USER_LED2,* t7 A7 u3 R! Z% S$ r) s3 s
                .name = "user_led2",
; u7 t& H1 s! ^8 _+ H$ K# {/ n) @                .default_trigger = "default-on",
7 l2 |( N2 I/ s6 U6 E" O        },( c4 j) p1 Z6 F+ Q) Y7 Z7 u% v
        {  @2 X0 E4 Y1 ]  q$ B
                .active_low = 0,% F. Y! ^9 n, [( R
                .gpio = DA850_USER_LED3,6 J0 o' S2 G3 A, p/ G6 h
                .name = "user_led3",/ A2 G: B( H1 w
                .default_trigger = "default-on",
% B& ^4 I7 K5 c        },6 V8 r8 x: Q( u1 T
};' W) [4 G, \0 a3 t0 H

" V& `% E2 b4 W+ c" J  xstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
+ k5 E8 ]. y# \. [! C6 M        .leds = da850_evm_tl_leds,
% J/ S# H5 e1 G9 e        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),+ ^1 S) R( Q6 N6 J
};
# z" [+ y: z" T# Q/ ~
1 Z" C  K6 Y# H2 F: r4 m% istatic void led_dev_release(struct device *dev)
) V0 j, m. s! K6 n# m! T6 w{- f& I4 R3 J3 @. [3 G
};: ~3 Z! l2 J$ i. ?
. [' D$ ]: p$ o# }" b
static struct platform_device da850_evm_tl_leds_device = {
) D% r1 u" P* h8 ]- U7 b: f* v        .name                = "leds-gpio",
' |" a( }4 E, p* \; c' f        .id                = 1,# v) [/ X- c3 n7 S5 ~1 p
        .dev = {* P/ k1 S7 R8 l
                .platform_data = &da850_evm_tl_leds_pdata,
" I: s, D2 g, l3 h5 Y6 r8 n. s7 K                .release = led_dev_release,0 w  N. r! e9 L3 H
        }
0 ^5 K2 o3 p+ @8 P1 b};
2 R# j7 V; }. [7 h
. _0 ?: |) m! \4 e) W; d0 m4 W- bstatic int __init led_platform_init(void)
0 E" E1 L! F( A' G- k- ]{
  r4 L# {- j# j) I- P        int ret;
4 f% K6 M( ]  N" k7 B#if 0! d( l" O$ c# |; d' I7 }
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);0 S; k3 G$ J) i3 j4 w
        if (ret)
4 |6 S1 |5 N+ o                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
! u3 N; j' y5 X5 x! h                                "%d\n", ret);2 v' {, r4 j/ I( g$ U+ r
#endif
/ I) r7 @3 o& B+ B0 C! e        ret = platform_device_register(&da850_evm_tl_leds_device);- P. a2 V5 ?  F5 e* g7 x6 Y
        if (ret)
' c4 B) w' k5 j3 y& {                pr_warning("Could not register som GPIO expander LEDS");
8 l7 r+ ^3 Q$ K6 x. ]( A  C        else
& k6 P" Z  x9 i+ k1 l- m- W                printk(KERN_INFO "LED register sucessful!\n");# D! f" k  L  ]" S) E1 Z

0 r: d1 w4 Q' r/ }5 o  V  |! }, L( p% r        return ret;
7 k; Y/ `: X, G3 k, F. O  M- g}% u1 P) s5 C. z9 J( R
$ s) S; l: M) W
static void __exit led_platform_exit(void); m- g4 d% f2 `; d
{
/ y8 N: R  E( k4 z; `        platform_device_unregister(&da850_evm_tl_leds_device);
) Y' Q7 [! o3 e2 K, R1 N$ o, \
' u9 k' k( W; S+ T$ ~        printk(KERN_INFO "LED unregister!\n");
" V3 o# p( z  a& O}
$ @) ]9 D- A1 |$ O: E# ?# ?* `% T) c
module_init(led_platform_init);
1 }9 ?; W1 Y. u' tmodule_exit(led_platform_exit);
0 l! e$ L9 L$ k4 d% |- g1 H- w5 W( \+ A3 w- q; M
MODULE_DESCRIPTION("Led platform driver");  m0 n6 \9 K$ y! o( e5 g
MODULE_AUTHOR("Tronlong");
0 A  ~/ m0 y; X2 O" jMODULE_LICENSE("GPL");
/ x6 T, Y& R4 q& R. x9 w+ `- ~4 k4 ^! a* d8 K
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-2-19 00:28 , Processed in 0.039382 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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