LibDriver CS1238
Loading...
Searching...
No Matches
cs1238 basic driver function

cs1238 basic driver modules More...

Collaboration diagram for cs1238 basic driver function:

Data Structures

struct  cs1238_handle_s
 cs1238 handle structure definition More...
struct  cs1238_info_s
 cs1238 information structure definition More...

Macros

#define CS1238_COMMAND_DATA_DELAY   5
 cs1238 command data delay definition

Typedefs

typedef struct cs1238_handle_s cs1238_handle_t
 cs1238 handle structure definition
typedef struct cs1238_info_s cs1238_info_t
 cs1238 information structure definition

Enumerations

enum  cs1238_bool_t { CS1238_BOOL_FALSE = 0x00 , CS1238_BOOL_TRUE = 0x01 }
 cs1238 bool enumeration definition More...
enum  cs1238_adc_rate_t { CS1238_ADC_RATE_10HZ = 0x00 , CS1238_ADC_RATE_40HZ = 0x01 , CS1238_ADC_RATE_640HZ = 0x02 , CS1238_ADC_RATE_1280HZ = 0x03 }
 cs1238 adc rate enumeration definition More...
enum  cs1238_pga_t { CS1238_PGA_1 = 0x00 , CS1238_PGA_2 = 0x01 , CS1238_PGA_64 = 0x02 , CS1238_PGA_128 = 0x03 }
 cs1238 pga enumeration definition More...
enum  cs1238_channel_t { CS1238_CHANNEL_A = 0x00 , CS1238_CHANNEL_B = 0x01 , CS1238_CHANNEL_TEMPERATURE = 0x02 , CS1238_CHANNEL_SHORT_CIRCUIT = 0x03 }
 cs1238 channel enumeration definition More...

Functions

uint8_t cs1238_info (cs1238_info_t *info)
 get chip's information
uint8_t cs1238_set_reference_voltage (cs1238_handle_t *handle, float volt)
 set reference voltage
uint8_t cs1238_get_reference_voltage (cs1238_handle_t *handle, float *volt)
 get reference voltage
uint8_t cs1238_set_temperature_calibration_point (cs1238_handle_t *handle, int32_t temperature_raw, float temperature_deg)
 set temperature calibration point
uint8_t cs1238_get_temperature_calibration_point (cs1238_handle_t *handle, int32_t *temperature_raw, float *temperature_deg)
 get temperature calibration point
uint8_t cs1238_init (cs1238_handle_t *handle)
 initialize the chip
uint8_t cs1238_deinit (cs1238_handle_t *handle)
 close the chip
uint8_t cs1238_read (cs1238_handle_t *handle, int32_t *raw, double *mv)
 read voltage
uint8_t cs1238_read_temperature (cs1238_handle_t *handle, int32_t *raw, float *degrees)
 read temperature
uint8_t cs1238_wake_up (cs1238_handle_t *handle)
 wake up
uint8_t cs1238_power_down (cs1238_handle_t *handle)
 power down
uint8_t cs1238_set_reference_voltage_output (cs1238_handle_t *handle, cs1238_bool_t enable)
 enable or disable reference voltage output
uint8_t cs1238_get_reference_voltage_output (cs1238_handle_t *handle, cs1238_bool_t *enable)
 get reference voltage output status
uint8_t cs1238_set_adc_rate (cs1238_handle_t *handle, cs1238_adc_rate_t rate)
 set adc rate
uint8_t cs1238_get_adc_rate (cs1238_handle_t *handle, cs1238_adc_rate_t *rate)
 get adc rate
uint8_t cs1238_set_pga (cs1238_handle_t *handle, cs1238_pga_t pga)
 set adc pga
uint8_t cs1238_get_pga (cs1238_handle_t *handle, cs1238_pga_t *pga)
 get adc pga
uint8_t cs1238_set_channel (cs1238_handle_t *handle, cs1238_channel_t channel)
 set adc channel
uint8_t cs1238_get_channel (cs1238_handle_t *handle, cs1238_channel_t *channel)
 get adc channel

Detailed Description

cs1238 basic driver modules

Macro Definition Documentation

◆ CS1238_COMMAND_DATA_DELAY

#define CS1238_COMMAND_DATA_DELAY   5

cs1238 command data delay definition

5us

Definition at line 63 of file driver_cs1238.h.

Typedef Documentation

◆ cs1238_handle_t

cs1238 handle structure definition

◆ cs1238_info_t

typedef struct cs1238_info_s cs1238_info_t

cs1238 information structure definition

Enumeration Type Documentation

◆ cs1238_adc_rate_t

cs1238 adc rate enumeration definition

Enumerator
CS1238_ADC_RATE_10HZ 

10hz

CS1238_ADC_RATE_40HZ 

40hz

CS1238_ADC_RATE_640HZ 

640hz

CS1238_ADC_RATE_1280HZ 

1280hz

Definition at line 78 of file driver_cs1238.h.

◆ cs1238_bool_t

cs1238 bool enumeration definition

Enumerator
CS1238_BOOL_FALSE 

false

CS1238_BOOL_TRUE 

true

Definition at line 69 of file driver_cs1238.h.

◆ cs1238_channel_t

cs1238 channel enumeration definition

