mirror of
https://github.com/djhackersdev/bemanitools.git
synced 2024-11-14 18:27:36 +01:00
aciodrv: refactor aciodrv_device_init function
This commit is contained in:
parent
d529ee484f
commit
5688fb7319
@ -23,11 +23,9 @@ struct aciodrv_device_ctx {
|
|||||||
uint8_t node_count;
|
uint8_t node_count;
|
||||||
};
|
};
|
||||||
|
|
||||||
static bool aciodrv_device_init(struct aciodrv_device_ctx *device)
|
static bool aciodrv_device_reset(struct aciodrv_device_ctx *device)
|
||||||
{
|
{
|
||||||
uint8_t reset_seq[525] = {0};
|
uint8_t reset_seq[525] = {0};
|
||||||
uint8_t init_seq[1] = {AC_IO_SOF};
|
|
||||||
uint8_t read_buff[1] = {0};
|
|
||||||
|
|
||||||
/* init/reset the device by sending 525 NULL bytes */
|
/* init/reset the device by sending 525 NULL bytes */
|
||||||
log_info("Resetting device");
|
log_info("Resetting device");
|
||||||
@ -46,6 +44,14 @@ static bool aciodrv_device_init(struct aciodrv_device_ctx *device)
|
|||||||
aciodrv_port_read(device->fd, reset_seq, sizeof(reset_seq));
|
aciodrv_port_read(device->fd, reset_seq, sizeof(reset_seq));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool aciodrv_device_sof_flush(struct aciodrv_device_ctx *device)
|
||||||
|
{
|
||||||
|
uint8_t init_seq[1] = {AC_IO_SOF};
|
||||||
|
uint8_t read_buff[1] = {0};
|
||||||
|
|
||||||
/* wait for reset to finish */
|
/* wait for reset to finish */
|
||||||
int read = 0;
|
int read = 0;
|
||||||
do {
|
do {
|
||||||
@ -71,6 +77,15 @@ static bool aciodrv_device_init(struct aciodrv_device_ctx *device)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool aciodrv_device_init(struct aciodrv_device_ctx *device)
|
||||||
|
{
|
||||||
|
if (!aciodrv_device_reset(device)) {
|
||||||
|
log_warning("Reset failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return aciodrv_device_sof_flush(device);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef AC_IO_MSG_LOG
|
#ifdef AC_IO_MSG_LOG
|
||||||
static void
|
static void
|
||||||
aciodrv_device_log_buffer(struct aciodrv_device_ctx *device, const char *msg, const uint8_t *buffer, int length)
|
aciodrv_device_log_buffer(struct aciodrv_device_ctx *device, const char *msg, const uint8_t *buffer, int length)
|
||||||
|
Loading…
Reference in New Issue
Block a user