我使用easylink配网时在函数里加了读取时间线程就配对不上网,线程去除(红色部分)就能正常配对连网 - 问答 - 电子技术论坛 - 最好最受欢迎电子论坛!

我使用easylink配网时在函数里加了读取时间线程就配对不上网,线程去除(红色部分)就能正常配对连网

许华 ( 楼主 ) 2017-4-18 17:25:36  只看该作者 倒序浏览
/*************************************************
2 f9 B# r$ B/ [+ u/ b * Function:  RTC初始化函数! ~1 s& n% p& K5 }/ m7 o8 M: ^3 H& J6 ^
* parameter- d3 L/ Q; u( t+ d# M! d
* Return& D7 }7 }4 S* J# c' Z2 P: t
* Modify:( i9 C7 I* i4 ?# F) P" ]  T) [
**************************************************/, x& n  U5 i% o* v
void RTC_Time_Init(void)( q: F; ]- |$ M$ Z; N& p
{
! e: e" E' U4 d9 Y! j  cur_time.year = 17; //设置时间0 f$ V8 @, J- E& W0 ^
  cur_time.month = 3;' V* Q3 [2 }7 C- s/ n7 @
  cur_time.date = 23;; q. y3 F- Q, |% q9 d
  cur_time.weekday = 4;3 Q$ x/ i4 b9 h% Z0 p! ]
  cur_time.hr = 23;# a3 j  Y- B: H! B$ F. k
  cur_time.min = 58;
0 o, v: H; n& g+ A9 R8 a7 z/ x  cur_time.sec = 0;
/ i6 y; Q# M2 Z# x  Time_Run.WeekDays_DATA =cur_time.weekday;5 y3 ]( r/ }  W! H# w- R, E- U
  MicoRtcSetTime(&cur_time);            //初始化 RTC 时钟的时间
