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

feat(putc function added, write a code ascii in a queue)

parent a8d7d234
No related branches found
No related tags found
No related merge requests found
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#define SHIFT_UP 0x2A #define SHIFT_UP 0x2A
#define SHIFT_DOWN 0xAA #define SHIFT_DOWN 0xAA
#define NB_KEYS 256 #define NB_KEYS 256
#define QUEUE_SIZE 8
typedef enum boolean typedef enum boolean
{ {
...@@ -20,10 +21,22 @@ typedef struct key_s ...@@ -20,10 +21,22 @@ typedef struct key_s
unsigned char top; unsigned char top;
} key_t; } key_t;
typedef struct queue_s
{
unsigned char first_free;
unsigned char cpt;
char array[QUEUE_SIZE];
} queue_t;
key_t KEY_MAPPING[NB_KEYS]; key_t KEY_MAPPING[NB_KEYS];
queue_t keyboard_queue;
void init_keymapping(); void init_keymapping();
char keyboard_map(unsigned char code); char keyboard_map(unsigned char code);
void init_queue();
void putc(char c);
#endif #endif
...@@ -79,3 +79,26 @@ char keyboard_map(unsigned char code) ...@@ -79,3 +79,26 @@ char keyboard_map(unsigned char code)
return KEY_MAPPING[code].top; return KEY_MAPPING[code].top;
return KEY_MAPPING[code].bottom; return KEY_MAPPING[code].bottom;
} }
void init_queue()
{
keyboard_queue.cpt = 0;
keyboard_queue.first_free = 0;
}
void putc(unsigned char c)
{
irq_disable();
if (c == NONE)
return;
if (keyboard_queue.cpt < QUEUE_SIZE)
{
keyboard_queue.cpt++;
keyboard_queue.first_free = (keyboard_queue.first_free + 1) % QUEUE_SIZE;
keyboard_queue.array[keyboard_queue.first_free] = c;
}
irq_enable();
}
\ 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