Тёмный

STM303RE Setting up your own printf function, no coding needed, debugging using ITM stuff 

Shayyan Ali
Подписаться 386
Просмотров 32
50% 1

This is for fellow students going through, youtube descriptions cant ahve angular brackets, so just type in the 3 #includes in the .c file
All this is shamelessly taken from a uni course of mine, and resued here :_)
myDebugger.h
/*
* myDebugger.h
*
* Created on: Jun 17, 2024
* Author: zero
*/
#ifndef INC_MYDEBUGGER_H_
#define INC_MYDEBUGGER_H_
void debug_printf(const char *fmt, ...);
#endif /* INC_MYDEBUGGER_H_ */
myDebugger.c
/*
* myDebugger.c
* This is a debugging library for functions that we can use when debugging :)
*
* Created on: Jun 17, 2024
* Author: zero
*/
// Includes
// RU-vid does not allow angular brakcets, so you will have to type #include for stdio.h, stdint.h, and stdarg.h
#include "myDebugger.h"
#include "stm32f3xx_hal.h"
// Code
//debug_printf sends a max of 256 characters to the ITM SWO t
//It uses a _variable length argument_, same as normal printf and does stuff :)
//Indeed, just call this function as if it was printf
void debug_printf(const char *fmt, ...) {
char buffer[256];
va_list args;
va_start(args, fmt);
vsnprintf(buffer, sizeof(buffer), fmt, args);
va_end(args);
uint16_t i = 0;
while(buffer[i] != '\0') {
ITM_SendChar(buffer[i]);
i++;
}
}

Опубликовано:

 

26 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 1   
@ShayyanAli
@ShayyanAli 3 месяца назад
Dude this such a cool video! You are the best! I should definitely subscribe, like and comment! This guy is so helpful!!!!! THANK YOU SO MUCH :0
Далее