#include <lpc21xx.h>#include <deb_led.h>#include <system_def.h>#include "engine.h"
Defines | |
| #define | ENGINE_PIN_A 7 |
| PWM output for engine A, pin P0.7. | |
| #define | ENGINE_PIN_B 8 |
| PWM output for engine B, pin P0.8. | |
| #define | ENGINE_ENA 28 |
| Enable output for engine A, pin P1.28. | |
| #define | ENGINE_ENB 30 |
| Enable output for engine B, pin P1.30. | |
| #define | ENGINE_IN2A 27 |
| Direction output for engine A , pin P1.27. | |
| #define | ENGINE_IN2B 29 |
| Direction output for engine A , pin P1.29. | |
| #define | PWM_FREQ 20000 |
| PWM frequency. | |
| #define | PWM_RES 100 |
| PWM resolution. | |
| #define | PWM_STEP ((CPU_APB_HZ / PWM_FREQ)/PWM_RES + 1) |
| Calculates smallest step PWM for resolution 0~100%. | |
Functions | |
| void | engine_A_en (unsigned status) |
| Enables or disables the ouput on engine A. | |
| void | engine_B_en (unsigned status) |
| Enables or disables the ouput on engine B. | |
| void | engine_A_dir (unsigned dir) |
| Changes motor A direction. | |
| void | engine_B_dir (unsigned dir) |
| Changes motor B direction. | |
| void | engine_A_pwm (unsigned pwm) |
| Sets motor A PWM value. | |
| void | engine_B_pwm (unsigned pwm) |
| Sets motor B PWM value. | |
| void | init_engine_A () |
| Inicializes Engine A - enables PWM outputs and sets IOs. | |
| void | init_engine_B () |
| Inicializes Engine B - enables PWM outputs and sets IOs. | |
Variables | |
| unsigned int | pwm_A = 0 |
| Actual value of PWM A. | |
| unsigned int | pwm_B = 0 |
| Actual value of PWM B. | |
| #define ENGINE_ENA 28 |
Enable output for engine A, pin P1.28.
| #define ENGINE_ENB 30 |
Enable output for engine B, pin P1.30.
| #define ENGINE_IN2A 27 |
Direction output for engine A , pin P1.27.
| #define ENGINE_IN2B 29 |
Direction output for engine A , pin P1.29.
| #define ENGINE_PIN_A 7 |
PWM output for engine A, pin P0.7.
| #define ENGINE_PIN_B 8 |
PWM output for engine B, pin P0.8.
| #define PWM_FREQ 20000 |
PWM frequency.
| #define PWM_RES 100 |
PWM resolution.
| #define PWM_STEP ((CPU_APB_HZ / PWM_FREQ)/PWM_RES + 1) |
Calculates smallest step PWM for resolution 0~100%.
| void engine_A_dir | ( | unsigned | dir | ) |
Changes motor A direction.
| dir | direction parameters are defined in engine.h |


| void engine_A_en | ( | unsigned | status | ) |
Enables or disables the ouput on engine A.
Causes smooth stop, without break.
| status | status parameters are defined in engine.h |

| void engine_A_pwm | ( | unsigned | pwm | ) |
Sets motor A PWM value.
| pwm | Unsigned int, 0~100% |

| void engine_B_dir | ( | unsigned | dir | ) |
Changes motor B direction.
| dir | direction parameters are defined in engine.h |


| void engine_B_en | ( | unsigned | status | ) |
Enables or disables the ouput on engine B.
Causes smooth stop, without break.
| status | status parameters are defined in engine.h |

| void engine_B_pwm | ( | unsigned | pwm | ) |
Sets motor B PWM value.
| pwm | Unsigned int, 0~100% |

| void init_engine_A | ( | ) |
Inicializes Engine A - enables PWM outputs and sets IOs.
Uses PWM channel - PWMMR2. If is somthing other set on PWM channels, it will affect the main PWM frequency If the engine B is set it will afect its output for one cycle

| void init_engine_B | ( | ) |
Inicializes Engine B - enables PWM outputs and sets IOs.
Uses PWM channel - PWMMR2. If is somthing other set on PWM channels, it will affect the main PWM frequency If the engine A is set it will afect its output for one cycle

| unsigned int pwm_A = 0 |
Actual value of PWM A.
| unsigned int pwm_B = 0 |
Actual value of PWM B.
1.7.1