still have unknown problems

This commit is contained in:
eddyem
2023-04-26 23:15:52 +03:00
parent b9cb9f6428
commit 3c7687bb0e
11 changed files with 108 additions and 78 deletions

View File

@@ -19,13 +19,14 @@
#include <math.h>
#include <stm32f3.h>
#include <string.h>
#include "usb.h"
/**
* @brief hexdump - dump hex array by 16 bytes in string
* @param sendfun - function to send data
* @param ifno - USB interface number
* @param arr - array to dump
* @param len - length of `arr`
*/
void hexdump(int (*sendfun)(const char *s), uint8_t *arr, uint16_t len){
void hexdump(int ifno, uint8_t *arr, uint16_t len){
char buf[52], *bptr = buf;
for(uint16_t l = 0; l < len; ++l, ++arr){
for(int16_t j = 1; j > -1; --j){
@@ -36,14 +37,14 @@ void hexdump(int (*sendfun)(const char *s), uint8_t *arr, uint16_t len){
if(l % 16 == 15){
*bptr++ = '\n';
*bptr = 0;
sendfun(buf);
USB_sendstr(ifno, buf);
bptr = buf;
}else *bptr++ = ' ';
}
if(bptr != buf){
*bptr++ = '\n';
*bptr = 0;
sendfun(buf);
USB_sendstr(ifno, buf);
}
}