This file implements the platform abstraction layer(pal) APIs for I2C. More...
#include <Arduino.h>
#include <Wire.h>
#include "pal_i2c.h"
#include "optiga_lib_config.h"
#include "optiga_lib_logger.h"
#include "optiga_lib_return_codes.h"
#define | OPTIGA_I2C_ARD_SERVICE "[optiga i2c ard] : " |
#define | OPTIGA_I2C_ARD_SERVICE_COLOR OPTIGA_LIB_LOGGER_COLOR_YELLOW |
#define | OPTIGA_I2C_ARD_LOG_MESSAGE(msg) {} |
Macro to enable logger for Util service. More... | |
#define | OPTIGA_I2C_ARD_LOG_HEX_DATA(array, array_len) {} |
#define | OPTIGA_I2C_ARD_LOG_STATUS(return_value) {} |
#define | PAL_I2C_MASTER_MAX_BITRATE (400U) |
#define | MAX_POLLING 50 |
LIBRARY_EXPORTS pal_status_t | pal_i2c_init (const pal_i2c_t *p_i2c_context) |
Initializes the I2C master. More... | |
LIBRARY_EXPORTS pal_status_t | pal_i2c_set_bitrate (const pal_i2c_t *p_i2c_context, uint16_t bitrate) |
Sets the I2C Master bitrate. More... | |
LIBRARY_EXPORTS pal_status_t | pal_i2c_write (pal_i2c_t *p_i2c_context, uint8_t *p_data, uint16_t length) |
Writes on I2C bus. More... | |
LIBRARY_EXPORTS pal_status_t | pal_i2c_read (pal_i2c_t *p_i2c_context, uint8_t *p_data, uint16_t length) |
Reads from I2C bus. More... | |
LIBRARY_EXPORTS pal_status_t | pal_i2c_deinit (const pal_i2c_t *p_i2c_context) |
De-initializes the I2C master. More... | |
This file implements the platform abstraction layer(pal) APIs for I2C.
Copyright (c) 2019 Infineon Technologies AG
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
\endcopyright
#define MAX_POLLING 50 |
#define OPTIGA_I2C_ARD_LOG_HEX_DATA | ( | array, | |
array_len | |||
) | {} |
#define OPTIGA_I2C_ARD_LOG_MESSAGE | ( | msg | ) | {} |
Macro to enable logger for Util service.
#define OPTIGA_I2C_ARD_LOG_STATUS | ( | return_value | ) | {} |
#define OPTIGA_I2C_ARD_SERVICE "[optiga i2c ard] : " |
optiga logger arduino library level
#define OPTIGA_I2C_ARD_SERVICE_COLOR OPTIGA_LIB_LOGGER_COLOR_YELLOW |
#define PAL_I2C_MASTER_MAX_BITRATE (400U) |
LIBRARY_EXPORTS pal_status_t pal_i2c_deinit | ( | const pal_i2c_t * | p_i2c_context | ) |
De-initializes the I2C master.
De-initializes the I2C master with the specified context.
[in] | p_i2c_context | Valid pointer to the PAL I2C context that should be de-initialized |
PAL_STATUS_SUCCESS | Returns when the I2C master de-init it successful |
PAL_STATUS_FAILURE | Returns when the I2C de-init fails. |
LIBRARY_EXPORTS pal_status_t pal_i2c_init | ( | const pal_i2c_t * | p_i2c_context | ) |
Initializes the I2C master.
Initializes the I2C master with the given context.
[in] | p_i2c_context | Valid pointer to the PAL I2C context that should be initialized |
PAL_STATUS_SUCCESS | Returns when the I2C master init it successful |
PAL_STATUS_FAILURE | Returns when the I2C init fails. |
LIBRARY_EXPORTS pal_status_t pal_i2c_read | ( | pal_i2c_t * | p_i2c_context, |
uint8_t * | p_data, | ||
uint16_t | length | ||
) |
Reads from I2C bus.
Reads the data from I2C slave.
[in] | p_i2c_context | pointer to the PAL I2C context pal_i2c_t |
[in] | p_data | Pointer to the data buffer to store the read data |
[in] | length | Length of the data to be read |
PAL_STATUS_SUCCESS | Returns when the I2C read is invoked successfully |
PAL_STATUS_FAILURE | Returns when the I2C read fails. |
PAL_STATUS_I2C_BUSY | Returns when the I2C bus is busy. |
LIBRARY_EXPORTS pal_status_t pal_i2c_set_bitrate | ( | const pal_i2c_t * | p_i2c_context, |
uint16_t | bitrate | ||
) |
Sets the I2C Master bitrate.
Sets the bitrate/speed(KHz) of I2C master.
[in] | p_i2c_context | Valid pointer to the PAL I2C context |
[in] | bitrate | Bitrate to be used by I2C master in KHz |
PAL_STATUS_SUCCESS | Returns when the setting of bitrate is successfully completed |
PAL_STATUS_FAILURE | Returns when the setting of bitrate fails. |
PAL_STATUS_I2C_BUSY | Returns when the I2C bus is busy. |
LIBRARY_EXPORTS pal_status_t pal_i2c_write | ( | pal_i2c_t * | p_i2c_context, |
uint8_t * | p_data, | ||
uint16_t | length | ||
) |
Writes on I2C bus.
Writes the data to I2C slave.
[in] | p_i2c_context | Valid pointer to the PAL I2C context pal_i2c_t |
[in] | p_data | Pointer to the data to be written |
[in] | length | Length of the data to be written |
PAL_STATUS_SUCCESS | Returns when the I2C write is invoked successfully |
PAL_STATUS_FAILURE | Returns when the I2C write fails. |
PAL_STATUS_I2C_BUSY | Returns when the I2C bus is busy. |