Subversion Repositories Code-Repo

Rev

Rev 240 | Rev 276 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

#ifndef CONTROLLERS_H
#define CONTROLLERS_H

#define CONTROLLER_CMD_READ     0xA
#define CONTROLLER_CMD_WRITE    0xB
#define CONTROLLER_CMD_RESET    0xC

#define CONTROLLER_BTN_DEFAULT  0xC0
#define CONTROLLER_LED_DEFAULT  0x00

#define CONTROLLER_PREFIX_ADDRESS   0xA0
#define CONTROLLER_START_ADDRESS    0x01
#define CONTROLLER_END_ADDRESS      0x08

#define CONTROLLER_MAX_COUNT    8

typedef struct {
    uint8_t connected_controllers[CONTROLLER_MAX_COUNT];
    uint8_t led_status[CONTROLLER_MAX_COUNT][2];
    uint8_t btn_prev[CONTROLLER_MAX_COUNT];
    uint8_t btn_last[CONTROLLER_MAX_COUNT];

    uint8_t connected_count;
} CONTROLLER_DATA;

void Controller_Init(CONTROLLER_DATA *data);
void Controller_Poll_Connected(void);
void Controller_Update(void);
void Controller_Set_Leds(uint8_t controller, uint16_t value);
uint8_t Controller_Query(uint8_t controller);

#endif  /* CONTROLLERS_H */