copy some useful code of IRQhandler(receive pattern) from original freeRTOS