EZR

Dependencies:   CRC16 FreescaleIAP FreescaleWatchdog GGSProtocol LM75B PIMA Parameters PersistentCircularQueue SerialNumberV2COM mbed-dev-watchdog_2016_03_04

Fork of smartRamalKW by Equipe Firmware V2COM

Files at this revision

API Documentation at this revision

Comitter:
fprado
Date:
Thu Feb 25 21:32:17 2016 +0000
Parent:
31:ef0e073126a1
Child:
33:dbf211068191
Commit message:
- Adicionada compila??o condicional para inicializa??o do watchdog na mbed-dev; - Adicionadas fun??es de verifica??o dos dados gravados e lidos da flash externa e de blank check;

Changed in this revision

at25sf041.lib Show annotated file Show diff for this revision Revisions of this file
cmd/gravarUpdate.cpp Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
settings.h Show annotated file Show diff for this revision Revisions of this file
--- a/at25sf041.lib	Wed Feb 24 14:31:25 2016 +0000
+++ b/at25sf041.lib	Thu Feb 25 21:32:17 2016 +0000
@@ -1,1 +1,1 @@
-https://developer.mbed.org/teams/Equipe-Firmware-V2COM/code/at25sf041/#dac96f40034e
+https://developer.mbed.org/teams/Equipe-Firmware-V2COM/code/at25sf041/#d2996058b51d
--- a/cmd/gravarUpdate.cpp	Wed Feb 24 14:31:25 2016 +0000
+++ b/cmd/gravarUpdate.cpp	Thu Feb 25 21:32:17 2016 +0000
@@ -4,6 +4,7 @@
 #include "crc.h"
 
 #define MAX_PACKAGE_SIZE    64      // for CRC checking
+#define MAX_FLASH_ATTEMPTS   3
 
 #define BOUNDARY_ERROR      -99     //Commands may not span several sectors
 #define ALIGN_ERROR         -98     //Data must be aligned on longword (two LSBs zero)
@@ -24,7 +25,7 @@
     const uint8_t *ptr = reinterpret_cast< uint8_t* >( dados );
     uint32_t addr = fromBigEndian< uint32_t >( &ptr[0] );
     uint32_t size = fromBigEndian< uint32_t >( &ptr[4] );
-    int res = static_cast< int >( extFlash.eraseInterval( addr, size ) );
+    int res = static_cast< int >( extFlash.eraseAndVerify( addr, size, MAX_FLASH_ATTEMPTS ) );
     exec.enviaResposta(RESP_INICIAR_UPDATE, res);
 }
 
@@ -33,7 +34,7 @@
     const uint8_t *ptr = reinterpret_cast< uint8_t* >( dados );
     uint32_t addr = fromBigEndian< uint32_t >( &ptr[0] );
     uint32_t size = fromBigEndian< uint32_t >( &ptr[4] );
-    int res = static_cast< int >( extFlash.writeArray( addr, &ptr[8], size ) );
+    int res = static_cast< int >( extFlash.writeAndVerify( addr, &ptr[8], size, MAX_FLASH_ATTEMPTS ) );
     exec.enviaResposta(RESP_GRAVAR_UPDATE, res);
 }
 
@@ -71,7 +72,7 @@
     while  ( size ) {
         if ( transferSize > size )
             transferSize = size;
-        int res = static_cast< int >( extFlash.readArray( addr, buffer, transferSize ) );
+        res = static_cast< int >( extFlash.readAndVerify( addr, buffer, transferSize, MAX_FLASH_ATTEMPTS ) );
         if ( res != SUCESSO )
             break;
         crc32->addData( buffer, transferSize );
--- a/main.cpp	Wed Feb 24 14:31:25 2016 +0000
+++ b/main.cpp	Thu Feb 25 21:32:17 2016 +0000
@@ -45,6 +45,11 @@
 const uint8_t * _AppConfigDataPayload = const_cast< const uint8_t * >( &_AppConfigData );
 #endif
 
+
+#if LED_TESTE
+static void TestLeds();
+#endif
+
 //////////////////////////////////////////////////////////////
 // Main
 
@@ -63,6 +68,10 @@
     
     isopowerDisable = 0;    // Habilita regulador (PIMA + Alarme Caixa)
 
+#if LED_TESTE
+    TestLeds();
+#endif
+
 #ifndef RAMAL
     boxAlarm.init();
 #endif    
@@ -142,6 +151,47 @@
     }
     
 }
+
+
+////////////////////////////////////////////////////////////
+// auxiliary functions
+
+#if LED_TESTE
+static void TestLeds() {
+    ledPowerON = 0;
+    ledNetwork = 0;
+    ledMeter = 0;
+    ledLoad = 0;
+    ledBox = 0;
+    wait(1.0);
+    ledPowerON = 1;
+    wait(1.0);
+    ledPowerON = 0;
+    ledNetwork = 1;
+    wait(1.0);
+    ledNetwork = 0;
+    ledMeter = 1;
+    wait(1.0);
+    ledMeter = 0;
+    ledLoad = 1;
+    wait(1.0);
+    ledLoad = 0;
+    ledBox = 1;
+    wait(1.0);
+    ledPowerON = 1;
+    ledNetwork = 1;
+    ledMeter = 1;
+    ledLoad = 1;
+    ledBox = 1;
+    wait(1.0);
+    ledPowerON = 0;
+    ledNetwork = 0;
+    ledMeter = 0;
+    ledLoad = 0;
+    ledBox = 0;
+}
+#endif
+
 void iniciaWd(){
     wd.Configure();
     tickerWd.attach(&feedWd, WATCHDOG_INTERVAL);
--- a/settings.h	Wed Feb 24 14:31:25 2016 +0000
+++ b/settings.h	Thu Feb 25 21:32:17 2016 +0000
@@ -4,6 +4,7 @@
 #define MBED_COMPILER  1        // habilitar para compilação no mbed compiler, comentar para IAR
 
 #define USE_PINO  1             // Usado para bypassar protocolo pino
+//#define LED_TESTE  1            // Usado para teste de bootloader
 //#define WATCHDOG_ENABLED  1     // habilita watchdog (para isso mbed deve ser compilada do fonto com o watchdog habilitado)
 //#define RAMAL 1                 // configura a aplicação para modo ramal (o normal é smart breaker)
 //#define RELES_INVERTIDOS  1     // inverte reles de corte e religamento
@@ -97,7 +98,7 @@
     #define DEFAULT_NODE_ADDRESS 3141L
     #define DEFAULT_NETWORK_ADDRESS 4400L
     #define DEFAULT_NETWORK_CHANNEL 2
-    #define DEFAULT_NODE_ROLE 1
+    #define DEFAULT_NODE_ROLE 2             // 1 = sink, 2 = headnode, 3 = subnode
     #define DEFAULT_SOURCE_ENDPOINT 1
     #define DEFAULT_DESTINATION_NODE 6
     #define DEFAULT_DESTINATION_ENDPOINT 1