Skip to content

Commit 2460907

Browse files
committed
Merge pull request #1778 from 0xc0170/dev_hal_doxy
hal - adding doxygen documentation
2 parents 02ce61d + 709f479 commit 2460907

13 files changed

+475
-121
lines changed

hal/hal/analogin_api.h

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,39 @@
2424
extern "C" {
2525
#endif
2626

27+
/** Analogin hal structure. analogin_s is declared in the target's hal
28+
*/
2729
typedef struct analogin_s analogin_t;
2830

29-
void analogin_init (analogin_t *obj, PinName pin);
30-
float analogin_read (analogin_t *obj);
31+
/**
32+
* \defgroup hal_analogin Analogin hal functions
33+
* @{
34+
*/
35+
36+
/** Initialize the analogin peripheral
37+
*
38+
* Configures the pin used by analogin.
39+
* @param obj The analogin object to initialize
40+
* @param pin The analogin pin name
41+
*/
42+
void analogin_init(analogin_t *obj, PinName pin);
43+
44+
/** Read the input voltage, represented as a float in the range [0.0, 1.0]
45+
*
46+
* @param obj The analogin object
47+
* @return A floating value representing the current input voltage
48+
*/
49+
float analogin_read(analogin_t *obj);
50+
51+
/** Read the value from analogin pin, represented as an unsigned 16bit value
52+
*
53+
* @param obj The analogin object
54+
* @return An unsigned 16bit value representing the current input voltage
55+
*/
3156
uint16_t analogin_read_u16(analogin_t *obj);
3257

58+
/**@}*/
59+
3360
#ifdef __cplusplus
3461
}
3562
#endif

hal/hal/analogout_api.h

Lines changed: 52 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,60 @@
2424
extern "C" {
2525
#endif
2626

27+
/** Analogout hal structure. dac_s is declared in the target's hal
28+
*/
2729
typedef struct dac_s dac_t;
2830

29-
void analogout_init (dac_t *obj, PinName pin);
30-
void analogout_free (dac_t *obj);
31-
void analogout_write (dac_t *obj, float value);
32-
void analogout_write_u16(dac_t *obj, uint16_t value);
33-
float analogout_read (dac_t *obj);
34-
uint16_t analogout_read_u16 (dac_t *obj);
31+
/**
32+
* \defgroup hal_analogout Analogout hal functions
33+
* @{
34+
*/
35+
36+
/** Initialize the analogout peripheral
37+
*
38+
* Configures the pin used by analogout.
39+
* @param obj The analogout object to initialize
40+
* @param pin The analogout pin name
41+
*/
42+
void analogout_init(dac_t *obj, PinName pin);
43+
44+
/** Release the analogout object
45+
*
46+
* Note: This is not currently used in the mbed-drivers
47+
* @param obj The analogout object
48+
*/
49+
void analogout_free(dac_t *obj);
50+
51+
/** Set the output voltage, specified as a percentage (float)
52+
*
53+
* @param obj The analogin object
54+
* @param value The floating-point output voltage to be set
55+
*/
56+
void analogout_write(dac_t *obj, float value);
57+
58+
/** Set the output voltage, specified as unsigned 16-bit
59+
*
60+
* @param obj The analogin object
61+
* @param value The unsigned 16-bit output voltage to be set
62+
*/
63+
void analogout_write_u16(dac_t *obj, uint16_t value);
64+
65+
/** Read the current voltage value on the pin
66+
*
67+
* @param obj The analogin object
68+
* @return A floating-point value representing the current voltage on the pin,
69+
* measured as a percentage
70+
*/
71+
float analogout_read(dac_t *obj);
72+
73+
/** Read the current voltage value on the pin, as a normalized unsigned 16bit value
74+
*
75+
* @param obj The analogin object
76+
* @return An unsigned 16-bit value representing the current voltage on the pin
77+
*/
78+
uint16_t analogout_read_u16(dac_t *obj);
79+
80+
/**@}*/
3581

3682
#ifdef __cplusplus
3783
}

hal/hal/gpio_api.h

Lines changed: 78 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,40 +16,111 @@
1616
#ifndef MBED_GPIO_API_H
1717
#define MBED_GPIO_API_H
1818

19+
#include <stdint.h>
1920
#include "device.h"
2021

