Skip to content
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

feat(stepper_motor): initial drv8434 driver #120

Draft
wants to merge 23 commits into
base: fouge/zephyr-4.0.0
Choose a base branch
from

Conversation

sri9311
Copy link
Contributor

@sri9311 sri9311 commented Dec 2, 2024

draft of interface driver to motor driver.
stepper application and integration to follow

fixes ORBP-286

@sri9311 sri9311 requested a review from fouge as a code owner December 2, 2024 02:21
@sri9311 sri9311 changed the title DRAFT: Motor Driver DRV8434 ORBP-286 DRAFT: Motor Driver DRV8434 Dec 3, 2024
@fouge fouge marked this pull request as draft December 13, 2024 15:58
@fouge fouge changed the title ORBP-286 DRAFT: Motor Driver DRV8434 chore(stepper_motor): initial drv8434 driver Dec 13, 2024
@fouge
Copy link
Collaborator

fouge commented Dec 13, 2024

hey
I fixed a few things in the title (conventional commit), setting this PR as draft, and putting the linear reference into the PR description

@fouge fouge changed the title chore(stepper_motor): initial drv8434 driver feat(stepper_motor): initial drv8434 driver Dec 13, 2024
@fouge fouge force-pushed the main branch 2 times, most recently from 0974d92 to 52ec901 Compare December 18, 2024 10:38
fouge added 17 commits January 20, 2025 16:01
update revision in west

Signed-off-by: Cyril Fougeray <[email protected]>
make CMake successfully load

Signed-off-by: Cyril Fougeray <[email protected]>
app is building
signature changed, now passing pointer, instead of pointer of pointer.
still many changes to be made

Signed-off-by: Cyril Fougeray <[email protected]>
with deferred initialization, we can now initialize
devices at runtime.
I2C1 is one that should be postponed until after
the power supplies are initialized and turned on.

Signed-off-by: Cyril Fougeray <[email protected]>
for main battery

Signed-off-by: Cyril Fougeray <[email protected]>
global CSTD property is deprecated with zephyr 3.7.0.

Signed-off-by: Cyril Fougeray <[email protected]>
ZTEST_NEW_API not a config anymore
fix test compilation and warnings
config MCUBOOT_BOOTLOADER_MODE_SINGLE_APP (one-slot)
config MCUBOOT_GENERATE_UNSIGNED_IMAGE because no signing keys are used
when generating the test binary
add more delay between dfu messages (erasure takes time)

Signed-off-by: Cyril Fougeray <[email protected]>
taken from mcuboot example
debug boot: read flash data, instead of relying on hardcoded values

Signed-off-by: Cyril Fougeray <[email protected]>
redefine M_PI
BUILD_ASSERT must be used instead of static_assert

Signed-off-by: Cyril Fougeray <[email protected]>
was enabled as long as `watchdog0` was an existing label.
now, kconfig has to be enabled

Signed-off-by: Cyril Fougeray <[email protected]>
use sys_init to initialize watchdog
callback cannot be set dynamically anymore, but weakly defined instead
so that it can be overridden by user at compile time.

Signed-off-by: Cyril Fougeray <[email protected]>
fix the generation of proto files.

cmake from orb-messages library is requesting to be linked into target.
Plus, use target defined in zephyr cmake as a dependency.

Signed-off-by: Cyril Fougeray <[email protected]>
don't use `orb/public`

was not causing issues so far but zephyr_module.py changed and isn't
able to find the project repo for zephyr.meta generation

it's important to note that this is only when the repo is used alone,
without it's `private` counterpart.

Signed-off-by: Cyril Fougeray <[email protected]>
when found, the cmake package `McuPrivate` is used to load custom
configs.
Allow a single point of entry for private configs, which is simpler to
maintain and understand.

Signed-off-by: Cyril Fougeray <[email protected]>
internal routing is now set in specific drivers that we don't use, as we
use the adc drivers to get vbat, vref and die temperature.
so we need so hardcode the configuration.

Signed-off-by: Cyril Fougeray <[email protected]>
disable formatter for CMakeLists.txt
rename dts.overlay to app.overlay
copy-pasted all files from original project
encryption enabled in release builds only

Signed-off-by: Cyril Fougeray <[email protected]>
with fixes
watchdog can be initialized only once, by our libray
adc node property: <SYNC> became "SYNC"

Signed-off-by: Cyril Fougeray <[email protected]>
Comment on lines 73 to 87
uint16_t tx_word = 0;

// Load register address into tx word
tx_word =
tx_word | ((uint16_t)(address) << DRV8434_SPI_TX_ADDRESS_START_POS);

// Load data into tx word
tx_word = tx_word | (uint16_t)(data);

// Wipe TX and RX buffers before each operation
memset(instance->spi.rx_buffer, 0, sizeof(instance->spi.rx_buffer));
memset(instance->spi.tx_buffer, 0, sizeof(instance->spi.tx_buffer));

instance->spi.tx_buffer[0u] = (tx_word >> 8) & DRV8434_SPI_TX_LSB_MASK;
instance->spi.tx_buffer[1u] = tx_word & DRV8434_SPI_TX_LSB_MASK;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about?
seems overly complicated to me 🤔

Suggested change
uint16_t tx_word = 0;
// Load register address into tx word
tx_word =
tx_word | ((uint16_t)(address) << DRV8434_SPI_TX_ADDRESS_START_POS);
// Load data into tx word
tx_word = tx_word | (uint16_t)(data);
// Wipe TX and RX buffers before each operation
memset(instance->spi.rx_buffer, 0, sizeof(instance->spi.rx_buffer));
memset(instance->spi.tx_buffer, 0, sizeof(instance->spi.tx_buffer));
instance->spi.tx_buffer[0u] = (tx_word >> 8) & DRV8434_SPI_TX_LSB_MASK;
instance->spi.tx_buffer[1u] = tx_word & DRV8434_SPI_TX_LSB_MASK;
instance->spi.tx_buffer[0u] = address << 1;
instance->spi.tx_buffer[1u] = data;

@sri9311 sri9311 force-pushed the sri/motor-driver-drv8434 branch from 8c22185 to 3d38424 Compare January 28, 2025 10:25
drv8434 register structs and addresses

Signed-off-by: Srikar Chintapalli <[email protected]>
drv8434 runtime context structs

Signed-off-by: Srikar Chintapalli <[email protected]>
drv8434 defines, application and SPI frame

Signed-off-by: Srikar Chintapalli <[email protected]>
drv8434 SPI transaction layer

Signed-off-by: Srikar Chintapalli <[email protected]>
drv8434 application interface

Signed-off-by: Srikar Chintapalli <[email protected]>
@sri9311 sri9311 force-pushed the sri/motor-driver-drv8434 branch from 3d38424 to f01a485 Compare January 29, 2025 17:42
@sri9311 sri9311 changed the base branch from main to fouge/zephyr-4.0.0 January 29, 2025 17:43
dts file changes to add peripheral support for motor driver

Signed-off-by: Srikar Chintapalli <[email protected]>
@fouge fouge force-pushed the fouge/zephyr-4.0.0 branch 2 times, most recently from 05461a3 to 13f8c3a Compare January 31, 2025 08:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants