52 lines
1.3 KiB
C
52 lines
1.3 KiB
C
#ifndef USB_LOGGING_H_
|
|
#define USB_LOGGING_H_
|
|
|
|
// Helper code for saving data to USB
|
|
#include "base/types.h"
|
|
|
|
// Global log buffer and usage:
|
|
static u8 log_buffer[4096];
|
|
static s32 m_log_usage = 0;
|
|
// Sending logs
|
|
static bool m_send_logs = 0;
|
|
static s32 m_log_buffer_send_index = 0;
|
|
static volatile bool tx_complete = true;
|
|
static bool full_tx_complete = false;
|
|
|
|
// Functions for adding to and resetting buffer:
|
|
#define LOG_MODE 0
|
|
// Mode 0: do not wrap around, do not append to buffer
|
|
// Mode 1: wrap around to beginning.
|
|
|
|
// FOR STRING LITERALS ONLY
|
|
// #define JIIM_LOG_USB(strlit) add_to_log_buffer(Create_String(strlit))
|
|
|
|
// Dynamic strings
|
|
static u8 sprint_buffer[128];
|
|
static s32 sprint_length;
|
|
|
|
// #TODO: I need to append a \n here
|
|
#define JIIM_LOG(fmt, ...) \
|
|
sprint_length = sprintf(sprint_buffer, fmt, ##__VA_ARGS__); \
|
|
add_format_string_to_log_buffer()
|
|
|
|
void reset_log_buffer(void);
|
|
void add_to_log_buffer(String str);
|
|
void add_format_string_to_log_buffer(void);
|
|
/*
|
|
void send_usb_log(String str) {
|
|
// Zero buffer:
|
|
//memset(str.data, 0, NRF_DRV_USBD_EPSIZE);
|
|
// Copy string:
|
|
//memcpy(m_tx_buffer, str.data, str.count);
|
|
|
|
app_usbd_cdc_acm_write(&m_app_cdc_acm, str.data, str.count);
|
|
}
|
|
|
|
void log_usb(char* data) {
|
|
send_usb_log(create_string(data));
|
|
}
|
|
*/
|
|
|
|
|
|
#endif // USB_LOGGING_H_
|