Rev 283 | Blame | Compare with Previous | Last modification | View Log | RSS feed
#include "defines.h"
#include "CONTROLLER.h"
#include "I2C1.h"
void Controller_Init(void) {
}
uint8_t Controller_Read(CTRL_BTN_STATUS *btns) {
uint8_t buffer[8];
uint8_t result, length, ret = 1;
// Read in the button values for each controller
I2C1_Master_Restart(CONTROLLER_ADDRESS, CONTROLLER_CMD_READ, 6);
do {
result = I2C1_Get_Status();
} while (!result);
if (result == I2C_RECV_OK) {
ret = 0;
// Save the read values
length = I2C1_Read_Buffer(buffer);
btns->REF = buffer[0];
btns->L_X_CH = buffer[1];
btns->L_Y_CH = buffer[2];
btns->R_X_CH = buffer[3];
btns->R_Y_CH = buffer[4];
btns->BTN = buffer[5];
}
return ret;
}
void Controller_Set_Led(uint8_t value) {
uint8_t c = value;
I2C1_Master_Send(CONTROLLER_ADDRESS, &c, 1);
}