Do less re-initialization of smbus, add battery charger enabling
This commit is contained in:
@ -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)) {
|
||||
|
Reference in New Issue
Block a user