FRDM-IMX93 for NXP CUP
FRDM-IMX93 support for NXP CUP
 
Loading...
Searching...
No Matches
hbridge.h
Go to the documentation of this file.
1/*
2 * Copyright 2025 NXP
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
14#ifndef _HBRIDGE_H_
15#define _HBRIDGE_H_
16
17#include <zephyr/drivers/gpio.h>
18#include <zephyr/drivers/pwm.h>
19
21#define NXP_HBRIDGE_NUM_GPIOS 2
22
24#define NXP_HBRIDGE_MAX_SPEED 100
25
34#define NXP_HBRIDGE_MOTOR_INVERT BIT(0)
35
46 const struct device *gpio_dev;
48 const struct device *pwm_dev;
50 uint32_t period;
56 int lchan;
58 int rchan;
60 uint32_t lflags;
62 uint32_t rflags;
63};
64
77
91int nxp_hbridge_init(struct nxp_hbridge *hbridge);
92
102int nxp_hbridge_set_direction(struct nxp_hbridge *hbridge, int direction);
103
118int nxp_hbridge_set_speed(struct nxp_hbridge *hbridge, uint32_t speed);
119
120#endif /* _HBRIDGE_H_ */
int nxp_hbridge_init(struct nxp_hbridge *hbridge)
Initialize the L298 H-BRIDGE module.
Definition hbridge.c:141
#define NXP_HBRIDGE_NUM_GPIOS
Definition hbridge.h:21
int nxp_hbridge_set_speed(struct nxp_hbridge *hbridge, uint32_t speed)
Set the speed of the car's motors.
Definition hbridge.c:175
nxp_hbridge_direction
Represents the spinning direction of a motor.
Definition hbridge.h:69
@ NXP_HBRIDGE_DIRECTION_OFF
Definition hbridge.h:71
@ NXP_HBRIDGE_DIRECTION_BACKWARDS
Definition hbridge.h:75
@ NXP_HBRIDGE_DIRECTION_FORWARD
Definition hbridge.h:73
int nxp_hbridge_set_direction(struct nxp_hbridge *hbridge, int direction)
Set the spinning direction of the car's motors.
Definition hbridge.c:109
Represents the L298N H-BRIDGE module.
Definition hbridge.h:44
int lgpios[2]
Definition hbridge.h:52
uint32_t lflags
Definition hbridge.h:60
const struct device * pwm_dev
Definition hbridge.h:48
int lchan
Definition hbridge.h:56
int rgpios[2]
Definition hbridge.h:54
int rchan
Definition hbridge.h:58
const struct device * gpio_dev
Definition hbridge.h:46
uint32_t period
Definition hbridge.h:50
uint32_t rflags
Definition hbridge.h:62