Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: quick_queue.cpp
- Revision:
- 10:c4629b6c42f8
- Child:
- 11:1d277e7e272d
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/quick_queue.cpp Sun Oct 15 23:13:18 2017 +0000
@@ -0,0 +1,91 @@
+
+#include "quick_queue.h"
+#include "mbed.h"
+
+radio_message_t out_messages[MESSAGE_BUFFER_SIZE];// = { 0, 0, 0, 0, "0", 0, 0};
+int out_output_index = 0;
+int out_input_index = 0;
+
+radio_message_t in_messages[MESSAGE_BUFFER_SIZE];// = { 0, 0, 0, 0, "0", 0, 0};
+int in_output_index = 0;
+int in_input_index = 0;
+
+// Utilise pour aller chercher une pointeur vers un message a remplir pour l'envoi
+radio_message_t* get_new_out_message(){
+ if ((out_input_index + 1) % MESSAGE_BUFFER_SIZE != out_output_index)
+ {
+ return &(out_messages[(out_input_index + 1) % MESSAGE_BUFFER_SIZE]);
+ //return true;
+ }
+ return NULL;
+}
+
+// Inique que le message courant est pret a etre envouye
+bool new_out_message_ready(){
+ if ((out_input_index + 1) % MESSAGE_BUFFER_SIZE != out_output_index)
+ {
+ out_input_index = (out_input_index + 1) % MESSAGE_BUFFER_SIZE;
+ return true;
+ }
+ return false;
+}
+
+// Utilise pour aller chercher le plus vieux message en sortie
+radio_message_t* get_last_out_message(){
+ if (out_output_index != out_input_index)
+ {
+ return &(out_messages[(out_output_index + 1) % MESSAGE_BUFFER_SIZE]);
+ //return true;
+ }
+ return NULL;
+}
+
+// Indique que le message a ete envoye
+bool last_out_message_read(){
+ if (out_output_index != out_input_index)
+ {
+ out_output_index = (out_output_index + 1) % MESSAGE_BUFFER_SIZE;
+ return true;
+ }
+ return false;
+}
+
+// Utilise pour aller recuperer un nouveau message a remplir pour la reception
+radio_message_t* get_new_in_message(){
+ if ((in_input_index + 1) % MESSAGE_BUFFER_SIZE != in_output_index)
+ {
+ return &(in_messages[(in_input_index + 1) % MESSAGE_BUFFER_SIZE]);
+ //return true;
+ }
+ return NULL;
+}
+
+// Indique qu'un nouveau message est pret en entree
+bool new_in_message_ready(){
+ if ((in_input_index + 1) % MESSAGE_BUFFER_SIZE != in_output_index)
+ {
+ in_input_index = (in_input_index + 1) % MESSAGE_BUFFER_SIZE;
+ return true;
+ }
+ return false;
+}
+
+// Utilise pour aller chercher le dernier message pret
+radio_message_t* get_last_in_message(){
+ if (in_output_index != in_input_index)
+ {
+ return &(in_messages[(in_output_index + 1) % MESSAGE_BUFFER_SIZE]);
+ //return true;
+ }
+ return NULL;
+}
+
+// Indique que le dernier message a bien ete lu
+bool last_in_message_read(){
+ if (in_output_index != in_input_index)
+ {
+ in_output_index = (in_output_index + 1) % MESSAGE_BUFFER_SIZE;
+ return true;
+ }
+ return false;
+}
\ No newline at end of file