You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.1 KiB
49 lines
1.1 KiB
|
1 month ago
|
#include "app_owi_service.h"
|
||
|
|
#include "owi.h"
|
||
|
|
#include <string.h>
|
||
|
|
|
||
|
|
static app_owi_result_t app_owi_from_raw(const owi_io_result_t *io)
|
||
|
|
{
|
||
|
|
app_owi_result_t r;
|
||
|
|
uint16_t i;
|
||
|
|
|
||
|
|
memset(&r, 0, sizeof(r));
|
||
|
|
|
||
|
|
if (!io) {
|
||
|
|
r.ok = 0;
|
||
|
|
return r;
|
||
|
|
}
|
||
|
|
|
||
|
|
r.ok = io->ok;
|
||
|
|
r.timeout = io->timeout;
|
||
|
|
r.read_len = io->read_len;
|
||
|
|
r.timeout_byte_index = io->timeout_byte_index;
|
||
|
|
r.timeout_bit_index = io->timeout_bit_index;
|
||
|
|
|
||
|
|
for (i = 0; i < io->read_len && i < OWI_IO_MAX_BYTES; i++) {
|
||
|
|
r.data[i] = io->data[i];
|
||
|
|
}
|
||
|
|
|
||
|
|
return r;
|
||
|
|
}
|
||
|
|
|
||
|
|
app_owi_result_t app_owi_read_basic(uint8_t id, int length)
|
||
|
|
{
|
||
|
|
owi_io_result_t io;
|
||
|
|
OWI_ReadBytesRaw(length, id, &io);
|
||
|
|
return app_owi_from_raw(&io);
|
||
|
|
}
|
||
|
|
|
||
|
|
app_owi_result_t app_owi_write_basic(uint8_t id, const uint8_t *tx_data, uint8_t tx_len)
|
||
|
|
{
|
||
|
|
owi_io_result_t io;
|
||
|
|
OWI_CommandModeRaw(tx_data, tx_len, id, &io);
|
||
|
|
return app_owi_from_raw(&io);
|
||
|
|
}
|
||
|
|
|
||
|
|
app_owi_result_t app_owi_write_t_basic(uint8_t id, const uint8_t *tx_data, uint8_t tx_len)
|
||
|
|
{
|
||
|
|
owi_io_result_t io;
|
||
|
|
OWI_T_CommandModeRaw(tx_data, tx_len, id, &io);
|
||
|
|
return app_owi_from_raw(&io);
|
||
|
|
}
|