stm32/extint: Make ExtInt.regs print using mp_printf.

Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
Damien George 2023-03-09 11:16:55 +11:00
parent f6a35f76af
commit f43c4dfc68
1 changed files with 43 additions and 44 deletions

View File

@ -24,10 +24,6 @@
* THE SOFTWARE.
*/
#include <stdio.h>
#include <stddef.h>
#include <string.h>
#include "py/runtime.h"
#include "py/gc.h"
#include "py/mphal.h"
@ -554,53 +550,56 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(extint_obj_swint_obj, extint_obj_swint);
/// \classmethod regs()
/// Dump the values of the EXTI registers.
STATIC mp_obj_t extint_regs(void) {
const mp_print_t *print = &mp_plat_print;
#if defined(STM32G0) || defined(STM32G4) || defined(STM32L4) || defined(STM32WB) || defined(STM32WL)
printf("EXTI_IMR1 %08x\n", (unsigned int)EXTI->IMR1);
printf("EXTI_IMR2 %08x\n", (unsigned int)EXTI->IMR2);
printf("EXTI_EMR1 %08x\n", (unsigned int)EXTI->EMR1);
printf("EXTI_EMR2 %08x\n", (unsigned int)EXTI->EMR2);
printf("EXTI_RTSR1 %08x\n", (unsigned int)EXTI->RTSR1);
printf("EXTI_RTSR2 %08x\n", (unsigned int)EXTI->RTSR2);
printf("EXTI_FTSR1 %08x\n", (unsigned int)EXTI->FTSR1);
printf("EXTI_FTSR2 %08x\n", (unsigned int)EXTI->FTSR2);
printf("EXTI_SWIER1 %08x\n", (unsigned int)EXTI->SWIER1);
printf("EXTI_SWIER2 %08x\n", (unsigned int)EXTI->SWIER2);
mp_printf(print, "EXTI_IMR1 %08x\n", (unsigned int)EXTI->IMR1);
mp_printf(print, "EXTI_IMR2 %08x\n", (unsigned int)EXTI->IMR2);
mp_printf(print, "EXTI_EMR1 %08x\n", (unsigned int)EXTI->EMR1);
mp_printf(print, "EXTI_EMR2 %08x\n", (unsigned int)EXTI->EMR2);
mp_printf(print, "EXTI_RTSR1 %08x\n", (unsigned int)EXTI->RTSR1);
mp_printf(print, "EXTI_RTSR2 %08x\n", (unsigned int)EXTI->RTSR2);
mp_printf(print, "EXTI_FTSR1 %08x\n", (unsigned int)EXTI->FTSR1);
mp_printf(print, "EXTI_FTSR2 %08x\n", (unsigned int)EXTI->FTSR2);
mp_printf(print, "EXTI_SWIER1 %08x\n", (unsigned int)EXTI->SWIER1);
mp_printf(print, "EXTI_SWIER2 %08x\n", (unsigned int)EXTI->SWIER2);
#if defined(STM32G0)
printf("EXTI_RPR1 %08x\n", (unsigned int)EXTI->RPR1);
printf("EXTI_FPR1 %08x\n", (unsigned int)EXTI->FPR1);
printf("EXTI_RPR2 %08x\n", (unsigned int)EXTI->RPR2);
printf("EXTI_FPR2 %08x\n", (unsigned int)EXTI->FPR2);
mp_printf(print, "EXTI_RPR1 %08x\n", (unsigned int)EXTI->RPR1);
mp_printf(print, "EXTI_FPR1 %08x\n", (unsigned int)EXTI->FPR1);
mp_printf(print, "EXTI_RPR2 %08x\n", (unsigned int)EXTI->RPR2);
mp_printf(print, "EXTI_FPR2 %08x\n", (unsigned int)EXTI->FPR2);
#else
printf("EXTI_PR1 %08x\n", (unsigned int)EXTI->PR1);
printf("EXTI_PR2 %08x\n", (unsigned int)EXTI->PR2);
mp_printf(print, "EXTI_PR1 %08x\n", (unsigned int)EXTI->PR1);
mp_printf(print, "EXTI_PR2 %08x\n", (unsigned int)EXTI->PR2);
#endif
#elif defined(STM32H7)
printf("EXTI_IMR1 %08x\n", (unsigned int)EXTI_D1->IMR1);
printf("EXTI_IMR2 %08x\n", (unsigned int)EXTI_D1->IMR2);
printf("EXTI_IMR3 %08x\n", (unsigned int)EXTI_D1->IMR3);
printf("EXTI_EMR1 %08x\n", (unsigned int)EXTI_D1->EMR1);
printf("EXTI_EMR2 %08x\n", (unsigned int)EXTI_D1->EMR2);
printf("EXTI_EMR3 %08x\n", (unsigned int)EXTI_D1->EMR3);
printf("EXTI_RTSR1 %08x\n", (unsigned int)EXTI->RTSR1);
printf("EXTI_RTSR2 %08x\n", (unsigned int)EXTI->RTSR2);
printf("EXTI_RTSR3 %08x\n", (unsigned int)EXTI->RTSR3);
printf("EXTI_FTSR1 %08x\n", (unsigned int)EXTI->FTSR1);
printf("EXTI_FTSR2 %08x\n", (unsigned int)EXTI->FTSR2);
printf("EXTI_FTSR3 %08x\n", (unsigned int)EXTI->FTSR3);
printf("EXTI_SWIER1 %08x\n", (unsigned int)EXTI->SWIER1);
printf("EXTI_SWIER2 %08x\n", (unsigned int)EXTI->SWIER2);
printf("EXTI_SWIER3 %08x\n", (unsigned int)EXTI->SWIER3);
printf("EXTI_PR1 %08x\n", (unsigned int)EXTI_D1->PR1);
printf("EXTI_PR2 %08x\n", (unsigned int)EXTI_D1->PR2);
printf("EXTI_PR3 %08x\n", (unsigned int)EXTI_D1->PR3);
mp_printf(print, "EXTI_IMR1 %08x\n", (unsigned int)EXTI_D1->IMR1);
mp_printf(print, "EXTI_IMR2 %08x\n", (unsigned int)EXTI_D1->IMR2);
mp_printf(print, "EXTI_IMR3 %08x\n", (unsigned int)EXTI_D1->IMR3);
mp_printf(print, "EXTI_EMR1 %08x\n", (unsigned int)EXTI_D1->EMR1);
mp_printf(print, "EXTI_EMR2 %08x\n", (unsigned int)EXTI_D1->EMR2);
mp_printf(print, "EXTI_EMR3 %08x\n", (unsigned int)EXTI_D1->EMR3);
mp_printf(print, "EXTI_RTSR1 %08x\n", (unsigned int)EXTI->RTSR1);
mp_printf(print, "EXTI_RTSR2 %08x\n", (unsigned int)EXTI->RTSR2);
mp_printf(print, "EXTI_RTSR3 %08x\n", (unsigned int)EXTI->RTSR3);
mp_printf(print, "EXTI_FTSR1 %08x\n", (unsigned int)EXTI->FTSR1);
mp_printf(print, "EXTI_FTSR2 %08x\n", (unsigned int)EXTI->FTSR2);
mp_printf(print, "EXTI_FTSR3 %08x\n", (unsigned int)EXTI->FTSR3);
mp_printf(print, "EXTI_SWIER1 %08x\n", (unsigned int)EXTI->SWIER1);
mp_printf(print, "EXTI_SWIER2 %08x\n", (unsigned int)EXTI->SWIER2);
mp_printf(print, "EXTI_SWIER3 %08x\n", (unsigned int)EXTI->SWIER3);
mp_printf(print, "EXTI_PR1 %08x\n", (unsigned int)EXTI_D1->PR1);
mp_printf(print, "EXTI_PR2 %08x\n", (unsigned int)EXTI_D1->PR2);
mp_printf(print, "EXTI_PR3 %08x\n", (unsigned int)EXTI_D1->PR3);
#else
printf("EXTI_IMR %08x\n", (unsigned int)EXTI->IMR);
printf("EXTI_EMR %08x\n", (unsigned int)EXTI->EMR);
printf("EXTI_RTSR %08x\n", (unsigned int)EXTI->RTSR);
printf("EXTI_FTSR %08x\n", (unsigned int)EXTI->FTSR);
printf("EXTI_SWIER %08x\n", (unsigned int)EXTI->SWIER);
printf("EXTI_PR %08x\n", (unsigned int)EXTI->PR);
mp_printf(print, "EXTI_IMR %08x\n", (unsigned int)EXTI->IMR);
mp_printf(print, "EXTI_EMR %08x\n", (unsigned int)EXTI->EMR);
mp_printf(print, "EXTI_RTSR %08x\n", (unsigned int)EXTI->RTSR);
mp_printf(print, "EXTI_FTSR %08x\n", (unsigned int)EXTI->FTSR);
mp_printf(print, "EXTI_SWIER %08x\n", (unsigned int)EXTI->SWIER);
mp_printf(print, "EXTI_PR %08x\n", (unsigned int)EXTI->PR);
#endif
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_0(extint_regs_fun_obj, extint_regs);