LibDriver CS1237
Loading...
Searching...
No Matches
cs1237 basic driver function

cs1237 basic driver modules More...

Collaboration diagram for cs1237 basic driver function:

Data Structures

struct  cs1237_handle_s
 cs1237 handle structure definition More...
struct  cs1237_info_s
 cs1237 information structure definition More...

Macros

#define CS1237_COMMAND_DATA_DELAY   5
 cs1237 command data delay definition

Typedefs

typedef struct cs1237_handle_s cs1237_handle_t
 cs1237 handle structure definition
typedef struct cs1237_info_s cs1237_info_t
 cs1237 information structure definition

Enumerations

enum  cs1237_bool_t { CS1237_BOOL_FALSE = 0x00 , CS1237_BOOL_TRUE = 0x01 }
 cs1237 bool enumeration definition More...
enum  cs1237_adc_rate_t { CS1237_ADC_RATE_10HZ = 0x00 , CS1237_ADC_RATE_40HZ = 0x01 , CS1237_ADC_RATE_640HZ = 0x02 , CS1237_ADC_RATE_1280HZ = 0x03 }
 cs1237 adc rate enumeration definition More...
enum  cs1237_pga_t { CS1237_PGA_1 = 0x00 , CS1237_PGA_2 = 0x01 , CS1237_PGA_64 = 0x02 , CS1237_PGA_128 = 0x03 }
 cs1237 pga enumeration definition More...
enum  cs1237_channel_t { CS1237_CHANNEL_A = 0x00 , CS1237_CHANNEL_TEMPERATURE = 0x02 , CS1237_CHANNEL_SHORT_CIRCUIT = 0x03 }
 cs1237 channel enumeration definition More...

Functions

uint8_t cs1237_info (cs1237_info_t *info)
 get chip's information
uint8_t cs1237_set_reference_voltage (cs1237_handle_t *handle, float volt)
 set reference voltage
uint8_t cs1237_get_reference_voltage (cs1237_handle_t *handle, float *volt)
 get reference voltage
uint8_t cs1237_set_temperature_calibration_point (cs1237_handle_t *handle, int32_t temperature_raw, float temperature_deg)
 set temperature calibration point
uint8_t cs1237_get_temperature_calibration_point (cs1237_handle_t *handle, int32_t *temperature_raw, float *temperature_deg)
 get temperature calibration point
uint8_t cs1237_init (cs1237_handle_t *handle)
 initialize the chip
uint8_t cs1237_deinit (cs1237_handle_t *handle)
 close the chip
uint8_t cs1237_read (cs1237_handle_t *handle, int32_t *raw, double *mv)
 read voltage
uint8_t cs1237_read_temperature (cs1237_handle_t *handle, int32_t *raw, float *degrees)
 read temperature
uint8_t cs1237_wake_up (cs1237_handle_t *handle)
 wake up
uint8_t cs1237_power_down (cs1237_handle_t *handle)
 power down
uint8_t cs1237_set_reference_voltage_output (cs1237_handle_t *handle, cs1237_bool_t enable)
 enable or disable reference voltage output
uint8_t cs1237_get_reference_voltage_output (cs1237_handle_t *handle, cs1237_bool_t *enable)
 get reference voltage output status
uint8_t cs1237_set_adc_rate (cs1237_handle_t *handle, cs1237_adc_rate_t rate)
 set adc rate
uint8_t cs1237_get_adc_rate (cs1237_handle_t *handle, cs1237_adc_rate_t *rate)
 get adc rate
uint8_t cs1237_set_pga (cs1237_handle_t *handle, cs1237_pga_t pga)
 set adc pga
uint8_t cs1237_get_pga (cs1237_handle_t *handle, cs1237_pga_t *pga)
 get adc pga
uint8_t cs1237_set_channel (cs1237_handle_t *handle, cs1237_channel_t channel)
 set adc channel
uint8_t cs1237_get_channel (cs1237_handle_t *handle, cs1237_channel_t *channel)
 get adc channel

Detailed Description

cs1237 basic driver modules

Macro Definition Documentation

◆ CS1237_COMMAND_DATA_DELAY

