82
82
% % Event type that will trigger a `gpio_interrupt'. STM32 only supports `rising', `falling', or `both'.
83
83
84
84
% %-----------------------------------------------------------------------------
85
- % % @returns Pid | error | {error, Reason}
85
+ % % @returns Pid | {error, Reason}
86
86
% % @doc Start the GPIO driver port
87
87
% %
88
88
% % Returns the pid of the active GPIO port driver, otherwise the GPIO
@@ -103,7 +103,7 @@ start() ->
103
103
end .
104
104
105
105
% %-----------------------------------------------------------------------------
106
- % % @returns Pid | error | {error, Reason}
106
+ % % @returns Pid | {error, Reason}
107
107
% % @doc Start the GPIO driver port
108
108
% %
109
109
% % The GPIO port driver will be stared and registered as `gpio'. If the
@@ -121,7 +121,7 @@ open() ->
121
121
122
122
% %-----------------------------------------------------------------------------
123
123
% % @param GPIO pid that was returned from gpio:start/0
124
- % % @returns ok | error | {error, Reason}
124
+ % % @returns ok | {error, Reason}
125
125
% % @doc Stop the GPIO interrupt port
126
126
% %
127
127
% % This function disables any interrupts that are set, stops
@@ -135,7 +135,7 @@ close(GPIO) ->
135
135
port :call (GPIO , {close }).
136
136
137
137
% %-----------------------------------------------------------------------------
138
- % % @returns ok | error | {error, Reason}
138
+ % % @returns ok | {error, Reason}
139
139
% % @doc Stop the GPIO interrupt port
140
140
% %
141
141
% % This function disables any interrupts that are set, stops
@@ -151,7 +151,7 @@ stop() ->
151
151
% %-----------------------------------------------------------------------------
152
152
% % @param GPIO pid that was returned from gpio:start/0
153
153
% % @param Pin number of the pin to read
154
- % % @returns high | low | error | {error, Reason}
154
+ % % @returns high | low | {error, Reason}
155
155
% % @doc Read the digital state of a GPIO pin
156
156
% %
157
157
% % Read if an input pin state is `high' or `low'.
@@ -169,7 +169,7 @@ read(GPIO, Pin) ->
169
169
% % @param GPIO pid that was returned from `gpio:start/0'
170
170
% % @param Pin number of the pin to configure
171
171
% % @param Direction is `input', `output', or `output_od'
172
- % % @returns ok | error | {error, Reason}
172
+ % % @returns ok | {error, Reason}
173
173
% % @doc Set the operational mode of a pin
174
174
% %
175
175
% % Pins can be used for input, output, or output with open drain.
@@ -199,7 +199,7 @@ set_direction(GPIO, Pin, Direction) ->
199
199
% % @param GPIO pid that was returned from `gpio:start/0'
200
200
% % @param Pin number of the pin to write
201
201
% % @param Level the desired output level to set
202
- % % @returns ok | error | {error, Reason}
202
+ % % @returns ok | {error, Reason}
203
203
% % @doc Set GPIO digital output level
204
204
% %
205
205
% % Set a pin to `high' (1) or `low' (0).
@@ -233,7 +233,7 @@ set_level(GPIO, Pin, Level) ->
233
233
% % @param GPIO pid that was returned from `gpio:start/0'
234
234
% % @param Pin number of the pin to set the interrupt on
235
235
% % @param Trigger is the state that will trigger an interrupt
236
- % % @returns ok | error | {error, Reason}
236
+ % % @returns ok | {error, Reason}
237
237
% % @doc Set a GPIO interrupt
238
238
% %
239
239
% % Available triggers are `none' (which is the same as disabling an
@@ -257,7 +257,7 @@ set_int(GPIO, Pin, Trigger) ->
257
257
% % @param Pin number of the pin to set the interrupt on
258
258
% % @param Trigger is the state that will trigger an interrupt
259
259
% % @param Pid is the process that will receive the interrupt message
260
- % % @returns ok | error | {error, Reason}
260
+ % % @returns ok | {error, Reason}
261
261
% % @doc Set a GPIO interrupt
262
262
% %
263
263
% % Available triggers are `none' (which is the same as disabling an
@@ -280,21 +280,21 @@ set_int(GPIO, Pin, Trigger, Pid) ->
280
280
% %-----------------------------------------------------------------------------
281
281
% % @param GPIO pid that was returned from `gpio:start/0'
282
282
% % @param Pin number of the pin to remove the interrupt
283
- % % @returns ok | error | {error, Reason}
283
+ % % @returns ok | {error, Reason}
284
284
% % @doc Remove a GPIO interrupt
285
285
% %
286
286
% % Removes an interrupt from the specified pin.
287
287
% %
288
288
% % The rp2040 (Pico) port does not support gpio interrupts at this time.
289
289
% % @end
290
290
% %-----------------------------------------------------------------------------
291
- -spec remove_int (GPIO :: gpio (), Pin :: pin ()) -> ok | {error , Reason :: atom ()} | error .
291
+ -spec remove_int (GPIO :: gpio (), Pin :: pin ()) -> ok | {error , Reason :: atom ()}.
292
292
remove_int (GPIO , Pin ) ->
293
293
port :call (GPIO , {remove_int , Pin }).
294
294
295
295
% %-----------------------------------------------------------------------------
296
296
% % @param Pin number to initialize
297
- % % @returns ok
297
+ % % @returns ok | raise(Error)
298
298
% % @doc Initialize a pin to be used as GPIO.
299
299
% % This is required on RP2040 and for some pins on ESP32.
300
300
% % @end
@@ -305,7 +305,7 @@ init(_Pin) ->
305
305
306
306
% %-----------------------------------------------------------------------------
307
307
% % @param Pin number to deinitialize
308
- % % @returns ok
308
+ % % @returns ok | raise(Error)
309
309
% % @doc Reset a pin back to the NULL function.
310
310
% % Currently only implemented for RP2040 (Pico).
311
311
% % @end
@@ -317,7 +317,7 @@ deinit(_Pin) ->
317
317
% %-----------------------------------------------------------------------------
318
318
% % @param Pin number to set operational mode
319
319
% % @param Direction is `input', `output', or `output_od'
320
- % % @returns ok | error | {error, Reason}
320
+ % % @returns ok | raise(Error)
321
321
% % @doc Set the operational mode of a pin
322
322
% %
323
323
% % Pins can be used for input, output, or output with open drain.
@@ -336,14 +336,14 @@ deinit(_Pin) ->
336
336
% % @end
337
337
% %-----------------------------------------------------------------------------
338
338
-spec set_pin_mode (Pin :: pin (), Direction :: direction ()) ->
339
- ok | { error , Reason :: atom ()} | error .
339
+ ok .
340
340
set_pin_mode (_Pin , _Mode ) ->
341
341
erlang :nif_error (undefined ).
342
342
343
343
% %-----------------------------------------------------------------------------
344
344
% % @param Pin number to set internal resistor direction
345
345
% % @param Pull is the internal resistor state
346
- % % @returns ok | error
346
+ % % @returns ok | raise(Error)
347
347
% % @doc Set the internal resistor of a pin
348
348
% %
349
349
% % Pins can be internally pulled `up', `down', `up_down' (pulled in
@@ -354,13 +354,13 @@ set_pin_mode(_Pin, _Mode) ->
354
354
% % or `set_pin_mode/2'.
355
355
% % @end
356
356
% %-----------------------------------------------------------------------------
357
- -spec set_pin_pull (Pin :: pin (), Pull :: pull ()) -> ok | error .
357
+ -spec set_pin_pull (Pin :: pin (), Pull :: pull ()) -> ok .
358
358
set_pin_pull (_Pin , _Pull ) ->
359
359
erlang :nif_error (undefined ).
360
360
361
361
% %-----------------------------------------------------------------------------
362
362
% % @param Pin number of the pin to be held
363
- % % @returns ok | error
363
+ % % @returns ok | raise(Error)
364
364
% % @doc Hold the state of a pin
365
365
% %
366
366
% % The gpio pad hold function works in both input and output modes,
@@ -380,13 +380,13 @@ set_pin_pull(_Pin, _Pull) ->
380
380
% % This function is only supported on ESP32.
381
381
% % @end
382
382
% %-----------------------------------------------------------------------------
383
- -spec hold_en (Pin :: pin ()) -> ok | error .
383
+ -spec hold_en (Pin :: pin ()) -> ok .
384
384
hold_en (_Pin ) ->
385
385
erlang :nif_error (undefined ).
386
386
387
387
% %-----------------------------------------------------------------------------
388
388
% % @param Pin number of the pin to be released
389
- % % @returns ok | error
389
+ % % @returns ok | raise(Error)
390
390
% % @doc Release a pin from a hold state.
391
391
% %
392
392
% % When the chip is woken up from Deep-sleep, the gpio will be set to
@@ -402,7 +402,7 @@ hold_en(_Pin) ->
402
402
% % This function is only supported on ESP32.
403
403
% % @end
404
404
% %-----------------------------------------------------------------------------
405
- -spec hold_dis (Pin :: pin ()) -> ok | error .
405
+ -spec hold_dis (Pin :: pin ()) -> ok .
406
406
hold_dis (_Pin ) ->
407
407
erlang :nif_error (undefined ).
408
408
@@ -445,7 +445,7 @@ deep_sleep_hold_dis() ->
445
445
% %-----------------------------------------------------------------------------
446
446
% % @param Pin number of the pin to write
447
447
% % @param Level the desired output level to set
448
- % % @returns ok | error | {error, Reason}
448
+ % % @returns ok | raise(Error)
449
449
% % @doc Set GPIO digital output level
450
450
% %
451
451
% % Set a pin to `high' (1) or `low' (0).
@@ -469,13 +469,13 @@ deep_sleep_hold_dis() ->
469
469
% % require or accept `set_pin_mode' or `set_pin_pull' before use.
470
470
% % @end
471
471
% %-----------------------------------------------------------------------------
472
- -spec digital_write (Pin :: pin (), Level :: level ()) -> ok | { error , Reason :: atom ()} | error .
472
+ -spec digital_write (Pin :: pin (), Level :: level ()) -> ok .
473
473
digital_write (_Pin , _Level ) ->
474
474
erlang :nif_error (undefined ).
475
475
476
476
% %-----------------------------------------------------------------------------
477
477
% % @param Pin number of the pin to read
478
- % % @returns high | low | error | {error, Reason}
478
+ % % @returns high | low | raise(Error)
479
479
% % @doc Read the digital state of a GPIO pin
480
480
% %
481
481
% % Read if an input pin state is high or low.
@@ -486,14 +486,14 @@ digital_write(_Pin, _Level) ->
486
486
% % and does not require or accept `set_pin_mode' or `set_pin_pull' before use.
487
487
% % @end
488
488
% %-----------------------------------------------------------------------------
489
- -spec digital_read (Pin :: pin ()) -> high | low | { error , Reason :: atom ()} | error .
489
+ -spec digital_read (Pin :: pin ()) -> high | low .
490
490
digital_read (_Pin ) ->
491
491
erlang :nif_error (undefined ).
492
492
493
493
% %-----------------------------------------------------------------------------
494
494
% % @param Pin number of the pin to set the interrupt on
495
495
% % @param Trigger is the state that will trigger an interrupt
496
- % % @returns ok | error | {error, Reason}
496
+ % % @returns ok | {error, Reason}
497
497
% % @doc Convenience function for `gpio:set_int/3'
498
498
% %
499
499
% % This is a convenience function for `gpio:set_int/3' that allows an
@@ -509,13 +509,13 @@ digital_read(_Pin) ->
509
509
% % @end
510
510
% %-----------------------------------------------------------------------------
511
511
-spec attach_interrupt (Pin :: pin (), Trigger :: trigger ()) ->
512
- ok | {error , Reason :: atom ()} | error .
512
+ ok | {error , Reason :: atom ()}.
513
513
attach_interrupt (Pin , Trigger ) ->
514
514
set_int (start (), Pin , Trigger ).
515
515
516
516
% -----------------------------------------------------------------------------
517
517
% % @param Pin number of the pin to remove the interrupt
518
- % % @returns ok | error | {error, Reason}
518
+ % % @returns ok | {error, Reason}
519
519
% % @doc Convenience function for `gpio:remove_int/2'
520
520
% %
521
521
% % This is a convenience function for `gpio:remove_int/2' that allows an
@@ -527,6 +527,6 @@ attach_interrupt(Pin, Trigger) ->
527
527
% % The rp2040 (Pico) port does not support gpio interrupts at this time.
528
528
% % @end
529
529
% %-----------------------------------------------------------------------------
530
- -spec detach_interrupt (Pin :: pin ()) -> ok | {error , Reason :: atom ()} | error .
530
+ -spec detach_interrupt (Pin :: pin ()) -> ok | {error , Reason :: atom ()}.
531
531
detach_interrupt (Pin ) ->
532
532
remove_int (whereis (gpio ), Pin ).
0 commit comments