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: main.cpp
- Revision:
- 4:4277898e55d8
- Parent:
- 3:7b1110501ef9
- Child:
- 5:25101883c27a
--- a/main.cpp Tue Mar 07 04:29:14 2017 +0000
+++ b/main.cpp Tue Mar 07 18:20:15 2017 +0000
@@ -13,8 +13,9 @@
DigitalOut led2(LED2);
Serial pc(USBTX, USBRX);
-//Mail<char (*) [256], 16> messageBox;
-Mail<char, 92 * 4> trameBox;
+Queue<int, 1500> envoi;
+Thread* listeningThread;
+
void printBin(uint16_t data)
{
@@ -267,8 +268,16 @@
void ReceiveBits(bool* data, int len);
void SendBits(bool* bits, int len)
{
+ // Emile
+ // thread.signal_set(0x1);
// Synchronize with wire
- ReceiveBits(bits, len);
+ for (int i = 0; i < len; i++)
+ {
+ envoi.put((int *) bits[i]);
+ }
+ listeningThread->signal_set(0x1);
+
+ //ReceiveBits(bits, len);
}
void SendFormated(bool* data, int len)
@@ -382,7 +391,7 @@
}
void ReceiveBits(bool* data, int len)
-{
+{
if (compareBoolArray(data, PREAMBULEBOOL))
{
data += 8;
@@ -406,6 +415,21 @@
}
}
+void Listening()
+{
+ while (1)
+ {
+ Thread::signal_wait(0x1);
+ osEvent evt = envoi.get();
+ if (evt.status == osEventMessage){
+ /*bool message = (message_t*) evt.value.p;
+ //ReceiveBits((bool *) message->bits, message->len);
+ envoi.free(message);*/
+ }
+ }
+
+}
+
extern "C" void TIMER2_IRQHandler (void)
{
if((LPC_TIM2->IR & 0x01) == 0x01) // if MR0 interrupt, proceed
@@ -433,9 +457,12 @@
void mainRaph()
{
init_clk();
- TestUtility();
- TestManchester();
+ //TestUtility();
+ // TestManchester();
+ SendText("A more complex sentence to prove our algorithm is robust!", 57);
+ wait(1);
SendText("OK", 2);
+ wait(1);
SendText("A more complex sentence to prove our algorithm is robust!", 57);
}
@@ -446,6 +473,9 @@
int main() {
Ticker ticker;
ticker.attach(&tick, 0.5);
+ listeningThread = new Thread();
+ listeningThread->start(Listening);
+
mainRaph();
while (1){}
}