LibDriver HCSR04
Loading...
Searching...
No Matches
hcsr04 base driver function

hcsr04 base driver modules More...

Collaboration diagram for hcsr04 base driver function:

Data Structures

struct  hcsr04_time_s
 hcsr04 time structure definition More...
struct  hcsr04_handle_s
 hcsr04 handle structure definition More...
struct  hcsr04_info_s
 hcsr04 information structure definition More...

Macros

#define HCSR04_READ_RETRY_TIMES   3
 hcsr04 read retry times definition

Typedefs

typedef struct hcsr04_time_s hcsr04_time_t
 hcsr04 time structure definition
typedef struct hcsr04_handle_s hcsr04_handle_t
 hcsr04 handle structure definition
typedef struct hcsr04_info_s hcsr04_info_t
 hcsr04 information structure definition

Functions

uint8_t hcsr04_info (hcsr04_info_t *info)
 get chip's information
uint8_t hcsr04_init (hcsr04_handle_t *handle)
 initialize the chip
uint8_t hcsr04_deinit (hcsr04_handle_t *handle)
 close the chip
uint8_t hcsr04_read (hcsr04_handle_t *handle, uint32_t *time_us, float *m)
 read the distance

Detailed Description

hcsr04 base driver modules

Macro Definition Documentation

◆ HCSR04_READ_RETRY_TIMES

#define HCSR04_READ_RETRY_TIMES   3

hcsr04 read retry times definition

retry 3 times

Definition at line 65 of file driver_hcsr04.h.

Typedef Documentation

◆ hcsr04_handle_t

hcsr04 handle structure definition

◆ hcsr04_info_t

typedef struct hcsr04_info_s hcsr04_info_t

hcsr04 information structure definition

◆ hcsr04_time_t

typedef struct hcsr04_time_s hcsr04_time_t

hcsr04 time structure definition

Function Documentation

◆ hcsr04_deinit()

uint8_t hcsr04_deinit ( hcsr04_handle_t * handle)

close the chip

Parameters
[in]*handlepointer to an hcsr04 handle structure
Returns
status code
  • 0 success
  • 1 trig or echo deinit failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 155 of file driver_hcsr04.c.

◆ hcsr04_info()

uint8_t hcsr04_info ( hcsr04_info_t * info)

get chip's information

Parameters
[out]*infopointer to an hcsr04 info structure
Returns
status code
  • 0 success
  • 2 handle is NULL
Note
none

Definition at line 325 of file driver_hcsr04.c.

◆ hcsr04_init()

uint8_t hcsr04_init ( hcsr04_handle_t * handle)

initialize the chip

Parameters
[in]*handlepointer to an hcsr04 handle structure
Returns
status code
  • 0 success
  • 1 trig or echo init failed
  • 2 handle is NULL
  • 3 linked functions is NULL
Note
none

Definition at line 62 of file driver_hcsr04.c.

◆ hcsr04_read()

uint8_t hcsr04_read ( hcsr04_handle_t * handle,
uint32_t * time_us,
float * m )

read the distance

Parameters
[in]*handlepointer to an hcsr04 handle structure
[out]*time_uspointer to a us buffer
[out]*mpointer to a distance buffer
Returns
status code
  • 0 success
  • 1 read failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 195 of file driver_hcsr04.c.