LibDriver SPS30  1.0.0
SPS30 full-featured driver
sps30 basic driver function

sps30 basic driver modules More...

Data Structures

struct  sps30_handle_s
 sps30 handle structure definition More...
 
struct  sps30_pm_s
 sps30 pm structure definition More...
 
struct  sps30_info_s
 sps30 information structure definition More...
 

Typedefs

typedef struct sps30_handle_s sps30_handle_t
 sps30 handle structure definition More...
 
typedef struct sps30_pm_s sps30_pm_t
 sps30 pm structure definition More...
 
typedef struct sps30_info_s sps30_info_t
 sps30 information structure definition More...
 

Enumerations

enum  sps30_interface_t { SPS30_INTERFACE_IIC = 0x00 , SPS30_INTERFACE_UART = 0x01 }
 sps30 interface enumeration definition More...
 
enum  sps30_format_t { SPS30_FORMAT_IEEE754 = 0x03 , SPS30_FORMAT_UINT16 = 0x05 }
 sps30 format enumeration definition More...
 
enum  sps30_data_ready_flag_t { SPS30_DATA_READY_FLAG_NOT_READY = 0x00 , SPS30_DATA_READY_FLAG_AVAILABLE = 0x01 }
 sps30 data ready flag enumeration definition More...
 
enum  sps30_status_t { SPS30_STATUS_FAN_SPEED_ERROR = (1 << 21) , SPS30_STATUS_LASER_ERROR = (1 << 5) , SPS30_STATUS_FAN_ERROR = (1 << 4) }
 sps30 status enumeration definition More...
 

Functions

uint8_t sps30_info (sps30_info_t *info)
 get chip information More...
 
uint8_t sps30_set_interface (sps30_handle_t *handle, sps30_interface_t interface)
 set the chip interface More...
 
uint8_t sps30_get_interface (sps30_handle_t *handle, sps30_interface_t *interface)
 get the chip interface More...
 
uint8_t sps30_init (sps30_handle_t *handle)
 initialize the chip More...
 
uint8_t sps30_deinit (sps30_handle_t *handle)
 close the chip More...
 
uint8_t sps30_read (sps30_handle_t *handle, sps30_pm_t *pm)
 read the result More...
 
uint8_t sps30_sleep (sps30_handle_t *handle)
 enter the sleep mode More...
 
uint8_t sps30_reset (sps30_handle_t *handle)
 reset the chip More...
 
uint8_t sps30_wake_up (sps30_handle_t *handle)
 wake up the chip More...
 
uint8_t sps30_start_measurement (sps30_handle_t *handle, sps30_format_t format)
 start the measurement More...
 
uint8_t sps30_stop_measurement (sps30_handle_t *handle)
 stop the measurement More...
 
uint8_t sps30_read_data_flag (sps30_handle_t *handle, sps30_data_ready_flag_t *flag)
 read the data read flag More...
 
uint8_t sps30_start_fan_cleaning (sps30_handle_t *handle)
 start the fan cleaning More...
 
uint8_t sps30_set_auto_cleaning_interval (sps30_handle_t *handle, uint32_t second)
 set the auto cleaning interval More...
 
uint8_t sps30_get_auto_cleaning_interval (sps30_handle_t *handle, uint32_t *second)
 get the auto cleaning interval More...
 
uint8_t sps30_disable_auto_cleaning_interval (sps30_handle_t *handle)
 disable the auto cleaning interval More...
 
uint8_t sps30_get_product_type (sps30_handle_t *handle, char type[9])
 get the product type More...
 
uint8_t sps30_get_serial_number (sps30_handle_t *handle, char sn[17])
 get the serial number More...
 
uint8_t sps30_get_version (sps30_handle_t *handle, uint8_t *major, uint8_t *minor)
 get the version More...
 
uint8_t sps30_get_device_status (sps30_handle_t *handle, uint32_t *status)
 get the device status More...
 
uint8_t sps30_clear_device_status (sps30_handle_t *handle)
 clear the device status More...
 

