Skip to content

Commit 49ed243

Browse files
committed
applications: sdp: mspi: change opcode cast to uint32
Change cast of opcode in ep_recv function to uint32_t instead of uint8_t. Signed-off-by: Magdalena Pastula <magdalena.pastula@nordicsemi.no>
1 parent c2daec3 commit 49ed243

File tree

4 files changed

+41
-26
lines changed

4 files changed

+41
-26
lines changed

CODEOWNERS

+1
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@
346346
/include/drivers/flash/flash_ipuc.h @nrfconnect/ncs-co-drivers @nrfconnect/ncs-charon
347347
/include/drivers/gpio/ @nrfconnect/ncs-co-drivers @nrfconnect/ncs-ll-ursus
348348
/include/drivers/bme68x_iaq.h @nrfconnect/ncs-co-drivers @nrfconnect/ncs-cia
349+
/include/drivers/mspi/nrf_mspi.h @nrfconnect/ncs-co-drivers @nrfconnect/ncs-ll-ursus
349350
/include/drivers/mspi/nrfe_mspi.h @nrfconnect/ncs-co-drivers @nrfconnect/ncs-ll-ursus
350351
/include/drivers/sensor_sim.h @nrfconnect/ncs-co-drivers @nrfconnect/ncs-cia
351352
/include/drivers/sensor_stub.h @nrfconnect/ncs-co-drivers @nrfconnect/ncs-cia

applications/sdp/mspi/src/main.c

+5-3
Original file line numberDiff line numberDiff line change
@@ -423,8 +423,9 @@ static void ep_recv(const void *data, size_t len, void *priv)
423423

424424
(void)priv;
425425
(void)len;
426-
uint8_t opcode = *(uint8_t *)data;
426+
uint32_t opcode = *(uint32_t *)data;
427427
uint32_t num_bytes = 0;
428+
uint32_t *resp_buff = (uint32_t *)response_buffer;
428429

429430
#if defined(CONFIG_SDP_MSPI_FAULT_TIMER)
430431
if (fault_timer != NULL) {
@@ -483,7 +484,8 @@ static void ep_recv(const void *data, size_t len, void *priv)
483484
}
484485

485486
/* If there is reset defined on any data line, assume it is no longer valid and
486-
* clear it. */
487+
* clear it.
488+
*/
487489
if (dev_config->dev_config.io_mode != MSPI_IO_MODE_SINGLE &&
488490
reset_configs[dev_config->device_index].pin_number != PIN_UNUSED) {
489491
nrf_vpr_csr_vio_out_clear_set(
@@ -545,7 +547,7 @@ static void ep_recv(const void *data, size_t len, void *priv)
545547
break;
546548
}
547549

548-
response_buffer[0] = opcode;
550+
resp_buff[0] = opcode;
549551
ipc_service_send(&ep, (const void *)response_buffer,
550552
sizeof(nrfe_mspi_opcode_t) + num_bytes);
551553

drivers/mspi/mspi_nrfe.c

+6-7
Original file line numberDiff line numberDiff line change
@@ -1063,13 +1063,12 @@ static int nrfe_mspi_init(const struct device *dev)
10631063
}
10641064

10651065
static const struct nrf_mspi_driver_api drv_api = {
1066-
.std_api =
1067-
{
1068-
.config = api_config,
1069-
.dev_config = api_dev_config,
1070-
.get_channel_status = api_get_channel_status,
1071-
.transceive = api_transceive,
1072-
},
1066+
.std_api = {
1067+
.config = api_config,
1068+
.dev_config = api_dev_config,
1069+
.get_channel_status = api_get_channel_status,
1070+
.transceive = api_transceive,
1071+
},
10731072
.reset_pin_config = api_reset_config,
10741073
.reset_pin_set = api_reset_set,
10751074
};

include/drivers/mspi/nrf_mspi.h

+29-16
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,25 @@ __subsystem struct nrf_mspi_driver_api {
2828
};
2929

3030
/**
31-
* @brief Configure reset pin. It is mandatory when reset pin overlaps with any data pin.
31+
* @brief Configure reset pin. It should be used if there is a chance that reset pin overlaps with
32+
* any data pin.
3233
*
33-
* @param dev pointer to the mspi device structure.
34-
* @param psel pin number
34+
* Function checks if given reset pin overlap with any pin used by MSPI. If it does and can be used
35+
* as reset in SINGLE mode (for example, ovelaps with data line DQ3), then it is saved in MSPI
36+
* driver. If it does not overlap, then gpio_pin_configure_dt() is called.
3537
*
36-
* @retval non-negative the observed state of the on-off service associated
37-
* with the clock machine at the time the request was
38-
* processed (see onoff_release()), if successful.
39-
* @retval -EIO if service has recorded an error.
40-
* @retval -ENOTSUP if the service is not in a state that permits release.
38+
* @param dev Pointer to the MSPI device structure.
39+
* @param dev_id Pointer to the device ID of the MSPI device.
40+
* @param spec GPIO specification from devicetree.
41+
* @param gpio_port_num GPIO port number of the selected reset pin.
42+
* @param extra_flags Additional GPIO flags.
43+
*
44+
* @retval 0 If successful.
45+
* @retval -ENOTSUP Return value from gpio_pin_configure_dt().
46+
* @retval -EINVAL If reset pin overlaps with MSPI pin that cannot be used as reset (e.g. CLK) or a
47+
* return value from gpio_pin_configure_dt().
48+
* @retval -EIO Return value from gpio_pin_configure_dt().
49+
* @retval -EWOULDBLOCK Return value from gpio_pin_configure_dt().
4150
*/
4251
static inline int nrf_mspi_reset_pin_config(const struct device *dev,
4352
const struct mspi_dev_id *dev_id,
@@ -50,16 +59,20 @@ static inline int nrf_mspi_reset_pin_config(const struct device *dev,
5059
}
5160

5261
/**
53-
* @brief Set reset pin state.
62+
* @brief Set reset pin state. It should be used if there is a chance that reset pin overlaps with
63+
* any data pin.
64+
*
65+
* If reset pin does not overlap with any MSPI pin, gpio_pin_set_dt() is called.
66+
* Assumes that nrf_mspi_reset_pin_config() was called before.
5467
*
55-
* @param dev pointer to the mspi device structure.
56-
* @param psel pin number
68+
* @param dev Pointer to the MSPI device structure.
69+
* @param spec GPIO specification from devicetree.
70+
* @param dev_id Pointer to the device ID of the MSPI device.
71+
* @param value Value assigned to the pin.
5772
*
58-
* @retval non-negative the observed state of the on-off service associated
59-
* with the clock machine at the time the request was
60-
* processed (see onoff_release()), if successful.
61-
* @retval -EIO if service has recorded an error.
62-
* @retval -ENOTSUP if the service is not in a state that permits release.
73+
* @retval 0 If successful.
74+
* @retval -EIO Return value from gpio_pin_set_dt().
75+
* @retval -EWOULDBLOCK Return value from gpio_pin_set_dt().
6376
*/
6477
static inline int nrf_mspi_reset_pin_set(const struct device *dev, const struct gpio_dt_spec *spec,
6578
const struct mspi_dev_id *dev_id, int value)

0 commit comments

Comments
 (0)