/*****************************************************************************/ /* */ /* 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