File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed
Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -74,10 +74,13 @@ struct rt_pin_ops
7474 rt_uint32_t mode , void (* hdr )(void * args ), void * args );
7575 rt_err_t (* pin_detach_irq )(struct rt_device * device , rt_int32_t pin );
7676 rt_err_t (* pin_irq_enable )(struct rt_device * device , rt_base_t pin , rt_uint32_t enabled );
77+ rt_base_t (* pin_get )(const char * name );
7778};
7879
7980int rt_device_pin_register (const char * name , const struct rt_pin_ops * ops , void * user_data );
8081
82+ /* Get pin number by name,such as PA.0,P0.12 */
83+ rt_base_t rt_pin_get (const char * name );
8184void rt_pin_mode (rt_base_t pin , rt_base_t mode );
8285void rt_pin_write (rt_base_t pin , rt_base_t value );
8386int rt_pin_read (rt_base_t pin );
Original file line number Diff line number Diff line change @@ -151,3 +151,18 @@ int rt_pin_read(rt_base_t pin)
151151 return _hw_pin .ops -> pin_read (& _hw_pin .parent , pin );
152152}
153153FINSH_FUNCTION_EXPORT_ALIAS (rt_pin_read , pinRead , read status from hardware pin );
154+
155+ rt_base_t rt_pin_get (const char * name )
156+ {
157+ RT_ASSERT (_hw_pin .ops != RT_NULL );
158+ RT_ASSERT (name [0 ] == 'P' );
159+
160+ if (_hw_pin .ops -> pin_get == RT_NULL )
161+ {
162+ return - RT_ENOSYS ;
163+ }
164+
165+ return _hw_pin .ops -> pin_get (name );
166+ }
167+ FINSH_FUNCTION_EXPORT_ALIAS (rt_pin_get , pinGet , get pin number from hardware pin );
168+
You can’t perform that action at this time.
0 commit comments