Compare commits
5 Commits
0b7491e56b
...
3f8af51ab9
Author | SHA1 | Date |
---|---|---|
Potter360 | 3f8af51ab9 | |
Potter360 | fa2594139b | |
Potter360 | 5c8e72486e | |
Potter360 | 4ec1493af1 | |
Potter360 | 8b906d9d59 |
|
@ -6,7 +6,8 @@ void keyboard_refresh();
|
|||
void keyboard_setup();
|
||||
uint8_t keyboard_get_line(int line);
|
||||
bool keydown(int key);
|
||||
|
||||
bool keypressed(int key);
|
||||
void keyboard_event_refresh(void);
|
||||
// Keycodes
|
||||
|
||||
enum {
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
|
||||
#include <omega/utils.h>
|
||||
#include <omega/display.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
uint8_t scan[12];
|
||||
uint8_t buff[12];
|
||||
void keyboard_setup()
|
||||
{
|
||||
for(int i=0;i<12;i++)
|
||||
|
@ -32,3 +34,26 @@ bool keydown(int key)
|
|||
|
||||
return (scan[row] & col) != 0;
|
||||
}
|
||||
void keyboard_event_refresh(void)
|
||||
{
|
||||
memcpy((uint32_t *)scan,(uint32_t *)buff,sizeof(uint8_t)*12);
|
||||
keyboard_refresh();
|
||||
|
||||
}
|
||||
bool keypressed(int key)
|
||||
{
|
||||
int row = (key >> 4);
|
||||
int col = 0x80 >> (key & 0x7);
|
||||
|
||||
|
||||
for(int i=0;i<12;i++)
|
||||
{
|
||||
if(scan[i]!=buff[i])
|
||||
{
|
||||
|
||||
return (scan[row] & col) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
#include <omega/tmu.h>
|
||||
#include <omega/display.h>
|
||||
|
||||
#include <omega/defs/calls.h>
|
||||
|
||||
|
@ -6,7 +7,7 @@ static tmu_channel_t *CHANNELS = TMU.CHANNELS;
|
|||
static volatile uint8_t *TSTR = &TMU.TSTR;
|
||||
|
||||
call_t tmu_callbacks[3];
|
||||
|
||||
uint8_t wait_unf;
|
||||
int default_callback(void)
|
||||
{
|
||||
return TIMER_STOP;
|
||||
|
@ -15,6 +16,7 @@ void back(int id)
|
|||
{
|
||||
tmu_channel_t *channel = &CHANNELS[id];
|
||||
channel->TCR.UNF = 0;
|
||||
wait_unf = 1;
|
||||
int return_value = tmu_callbacks[id]();
|
||||
|
||||
if(return_value == TIMER_STOP)
|
||||
|
@ -66,7 +68,8 @@ int timer_new(uint64_t delay, call_t call)
|
|||
uint32_t final_delay = timer_delay(delay);
|
||||
|
||||
timer_configure(i,final_delay,call);
|
||||
timer_start(i);
|
||||
|
||||
|
||||
|
||||
return i;
|
||||
}
|
||||
|
@ -97,5 +100,7 @@ void timer_stop(int id)
|
|||
void timer_wait(int id)
|
||||
{
|
||||
tmu_channel_t *channel = &CHANNELS[id];
|
||||
while(*TSTR & (1 << id)) if(channel->TCR.UNIE) __asm__("sleep");
|
||||
|
||||
while(!(wait_unf)) if(channel->TCR.UNIE) __asm__("sleep");
|
||||
wait_unf = 0;
|
||||
}
|
Loading…
Reference in New Issue