STM8S/A Standard Peripherals Drivers
|
This file contains all functions prototype and macros for the I2C peripheral. More...
#include "stm8s.h"
Go to the source code of this file.
Defines | |
#define | I2C_MAX_FAST_FREQ ((uint32_t)400000) |
#define | I2C_MAX_INPUT_FREQ ((uint8_t)16) |
#define | I2C_MAX_STANDARD_FREQ ((uint32_t)100000) |
#define | IS_I2C_ACK_OK(ACK) |
Macro used by the assert function to check the different acknowledgement configuration. | |
#define | IS_I2C_ADDMODE_OK(ADDMODE) |
Macro used by the assert function to check the different I2C addressing modes. | |
#define | IS_I2C_ADDRESS_OK(ADD) (((ADD) & (uint8_t)0x01) == (uint8_t)0x00) |
#define | IS_I2C_CLEAR_FLAG_OK(FLAG) |
Macro used by the assert function to check the I2C flags to clear. | |
#define | IS_I2C_CLEAR_ITPENDINGBIT_OK(ITPENDINGBIT) |
Macro used by the assert function to check the different I2C possible pending bits to clear by writing 0. | |
#define | IS_I2C_DIRECTION_OK(DIR) |
Macro used by the assert function to check the different I2C communcation direction. | |
#define | IS_I2C_DUTYCYCLE_OK(DUTY) |
Macro used by the assert function to check the different functions parameters. | |
#define | IS_I2C_EVENT_OK(EVENT) |
Macro used by the assert function to check the different I2C possible events. | |
#define | IS_I2C_FLAG_OK(FLAG) |
Macro used by the assert function to check the different I2C flags. | |
#define | IS_I2C_INPUT_CLOCK_FREQ_OK(FREQ) (((FREQ) >= (uint8_t)1) && ((FREQ) <= I2C_MAX_INPUT_FREQ)) |
Macro used by the assert function to check that I2C Input clock frequency must be between 1MHz and 50MHz. | |
#define | IS_I2C_INTERRUPT_OK(IT) |
Macro used by the assert function to check the different I2C interrupt types. | |
#define | IS_I2C_ITPENDINGBIT_OK(ITPENDINGBIT) |
Macro used by the assert function to check the different I2C possible pending bits. | |
#define | IS_I2C_OUTPUT_CLOCK_FREQ_OK(FREQ) (((FREQ) >= (uint8_t)1) && ((FREQ) <= I2C_MAX_FAST_FREQ)) |
Macro used by the assert function to check that I2C Output clock frequency must be between 1Hz and 400kHz. | |
#define | IS_I2C_OWN_ADDRESS_OK(ADDRESS) ((ADDRESS) <= (uint16_t)0x03FF) |
Macro used by the assert function to check the different I2C possible own address. | |
Enumerations | |
enum | I2C_Ack_TypeDef { I2C_ACK_NONE = (uint8_t)0x00, I2C_ACK_CURR = (uint8_t)0x01, I2C_ACK_NEXT = (uint8_t)0x02 } |
I2C Acknowledgement configuration. More... | |
enum | I2C_AddMode_TypeDef { I2C_ADDMODE_7BIT = (uint8_t)0x00, I2C_ADDMODE_10BIT = (uint8_t)0x80 } |
I2C Addressing Mode (slave mode only) More... | |
enum | I2C_Direction_TypeDef { I2C_DIRECTION_TX = (uint8_t)0x00, I2C_DIRECTION_RX = (uint8_t)0x01 } |
I2C transfer direction Warning: the values correspond to the ADD0 bit position in the OARL register. More... | |
enum | I2C_DutyCycle_TypeDef { I2C_DUTYCYCLE_2 = (uint8_t)0x00, I2C_DUTYCYCLE_16_9 = (uint8_t)0x40 } |
I2C duty cycle (fast mode only) More... | |
enum | I2C_Event_TypeDef { I2C_EVENT_MASTER_MODE_SELECT = (uint16_t)0x0301, I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED = (uint16_t)0x0782, I2C_EVENT_MASTER_RECEIVER_MODE_SELECTED = (uint16_t)0x0302, I2C_EVENT_MASTER_MODE_ADDRESS10 = (uint16_t)0x0308, I2C_EVENT_MASTER_BYTE_RECEIVED = (uint16_t)0x0340, I2C_EVENT_MASTER_BYTE_TRANSMITTING = (uint16_t)0x0780, I2C_EVENT_MASTER_BYTE_TRANSMITTED = (uint16_t)0x0784, I2C_EVENT_SLAVE_RECEIVER_ADDRESS_MATCHED = (uint16_t)0x0202, I2C_EVENT_SLAVE_TRANSMITTER_ADDRESS_MATCHED = (uint16_t)0x0682, I2C_EVENT_SLAVE_GENERALCALLADDRESS_MATCHED = (uint16_t)0x1200, I2C_EVENT_SLAVE_BYTE_RECEIVED = (uint16_t)0x0240, I2C_EVENT_SLAVE_STOP_DETECTED = (uint16_t)0x0010, I2C_EVENT_SLAVE_BYTE_TRANSMITTED = (uint16_t)0x0684, I2C_EVENT_SLAVE_BYTE_TRANSMITTING = (uint16_t)0x0680, I2C_EVENT_SLAVE_ACK_FAILURE = (uint16_t)0x0004 } |
I2C possible events Values convention: 0xXXYY XX = Event SR3 corresponding value YY = Event SR1 corresponding value. More... | |
enum | I2C_Flag_TypeDef { I2C_FLAG_TXEMPTY = (uint16_t)0x0180, I2C_FLAG_RXNOTEMPTY = (uint16_t)0x0140, I2C_FLAG_STOPDETECTION = (uint16_t)0x0110, I2C_FLAG_HEADERSENT = (uint16_t)0x0108, I2C_FLAG_TRANSFERFINISHED = (uint16_t)0x0104, I2C_FLAG_ADDRESSSENTMATCHED = (uint16_t)0x0102, I2C_FLAG_STARTDETECTION = (uint16_t)0x0101, I2C_FLAG_WAKEUPFROMHALT = (uint16_t)0x0220, I2C_FLAG_OVERRUNUNDERRUN = (uint16_t)0x0208, I2C_FLAG_ACKNOWLEDGEFAILURE = (uint16_t)0x0204, I2C_FLAG_ARBITRATIONLOSS = (uint16_t)0x0202, I2C_FLAG_BUSERROR = (uint16_t)0x0201, I2C_FLAG_GENERALCALL = (uint16_t)0x0310, I2C_FLAG_TRANSMITTERRECEIVER = (uint16_t)0x0304, I2C_FLAG_BUSBUSY = (uint16_t)0x0302, I2C_FLAG_MASTERSLAVE = (uint16_t)0x0301 } |
I2C Flags. More... | |
enum | I2C_IT_TypeDef { I2C_IT_ERR = (uint8_t)0x01, I2C_IT_EVT = (uint8_t)0x02, I2C_IT_BUF = (uint8_t)0x04 } |
I2C Interrupt sources Warning: the values correspond to the bit position in the ITR register. More... | |
enum | I2C_ITPendingBit_TypeDef { I2C_ITPENDINGBIT_TXEMPTY = (uint16_t)0x1680, I2C_ITPENDINGBIT_RXNOTEMPTY = (uint16_t)0x1640, I2C_ITPENDINGBIT_STOPDETECTION = (uint16_t)0x1210, I2C_ITPENDINGBIT_HEADERSENT = (uint16_t)0x1208, I2C_ITPENDINGBIT_TRANSFERFINISHED = (uint16_t)0x1204, I2C_ITPENDINGBIT_ADDRESSSENTMATCHED = (uint16_t)0x1202, I2C_ITPENDINGBIT_STARTDETECTION = (uint16_t)0x1201, I2C_ITPENDINGBIT_WAKEUPFROMHALT = (uint16_t)0x2220, I2C_ITPENDINGBIT_OVERRUNUNDERRUN = (uint16_t)0x2108, I2C_ITPENDINGBIT_ACKNOWLEDGEFAILURE = (uint16_t)0x2104, I2C_ITPENDINGBIT_ARBITRATIONLOSS = (uint16_t)0x2102, I2C_ITPENDINGBIT_BUSERROR = (uint16_t)0x2101 } |
I2C Pending bits Elements values convention: 0xXYZZ X = SRx registers index X = 1 : SR1 X = 2 : SR2 Y = Position of the corresponding Interrupt ZZ = flag mask in the dedicated register(X register) More... | |
Functions | |
void | I2C_AcknowledgeConfig (I2C_Ack_TypeDef Ack) |
Enable or Disable the I2C acknowledge and position acknowledge feature. | |
ErrorStatus | I2C_CheckEvent (I2C_Event_TypeDef I2C_Event) |
I2C State Monitoring Functions. | |
void | I2C_ClearFlag (I2C_Flag_TypeDef I2C_FLAG) |
Clear flags. | |
void | I2C_ClearITPendingBit (I2C_ITPendingBit_TypeDef I2C_ITPendingBit) |
Clear IT pending bit. | |
void | I2C_Cmd (FunctionalState NewState) |
Enables or disables the I2C peripheral. | |
void | I2C_DeInit (void) |
Deinitializes the I2C peripheral registers to their default reset values. | |
void | I2C_FastModeDutyCycleConfig (I2C_DutyCycle_TypeDef I2C_DutyCycle) |
Selects the specified I2C fast mode duty cycle. | |
void | I2C_GeneralCallCmd (FunctionalState NewState) |
Enables or disables the I2C General Call feature. | |
void | I2C_GenerateSTART (FunctionalState NewState) |
Generates I2C communication START condition. | |
void | I2C_GenerateSTOP (FunctionalState NewState) |
Generates I2C communication STOP condition. | |
FlagStatus | I2C_GetFlagStatus (I2C_Flag_TypeDef I2C_Flag) |
3) Flag-based state monitoring | |
ITStatus | I2C_GetITStatus (I2C_ITPendingBit_TypeDef I2C_ITPendingBit) |
Checks whether the specified I2C interrupt has occurred or not. | |
I2C_Event_TypeDef | I2C_GetLastEvent (void) |
2) Advanced state monitoring | |
void | I2C_Init (uint32_t OutputClockFrequencyHz, uint16_t OwnAddress, I2C_DutyCycle_TypeDef I2C_DutyCycle, I2C_Ack_TypeDef Ack, I2C_AddMode_TypeDef AddMode, uint8_t InputClockFrequencyMHz) |
Initializes the I2C according to the specified parameters in standard or fast mode. | |
void | I2C_ITConfig (I2C_IT_TypeDef I2C_IT, FunctionalState NewState) |
Enables or disables the specified I2C interrupt. | |
uint8_t | I2C_ReceiveData (void) |
Returns the most recent received data. | |
void | I2C_Send7bitAddress (uint8_t Address, I2C_Direction_TypeDef Direction) |
Transmits the 7-bit address (to select the) slave device. | |
void | I2C_SendData (uint8_t Data) |
Send a byte by writing in the DR register. | |
void | I2C_SoftwareResetCmd (FunctionalState NewState) |
Enables or disables I2C software reset. | |
void | I2C_StretchClockCmd (FunctionalState NewState) |
Enables or disables the I2C clock stretching. |
Detailed Description
This file contains all functions prototype and macros for the I2C peripheral.
- Attention:
© COPYRIGHT 2014 STMicroelectronics
Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); You may not use this file except in compliance with the License. You may obtain a copy of the License at:
http://www.st.com/software_license_agreement_liberty_v2
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Definition in file stm8s_i2c.h.