3D Low Frequency Wakeup Receiver

Revision:
3:2de552c4ffbc
Parent:
1:944583d4b1de
Child:
4:10d482ca4eb1
--- a/AS3933.h	Wed Mar 07 15:04:16 2018 +0000
+++ b/AS3933.h	Wed Mar 07 16:43:51 2018 +0000
@@ -20,7 +20,67 @@
 /**
     Example:
 
-    [TODO]
+    #include "mbed.h"
+#include "AS3933.h"
+
+AS3933 myAS3933   ( PB_5, PB_4, PB_3, PB_8, 1000000 );                              // MOSI: PB_5 | MISO: PB_4 | SCLK: PB_3 | CS: PB_8 | FREQ: 1MHz;
+Serial pc         ( USBTX, USBRX );
+
+Ticker     newReading;
+DigitalOut myled(LED1);
+
+AS3933::AS3933_status_t  aux;
+AS3933::AS3933_data_t    myAS3933Data;
+uint32_t                 myState = 0;
+
+
+void changeDATA ( void )
+{
+    myState = 1;
+}
+
+
+int main()
+{
+    pc.baud ( 115200 );
+
+    myled   =   1;
+    wait(3);
+    myled   =   0;
+
+
+    // Clears the wake state of the chip
+    aux  =   myAS3933.AS3933_Send_DirectCommand ( AS3933::CLEAR_WAKE );
+
+    // Sets all register in the default mode
+    aux  =   myAS3933.AS3933_Send_DirectCommand ( AS3933::PRESET_DEFAULT );
+
+
+    // Update the wakeup pattern ( default value )
+    myAS3933Data.patt1b     =   0x23;                                           // Default value: AS3933::TS1_WAKEUP_PATTERN_PATT1B;
+    myAS3933Data.patt2b     =   AS3933::TS2_WAKEUP_PATTERN_PATT2B;
+
+    aux  =   myAS3933.AS3933_SetWakeUpPattern   ( myAS3933Data );
+
+    newReading.attach( &changeDATA, 1 );                                        // the address of the function to be attached ( changeDATA ) and the interval ( 1s )
+
+    // Let the callbacks take care of everything
+    while(1) {
+        sleep();
+
+        myled = 1;
+
+        if ( myState == 1 ) {
+            // Read the wakeup pattern
+            aux  =   myAS3933.AS3933_GetWakeUpPattern ( &myAS3933Data );
+            pc.printf( "PATT1B: %x ( 0x23 ) | PATT2B: %x ( 0x69 )\r\n", myAS3933Data.patt1b, myAS3933Data.patt2b );
+
+            myState  =   0;                                                     // Reset the variable
+        }
+
+        myled = 0;
+    }
+}
 
 */
 
@@ -968,7 +1028,7 @@
     /** It configures the correlator and the Manchester Decoder.
         */
     AS3933_status_t  AS3933_SetCorrelator                   ( AS3933_r1_en_wpat_value_t myCorrelatorMode, AS3933_r0_patt32_value_t mySymbolPattern, AS3933_r7_t_hbit_value_t myRate,
-                                                              AS3933_r1_en_manch_value_t myManchesterDecoderMode                                                                     );
+            AS3933_r1_en_manch_value_t myManchesterDecoderMode                                                                     );
 
     /** It sets the wakeup pattern ( Manchester ).
         */