Pulse SCI
This commit is contained in:
parent
75f9ca4692
commit
d2e02f2380
@ -1,3 +1,4 @@
|
|||||||
|
#include <arch/delay.h>
|
||||||
#include <board/acpi.h>
|
#include <board/acpi.h>
|
||||||
#include <board/gpio.h>
|
#include <board/gpio.h>
|
||||||
#include <board/pmc.h>
|
#include <board/pmc.h>
|
||||||
@ -20,17 +21,34 @@ enum PmcState {
|
|||||||
|
|
||||||
static uint8_t pmc_sci_queue = 0;
|
static uint8_t pmc_sci_queue = 0;
|
||||||
|
|
||||||
bool pmc_sci(struct Pmc * pmc, uint8_t sci) {
|
void pmc_sci_interrupt(void) {
|
||||||
bool update = pmc_sci_queue == 0;
|
|
||||||
// Set SCI queue if possible
|
|
||||||
if (update) pmc_sci_queue = sci;
|
|
||||||
// Set SCI pending bit
|
|
||||||
uint8_t sts = pmc_status(pmc);
|
|
||||||
pmc_set_status(pmc, sts | (1 << 5));
|
|
||||||
// Start SCI interrupt
|
// Start SCI interrupt
|
||||||
gpio_set(&SCI_N, false);
|
gpio_set(&SCI_N, false);
|
||||||
*(SCI_N.control) = 0x40;
|
*(SCI_N.control) = GPIO_OUT;
|
||||||
return update;
|
|
||||||
|
// Delay T_HOLD (value assumed)
|
||||||
|
delay_us(1);
|
||||||
|
|
||||||
|
// Stop SCI interrupt
|
||||||
|
*(SCI_N.control) = GPIO_IN;
|
||||||
|
gpio_set(&SCI_N, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool pmc_sci(struct Pmc * pmc, uint8_t sci) {
|
||||||
|
// Set SCI queue if possible
|
||||||
|
if (pmc_sci_queue == 0) {
|
||||||
|
pmc_sci_queue = sci;
|
||||||
|
|
||||||
|
// Set SCI pending bit
|
||||||
|
pmc_set_status(pmc, pmc_status(pmc) | (1 << 5));
|
||||||
|
|
||||||
|
// Send SCI
|
||||||
|
pmc_sci_interrupt();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void pmc_event(struct Pmc * pmc) {
|
void pmc_event(struct Pmc * pmc) {
|
||||||
@ -75,9 +93,6 @@ void pmc_event(struct Pmc * pmc) {
|
|||||||
pmc_set_status(pmc, sts & ~(1 << 5));
|
pmc_set_status(pmc, sts & ~(1 << 5));
|
||||||
// Send SCI queue
|
// Send SCI queue
|
||||||
pmc_write(pmc, pmc_sci_queue, PMC_TIMEOUT);
|
pmc_write(pmc, pmc_sci_queue, PMC_TIMEOUT);
|
||||||
// Stop SCI interrupt
|
|
||||||
*(SCI_N.control) = 0x80;
|
|
||||||
gpio_set(&SCI_N, true);
|
|
||||||
// Clear SCI queue
|
// Clear SCI queue
|
||||||
pmc_sci_queue = 0;
|
pmc_sci_queue = 0;
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user