From cc9fde08912150d0cfc9b1b3f7df9b6a9a5665d8 Mon Sep 17 00:00:00 2001 From: Ed Date: Fri, 13 Mar 2026 14:31:04 +0000 Subject: [PATCH 1/2] Add CONTROL_INTERFACES_NUM to internals --- examples/i2c/device/src/main.xc | 4 +-- lib_device_control/adapters/transport_i2c.xc | 6 ++--- lib_device_control/api/control.h | 22 ++++++++-------- lib_device_control/inc/transport_i2c.h | 3 ++- lib_device_control/src/control.xc | 27 ++++++++++---------- 5 files changed, 30 insertions(+), 32 deletions(-) diff --git a/examples/i2c/device/src/main.xc b/examples/i2c/device/src/main.xc index 93b254c0..5ae81643 100644 --- a/examples/i2c/device/src/main.xc +++ b/examples/i2c/device/src/main.xc @@ -28,11 +28,9 @@ int main(void) control_init(); control_register_resources(i_control, CONTROL_INTERFACES_NUM); - /* bug 17317 - [[combine]] */ par { -#pragma warning disable unusual-code // Suppress slice interface warning (no array size passed) + [[distribute]] i2c_control_client(i_i2c, i_control); -#pragma warning enable i2c_slave(i_i2c, p_scl, p_sda, i2c_device_addr); } } diff --git a/lib_device_control/adapters/transport_i2c.xc b/lib_device_control/adapters/transport_i2c.xc index 84b98545..ce4087a4 100644 --- a/lib_device_control/adapters/transport_i2c.xc +++ b/lib_device_control/adapters/transport_i2c.xc @@ -14,13 +14,12 @@ // // To include this file in the build, define CONTROL_USE_I2C as 1, in control_conf.h -// [[distributable]] -void i2c_control_client(server i2c_slave_callback_if i_i2c, client interface control i_control[]) +[[distributable]] +void i2c_control_client(server i2c_slave_callback_if i_i2c, client interface control i_control[CONTROL_INTERFACES_NUM]) { while (1) { select { case i_i2c.ack_write_request(void) -> i2c_slave_ack_t resp: -#pragma warning disable unusual-code // Suppress slice interface warning (no array size passed) if (control_process_i2c_write_start(i_control) == CONTROL_SUCCESS) resp = I2C_SLAVE_ACK; else @@ -47,7 +46,6 @@ void i2c_control_client(server i2c_slave_callback_if i_i2c, client interface con case i_i2c.stop_bit(void): control_process_i2c_stop(i_control); break; -#pragma warning enable } } diff --git a/lib_device_control/api/control.h b/lib_device_control/api/control.h index d1966f68..aae28e28 100644 --- a/lib_device_control/api/control.h +++ b/lib_device_control/api/control.h @@ -125,7 +125,7 @@ control_register_resources(CLIENT_INTERFACE_ARRAY(control, i, n), unsigned n); * \returns Whether the write start was successful or not */ control_ret_t -control_process_i2c_write_start(CLIENT_INTERFACE(control, i[])); +control_process_i2c_write_start(CLIENT_INTERFACE(control, i[CONTROL_INTERFACES_NUM])); /** Inform the control library that an I2C slave read has started. Called from I2C callback API. * @@ -134,7 +134,7 @@ control_process_i2c_write_start(CLIENT_INTERFACE(control, i[])); * \returns Whether the read start was successful or not */ control_ret_t -control_process_i2c_read_start(CLIENT_INTERFACE(control, i[])); +control_process_i2c_read_start(CLIENT_INTERFACE(control, i[CONTROL_INTERFACES_NUM])); /** Inform the control library that an I2C slave write has occurred. Called from I2C callback API. * @@ -145,7 +145,7 @@ control_process_i2c_read_start(CLIENT_INTERFACE(control, i[])); */ control_ret_t control_process_i2c_write_data(const uint8_t data, - CLIENT_INTERFACE(control, i[])); + CLIENT_INTERFACE(control, i[CONTROL_INTERFACES_NUM])); /** Inform the control library that an I2C slave read has occurred. Called from I2C callback API. * @@ -156,7 +156,7 @@ control_process_i2c_write_data(const uint8_t data, */ control_ret_t control_process_i2c_read_data(REFERENCE_PARAM(uint8_t, data), - CLIENT_INTERFACE(control, i[])); + CLIENT_INTERFACE(control, i[CONTROL_INTERFACES_NUM])); /** Inform the control library that an I2C transaction has stopped. Called from I2C callback API. * @@ -165,7 +165,7 @@ control_process_i2c_read_data(REFERENCE_PARAM(uint8_t, data), * \returns Whether the stop was successful or not */ control_ret_t -control_process_i2c_stop(CLIENT_INTERFACE(control, i[])); +control_process_i2c_stop(CLIENT_INTERFACE(control, i[CONTROL_INTERFACES_NUM])); /** Inform the control library that a USB set (write) has occurred. Called from USB EP0 handler. * @@ -180,7 +180,7 @@ control_process_i2c_stop(CLIENT_INTERFACE(control, i[])); control_ret_t control_process_usb_set_request(uint16_t windex, uint16_t wvalue, uint16_t wlength, const uint8_t request_data[], - CLIENT_INTERFACE(control, i[])); + CLIENT_INTERFACE(control, i[CONTROL_INTERFACES_NUM])); /** Inform the control library that a USB get (read) has occurred. Called from USB EP0 handler. * @@ -195,7 +195,7 @@ control_process_usb_set_request(uint16_t windex, uint16_t wvalue, uint16_t wleng control_ret_t control_process_usb_get_request(uint16_t windex, uint16_t wvalue, uint16_t wlength, uint8_t request_data[], - CLIENT_INTERFACE(control, i[])); + CLIENT_INTERFACE(control, i[CONTROL_INTERFACES_NUM])); /** Inform the control library that an xscope transfer has occurred. Called from xscope handler. * This function both reads and writes data in a single call. @@ -213,7 +213,7 @@ control_process_usb_get_request(uint16_t windex, uint16_t wvalue, uint16_t wleng control_ret_t control_process_xscope_upload(uint8_t buf[], unsigned buf_size, unsigned length_in, REFERENCE_PARAM(unsigned, length_out), - CLIENT_INTERFACE(control, i[])); + CLIENT_INTERFACE(control, i[CONTROL_INTERFACES_NUM])); /** Inform the control library that the SPI master has ended the transaction. If the command * was a write, this is the point that a write command is emitted on the i_ctl interface. @@ -223,7 +223,7 @@ control_process_xscope_upload(uint8_t buf[], unsigned buf_size, * \returns Whether the transfer was successful or not */ control_ret_t -control_process_spi_master_ends_transaction(CLIENT_INTERFACE(control, i_ctl[])); +control_process_spi_master_ends_transaction(CLIENT_INTERFACE(control, i_ctl[CONTROL_INTERFACES_NUM])); /** Inform the control library that the SPI master requires data. If the command * was a read, then this is the point that a read command is emitted on the i_ctl interface. @@ -236,7 +236,7 @@ control_process_spi_master_ends_transaction(CLIENT_INTERFACE(control, i_ctl[])); * \returns Whether the transfer was successful or not */ control_ret_t -control_process_spi_master_requires_data(REFERENCE_PARAM(uint32_t, data), CLIENT_INTERFACE(control, i_ctl[])); +control_process_spi_master_requires_data(REFERENCE_PARAM(uint32_t, data), CLIENT_INTERFACE(control, i_ctl[CONTROL_INTERFACES_NUM])); /** Inform the control library that the SPI master supplied data. * NOTE: It is assumed that the datum is 8 bits wide, i.e. spi_slave(...) is set up with @@ -249,6 +249,6 @@ control_process_spi_master_requires_data(REFERENCE_PARAM(uint32_t, data), CLIENT * \returns Whether the transfer was successful or not */ control_ret_t -control_process_spi_master_supplied_data(uint32_t datum, uint32_t valid_bits, CLIENT_INTERFACE(control, i_ctl[])); +control_process_spi_master_supplied_data(uint32_t datum, uint32_t valid_bits, CLIENT_INTERFACE(control, i_ctl[CONTROL_INTERFACES_NUM])); #endif // CONTROL_H diff --git a/lib_device_control/inc/transport_i2c.h b/lib_device_control/inc/transport_i2c.h index 52458a93..ce9b1abb 100644 --- a/lib_device_control/inc/transport_i2c.h +++ b/lib_device_control/inc/transport_i2c.h @@ -14,6 +14,7 @@ * \param i_control Control interface array * */ -void i2c_control_client(SERVER_INTERFACE(i2c_slave_callback_if, i_i2c), CLIENT_INTERFACE(control, i_control[])); +[[distributable]] +void i2c_control_client(SERVER_INTERFACE(i2c_slave_callback_if, i_i2c), CLIENT_INTERFACE(control, i_control[CONTROL_INTERFACES_NUM])); #endif // TRANSPORT_I2C_H diff --git a/lib_device_control/src/control.xc b/lib_device_control/src/control.xc index 5daeea83..f08221f9 100644 --- a/lib_device_control/src/control.xc +++ b/lib_device_control/src/control.xc @@ -42,6 +42,7 @@ control_ret_t control_register_resources(client interface control i[n], unsigned ret = CONTROL_SUCCESS; for (j = 0; j < n; j++) { + printf("registering resources for interface %d\n", j); i[j].register_resources(r, n0); if (resource_table_add(r, n0, j) != 0) ret = CONTROL_REGISTRATION_FAILED; @@ -109,7 +110,7 @@ special_read_command(control_cmd_t cmd, uint8_t payload[], unsigned payload_len) } static control_ret_t -write_command(client interface control i[], +write_command(client interface control i[CONTROL_INTERFACES_NUM], unsigned char ifnum, control_resid_t resid, control_cmd_t cmd, const uint8_t payload[], unsigned payload_len) { @@ -130,7 +131,7 @@ write_command(client interface control i[], } static control_ret_t -read_command(client interface control i[], +read_command(client interface control i[CONTROL_INTERFACES_NUM], unsigned char ifnum, control_resid_t resid, control_cmd_t cmd, uint8_t payload[], unsigned payload_len) { @@ -148,7 +149,7 @@ read_command(client interface control i[], } control_ret_t -control_process_i2c_write_start(client interface control i[]) +control_process_i2c_write_start(client interface control i[CONTROL_INTERFACES_NUM]) { UNUSED_RES(i); // always start a new command @@ -158,7 +159,7 @@ control_process_i2c_write_start(client interface control i[]) } control_ret_t -control_process_i2c_write_data(const uint8_t data, client interface control i[]) +control_process_i2c_write_data(const uint8_t data, client interface control i[CONTROL_INTERFACES_NUM]) { unsigned char ifnum; control_ret_t ret = CONTROL_ERROR; @@ -250,7 +251,7 @@ control_process_i2c_write_data(const uint8_t data, client interface control i[]) } control_ret_t -control_process_i2c_read_start(client interface control i[]) +control_process_i2c_read_start(client interface control i[CONTROL_INTERFACES_NUM]) { control_ret_t ret; @@ -284,7 +285,7 @@ control_process_i2c_read_start(client interface control i[]) } control_ret_t -control_process_i2c_read_data(uint8_t &data, client interface control i[]) +control_process_i2c_read_data(uint8_t &data, client interface control i[CONTROL_INTERFACES_NUM]) { UNUSED_RES(i); @@ -313,7 +314,7 @@ control_process_i2c_read_data(uint8_t &data, client interface control i[]) } control_ret_t -control_process_i2c_stop(client interface control i[]) +control_process_i2c_stop(client interface control i[CONTROL_INTERFACES_NUM]) { UNUSED_RES(i); @@ -369,7 +370,7 @@ control_process_i2c_stop(client interface control i[]) control_ret_t control_process_usb_set_request(uint16_t windex, uint16_t wvalue, uint16_t wlength, const uint8_t request_data[], - client interface control i[]) + client interface control i[CONTROL_INTERFACES_NUM]) { unsigned payload_len; control_resid_t resid; @@ -400,7 +401,7 @@ control_process_usb_set_request(uint16_t windex, uint16_t wvalue, uint16_t wleng control_ret_t control_process_usb_get_request(uint16_t windex, uint16_t wvalue, uint16_t wlength, uint8_t request_data[], - client interface control i[]) + client interface control i[CONTROL_INTERFACES_NUM]) { unsigned payload_len; control_resid_t resid; @@ -427,7 +428,7 @@ control_process_usb_get_request(uint16_t windex, uint16_t wvalue, uint16_t wleng control_ret_t control_process_xscope_upload(uint8_t buf[], unsigned buf_size, unsigned length_in, unsigned &length_out, - client interface control i[]) + client interface control i[CONTROL_INTERFACES_NUM]) { (void)buf_size; (void)length_in; @@ -490,7 +491,7 @@ static struct { /************/ control_ret_t -control_process_spi_master_ends_transaction(client interface control i_ctl[]) +control_process_spi_master_ends_transaction(client interface control i_ctl[CONTROL_INTERFACES_NUM]) { /* Debugging */ // debug_printf("Recieved: "); @@ -541,7 +542,7 @@ control_process_spi_master_ends_transaction(client interface control i_ctl[]) } control_ret_t -control_process_spi_master_requires_data(uint32_t &data, client interface control i_ctl[]) +control_process_spi_master_requires_data(uint32_t &data, client interface control i_ctl[CONTROL_INTERFACES_NUM]) { control_ret_t ret = CONTROL_SUCCESS; data = 0; @@ -566,7 +567,7 @@ control_process_spi_master_requires_data(uint32_t &data, client interface contro } control_ret_t -control_process_spi_master_supplied_data(uint32_t datum, uint32_t valid_bits, client interface control i_ctl[]) +control_process_spi_master_supplied_data(uint32_t datum, uint32_t valid_bits, client interface control i_ctl[CONTROL_INTERFACES_NUM]) { /* Debugging */ // buffer[buffer_length] = (unsigned char) datum; From 3bd9650b695e19ceef38c5a17e19cd8d033156f7 Mon Sep 17 00:00:00 2001 From: Ed Date: Mon, 16 Mar 2026 15:41:49 +0000 Subject: [PATCH 2/2] Update all arrays with CONTROL_INTERFACES_NUM --- examples/spi/device/src/main.xc | 8 +++----- examples/usb/device/src/endpoint0.xc | 4 ---- examples/usb/device/src/main.xc | 2 +- examples/xscope/device/src/main.xc | 4 +--- lib_device_control/adapters/transport_spi.xc | 4 +--- lib_device_control/adapters/transport_usb.xc | 4 ++-- .../adapters/transport_xscope.xc | 6 ++---- lib_device_control/inc/control_default_conf.h | 3 +++ lib_device_control/inc/transport_spi.h | 2 +- lib_device_control/inc/transport_usb.h | 4 ++-- lib_device_control/inc/transport_xscope.h | 2 +- lib_device_control/src/control.xc | 2 -- tests/i2c_device/src/control_conf.h | 9 +++++++++ tests/i2c_device/src/test.xc | 18 ++++++++---------- tests/i2c_end_to_end_sim/src/app_device.xc | 2 -- tests/spi_device/src/control_conf.h | 9 +++++++++ tests/spi_device/src/test.xc | 18 ++++++++---------- tests/usb_device/src/control_conf.h | 9 +++++++++ tests/usb_device/src/test.xc | 18 ++++++++---------- tests/usb_end_to_end_hardware/src/main.xc | 4 ---- tests/version/src/test.xc | 8 -------- tests/xscope_device/src/control_conf.h | 9 +++++++++ tests/xscope_device/src/test.xc | 18 ++++++++---------- 23 files changed, 85 insertions(+), 82 deletions(-) create mode 100644 tests/i2c_device/src/control_conf.h create mode 100644 tests/spi_device/src/control_conf.h create mode 100644 tests/usb_device/src/control_conf.h create mode 100644 tests/xscope_device/src/control_conf.h diff --git a/examples/spi/device/src/main.xc b/examples/spi/device/src/main.xc index 8fb4421f..ea5d126f 100644 --- a/examples/spi/device/src/main.xc +++ b/examples/spi/device/src/main.xc @@ -17,15 +17,13 @@ on tile[PORT_SPI_SLAVE_CS_TILE_NUM]: in port p_ss = PORT_SPI_SL on tile[PORT_SPI_SLAVE_MISO_TILE_NUM]: out buffered port:32 p_miso = PORT_SPI_SLAVE_MISO; on tile[PORT_SPI_SLAVE_MOSI_TILE_NUM]: in buffered port:32 p_mosi = PORT_SPI_SLAVE_MOSI; -void spi_ctrl(client interface control i_control[1]) +void spi_ctrl(client interface control i_control[CONTROL_INTERFACES_NUM]) { interface spi_slave_callback_if i_spi; control_init(); - control_register_resources(i_control, 1); + control_register_resources(i_control, CONTROL_INTERFACES_NUM); par { -#pragma warning disable unusual-code // Suppress slice interface warning (no array size passed) spi_control_client(i_spi, i_control); -#pragma warning enable spi_slave(i_spi, p_sclk, p_mosi, p_miso, p_ss, cb, SPI_MODE_3, SPI_TRANSFER_SIZE_8); } @@ -34,7 +32,7 @@ void spi_ctrl(client interface control i_control[1]) int main(void) { - interface control i_control[1]; + interface control i_control[CONTROL_INTERFACES_NUM]; par { on tile[PORT_SPI_SLAVE_SCLK_TILE_NUM]: par { spi_ctrl(i_control); diff --git a/examples/usb/device/src/endpoint0.xc b/examples/usb/device/src/endpoint0.xc index 74b3008a..1e14043b 100644 --- a/examples/usb/device/src/endpoint0.xc +++ b/examples/usb/device/src/endpoint0.xc @@ -106,9 +106,7 @@ void Endpoint0(chanend chan_ep0_out, chanend chan_ep0_in, client interface contr break; case USB_BMREQ_H2D_VENDOR_DEV: -#pragma warning disable unusual-code // Suppress slice interface warning (no array size passed) result = USB_H2D_VendorRequest(ep0_out, ep0_in, &sp, i_control); -#pragma warning enable break; case USB_BMREQ_D2H_VENDOR_DEV: @@ -116,9 +114,7 @@ void Endpoint0(chanend chan_ep0_out, chanend chan_ep0_in, client interface contr result = XUD_GetMsosDescriptor(ep0_out, ep0_in, &sp); } else { -#pragma warning disable unusual-code // Suppress slice interface warning (no array size passed) result = USB_D2H_VendorRequest(ep0_out, ep0_in, &sp, i_control); -#pragma warning enable } break; } diff --git a/examples/usb/device/src/main.xc b/examples/usb/device/src/main.xc index 3512be6a..aade4ad5 100644 --- a/examples/usb/device/src/main.xc +++ b/examples/usb/device/src/main.xc @@ -26,7 +26,7 @@ XUD_EpType epTypeTableIn[XUD_EP_COUNT_IN] = {XUD_EPTYPE_CTL | XUD_STATUS_ENABL int main(void) { chan c_ep_out[XUD_EP_COUNT_OUT], c_ep_in[XUD_EP_COUNT_IN]; - interface control i_control[1]; + interface control i_control[CONTROL_INTERFACES_NUM]; par { on USB_TILE: par { Endpoint0(c_ep_out[0], c_ep_in[0], i_control); diff --git a/examples/xscope/device/src/main.xc b/examples/xscope/device/src/main.xc index 1c6a82d6..5c93e5dd 100644 --- a/examples/xscope/device/src/main.xc +++ b/examples/xscope/device/src/main.xc @@ -14,13 +14,11 @@ int main(void) { chan c_xscope; - interface control i_control[1]; + interface control i_control[CONTROL_INTERFACES_NUM]; par { xscope_host_data(c_xscope); -#pragma warning disable unusual-code // Suppress slice interface warning (no array size passed) on tile[0]: xscope_control_client(c_xscope, i_control); -#pragma warning enable on tile[0]: app(i_control[0]); } return 0; diff --git a/lib_device_control/adapters/transport_spi.xc b/lib_device_control/adapters/transport_spi.xc index b4d7db49..9baa4df8 100644 --- a/lib_device_control/adapters/transport_spi.xc +++ b/lib_device_control/adapters/transport_spi.xc @@ -14,10 +14,9 @@ // // To include this file in the build, define CONTROL_USE_SPI as 1, in control_conf.h -void spi_control_client(server spi_slave_callback_if i_spi, client interface control i_control[]) +void spi_control_client(server spi_slave_callback_if i_spi, client interface control i_control[CONTROL_INTERFACES_NUM]) { while (1) { -#pragma warning disable unusual-code // Suppress slice interface warning (no array size passed) select { case i_spi.master_ends_transaction(): control_process_spi_master_ends_transaction(i_control); @@ -29,7 +28,6 @@ void spi_control_client(server spi_slave_callback_if i_spi, client interface con control_process_spi_master_supplied_data(datum, valid_bits, i_control); break; } -#pragma warning enable } } diff --git a/lib_device_control/adapters/transport_usb.xc b/lib_device_control/adapters/transport_usb.xc index e945b8d1..12fd60e2 100644 --- a/lib_device_control/adapters/transport_usb.xc +++ b/lib_device_control/adapters/transport_usb.xc @@ -34,7 +34,7 @@ static XUD_Result_t USB_EP0_Receive(XUD_ep ep0_out, USB_SetupPacket_t *sp, uint8 } // case USB_BMREQ_H2D_VENDOR_DEV: -XUD_Result_t USB_H2D_VendorRequest(XUD_ep ep0_out, XUD_ep ep0_in, USB_SetupPacket_t *sp, client interface control i_control[]) { +XUD_Result_t USB_H2D_VendorRequest(XUD_ep ep0_out, XUD_ep ep0_in, USB_SetupPacket_t *sp, client interface control i_control[CONTROL_INTERFACES_NUM]) { XUD_Result_t result = XUD_RES_ERR; if ((sp->bRequest == CONTROL_VENDOR_REQUEST) && (sp->wLength <= EP0_MAX_REQUEST_SIZE)) { result = USB_EP0_Receive(ep0_out, sp, request_data); @@ -53,7 +53,7 @@ XUD_Result_t USB_H2D_VendorRequest(XUD_ep ep0_out, XUD_ep ep0_in, USB_SetupPacke } // case USB_BMREQ_D2H_VENDOR_DEV: -XUD_Result_t USB_D2H_VendorRequest(XUD_ep ep0_out, XUD_ep ep0_in, USB_SetupPacket_t *sp, client interface control i_control[]) { +XUD_Result_t USB_D2H_VendorRequest(XUD_ep ep0_out, XUD_ep ep0_in, USB_SetupPacket_t *sp, client interface control i_control[CONTROL_INTERFACES_NUM]) { XUD_Result_t result = XUD_RES_ERR; if ((sp->bRequest == CONTROL_VENDOR_REQUEST) && (sp->wLength <= EP0_MAX_REQUEST_SIZE)) { control_ret_t ctrl = control_process_usb_get_request(sp->wIndex, sp->wValue, sp->wLength, request_data, i_control); diff --git a/lib_device_control/adapters/transport_xscope.xc b/lib_device_control/adapters/transport_xscope.xc index 459bcaea..3a1ffdbc 100644 --- a/lib_device_control/adapters/transport_xscope.xc +++ b/lib_device_control/adapters/transport_xscope.xc @@ -16,13 +16,13 @@ #define DEBUG_UNIT TRANSPORT #include "debug_print.h" -void xscope_control_client(chanend c_xscope, client interface control i_control[]) +void xscope_control_client(chanend c_xscope, client interface control i_control[CONTROL_INTERFACES_NUM]) { uint8_t buffer[256]; /* 256 bytes from xscope.h */ int num_bytes_read; control_init(); - control_register_resources(i_control, 1); + control_register_resources(i_control, CONTROL_INTERFACES_NUM); xscope_connect_data_from_host(c_xscope); @@ -32,9 +32,7 @@ void xscope_control_client(chanend c_xscope, client interface control i_control[ select { case xscope_data_from_host(c_xscope, buffer, num_bytes_read): unsigned return_size; -#pragma warning disable unusual-code // Suppress slice interface warning (no array size passed) control_process_xscope_upload(buffer, sizeof(buffer), num_bytes_read, return_size, i_control); -#pragma warning enable if (return_size > 0) { xscope_core_bytes(0, return_size, buffer); } diff --git a/lib_device_control/inc/control_default_conf.h b/lib_device_control/inc/control_default_conf.h index a4348cd1..eabce096 100644 --- a/lib_device_control/inc/control_default_conf.h +++ b/lib_device_control/inc/control_default_conf.h @@ -10,6 +10,9 @@ #ifndef CONTROL_INTERFACES_NUM #define CONTROL_INTERFACES_NUM 1 +// TODO host apps fail with this warning +// #warning "CONTROL_INTERFACES_NUM not defined in control_conf.h, defaulting to 1." +// #warning "Please define CONTROL_INTERFACES_NUM in control_conf.h to silence this warning." #endif #if CONTROL_INTERFACES_NUM <= 0 diff --git a/lib_device_control/inc/transport_spi.h b/lib_device_control/inc/transport_spi.h index 723bb55a..463f0806 100644 --- a/lib_device_control/inc/transport_spi.h +++ b/lib_device_control/inc/transport_spi.h @@ -14,6 +14,6 @@ * \param i_control Control interface array * */ -void spi_control_client(SERVER_INTERFACE(spi_slave_callback_if, i_spi), CLIENT_INTERFACE(control, i_control[])); +void spi_control_client(SERVER_INTERFACE(spi_slave_callback_if, i_spi), CLIENT_INTERFACE(control, i_control[CONTROL_INTERFACES_NUM])); #endif // TRANSPORT_SPI_H diff --git a/lib_device_control/inc/transport_usb.h b/lib_device_control/inc/transport_usb.h index d8d2d7fa..5403e945 100644 --- a/lib_device_control/inc/transport_usb.h +++ b/lib_device_control/inc/transport_usb.h @@ -17,7 +17,7 @@ * * \return XUD_Result_t Result of the operation */ -XUD_Result_t USB_H2D_VendorRequest(XUD_ep ep0_out, XUD_ep ep0_in, USB_SetupPacket_t *sp, CLIENT_INTERFACE(control, i_control[])); +XUD_Result_t USB_H2D_VendorRequest(XUD_ep ep0_out, XUD_ep ep0_in, USB_SetupPacket_t *sp, CLIENT_INTERFACE(control, i_control[CONTROL_INTERFACES_NUM])); /** USB transport host read (Get) processing function * \param ep0_out Endpoint 0 OUT endpoint @@ -27,6 +27,6 @@ XUD_Result_t USB_H2D_VendorRequest(XUD_ep ep0_out, XUD_ep ep0_in, USB_SetupPacke * * \return XUD_Result_t Result of the operation */ -XUD_Result_t USB_D2H_VendorRequest(XUD_ep ep0_out, XUD_ep ep0_in, USB_SetupPacket_t *sp, CLIENT_INTERFACE(control, i_control[])); +XUD_Result_t USB_D2H_VendorRequest(XUD_ep ep0_out, XUD_ep ep0_in, USB_SetupPacket_t *sp, CLIENT_INTERFACE(control, i_control[CONTROL_INTERFACES_NUM])); #endif // TRANSPORT_USB_H diff --git a/lib_device_control/inc/transport_xscope.h b/lib_device_control/inc/transport_xscope.h index 4424e7e7..fbdeac20 100644 --- a/lib_device_control/inc/transport_xscope.h +++ b/lib_device_control/inc/transport_xscope.h @@ -14,6 +14,6 @@ * \param i_control Control interface array * */ -void xscope_control_client(chanend c_xscope, CLIENT_INTERFACE(control, i_control[])); +void xscope_control_client(chanend c_xscope, CLIENT_INTERFACE(control, i_control[CONTROL_INTERFACES_NUM])); #endif // TRANSPORT_XSCOPE_H diff --git a/lib_device_control/src/control.xc b/lib_device_control/src/control.xc index f08221f9..2ae21db3 100644 --- a/lib_device_control/src/control.xc +++ b/lib_device_control/src/control.xc @@ -2,7 +2,6 @@ // This Software is subject to the terms of the XMOS Public Licence: Version 1. #include #include -#include #include #include "control.h" #include "control_transport_shared.h" @@ -42,7 +41,6 @@ control_ret_t control_register_resources(client interface control i[n], unsigned ret = CONTROL_SUCCESS; for (j = 0; j < n; j++) { - printf("registering resources for interface %d\n", j); i[j].register_resources(r, n0); if (resource_table_add(r, n0, j) != 0) ret = CONTROL_REGISTRATION_FAILED; diff --git a/tests/i2c_device/src/control_conf.h b/tests/i2c_device/src/control_conf.h new file mode 100644 index 00000000..d7dca21f --- /dev/null +++ b/tests/i2c_device/src/control_conf.h @@ -0,0 +1,9 @@ +// Copyright 2026 XMOS LIMITED. +// This Software is subject to the terms of the XMOS Public Licence: Version 1. + +#ifndef CONTROL_CONF_H +#define CONTROL_CONF_H + +#define CONTROL_INTERFACES_NUM 3 + +#endif // CONTROL_CONF_H diff --git a/tests/i2c_device/src/test.xc b/tests/i2c_device/src/test.xc index feff4958..50f2e1a8 100644 --- a/tests/i2c_device/src/test.xc +++ b/tests/i2c_device/src/test.xc @@ -10,7 +10,7 @@ #include "support_inline.h" #include "user_task.h" -void test_client(client interface control i[3], chanend c_user_task[3]) +void test_client(client interface control i[CONTROL_INTERFACES_NUM], chanend c_user_task[CONTROL_INTERFACES_NUM]) { uint8_t buf[I2C_TRANSACTION_MAX_BYTES]; size_t buf_len; @@ -32,8 +32,8 @@ void test_client(client interface control i[3], chanend c_user_task[3]) /* trigger a registration call, catch it and supply resource IDs to register */ par { - control_register_resources(i, 3); - drive_user_task_registration(c_user_task, 3); + control_register_resources(i, CONTROL_INTERFACES_NUM); + drive_user_task_registration(c_user_task, CONTROL_INTERFACES_NUM); } fails = 0; @@ -56,7 +56,6 @@ void test_client(client interface control i[3], chanend c_user_task[3]) tmr :> t; timeout = 0; par { -#pragma warning disable unusual-code // Suppress slice interface warning (no array size passed) { control_ret_t ret; ret = CONTROL_SUCCESS; ret |= control_process_i2c_write_start(i); @@ -94,7 +93,6 @@ void test_client(client interface control i[3], chanend c_user_task[3]) d :> ret; fails += check(o, c1, c2, timeout, ret, 3); } -#pragma warning enable } } } @@ -115,13 +113,13 @@ void test_client(client interface control i[3], chanend c_user_task[3]) int main(void) { - interface control i[3]; - chan c_user_task[3]; + interface control i[CONTROL_INTERFACES_NUM]; + chan c_user_task[CONTROL_INTERFACES_NUM]; par { test_client(i, c_user_task); - user_task(i[0], c_user_task[0]); - user_task(i[1], c_user_task[1]); - user_task(i[2], c_user_task[2]); + par(int t=0; t < CONTROL_INTERFACES_NUM; t++) { + user_task(i[t], c_user_task[t]); + } { delay_microseconds(10000); printf("ERROR - test timeout\n"); exit(1); diff --git a/tests/i2c_end_to_end_sim/src/app_device.xc b/tests/i2c_end_to_end_sim/src/app_device.xc index ff98cb35..c12d3864 100644 --- a/tests/i2c_end_to_end_sim/src/app_device.xc +++ b/tests/i2c_end_to_end_sim/src/app_device.xc @@ -14,7 +14,6 @@ void i2c_client(server i2c_slave_callback_if i_i2c, client interface control i_c while (1) { select { -#pragma warning disable unusual-code // Suppress slice interface warning (no array size passed) case i_i2c.ack_write_request(void) -> i2c_slave_ack_t resp: if (control_process_i2c_write_start(i_control) == CONTROL_SUCCESS) resp = I2C_SLAVE_ACK; @@ -45,7 +44,6 @@ void i2c_client(server i2c_slave_callback_if i_i2c, client interface control i_c control_process_i2c_stop(i_control); break; } -#pragma warning enable } } diff --git a/tests/spi_device/src/control_conf.h b/tests/spi_device/src/control_conf.h new file mode 100644 index 00000000..d7dca21f --- /dev/null +++ b/tests/spi_device/src/control_conf.h @@ -0,0 +1,9 @@ +// Copyright 2026 XMOS LIMITED. +// This Software is subject to the terms of the XMOS Public Licence: Version 1. + +#ifndef CONTROL_CONF_H +#define CONTROL_CONF_H + +#define CONTROL_INTERFACES_NUM 3 + +#endif // CONTROL_CONF_H diff --git a/tests/spi_device/src/test.xc b/tests/spi_device/src/test.xc index 5b3c5195..a5ac09dd 100644 --- a/tests/spi_device/src/test.xc +++ b/tests/spi_device/src/test.xc @@ -10,7 +10,7 @@ #include "support_inline.h" #include "user_task.h" -void test_client(client interface control i[3], chanend c_user_task[3]) +void test_client(client interface control i[CONTROL_INTERFACES_NUM], chanend c_user_task[CONTROL_INTERFACES_NUM]) { uint8_t buf[SPI_TRANSACTION_MAX_BYTES]; size_t buf_len; @@ -33,8 +33,8 @@ void test_client(client interface control i[3], chanend c_user_task[3]) /* trigger a registration call, catch it and supply resource IDs to register */ par { - control_register_resources(i, 3); - drive_user_task_registration(c_user_task, 3); + control_register_resources(i, CONTROL_INTERFACES_NUM); + drive_user_task_registration(c_user_task, CONTROL_INTERFACES_NUM); } fails = 0; @@ -58,7 +58,6 @@ void test_client(client interface control i[3], chanend c_user_task[3]) tmr :> t; timeout = 0; par { -#pragma warning disable unusual-code // Suppress slice interface warning (no array size passed) { control_ret_t ret; ret = CONTROL_SUCCESS; @@ -103,7 +102,6 @@ void test_client(client interface control i[3], chanend c_user_task[3]) } d <: ret; } -#pragma warning disable { control_ret_t ret; select { case drive_user_task_commands(c2, c1, c_user_task, o.read_cmd); @@ -134,13 +132,13 @@ void test_client(client interface control i[3], chanend c_user_task[3]) int main(void) { - interface control i[3]; - chan c_user_task[3]; + interface control i[CONTROL_INTERFACES_NUM]; + chan c_user_task[CONTROL_INTERFACES_NUM]; par { test_client(i, c_user_task); - user_task(i[0], c_user_task[0]); - user_task(i[1], c_user_task[1]); - user_task(i[2], c_user_task[2]); + par(int t=0; t < CONTROL_INTERFACES_NUM; t++) { + user_task(i[t], c_user_task[t]); + } { delay_microseconds(10000); printf("ERROR - test timeout\n"); exit(1); diff --git a/tests/usb_device/src/control_conf.h b/tests/usb_device/src/control_conf.h new file mode 100644 index 00000000..d7dca21f --- /dev/null +++ b/tests/usb_device/src/control_conf.h @@ -0,0 +1,9 @@ +// Copyright 2026 XMOS LIMITED. +// This Software is subject to the terms of the XMOS Public Licence: Version 1. + +#ifndef CONTROL_CONF_H +#define CONTROL_CONF_H + +#define CONTROL_INTERFACES_NUM 3 + +#endif // CONTROL_CONF_H diff --git a/tests/usb_device/src/test.xc b/tests/usb_device/src/test.xc index 72dad4f1..24f79c39 100644 --- a/tests/usb_device/src/test.xc +++ b/tests/usb_device/src/test.xc @@ -10,7 +10,7 @@ #include "support_inline.h" #include "user_task.h" -void test_client(client interface control i[3], chanend c_user_task[3]) +void test_client(client interface control i[CONTROL_INTERFACES_NUM], chanend c_user_task[CONTROL_INTERFACES_NUM]) { uint16_t windex, wvalue, wlength; struct command c1, c2; @@ -31,8 +31,8 @@ void test_client(client interface control i[3], chanend c_user_task[3]) /* trigger a registration call, catch it and supply resource IDs to register */ par { - control_register_resources(i, 3); - drive_user_task_registration(c_user_task, 3); + control_register_resources(i, CONTROL_INTERFACES_NUM); + drive_user_task_registration(c_user_task, CONTROL_INTERFACES_NUM); } fails = 0; @@ -59,7 +59,6 @@ void test_client(client interface control i[3], chanend c_user_task[3]) tmr :> t; timeout = 0; par { -#pragma warning disable unusual-code // Suppress slice interface warning (no array size passed) { if (o.read_cmd) { d <: control_process_usb_get_request(windex, wvalue, wlength, (uint8_t*)payload_ptr, i); @@ -74,7 +73,6 @@ void test_client(client interface control i[3], chanend c_user_task[3]) d <: payload_ptr[0]; } } -#pragma warning enable { select { case drive_user_task_commands(c2, c1, c_user_task, o.read_cmd); case tmr when timerafter(t + 500) :> void: @@ -104,13 +102,13 @@ void test_client(client interface control i[3], chanend c_user_task[3]) int main(void) { - interface control i[3]; - chan c_user_task[3]; + interface control i[CONTROL_INTERFACES_NUM]; + chan c_user_task[CONTROL_INTERFACES_NUM]; par { test_client(i, c_user_task); - user_task(i[0], c_user_task[0]); - user_task(i[1], c_user_task[1]); - user_task(i[2], c_user_task[2]); + par(int t=0; t < CONTROL_INTERFACES_NUM; t++) { + user_task(i[t], c_user_task[t]); + } { delay_microseconds(5000); printf("ERROR - test timeout\n"); exit(1); diff --git a/tests/usb_end_to_end_hardware/src/main.xc b/tests/usb_end_to_end_hardware/src/main.xc index 29fc0e70..704fefaa 100644 --- a/tests/usb_end_to_end_hardware/src/main.xc +++ b/tests/usb_end_to_end_hardware/src/main.xc @@ -44,10 +44,8 @@ void endpoint0(chanend c_ep0_out, chanend c_ep0_in, client interface control i_c case USB_BMREQ_H2D_VENDOR_DEV: res = XUD_GetBuffer(ep0_out, request_data, len); if (res == XUD_RES_OKAY) { -#pragma warning disable unusual-code // Suppress slice interface warning (no array size passed) if (control_process_usb_set_request(sp.wIndex, sp.wValue, sp.wLength, request_data, i_control) == CONTROL_SUCCESS) { -#pragma warning enable /* zero length data to indicate success * on control error, go to standard requests, which will issue STALL */ @@ -60,10 +58,8 @@ void endpoint0(chanend c_ep0_out, chanend c_ep0_in, client interface control i_c /* application retrieval latency inside the control library call * XUD task defers further calls by NAKing USB transactions */ -#pragma warning disable unusual-code // Suppress slice interface warning (no array size passed) if (control_process_usb_get_request(sp.wIndex, sp.wValue, sp.wLength, request_data, i_control) == CONTROL_SUCCESS) { -#pragma warning enable len = sp.wLength; res = XUD_DoGetRequest(ep0_out, ep0_in, request_data, len, len); handled = 1; diff --git a/tests/version/src/test.xc b/tests/version/src/test.xc index 55608368..995523a6 100644 --- a/tests/version/src/test.xc +++ b/tests/version/src/test.xc @@ -18,9 +18,7 @@ void test_usb(client interface control i[1]) control_usb_fill_header(&windex, &wvalue, &wlength, CONTROL_SPECIAL_RESID, CONTROL_GET_VERSION, sizeof(control_version_t)); -#pragma warning disable unusual-code // Suppress slice interface warning (no array size passed) ret = control_process_usb_get_request(windex, wvalue, wlength, request_data, i); -#pragma warning disable memcpy(&version, request_data, sizeof(control_version_t)); if (ret != CONTROL_SUCCESS) { @@ -46,7 +44,6 @@ void test_i2c(client interface control i[1]) CONTROL_GET_VERSION, data, sizeof(control_version_t)); ret = CONTROL_SUCCESS; -#pragma warning disable unusual-code // Suppress slice interface warning (no array size passed) ret |= control_process_i2c_write_start(i); for (j = 0; j < len; j++) { ret |= control_process_i2c_write_data(buf[j], i); @@ -58,7 +55,6 @@ void test_i2c(client interface control i[1]) memcpy(&version, data, sizeof(control_version_t)); ret |= control_process_i2c_stop(i); -#pragma warning enable if (ret != CONTROL_SUCCESS) { printf("ERROR - I2C processing functions returned %d\n", ret); @@ -85,7 +81,6 @@ void test_spi(client interface control i[1]) len = control_build_spi_data(buf, CONTROL_SPECIAL_RESID, CONTROL_GET_VERSION, (uint8_t*) data, sizeof(control_version_t)); -#pragma warning disable unusual-code // Suppress slice interface warning (no array size passed) // Send message information in a write transaction for (j = 0; j < len; j++) { ret |= control_process_spi_master_supplied_data(buf[j], SPI_TRANSFER_SIZE_BITS, i); @@ -102,7 +97,6 @@ void test_spi(client interface control i[1]) memcpy(&version, data, sizeof(control_version_t)); ret |= control_process_spi_master_ends_transaction(i); -#pragma warning disable if (ret != CONTROL_SUCCESS) { printf("ERROR - SPI processing functions returned %d\n", ret); @@ -125,9 +119,7 @@ void test_xscope(client interface control i[1]) len = control_xscope_create_upload_buffer(buf, CONTROL_GET_VERSION, CONTROL_SPECIAL_RESID, NULL, sizeof(control_version_t)); -#pragma warning disable unusual-code // Suppress slice interface warning (no array size passed) ret = control_process_xscope_upload((uint8_t*)buf, sizeof(buf), len, len2, i); -#pragma warning enable resp = (struct control_xscope_response*)buf; version = *(control_version_t*)(resp + 1); diff --git a/tests/xscope_device/src/control_conf.h b/tests/xscope_device/src/control_conf.h new file mode 100644 index 00000000..d7dca21f --- /dev/null +++ b/tests/xscope_device/src/control_conf.h @@ -0,0 +1,9 @@ +// Copyright 2026 XMOS LIMITED. +// This Software is subject to the terms of the XMOS Public Licence: Version 1. + +#ifndef CONTROL_CONF_H +#define CONTROL_CONF_H + +#define CONTROL_INTERFACES_NUM 3 + +#endif // CONTROL_CONF_H diff --git a/tests/xscope_device/src/test.xc b/tests/xscope_device/src/test.xc index 825cf1b5..a8925ef2 100644 --- a/tests/xscope_device/src/test.xc +++ b/tests/xscope_device/src/test.xc @@ -13,7 +13,7 @@ #define PRINT_ALL 0 -void test_client(client interface control i[3], chanend c_user_task[3]) +void test_client(client interface control i[CONTROL_INTERFACES_NUM], chanend c_user_task[CONTROL_INTERFACES_NUM]) { uint32_t buf[64]; struct command c1, c2; @@ -39,8 +39,8 @@ void test_client(client interface control i[3], chanend c_user_task[3]) /* trigger a registration call, catch it and supply resource IDs to register */ par { - control_register_resources(i, 3); - drive_user_task_registration(c_user_task, 3); + control_register_resources(i, CONTROL_INTERFACES_NUM); + drive_user_task_registration(c_user_task, CONTROL_INTERFACES_NUM); } fails = 0; @@ -68,9 +68,7 @@ void test_client(client interface control i[3], chanend c_user_task[3]) tmr :> t; timeout = 0; par { -#pragma warning disable unusual-code // Suppress slice interface warning (no array size passed) d <: control_process_xscope_upload((uint8_t*)buf_ptr, sizeof(buf), lenin, lenout, i); -#pragma warning enable { const size_t header_len = sizeof(struct control_xscope_response); struct control_xscope_response *resp = (struct control_xscope_response*)buf; uint8_t *payload = (uint8_t*)(resp + 1); @@ -151,13 +149,13 @@ void test_client(client interface control i[3], chanend c_user_task[3]) int main(void) { - interface control i[3]; - chan c_user_task[3]; + interface control i[CONTROL_INTERFACES_NUM]; + chan c_user_task[CONTROL_INTERFACES_NUM]; par { test_client(i, c_user_task); - user_task(i[0], c_user_task[0]); - user_task(i[1], c_user_task[1]); - user_task(i[2], c_user_task[2]); + par(int t=0; t < CONTROL_INTERFACES_NUM; t++) { + user_task(i[t], c_user_task[t]); + } { delay_microseconds(5000); printf("ERROR - test timeout\n"); exit(1);