commit c154e5c92c1dfa6def4d8c8d21bcaf9905de2024
parent 7e64ff3ffa6b0283552d93ad2f2a15aeb29712e1
Author: Lukas F. Hartmann <lukas@mntre.com>
Date: Tue, 16 May 2023 17:28:36 +0200
trackball2-fw2: fix typing errors
Diffstat:
2 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/reform2-trackball2-fw/src/main.c b/reform2-trackball2-fw/src/main.c
@@ -81,7 +81,7 @@ int main(void)
bi_decl(bi_2pins_with_func(PIN_SDA, PIN_SCL, GPIO_FUNC_I2C));
- char buf[] = {0x7f, 0x00, 0x00, 0x00};
+ uint8_t buf[] = {0x7f, 0x00, 0x00, 0x00};
i2c_write_blocking(i2c0, ADDR_SENSOR, buf, 2, false);
buf[0] = 0x05;
@@ -206,7 +206,7 @@ void hid_task(void)
const uint32_t interval_ms = 10;
static uint32_t start_ms = 0;
- int8_t buf[] = {0x7f, 0x00, 0x00, 0x00};
+ uint8_t buf[] = {0x7f, 0x00, 0x00, 0x00};
if ( board_millis() - start_ms < interval_ms) return; // not enough time
@@ -240,11 +240,11 @@ void hid_task(void)
i2c_write_blocking(i2c0, ADDR_SENSOR, buf, 1, true);
i2c_read_blocking(i2c0, ADDR_SENSOR, buf, 1, false);
- int btn1 = !gpio_get(PIN_BTN1);
- int btn2 = !gpio_get(PIN_BTN2);
- int btn3 = !gpio_get(PIN_BTN3);
- int btn4 = !gpio_get(PIN_BTN4);
- int btn5 = !gpio_get(PIN_BTN5);
+ uint8_t btn1 = !gpio_get(PIN_BTN1);
+ uint8_t btn2 = !gpio_get(PIN_BTN2);
+ uint8_t btn3 = !gpio_get(PIN_BTN3);
+ uint8_t btn4 = !gpio_get(PIN_BTN4);
+ uint8_t btn5 = !gpio_get(PIN_BTN5);
// pressing both wheel buttons together turns on sticky wheel mode
if (btn1 || btn2 || btn4) {
@@ -260,8 +260,8 @@ void hid_task(void)
i2c_write_blocking(i2c0, ADDR_SENSOR, buf, 1, true);
i2c_read_blocking(i2c0, ADDR_SENSOR, buf, 2, false);
- int8_t nx = buf[0];
- int8_t ny = buf[1];
+ int8_t nx = (int8_t)buf[0];
+ int8_t ny = (int8_t)buf[1];
// no button, right + down, no scroll pan
if (btn3 || btn5 || scroll_toggle) {
@@ -287,6 +287,7 @@ uint16_t tud_hid_get_report_cb(uint8_t itf, uint8_t report_id, hid_report_type_t
{
// TODO not Implemented
(void) itf;
+ (void) buffer;
(void) reqlen;
if (report_type != HID_REPORT_TYPE_FEATURE) return 0;
diff --git a/reform2-trackball2-fw/src/usb_descriptors.c b/reform2-trackball2-fw/src/usb_descriptors.c
@@ -226,7 +226,7 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
const char* str = string_desc_arr[index];
// Cap at max char
- chr_count = strlen(str);
+ chr_count = (uint8_t)strlen(str);
if ( chr_count > 31 ) chr_count = 31;
// Convert ASCII string into UTF-16
@@ -237,7 +237,7 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
}
// first byte is length (including header), second byte is string type
- _desc_str[0] = (TUSB_DESC_STRING << 8 ) | (2*chr_count + 2);
+ _desc_str[0] = (uint16_t)((TUSB_DESC_STRING << 8 ) | (2*chr_count + 2));
return _desc_str;
}