#ifndef AT91TWI_H_ #define AT91TWI_H_ #include /* TWI slave addresses */ #define TWI_ADDR_BL1 0x21 #define TWI_ADDR_BL2 0x22 #define TWI_ADDR_BL3 0x23 #define TWI_ADDR_BL4 0x24 #define TWI_ADDR_EEPROM 0x40 /* TWIBOOT commands */ #define CMD_WAIT 0x00 #define CMD_GET_INFO 0x10 #define CMD_GET_SIGNATURE 0x11 #define CMD_WRITE_FLASH 0x12 #define CMD_READ_FLASH 0x13 #define CMD_WRITE_EEPROM 0x14 #define CMD_READ_EEPROM 0x15 #define CMD_BOOT_APPLICATION 0x1F /* blctrl commands */ //#define CMD_WAIT 0x00 //#define CMD_GET_INFO 0x10 #define CMD_SET_PWM 0x21 #define CMD_GET_STATUS 0x22 //#define CMD_SET_PARAM 0x23 //#define CMD_GET_PARAM 0x24 #define CMD_BOOT_LOADER 0x2F struct blmc_cmd { uint32_t cmd; /* cmd byte(s) */ uint8_t mode; /* read/write, cmdlen (1-3 bytes) */ uint16_t size; /* data size */ uint8_t *data; /* read/write data */ }; /* same bits as TWI_MMR[8..15] */ #define BLMC_CMD_READ 0x10 #define BLMC_CMD_WRITE 0x00 #define BLMC_CMD_0_ARG 0x01 #define BLMC_CMD_1_ARG 0x02 #define BLMC_CMD_2_ARG 0x03 uint32_t twi_read_eeprom(uint32_t addr, uint8_t *buf, uint32_t size); uint32_t twi_write_eeprom(uint32_t addr, uint8_t *buf, uint32_t size); uint32_t twi_setpwm(uint8_t *values); uint32_t twi_cmd(uint8_t addr, struct blmc_cmd *cmd); void at91_twi_init(void); void at91_twi_test(void); #endif /*AT91TWI_H_*/