Skip to content
Snippets Groups Projects
Commit 1fa0fe5b authored by Thierno souleymane Bah's avatar Thierno souleymane Bah
Browse files

feat(getc implemented but not yet tested, using semanphore coming soon)

parent 16a35305
No related branches found
No related tags found
No related merge requests found
......@@ -37,6 +37,10 @@ char keyboard_map(unsigned char code);
void init_queue();
void putc(char c);
void putc(unsigned char c);
void putc(unsigned char c);
char getc();
#endif
......@@ -90,10 +90,7 @@ void putc(unsigned char c)
{
irq_disable();
if (c == NONE)
return;
if (keyboard_queue.cpt < QUEUE_SIZE)
if (c != NONE && keyboard_queue.cpt < QUEUE_SIZE)
{
keyboard_queue.cpt++;
keyboard_queue.first_free = (keyboard_queue.first_free + 1) % QUEUE_SIZE;
......@@ -102,3 +99,14 @@ void putc(unsigned char c)
irq_enable();
}
char getc()
{
irq_disable();
char idx = (keyboard_queue.first_free + QUEUE_SIZE - keyboard_queue.cpt) % QUEUE_SIZE;
keyboard_queue.cpt--;
irq_enable();
return keyboard_queue.array[idx];
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment