Add SCI event queue

This commit is contained in:
Jeremy Soller
2019-12-02 13:20:56 -07:00
parent 73ab827211
commit dc19bf1248
3 changed files with 18 additions and 4 deletions

View File

@ -3,6 +3,8 @@
#include <board/scratch.h> #include <board/scratch.h>
#include <common/debug.h> #include <common/debug.h>
uint8_t pmc_sci_queue = 0;
void pmc_init(void) { void pmc_init(void) {
*(PMC_1.control) = 0x41; *(PMC_1.control) = 0x41;
*(PMC_2.control) = 0x41; *(PMC_2.control) = 0x41;
@ -37,17 +39,24 @@ void pmc_event(struct Pmc * pmc) {
break; break;
case 0x82: case 0x82:
DEBUG(" burst enable\n"); DEBUG(" burst enable\n");
// TODO: figure out what burst is // Set burst bit
pmc_set_status(pmc, sts | (1 << 4));
// Send acknowledgement byte
pmc_write(pmc, 0x90, PMC_TIMEOUT); pmc_write(pmc, 0x90, PMC_TIMEOUT);
break; break;
case 0x83: case 0x83:
DEBUG(" burst disable\n"); DEBUG(" burst disable\n");
// TODO: figure out what burst is // Clear burst bit
pmc_set_status(pmc, sts & ~(1 << 4));
break; break;
case 0x84: case 0x84:
DEBUG(" SCI queue\n"); DEBUG(" SCI queue\n");
// TODO: queue is always empty // Clear SCI event pending bit
pmc_write(pmc, 0, PMC_TIMEOUT); pmc_set_status(pmc, sts & ~(1 << 5));
// Send SCI event
pmc_write(pmc, pmc_sci_queue, PMC_TIMEOUT);
// Clear SCI queue
pmc_sci_queue = 0;
break; break;
case 0xDC: case 0xDC:

View File

@ -23,6 +23,7 @@ extern struct Pmc __code PMC_2;
#define PMC_STS_CMD (1 << 3) #define PMC_STS_CMD (1 << 3)
uint8_t pmc_status(struct Pmc * pmc); uint8_t pmc_status(struct Pmc * pmc);
void pmc_set_status(struct Pmc * pmc, uint8_t status);
uint8_t pmc_read(struct Pmc * pmc); uint8_t pmc_read(struct Pmc * pmc);
bool pmc_write(struct Pmc * pmc, uint8_t data, int timeout); bool pmc_write(struct Pmc * pmc, uint8_t data, int timeout);

View File

@ -14,6 +14,10 @@ uint8_t pmc_status(struct Pmc * pmc) {
return *(pmc->status); return *(pmc->status);
} }
void pmc_set_status(struct Pmc * pmc, uint8_t status) {
*(pmc->status) = status;
}
uint8_t pmc_read(struct Pmc * pmc) { uint8_t pmc_read(struct Pmc * pmc) {
return *(pmc->data_in); return *(pmc->data_in);
} }