Skip to content

Commit 8f44e59

Browse files
committed
!debug: LUMP init sequence.
1 parent 2237dc5 commit 8f44e59

File tree

2 files changed

+45
-6
lines changed

2 files changed

+45
-6
lines changed

lib/pbio/drv/bluetooth/bluetooth.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,13 @@ static lwrb_t stdout_ring_buf;
6262
static bool stdout_send_busy;
6363

6464
void pbdrv_bluetooth_init(void) {
65-
// enough for two packets, one currently being sent and one to be ready
65+
// enough for 200 packets, one currently being sent and one to be ready
6666
// as soon as the previous one completes + 1 byte for ring buf pointer
67+
#if PBDRV_CONFIG_BLOCK_DEVICE_RAM_SIZE > (20 * 1024)
68+
static uint8_t stdout_buf[PBDRV_BLUETOOTH_MAX_CHAR_SIZE * 200 + 1];
69+
#else
6770
static uint8_t stdout_buf[PBDRV_BLUETOOTH_MAX_CHAR_SIZE * 2 + 1];
71+
#endif
6872
lwrb_init(&stdout_ring_buf, stdout_buf, PBIO_ARRAY_SIZE(stdout_buf));
6973

7074
pbdrv_bluetooth_init_hci();

lib/pbio/src/port_lump.c

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,51 @@
1616
#include <pbio/port_lump.h>
1717
#include <pbdrv/ioport.h>
1818

19-
#define DEBUG 0
20-
#if DEBUG
19+
#define DEBUG 2
20+
21+
#if DEBUG == 1
2122
#include <stdio.h>
2223
#include <inttypes.h>
2324
#include <pbdrv/../../drv/uart/uart_debug_first_port.h>
24-
#define debug_pr pbdrv_uart_debug_printf
25-
#define DBG_ERR(expr) expr
25+
#define debug_pr printf
26+
#elif DEBUG == 2 && PBDRV_CONFIG_BLOCK_DEVICE_RAM_SIZE > (20 * 1024)
27+
#include <stdarg.h>
28+
#include <inttypes.h>
29+
#include <stdio.h>
30+
#include <string.h>
31+
#include <pbsys/host.h>
32+
int debug_pr(const char *format, ...) {
33+
char buffer[256];
34+
va_list args;
35+
int len;
36+
37+
38+
va_start(args, format);
39+
len = vsnprintf(buffer, sizeof(buffer), format, args);
40+
va_end(args);
41+
42+
if (len < 0) {
43+
return len;
44+
}
45+
46+
if ((size_t)len >= sizeof(buffer)) {
47+
len = sizeof(buffer) - 1;
48+
}
49+
50+
if (len > 0 && buffer[len - 1] == '\n' && (size_t)len + 1 < sizeof(buffer)) {
51+
buffer[len - 1] = '\r';
52+
buffer[len] = '\n';
53+
len++;
54+
}
55+
56+
// Write the formatted string using pbsys_host_stdout_write
57+
uint32_t size = len;
58+
pbsys_host_stdout_write((const uint8_t *)buffer, &size);
59+
60+
return len; // Return the number of characters written
61+
}
2662
#else
2763
#define debug_pr(...)
28-
#define DBG_ERR(expr)
2964
#endif
3065

3166
#define EV3_UART_MAX_MESSAGE_SIZE (LUMP_MAX_MSG_SIZE + 3)

0 commit comments

Comments
 (0)