|
monoZ docs
|
This is an example application for i2c. User can use this app for i2c protocol specific requirements. More...
#include "MZ_sys_cmsis_os2.h"#include "MZ_i2c_example.h"#include "MZ_timer.h"#include "MZ_print.h"#include "MZ_i2c1_instance.h"#include "MZ_error_handler.h"#include "MZ_i2c.h"#include <stdio.h>#include <math.h>#include <stdlib.h>#include "stm32l4xx_hal_i2c.h"Go to the source code of this file.
Macros | |
| #define | I2C_APP_STACK_SIZE (1024) |
| #define | I2C_TX_TIME (pdMS_TO_TICKS(60000)) |
| #define | I2C_TX_SIZE (10) |
| #define | RESP_BUF_LEN 10 |
| #define | SI_SENSOR_BUF_LEN 50 |
Functions | |
| static void | timer_cb (TimerHandle_t xTimer) |
| Timer callback function for transmission of the data. More... | |
| static void | i2c_app (void *arg) |
| create the timer and starts if main RTOS scheduler started More... | |
| mz_error_t | i2c_app_init (void) |
| mz_error_t | I2C_Write_Reg (uint8_t addr, uint8_t data) |
| Function to write into the specific register. More... | |
| mz_error_t | I2C_Read_Reg (uint8_t addr, uint32_t *buf) |
| Function to read from the specific register. More... | |
| void | reset_resp_counter () |
| Reset register. More... | |
| mz_error_t | param_table_write (uint8_t addr, uint8_t data) |
| Function to read from the specific register. More... | |
| mz_error_t | SENSOR_Config () |
| Function to config the sensor. More... | |
| mz_error_t | Sensor_cmd_data_conf (uint8_t addr, uint8_t data) |
| Function to write data for Sensor Configuration. More... | |
| void | SENSOR_Init () |
| Function Sensor Initialisation. More... | |
| mz_error_t | Sensor_ReadID (uint8_t *buf) |
| Function to read the content from ID register of SENSOR. More... | |
| SISER_RCVD | SI_Read_UV () |
| Function to read the data from SENSOR. More... | |
| int32_t | SENSOR_getUv (int32_t uv, SENSOR_Coeff_TypeDef *uk) |
| Function to Conversion of Raw Data. More... | |
| int32_t | SENSOR_calcPolyInner (int32_t input, int8_t fraction, uint16_t mag, int8_t shift) |
| Function to Conversion of Raw Data. More... | |
| int32_t | SENSOR_calcEvalPoly (int32_t x, int32_t y, uint8_t input_fraction, uint8_t output_fraction, uint8_t num_coeff, SENSOR_Coeff_TypeDef *kp) |
| Function to Conversion of Raw Data. More... | |
| void | calib_uv_index (float uv_raw_data) |
| Function to calibrate the raw data. More... | |
| uint16_t | string_copy (uint8_t *dststr, uint8_t *srcstr) |
| Function to Copy the data from source to destination. More... | |
| uint8_t | string_append (uint8_t *srcstr, uint8_t *apstr) |
| Function to append the string. More... | |
| uint16_t | Get_String_len (uint8_t *buf) |
| Function to get string length. More... | |
| void | int8buf_to_asciibuf (uint8_t *destbuf, uint8_t *srcbuf, uint16_t len) |
| Function to Conversion of Int to ascii data. More... | |
Variables | |
| static mz_thread_t | i2c_thread_id = NULL |
| static StaticTask_t | i2c_cb_mem |
| static StackType_t | i2c_stack [I2C_APP_STACK_SIZE] |
| static mz_semaphore_t | i2c_sema_id = NULL |
| static mzUint8 | loc_buf [RESP_BUF_LEN] |
| static mzUint8 | resp_buf [RESP_BUF_LEN] |
| static mzUint8 | err_code |
| static mzUint8 | write_sucess |
| static mzUint8 | localBuf1 [SI_SENSOR_BUF_LEN] |
| static mzUint8 | i2cLocBuf [SI_SENSOR_BUF_LEN] |
| static mzUint8 | locstr1 [50] |
| static mzUint8 | send_data [I2C_TX_SIZE] |
| mzUint8 | buf [10] |
| mzUint32 | uv_val |
| mzUint32 | als_val1 |
| mzUint32 | als_val2 |
| mzUint32 | als_val3 |
| SISER_RCVD | SI_resp_rcvd = SISER_NONE_RCVD |
| mzUint8 | cnt =0 |
This is an example application for i2c. User can use this app for i2c protocol specific requirements.
Definition in file MZ_i2c_example.c.
| #define I2C_APP_STACK_SIZE (1024) |
Definition at line 20 of file MZ_i2c_example.c.
| #define I2C_TX_TIME (pdMS_TO_TICKS(60000)) |
Definition at line 21 of file MZ_i2c_example.c.
| #define I2C_TX_SIZE (10) |
Definition at line 22 of file MZ_i2c_example.c.
| #define RESP_BUF_LEN 10 |
Definition at line 23 of file MZ_i2c_example.c.
| #define SI_SENSOR_BUF_LEN 50 |
Definition at line 24 of file MZ_i2c_example.c.
|
static |
Timer callback function for transmission of the data.
Definition at line 48 of file MZ_i2c_example.c.
|
static |
create the timer and starts if main RTOS scheduler started
| arg | void |
Definition at line 60 of file MZ_i2c_example.c.
| mz_error_t i2c_app_init | ( | void | ) |
Definition at line 88 of file MZ_i2c_example.c.
| mz_error_t I2C_Write_Reg | ( | uint8_t | addr, |
| uint8_t | data | ||
| ) |
Function to write into the specific register.
| addr | - address of the register |
| data | - data to be write |
| MZ_OK | or MZ_FAIL |
Definition at line 125 of file MZ_i2c_example.c.
| mz_error_t I2C_Read_Reg | ( | uint8_t | addr, |
| uint32_t * | buf | ||
| ) |
Function to read from the specific register.
| addr | - address of the register |
| buf | - buffer which receives data from the register |
| MZ_OK | or MZ_FAIL |
Definition at line 148 of file MZ_i2c_example.c.
| void reset_resp_counter | ( | void | ) |
| mz_error_t param_table_write | ( | uint8_t | addr, |
| uint8_t | data | ||
| ) |
Function to read from the specific register.
| addr | - address of the register |
| data | - buffer which receives data from the register |
| MZ_OK | or MZ_FAIL |
Definition at line 188 of file MZ_i2c_example.c.
| mz_error_t SENSOR_Config | ( | ) |
Function to config the sensor.
| None |
| MZ_OK/MZ_FAIL |
Definition at line 248 of file MZ_i2c_example.c.
| mz_error_t Sensor_cmd_data_conf | ( | uint8_t | addr, |
| uint8_t | data | ||
| ) |
Function to write data for Sensor Configuration.
| addr | - address of the register |
| data | - buffer which receives data from the register |
| MZ_OK | or MZ_FAIL |
Definition at line 341 of file MZ_i2c_example.c.
| void SENSOR_Init | ( | ) |
Function Sensor Initialisation.
| NONE |
| NONE |
Definition at line 358 of file MZ_i2c_example.c.
| mz_error_t Sensor_ReadID | ( | uint8_t * | buf | ) |
Function to read the content from ID register of SENSOR.
| buf | - buffer which receives data from the ID register |
| MZ_OK | or MZ_FAIL |
Definition at line 374 of file MZ_i2c_example.c.
| SISER_RCVD SI_Read_UV | ( | void | ) |
Function to read the data from SENSOR.
| NONE |
| SISER_VALID_RESP_RCVD | or SISER_INVALID_RESP_RCVD |
Definition at line 400 of file MZ_i2c_example.c.
| int32_t SENSOR_getUv | ( | int32_t | uv, |
| SENSOR_Coeff_TypeDef * | uk | ||
| ) |
Function to Conversion of Raw Data.
| uv | -Raw data. |
| uk | - Sensor Coefficient. |
| uvi- | Sensor Converted Data. |
Definition at line 452 of file MZ_i2c_example.c.
| int32_t SENSOR_calcPolyInner | ( | int32_t | input, |
| int8_t | fraction, | ||
| uint16_t | mag, | ||
| int8_t | shift | ||
| ) |
Function to Conversion of Raw Data.
| input | -Raw data. |
| fraction | - Sensor fraction. |
| mag | - Sensor magnitude. |
| shift | - Sensor shifted. |
| value- | Sensor data converted with polyInner. |
Definition at line 467 of file MZ_i2c_example.c.
| int32_t SENSOR_calcEvalPoly | ( | int32_t | x, |
| int32_t | y, | ||
| uint8_t | input_fraction, | ||
| uint8_t | output_fraction, | ||
| uint8_t | num_coeff, | ||
| SENSOR_Coeff_TypeDef * | kp | ||
| ) |
Function to Conversion of Raw Data.
| x | int32_t -Raw data. |
| y | int32_t - Sensor fraction. |
| input_fraction | uint8_t |
| output_fraction | uint8_t |
| num_coeff | uint8_t |
| kp | *SENSOR_Coeff_TypeDef. |
| value- | Sensor data converted with calcEvalPoly. |
Definition at line 493 of file MZ_i2c_example.c.
| void calib_uv_index | ( | float | uv_raw_data | ) |
Function to calibrate the raw data.
| uv_raw_data | float. |
| value- | None. |
Definition at line 560 of file MZ_i2c_example.c.
| uint16_t string_copy | ( | uint8_t * | dststr, |
| uint8_t * | srcstr | ||
| ) |
Function to Copy the data from source to destination.
| dststr | -destination string. |
| srcstr | -source string. |
| value- | string index. |
Definition at line 580 of file MZ_i2c_example.c.
| uint8_t string_append | ( | uint8_t * | srcstr, |
| uint8_t * | apstr | ||
| ) |
Function to append the string.
| apstr | -append string. |
| srcstr | -source string. |
| value- | string index. |
Definition at line 596 of file MZ_i2c_example.c.
| uint16_t Get_String_len | ( | uint8_t * | buf | ) |
Function to get string length.
| buf | -string. |
| len- | string length. |
Definition at line 617 of file MZ_i2c_example.c.
| void int8buf_to_asciibuf | ( | uint8_t * | destbuf, |
| uint8_t * | srcbuf, | ||
| uint16_t | len | ||
| ) |
Function to Conversion of Int to ascii data.
| destbuf | -destination string. |
| srcbuf | -source string. |
| len | -string. |
| None. |
Definition at line 633 of file MZ_i2c_example.c.
|
static |
Definition at line 26 of file MZ_i2c_example.c.
|
static |
Definition at line 27 of file MZ_i2c_example.c.
|
static |
Definition at line 28 of file MZ_i2c_example.c.
|
static |
Definition at line 29 of file MZ_i2c_example.c.
|
static |
Definition at line 30 of file MZ_i2c_example.c.
|
static |
Definition at line 31 of file MZ_i2c_example.c.
|
static |
Definition at line 32 of file MZ_i2c_example.c.
|
static |
Definition at line 33 of file MZ_i2c_example.c.
|
static |
Definition at line 34 of file MZ_i2c_example.c.
|
static |
Definition at line 35 of file MZ_i2c_example.c.
|
static |
Definition at line 36 of file MZ_i2c_example.c.
|
static |
Definition at line 37 of file MZ_i2c_example.c.
| mzUint8 buf[10] |
Definition at line 38 of file MZ_i2c_example.c.
| mzUint32 uv_val |
Definition at line 39 of file MZ_i2c_example.c.
| mzUint32 als_val1 |
Definition at line 39 of file MZ_i2c_example.c.
| mzUint32 als_val2 |
Definition at line 39 of file MZ_i2c_example.c.
| mzUint32 als_val3 |
Definition at line 39 of file MZ_i2c_example.c.
| SISER_RCVD SI_resp_rcvd = SISER_NONE_RCVD |
Definition at line 40 of file MZ_i2c_example.c.
| mzUint8 cnt =0 |
Definition at line 41 of file MZ_i2c_example.c.