Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: CANBuffer KS0108_fork mbed-rtos mbed CAN Addresses
Fork of REVO_Updated_Steering by
Revision 9:e946cafa3cae, committed 2014-10-18
- Comitter:
- palimar
- Date:
- Sat Oct 18 16:36:44 2014 +0000
- Parent:
- 8:57f279f486d9
- Child:
- 10:493f2151d5f1
- Child:
- 13:1f05dcd9ae0e
- Commit message:
- Added preliminary code to send drive status requests.
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/CAN_FILTER_LUT.h Sat Oct 18 16:36:44 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/Steering.cpp Thu Oct 16 22:37:28 2014 +0000
+++ b/Steering.cpp Sat Oct 18 16:36:44 2014 +0000
@@ -1,6 +1,5 @@
#include "Steering.h"
-
void HomeScreen()
{
CANMessage Rxmsg;
@@ -208,25 +207,26 @@
}
-void ON()
+void request_status_change()
{
- Txmsg_Drive.data[0]|=(1<<0);
- wait(0.1);
+ //drive_status != drive_status;
+ //wait(0.1);
+
+ //char status_string = (drive_status == 1 ? "ON" : "OFF");
display.ClearScreen();
display.SelectFont(Arial12,BLACK,ReadData);
display.GotoXY(26,16);
- display.PrintString(" ON INITIATED");
- printf("ON Initiated\n\r");
- //screen=0;
+ display.PrintString("REQUEST SENT TO CHANGE DRIVE STATUS TO ");
+ printf("DRIVE STATUS CHANGE Initiated\n\r");
+
+
+
return;
}
-void ResetCommand()
+void reset()
{
- Txmsg_Drive.data[0]&=~(1<<0);
- wait(0.1);
-
display.ClearScreen();
display.SelectFont(Arial12,BLACK,ReadData);
display.GotoXY(16,16);
@@ -259,9 +259,8 @@
{
pc.baud(230400);
CAN_Steering.frequency(500000);
- for(int i = 0; i<4; i++){
- drive[i] = (0x00);
- }
+ drive_status = 0;
+ reset_body = 0;
ledstream.write(0);
call_ledstream.attach(&Powerstream,0.1);
}
@@ -278,26 +277,19 @@
display.PrintString("Penn Electric Racing");
wait(1);
-
- Thread thread(display_speed_data);
// Start to read buttons on main thread
- screen=0;
- wait(1);
while(1)
{
if(biSWBL.read())
{
- ON();
- //wait(1);
- // HomeScreen();
+ request_status_change();
}
if(biSWBR.read())
{
- ResetCommand();
+ reset();
}
- CAN_Steering.write(Txmsg_Drive);
- wait(0.3);
+
}
}
--- a/Steering.h Thu Oct 16 22:37:28 2014 +0000
+++ b/Steering.h Sat Oct 18 16:36:44 2014 +0000
@@ -102,6 +102,11 @@
int maxScreen=5;
int screen;
-char drive[4];
-CANMessage Txmsg_Drive(0x601,drive,sizeof(drive));
+
+char drive_status;
+char reset_body;
+
+CANMessage Txmsg_drive_status(0x501,&drive_status,1);
+CANMessage Txmsg_reset(0x502,&reset_body,1);
+
#endif /* STEERING_H */
\ No newline at end of file
