zephyr/zephyr_getchar: Update to Zephyr 1.6 unified kernel API.

This commit is contained in:
Paul Sokolovsky 2016-11-30 01:42:58 +03:00
parent a6de451a13
commit 295266178c

View File

@ -43,12 +43,12 @@ static int console_irq_input_hook(uint8_t ch)
i_put = i_next; i_put = i_next;
} }
//printk("%x\n", ch); //printk("%x\n", ch);
nano_isr_sem_give(&uart_sem); k_sem_give(&uart_sem);
return 1; return 1;
} }
uint8_t zephyr_getchar(void) { uint8_t zephyr_getchar(void) {
nano_task_sem_take(&uart_sem, TICKS_UNLIMITED); k_sem_take(&uart_sem, K_FOREVER);
unsigned int key = irq_lock(); unsigned int key = irq_lock();
uint8_t c = uart_ringbuf[i_get++]; uint8_t c = uart_ringbuf[i_get++];
i_get &= UART_BUFSIZE - 1; i_get &= UART_BUFSIZE - 1;
@ -57,7 +57,7 @@ uint8_t zephyr_getchar(void) {
} }
void zephyr_getchar_init(void) { void zephyr_getchar_init(void) {
nano_sem_init(&uart_sem); k_sem_init(&uart_sem, 0, UINT_MAX);
uart_console_in_debug_hook_install(console_irq_input_hook); uart_console_in_debug_hook_install(console_irq_input_hook);
// All NULLs because we're interested only in the callback above // All NULLs because we're interested only in the callback above
uart_register_input(NULL, NULL, NULL); uart_register_input(NULL, NULL, NULL);