void usart2_rx_handler() { if(*(USART2_SR) & USART_FLAG_RXNE) { if(rxp - usart_rx_buf < RXBUF_SIZE -1) { *rxp = *(USART2_DR) & 0xFF; rxp++; if( console_pid != -1) { thread_wake(console_pid); } } } }
/** Up a semaphore. * @param sem Semaphore to up. * @param count Value to increment the count by. */ void semaphore_up(semaphore_t *sem, size_t count) { thread_t *thread; size_t i; spinlock_lock(&sem->lock); for(i = 0; i < count; i++) { if(list_empty(&sem->threads)) { sem->count++; } else { thread = list_first(&sem->threads, thread_t, wait_link); thread_wake(thread); } } spinlock_unlock(&sem->lock); }