oam timings passing.
This commit is contained in:
7
.vscode/settings.json
vendored
7
.vscode/settings.json
vendored
@ -10,6 +10,11 @@
|
||||
"xtr1common": "c",
|
||||
"chrono": "c",
|
||||
"interrupts.h": "c",
|
||||
"cmath": "c"
|
||||
"cmath": "c",
|
||||
"algorithm": "c",
|
||||
"functional": "c",
|
||||
"optional": "c",
|
||||
"system_error": "c",
|
||||
"xutility": "c"
|
||||
}
|
||||
}
|
@ -6,8 +6,10 @@ typedef struct {
|
||||
bool active;
|
||||
u8 byte;
|
||||
u8 value;
|
||||
u8 value_buffer;
|
||||
u8 start_delay;
|
||||
bool transferring;
|
||||
bool dma_waiting;
|
||||
} dma_context;
|
||||
|
||||
typedef struct {
|
||||
|
24
lib/dma.c
24
lib/dma.c
@ -8,23 +8,31 @@
|
||||
static dma_context ctx;
|
||||
|
||||
void dma_start(u8 start) {
|
||||
ctx.start_delay = 1;
|
||||
ctx.value_buffer = start;
|
||||
ctx.dma_waiting = true;
|
||||
}
|
||||
|
||||
void dma_begin() {
|
||||
ctx.active = true;
|
||||
ctx.byte = 0;
|
||||
ctx.start_delay = 2;
|
||||
ctx.value = start;
|
||||
ctx.transferring = false;
|
||||
ctx.value = ctx.value_buffer;
|
||||
ctx.dma_waiting = false;
|
||||
}
|
||||
|
||||
void dma_tick() {
|
||||
ctx.transferring = false;
|
||||
|
||||
if (ctx.start_delay) {
|
||||
ctx.start_delay--;
|
||||
} else if(ctx.dma_waiting) {
|
||||
dma_begin();
|
||||
}
|
||||
|
||||
if (!ctx.active) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (ctx.start_delay) {
|
||||
ctx.start_delay--;
|
||||
return;
|
||||
}
|
||||
ctx.transferring = true;
|
||||
u8 data = 0;
|
||||
u16 addr = (ctx.value << 8) | ctx.byte;
|
||||
@ -45,7 +53,7 @@ void dma_tick() {
|
||||
}
|
||||
|
||||
bool dma_transferring() {
|
||||
return ctx.transferring && ctx.active;
|
||||
return ctx.transferring;// && ctx.active;
|
||||
}
|
||||
|
||||
void dma_save_state(dma_state* state) {
|
||||
|
Reference in New Issue
Block a user