Teste Flash

Dependencies:   pulga-lorawan-drv Si1133 BME280

Revision:
70:99b7a15c09da
Parent:
69:2d56b571c78e
--- a/main.cpp	Tue Jun 01 20:19:52 2021 +0000
+++ b/main.cpp	Mon Sep 13 18:55:32 2021 +0000
@@ -26,6 +26,7 @@
 #include "serial.h"
 #include "gps.h"
 #include "lora_radio.h"
+#include "SPI_MX25R.h"
 
 
 using namespace events;
@@ -110,73 +111,23 @@
     pc.baud(9600);
     pc.printf("config9600\n");
     //enable serial rx interrupt
-    pc.attach(&serial_post_to_queue, RawSerial::RxIrq);
-    gps_config();
-    gps_leBootMsg();
-    gps_config_gnss ();
     
     wait_ms(250);
-
-    //########################################################
-    // setup tracing
-    setup_trace();
-
-    // stores the status of a call to LoRaWAN protocol
-    lorawan_status_t retcode;
-
-    // Initialize LoRaWAN stack
-    /*if (lorawan.initialize(&ev_queue) != LORAWAN_STATUS_OK) {
-        pc.printf("\r\n LoRa initialization failed! \r\n");
-        return -1;
-    }*/
-    
-    if(lorawan_initialize_stack(&ev_queue) != 0){
-        return -1;
-    }
-
-    pc.printf("\r\n Mbed LoRaWANStack initialized \r\n");
-
-    // prepare application callbacks
-    /*callbacks.events = mbed::callback(lora_event_handler);
-    lorawan.add_app_callbacks(&callbacks);
-    */
-    
-    callbacks.events = mbed::callback(lora_event_handler);
-    lorawan_add_callbacks(callbacks);
-    
-    // Set number of retries in case of CONFIRMED message
-    if(lorawan_set_confirmed_msg_retries(CONFIRMED_MSG_RETRY_COUNTER) != 0){
-        pc.printf("\r\n set_confirmed_msg_retries failed! \r\n\r\n");
-        return -1;
-    }
-    
-
-    pc.printf("\r\n CONFIRMED message retries : %d \r\n",
-           CONFIRMED_MSG_RETRY_COUNTER);
-           
-    // Enable adaptive data rate
-    if(lorawan_enable_adaptive_datarate() != 0){
-        pc.printf("\r\n enable_adaptive_datarate failed! \r\n");
-        return -1;
-    }
-    
-
-    pc.printf("\r\n Adaptive data  rate (ADR) - Enabled \r\n");
-
-    
-    if(lorawan_connect() != 0){
-        pc.printf("\r\n Connection error, code = %d \r\n", retcode);
-        return -1;
-    }
-    
-    pc.printf("\r\n Connection - In Progress ...\r\n");
     
     _actuated_led =0;
     
-    //
-    // make your event queue dispatching events forever
-    ev_queue.call_every(TX_TIMER, GPS_Read);
-    ev_queue.dispatch_forever();
+    uint8_t data[2];
+    data[0]= 0xFF;  //byte qualquer
+    data[1] = 0xFF; //byte qualquer
+    
+    SPI_MX25R *flash = new SPI_MX25R(P0_20, P0_17, P0_22, P0_24);
+    
+    flash->writeEnable();
+    flash->programPage(0x191F50, data, 2);
+    
+    pc.printf("o numero foi: %d\n\r", flash->read8(0x191F50));
+    pc.printf("o numero foi: %d\n\r", flash->read8(0x191F51));
+    
     return 0;
 }