Blame view

Project/econais/inc/STM32F1/libwismart_irqs.h 3.35 KB
Imanol-Mikel Barba Sabariego authored
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116

/*****************************************************************************/
/*                                                                           */
/* Copyright (C) 2010-2012 eConais                                           */
/*                                                                           */
/* Irq Handlers Module                                                       */
/*                                                                           */
/*****************************************************************************/

#include "libwismart.h"

/* include the platform hdrs */
#include "stm32f10x.h"

#define PRINT print

void memp_status(void);

/* ---------------------------------------------------------------------------------- */
/* Errors IRQ Handlers                                                                */
/* ---------------------------------------------------------------------------------- */
#if !defined(LIBWISMART_RELEASE)
static const char *states[] = {THD_STATE_NAMES};
#endif

void NMIVector(void)		{PRINT("NMI");while(1){};}
void MemManageVector(void)	{PRINT("mem!");while(1){};}
void BusFaultVector(void)	{PRINT("bus fault!");while(1){};}
void UsageFaultVector(void)	{PRINT("usage fault!");while(1){};}
void HardFaultVector(void)	{
#if !defined(LIBWISMART_RELEASE)
	size_t nFrag, nSize;
	Thread *tp;

    nFrag = chHeapStatus(NULL, &nSize);

    PRINT("\r\n<======= hard! =======>\r\n");
	PRINT("[Heap Statistics]  FreeFrags:%d ,  FreeSize: %d bytes Core:%d bytes\r\n",nFrag,nSize,chCoreStatus());

    /* ---------------- lwip pools info ------------- */

	/* print statistics of the lwip mem pool */
	memp_status();

    /* ---------------- Threads info ---------------- */
    PRINT("    addr    stack prio refs     state     time StkUnused Name\r\n");
    tp = chRegFirstThread();
    do {
        PRINT("0x%x 0x%x %u %u %s %lu ",
              (uint32_t)tp, (uint32_t)tp->p_ctx.r13,
              (uint32_t)tp->p_prio, (uint32_t)(tp->p_refs - 1),
              states[tp->p_state], (uint32_t)tp->p_time);

#if CH_DBG_ENABLE_STACK_CHECK 
        /* print the unused stack size */
        PRINT("%lu ", (uint32_t)((uint8_t *)tp->p_ctx.r13 - (uint8_t *)tp->p_stklimit));
#endif

        PRINT("%s ", tp->p_name);

        PRINT("\r\n");
        tp = chRegNextThread(tp);
    } while (tp != NULL);

    while(1){};
#endif
}


/* ---------------------------------------------------------------------------------- */
/* IRQ Handlers                                                                       */
/* ---------------------------------------------------------------------------------- */

#ifndef USER_IRQS
// UART recv handler
CH_IRQ_HANDLER(USART1_IRQHandler)
{
    CH_IRQ_PROLOGUE();

    libwismart_UART_IRQHandler();

    CH_IRQ_EPILOGUE();
}

// WiFi external irq
CH_IRQ_HANDLER(EXTI0_IRQHandler)
{
    CH_IRQ_PROLOGUE();

    libwismart_WiFi_IRQHandler();

    CH_IRQ_EPILOGUE();
}

// UART TX dma irq
CH_IRQ_HANDLER(DMA1_Ch4_IRQHandler)
{
    CH_IRQ_PROLOGUE();

    libwismart_UART_TXDMA_IRQHandler();

    CH_IRQ_EPILOGUE();
}


// UART RX dma irq
CH_IRQ_HANDLER(DMA1_Ch5_IRQHandler)
{
    CH_IRQ_PROLOGUE();

    libwismart_UART_RXDMA_IRQHandler();

    CH_IRQ_EPILOGUE();
}

#endif