LibDriver MCP3421
Loading...
Searching...
No Matches
mcp3421 base driver function

mcp3421 base driver modules More...

Collaboration diagram for mcp3421 base driver function:

Data Structures

struct  mcp3421_handle_s
 mcp3421 handle structure definition More...
struct  mcp3421_info_s
 mcp3421 information structure definition More...

Typedefs

typedef struct mcp3421_handle_s mcp3421_handle_t
 mcp3421 handle structure definition
typedef struct mcp3421_info_s mcp3421_info_t
 mcp3421 information structure definition

Enumerations

enum  mcp3421_bit_t { MCP3421_BIT_12 = 0x00 , MCP3421_BIT_14 = 0x01 , MCP3421_BIT_16 = 0x02 , MCP3421_BIT_18 = 0x03 }
 mcp3421 bit enumeration definition More...
enum  mcp3421_pga_t { MCP3421_PGA_1 = 0x00 , MCP3421_PGA_2 = 0x01 , MCP3421_PGA_4 = 0x02 , MCP3421_PGA_8 = 0x03 }
 mcp3421 pga enumeration definition More...

Functions

uint8_t mcp3421_info (mcp3421_info_t *info)
 get chip's information
uint8_t mcp3421_init (mcp3421_handle_t *handle)
 initialize the chip
uint8_t mcp3421_deinit (mcp3421_handle_t *handle)
 close the chip
uint8_t mcp3421_single_read (mcp3421_handle_t *handle, int32_t *raw, double *v)
 read data from the chip once
uint8_t mcp3421_start_continuous_read (mcp3421_handle_t *handle)
 start the chip reading
uint8_t mcp3421_stop_continuous_read (mcp3421_handle_t *handle)
 stop the chip reading
uint8_t mcp3421_continuous_read (mcp3421_handle_t *handle, int32_t *raw, double *v)
 read data from the chip continuously
uint8_t mcp3421_set_adc_bit (mcp3421_handle_t *handle, mcp3421_bit_t adc_bit)
 set the adc bit
uint8_t mcp3421_get_adc_bit (mcp3421_handle_t *handle, mcp3421_bit_t *adc_bit)
 get the adc bit
uint8_t mcp3421_set_pga (mcp3421_handle_t *handle, mcp3421_pga_t pga)
 set the adc pga
uint8_t mcp3421_get_pga (mcp3421_handle_t *handle, mcp3421_pga_t *pga)
 get the adc pga

Detailed Description

mcp3421 base driver modules

Typedef Documentation

◆ mcp3421_handle_t

mcp3421 handle structure definition

◆ mcp3421_info_t

mcp3421 information structure definition

Enumeration Type Documentation

◆ mcp3421_bit_t

mcp3421 bit enumeration definition

Enumerator
MCP3421_BIT_12 

240 sps 12 bits

MCP3421_BIT_14 

60 sps 14 bits

MCP3421_BIT_16 

15 sps 16 bits

MCP3421_BIT_18 

3.75 sps 18 bits

Definition at line 62 of file driver_mcp3421.h.

◆ mcp3421_pga_t

mcp3421 pga enumeration definition

Enumerator
MCP3421_PGA_1 

pga 1

MCP3421_PGA_2 

pga 2

MCP3421_PGA_4 

pga 4

MCP3421_PGA_8 

pga 8

Definition at line 73 of file driver_mcp3421.h.

Function Documentation

◆ mcp3421_continuous_read()

uint8_t mcp3421_continuous_read ( mcp3421_handle_t * handle,
int32_t * raw,
double * v )

read data from the chip continuously

Parameters
[in]*handlepointer to an mcp3421 handle structure
[out]*rawpointer to a raw adc buffer
[out]*vpointer to a converted adc buffer
Returns
status code
  • 0 success
  • 1 continuous read failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
this function can be used only after run mcp3421_start_continuous_read and can be stopped by mcp3421_stop_continuous_read