#define CS1237_COMMAND_DATA_DELAY   5

cs1237 command data delay definition

5us

Definition at line 63 of file driver_cs1237.h.

Typedef Documentation

◆ cs1237_handle_t

cs1237 handle structure definition

◆ cs1237_info_t

typedef struct cs1237_info_s cs1237_info_t

cs1237 information structure definition

Enumeration Type Documentation

◆ cs1237_adc_rate_t

cs1237 adc rate enumeration definition

Enumerator
CS1237_ADC_RATE_10HZ 

10hz

CS1237_ADC_RATE_40HZ 

40hz

CS1237_ADC_RATE_640HZ 

640hz

CS1237_ADC_RATE_1280HZ 

1280hz

Definition at line 78 of file driver_cs1237.h.

◆ cs1237_bool_t

cs1237 bool enumeration definition

Enumerator
CS1237_BOOL_FALSE 

false

CS1237_BOOL_TRUE 

true

Definition at line 69 of file driver_cs1237.h.

◆ cs1237_channel_t

cs1237 channel enumeration definition

Enumerator
CS1237_CHANNEL_A 

channel a

CS1237_CHANNEL_TEMPERATURE 

channel temperature

CS1237_CHANNEL_SHORT_CIRCUIT 

channel short circuit

Definition at line 100 of file driver_cs1237.h.

◆ cs1237_pga_t

cs1237 pga enumeration definition

Enumerator
CS1237_PGA_1 

1

CS1237_PGA_2 

2

CS1237_PGA_64 

64

CS1237_PGA_128 

128

Definition at line 89 of file driver_cs1237.h.

Function Documentation

◆ cs1237_deinit()

uint8_t cs1237_deinit ( cs1237_handle_t * handle)

close the chip

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

Definition at line 1305 of file driver_cs1237.c.

◆ cs1237_get_adc_rate()

uint8_t cs1237_get_adc_rate ( cs1237_handle_t * handle,
cs1237_adc_rate_t * rate )

get adc rate

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

Definition at line 773 of file driver_cs1237.c.

◆ cs1237_get_channel()

uint8_t cs1237_get_channel ( cs1237_handle_t * handle,
cs1237_channel_t * channel )

get adc channel

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

Definition at line 972 of file driver_cs1237.c.

◆ cs1237_get_pga()

uint8_t cs1237_get_pga ( cs1237_handle_t * handle,
cs1237_pga_t * pga )

get adc pga

Parameters
[in]*handlepointer to a cs1237 handle structure
[out]*pgapointer to an adc 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 866 of file driver_cs1237.c.

◆ cs1237_get_reference_voltage()

uint8_t cs1237_get_reference_voltage ( cs1237_handle_t * handle,
float * volt )

get reference voltage

Parameters
[in]*handlepointer to a cs1237 handle structure
[out]*voltpointer to a reference voltage buffer
Returns
status code
  • 0 success
  • 2 handle is NULL
Note
none

Definition at line 587 of file driver_cs1237.c.

◆ cs1237_get_reference_voltage_output()

uint8_t cs1237_get_reference_voltage_output ( cs1237_handle_t * handle,
cs1237_bool_t * enable )

get reference voltage output status

Parameters
[in]*handlepointer to a cs1237 handle structure
[out]*enablepointer to a bool value buffer
Returns
status code
  • 0 success
  • 1 get reference voltage output failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 697 of file driver_cs1237.c.

◆ cs1237_get_temperature_calibration_point()

uint8_t cs1237_get_temperature_calibration_point ( cs1237_handle_t * handle,
int32_t * temperature_raw,
float * temperature_deg )

get temperature calibration point

Parameters
[in]*handlepointer to a cs1237 handle structure
[out]*temperature_rawpointer to a temperature raw value buffer
[out]*temperature_degpointer to a temperature degrees buffer
Returns
status code
  • 0 success
  • 2 handle is NULL
Note
none

Definition at line 632 of file driver_cs1237.c.

◆ cs1237_info()

uint8_t cs1237_info ( cs1237_info_t * info)

get chip's information

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

Definition at line 1453 of file driver_cs1237.c.

