#define N_A "n/a"
-const char *types_name[96] = {
+static const char *types_name[96] = {
"usbtousart", "usbtospi", "usbtoi2c", "usbtogpio", "usbtocan", "usbtopwm",
"usbtoadc", "usbtodac",
"usbtomicrowire", "usbtoswim", "usbtodusi", N_A, N_A, N_A, "usbtopower", "usbtodelay",
static uint16_t usbtoxxx_current_cmd_index;
static uint8_t *usbtoxxx_buffer;
-uint16_t collect_index;
-uint8_t collect_cmd;
+static uint16_t collect_index;
+static uint8_t collect_cmd;
static uint8_t poll_nesting;
struct usbtoxxx_context_t {
versaloon_pending_idx = c->versaloon_pending_idx;
}
-RESULT usbtoxxx_validate_current_command_type(void)
+static RESULT usbtoxxx_validate_current_command_type(void)
{
if (type_pre > 0) {
/* not the first command */
- if (NULL == usbtoxxx_buffer) {
+ if (!usbtoxxx_buffer) {
LOG_BUG(ERRMSG_INVALID_BUFFER, TO_STR(usbtoxxx_buffer));
return ERRCODE_INVALID_BUFFER;
}
struct versaloon_want_pos_t *tmp;
tmp = versaloon_pending[i].pos;
- while (tmp != NULL) {
- if ((tmp->buff != NULL) && (tmp->size > 0)) {
+ while (tmp) {
+ if ((tmp->buff) && (tmp->size > 0)) {
memcpy(tmp->buff,
versaloon_buf + usbtoxxx_buffer_index
+ tmp->offset,
return (usbtoxxx_abilities[cmd / 8] & (1 << (cmd % 8))) > 0;
}
-RESULT usbtoxxx_ensure_buffer_size(uint16_t cmdlen)
+static RESULT usbtoxxx_ensure_buffer_size(uint16_t cmdlen)
{
/* check free space, commit if not enough */
if (((usbtoxxx_buffer_index + usbtoxxx_current_cmd_index + cmdlen)
if (ERROR_OK != usbtoxxx_ensure_buffer_size(cmdlen + 6))
return ERROR_FAIL;
- if ((type_pre != type) || (NULL == usbtoxxx_buffer)) {
+ if ((type_pre != type) || (!usbtoxxx_buffer)) {
if (ERROR_OK != usbtoxxx_validate_current_command_type()) {
LOG_BUG(ERRMSG_FAILURE_OPERATION, "validate previous commands");
return ERRCODE_FAILURE_OPERATION;
SET_LE_U16(&usbtoxxx_buffer[collect_index], len_tmp);
}
- if (cmdbuf != NULL) {
+ if (cmdbuf) {
memcpy(usbtoxxx_buffer + usbtoxxx_current_cmd_index, cmdbuf, cmdlen);
usbtoxxx_current_cmd_index += cmdlen;
}