some more stack shrinking
This commit is contained in:
@@ -8,7 +8,7 @@
|
|||||||
#if USE_DEBUG_UART
|
#if USE_DEBUG_UART
|
||||||
|
|
||||||
// debug printf
|
// debug printf
|
||||||
int _DO_PRINTF(const char *format, ...)
|
void _DO_PRINTF(const char *format, ...)
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
int len;
|
int len;
|
||||||
@@ -25,8 +25,6 @@ int _DO_PRINTF(const char *format, ...)
|
|||||||
|
|
||||||
_write_r(NULL, 2, dbg_buf, (size_t) len);
|
_write_r(NULL, 2, dbg_buf, (size_t) len);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
return len;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -34,19 +32,10 @@ int _DO_PRINTF(const char *format, ...)
|
|||||||
* @param string - buffer to print
|
* @param string - buffer to print
|
||||||
* @param len - number of bytes to print
|
* @param len - number of bytes to print
|
||||||
*/
|
*/
|
||||||
void PUTSN(const char *string, size_t len)
|
void PUTSN(const char *string, uint16_t len)
|
||||||
{
|
{
|
||||||
if (len == 0) len = strlen(string);
|
if (len == 0) len = (uint16_t) strlen(string);
|
||||||
_write_r(NULL, 2, string, (size_t) len);
|
debug_write(string, len);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Puts a newline
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
void PUTNL(void)
|
|
||||||
{
|
|
||||||
_write_r(NULL, 2, "\r\n", 2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -54,22 +43,11 @@ void PUTNL(void)
|
|||||||
* @param string - string to print, zero-terminated
|
* @param string - string to print, zero-terminated
|
||||||
* @return number of characters printed
|
* @return number of characters printed
|
||||||
*/
|
*/
|
||||||
int PUTS(const char *string)
|
void PUTS(const char *string)
|
||||||
{
|
{
|
||||||
size_t len = strlen(string);
|
size_t len = strlen(string);
|
||||||
_write_r(NULL, 2, string, len);
|
debug_write(string, (uint16_t) len);
|
||||||
return (int) len;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Print one character to debug uart
|
|
||||||
* @param ch - character ASCII code
|
|
||||||
* @return the character code
|
|
||||||
*/
|
|
||||||
int PUTCHAR(int ch)
|
|
||||||
{
|
|
||||||
_write_r(NULL, 2, &ch, 1);
|
|
||||||
return ch; // or EOF
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -11,11 +11,26 @@
|
|||||||
|
|
||||||
#if USE_DEBUG_UART
|
#if USE_DEBUG_UART
|
||||||
|
|
||||||
int _DO_PRINTF(const char *format, ...) __attribute__((format(printf,1,2))) ;
|
extern void debug_write(const char *buf, uint16_t len);
|
||||||
void PUTSN(const char *string, size_t len);
|
|
||||||
int PUTS(const char *string);
|
void _DO_PRINTF(const char *format, ...) __attribute__((format(printf,1,2))) ;
|
||||||
void PUTNL(void);
|
void PUTSN(const char *string, uint16_t len);
|
||||||
int PUTCHAR(int ch);
|
void PUTS(const char *string);
|
||||||
|
|
||||||
|
static inline void PUTNL(void)
|
||||||
|
{
|
||||||
|
debug_write("\r\n", 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Print one character to debug uart
|
||||||
|
* @param ch - character ASCII code
|
||||||
|
* @return the character code
|
||||||
|
*/
|
||||||
|
static inline void PUTCHAR(char ch)
|
||||||
|
{
|
||||||
|
debug_write(&ch, 1);
|
||||||
|
}
|
||||||
|
|
||||||
#define PRINTF(format, ...) do { \
|
#define PRINTF(format, ...) do { \
|
||||||
if (VA_ARG_COUNT(__VA_ARGS__) == 0) { \
|
if (VA_ARG_COUNT(__VA_ARGS__) == 0) { \
|
||||||
|
|||||||
@@ -364,12 +364,12 @@ static void export_unit_do(UlistEntry *li, IniWriter *iw)
|
|||||||
{
|
{
|
||||||
// special message for failed unit die to resource
|
// special message for failed unit die to resource
|
||||||
if (pUnit->status == E_RESOURCE_NOT_AVAILABLE) {
|
if (pUnit->status == E_RESOURCE_NOT_AVAILABLE) {
|
||||||
iw_comment(iw, "!!! %s not available, already held by %s",
|
iw_commentf(iw, "!!! %s not available, already held by %s",
|
||||||
rsc_get_name(pUnit->failed_rsc),
|
rsc_get_name(pUnit->failed_rsc),
|
||||||
rsc_get_owner_name(pUnit->failed_rsc));
|
rsc_get_owner_name(pUnit->failed_rsc));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
iw_comment(iw, "!!! %s", error_get_message(pUnit->status));
|
iw_commentf(iw, "!!! %s", error_get_message(pUnit->status));
|
||||||
}
|
}
|
||||||
iw_cmt_newline(iw);
|
iw_cmt_newline(iw);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ GEX_CFLAGS = \
|
|||||||
-MD -Wno-redundant-decls -Wno-unused-parameter \
|
-MD -Wno-redundant-decls -Wno-unused-parameter \
|
||||||
-Wno-unused-variable -Wno-inline \
|
-Wno-unused-variable -Wno-inline \
|
||||||
-fmerge-constants -fmerge-all-constants -Wno-implicit-fallthrough \
|
-fmerge-constants -fmerge-all-constants -Wno-implicit-fallthrough \
|
||||||
-fno-exceptions -finline-small-functions -findirect-inlining -Wno-strict-aliasing -Wno-float-equal -Wno-discarded-qualifiers
|
-fno-exceptions -finline-small-functions -findirect-inlining -Wno-strict-aliasing -Wno-float-equal -Wno-discarded-qualifiers -fstack-usage
|
||||||
|
|
||||||
GEX_CDEFS_BASE = \
|
GEX_CDEFS_BASE = \
|
||||||
-D__weak="__attribute__((weak))" \
|
-D__weak="__attribute__((weak))" \
|
||||||
|
|||||||
@@ -106,18 +106,19 @@ void DebugUart_PreInit(void)
|
|||||||
LL_USART_Enable(DEBUG_USART);
|
LL_USART_Enable(DEBUG_USART);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void debug_write(const char *buf, uint16_t len)
|
||||||
|
{
|
||||||
|
for (uint16_t i = 0; i < len; i++) {
|
||||||
|
while (!LL_USART_IsActiveFlag_TC(DEBUG_USART));
|
||||||
|
LL_USART_TransmitData8(DEBUG_USART, (uint8_t) *buf++);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Debug print, used by debug / newlib */
|
/** Debug print, used by debug / newlib */
|
||||||
ssize_t _write_r(struct _reent *rptr, int fd, const void *buf, size_t len)
|
ssize_t _write_r(struct _reent *rptr, int fd, const void *buf, size_t len)
|
||||||
{
|
{
|
||||||
(void)rptr;
|
(void)rptr;
|
||||||
|
debug_write(buf, len);
|
||||||
uint8_t *buff = buf;
|
|
||||||
|
|
||||||
for (uint32_t i = 0; i < len; i++) {
|
|
||||||
while (!LL_USART_IsActiveFlag_TC(DEBUG_USART));
|
|
||||||
LL_USART_TransmitData8(DEBUG_USART, *buff++);
|
|
||||||
}
|
|
||||||
|
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,4 +8,6 @@
|
|||||||
void DebugUart_PreInit(void);
|
void DebugUart_PreInit(void);
|
||||||
void DebugUart_Init(void);
|
void DebugUart_Init(void);
|
||||||
|
|
||||||
|
void debug_write(const char *buf, uint16_t len);
|
||||||
|
|
||||||
#endif //GEX_DEBUG_UART_H
|
#endif //GEX_DEBUG_UART_H
|
||||||
|
|||||||
+11
-1
@@ -82,7 +82,7 @@ void iw_section(IniWriter *iw, const char *format, ...)
|
|||||||
iw_string(iw, "]\r\n");
|
iw_string(iw, "]\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void iw_comment(IniWriter *iw, const char *format, ...)
|
void iw_commentf(IniWriter *iw, const char *format, ...)
|
||||||
{
|
{
|
||||||
if (iw->count == 0) return;
|
if (iw->count == 0) return;
|
||||||
if (!SystemSettings.ini_comments) return;
|
if (!SystemSettings.ini_comments) return;
|
||||||
@@ -92,6 +92,16 @@ void iw_comment(IniWriter *iw, const char *format, ...)
|
|||||||
iw_newline(iw);
|
iw_newline(iw);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void iw_comment(IniWriter *iw, const char *text)
|
||||||
|
{
|
||||||
|
if (iw->count == 0) return;
|
||||||
|
if (!SystemSettings.ini_comments) return;
|
||||||
|
|
||||||
|
iw_string(iw, "# ");
|
||||||
|
iw_string(iw, text);
|
||||||
|
iw_newline(iw);
|
||||||
|
}
|
||||||
|
|
||||||
void iw_hdr_comment(IniWriter *iw, const char *format, ...)
|
void iw_hdr_comment(IniWriter *iw, const char *format, ...)
|
||||||
{
|
{
|
||||||
if (iw->count == 0) return;
|
if (iw->count == 0) return;
|
||||||
|
|||||||
+8
-1
@@ -85,13 +85,20 @@ void iw_sprintf(IniWriter *iw, const char *format, ...)
|
|||||||
void iw_section(IniWriter *iw, const char *format, ...)
|
void iw_section(IniWriter *iw, const char *format, ...)
|
||||||
__attribute__((format(printf,2,3)));
|
__attribute__((format(printf,2,3)));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Try to write a INI comment # blah\r\n
|
||||||
|
* @param iw - iniwriter handle
|
||||||
|
* @param text - format, like printf
|
||||||
|
*/
|
||||||
|
void iw_comment(IniWriter *iw, const char *text);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Try to write a INI comment # blah\r\n
|
* Try to write a INI comment # blah\r\n
|
||||||
* @param iw - iniwriter handle
|
* @param iw - iniwriter handle
|
||||||
* @param format - format, like printf
|
* @param format - format, like printf
|
||||||
* @param ... - replacements
|
* @param ... - replacements
|
||||||
*/
|
*/
|
||||||
void iw_comment(IniWriter *iw, const char *format, ...)
|
void iw_commentf(IniWriter *iw, const char *format, ...)
|
||||||
__attribute__((format(printf,2,3)));
|
__attribute__((format(printf,2,3)));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user