Detailed Description

sps30 basic driver modules

Typedef Documentation

◆ sps30_handle_t

sps30 handle structure definition

◆ sps30_info_t

typedef struct sps30_info_s sps30_info_t

sps30 information structure definition

◆ sps30_pm_t

typedef struct sps30_pm_s sps30_pm_t

sps30 pm structure definition

Enumeration Type Documentation

◆ sps30_data_ready_flag_t

sps30 data ready flag enumeration definition

Enumerator
SPS30_DATA_READY_FLAG_NOT_READY 

no new measurements available

SPS30_DATA_READY_FLAG_AVAILABLE 

new measurements ready to read

Definition at line 80 of file driver_sps30.h.

◆ sps30_format_t

sps30 format enumeration definition

Enumerator
SPS30_FORMAT_IEEE754 

big endian IEEE754 float values

SPS30_FORMAT_UINT16 

big endian unsigned 16 bit integer values

Definition at line 71 of file driver_sps30.h.

◆ sps30_interface_t

sps30 interface enumeration definition

Enumerator
SPS30_INTERFACE_IIC 

iic interface

SPS30_INTERFACE_UART 

uart interface

Definition at line 62 of file driver_sps30.h.

◆ sps30_status_t

sps30 status enumeration definition

Enumerator
SPS30_STATUS_FAN_SPEED_ERROR 

fan speed is too high or too low

SPS30_STATUS_LASER_ERROR 

laser is switched on and current is out of range

SPS30_STATUS_FAN_ERROR 

fan is switched on but the measured fan speed is 0 rpm

Definition at line 89 of file driver_sps30.h.

Function Documentation

◆ sps30_clear_device_status()

uint8_t sps30_clear_device_status ( sps30_handle_t handle)

clear the device status

Parameters
[in]*handlepointer to an sps30 handle structure
Returns
status code
  • 0 success
  • 1 clear device status failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 1541 of file driver_sps30.c.

◆ sps30_deinit()

uint8_t sps30_deinit ( sps30_handle_t handle)

close the chip

Parameters
[in]*handlepointer to an sps30 handle structure
Returns
status code
  • 0 success
  • 1 iic or uart deinit failed
  • 2 handle is NULL
  • 3 handle is not initialized
  • 4 soft reset failed
Note
none

Definition at line 2085 of file driver_sps30.c.

◆ sps30_disable_auto_cleaning_interval()

uint8_t sps30_disable_auto_cleaning_interval ( sps30_handle_t handle)

disable the auto cleaning interval

Parameters
[in]*handlepointer to an sps30 handle structure
Returns
status code
  • 0 success
  • 1 disable auto cleaning interval failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 1105 of file driver_sps30.c.

◆ sps30_get_auto_cleaning_interval()

uint8_t sps30_get_auto_cleaning_interval ( sps30_handle_t handle,
uint32_t *  second 
)

get the auto cleaning interval

Parameters
[in]*handlepointer to an sps30 handle structure
[out]*secondpointer to an interval buffer
Returns
status code
  • 0 success
  • 1 get auto cleaning interval failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 1017 of file driver_sps30.c.

◆ sps30_get_device_status()

uint8_t sps30_get_device_status ( sps30_handle_t handle,
uint32_t *  status 
)

get the device status

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

Definition at line 1453 of file driver_sps30.c.

◆ sps30_get_interface()

uint8_t sps30_get_interface ( sps30_handle_t handle,
sps30_interface_t interface 
)

get the chip interface

Parameters
[in]*handlepointer to an sps30 handle structure
[out]*interfacepointer to a chip interface buffer
Returns
status code
  • 0 success
  • 2 handle is NULL
Note
none

Definition at line 500 of file driver_sps30.c.

◆ sps30_get_product_type()

uint8_t sps30_get_product_type ( sps30_handle_t handle,
char  type[9] 
)

get the product type

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

Definition at line 1190 of file driver_sps30.c.

