Skip to content

Open Bot Brain primitives for motors + color sensor #285

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

Open
wants to merge 25 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
1470028
Add open bot brain Zephyr primitives
MaartenS11 Oct 31, 2024
b033e1d
Move some motor code into a separate file
MaartenS11 Nov 4, 2024
292a6cd
Refactor motor code a bit more by creating a Motor class that does mo…
MaartenS11 Nov 5, 2024
ff7454c
Only use one interrupt for the motor encoders instead of two, this al…
MaartenS11 Dec 2, 2024
52dda65
Enable CONFIG_STM32_ENABLE_DEBUG_SLEEP_STOP to allow flashing the boa…
MaartenS11 Apr 28, 2025
d7bab5f
Clean up color sensor code a bit
MaartenS11 Dec 4, 2024
d7339c9
Rename colour_sensor to color_sensor + add abort primitive + set hear…
MaartenS11 Dec 4, 2024
8a2421b
Minor cleanup
MaartenS11 Dec 4, 2024
4cc94a8
Move sensor setup into separate function
MaartenS11 Dec 4, 2024
fc651f6
Move most of the color sensor code into the uart_sensor files
MaartenS11 Dec 4, 2024
aa04464
Fix case where invalid data was read from the sensor
MaartenS11 Dec 4, 2024
f342a30
Move uart sensor data into a struct
MaartenS11 Dec 5, 2024
63452b7
Misc type conversions
MaartenS11 Dec 5, 2024
1c3882c
Invert motor direction to match the forward direction used by Lego th…
MaartenS11 Apr 28, 2025
f31646c
Update motor primitives to all have the port and speed first and othe…
MaartenS11 Apr 28, 2025
ef3b9e2
Put open bot brain primitives in an ifdef for the board
MaartenS11 Apr 28, 2025
74cf4ea
Use DT_FOREACH_PROP_ELEM_SEP to get all pwm specs
MaartenS11 Apr 28, 2025
38ef8c3
Don't hardcode the number of motors
MaartenS11 Apr 28, 2025
4884cc0
Run clang-tidy
MaartenS11 Apr 28, 2025
a96d795
Place mindstorms file under ifndef ARDUINO
MaartenS11 Apr 28, 2025
5947074
Read debug messages in debug thread again instead of timer interrupt …
MaartenS11 Apr 29, 2025
d1c6c00
clang-format
MaartenS11 Apr 29, 2025
8c336f8
Make print_int print signed integers
MaartenS11 Apr 30, 2025
a72c41d
Make color_sensor push signed integers
MaartenS11 Apr 30, 2025
6180625
Support data messages consisting of two bytes
MaartenS11 Apr 30, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions platforms/Zephyr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ target_sources(app PRIVATE
../../src/Interpreter/instructions.cpp
../../src/Interpreter/interpreter.cpp
../../src/Primitives/zephyr.cpp
../../src/Primitives/Mindstorms/Motor.cpp
../../src/Primitives/Mindstorms/uart_sensor.cpp
../../src/Memory/mem.cpp
../../src/Utils/util.cpp
../../src/Utils/util_arduino.cpp
Expand Down
258 changes: 137 additions & 121 deletions platforms/Zephyr/boards/stm32l496g_disco.overlay
Original file line number Diff line number Diff line change
@@ -1,132 +1,148 @@
#include "../app.overlay"

/ {
zephyr,user {
warduino-gpios =
<&gpioa 0 0>,
<&gpioa 1 0>,
<&gpioa 2 0>,
<&gpioa 3 0>,
<&gpioa 4 0>,
<&gpioa 5 0>,
<&gpioa 6 0>,
<&gpioa 7 0>,
<&gpioa 8 0>,
<&gpioa 9 0>,
<&gpioa 10 0>,
<&gpioa 11 0>,
<&gpioa 12 0>,
<&gpioa 15 0>,
<&gpiob 0 0>,
<&gpiob 1 0>,
<&gpiob 2 0>,
<&gpiob 3 0>,
<&gpiob 4 0>,
<&gpiob 5 0>,
<&gpiob 6 0>,
<&gpiob 7 0>,
<&gpiob 8 0>,
<&gpiob 9 0>,
<&gpiob 12 0>,
<&gpiob 13 0>,
<&gpiob 14 0>,
<&gpiob 15 0>,
<&gpioc 0 0>,
<&gpioc 1 0>,
<&gpioc 2 0>,
<&gpioc 3 0>,
<&gpioc 4 0>,
<&gpioc 5 0>,
<&gpioc 6 0>,
<&gpioc 7 0>,
<&gpioc 8 0>,
<&gpioc 9 0>,
<&gpioc 12 0>,
<&gpioc 15 0>,
<&gpiod 0 0>,
<&gpiod 1 0>,
<&gpiod 2 0>,
<&gpiod 3 0>,
<&gpiod 4 0>,
<&gpiod 7 0>,
<&gpiod 8 0>,
<&gpiod 9 0>,
<&gpiod 10 0>,
<&gpiod 11 0>,
<&gpiod 12 0>,
<&gpiod 13 0>,
<&gpiod 14 0>,
<&gpiod 15 0>,
<&gpioe 0 0>,
<&gpioe 1 0>,
<&gpioe 2 0>,
<&gpioe 3 0>,
<&gpioe 4 0>,
<&gpioe 7 0>,
<&gpioe 8 0>,
<&gpioe 10 0>,
<&gpioe 11 0>,
<&gpioe 12 0>,
<&gpioe 13 0>,
<&gpioe 14 0>,
<&gpioe 15 0>,
<&gpiof 3 0>,
<&gpiof 4 0>,
<&gpiof 5 0>,
<&gpiof 6 0>,
<&gpiof 7 0>,
<&gpiof 8 0>,
<&gpiof 9 0>,
<&gpiof 10 0>,
<&gpiof 11 0>,
<&gpiof 12 0>,
<&gpiof 13 0>,
<&gpiof 14 0>,
<&gpiog 2 0>,
<&gpiog 3 0>,
<&gpiog 4 0>,
<&gpiog 5 0>,
<&gpiog 6 0>,
<&gpiog 7 0>,
<&gpiog 8 0>,
<&gpiog 11 0>,
<&gpiog 12 0>,
<&gpiog 15 0>,
<&gpiob 10 0>,
<&gpiob 11 0>,
<&gpioc 10 0>,
<&gpioc 11 0>,
<&gpiog 13 0>,
<&gpiog 14 0>,
<&gpiod 5 0>,
<&gpiod 6 0>,
<&gpiof 0 0>,
<&gpiof 1 0>,
<&gpiog 9 0>,
<&gpiog 10 0>;
zephyr,user {
warduino-gpios =
<&gpioa 0 0>,
<&gpioa 1 0>,
<&gpioa 2 0>,
<&gpioa 3 0>,
<&gpioa 4 0>,
<&gpioa 5 0>,
<&gpioa 6 0>,
<&gpioa 7 0>,
<&gpioa 8 0>,
<&gpioa 9 0>,
<&gpioa 10 0>,
<&gpioa 11 0>,
<&gpioa 12 0>,
<&gpioa 15 0>,
<&gpiob 0 0>,
<&gpiob 1 0>,
<&gpiob 2 0>,
<&gpiob 3 0>,
<&gpiob 4 0>,
<&gpiob 5 0>,
<&gpiob 6 0>,
<&gpiob 7 0>,
<&gpiob 8 0>,
<&gpiob 9 0>,
<&gpiob 12 0>,
<&gpiob 13 0>,
<&gpiob 14 0>,
<&gpiob 15 0>,
<&gpioc 0 0>,
<&gpioc 1 0>,
<&gpioc 2 0>,
<&gpioc 3 0>,
<&gpioc 4 0>,
<&gpioc 5 0>,
<&gpioc 6 0>,
<&gpioc 7 0>,
<&gpioc 8 0>,
<&gpioc 9 0>,
<&gpioc 12 0>,
<&gpioc 15 0>,
<&gpiod 0 0>,
<&gpiod 1 0>,
<&gpiod 2 0>,
<&gpiod 3 0>,
<&gpiod 4 0>,
<&gpiod 7 0>,
<&gpiod 8 0>,
<&gpiod 9 0>,
<&gpiod 10 0>,
<&gpiod 11 0>,
<&gpiod 12 0>,
<&gpiod 13 0>,
<&gpiod 14 0>,
<&gpiod 15 0>,
<&gpioe 0 0>,
<&gpioe 1 0>,
<&gpioe 2 0>,
<&gpioe 3 0>,
<&gpioe 4 0>,
<&gpioe 7 0>,
<&gpioe 8 0>,
<&gpioe 10 0>,
<&gpioe 11 0>,
<&gpioe 12 0>,
<&gpioe 13 0>,
<&gpioe 14 0>,
<&gpioe 15 0>,
<&gpiof 3 0>,
<&gpiof 4 0>,
<&gpiof 5 0>,
<&gpiof 6 0>,
<&gpiof 7 0>,
<&gpiof 8 0>,
<&gpiof 9 0>,
<&gpiof 10 0>,
<&gpiof 11 0>,
<&gpiof 12 0>,
<&gpiof 13 0>,
<&gpiof 14 0>,
<&gpiog 2 0>,
<&gpiog 3 0>,
<&gpiog 4 0>,
<&gpiog 5 0>,
<&gpiog 6 0>,
<&gpiog 7 0>,
<&gpiog 8 0>,
<&gpiog 11 0>,
<&gpiog 12 0>,
<&gpiog 15 0>,
<&gpiob 10 0>,
<&gpiob 11 0>,
<&gpioc 10 0>,
<&gpioc 11 0>,
<&gpiog 13 0>,
<&gpiog 14 0>,
<&gpiod 5 0>,
<&gpiod 6 0>,
<&gpiof 0 0>,
<&gpiof 1 0>,
<&gpiog 9 0>,
<&gpiog 10 0>;

pwms =
<&pwm8 3 10000 PWM_POLARITY_NORMAL>,
<&pwm8 4 10000 PWM_POLARITY_NORMAL>,
<&pwm8 1 10000 PWM_POLARITY_NORMAL>,
<&pwm8 2 10000 PWM_POLARITY_NORMAL>;

warduino-uarts =
<&usart1>;
};
pwms =
<&pwm8 3 10000 PWM_POLARITY_NORMAL>,
<&pwm8 4 10000 PWM_POLARITY_NORMAL>,
<&pwm8 1 10000 PWM_POLARITY_NORMAL>,
<&pwm8 2 10000 PWM_POLARITY_NORMAL>,
<&pwm1 3 10000 PWM_POLARITY_NORMAL>,
<&pwm1 4 10000 PWM_POLARITY_NORMAL>,
<&pwm1 1 10000 PWM_POLARITY_NORMAL>,
<&pwm1 2 10000 PWM_POLARITY_NORMAL>;

warduino-uarts =
<&usart1>;
};
};

&timers8 {
status = "okay";
pwm8: pwm {
status = "okay";
pinctrl-0 = <&tim8_ch3_pc8 &tim8_ch4_pc9 &tim8_ch1_pc6 &tim8_ch2_pc7>;
pinctrl-names =
"default";
};
status = "okay";

pwm8: pwm {
status = "okay";
pinctrl-0 = <&tim8_ch3_pc8 &tim8_ch4_pc9 &tim8_ch1_pc6 &tim8_ch2_pc7>;
pinctrl-names =
"default";
};
};

&timers1 {
status = "okay";

pwm1: pwm {
status = "okay";
pinctrl-0 = <&tim1_ch3_pe13 &tim1_ch4_pe14 &tim1_ch1_pa8 &tim1_ch2_pa9>;
pinctrl-names =
"default";
};
};

&usart1 {
pinctrl-0 = <&usart1_tx_pg9 &usart1_rx_pg10>;
current-speed = <2400>;
pinctrl-0 = <&usart1_tx_pg9 &usart1_rx_pg10>;
current-speed = <2400>;
};
2 changes: 1 addition & 1 deletion platforms/Zephyr/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void startDebuggerStd() {
int valread;
uint8_t buffer[1024] = {0};
while (true) {
k_msleep(1000);
k_msleep(500);

while ((valread = war_console_read(NULL, buffer, 1024)) > 0) {
wac->handleInterrupt(valread, buffer);
Expand Down
4 changes: 4 additions & 0 deletions platforms/Zephyr/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,7 @@ CONFIG_CONSOLE_PUTCHAR_BUFSIZE=4096

CONFIG_POSIX_API=y
CONFIG_MAIN_STACK_SIZE=8192

# Allow flashing the board without reset (increases power consumption so should only be used for development)
CONFIG_STM32_ENABLE_DEBUG_SLEEP_STOP=y

Loading
Loading