Skip to content
Snippets Groups Projects
hw_impl_unix.h 2.13 KiB
#ifndef HW_IMPL_UNIX
#define HW_IMPL_UNIX

#include "hw_iface.h"
#include "type_def.h"

#include <sys/time.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <time.h>

#define VIRT_QUAD_FIFOS_DIR "virt-quad-fifos"

int unix_uart_reset(struct UARTDriver *self);
int unix_uart_write(struct UARTDriver *self, unsigned char c);
int unix_uart_read(struct UARTDriver *self, unsigned char *c);

int unix_pwm_output_reset(struct PWMOutputDriver *self);
int unix_pwm_output_write(struct PWMOutputDriver *self, unsigned int channel, unsigned long pulse_width_us);

int unix_pwm_input_reset(struct PWMInputDriver *self);
int unix_pwm_input_read(struct PWMInputDriver *self, unsigned int channel, unsigned long *pulse_width_us);

int unix_i2c_reset(struct I2CDriver *self);
int unix_i2c_write(struct I2CDriver *self,
                   unsigned short device_addr,
                   unsigned char *data,
                   unsigned int length);
int unix_i2c_read(struct I2CDriver *self,
                  unsigned short device_addr,
                  unsigned char *buff,
                  unsigned int length);

int unix_global_timer_reset(struct TimerDriver *self);
int unix_global_timer_restart(struct TimerDriver *self);
int unix_global_timer_read(struct TimerDriver *self, u64 *us);

int unix_axi_timer_reset(struct TimerDriver *self);
int unix_axi_timer_restart(struct TimerDriver *self);
int unix_axi_timer_read(struct TimerDriver *self, u64 *us);

int unix_mio7_led_reset(struct LEDDriver *self);
int unix_mio7_led_turn_on(struct LEDDriver *self);
int unix_mio7_led_turn_off(struct LEDDriver *self);

int unix_system_reset(struct SystemDriver *self);
int unix_system_sleep(struct SystemDriver *self, unsigned long us);

struct UARTDriver create_unix_uart();
struct PWMOutputDriver create_unix_pwm_outputs();
struct PWMInputDriver create_unix_pwm_inputs();
struct I2CDriver create_unix_i2c();
struct TimerDriver create_unix_global_timer();
struct TimerDriver create_unix_axi_timer();
struct LEDDriver create_unix_mio7_led();
struct SystemDriver create_unix_system();

int test_unix_i2c();
int test_unix_mio7_led_and_system();
int test_unix_pwm_inputs();

#endif