Changed address of keyboard device and added reboot command to i2c upload

This commit is contained in:
Dreaded_X 2020-12-30 03:30:15 +01:00
parent 9eb63608ea
commit 96058f06c2
3 changed files with 16 additions and 9 deletions

View File

@ -114,15 +114,16 @@ void handle_io_read() {
/* write_data(0x01); */ /* write_data(0x01); */
/* break; */ /* break; */
// Stand in for the keyboard hardware /* Stand in for the keyboard hardware */
/* case 0x1E: */ /* case 0x1E: */
/* write_data(control.input.c); */ /* write_data(char_c); */
/* control.input.received = 0; */ /* char_r = 0; */
/* break; */ /* break; */
// Stand in for the keyboard hardware /* Stand in for the keyboard hardware */
/* case 0x1F: */ /* case 0x1F: */
/* write_data(0x01 * control.input.received); */ /* #<{(| write_data(0x01 * char_r); |)}># */
/* write_data(0x00); */
/* break; */ /* break; */
case 0x08: case 0x08:

View File

@ -43,9 +43,15 @@ void firmware_update() {
control_program_eeprom(data, length); control_program_eeprom(data, length);
break; break;
case TARGET_I2C: { case TARGET_I2C: {
// Make sure tell the device to enter bootloader mode first printf("Restarting target to bootloader...\n\r");
// Upload the application // @todo Make sure that the address to reset to bootloader is the same as the bootloader address
uint8_t reboot_command[] = {0x07};
HAL_I2C_Master_Transmit(&hi2c1, address << 1, reboot_command, sizeof(reboot_command), 1000);
for (volatile int i = 0; i < 10000000; ++i) {}
printf("Uploading to target...\n\r"); printf("Uploading to target...\n\r");
uint8_t upload_command[4 + length]; uint8_t upload_command[4 + length];
upload_command[0] = 0x02; upload_command[0] = 0x02;
upload_command[1] = 0x01; upload_command[1] = 0x01;

View File

@ -123,7 +123,7 @@ void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) {
if (!is_command) { if (!is_command) {
// ONLY SEND THE FIRST CHAR // ONLY SEND THE FIRST CHAR
if (cmd_buffer_len > 0) { if (cmd_buffer_len > 0) {
HAL_I2C_Master_Transmit(&hi2c1, 0x04 << 1, &byte, 1, 1000); HAL_I2C_Master_Transmit(&hi2c1, 0x29 << 1, &byte, 1, 1000);
} }
cmd_buffer_len = 0; cmd_buffer_len = 0;
} else if (handle_command && is_command) { } else if (handle_command && is_command) {
@ -148,7 +148,7 @@ void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) {
break; break;
case '#': case '#':
HAL_I2C_Master_Transmit(&hi2c1, 0x04 << 1, &byte, 1, 1000); HAL_I2C_Master_Transmit(&hi2c1, 0x29 << 1, &byte, 1, 1000);
break; break;
default: default: