Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
rbiasini committed Jul 3, 2019
1 parent ea908cb commit 955842b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
21 changes: 12 additions & 9 deletions board/drivers/gmlan_alt.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,27 +49,30 @@ int append_crc(char *in, int in_len) {
}
crc &= 0x7fffU;
}
int in_len_copy = in_len;
for (int i = 14; i >= 0; i--) {
in[in_len] = (crc >> (unsigned int)(i)) & 1U;
in_len++;
in[in_len_copy] = (crc >> (unsigned int)(i)) & 1U;
in_len_copy++;
}
return in_len;
return in_len_copy;
}

int append_bits(char *in, int in_len, char *app, int app_len) {
int in_len_copy = in_len;
for (int i = 0; i < app_len; i++) {
in[in_len] = app[i];
in_len++;
in[in_len_copy] = app[i];
in_len_copy++;
}
return in_len;
return in_len_copy;
}

int append_int(char *in, int in_len, int val, int val_len) {
int in_len_copy = in_len;
for (int i = val_len-1; i >= 0; i--) {
in[in_len] = ((unsigned int)(val) & (1U << (unsigned int)(i))) != 0;
in_len++;
in[in_len_copy] = ((unsigned int)(val) & (1U << (unsigned int)(i))) != 0;
in_len_copy++;
}
return in_len;
return in_len_copy;
}

int get_bit_message(char *out, CAN_FIFOMailBox_TypeDef *to_bang) {
Expand Down
13 changes: 7 additions & 6 deletions board/drivers/uart.h
Original file line number Diff line number Diff line change
Expand Up @@ -307,22 +307,23 @@ void putch(const char a) {
}

void puts(const char *a) {
for (;*a;a++) {
if (*a == '\n') putch('\r');
putch(*a);
for (const char *in = a; *in; in++) {
if (*in == '\n') putch('\r');
putch(*in);
}
}

void putui(uint32_t i) {
uint32_t i_copy = i;
char str[11];
uint8_t idx = 10;
str[idx] = '\0';
idx--;
do {
str[idx] = (i % 10) + 0x30;
str[idx] = (i_copy % 10) + 0x30;
idx--;
i /= 10;
} while (i != 0);
i_copy /= 10;
} while (i_copy / 10 != 0);
puts(str + idx + 1);
}

Expand Down

0 comments on commit 955842b

Please sign in to comment.