| BlueNRG-1 Peripherals drivers APIs

- Main Page
- Modules
- Classes
- Files

- File List
- File Members

BlueNRG1_i2c.h
Go to the documentation of this file.
1
23 /* Define to prevent recursive inclusion -------------------------------------*/
24 #ifndef BLUENRG1_I2C_H
25 #define BLUENRG1_I2C_H
26
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30
31 /* Includes ------------------------------------------------------------------*/
32 #include "BlueNRG1.h"
33
49 typedef struct
50 {
51 uint32_t I2C_ClockSpeed;
54 uint8_t I2C_OperatingMode;
57 uint8_t I2C_Filtering;
60 uint16_t I2C_OwnAddress1;
63 FunctionalState I2C_ExtendAddress;
65 } I2C_InitType;
66
67
68
72 typedef struct {
73 uint16_t Operation;
76 uint16_t Address;
78 uint16_t StartByte;
81 uint16_t AddressType;
84 uint16_t StopCondition;
87 uint16_t Length;
89 } I2C_TransactionType;
90
91
95 typedef enum {
96 I2C_NOP = 0,
97 I2C_OP_ONGOING,
98 I2C_OP_OK,
99 I2C_OP_ABORTED,
101 } I2C_OpStatus;
102
120 #define IS_I2C_ALL_PERIPH(I2CX) (((I2CX) == I2C1) || \
121 ((I2CX) == I2C2))
122
130 #define IS_I2C_TX_THRESHOLD(TXTHR) ((TXTHR) <= 8)
131
132 #define IS_I2C_RX_THRESHOLD(RXTHR) ((RXTHR) <= 8)
133
142 #define I2C_Filtering_Off ((uint8_t)0x00)
143 #define I2C_Filtering_1Ck_Spike ((uint8_t)0x01)
144 #define I2C_Filtering_2Ck_Spikes ((uint8_t)0x02)
145 #define I2C_Filtering_4Ck_Spikes ((uint8_t)0x03)
148 #define IS_I2C_FILTERING(FILTER) (((FILTER) == I2C_Filtering_Off) || \
149 ((FILTER) == I2C_Filtering_1Ck_Spike) || \
150 ((FILTER) == I2C_Filtering_2Ck_Spikes) || \
151 ((FILTER) == I2C_Filtering_4Ck_Spikes))
152
161 #define I2C_OperatingMode_Slave (0x00)
162 #define I2C_OperatingMode_Master (0x01)
163 #define I2C_OperatingMode_MasterSlave (0x02)
166 #define IS_I2C_OPERATING_MODE(MODE) (((MODE) == I2C_OperatingMode_Master) || \
167 ((MODE) == I2C_OperatingMode_Slave) || \
168 ((MODE) == I2C_OperatingMode_MasterSlave))
169
178 #define I2C_Operation_Write ((uint8_t)0)
179 #define I2C_Operation_Read ((uint8_t)1)
182 #define IS_I2C_OPERATION(OP) (((OP) == I2C_Operation_Write) || \
183 ((OP) == I2C_Operation_Read))
184
193 #define I2C_StartByte_Disable ((uint16_t)0x0000)
194 #define I2C_StartByte_Enable ((uint16_t)0x0800)
197 #define IS_I2C_STARTBYTE(SB) (((SB) == I2C_StartByte_Disable) || \
198 ((SB) == I2C_StartByte_Enable))
199
208 #define I2C_AddressType_GeneralCall ((uint16_t)0x0000)
209 #define I2C_AddressType_7Bit ((uint16_t)0x1000)
210 #define I2C_AddressType_10Bit ((uint16_t)0x2000)
213 #define IS_I2C_ADDRESSTYPE(AT) (((AT) == I2C_AddressType_GeneralCall) || \
214 ((AT) == I2C_AddressType_7Bit) || \
215 ((AT) == I2C_AddressType_10Bit))
216
225 #define I2C_StopCondition_Disable ((uint16_t)0x0000)
226 #define I2C_StopCondition_Enable ((uint16_t)0x4000)
229 #define IS_I2C_STOPCONDITION(P) (((P) == I2C_StopCondition_Disable) || \
230 ((P) == I2C_StopCondition_Enable))
231
232 #define IS_I2C_LENGTH(P) ((P) <= 0x7FF)
233
242 #define I2C_IT_TXFE (0x00000001)
243 #define I2C_IT_TXFNE (0x00000002)
244 #define I2C_IT_TXFF (0x00000004)
245 #define I2C_IT_TXFOVR (0x00000008)
246 #define I2C_IT_RXFE (0x00000010)
247 #define I2C_IT_RXFNF (0x00000020)
248 #define I2C_IT_RXFF (0x00000040)
249 #define I2C_IT_LBR (0x00008000)
250 #define I2C_IT_RFSR (0x00010000)
251 #define I2C_IT_RFSE (0x00020000)
252 #define I2C_IT_WTSR (0x00040000)
253 #define I2C_IT_MTD (0x00080000)
254 #define I2C_IT_STD (0x00100000)
255 #define I2C_IT_SAL (0x00800000)
256 #define I2C_IT_MAL (0x01000000)
257 #define I2C_IT_BERR (0x02000000)
258 #define I2C_IT_MTDWS (0x10000000)
259 #define I2C_IT_TIMEOUT (0x40000000)
260 #define I2C_IT_MSK (0x739F807F)
263 #define IS_I2C_IT(IT) ((((IT) & ~I2C_IT_MSK) == 0x00000000) && ((IT) != 0x00000000))
264
274 #define IS_I2C_OWN_ADDRESS1(ADDRESS1) ((ADDRESS1) <= 0x3FF)
275
276
278 #define IS_I2C_OWN_ADDRESS(ADDRESS2) ((ADDRESS2) <= 0x7F)
279
290 #define IS_I2C_CLOCK_SPEED_I2C(SPEED) (((SPEED) >= 1) && ((SPEED) <= 400000))
291
301 #define I2C_DMAReq_Tx ((uint16_t)0x0200)
302 #define I2C_DMAReq_Rx ((uint16_t)0x0400)
303 #define IS_I2C_DMAREQ(DMAREQ) ((DMAREQ & 0x0600) != 0)
304
314 #define IS_I2C_BURSTSIZE(SIZE) (((SIZE) >= 1) && ((SIZE) <= 7))
315
325 #define IS_I2C_HOLDTIME(TIME) ((TIME) <= 0x1FF)
326
339 void I2C_DeInit(I2C_Type* I2Cx);
340 void I2C_Init(I2C_Type* I2Cx, I2C_InitType* I2C_InitStruct);
341 void I2C_StructInit(I2C_InitType* I2C_InitStruct);
342 void I2C_Cmd(I2C_Type* I2Cx, FunctionalState NewState);
343 void I2C_BeginTransaction(I2C_Type* I2Cx, I2C_TransactionType* tr);
344 void I2C_GeneralCallCmd(I2C_Type* I2Cx, FunctionalState NewState);
345 void I2C_FillTxFIFO(I2C_Type* I2Cx, uint8_t Data);
346 uint8_t I2C_ReceiveData(I2C_Type* I2Cx);
347 void I2C_FlushTx(I2C_Type* I2Cx);
348 void I2C_FlushRx(I2C_Type* I2Cx);
349 void I2C_SetTxThreshold(I2C_Type* I2Cx, uint16_t TxThres);
350 void I2C_SetRxThreshold(I2C_Type* I2Cx, uint16_t RxThres);
351 void I2C_GenerateStopCondition(I2C_Type* I2Cx);
352 void I2C_SetHoldTime(I2C_Type* I2Cx, uint16_t I2C_HoldTime);
353 void I2C_SetHoldTimeStartCondition(I2C_Type* I2Cx, uint16_t I2C_HoldTime);
354 I2C_OpStatus I2C_WaitFlushRx(I2C_Type* I2Cx);
355 I2C_OpStatus I2C_WaitFlushTx(I2C_Type* I2Cx);
356
357 void I2C_ITConfig(I2C_Type* I2Cx, uint32_t I2C_IT, FunctionalState NewState);
358 ITStatus I2C_GetITStatus(I2C_Type* I2Cx, uint32_t I2C_IT);
359 void I2C_ClearITPendingBit(I2C_Type* I2Cx, uint32_t I2C_IT);
360 ITStatus I2C_GetITPendingBit(I2C_Type* I2Cx, uint32_t I2C_IT);
361 I2C_OpStatus I2C_GetStatus(I2C_Type* I2Cx);
362 void I2C_DMACmd(I2C_Type* I2Cx, uint16_t I2C_DMAReq, FunctionalState NewState);
363 void I2C_DMATxBurstMode(I2C_Type* I2Cx, FunctionalState NewState);
364 void I2C_DMATxBurstSize(I2C_Type* I2Cx, uint8_t I2C_BurstSize);
365
366
379 #ifdef __cplusplus
380 }
381 #endif
382
383 #endif /*BLUENRG1_I2C_H */
384
385 /******************* (C) COPYRIGHT 2016 STMicroelectronics *****END OF FILE****/
I2C_OP_ABORTED
Definition: BlueNRG1_i2c.h:99
I2C_DMACmd
void I2C_DMACmd(I2C_Type *I2Cx, uint16_t I2C_DMAReq, FunctionalState NewState)
Enables or disables the I2C DMA interface.
Definition: BlueNRG1_i2c.c:648
I2C_DMATxBurstMode
void I2C_DMATxBurstMode(I2C_Type *I2Cx, FunctionalState NewState)
Enables or disables the I2C TX DMA burst mode.
Definition: BlueNRG1_i2c.c:674
I2C_BeginTransaction
void I2C_BeginTransaction(I2C_Type *I2Cx, I2C_TransactionType *tr)
Start an I2C transaction sending the frame specified.
Definition: BlueNRG1_i2c.c:237
I2C_InitType::I2C_ClockSpeed
uint32_t I2C_ClockSpeed
Definition: BlueNRG1_i2c.h:51
I2C_SetTxThreshold
void I2C_SetTxThreshold(I2C_Type *I2Cx, uint16_t TxThres)
Sets the transmit FIFO threshold by the I2Cx peripheral.
Definition: BlueNRG1_i2c.c:423
I2C_GetStatus
I2C_OpStatus I2C_GetStatus(I2C_Type *I2Cx)
Get the present state of the operation executed by I2C block.
Definition: BlueNRG1_i2c.c:626
I2C_StructInit
void I2C_StructInit(I2C_InitType *I2C_InitStruct)
Fills the I2C_InitStruct with default values.
Definition: BlueNRG1_i2c.c:187
I2C_Cmd
void I2C_Cmd(I2C_Type *I2Cx, FunctionalState NewState)
Enables or disables the specified I2C peripheral.
Definition: BlueNRG1_i2c.c:213
I2C_TransactionType::Address
uint16_t Address
Definition: BlueNRG1_i2c.h:76
I2C_SetRxThreshold
void I2C_SetRxThreshold(I2C_Type *I2Cx, uint16_t RxThres)
Sets the receive FIFO threshold by the I2Cx peripheral.
Definition: BlueNRG1_i2c.c:438
I2C_GetITPendingBit
ITStatus I2C_GetITPendingBit(I2C_Type *I2Cx, uint32_t I2C_IT)
Checks whether the specified I2C interrupt has occurred or not.
Definition: BlueNRG1_i2c.c:568
I2C_InitType::I2C_Filtering
uint8_t I2C_Filtering
Definition: BlueNRG1_i2c.h:57
I2C_SetHoldTime
void I2C_SetHoldTime(I2C_Type *I2Cx, uint16_t I2C_HoldTime)
Set the hold time value for data transfer.
Definition: BlueNRG1_i2c.c:469
I2C_OpStatus
I2C_OpStatus
I2C operation status enumeration.
Definition: BlueNRG1_i2c.h:95
I2C_TransactionType::Length
uint16_t Length
Definition: BlueNRG1_i2c.h:87
I2C_DMATxBurstSize
void I2C_DMATxBurstSize(I2C_Type *I2Cx, uint8_t I2C_BurstSize)
Set the number of burst of data. If this number is smaller than the transaction length, only one single request are generated.
Definition: BlueNRG1_i2c.c:699
I2C_TransactionType::AddressType
uint16_t AddressType
Definition: BlueNRG1_i2c.h:81
I2C_ClearITPendingBit
void I2C_ClearITPendingBit(I2C_Type *I2Cx, uint32_t I2C_IT)
Clears the I2Cx interrupt pending bits.
Definition: BlueNRG1_i2c.c:611
I2C_OP_OK
Definition: BlueNRG1_i2c.h:98
I2C_NOP
Definition: BlueNRG1_i2c.h:96
I2C_DeInit
void I2C_DeInit(I2C_Type *I2Cx)
Deinitializes the I2C peripheral registers to their default reset values.
Definition: BlueNRG1_i2c.c:96
I2C_InitType::I2C_ExtendAddress
FunctionalState I2C_ExtendAddress
Definition: BlueNRG1_i2c.h:63
I2C_FlushTx
void I2C_FlushTx(I2C_Type *I2Cx)
Returns the most recent received data by the I2Cx peripheral.
Definition: BlueNRG1_i2c.c:355
I2C_FillTxFIFO
void I2C_FillTxFIFO(I2C_Type *I2Cx, uint8_t Data)
Fills the Tx FIFO with the specified data byte.
Definition: BlueNRG1_i2c.c:328
I2C_InitType
Structure definition of I2C initialization.
Definition: BlueNRG1_i2c.h:49
I2C_OP_ONGOING
Definition: BlueNRG1_i2c.h:97
I2C_GeneralCallCmd
void I2C_GeneralCallCmd(I2C_Type *I2Cx, FunctionalState NewState)
Enables or disables the general call feature.
Definition: BlueNRG1_i2c.c:263
I2C_TransactionType::Operation
uint16_t Operation
Definition: BlueNRG1_i2c.h:73
I2C_WaitFlushTx
I2C_OpStatus I2C_WaitFlushTx(I2C_Type *I2Cx)
Return the status of the TX FIFO flush operation.
Definition: BlueNRG1_i2c.c:369
I2C_InitType::I2C_OwnAddress1
uint16_t I2C_OwnAddress1
Definition: BlueNRG1_i2c.h:60
I2C_ReceiveData
uint8_t I2C_ReceiveData(I2C_Type *I2Cx)
Returns the most recent received data by the I2Cx peripheral.
Definition: BlueNRG1_i2c.c:341
I2C_WaitFlushRx
I2C_OpStatus I2C_WaitFlushRx(I2C_Type *I2Cx)
Return the status of the RX FIFO flush operation.
Definition: BlueNRG1_i2c.c:403
I2C_ITConfig
void I2C_ITConfig(I2C_Type *I2Cx, uint32_t I2C_IT, FunctionalState NewState)
Enables or disables the specified I2C interrupts.
Definition: BlueNRG1_i2c.c:305
I2C_TransactionType::StopCondition
uint16_t StopCondition
Definition: BlueNRG1_i2c.h:84
I2C_InitType::I2C_OperatingMode
uint8_t I2C_OperatingMode
Definition: BlueNRG1_i2c.h:54
I2C_GenerateStopCondition
void I2C_GenerateStopCondition(I2C_Type *I2Cx)
Generate a stop condition.
Definition: BlueNRG1_i2c.c:454
I2C_GetITStatus
ITStatus I2C_GetITStatus(I2C_Type *I2Cx, uint32_t I2C_IT)
Checks whether the specified I2C interrupt has occurred or not.
Definition: BlueNRG1_i2c.c:525
I2C_Init
void I2C_Init(I2C_Type *I2Cx, I2C_InitType *I2C_InitStruct)
Initializes the I2Cx peripheral according to the specified parameters in the I2C_InitStruct.
Definition: BlueNRG1_i2c.c:117
I2C_TransactionType::StartByte
uint16_t StartByte
Definition: BlueNRG1_i2c.h:78
I2C_SetHoldTimeStartCondition
void I2C_SetHoldTimeStartCondition(I2C_Type *I2Cx, uint16_t I2C_HoldTime)
Set the hold time value for start condition.
Definition: BlueNRG1_i2c.c:484
I2C_FlushRx
void I2C_FlushRx(I2C_Type *I2Cx)
Returns the most recent received data by the I2Cx peripheral.
Definition: BlueNRG1_i2c.c:389
I2C_TransactionType
Structure definition of I2C transaction initialization.
Definition: BlueNRG1_i2c.h:72