2122
#ifdef __cplusplus
2223
extern "C" {
2324
#endif
2425

25-
/* Set the given pin as GPIO
26+
/**
27+
* \defgroup hal_gpio GPIO HAL functions
28+
* @{
29+
*/
30+
31+
/** Set the given pin as GPIO
32+
*
2633
* @param pin The pin to be set as GPIO
2734
* @return The GPIO port mask for this pin
2835
**/
2936
uint32_t gpio_set(PinName pin);
30-
3137
/* Checks if gpio object is connected (pin was not initialized with NC)
3238
* @param pin The pin to be set as GPIO
3339
* @return 0 if port is initialized with NC
3440
**/
3541
int gpio_is_connected(const gpio_t *obj);
3642

37-
/* GPIO object */
43+
/** Initialize the GPIO pin
44+
*
45+
* @param obj The GPIO object to initialize
46+
* @param pin The GPIO pin to initialize
47+
*/
3848
void gpio_init(gpio_t *obj, PinName pin);
3949

40-
void gpio_mode (gpio_t *obj, PinMode mode);
41-
void gpio_dir (gpio_t *obj, PinDirection direction);
50+
/** Set the input pin mode
51+
*
52+
* @param obj The GPIO object
53+
* @param mode The pin mode to be set
54+
*/
55+
void gpio_mode(gpio_t *obj, PinMode mode);
56+
57+
/** Set the pin direction
58+
*
59+
* @param obj The GPIO object
60+
* @param direction The pin direction to be set
61+
*/
62+
void gpio_dir(gpio_t *obj, PinDirection direction);
4263

64+
/** Set the output value
65+
*
66+
* @param obj The GPIO object
67+
* @param value The value to be set
68+
*/
4369
void gpio_write(gpio_t *obj, int value);
44-
int gpio_read (gpio_t *obj);
4570

46-
// the following set of functions are generic and are implemented in the common gpio.c file
71+
/** Read the input value
72+
*
73+
* @param obj The GPIO object
74+
* @return An integer value 1 or 0
75+
*/
76+
int gpio_read(gpio_t *obj);
77+
78+
// the following functions are generic and implemented in the common gpio.c file
79+
// TODO: fix, will be moved to the common gpio header file
80+
81+
/** Init the input pin and set mode to PullDefault
82+
*
83+
* @param obj The GPIO object
84+
* @param pin The pin name
85+
*/
4786
void gpio_init_in(gpio_t* gpio, PinName pin);
87+
88+
/** Init the input pin and set the mode
89+
*
90+
* @param obj The GPIO object
91+
* @param pin The pin name
92+
* @param mode The pin mode to be set
93+
*/
4894
void gpio_init_in_ex(gpio_t* gpio, PinName pin, PinMode mode);
95+
96+
/** Init the output pin as an output, with predefined output value 0
97+
*
98+
* @param obj The GPIO object
99+
* @param pin The pin name
100+
* @return An integer value 1 or 0
101+
*/
49102
void gpio_init_out(gpio_t* gpio, PinName pin);
103+
104+
/** Init the pin as an output and set the output value
105+
*
106+
* @param obj The GPIO object
107+
* @param pin The pin name
108+
* @param value The value to be set
109+
*/
50110
void gpio_init_out_ex(gpio_t* gpio, PinName pin, int value);
111+
112+
/** Init the pin to be in/out
113+
*
114+
* @param obj The GPIO object
115+
* @param pin The pin name
116+
* @param direction The pin direction to be set
117+
* @param mode The pin mode to be set
118+
* @param value The value to be set for an output pin
119+
*/
51120
void gpio_init_inout(gpio_t* gpio, PinName pin, PinDirection direction, PinMode mode, int value);
52121

122+
/**@}*/
123+
53124
#ifdef __cplusplus
54125
}
55126
#endif

hal/hal/gpio_irq_api.h

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,65 @@
2424
extern "C" {
2525
#endif
2626

27+
/** GPIO IRQ events
28+
*/
2729
typedef enum {
2830
IRQ_NONE,
2931
IRQ_RISE,
3032
IRQ_FALL
3133
} gpio_irq_event;
3234

35+
/** GPIO IRQ HAL structure. gpio_irq_s is declared in the target's HAL
36+
*/
3337
typedef struct gpio_irq_s gpio_irq_t;
3438

3539
typedef void (*gpio_irq_handler)(uint32_t id, gpio_irq_event event);
3640

37-
int gpio_irq_init(gpio_irq_t *obj, PinName pin, gpio_irq_handler handler, uint32_t id);
41+
/**
42+
* \defgroup hal_gpioirq GPIO IRQ HAL functions
43+
* @{
44+
*/
45+
46+
/** Initialize the GPIO IRQ pin
47+
*
48+
* @param obj The GPIO object to initialize
49+
* @param pin The GPIO pin name
50+
* @param handler The handler to be attached to GPIO IRQ
51+
* @param id The object ID (id != 0, 0 is reserved)
52+
* @return -1 if pin is NC, 0 otherwise
53+
*/
54+
int gpio_irq_init(gpio_irq_t *obj, PinName pin, gpio_irq_handler handler, uint32_t id);
55+
56+
/** Release the GPIO IRQ PIN
57+
*
58+
* @param obj The gpio object
59+
*/
3860
void gpio_irq_free(gpio_irq_t *obj);
39-
void gpio_irq_set (gpio_irq_t *obj, gpio_irq_event event, uint32_t enable);
61+
62+
/** Enable/disable pin IRQ event
63+
*
64+
* @param obj The GPIO object
65+
* @param event The GPIO IRQ event
66+
* @param enable The enable flag
67+
*/
68+
void gpio_irq_set(gpio_irq_t *obj, gpio_irq_event event, uint32_t enable);
69+
70+
/** Enable GPIO IRQ
71+
*
72+
* This is target dependent, as it might enable the entire port or just a pin
73+
* @param obj The GPIO object
74+
*/
4075
void gpio_irq_enable(gpio_irq_t *obj);
76+
77+
/** Disable GPIO IRQ
78+
*
79+
* This is target dependent, as it might disable the entire port or just a pin
80+
* @param obj The GPIO object
81+
*/
4182
void gpio_irq_disable(gpio_irq_t *obj);
4283

84+
/**@}*/
85+
4386
#ifdef __cplusplus
4487
}
4588
#endif

0 commit comments

Comments
 (0)