Skip to content
Snippets Groups Projects
Commit 247371ca authored by bbartels's avatar bbartels Committed by dawehr
Browse files

wip: update PWM output test

parent 594e9249
No related branches found
No related tags found
1 merge request!9Abstract the hardware layer
......@@ -11,6 +11,7 @@
int send_actuator_commands(struct PWMOutputDriver *pwm_outputs, log_t* log_struct, actuator_command_t* actuator_command_struct) {
int i;
// write the PWMs to the motors
for (i = 0; i < 4; i++) {
pwm_outputs->write(pwm_outputs, i, actuator_command_struct->pwms[i]);
}
......
#include "hw_impl_zybo.h"
#define THROTTLE_PULSE_WIDTH_LOW 100000 // 1us
#define THROTTLE_PULSE_WIDTH_HIGH 200000 // 2us
#define PERIOD_WIDTH 222222 // 100000000 ns / 450
#define SYS_CLOCK_RATE 100000000 // ticks per second
#define FREQUENCY 450
#define PERIOD_WIDTH SYS_CLOCK_RATE/FREQUENCY
#define THROTTLE_PULSE_WIDTH_LOW SYS_CLOCK_RATE/1000 // 1 ms
#define THROTTLE_PULSE_WIDTH_HIGH SYS_CLOCK_RATE/500 // 2 ms
#define PULSE_WIDTH_ADDR_OFFSET 1
struct PWMOutputDriverState {
......
......@@ -117,17 +117,14 @@ int test_zybo_pwm_outputs() {
struct SystemDriver sys = create_zybo_system();
sys.reset(&sys);
unsigned long pwms[4];
pwms[0] = 100000;
pwms[1] = 100000;
pwms[2] = 100000;
pwms[3] = 100000;
int n = 0;
while (1) {
int i;
for (i = 0; i < 4; i += 1) {
pwm_outputs.write(&pwm_outputs, i, pwms[i] + n++);
sys.sleep(&sys, 50);
int j;
for (j = 100000; j < 200000; j += 1) {
int i;
for (i = 0; i < 4; i += 1) {
pwm_outputs.write(&pwm_outputs, i, j);
sys.sleep(&sys, 50);
}
}
continue;
}
......
......@@ -4,7 +4,7 @@
#include "type_def.h"
#include "platform.h"
#define RUN_TESTS
//#define RUN_TESTS
int setup_hardware(hardware_t *hardware) {
hardware->i2c = create_zybo_i2c();
......@@ -30,7 +30,7 @@ int main()
//test_zybo_pwm_outputs();
//test_zybo_uart();
//test_zybo_axi_timer();
test_zybo_uart();
//test_zybo_uart();
return 0;
#endif
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment