MotorControlModuleSDFM_TMS3.../Projects/EFC_UsbDriver/src/service/sv_device.h
2024-06-07 11:04:32 +03:00

60 lines
1.4 KiB
C

/*
* sv_device.h
*
* Created on: 22 Aug 2023
* Author: malyarenko
*/
#ifndef SRC_SERVICE_SV_DEVICE_H_
#define SRC_SERVICE_SV_DEVICE_H_
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdatomic.h>
#include <usblib.h>
#include <usbdevice.h>
#include <efc_usb/service.h>
struct sv_device {
uint32_t usb_base;
/* Флаги состояния */
struct {
bool initialized;
bool connected;
bool enabled;
} flags;
/* Командный интерфейс */
struct {
efc_usb_sv_cmd_handle_t rx_handle;
efc_usb_sv_cmd_buffer_selector_t rx_buffer_selector;
void* rx_param;
atomic_flag rx_lock;
efc_usb_sv_cmd_handle_t tx_handle;
efc_usb_sv_cmd_buffer_selector_t tx_buffer_selector;
void* tx_param;
atomic_flag tx_lock;
} cmd;
/* Управление сбросом */
efc_usb_sv_reset_handle_t reset_handle;
void* reset_handle_param;
};
bool sv_device_validate_config(const struct efc_usb_sv_config* config);
bool sv_device_init(struct sv_device* handler, const struct efc_usb_sv_config* config);
void sv_device_fini(struct sv_device* handler);
bool sv_device_cmd_init(struct sv_device* handler, const struct efc_usb_sv_config* config);
void sv_device_cmd_fini(struct sv_device* handler);
#endif /* SRC_SERVICE_SV_DEVICE_H_ */