#include <stdio.h>
#include "upm_utilities.h"
int main(void) {
float pressure;
float temp;
while(1){
printf("Retrieved pressure: %f %d\n", pressure, dev->unit);
printf("Retieved temperature: %f C\n", temp);
upm_delay_ms(500);
}
return 0;
}
Go to the source code of this file.
◆ rsc_init()
rsc_context rsc_init |
( |
uint8_t |
bus, |
|
|
uint8_t |
cs_ee_pin, |
|
|
uint8_t |
cs_adc_pin |
|
) |
| |
RSC initialization.
This device supports SPI. The sensor has two chip select pins since there are two ways to access content on the sensor - EEPROM/ADC. We will not be using the SPI CS here because that would work for all SPI operations. Hence, you are expected to initialize any 2 gpio pins for CS by providing the pin numbers.
- Parameters
-
bus | SPI bus to use. |
cs_ee_pin | The CS pin for accessing the EEPROM |
cs_adc_pin | The CS pin for accessing the ADC |
- Returns
- The device context, or NULL if an error occurred.
◆ rsc_close()
RSC Close function
- Parameters
-
◆ rsc_get_sensor_name()
upm_result_t rsc_get_sensor_name |
( |
rsc_context |
dev, |
|
|
uint8_t * |
sensor_name |
|
) |
| |
This function fills up a character array provided to it with the sensor name that it reads from the EEPROM. NOTE: The length of the array will always have to be RSC_SENSOR_NAME_LEN
- Parameters
-
dev | The device context |
sensor_name | Pointer to a uint8_t array with length RSC_SENSOR_NAME_LEN. This array will be filled up with the sensor name read from the EEPROM. |
- Returns
- UPM result.
◆ rsc_get_sensor_serial_number()
upm_result_t rsc_get_sensor_serial_number |
( |
rsc_context |
dev, |
|
|
uint8_t * |
rsc_number |
|
) |
| |
This function fills up a character array provided to it with the sensor serial number that it reads from the EEPROM. NOTE: The length of the array will always have to be RSC_SENSOR_NUMBER_LEN
- Parameters
-
dev | The device context |
sensor_name | Pointer to a uint8_t array with length RSC_SENSOR_NUMBER_LEN. This array will be filled up with the serial number |
- Returns
- UPM result.
◆ rsc_get_pressure_range()
This function reads the EEPROM to retrieve the pressure range for the particular RSC device.
- Parameters
-
- Returns
- Sensor pressure range in float
◆ rsc_get_minimum_pressure()
This function reads the EEPROM to retrieve the minimum pressure that the sensor can read.
- Parameters
-
- Returns
- Minimum pressure sensor can read in float
◆ rsc_get_pressure_unit()
This function reads the EEPROM to retrieve the pressure units that the pressure is read in
- Parameters
-
- Returns
- enum PRESSURE_U
◆ rsc_get_pressure_type()
This function reads the EEPROM to retrieve the sensor pressure type
- Parameters
-
- Returns
- enum PRESSURE_T
◆ rsc_get_initial_adc_values()
upm_result_t rsc_get_initial_adc_values |
( |
rsc_context |
dev, |
|
|
uint8_t * |
adc_init_values |
|
) |
| |
This function reads the EEPROM to extract the values with which the ADC has to be initialized. NOTE: The length of the array will always be 4
- Parameters
-
dev | The device context |
adc_init_values | uint8_t pointer to an array containing the initial values for the ADC |
- Returns
- UPM result.
◆ rsc_retrieve_coefficients()
upm_result_t rsc_retrieve_coefficients |
( |
rsc_context |
dev | ) |
|
This function is used to retrieve the coefficients from the EEPROM. Once retrieved, the function updates a 2 dimensional array in the sensor context with the latest values. This function doesn't return the coefficient values.
- Parameters
-
- Returns
- UPM result.
◆ rsc_setup_adc()
upm_result_t rsc_setup_adc |
( |
rsc_context |
dev, |
|
|
uint8_t * |
adc_init_values |
|
) |
| |
This function sets up the initial values in the ADC and also sets is to a default data rate - normal with 20 samples per second
- Parameters
-
- Returns
- UPM result.
◆ rsc_get_temperature()
Function to get the compensated temperature as read by the sensor.
- Parameters
-
- Returns
- float temperature in degree Celsius
◆ rsc_get_pressure()
Function to get the compensated pressure as read by the sensor.
- Parameters
-
- Returns
- float pressure (units inH2O)
◆ rsc_set_mode()
upm_result_t rsc_set_mode |
( |
rsc_context |
dev, |
|
|
RSC_MODE |
mode |
|
) |
| |
Function to set the mode of the sensor.
- Parameters
-
dev | The device context |
mode | mode of the sensor |
- Returns
- UPM result.
◆ rsc_set_data_rate()
upm_result_t rsc_set_data_rate |
( |
rsc_context |
dev, |
|
|
RSC_DATA_RATE |
dr |
|
) |
| |
Function to set the data rate of the sensor.
- Parameters
-
dev | The device context |
dr | data rate of the sensor |
- Returns
- UPM result.
◆ rsc_context