L298N H-BRIDGE API definition. More...
#include <zephyr/drivers/gpio.h>
#include <zephyr/drivers/pwm.h>
Go to the source code of this file.
Classes | |
struct | nxp_hbridge |
Represents the L298N H-BRIDGE module. More... | |
Macros | |
#define | NXP_HBRIDGE_NUM_GPIOS 2 |
#define | NXP_HBRIDGE_MAX_SPEED 100 |
#define | NXP_HBRIDGE_MOTOR_INVERT BIT(0) |
Enumerations | |
enum | nxp_hbridge_direction { NXP_HBRIDGE_DIRECTION_OFF = 0 , NXP_HBRIDGE_DIRECTION_FORWARD = 1 , NXP_HBRIDGE_DIRECTION_BACKWARDS = 2 } |
Represents the spinning direction of a motor. More... | |
Functions | |
int | nxp_hbridge_init (struct nxp_hbridge *hbridge) |
Initialize the L298 H-BRIDGE module. | |
int | nxp_hbridge_set_direction (struct nxp_hbridge *hbridge, int direction) |
Set the spinning direction of the car's motors. | |
int | nxp_hbridge_set_speed (struct nxp_hbridge *hbridge, uint32_t speed) |
Set the speed of the car's motors. | |
L298N H-BRIDGE API definition.
This file offers the API required for working with the L298N H-BRIDGE module.
#define NXP_HBRIDGE_MAX_SPEED 100 |
maximum allowed speed
#define NXP_HBRIDGE_NUM_GPIOS 2 |
maximum number of GPIOs per motor
int nxp_hbridge_init | ( | struct nxp_hbridge * | hbridge | ) |
Initialize the L298 H-BRIDGE module.
Put the L298 H-BRIDGE hardware into a known state. This consists of:
hbridge | pointer to structure representing the H-BRIDGE |
0 | on success |
negative | errno code if failure |
int nxp_hbridge_set_direction | ( | struct nxp_hbridge * | hbridge, |
int | direction | ||
) |
Set the spinning direction of the car's motors.
hbridge | pointer to the structure representing the H-BRIDGE |
direction | one of nxp_hbridge_direction |
0 | on success |
negative | errno code if failure |
int nxp_hbridge_set_speed | ( | struct nxp_hbridge * | hbridge, |
uint32_t | speed | ||
) |
Set the speed of the car's motors.
Set the speed of the car's motors based on a given percentage, where:
hbridge | pointer to the structure representing the H-BRIDGE |
speed | percentage to set (from 0% to 100%) |
0 | on success |
negative | errno code if failure |