Enumerator
CS1238_CHANNEL_A 

channel a

CS1238_CHANNEL_B 

channel b

CS1238_CHANNEL_TEMPERATURE 

channel temperature

CS1238_CHANNEL_SHORT_CIRCUIT 

channel short circuit

Definition at line 100 of file driver_cs1238.h.

◆ cs1238_pga_t

cs1238 pga enumeration definition

Enumerator
CS1238_PGA_1 

1

CS1238_PGA_2 

2

CS1238_PGA_64 

64

CS1238_PGA_128 

128

Definition at line 89 of file driver_cs1238.h.

Function Documentation

◆ cs1238_deinit()

uint8_t cs1238_deinit ( cs1238_handle_t * handle)

close the chip

Parameters
[in]*handlepointer to a cs1238 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 1313 of file driver_cs1238.c.

◆ cs1238_get_adc_rate()

uint8_t cs1238_get_adc_rate ( cs1238_handle_t * handle,
cs1238_adc_rate_t * rate )

get adc rate

Parameters
[in]*handlepointer to a cs1238 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_cs1238.c.

◆ cs1238_get_channel()

uint8_t cs1238_get_channel ( cs1238_handle_t * handle,
cs1238_channel_t * channel )

get adc channel

Parameters
[in]*handlepointer to a cs1238 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 976 of file driver_cs1238.c.

◆ cs1238_get_pga()

uint8_t cs1238_get_pga ( cs1238_handle_t * handle,
cs1238_pga_t * pga )

get adc pga

Parameters
[in]*handlepointer to a cs1238 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_cs1238.c.

◆ cs1238_get_reference_voltage()

uint8_t cs1238_get_reference_voltage ( cs1238_handle_t * handle,
float * volt )

get reference voltage

Parameters
[in]*handlepointer to a cs1238 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_cs1238.c.

◆ cs1238_get_reference_voltage_output()

uint8_t cs1238_get_reference_voltage_output ( cs1238_handle_t * handle,
cs1238_bool_t * enable )

get reference voltage output status

Parameters
[in]*handlepointer to a cs1238 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_cs1238.c.

◆ cs1238_get_temperature_calibration_point()

uint8_t cs1238_get_temperature_calibration_point ( cs1238_handle_t * handle,
int32_t * temperature_raw,
float * temperature_deg )

get temperature calibration point

Parameters
[in]*handlepointer to a cs1238 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_cs1238.c.

◆ cs1238_info()

uint8_t cs1238_info ( cs1238_info_t * info)

get chip's information

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

Definition at line 1461 of file driver_cs1238.c.

◆ cs1238_init()

uint8_t cs1238_init ( cs1238_handle_t * handle)

initialize the chip

Parameters
[in]*handlepointer to a cs1238 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 1194 of file driver_cs1238.c.

◆ cs1238_power_down()

uint8_t cs1238_power_down ( cs1238_handle_t * handle)

power down

Parameters
[in]*handlepointer to a cs1238 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 1027 of file driver_cs1238.c.

◆ cs1238_read()

uint8_t cs1238_read ( cs1238_handle_t * handle,
int32_t * raw,
double * mv )

read voltage

Parameters
[in]*handlepointer to a cs1238 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 1094 of file driver_cs1238.c.

◆ cs1238_read_temperature()

uint8_t cs1238_read_temperature ( cs1238_handle_t * handle,
int32_t * raw,
float * degrees )

read temperature

Parameters
[in]*handlepointer to a cs1238 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 1141 of file driver_cs1238.c.

◆ cs1238_set_adc_rate()

uint8_t cs1238_set_adc_rate ( cs1238_handle_t * handle,
cs1238_adc_rate_t rate )

set adc rate

Parameters
[in]*handlepointer to a cs1238 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_cs1238.c.

◆ cs1238_set_channel()

uint8_t cs1238_set_channel ( cs1238_handle_t * handle,
cs1238_channel_t channel )

set adc channel

Parameters
[in]*handlepointer to a cs1238 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_cs1238.c.

◆ cs1238_set_pga()

uint8_t cs1238_set_pga ( cs1238_handle_t * handle,
cs1238_pga_t pga )

set adc pga

Parameters
[in]*handlepointer to a cs1238 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_cs1238.c.

◆ cs1238_set_reference_voltage()

uint8_t cs1238_set_reference_voltage ( cs1238_handle_t * handle,
float volt )

set reference voltage

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

Definition at line 566 of file driver_cs1238.c.

◆ cs1238_set_reference_voltage_output()

uint8_t cs1238_set_reference_voltage_output ( cs1238_handle_t * handle,
cs1238_bool_t enable )

enable or disable reference voltage output

Parameters
[in]*handlepointer to a cs1238 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_cs1238.c.

◆ cs1238_set_temperature_calibration_point()

uint8_t cs1238_set_temperature_calibration_point ( cs1238_handle_t * handle,
int32_t temperature_raw,
float temperature_deg )

set temperature calibration point

Parameters
[in]*handlepointer to a cs1238 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_cs1238.c.

◆ cs1238_wake_up()

uint8_t cs1238_wake_up ( cs1238_handle_t * handle)

wake up

Parameters
[in]*handlepointer to a cs1238 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 1059 of file driver_cs1238.c.