◆ sps30_get_serial_number()

uint8_t sps30_get_serial_number ( sps30_handle_t handle,
char  sn[17] 
)

get the serial number

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

Definition at line 1281 of file driver_sps30.c.

◆ sps30_get_version()

uint8_t sps30_get_version ( sps30_handle_t handle,
uint8_t *  major,
uint8_t *  minor 
)

get the version

Parameters
[in]*handlepointer to an sps30 handle structure
[out]*majorpointer to a major buffer
[out]*minorpointer to a minor buffer
Returns
status code
  • 0 success
  • 1 get version failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 1373 of file driver_sps30.c.

◆ sps30_info()

uint8_t sps30_info ( sps30_info_t info)

get chip information

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

Definition at line 2272 of file driver_sps30.c.

◆ sps30_init()

uint8_t sps30_init ( sps30_handle_t handle)

initialize the chip

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

Definition at line 1939 of file driver_sps30.c.

◆ sps30_read()

uint8_t sps30_read ( sps30_handle_t handle,
sps30_pm_t pm 
)

read the result

Parameters
[in]*handlepointer to an sps30 handle structure
[out]*pmpointer to an sps30 pm structure
Returns
status code
  • 0 success
  • 1 read failed
  • 2 handle is NULL
  • 3 handle is not initialized
  • 4 mode is invalid
Note
none

Definition at line 1678 of file driver_sps30.c.

◆ sps30_read_data_flag()

uint8_t sps30_read_data_flag ( sps30_handle_t handle,
sps30_data_ready_flag_t flag 
)

read the data read flag

Parameters
[in]*handlepointer to an sps30 handle structure
[out]*flagpointer to a data ready flag buffer
Returns
status code
  • 0 success
  • 1 read data read flag failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 667 of file driver_sps30.c.

◆ sps30_reset()

uint8_t sps30_reset ( sps30_handle_t handle)

reset the chip

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

Definition at line 1609 of file driver_sps30.c.

◆ sps30_set_auto_cleaning_interval()

uint8_t sps30_set_auto_cleaning_interval ( sps30_handle_t handle,
uint32_t  second 
)

set the auto cleaning interval

Parameters
[in]*handlepointer to an sps30 handle structure
[in]secondinterval
Returns
status code
  • 0 success
  • 1 set auto cleaning interval failed
  • 2 handle is NULL
  • 3 handle is not initialized
  • 4 second is invalid
Note
10 <= second <= 604800

Definition at line 929 of file driver_sps30.c.

◆ sps30_set_interface()

uint8_t sps30_set_interface ( sps30_handle_t handle,
sps30_interface_t  interface 
)

set the chip interface

Parameters
[in]*handlepointer to an sps30 handle structure
[in]interfacechip interface
Returns
status code
  • 0 success
  • 2 handle is NULL
Note
none

Definition at line 479 of file driver_sps30.c.

◆ sps30_sleep()

uint8_t sps30_sleep ( sps30_handle_t handle)

enter the sleep mode

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

Definition at line 720 of file driver_sps30.c.

◆ sps30_start_fan_cleaning()

uint8_t sps30_start_fan_cleaning ( sps30_handle_t handle)

start the fan cleaning

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

Definition at line 860 of file driver_sps30.c.

◆ sps30_start_measurement()

uint8_t sps30_start_measurement ( sps30_handle_t handle,
sps30_format_t  format 
)

start the measurement

Parameters
[in]*handlepointer to an sps30 handle structure
[in]formatdata format
Returns
status code
  • 0 success
  • 1 start measurement failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 523 of file driver_sps30.c.

◆ sps30_stop_measurement()

uint8_t sps30_stop_measurement ( sps30_handle_t handle)

stop the measurement

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

Definition at line 599 of file driver_sps30.c.

◆ sps30_wake_up()

uint8_t sps30_wake_up ( sps30_handle_t handle)

wake up the chip

Parameters
[in]*handlepointer to an sps30 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 787 of file driver_sps30.c.