关于STM32单片机的问题2 - 问答 - 电子技术论坛 - 最好最受欢迎电子论坛!

关于STM32单片机的问题2

wangxd5429 ( 楼主 ) 2015-11-17 08:16:05  只看该作者 倒序浏览
; y) g% k" ~9 N. m1 M" O9 B
各位高手,小弟正在调试一个基于WIFI控制电机的应用。操作系统是mico,开发板是mico-3165。庆科提供了TCP server的源码,测试这个源码时发现,没有执行连接AP的操作。单步调试这个源码,进入mico_system_init.c这个文件中的mico_system_init函数,继续单步调试,运行到“#ifdef
" Q! a# {) h* o' z4 K( U
MICO_WLAN_CONNECtiON_ENABLE”,mico_config.h中已经定义了

( U, r  C5 t; u( g' w1 a' C  C) W
MICO_WLAN_CONNECTION_ENABLE这个宏,但是系统没有进入这个分支运行,而是直接跳转到了最后一行“return err”,请教各位高手其中的原因。谢谢。mico_system_init函数的源码如下:

  D# k; h' F$ Q; Z! G& j0 ?
OSStatus  mico_system_init( mico_Context_t* in_context)

* i5 g* N3 S/ g  A
{
% s! i2 Z. \8 i" O, p
OSStatus err = kNoErr;

3 e$ q/ j1 i0 I
/ o6 ^5 Y4 D* N; j3 {2 _
require_action( in_context, exit, err = kNotPreparedErr );

- U1 N# l/ b+ ^- g5 [2 H/ L0 d4 d

+ Q8 V# A" c7 F7 H5 l% H5 h! d) ~; R
/* Initialize power management daemen */
' \$ U# d, O7 B5 ]
err = mico_system_power_daemon_start( in_context );/*启动电源管理后台*/

9 o4 H. b0 l6 K7 q, A
require_noerr( err, exit );
8 m! K7 R( B3 w5 v2 [& `/ q
# N! a7 O- S& {; O2 ~7 i1 R
/* Initialize mico notify system */

" V0 Y* a& h1 w- l1 _% g  i" V: C
err = system_notification_init( in_context );/*初始化通知事件回调机制*/

7 h+ ?; e$ J+ W" A1 ?' W' [
require_noerr( err, exit );
8 H3 L7 q0 @7 f; U6 [
5 Z' f& O- ]6 C) \- H* y
#ifdef mico_system_MONITOR_ENABLE

4 R2 N: N0 ^) X9 _* V/ }$ i- H
/* MiCO system monitor */

, ~* y* ]: F4 C2 Q
err = mico_system_monitor_daemen_start( );

4 W% c, j* Y6 u& [& d! F0 g
require_noerr( err, exit );
# l' Q) v# A" l( ]! v7 v+ Z
#endif
& N4 i+ E: _9 C- _5 ~
; ~. H! ]- [% q' s
#ifdef MICO_CLI_ENABLE

5 R) E' ], u7 M4 X+ N; l
/*初始化命令行接口, MiCO command line interface */

4 c, U7 o: d- |* T- s( y) B2 x
cli_init();
$ C$ H; j2 o! g: s
#endif

. @5 m3 W& T. M/ ]

3 U/ E. p( C$ X% c: }/ X4 ~
/*网卡驱动和TCP/IP协议栈初始化, Network PHY driver and tcp/ipstatic init */

2 [& ]8 Y. {) [" Q
err = system_network_daemen_start( in_context );

+ y1 Z  E  G: X0 ?; [. R
require_noerr( err, exit );

* R0 w$ ?. f) ]& G& ^/ N4 l! E
0 D$ _6 S' n9 S
#ifdef USE_MiCOKit_EXT
" v' a3 j" l- n
/*如果按键按下,则测试扩展板. user test mode to testMiCOKit-EXT board */
& k- e8 y+ R; n. V% D# b
if(MicoExtShouldEnterTestMode()){
6 j( s  ^, W* m2 u0 f8 V+ O' R1 I
   system_log("Enter ext-board test mode by key2.");
$ k" e, `/ u. {( x% Z; i( M: p
   micokit_ext_mfg_test(in_context);

6 B" u4 O8 h9 p' c0 p' k; u
}
3 D; `/ J4 T8 k$ f
#endif

0 K. u# a* G5 }& a: Z# C

6 c0 P) m6 g4 u7 h  P
#ifdef MICO_WLAN_CONNECTION_ENABLE

  j9 |2 j6 l7 X) I* l
if( in_context->flashContentInRam.micoSystemConfig.configured ==wLanUnConfigured ||
; c0 W! P8 l5 A, _
     in_context->flashContentInRam.micoSystemConfig.configured ==unConfigured){
5 E; \8 F7 ?" I: ~
   system_log("Empty configuration. Starting configurationmode...");

1 _* t9 L) \$ ^! J+ P. O

+ v3 x- n2 d' f' g& d+ |
#if (MICO_CONFIG_MODE ==CONFIG_MODE_EASYLINK) ||
5 w! ]; o3 i9 C. ^. y
   (MICO_CONFIG_MODE == CONFIG_MODE_SOFT_AP) ||  
, C6 f6 g( B4 U5 y
    (MICO_CONFIG_MODE == CONFIG_MODE_EASYLINK_WITH_SOFTAP)
% y+ |! _8 p' B2 j+ u
   err = system_easylink_start( in_context );/*启动EASYLINK*/

- e) A' j# ^0 o1 f# M1 x3 [9 X- u( U: O
   require_noerr( err, exit );
1 I( u4 t  ^( n) @1 h) ]% ?# a6 ?: D
#elif ( MICO_CONFIG_MODE ==CONFIG_MODE_WAC)
2 h5 j% }# {- {8 }% S8 Q
   err = mico_easylink_start( in_context );
1 M5 j* V; E  V
   require_noerr( err, exit );

2 ^7 `. O, x7 }+ ?, w  q7 T) I
#else

. h; [1 D# o. ]& q' Z2 H9 [2 e
   #error "Wi-Fi configuration mode is not defined"
6 d& C6 w) Q+ w! z" X* U
#endif
9 r% i7 f' `" e  r0 ~
}

8 n7 m2 {( f) S: x9 l- O! c9 g
#ifdef MFG_MODE_AUTO

0 Y$ h$ I% E0 b! n
else if( in_context->flashContentInRam.micoSystemConfig.configured ==mfgConfigured ){
# L* I( I' G  e
   system_log( "Enter MFG mode automatically" );

! Y" W: U* B$ P( A8 Z
   mico_mfg_test( in_context );
& }" n# Z- {2 S2 F- _
   mico_thread_sleep( MICO_NEVER_TIMEOUT );

9 g' s! ^6 S9 Y: b
}

3 B4 b8 {7 t' Y  v, M9 e
#endif
; U0 ^; V8 H1 n- }3 ]: m
else{
- m  }) ?" r) ?+ K8 k& e: Z
   system_log("Available configuration. Starting Wi-Ficonnection...");
# D% R: n, O/ g; q! D* J# r
   system_connect_wifi_fast( in_context );/*建立WIFI连接*/
1 a. a& [  k7 v
}
" ~* J9 Y& N" i) C! p' u
#endif
- {9 K/ S* }6 U: D1 c& H- a8 l

1 m( U2 O# T$ m
/*Local configuration server*/
) t9 Y8 H! n: r7 i$ r# N6 j
#ifdef MICO_CONFIG_SERVER_ENABLE

: T% o$ b6 f( c6 k7 x
config_server_start( in_context );/*创建本地配置服务器*/

: ]5 f/ ~: C$ y5 G" B
#endif

- ?. `: P9 S2 l8 F

% X: ?6 Q9 a: L! {% z4 I0 R* u
require_noerr_action( err, exit, system_log("Closing main threadwith err num: %d.", err) );
( z- U) Y2 ]3 Z8 s7 W" |+ p8 U
exit:
" S% @7 s  I0 E& t# ^

/ T9 F: l7 i9 x+ t2 @
return err;
}
! v0 v9 V4 G8 r: G" d* Y

0个回复

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

本版积分规则


关闭

站长推荐上一条 /6 下一条

小黑屋|手机版|Archiver|电子发烧友 ( 湘ICP备2023018690号 )

GMT+8, 2024-4-20 03:45 , Processed in 0.322868 second(s), Total 34, Slave 24 queries .

Powered by 电子发烧友网

© 2015 bbs.elecfans.com

微信扫描
快速回复 返回顶部 返回列表