MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / spi_probe

Function spi_probe

components/drivers/spi/dev_spi_bus.c:128–167  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

126}
127
128static rt_err_t spi_probe(rt_device_t dev)
129{
130 rt_err_t err;
131 struct rt_spi_bus *bus;
132 struct rt_spi_driver *driver = rt_container_of(dev->drv, struct rt_spi_driver, parent);
133 struct rt_spi_device *device = rt_container_of(dev, struct rt_spi_device, parent);
134
135 if (!device->bus)
136 {
137 return -RT_EINVAL;
138 }
139
140 err = driver->probe(device);
141
142 if (err)
143 {
144 return err;
145 }
146
147 bus = device->bus;
148
149 if (bus->cs_pins[0] >= 0)
150 {
151 device->cs_pin = bus->cs_pins[device->chip_select[0]];
152
153 rt_pin_mode(device->cs_pin, PIN_MODE_OUTPUT);
154 }
155 else
156 {
157 device->cs_pin = PIN_NONE;
158 }
159
160 /* Driver not register SPI device to system */
161 if (device->parent.type == RT_Device_Class_Unknown)
162 {
163 rt_spidev_device_init(device, rt_dm_dev_get_name(&device->parent));
164 }
165
166 return err;
167}
168
169static rt_err_t spi_remove(rt_device_t dev)
170{

Callers

nothing calls this directly

Calls 3

rt_spidev_device_initFunction · 0.85
rt_dm_dev_get_nameFunction · 0.85
rt_pin_modeFunction · 0.50

Tested by

no test coverage detected