Skip to content

Commit 09b020c

Browse files
committed
修复exception_type 输出异常
* 更改变量名称 * 优化输出内容
1 parent cbb883b commit 09b020c

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

src/get_irq.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@
2121
/* Private typedef -----------------------------------------------------------*/
2222
typedef struct
2323
{
24-
rt_uint8_t ldx; //IRQ编号
25-
rt_uint8_t priotity; //优先级
24+
rt_uint8_t ldx; //IRQ编号
25+
rt_uint8_t priotity : 4; //优先级
2626
}type;
2727
/* Private define ------------------------------------------------------------*/
2828
#define irq_printf rt_kprintf
2929
/* Private macro -------------------------------------------------------------*/
3030
#define NAME_LEN 30 //中断名称长度
3131
/* Private variables ---------------------------------------------------------*/
32-
static const char * const exception_name[] = {
32+
static const char * const exception_type_name[] = {
3333
/****** Cortex-M Processor Exceptions Numbers *****************************************************************/
3434
[-NonMaskableInt_IRQn] = "NonMaskableInt_IRQn", /*!< 2 Non Maskable Interrupt */
3535
[-HardFault_IRQn] = "HardFault_IRQn", /*!< 3 Cortex-M Hard Fault Interrupt */
@@ -41,7 +41,7 @@ static const char * const exception_name[] = {
4141
[-PendSV_IRQn] = "PendSV_IRQn", /*!< 14 Cortex-M Pend SV Interrupt */
4242
[-SysTick_IRQn] = "SysTick_IRQn", /*!< 15 Cortex-M System Tick Interrupt */
4343
};
44-
static const char * const nvic_name[] = {
44+
static const char * const irq_name[] = {
4545
#if defined(SOC_SERIES_STM32H7)
4646
#include "inc/irq_stm32h7.h"
4747
#elif defined(SOC_SERIES_STM32F7)
@@ -66,7 +66,7 @@ static const char * const nvic_name[] = {
6666
#error "Unsupported chips"
6767
#endif
6868
};
69-
#define IRQ_LEN sizeof(nvic_name) / sizeof(nvic_name[1])
69+
#define IRQ_LEN sizeof(irq_name) / sizeof(irq_name[1])
7070
/* Private function prototypes -----------------------------------------------*/
7171
rt_inline void object_split(char c,int len)
7272
{
@@ -78,23 +78,23 @@ rt_inline void nvic_irq_header(void)
7878
irq_printf("--- --------"); object_split('-',NAME_LEN - 8);irq_printf(" - - - --------\n");
7979
}
8080
/**
81-
* @brief 获取exception信息.
81+
* @brief 获取exception type信息.
8282
* @param None.
8383
* @retval None.
8484
* @note None.
8585
*/
86-
static void nvic_exception_get(void)
86+
static void nvic_exception_type_get(void)
8787
{
88-
irq_printf("num exception name"); object_split(' ',NAME_LEN - 13); irq_printf("E P A Priotity\n");
89-
irq_printf("--- --------------"); object_split('-',NAME_LEN - 14);irq_printf(" - - - --------\n");
88+
irq_printf("num exception_type name"); object_split(' ',NAME_LEN - 18); irq_printf("E P A Priotity\n");
89+
irq_printf("--- -------------------"); object_split('-',NAME_LEN - 19);irq_printf(" - - - --------\n");
9090

91-
for (rt_int32_t i = NonMaskableInt_IRQn; i <= 1; i++)
91+
for (rt_int32_t i = -NonMaskableInt_IRQn; i > 0; i--)
9292
{
93-
if(exception_name[-i] == RT_NULL)
93+
if(exception_type_name[i] == RT_NULL)
9494
continue;
95-
irq_printf("%3d ",16 + i);
96-
irq_printf("%-*.*s X X X",NAME_LEN,NAME_LEN,exception_name[-i]);
97-
irq_printf(" %02d\n",NVIC_GetPriority((IRQn_Type)+i));
95+
irq_printf("%3d ",-i);
96+
irq_printf("%-*.*s X X X",NAME_LEN,NAME_LEN,exception_type_name[i]);
97+
irq_printf(" %02d\n",NVIC_GetPriority((IRQn_Type)-i));
9898
}
9999
}
100100
/**
@@ -106,7 +106,7 @@ static void nvic_exception_get(void)
106106
static void nvic_irq_get(rt_uint8_t i)
107107
{
108108
irq_printf("%3d ",i);
109-
irq_printf("%-*.*s 1",NAME_LEN,NAME_LEN,nvic_name[i]);
109+
irq_printf("%-*.*s 1",NAME_LEN,NAME_LEN,irq_name[i]);
110110
NVIC_GetPendingIRQ((IRQn_Type)i) ? irq_printf(" 1") : irq_printf(" 0");
111111
NVIC_GetActive((IRQn_Type)i) ? irq_printf(" 1") : irq_printf(" 0");
112112
irq_printf(" %02d\n",NVIC_GetPriority((IRQn_Type)i));
@@ -200,8 +200,8 @@ static void nvic_irq_msh(uint8_t argc, char **argv)
200200

201201
if (argc < 2)
202202
{
203-
nvic_exception_get();
204-
irq_printf("\n\n");
203+
nvic_exception_type_get();
204+
irq_printf("\n");
205205
nvic_irq_get_idx();
206206
}
207207
else

0 commit comments

Comments
 (0)