Do less re-initialization of smbus, add battery charger enabling

This commit is contained in:
Jeremy Soller
2019-11-05 14:42:15 -07:00
parent aee44bbce0
commit 976874f525
5 changed files with 44 additions and 52 deletions

View File

@ -3,23 +3,11 @@
#include <ec/smbus.h>
void i2c_write(unsigned char value) {
// Write value to 0x76
TRASLAA = 0x76 << 1;
HOCMDA = value;
for (;;) {
// Wait for last command
while (HOSTAA & 1) {}
// Clear result
HOSTAA = HOSTAA;
// Clock to 400 KHz
SCLKTSA = 3;
// Enable host interface with i2c compatibility
HOCTL2A = (1 << 1) | (1 << 0);
// Write value to 0x76
TRASLAA = 0x76 << 1;
HOCMDA = value;
// Start command
HOCTLA = (1 << 6) | (0b001 << 2);
@ -33,9 +21,6 @@ void i2c_write(unsigned char value) {
uint8_t status = HOSTAA;
HOSTAA = status;
// Disable host interface
HOCTL2A = 0;
// If there were no errors, return
uint8_t error = (1 << 6) | (1 << 5) | (1 << 4) | (1 << 3) | (1 << 2);
if (!(status & error)) {