mirror of
https://github.com/opentx/opentx.git
synced 2025-07-16 04:45:17 +03:00
200 lines
5.8 KiB
C
200 lines
5.8 KiB
C
/*
|
|
* Authors (alphabetical order)
|
|
* - Andre Bernet <bernet.andre@gmail.com>
|
|
* - Andreas Weitl
|
|
* - Bertrand Songis <bsongis@gmail.com>
|
|
* - Bryan J. Rentoul (Gruvin) <gruvin@gmail.com>
|
|
* - Cameron Weeks <th9xer@gmail.com>
|
|
* - Erez Raviv
|
|
* - Gabriel Birkus
|
|
* - Jean-Pierre Parisy
|
|
* - Karl Szmutny
|
|
* - Michael Blandford
|
|
* - Michal Hlavinka
|
|
* - Pat Mackenzie
|
|
* - Philip Moss
|
|
* - Rob Thomson
|
|
* - Romolo Manfredini <romolo.manfredini@gmail.com>
|
|
* - Thomas Husterer
|
|
*
|
|
* opentx is based on code named
|
|
* gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/,
|
|
* er9x by Erez Raviv: http://code.google.com/p/er9x/,
|
|
* and the original (and ongoing) project by
|
|
* Thomas Husterer, th9x: http://code.google.com/p/th9x/
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
* published by the Free Software Foundation.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
*/
|
|
|
|
#ifndef debug_h
|
|
#define debug_h
|
|
|
|
#include <inttypes.h>
|
|
#include "rtc.h"
|
|
|
|
#if defined(SIMU)
|
|
|
|
#include <stdio.h>
|
|
|
|
#define TRACE(...) do { printf(__VA_ARGS__); printf("\n"); fflush(stdout); } while(0)
|
|
#define TRACE_DEBUG(...) do { printf("-D- " __VA_ARGS__); fflush(stdout); } while(0)
|
|
#define TRACE_DEBUG_WP(...) do { printf(__VA_ARGS__); fflush(stdout); } while(0)
|
|
#define TRACE_INFO(...) do { printf("-I- " __VA_ARGS__); fflush(stdout); } while(0)
|
|
#define TRACE_INFO_WP(...) do { printf(__VA_ARGS__); fflush(stdout); } while(0)
|
|
#define TRACE_WARNING(...) do { printf("-W- " __VA_ARGS__); fflush(stdout); } while(0)
|
|
#define TRACE_WARNING_WP(...) do { printf(__VA_ARGS__); fflush(stdout); } while(0)
|
|
#define TRACE_ERROR(...) do { printf("-E- " __VA_ARGS__); fflush(stdout); } while(0)
|
|
#define FLUSH()
|
|
|
|
inline void dump(void * data, unsigned int size)
|
|
{
|
|
unsigned char *uchar_data = (unsigned char *)data;
|
|
|
|
printf("DUMP %d bytes ...\n\r", size);
|
|
unsigned int i = 0, j=0;
|
|
while (i*32+j < size) {
|
|
printf("%.2X ", uchar_data[i*32+j]);
|
|
j++;
|
|
if (j==32) {
|
|
i++; j=0;
|
|
printf("\n\r");
|
|
}
|
|
}
|
|
printf("\n\r");
|
|
}
|
|
#define DUMP(data, size) dump(data, size)
|
|
|
|
#elif defined(DEBUG) && defined(CPUARM)
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
void debugPuts(const char *string, ...);
|
|
void dump(unsigned char *data, unsigned int size);
|
|
void debugFlush();
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#define TRACE(...) do { debugPuts(__VA_ARGS__); debugPuts("\r\n"); } while(0)
|
|
#define DUMP(data, size) dump(data, size)
|
|
#define TRACE_DEBUG(...) debugPuts("-D- " __VA_ARGS__)
|
|
#define TRACE_DEBUG_WP(...) debugPuts(__VA_ARGS__)
|
|
#define TRACE_INFO(...) debugPuts("-I- " __VA_ARGS__)
|
|
#define TRACE_INFO_WP(...) debugPuts(__VA_ARGS__)
|
|
#define TRACE_WARNING(...) debugPuts("-W- " __VA_ARGS__)
|
|
#define TRACE_WARNING_WP(...) debugPuts(__VA_ARGS__)
|
|
#define TRACE_ERROR(...) debugPuts("-E- " __VA_ARGS__)
|
|
#define FLUSH() debugFlush();
|
|
void debugTask(void* pdata);
|
|
|
|
#else
|
|
|
|
#define TRACE(...) { }
|
|
#define DUMP(...) { }
|
|
#define TRACE_DEBUG(...) { }
|
|
#define TRACE_DEBUG_WP(...) { }
|
|
#define TRACE_INFO(...) { }
|
|
#define TRACE_INFO_WP(...) { }
|
|
#define TRACE_WARNING(...) { }
|
|
#define TRACE_WARNING_WP(...) { }
|
|
#define TRACE_ERROR(...) { }
|
|
#define FLUSH()
|
|
|
|
#endif
|
|
|
|
|
|
#if defined(DEBUG_TRACE_BUFFER)
|
|
|
|
#define TRACE_BUFFER_LEN 50
|
|
|
|
enum TraceEvent {
|
|
trace_start = 1,
|
|
|
|
sd_wait_ready = 10,
|
|
sd_rcvr_datablock,
|
|
sd_xmit_datablock_wait_ready,
|
|
sd_xmit_datablock_rcvr_spi,
|
|
sd_send_cmd_wait_ready,
|
|
sd_send_cmd_rcvr_spi,
|
|
|
|
sd_SD_ReadSectors = 16,
|
|
sd_disk_read,
|
|
sd_SD_WriteSectors,
|
|
sd_disk_write,
|
|
|
|
sd_disk_ioctl_CTRL_SYNC = 20,
|
|
sd_disk_ioctl_GET_SECTOR_COUNT,
|
|
sd_disk_ioctl_MMC_GET_CSD,
|
|
sd_disk_ioctl_MMC_GET_CID,
|
|
sd_disk_ioctl_MMC_GET_OCR,
|
|
sd_disk_ioctl_MMC_GET_SDSTAT_1,
|
|
sd_disk_ioctl_MMC_GET_SDSTAT_2,
|
|
sd_spi_reset,
|
|
|
|
ff_f_write_validate = 30,
|
|
ff_f_write_flag,
|
|
ff_f_write_clst,
|
|
ff_f_write_sync_window,
|
|
ff_f_write_disk_write_dirty,
|
|
ff_f_write_clust2sect,
|
|
ff_f_write_disk_write,
|
|
ff_f_write_disk_read,
|
|
ff_f_write_move_window,
|
|
|
|
audio_getNextFilledBuffer_skip = 50,
|
|
};
|
|
|
|
struct TraceElement {
|
|
gtime_t time;
|
|
uint8_t time_ms;
|
|
uint8_t event;
|
|
uint32_t data;
|
|
};
|
|
|
|
void trace_event(enum TraceEvent event, uint32_t data);
|
|
void trace_event_i(enum TraceEvent event, uint32_t data);
|
|
const struct TraceElement * getTraceElement(uint16_t idx);
|
|
void dumpTraceBuffer();
|
|
|
|
#define TRACE_EVENT(condition, event, data) if (condition) { trace_event(event, data); }
|
|
#define TRACEI_EVENT(condition, event, data) if (condition) { trace_event_i(event, data); }
|
|
|
|
#else // #if defined(DEBUG_TRACE_BUFFER)
|
|
|
|
#define TRACE_EVENT(condition, event, data)
|
|
#define TRACEI_EVENT(condition, event, data)
|
|
|
|
#endif // #if defined(DEBUG_TRACE_BUFFER)
|
|
|
|
#if defined(TRACE_SD_CARD)
|
|
#define TRACE_SD_CARD_EVENT(condition, event, data) TRACE_EVENT(condition, event, data)
|
|
#else
|
|
#define TRACE_SD_CARD_EVENT(condition, event, data)
|
|
#endif
|
|
#if defined(TRACE_FATFS)
|
|
#define TRACE_FATFS_EVENT(condition, event, data) TRACE_EVENT(condition, event, data)
|
|
#else
|
|
#define TRACE_FATFS_EVENT(condition, event, data)
|
|
#endif
|
|
#if defined(TRACE_AUDIO)
|
|
#define TRACE_AUDIO_EVENT(condition, event, data) TRACE_EVENT(condition, event, data)
|
|
#define TRACEI_AUDIO_EVENT(condition, event, data) TRACEI_EVENT(condition, event, data)
|
|
#else
|
|
#define TRACE_AUDIO_EVENT(condition, event, data)
|
|
#define TRACEI_AUDIO_EVENT(condition, event, data)
|
|
#endif
|
|
|
|
|
|
#endif // #ifndef debug_h
|
|
|