◆ cs1237_init()

uint8_t cs1237_init ( cs1237_handle_t * handle)

initialize the chip

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

Definition at line 1186 of file driver_cs1237.c.

◆ cs1237_power_down()

uint8_t cs1237_power_down ( cs1237_handle_t * handle)

power down

Parameters
[in]*handlepointer to a cs1237 handle structure
Returns
status code
  • 0 success
  • 1 power down failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 1019 of file driver_cs1237.c.

◆ cs1237_read()

uint8_t cs1237_read ( cs1237_handle_t * handle,
int32_t * raw,
double * mv )

read voltage

Parameters
[in]*handlepointer to a cs1237 handle structure
[out]*rawpointer to a raw buffer
[out]*mvpointer to a mv buffer
Returns
status code
  • 0 success
  • 1 read failed
  • 2 handle is NULL
  • 3 handle is not initialized
  • 4 can't be temperature channel
Note
none

Definition at line 1086 of file driver_cs1237.c.

◆ cs1237_read_temperature()

uint8_t cs1237_read_temperature ( cs1237_handle_t * handle,
int32_t * raw,
float * degrees )

read temperature

Parameters
[in]*handlepointer to a cs1237 handle structure
[out]*rawpointer to a raw buffer
[out]*degreespointer to a degrees buffer
Returns
status code
  • 0 success
  • 1 read temperature failed
  • 2 handle is NULL
  • 3 handle is not initialized
  • 4 not temperature channel
  • 5 pga must be 1
  • 6 temperature raw can't be 0
Note
none

Definition at line 1133 of file driver_cs1237.c.

◆ cs1237_set_adc_rate()

uint8_t cs1237_set_adc_rate ( cs1237_handle_t * handle,
cs1237_adc_rate_t rate )

set adc rate

Parameters
[in]*handlepointer to a cs1237 handle structure
[in]rateadc rate
Returns
status code
  • 0 success
  • 1 set adc rate failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 732 of file driver_cs1237.c.

◆ cs1237_set_channel()

uint8_t cs1237_set_channel ( cs1237_handle_t * handle,
cs1237_channel_t channel )

set adc channel

Parameters
[in]*handlepointer to a cs1237 handle structure
[in]channeladc channel
Returns
status code
  • 0 success
  • 1 set channel failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 918 of file driver_cs1237.c.

◆ cs1237_set_pga()

uint8_t cs1237_set_pga ( cs1237_handle_t * handle,
cs1237_pga_t pga )

set adc pga

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

Definition at line 808 of file driver_cs1237.c.

◆ cs1237_set_reference_voltage()

uint8_t cs1237_set_reference_voltage ( cs1237_handle_t * handle,
float volt )

set reference voltage

Parameters
[in]*handlepointer to a cs1237 handle structure
[in]voltreference voltage
Returns
status code
  • 0 success
  • 2 handle is NULL
Note
none

Definition at line 566 of file driver_cs1237.c.

◆ cs1237_set_reference_voltage_output()

uint8_t cs1237_set_reference_voltage_output ( cs1237_handle_t * handle,
cs1237_bool_t enable )

enable or disable reference voltage output

Parameters
[in]*handlepointer to a cs1237 handle structure
[in]enablebool value
Returns
status code
  • 0 success
  • 1 set reference voltage output failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 656 of file driver_cs1237.c.

◆ cs1237_set_temperature_calibration_point()

uint8_t cs1237_set_temperature_calibration_point ( cs1237_handle_t * handle,
int32_t temperature_raw,
float temperature_deg )

set temperature calibration point

Parameters
[in]*handlepointer to a cs1237 handle structure
[in]temperature_rawtemperature raw value
[in]temperature_degtemperature degrees
Returns
status code
  • 0 success
  • 2 handle is NULL
Note
none

Definition at line 609 of file driver_cs1237.c.

◆ cs1237_wake_up()

uint8_t cs1237_wake_up ( cs1237_handle_t * handle)

wake up

Parameters
[in]*handlepointer to a cs1237 handle structure
Returns
status code
  • 0 success
  • 1 wake up failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 1051 of file driver_cs1237.c.