gerði breytingar pi megin og þarf að pusha fyrir tölvuna

This commit is contained in:
2026-10-15 15:29:08 +00:00
parent b4f274a65c
commit 13a89d7311
5 changed files with 24 additions and 9 deletions
+3 -3
View File
@@ -1,7 +1,7 @@
#!/bin/sh
# Brings up can0 at the same bitrate as the Nucleo (CAN_BITRATE in src/can_send_test.c).
# Usage: ./can_up.sh [bitrate] (default 250000)
BITRATE=${1:-250000}
# Brings up can0 at the same bitrate as the Nucleo (125000 in src/CAN_FRAME_TEST.c and src/can_send_test.c).
# Usage: ./can_up.sh [bitrate] (default 125000)
BITRATE=${1:-125000}
sudo ip link set can0 down 2>/dev/null
sudo ip link set can0 up type can bitrate "$BITRATE"
+6
View File
@@ -27,3 +27,9 @@ upload_flags =
[env:can_test]
extends = env:nucleo_l432kc
build_flags = -D CAN_SEND_TEST=1
; L4.4 example (src/CAN_FRAME_TEST.c) instead of the motor app.
; Build/upload: pio run -e can_frame_test -t upload
[env:can_frame_test]
extends = env:nucleo_l432kc
build_flags = -D CAN_FRAME_TEST=1
+8 -6
View File
@@ -7,25 +7,27 @@
/* Devicetree node selected by zephyr,canbus in the overlay */
#define CANBUS_NODE DT_CHOSEN(zephyr_canbus)
int main(void)
// L4.4 example. Built only with the can_frame_test environment
// (-D CAN_FRAME_TEST=1); main() in main.c calls this function.
void can_frame_test_main(void)
{
const struct device *dev = DEVICE_DT_GET(CANBUS_NODE);
if (!device_is_ready(dev)) {
printk("CAN device not ready\n");
return 0;
return;
}
int err = can_set_bitrate(dev, 125000);
if (err != 0) {
printk("Error setting CAN bitrate (err %d)\n", err);
return 0;
return;
}
err = can_start(dev);
if (err != 0) {
printk("Error starting CAN controller (err %d)\n", err);
return 0;
return;
}
struct can_frame frame = {
@@ -41,7 +43,7 @@ int main(void)
err = can_send(dev, &frame, K_MSEC(100), NULL, NULL);
if (err != 0) {
printk("Sending failed (err %d)\n", err);
return 0;
return;
}
}
}
}
+3
View File
@@ -2,11 +2,14 @@
void motor_application_main(void);
void can_send_test_main(void);
void can_frame_test_main(void);
int main(void)
{
#if CAN_SEND_TEST
can_send_test_main();
#elif CAN_FRAME_TEST
can_frame_test_main();
#else
motor_application_main();
#endif
+4
View File
@@ -3,6 +3,10 @@
#include <zephyr/dt-bindings/pwm/stm32_pwm.h>
/ {
chosen {
zephyr,canbus = &can1;
};
aliases {
encoder-c1 = &encoder_c1;
encoder-c2 = &encoder_c2;