-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Detect breaks task #15
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,13 +5,32 @@ | |
#include "interrupts.h" | ||
#include "ApplicationTypes.h" | ||
#include "data_aggregator.h" | ||
#include "CANDriver.h" | ||
|
||
/** | ||
* Brakes are connected to GPIO 0 | ||
*/ | ||
const uint BRAKE_PIN = 0; | ||
|
||
void brakes_callback(uint gpio, uint32_t events) { | ||
bool brake_pressed = (events & GPIO_IRQ_EDGE_RISE); | ||
data_aggregator_set_breaks_pressed(brake_pressed); | ||
iCommsMessage_t brakeMsg; | ||
|
||
// Sending the brake signal through CAN | ||
if (brake_pressed) { | ||
brakeMsg.standardMessageID = 0x123; // Brake message ID | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would suggest to add this message to UOSM-core There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there is a couple of place you need to add code for that but a good start to look is here : There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you also need to create the external call back in the core like this : |
||
brakeMsg.dataLength = 1; | ||
brakeMsg.data[0] = brake_pressed; | ||
|
||
uint8_t result = CANSPI_Transmit(&brakeMsg); | ||
|
||
if (result == 1) { | ||
DebugPrint("Brake signal sent successfully\n"); | ||
} else { | ||
DebugPrint(("Brake signal sent failed\n")); | ||
} | ||
|
||
data_aggregator_set_breaks_pressed(events & GPIO_IRQ_EDGE_RISE); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in UOSM-core there is function to create CAN message directly. Those are the standard in our code currently but in the end it does the same thing (IComms_CreateMessage) feel free to look at it and change your function if you want
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
look at those to function that might work :
https://github.com/UOSupermileage/UOSM-Pressure-Sensor/blob/d4d55eec0faa8c9e6d6fd3841e7ce6d48e2f44c6/UOSM-Core/Modules/InternalCommsModule.h#L35
https://github.com/UOSupermileage/UOSM-Pressure-Sensor/blob/d4d55eec0faa8c9e6d6fd3841e7ce6d48e2f44c6/UOSM-Core/Modules/InternalCommsModule.h#L25