Definition at line 549 of file driver_mcp3421.c.

◆ mcp3421_deinit()

uint8_t mcp3421_deinit ( mcp3421_handle_t * handle)

close the chip

Parameters
[in]*handlepointer to an mcp3421 handle structure
Returns
status code
  • 0 success
  • 1 iic deinit failed
  • 2 handle is NULL
  • 3 handle is not initialized
  • 4 power down failed
Note
none

Definition at line 174 of file driver_mcp3421.c.

◆ mcp3421_get_adc_bit()

uint8_t mcp3421_get_adc_bit ( mcp3421_handle_t * handle,
mcp3421_bit_t * adc_bit )

get the adc bit

Parameters
[in]*handlepointer to an mcp3421 handle structure
[out]*adc_bitpointer to an adc bit buffer
Returns
status code
  • 0 success
  • 1 get adc bit failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 271 of file driver_mcp3421.c.

◆ mcp3421_get_pga()

uint8_t mcp3421_get_pga ( mcp3421_handle_t * handle,
mcp3421_pga_t * pga )

get the adc pga

Parameters
[in]*handlepointer to an mcp3421 handle structure
[out]*pgapointer to a pga buffer
Returns
status code
  • 0 success
  • 1 get pga failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 353 of file driver_mcp3421.c.

◆ mcp3421_info()

uint8_t mcp3421_info ( mcp3421_info_t * info)

get chip's information

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

Definition at line 807 of file driver_mcp3421.c.

◆ mcp3421_init()

uint8_t mcp3421_init ( mcp3421_handle_t * handle)

initialize the chip

Parameters
[in]*handlepointer to an mcp3421 handle structure
Returns
status code
  • 0 success
  • 1 iic initialization failed
  • 2 handle is NULL
  • 3 linked functions is NULL
Note
none

Definition at line 111 of file driver_mcp3421.c.

◆ mcp3421_set_adc_bit()

uint8_t mcp3421_set_adc_bit ( mcp3421_handle_t * handle,
mcp3421_bit_t adc_bit )

set the adc bit

Parameters
[in]*handlepointer to an mcp3421 handle structure
[in]adc_bitset adc bit
Returns
status code
  • 0 success
  • 1 set adc bit failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 226 of file driver_mcp3421.c.

◆ mcp3421_set_pga()

uint8_t mcp3421_set_pga ( mcp3421_handle_t * handle,
mcp3421_pga_t pga )

set the adc pga

Parameters
[in]*handlepointer to an mcp3421 handle structure
[in]pgaset pga
Returns
status code
  • 0 success
  • 1 set pga failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 308 of file driver_mcp3421.c.

◆ mcp3421_single_read()

uint8_t mcp3421_single_read ( mcp3421_handle_t * handle,
int32_t * raw,
double * v )

read data from the chip once

Parameters
[in]*handlepointer to an mcp3421 handle structure
[out]*rawpointer to a raw adc buffer
[out]*vpointer to a converted adc buffer
Returns
status code
  • 0 success
  • 1 single read failed
  • 2 handle is NULL
  • 3 handle is not initialized
  • 4 read timeout
Note
none

Definition at line 392 of file driver_mcp3421.c.

◆ mcp3421_start_continuous_read()

uint8_t mcp3421_start_continuous_read ( mcp3421_handle_t * handle)

start the chip reading

Parameters
[in]*handlepointer to an mcp3421 handle structure
Returns
status code
  • 0 success
  • 1 start continuous read failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 668 of file driver_mcp3421.c.

◆ mcp3421_stop_continuous_read()

uint8_t mcp3421_stop_continuous_read ( mcp3421_handle_t * handle)

stop the chip reading

Parameters
[in]*handlepointer to an mcp3421 handle structure
Returns
status code
  • 0 success
  • 1 stop continuous read failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 713 of file driver_mcp3421.c.