+ x/ ^9 Y  l8 Q, \}
3 K8 u# G' S- x( k% G- e6 g( t/*************************************************3 A, E; U0 n) J" X7 I
* Function:  RTC时间允许读取函数8 F/ t6 M" {% x! b% a( Y
* parameter
2 ?( e) t7 k) Y * Return
9 W" f* {) J9 P4 R: [/ s- q * Modify:
6 ~) e+ r, j. @0 @0 h" x, g' a**************************************************/- Y( ?( F4 K; k! Z0 E5 s9 H
void RTC_Time_Run(unsigned int arg)3 k/ A1 w& q" s0 x
{
& a, H* n/ L2 z% O  RTC_Time_Init();4 A% Y" z: p( \; q1 G- @+ L$ N0 z
while(1)
, _& p" U% }# J: P# O) D7 O1 w {0 Q* U" }7 h; E  G
  MicoRtcGetTime(&cur_time); //返回新的时间值$ _7 l5 V2 p9 q! i& J1 h
}
& f% x& s7 _. p' ^}
- d# [2 b" K# P) D6 @# p9 rint application_start( void )
; \; v9 Z8 s3 o{
8 t$ N* c8 C! c# c6 C; Q8 A  OSStatus err = kNoErr;
0 ~9 [& R5 h% f$ \! T. f" d( E1 H' f9 b: K$ ?- j
  MicoInit();: q+ K. m! b& p4 Q
. `# C6 |: T, g3 V) M4 x# r2 ]$ p
  /* Start MiCO system functions according to mico_config.h,
; D* c2 Q( Z# n5 T: r     Define macro MICO_WLAN_CONNECTION_ENABLE to enable wlan connection function% S: u; V7 d) w% Z& s0 b
     Select wlan configuration mode: MICO_CONFIG_MODE) S8 W3 k$ G/ T5 ]9 o% g
     Define EasyLink settings */
: d/ V# N& |5 z: E  err = mico_system_init( mico_system_context_init( 0 ) );. [$ d3 b: B* I& u5 U3 I# Y

+ M- w$ s  U/ u* J5 c% h  /* Register user function when wlan connection status is changed */0 d( T! Q( F/ _8 s0 {: |, }
  err = mico_system_notify_register( mico_notify_WIFI_STATUS_CHANGED, (void *)micoNotify_WifiStatusHandler, NULL );
4 ]# F4 I. F  }2 T
  N; p( I) g3 }. s  `. Z  /* Register user function when wlan connection is faile in one attempt */; U' {, L1 M  A
  err = mico_system_notify_register( mico_notify_WIFI_CONNECT_FAILED, (void *)micoNotify_ConnectFailedHandler, NULL );
' x- E" M. B: I' |$ \) w( @& F/ U ' T! Z0 }/ _( x7 x3 b4 v
  ext_rgb_led_log("rgb led conrtol demo(RGB_MODE)");
# E' `; h4 W" _2 `1 g7 t; J  /*创建一个时间运行线程*/* m# W- V. n* P) [
  err = mico_rtos_create_thread(NULL,MICO_APPLICATION_PRIORITY,"RTC Time Run",RTC_Time_Run,200,NULL);//创建并启动一个新的线程3 G1 X+ S. M/ [! B8 A
; O% e. @! q# j. N0 a! @$ {
  /*初始化 RGB LED(P9813)*/
$ c+ P6 l& p4 w1 Q  rgb_led_init();
5 M5 `6 b2 t7 V7 Y! N$ t" ^% i0 L6 _  MicoGpioOutputHigh(MICO_RF_LED);
9 r2 e; I+ O' w( E) J3 [, I  //while(1) {
4 Y- Z' H6 u, y4 y  /*RGB LED亮红灯,#FF0000*/
- V- [0 K, B1 m- W/ m  //  rgb_led_open(255, 0, 0); : l# D9 G5 w, d  J( x
  // mico_thread_sleep(1);. J' s, Z7 Y  [' e" K3 G9 G
  /*RGB LED亮绿灯 #00FF00*/
/ p! O2 h( N9 s$ \$ I- C  //  rgb_led_open(0, 255, 0);
) q2 H0 Q* U* \- G$ y* P7 L0 ~  //  mico_thread_sleep(1); 4 A- C. R: L1 Z; R  V" O( i
  /*RGB LED亮蓝灯,#0000FF*/ 8 \) Y0 x1 H4 i' B
  //   rgb_led_open(0, 0, 255); % E6 q1 t; P# \
  //  mico_thread_sleep(1);
  B. e. j  ?1 `3 {0 f  // }*/
6 _5 L4 y& ~# e2 ?% B1 R  /*LED1初始化*/
; f: r/ u' C& C1 P4 `  err = RUN_LED_init();
: s' e! B  W7 D
3 n9 ]# \8 P) A. {1 A( K0 D. o  /* 初始化 直流电机 */, i1 \& D) L+ d0 P& c2 ^9 ~- O
  err = dc_motor_init();
+ U7 ~: F: s" x- y$ h) @; d+ V; E2 c
& \5 B: x7 Z# P8 u( M5 B
  /*初始化 温度 湿度*/ 8 b2 n, j" ?. M4 W7 r' s1 _
  err = DHT11_Init();% u7 M$ F5 M. v' _+ S! u6 K

0 }. @# m. P' u1 u6 d9 j; n- m) P  e7 D' ?! X5 m  o% m
  /*初始化 光发射二极管*/
$ t- }* ^) J% O1 ^  OLED_Init();0 [* s# d; i% N) a+ }/ v
  OLED_ShowString(0, 2, " Le Ju Le Yun");
2 R( C, g, L0 v+ b& e/ j
, b3 @3 P" {3 f- |  /*初始化光强传感器*/ 4 a. \: f; O# o. ^+ @% K
  err = light_sensor_init(); : I$ x: W) Z4 z7 d; Z4 G/ k

; W& r4 m1 H8 M! l$ Q+ k  /*按键初始化*/
6 \& k/ G8 k0 G; n& J( p0 [% x/ a  GPIO_KEY_Init();$ J7 R3 p8 Q7 W& A; @

7 w4 E3 j: N4 p& d9 n; b! n, H6 `8 y  mico_rtos_delete_thread(NULL);
; [3 ]# [6 [: L  return err;% m+ L0 L& g+ w
}
" g# v4 m# s) r, F. W; U, F; ^0 h+ K: U) c
9 u1 R) v" W" J/ I+ w7 p

1个回复

许华 发表于 2017-4-19 16:34:17
问题已经解决了,RTC_Time_Run休眠没有,easylink线程根本得不到CPU资源运行代码。
您需要登录后才可以回帖 登录 | 注册

本版积分规则


关闭

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

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

GMT+8, 2024-5-9 09:45 , Processed in 0.573587 second(s), Total 65, Slave 46 queries .

Powered by 电子发烧友网

© 2015 bbs.elecfans.com

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