static void dma_init(DMA_Stream_TypeDef *dma_stream, uint32_t dma_channel, uint32_t direction) { DMAHandle.Instance = dma_stream; DMAHandle.Init.Channel = dma_channel; DMAHandle.Init.Direction = direction; DMAHandle.Init.MemInc = DMA_MINC_ENABLE; DMAHandle.Init.PeriphInc = DMA_PINC_DISABLE; DMAHandle.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD; DMAHandle.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; DMAHandle.Init.Mode = DMA_PFCTRL; DMAHandle.Init.Priority = DMA_PRIORITY_LOW; DMAHandle.Init.FIFOMode = DMA_FIFOMODE_ENABLE; DMAHandle.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; DMAHandle.Init.MemBurst = DMA_MBURST_INC4; DMAHandle.Init.PeriphBurst = DMA_PBURST_INC4; // Associate the DMA handle with the SDIO handle // Note: The DMA handle is linked to both SDIO TX/RX handles // since we're using a single DMA channel/IRQHandler for TX/RX. __HAL_LINKDMA(&SDHandle, hdmatx, DMAHandle); __HAL_LINKDMA(&SDHandle, hdmarx, DMAHandle); HAL_DMA_DeInit(&DMAHandle); if (HAL_DMA_Init(&DMAHandle) != HAL_OK) { // Initialization Error __BKPT(0); } // Configure and enable SD IRQ Channel HAL_NVIC_SetPriority(DMA2_Stream3_IRQn, IRQ_PRI_DMA, IRQ_SUBPRI_DMA); HAL_NVIC_EnableIRQ(DMA2_Stream3_IRQn); }
static void __fatal(char *msg) { __enable_irq(); Board_UARTPutSTR(msg); while(1) { __BKPT(0); } }
void Dummy_Handler(void) { #if defined DEBUG __BKPT(3); #endif for (;;) { } }
//we override __assert_func to flash the leds (so we know something bad has happend) //and to repeat the error message repeatedly (so we have a chance to attach the device to a serial console before the error message is gone) void __assert_func( const char *file, int line, const char *func, const char *failedexpr) { start_atomic(); led_on(0); led_on(2); led_on(3); while(1) { #if defined(FRAMEWORK_LOG_ENABLED) printf("assertion \"%s\" failed: file \"%s\", line %d%s%s\n",failedexpr, file, line, func ? ", function: " : "", func ? func : ""); #endif __BKPT (0); // break into debugger, when attached for(uint32_t j = 0; j < 20; j++) { //blink at twice the frequency of the _exit call, so we can identify which of the two events has occurred for(uint32_t i = 0; i < 0xFFFFF; i++){} led_toggle(0); led_toggle(2); led_toggle(3); } } end_atomic(); }
void __assert_func(const char *file, int line, const char *func, const char *failedExpr) { PRINTF("ASSERT ERROR \" %s \": file \"%s\" Line \"%d\" function name \"%s\" \n", failedExpr, file, line, func); for (;;) { __BKPT(0); } }
void __aeabi_assert(const char *failedExpr, const char *file, int line) { PRINTF("ASSERT ERROR \" %s \": file \"%s\" Line \"%d\" \n", failedExpr, file, line); for (;;) { __BKPT(0); } }
/** * @brief General error handler. */ static void error_loop(void) { __BKPT(); SET_PIN(7); while (true) { __WFE(); } }
// Unimplemented, for now. void SVC_Handler(void) { #ifdef DEBUG printf_semi("SVC_Handler called. (Unimplemented - HALT)\n"); __BKPT(0); #endif while (1) {}; }
void HardFault_Handler(uint32_t pc, uint32_t lr) { __LOG(RTT_CTRL_TEXT_RED "HARDFAULT pc=0x%x\n", pc); __disable_irq(); #ifdef DEBUG_LEDS NRF_GPIO->OUTSET = (1 << 7); NRF_GPIO->OUTCLR = (1 << 23); #endif __BKPT(0); while (1); }
void app_error_handler(uint32_t error_code, uint32_t line_num, const uint8_t * p_file_name) { __LOG(RTT_CTRL_TEXT_RED "APP ERROR %d, @%s:L%d\n", error_code, p_file_name, line_num); __disable_irq(); #ifdef DEBUG_LEDS NRF_GPIO->OUTSET = (1 << 7); NRF_GPIO->OUTCLR = (1 << 23); #endif __BKPT(0); while (1); }
uint8_t NRF_SPI_ReadBuf(uint8_t reg, uint8_t *buffer, uint8_t len) { if(len > BUFFER_LEN - 1) { __BKPT(104); return -1; } while(SPI_isBusy()); __spi_buf[0] = reg; for(int i = 0 ; i < len ; i++) __spi_buf[i+1] = 0; SPI_RWData(__spi_buf,len+1); while(SPI_isBusy()); for(int i = 0 ; i < len ; i++) buffer[i] = __spi_buf[i+1]; return __spi_buf[0]; }
/* * Function for error handling, which is called when an error has occurred. * * warning This handler is an example only and does not fit a final product. You need to analyze * how your product is supposed to react in case of error. * * [in] error_code Error code supplied to the handler. * [in] line_num Line number where the handler is called. * [in] p_file_name Pointer to the file name. */ void app_error_handler(uint32_t error_code, uint32_t line_num, const uint8_t * p_file_name) { PRINTF("app_error: err(0x%x) line(%u) in %s\n", (unsigned)error_code, (unsigned)line_num, p_file_name); #if defined(DEBUG) __disable_irq(); __BKPT(0); while (1) { /* spin */} #else /* On assert, the system can only recover with a reset. */ NVIC_SystemReset(); #endif }
void NMI_Handler(void) { __BKPT(14); while (1); }
__RETAINED_CODE void hw_watchdog_handle_int(unsigned long *exception_args) { // Reached this point due to a WDOG timeout uint16_t pmu_ctrl_reg = CRG_TOP->PMU_CTRL_REG; pmu_ctrl_reg |= ((1 << CRG_TOP_PMU_CTRL_REG_BLE_SLEEP_Pos) | /* turn off BLE */ (1 << CRG_TOP_PMU_CTRL_REG_FTDF_SLEEP_Pos) | /* turn off FTDF */ (1 << CRG_TOP_PMU_CTRL_REG_RADIO_SLEEP_Pos) | /* turn off radio PD */ (1 << CRG_TOP_PMU_CTRL_REG_PERIPH_SLEEP_Pos)); /* turn off peripheral power domain */ CRG_TOP->PMU_CTRL_REG = pmu_ctrl_reg; REG_SET_BIT(CRG_TOP, CLK_RADIO_REG, BLE_LP_RESET); /* reset the BLE LP timer */ #if (dg_configIMAGE_SETUP == DEVELOPMENT_MODE) hw_watchdog_freeze(); // Stop WDOG ENABLE_DEBUGGER; if (exception_args != NULL) { *(volatile unsigned long *)(STATUS_BASE) = exception_args[0]; // R0 *(volatile unsigned long *)(STATUS_BASE + 0x04) = exception_args[1]; // R1 *(volatile unsigned long *)(STATUS_BASE + 0x08) = exception_args[2]; // R2 *(volatile unsigned long *)(STATUS_BASE + 0x0C) = exception_args[3]; // R3 *(volatile unsigned long *)(STATUS_BASE + 0x10) = exception_args[4]; // R12 *(volatile unsigned long *)(STATUS_BASE + 0x14) = exception_args[5]; // LR *(volatile unsigned long *)(STATUS_BASE + 0x18) = exception_args[6]; // PC *(volatile unsigned long *)(STATUS_BASE + 0x1C) = exception_args[7]; // PSR *(volatile unsigned long *)(STATUS_BASE + 0x20) = (unsigned long)exception_args; // Stack Pointer *(volatile unsigned long *)(STATUS_BASE + 0x24) = (*((volatile unsigned long *)(0xE000ED28))); // CFSR *(volatile unsigned long *)(STATUS_BASE + 0x28) = (*((volatile unsigned long *)(0xE000ED2C))); // HFSR *(volatile unsigned long *)(STATUS_BASE + 0x2C) = (*((volatile unsigned long *)(0xE000ED30))); // DFSR *(volatile unsigned long *)(STATUS_BASE + 0x30) = (*((volatile unsigned long *)(0xE000ED3C))); // AFSR *(volatile unsigned long *)(STATUS_BASE + 0x34) = (*((volatile unsigned long *)(0xE000ED34))); // MMAR *(volatile unsigned long *)(STATUS_BASE + 0x38) = (*((volatile unsigned long *)(0xE000ED38))); // BFAR } hw_cpm_assert_trigger_gpio(); if (REG_GETF(CRG_TOP, SYS_STAT_REG, DBG_IS_ACTIVE)) { __BKPT(0); } else { while (1); } #else // dg_configIMAGE_SETUP == DEVELOPMENT_MODE if (exception_args != NULL) { nmi_event_data[0] = NMI_MAGIC_NUMBER; nmi_event_data[1] = exception_args[0]; // R0 nmi_event_data[2] = exception_args[1]; // R1 nmi_event_data[3] = exception_args[2]; // R2 nmi_event_data[4] = exception_args[3]; // R3 nmi_event_data[5] = exception_args[4]; // R12 nmi_event_data[6] = exception_args[5]; // LR nmi_event_data[7] = exception_args[6]; // PC nmi_event_data[8] = exception_args[7]; // PSR } // Wait for the reset to occur while (1); #endif // dg_configIMAGE_SETUP == DEVELOPMENT_MODE }
static void jump_to_bootloader(void) { /* __asm__ volatile("bkpt"); */ /* Same as above, CMSIS notation: */ __BKPT(0); }
void __attribute__ ((weak)) HardFault_Handler_c(stack_regs_t *stack, uint32_t lr) { __BKPT(0); }
void HAL_AssertEx() { __BKPT(0); while(true) { /*nop*/ } }
void HardFault_Handler(void) { __BKPT(13); while (1); }
void PendSV_Handler(void) { __BKPT(2); while (1); }
/* Default for Kinetis - expecting an ARM Teensy */ void bootloader_jump(void) { chThdSleepMilliseconds(100); __BKPT(0); }
void SVC_Handler(void) { __BKPT(5); while (1); }
static void Error_Handler(void) { __BKPT(); }
void SysTick_Handler(void) { __BKPT(1); while (1); }
__weak void _exit(int status) { (void) status; for (;;) { __BKPT(0); } }