This file provides the prototype declarations of PAL I2C. More...
#include "pal.h"
Go to the source code of this file.
Classes | |
struct | pal_i2c |
PAL I2C context structure. More... | |
#define | PAL_I2C_EVENT_SUCCESS (0x0000) |
Event returned when I2C master completes execution. More... | |
#define | PAL_I2C_EVENT_ERROR (0x0001) |
Event returned when I2C master operation fails. More... | |
#define | PAL_I2C_EVENT_BUSY (0x0002) |
Event returned when lower level I2C bus is busy. More... | |
typedef struct pal_i2c | pal_i2c_t |
PAL I2C context structure. More... | |
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 provides the prototype declarations of PAL 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 PAL_I2C_EVENT_BUSY (0x0002) |
Event returned when lower level I2C bus is busy.
#define PAL_I2C_EVENT_ERROR (0x0001) |
Event returned when I2C master operation fails.
#define PAL_I2C_EVENT_SUCCESS (0x0000) |
Event returned when I2C master completes execution.
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. |