Fix test for when to update battery and fan state, hold SCI_N for longer

This commit is contained in:
Jeremy Soller 2020-02-21 20:30:10 -07:00
parent 11c15c2291
commit d16ecc6129
No known key found for this signature in database
GPG Key ID: E988B49EE78A7FB1
6 changed files with 27 additions and 6 deletions

View File

@ -97,7 +97,10 @@ void main(void) {
INFO("System76 EC board '%s', version '%s'\n", board(), version());
uint32_t last_time = 0;
for(main_cycle = 0; ; main_cycle++) {
uint32_t time = time_get();
// Handle power states
power_event();
// Scans keyboard and sends keyboard packets
@ -109,7 +112,8 @@ void main(void) {
// Checks for keyboard/mouse packets from host
kbc_event(&KBC);
// Only run the following once a second
if (time_get() % 1000 == 0) {
if (last_time > time || (time - last_time) >= 1000) {
last_time = time;
// Updates fan status and temps
peci_event();
// Updates battery status

View File

@ -26,11 +26,14 @@ void pmc_sci_interrupt(void) {
*(SCI_N.control) = GPIO_OUT;
// Delay T_HOLD (value assumed)
delay_us(1);
delay_us(65);
// Stop SCI interrupt
*(SCI_N.control) = GPIO_IN;
gpio_set(&SCI_N, true);
// Delay T_HOLD (value assumed)
delay_us(65);
}
bool pmc_sci(struct Pmc * pmc, uint8_t sci) {

View File

@ -97,7 +97,10 @@ void main(void) {
INFO("System76 EC board '%s', version '%s'\n", board(), version());
uint32_t last_time = 0;
for(main_cycle = 0; ; main_cycle++) {
uint32_t time = time_get();
// Handle power states
power_event();
// Scans keyboard and sends keyboard packets
@ -109,7 +112,8 @@ void main(void) {
// Checks for keyboard/mouse packets from host
kbc_event(&KBC);
// Only run the following once a second
if (time_get() % 1000 == 0) {
if (last_time > time || (time - last_time) >= 1000) {
last_time = time;
// Updates fan status and temps
peci_event();
// Updates battery status

View File

@ -26,11 +26,14 @@ void pmc_sci_interrupt(void) {
*(SCI_N.control) = GPIO_OUT;
// Delay T_HOLD (value assumed)
delay_us(1);
delay_us(65);
// Stop SCI interrupt
*(SCI_N.control) = GPIO_IN;
gpio_set(&SCI_N, true);
// Delay T_HOLD (value assumed)
delay_us(65);
}
bool pmc_sci(struct Pmc * pmc, uint8_t sci) {

View File

@ -99,7 +99,10 @@ void main(void) {
INFO("System76 EC board '%s', version '%s'\n", board(), version());
uint32_t last_time = 0;
for(main_cycle = 0; ; main_cycle++) {
uint32_t time = time_get();
// Handle power states
power_event();
// Scans keyboard and sends keyboard packets
@ -111,7 +114,8 @@ void main(void) {
// Checks for keyboard/mouse packets from host
kbc_event(&KBC);
// Only run the following once a second
if (time_get() % 1000 == 0) {
if (last_time > time || (time - last_time) >= 1000) {
last_time = time;
// Updates fan status and temps
peci_event();
// Updates battery status

View File

@ -26,11 +26,14 @@ void pmc_sci_interrupt(void) {
*(SCI_N.control) = GPIO_OUT;
// Delay T_HOLD (value assumed)
delay_us(1);
delay_us(65);
// Stop SCI interrupt
*(SCI_N.control) = GPIO_IN;
gpio_set(&SCI_N, true);
// Delay T_HOLD (value assumed)
delay_us(65);
}
bool pmc_sci(struct Pmc * pmc, uint8_t sci) {