void myUSART_callback(uint32_t event) { switch (event) { case ARM_USART_EVENT_RECEIVE_COMPLETE: break; case ARM_USART_EVENT_TRANSFER_COMPLETE: break; case ARM_USART_EVENT_SEND_COMPLETE: /* Success: Wakeup Thread */ //osMutexRelease(printMutexId); break; case ARM_USART_EVENT_TX_COMPLETE: break; case ARM_USART_EVENT_RX_TIMEOUT: __breakpoint(0); /* Error: Call debugger or replace with custom error handling */ break; case ARM_USART_EVENT_RX_OVERFLOW: case ARM_USART_EVENT_TX_UNDERFLOW: __breakpoint(0); /* Error: Call debugger or replace with custom error handling */ break; } }
void StartTask_Uart1Reception (void const *argument) { extern osMessageQId Q_CmdReceptionHandle; uint32_t reclen; osStatus qretval; /*!< The return value which indicates the osMessagePut() implementation result */ uint8_t* ptrdata; /*!< Pointer to any byte in the uart buffer */ uint8_t (*ptr_bufhead)[1], /*!< Pointer to the head of the uart buffer */ (*ptr_buftail)[1]; /*!< Pointer to the tail of the uart buffer */ while (1) { osSignalWait (0x01, osWaitForever); reclen = MAX_DEPTH_UART1_BUF - huart1.hdmarx->Instance->NDTR; ptrdata = *uart_buf + reclen - 1; // point to the last char received ptr_bufhead = (uint8_t(*)[1])uart1_buf[0]; ptr_buftail = (uint8_t(*)[1])uart1_buf[MAX_COUNT_UART1_BUF - 2]; if(*ptrdata == '\n') { /* Insert a terminal into the string */ *(ptrdata + 1) = 0x0; if(*(--ptrdata) == '\r') // A command has been received { /* * The current buffer has been used and post to the working thread * switch to the next uart1 queue buffer to recevie the furture data */ qretval = osMessagePut(Q_CmdReceptionHandle, (uint32_t)(uart_buf), 0); // Put the pointer of the data container to the queue if(qretval != osOK) { __breakpoint(0); //printk(KERN_ERR "It's failed to put the command into the message queue!\r\n"); } /* Move to the next row of the buffer */ uart_buf++; if(uart_buf > (uint8_t(*)[50])ptr_buftail) { uart_buf = (uint8_t(*)[50])ptr_bufhead; } } /* Reset DMA_EN bit can result in the TCIF interrupt. The interrupt raises the HAL_UART_RxCpltCallback() event, the DMA_Rx will be restarted in it */ HAL_DMA_Abort(huart1.hdmarx); USART_Start_Receive_DMA(&huart1); } else /* Continue recepition if the last char is not '\n' */ { __HAL_UART_ENABLE_IT(&huart1, UART_IT_IDLE); } } }
void UsageFault_Handler(void) { if (CoreDebug->DHCSR & 1) { // check C_DEBUGEN == 1-> Debugger Connected __breakpoint (0); // halt program execution here } /* Go to infinite loop when Usage Fault exception occurs */ while (1) { } }
static void SPIEventCallBack(uint32_t event) { switch (event) { case ARM_SPI_EVENT_TRANSFER_COMPLETE: /* Success: Wakeup Thread */ //osSignalSet(tid_mySPI_Thread, 0x01); break; case ARM_SPI_EVENT_DATA_LOST: /* Occurs in slave mode when data is requested/sent by master but send/receive/transfer operation has not been started and indicates that data is lost. */ __breakpoint(0); /* Error: Call debugger or replace with custom error handling */ break; case ARM_SPI_EVENT_MODE_FAULT: /* Occurs in master mode when Slave Select is deactivated and indicates Master Mode Fault. */ __breakpoint(0); /* Error: Call debugger or replace with custom error handling */ break; } }
/** * @brief The callback function of communication bus idle ISR. * @param huart: the owner of ISR. * @retval null */ void My_HAL_UART_IdleCallback(UART_HandleTypeDef *huart) { // osStatus qretval; /*!< The return value which indicates the osMessagePut() implementation result */ // uint8_t* ptrdata; /*!< Pointer to any byte in the uart buffer */ // uint8_t (*ptr_bufhead)[1], /*!< Pointer to the head of the uart buffer */ // (*ptr_buftail)[1]; /*!< Pointer to the tail of the uart buffer */ if(huart->Instance == USART1) { osSignalSet(Uart1ReceptionHandle, 0x1); // Ask the Usart1 Rx handler thread to handle the Rx data. } else if(huart->Instance == USART2) { __breakpoint(1); } }
void panic( panicId_t id, uint32_t location, uint32_t extra1, uint32_t extra2 ) { #if gUsePanic_c /* Save the Link Register */ volatile uint32_t savedLR; // __asm("str r14, [SP]"); __asm("push {r2} "); __asm("push {LR} "); __asm("pop {r2} "); __asm("str r2, [SP, #4]"); __asm("pop {r2}"); panic_data.id = id; panic_data.location = location; panic_data.extra1 = extra1; panic_data.extra2 = extra2; panic_data.linkRegister = savedLR; panic_data.cpsr_contents = 0; #if 0 OSA_ExitCritical(kCriticalDisableInt); /* enable interrupts */ OSA_TimeDelay(100); /* allowing datalogs to get out */ #endif OSA_EnterCritical(kCriticalDisableInt); /* disable interrupts */ /* cause processor to halt */ #ifdef __IAR_SYSTEMS_ICC__ __asm("BKPT #0xF"); __asm("NOP"); __asm("NOP"); __asm("NOP"); #endif #ifdef RVDS __breakpoint(); #endif /* infinite loop just to ensure this routine never returns */ for(;;) { __asm("NOP"); } #endif }
void AccessError_Handler(void) { for(;;) { __breakpoint(); } }