Browse Source

add debug_suspend() / assert print works

makefile_for_cmsis
heck 2 years ago
parent
commit
84fd09ae54
  1. 27
      src/cppmain.cc
  2. 4
      src/cppmain.h

27
src/cppmain.cc

@ -10,6 +10,12 @@ const double pi{ std::acos(-1) };
#define BUFFER_SIZE 512
namespace Heck {
bool debug_suspend_active = false;
void debug_suspend_continue() {
debug_suspend_active = false;
}
// Serial Logging
// --------------
void log(std::string msg)
@ -72,10 +78,7 @@ namespace Heck {
// CALLBACKS
void irq1_cb()
{
if (!is_running) {
is_running = true;
return;
}
debug_suspend_continue();
}
void timer2_cb()
@ -121,7 +124,7 @@ namespace Heck {
{
log("buffer_init_sin()");
for (int i = 0; i < BUFFER_SIZE; i++) {
float p = float(i) / (float)BUFFER_SIZE - 0.5;
float p = float(i) / (float)BUFFER_SIZE - 0.5 / 2.;
u32 val = sin(p) * 4096;
audio_buffer[i] = val;
log(std::to_string(val));
@ -149,9 +152,7 @@ namespace Heck {
void main()
{
while (!is_running) {
HAL_Delay(1);
}
heck_debug_suspend();
log("Starting...");
dac_start_dma();
@ -177,6 +178,14 @@ namespace Heck {
// C Linkage (Bridging)
// ----------------------------------------------------------------------------------------------
void heck_debug_suspend(void) {
Heck::debug_suspend_active = true;
while(Heck::debug_suspend_active == true) {
Heck::log("debug_suspend...");
HAL_Delay(1000);
}
}
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
if (GPIO_Pin == GPIO_PIN_0) {
@ -238,7 +247,7 @@ void assert_failed(uint8_t *file, uint32_t line)
ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
int str_size = 1024;
char str[str_size];
snprintf(str, str_size, "assert failed: %s:%d");
snprintf(str, str_size, "assert failed: %s:%d",file,line);
heck_log(str);
}

4
src/cppmain.h

@ -12,6 +12,7 @@ extern "C" {
void heck_cppmain(void);
void heck_log(char* msg);
void heck_debug_suspend(void);
void assert_failed(uint8_t* file, uint32_t line);
void Error_Handler(void);
@ -32,8 +33,7 @@ extern "C" {
using u32 = uint32_t;
namespace Heck {
bool is_running{ false };
void debug_suspend_continue();
// Serial Logging
void log(std::string msg);

Loading…
Cancel
Save