File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -94,11 +94,20 @@ rt_err_t rt_spi_configure(struct rt_spi_device *device,
9494
9595 RT_ASSERT (device != RT_NULL );
9696
97+ /* If the configurations are the same, we don't need to set again. */
98+ if (device -> config .data_width == cfg -> data_width &&
99+ device -> config .mode == (cfg -> mode & RT_SPI_MODE_MASK ) &&
100+ device -> config .max_hz == cfg -> max_hz )
101+ {
102+ return RT_EOK ;
103+ }
104+
97105 /* set configuration */
98106 device -> config .data_width = cfg -> data_width ;
99- device -> config .mode = cfg -> mode & RT_SPI_MODE_MASK ;
100- device -> config .max_hz = cfg -> max_hz ;
107+ device -> config .mode = cfg -> mode & RT_SPI_MODE_MASK ;
108+ device -> config .max_hz = cfg -> max_hz ;
101109
110+ /* reset the CS pin */
102111 if (device -> cs_pin != PIN_NONE )
103112 {
104113 if (device -> config .mode & RT_SPI_CS_HIGH )
You can’t perform that action at this time.
0 commit comments