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

Function pin_pic_init

components/drivers/pin/dev_pin_dm.c:377–417  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

375}
376
377rt_err_t pin_pic_init(struct rt_device_pin *gpio, int pin_irq)
378{
379 rt_err_t err;
380
381 if (gpio)
382 {
383 struct rt_pin_irqchip *irqchip = &gpio->irqchip;
384 struct rt_pic *pic = &irqchip->parent;
385
386 irqchip->irq = pin_irq;
387
388 if (!gpio->pin_nr)
389 {
390 return -RT_EINVAL;
391 }
392
393 gpio->legacy_isr = rt_calloc(gpio->pin_nr, sizeof(*gpio->legacy_isr));
394
395 if (!gpio->legacy_isr)
396 {
397 return -RT_ENOMEM;
398 }
399
400 pic->priv_data = gpio;
401 pic->ops = &pin_dm_ops;
402 /* Make sure the type of gpio for pic */
403 gpio->parent.parent.type = RT_Object_Class_Device;
404 rt_pic_default_name(&irqchip->parent);
405
406 err = rt_pic_linear_irq(pic, gpio->pin_nr);
407 rt_pic_user_extends(pic);
408
409 err = RT_EOK;
410 }
411 else
412 {
413 err = -RT_EINVAL;
414 }
415
416 return err;
417}
418
419rt_ssize_t rt_pin_get_named_pin(struct rt_device *dev, const char *propname, int index,
420 rt_uint8_t *out_mode, rt_uint8_t *out_value)

Callers

nothing calls this directly

Calls 4

rt_callocFunction · 0.85
rt_pic_default_nameFunction · 0.85
rt_pic_linear_irqFunction · 0.85
rt_pic_user_extendsFunction · 0.85

Tested by

no test coverage detected