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:
tpadovani
Date:
Tue Jun 16 22:16:02 2015 +0000
Parent:
0:999112ad27f0
Child:
2:b808b1743de2
Commit message:
ainda n?o funcional

Changed in this revision

CRC16.lib Show annotated file Show diff for this revision Revisions of this file
FreescaleWatchdog.lib Show annotated file Show diff for this revision Revisions of this file
GGSProtocol.lib Show annotated file Show diff for this revision Revisions of this file
SerialNumberV2COM.lib 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
main.h Show annotated file Show diff for this revision Revisions of this file
mbed-src-watchdog.lib Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show diff for this revision Revisions of this file
settings.h Show annotated file Show diff for this revision Revisions of this file
v2hardware.h Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CRC16.lib	Tue Jun 16 22:16:02 2015 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/teams/Equipe-Firmware-V2COM/code/CRC16/#45617a5280ed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/FreescaleWatchdog.lib	Tue Jun 16 22:16:02 2015 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/teams/Equipe-Firmware-V2COM/code/FreescaleWatchdog/#3856e778991e
--- a/GGSProtocol.lib	Mon Jun 15 21:37:46 2015 +0000
+++ b/GGSProtocol.lib	Tue Jun 16 22:16:02 2015 +0000
@@ -1,1 +1,1 @@
-GGSProtocol#fb7f55164cab
+GGSProtocol#0b846eac1798
--- a/SerialNumberV2COM.lib	Mon Jun 15 21:37:46 2015 +0000
+++ b/SerialNumberV2COM.lib	Tue Jun 16 22:16:02 2015 +0000
@@ -1,1 +1,1 @@
-http://developer.mbed.org/teams/Equipe-Firmware-V2COM/code/SerialNumberV2COM/#7f68b65d3ae7
+http://developer.mbed.org/teams/Equipe-Firmware-V2COM/code/SerialNumberV2COM/#f0a2d7e52eac
--- a/main.cpp	Mon Jun 15 21:37:46 2015 +0000
+++ b/main.cpp	Tue Jun 16 22:16:02 2015 +0000
@@ -1,15 +1,24 @@
 #include "main.h"
 
+static Watchdog wd;
+static Ticker tickerWd;
+static SerialNumber sn;
 static Parameters param ((unsigned char *)&APP_PARAMETERS, sizeof(APP_PARAMETERS));
 
 
 int main()
 {
+    iniciaWd();
     
     printf("##### %s #####\r\n", version);
-    
+    printSerialNumber();
+
     param.loadParameters();
-    while(1);
+    network.baud(19200);
+    
+    while(1){
+        trataPacoteGGS();
+    }
     
 }
 
@@ -17,3 +26,31 @@
     printf("App Params Validated\r\n");
     
 }
+
+void iniciaWd(){
+    wd.Configure();
+    tickerWd.attach(&feedWd, WATCHDOG_INTERVAL);
+}
+
+void feedWd(){
+    wd.Service();
+}
+
+void softReset(){
+    printf("SoftReset\r\n");
+    tickerWd.detach();
+}
+
+void enviaRespostaGGS(unsigned char * dados, int tamanho){
+    for(int i=0; i < tamanho; i++){
+        network.putc(dados[i]);
+    }
+}
+
+void printSerialNumber(){
+    printf("SN: ");
+    for(int i=0; i < SERIAL_LENGTH; i++){
+        printf("%02x", sn.get()[i]);
+    }
+    printf("\r\n");
+}
--- a/main.h	Mon Jun 15 21:37:46 2015 +0000
+++ b/main.h	Tue Jun 16 22:16:02 2015 +0000
@@ -4,8 +4,11 @@
 #include "mbed.h"
 #include "settings.h"
 #include "version.h"
+#include "serialNumber.h"
 #include "parameters.h"
 #include "appParameters.h"
+#include "FreescaleWatchdog.h"
+#include "ggs.h"
 
 ParametersBlock APP_PARAMETERS;
 
@@ -20,10 +23,11 @@
 
 
 
-
-
-
-
+void iniciaWd();
+void feedWd();
+void softReset();
+void enviaRespostaGGS(unsigned char * dados, int tamanho);
+void printSerialNumber();
 
 
 #endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-src-watchdog.lib	Tue Jun 16 22:16:02 2015 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/teams/Equipe-Firmware-V2COM/code/mbed-src-watchdog/#f54096b70ee9
--- a/mbed.bld	Mon Jun 15 21:37:46 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/7cff1c4259d7
\ No newline at end of file
--- a/settings.h	Mon Jun 15 21:37:46 2015 +0000
+++ b/settings.h	Tue Jun 16 22:16:02 2015 +0000
@@ -1,7 +1,9 @@
 #ifndef SETTINGS_H
 #define SETTINGS_H
 
+//#define TEST_MODE 1    // Usado para testar na placa de desenvolvimento
 
+#define WATCHDOG_INTERVAL 0.1  // intervalo de alimentacao do watchdog, em segundos (float)
 
 
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/v2hardware.h	Tue Jun 16 22:16:02 2015 +0000
@@ -0,0 +1,17 @@
+#ifndef V2_HARDWARE_H
+#define V2_HARDWARE_H
+
+#include "mbed.h"
+#include "settings.h"
+
+#ifdef TEST_MODE
+    DigitalOut reset_relay(PTC6);
+    DigitalOut set_relay(PTC5);
+    Serial network(USBTX, USBRX);
+#else
+    DigitalOut reset_relay(PTC6);
+    DigitalOut set_relay(PTC5);
+    Serial network(PTC4, PTC3);
+#endif  // TEST_MODE
+
+#endif  // V2_HARDWARE_H