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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。: p, ]+ M* ~2 h( K
#include <linux/init.h>
* r! _0 l+ c* @7 a. I#include <linux/module.h>% |  p) G4 J! P8 d8 ?0 Q
#include <linux/kernel.h>
$ E5 E1 ~4 u8 k# D' i$ C$ x, \8 p. G#include <linux/types.h>  q8 u6 x; H! W3 m
#include <linux/gpio.h>" D- A, }# _) L/ n/ i
#include <linux/leds.h>
2 p8 F$ \* B7 e# h#include <linux/platform_device.h>
  U$ m, o" |0 u# s6 g/ Q
6 {- ~# b; ~. X2 Q; m5 j#include <asm/mach-types.h>0 N! ~/ H( F% ]6 T
#include <asm/mach/arch.h>% m1 k( B( C+ N: f8 `; W
#include <mach/da8xx.h>
9 U1 ?( p- {' g1 O  U#include <mach/mux.h>7 b; U6 k0 J' }% c+ D

' ?( P* U; n( O1 |  E+ k- j#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)/ r9 Y7 n# ^, C3 K( x" B/ X
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)& H$ m# E0 _3 ]
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)9 D0 \# b5 \6 T( L, ~$ j
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)- y) R8 r* r8 s9 L: u

" v. G2 \. |6 u8 H  F/* assign the tl som board LED-GPIOs*/
# F/ M. U" t# Xstatic const short da850_evm_tl_user_led_pins[] = {
( a  H& M% c) F5 n        /* These pins are definition at <mach/mux.h> file */$ K5 W  t' R7 H2 e4 B
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,& z" v% H: @: B6 r3 `0 d7 j
        -17 ]. ?. o4 Q6 `8 e
};* T0 D! q5 p/ z( B+ G% }( t8 l
6 V4 |( U" U% X3 b) n
static struct gpio_led da850_evm_tl_leds[] = {/ D9 F" K+ L) K7 v* d3 t
        {2 p. c, v1 S, D% t
                .active_low = 0,& g6 n6 K6 s2 y$ s8 j, t# X
                .gpio = DA850_USER_LED0,4 ~8 g6 @4 h7 ^) O. ~+ e. o4 w
                .name = "user_led0",# D/ O1 w+ p  K
                .default_trigger = "default-on",5 a1 V0 i* q0 A3 e6 z. L
        },
4 o+ P& c" L- N4 {0 c        {0 f% t1 \3 H5 @. I' G& Y  ?
                .active_low = 0,/ y# c& v- R/ b0 P3 ?* l* n3 u
                .gpio = DA850_USER_LED1,& U1 N7 X1 ]7 a$ ~+ E1 [" M& K1 J7 `
                .name = "user_led1",) ^0 \% o3 Y5 h7 q, \% r$ p" q
                .default_trigger = "default-on",
+ k! l7 n$ v8 k+ `        },3 G8 _: z& ?# E! B7 Z3 T- T
        {+ t, N( P& d( }& y' ^
                .active_low = 0,' w: s) n8 h) Z6 ]6 F
                .gpio = DA850_USER_LED2,  H  ]5 m: d# b
                .name = "user_led2",- y- |$ f# D; S1 z) S/ a
                .default_trigger = "default-on",
# S( N, _2 R, n" o, f        },: L, h: L" `6 E! p  W! a
        {
- U! F" K: [+ I6 q+ i0 s                .active_low = 0,3 {( i5 a8 z: m1 P
                .gpio = DA850_USER_LED3,8 Q' a9 A; G! n1 z& d
                .name = "user_led3",
5 e6 _  d# _4 u& f- N4 }" Q                .default_trigger = "default-on",
+ ?; f5 p# I  P. ?: x        },
5 U. ?8 Y8 m8 C  f2 H* ]' B4 f9 J0 H};
" ~& O9 o$ ]( q+ _1 @0 ^6 H
8 G3 p6 x5 j0 ostatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
, _8 q9 N8 W8 A& |  ~" H5 w' T' f        .leds = da850_evm_tl_leds,! o, ]5 s, u9 A
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
2 k9 u% J- L  ]) T; g2 _};1 S$ P) M/ W% Y" o2 T
( R3 I$ u  s* W  W, r) N+ `- F0 t
static void led_dev_release(struct device *dev)
: X7 j0 _8 H1 j" ~{' |4 J$ x6 H, k4 s6 L1 d5 }
};0 g8 f4 O# G* `8 X

; l! N7 X% J. o5 Qstatic struct platform_device da850_evm_tl_leds_device = {
& [2 K" |/ G( D3 g$ f) G, Q0 R        .name                = "leds-gpio",2 R0 N, g' k0 {" P) W; i4 D, p6 b$ d
        .id                = 1,8 e) @6 p: i, a9 }& G# O( e0 ^
        .dev = {
$ B/ D% W7 ^5 U# P( Q                .platform_data = &da850_evm_tl_leds_pdata,
) g; C# Y  j4 ^; o# l, h! l                .release = led_dev_release,
8 s! s& M$ x  ^2 i+ t        }* Z" d  e; a0 ?+ R5 v
};
! M7 k, [, ~8 y0 H. y: o' e+ _; ^# b+ Q3 w0 ^+ D
static int __init led_platform_init(void)
4 N; {" g! w* W$ J! p9 C{
' W, u0 S+ G& S5 m" u        int ret;
7 A: s) d9 D2 O2 k" I' x#if 07 y. R6 P+ Z' c3 U
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
9 L* i' U7 N1 q6 K5 `        if (ret), m' W" H/ y9 M8 {' I9 N  i! s
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"$ O* Y# h. T8 D. `$ L+ T
                                "%d\n", ret);9 z6 I- g7 h, ?5 O& X* Z/ I
#endif, ?0 q4 s+ L& j" y# c  Z6 A: {
        ret = platform_device_register(&da850_evm_tl_leds_device);& y  C+ ]( [0 O, a
        if (ret), d7 r% h3 A$ ^7 `3 `* H  v' v/ t
                pr_warning("Could not register som GPIO expander LEDS");9 E5 V4 f% g  q; |5 e
        else" M5 s( |; O* @5 ~6 l8 I
                printk(KERN_INFO "LED register sucessful!\n");
+ s* w5 X3 `3 @8 `" \! y! t6 }  a& ^
        return ret;
5 a6 m4 C+ X) u& F9 ^" z}
/ Y7 \- R5 F( E% E+ B1 F# B* U; R+ I/ m" ?0 s
static void __exit led_platform_exit(void)
, D% ^# t- ~/ ?' k0 t{
' ?2 {3 a+ b8 p: H1 i        platform_device_unregister(&da850_evm_tl_leds_device);
4 k. Q( `; R% y& w* Z+ k! E0 ^: G) s/ X7 v, G1 Z
        printk(KERN_INFO "LED unregister!\n");
+ ?9 w5 m- P3 f5 t/ }/ Z. n  O}& X  S4 K, q5 v: l0 K

: k9 \% D' f( G6 L/ R* B0 `module_init(led_platform_init);, p3 |5 ^# T- X% C% }* ~+ G5 W
module_exit(led_platform_exit);
+ K& j1 I2 F  ^& d) K( G- t- t6 I3 S$ b
MODULE_DESCRIPTION("Led platform driver");
# z( O, l  _4 s8 {4 w. bMODULE_AUTHOR("Tronlong");
/ G+ U- t0 l4 O9 l' {2 u' [MODULE_LICENSE("GPL");, t# h: k$ [; i$ B) T! m
6 n7 S" G& C1 R. j, r! D
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-10-7 08:26 , Processed in 0.039207 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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