Penn Electric Racing / Mbed 2 deprecated REVO_Updated_Steering

Dependencies:   CANBuffer KS0108_fork mbed-rtos mbed CAN Addresses

Fork of REVO_Updated_Steering by Penn Electric

Files at this revision

API Documentation at this revision

Comitter:
tmccurbin
Date:
Sat Oct 18 17:21:36 2014 +0000
Parent:
14:3e21d6c764a5
Commit message:
Re-added soft reset functionality

Changed in this revision

CANBuffer.lib Show annotated file Show diff for this revision Revisions of this file
CAN_FILTER_LUT.h Show annotated file Show diff for this revision Revisions of this file
CAN_Filter_LUT.h Show diff for this revision Revisions of this file
Steering.cpp Show annotated file Show diff for this revision Revisions of this file
Steering.h Show annotated file Show diff for this revision Revisions of this file
--- a/CANBuffer.lib	Sat Oct 18 17:17:02 2014 +0000
+++ b/CANBuffer.lib	Sat Oct 18 17:21:36 2014 +0000
@@ -1,1 +1,1 @@
-http://developer.mbed.org/teams/Penn-Electric-Racing/code/CANBuffer/#fbfd7c8a93b5
+http://developer.mbed.org/teams/Penn-Electric-Racing/code/CANBuffer/#110f268af846
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CAN_FILTER_LUT.h	Sat Oct 18 17:21:36 2014 +0000
@@ -0,0 +1,65 @@
+/*
+Code by Parth Patel, Penn Electric Racing 2014, 9/23/2014
+ 
+This library provides an easy to use, buffered, hardware-filtered CAN interface for
+high performance CAN applications.  Provides automatic reception of messages via CAN RX interrupt
+into a rx ring buffer.  Provides automatic transmission of messages via CAN TX interrupt.
+ 
+@File CAN_Filter_LUT.h: Contains the formatted lookup tables to program the onboard CAN acceptance filters
+ 
+*/
+#ifndef _FILE_CAN_FILTER_LUT_H
+#define _FILE_CAN_FILTER_LUT_H
+ 
+#define STDMASK 0x7FF
+#define EXTMASK 0x1FFFFFFF
+ 
+// These arrays defines the CAN Controller Acceptance Filter Lookup Table.
+// Follow notes below or else the chip's behaviour will be undefined
+// MAX SIZE PERMITTED = 512 32bit ints total across all tables
+// Note that AF_LUT_SEI is 16bit, divide #entries by 2 for this one
+// Note that AF_LUT_EIR is 64bit, multipy #entries by 2 for this one
+ 
+const uint16_t AF_LUT_SEI[] = {
+// !! ID's MUST BE IN ASCENDING ORDER (starting at 0x00) !!
+ 
+// STANDARD EXPLICIT IDs - CAN CONTROLLER 1
+//( 0xID                              & STDMASK),
+ 
+// STANDARD EXPLICIT IDs - CAN CONTROLLER 2
+//( 0xID                              & STDMASK) | 1<<13,
+};
+ 
+const uint32_t AF_LUT_SIR[] = {
+// !! ID's MUST BE IN ASCENDING ORDER (starting at 0x00), NO OVERLAPPING RANGES !!
+ 
+// STANDARD ID RANGES - CAN CONTROLLER 1
+//( 0xLOWERBOUND & STDMASK) << 16         | ( 0xUPPERBOUND & STDMASK),          lower/upperbounds are inclusive
+ 
+// STANDARD ID RANGES - CAN CONTROLLER 2
+//( 0xLOWERBOUND & STDMASK | 1<<13) << 16 | ( 0xUPPERBOUND & STDMASK | 1<<13),  lower/upperbounds are inclusive
+  ( 0x400        & STDMASK | 1<<13) << 16 | ( 0x4FF        & STDMASK | 1<<13),  // Index1
+};
+ 
+const uint32_t AF_LUT_EEI[] = {
+// !! ID's MUST BE IN ASCENDING ORDER (starting at 0x00) !!
+ 
+// EXTENDED EXPLICIT IDs - CAN CONTROLLER 1
+//( 0xID                              & EXTMASK),
+ 
+// EXTENDED EXPLICIT IDs - CAN CONTROLLER 2
+//( 0xID                              & EXTMASK) | 1<<29,
+};
+ 
+const uint64_t AF_LUT_EIR[] = {
+// !! ID's MUST BE IN ASCENDING ORDER (starting at 0x00), NO OVERLAPPING RANGES !!
+ 
+// EXTENDED ID RANGES - CAN CONTROLLER 1
+//( 0xLOWERBOUND & EXTMASK) << 32         | ( 0xUPPERBOUND & EXTMASK), lower/upperbounds are inclusive
+ 
+// EXTENDED ID RANGES - CAN CONTROLLER 2
+//( 0xLOWERBOUND & EXTMASK | 1<<29) << 32 | ( 0xUPPERBOUND & EXTMASK | 1<<29), lower/upperbounds are inclusive
+ 
+};
+ 
+#endif
\ No newline at end of file
--- a/CAN_Filter_LUT.h	Sat Oct 18 17:17:02 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,65 +0,0 @@
-/*
-Code by Parth Patel, Penn Electric Racing 2014, 9/23/2014
- 
-This library provides an easy to use, buffered, hardware-filtered CAN interface for
-high performance CAN applications.  Provides automatic reception of messages via CAN RX interrupt
-into a rx ring buffer.  Provides automatic transmission of messages via CAN TX interrupt.
- 
-@File CAN_Filter_LUT.h: Contains the formatted lookup tables to program the onboard CAN acceptance filters
- 
-*/
-#ifndef _FILE_CAN_FILTER_LUT_H
-#define _FILE_CAN_FILTER_LUT_H
- 
-#define STDMASK 0x7FF
-#define EXTMASK 0x1FFFFFFF
- 
-// These arrays defines the CAN Controller Acceptance Filter Lookup Table.
-// Follow notes below or else the chip's behaviour will be undefined
-// MAX SIZE PERMITTED = 512 32bit ints total across all tables
-// Note that AF_LUT_SEI is 16bit, divide #entries by 2 for this one
-// Note that AF_LUT_EIR is 64bit, multipy #entries by 2 for this one
- 
-const uint16_t AF_LUT_SEI[] = {
-// !! ID's MUST BE IN ASCENDING ORDER (starting at 0x00) !!
- 
-// STANDARD EXPLICIT IDs - CAN CONTROLLER 1
-//( 0xID                              & STDMASK),
- 
-// STANDARD EXPLICIT IDs - CAN CONTROLLER 2
-//( 0xID                              & STDMASK) | 1<<13,
-};
- 
-const uint32_t AF_LUT_SIR[] = {
-// !! ID's MUST BE IN ASCENDING ORDER (starting at 0x00), NO OVERLAPPING RANGES !!
- 
-// STANDARD ID RANGES - CAN CONTROLLER 1
-//( 0xLOWERBOUND & STDMASK) << 16         | ( 0xUPPERBOUND & STDMASK),          lower/upperbounds are inclusive
- 
-// STANDARD ID RANGES - CAN CONTROLLER 2
-//( 0xLOWERBOUND & STDMASK | 1<<13) << 16 | ( 0xUPPERBOUND & STDMASK | 1<<13),  lower/upperbounds are inclusive
-  ( 0x400        & STDMASK | 1<<13) << 16 | ( 0x4FF        & STDMASK | 1<<13),  // Index1
-};
- 
-const uint32_t AF_LUT_EEI[] = {
-// !! ID's MUST BE IN ASCENDING ORDER (starting at 0x00) !!
- 
-// EXTENDED EXPLICIT IDs - CAN CONTROLLER 1
-//( 0xID                              & EXTMASK),
- 
-// EXTENDED EXPLICIT IDs - CAN CONTROLLER 2
-//( 0xID                              & EXTMASK) | 1<<29,
-};
- 
-const uint64_t AF_LUT_EIR[] = {
-// !! ID's MUST BE IN ASCENDING ORDER (starting at 0x00), NO OVERLAPPING RANGES !!
- 
-// EXTENDED ID RANGES - CAN CONTROLLER 1
-//( 0xLOWERBOUND & EXTMASK) << 32         | ( 0xUPPERBOUND & EXTMASK), lower/upperbounds are inclusive
- 
-// EXTENDED ID RANGES - CAN CONTROLLER 2
-//( 0xLOWERBOUND & EXTMASK | 1<<29) << 32 | ( 0xUPPERBOUND & EXTMASK | 1<<29), lower/upperbounds are inclusive
- 
-};
- 
-#endif
\ No newline at end of file
--- a/Steering.cpp	Sat Oct 18 17:17:02 2014 +0000
+++ b/Steering.cpp	Sat Oct 18 17:21:36 2014 +0000
@@ -209,39 +209,32 @@
 
 void request_status_change()
 {
-    
-    char drive_status_request = !drive_status;
-    char * status_string;
+    //drive_status != drive_status;   
+    //wait(0.1);
     
-    if(drive_status_request){
-        status_string = "ON";
-    }
-    else{
-        status_string = "OFF";
-    }
-    
-    for(int i = 0; i < 10; i++){
-        CAN_Steering.write(Txmsg_drive_status_request);
-    }
+    //char status_string = (drive_status == 1 ? "ON" : "OFF");
 
     display.ClearScreen();
     display.SelectFont(Arial12,BLACK,ReadData);
     display.GotoXY(26,16);
-    display.PrintString("REQUEST SENT TO CHANGE DRIVE STATUS TO: ");
-    display.PrintString(status_string);
-    display.PrintString(".\n");
+    display.PrintString("REQUEST SENT TO CHANGE DRIVE STATUS TO ");
+    printf("DRIVE STATUS CHANGE Initiated\n\r");
     
-    printf("DRIVE STATUS CHANGE Initiated\n\r");
+    
+    
     return;
 }
 
 void reset()
 {
-    display.ClearScreen();
-    display.SelectFont(Arial12,BLACK,ReadData);
-    display.GotoXY(16,16);
-    display.PrintString(" RESET INITIATED");
-    printf("Reset Initiated\n\r");
+    txWriteDirect(Txmsg_reset);
+    mbed_reset();
+    
+//    display.ClearScreen();
+//    display.SelectFont(Arial12,BLACK,ReadData);
+//    display.GotoXY(16,16);
+//    display.PrintString(" RESET INITIATED");
+//    printf("Reset Initiated\n\r");
     
     return;
 }    
@@ -270,7 +263,6 @@
     pc.baud(230400);
     CAN_Steering.frequency(500000);
     drive_status = 0;
-    drive_status_request = 1;
     reset_body = 0;
     ledstream.write(0);
     call_ledstream.attach(&Powerstream,0.1);
--- a/Steering.h	Sat Oct 18 17:17:02 2014 +0000
+++ b/Steering.h	Sat Oct 18 17:21:36 2014 +0000
@@ -104,10 +104,11 @@
 int screen; 
 
 char drive_status;
-char drive_status_request;
 char reset_body;
 
-CANMessage Txmsg_drive_status_request(0x501,&drive_status_request,1);
+CANMessage Txmsg_drive_status(0x501,&drive_status,1);
 CANMessage Txmsg_reset(0x502,&reset_body,1);
 
+extern "C" void mbed_reset();
+
 #endif /* STEERING_H */    
\ No newline at end of file