看Freertos头文件Semphr.h的注释。) C% R8 @" u+ `8 z
2) Resource management.% Q) |0 L9 J1 L+ j% O8 f
* In this usage scenario the count value indicates the number of resources ' R1 f8 U4 R/ Q7 ^7 f4 C * available. To obtain control of a resource a task must first obtain a% Q; P. \2 L$ m% k) C
* semaphore - decrementing the semaphore count value. When the count value/ x5 a8 C$ V" D! h2 h- }& c! c# o, d
* reaches zero there are no free resources. When a task finishes with the + k) a# u! j8 J3 m: \ * resource it 'gives' the semaphore back - incrementing the semaphore count $ y1 y3 Z# w" v; Q, g4 x/ I * value. In this case it is desirable for the initial count value to be( }2 t' @, k. O1 T- C& G. [
* equal to the maximum count value, indicating that all resources are free.
刚刚贴的代码怎么不见了?再贴一遍头文件中的注释,很明了: L+ M r& G+ Z- g1 E
* Counting semaphores are typically used for two things:8 u) u; N- H9 X
* 4 A, n- Y; v4 }$ l. G6 |1 ]. V * 1) Counting events.& s# W9 y' B' ?# d: W- I
*. r5 C0 o: f$ p: j* I! u
* In this usage scenario an event handler will 'give' a semaphore each time $ s5 R5 ~/ `9 M4 ^' X& X( F! }8 ?. e * an event occurs (incrementing the semaphore count value), and a handler + @7 P: v+ D, z! u! D- X * task will 'take' a semaphore each time it processes an event X" H9 C( A/ J1 J
* (decrementing the semaphore count value). The count value is therefore W* @1 D( Z$ \+ I * the difference between the number of events that have occurred and the. Z. E8 c1 X2 ~* y
* number that have been processed. In this case it is desirable for the- ?: c& ^8 ?5 K! c( g7 G
* initial count value to be zero.+ f- @2 N3 o P3 T5 ~: O0 |" o+ [
*+ X& |' x( O* o& D. g. u0 q
* 2) Resource management. # i* O/ ?8 \! T * 1 y: \7 n9 l' f5 i; J: n * In this usage scenario the count value indicates the number of resources( U0 p: r! X6 Q! z+ \/ ~% J
* available. To obtain control of a resource a task must first obtain a : S E4 @1 Y) d4 [ q9 M4 J0 F$ H * semaphore - decrementing the semaphore count value. When the count value % _% F- k! {* z, c+ m * reaches zero there are no free resources. When a task finishes with the/ n1 X. @0 a6 L* K/ `- w7 }1 y
* resource it 'gives' the semaphore back - incrementing the semaphore count w. Q Z* I/ p6 o) C * value. In this case it is desirable for the initial count value to be 3 h8 x" f; {7 M * equal to the maximum count value, indicating that all resources are free.
看帖 应该 就知道很好用了 基本上 点几下鼠标就创建一个可以直接使用的 工程
那只是可用,效率怎么样呢
本人建议 库只用于 比较复杂的 外设初始化 比如 串口 ,SPI SDIO等等
# N* Q5 Q1 \1 `9 N, G- |
初始化完成之后的操作 建议使用寄存器
2) Resource management.% Q) |0 L9 J1 L+ j% O8 f
* In this usage scenario the count value indicates the number of resources
* available. To obtain control of a resource a task must first obtain a% Q; P. \2 L$ m% k) C
* semaphore - decrementing the semaphore count value. When the count value/ x5 a8 C$ V" D! h2 h- }& c! c# o, d
* reaches zero there are no free resources. When a task finishes with the
* resource it 'gives' the semaphore back - incrementing the semaphore count
* value. In this case it is desirable for the initial count value to be( }2 t' @, k. O1 T- C& G. [
* equal to the maximum count value, indicating that all resources are free.
* Counting semaphores are typically used for two things:8 u) u; N- H9 X
*
* 1) Counting events.& s# W9 y' B' ?# d: W- I
*. r5 C0 o: f$ p: j* I! u
* In this usage scenario an event handler will 'give' a semaphore each time
* an event occurs (incrementing the semaphore count value), and a handler
* task will 'take' a semaphore each time it processes an event X" H9 C( A/ J1 J
* (decrementing the semaphore count value). The count value is therefore
* the difference between the number of events that have occurred and the. Z. E8 c1 X2 ~* y
* number that have been processed. In this case it is desirable for the- ?: c& ^8 ?5 K! c( g7 G
* initial count value to be zero.+ f- @2 N3 o P3 T5 ~: O0 |" o+ [
*+ X& |' x( O* o& D. g. u0 q
* 2) Resource management.
*
* In this usage scenario the count value indicates the number of resources( U0 p: r! X6 Q! z+ \/ ~% J
* available. To obtain control of a resource a task must first obtain a
* semaphore - decrementing the semaphore count value. When the count value
* reaches zero there are no free resources. When a task finishes with the/ n1 X. @0 a6 L* K/ `- w7 }1 y
* resource it 'gives' the semaphore back - incrementing the semaphore count
* value. In this case it is desirable for the initial count value to be
* equal to the maximum count value, indicating that all resources are free.
是的 因为我的 资源一开始是不可用的 ) y5 Z% D/ S, g3 f8 f/ y# o" W* o
这是典型的 生产消费问题0 F: k% i- P; _& }2 `& ]3 y2 n
串口接收数据(生产) 9 f/ P4 ]2 {! r5 ^: ]
+ @5 h3 U6 w, H7 \ ^
线程消费数据
一开始是没有现成的数据的 " P+ |7 @# }; w4 l' u' x1 @# g# a
而这个 函数接口 只能以另一种方式使用那就是一开始就存在资源,这在实际使用中是不合理的!!
哈哈 你来晚了钱都被他们拿完了~~