OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Demo/] [ARM7_STR75x_GCC/] [STLibrary/] [inc/] [75x_i2c.h] - Blame information for rev 583

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 577 jeremybenn
/******************** (C) COPYRIGHT 2006 STMicroelectronics ********************
2
* File Name          : 75x_i2c.h
3
* Author             : MCD Application Team
4
* Date First Issued  : 03/10/2006
5
* Description        : This file contains all the functions prototypes for the
6
*                      I2C software library.
7
********************************************************************************
8
* History:
9
* 07/17/2006 : V1.0
10
* 03/10/2006 : V0.1
11
********************************************************************************
12
* THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
13
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
14
* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
15
* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
16
* CONTENT OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
17
* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
18
*******************************************************************************/
19
 
20
/* Define to prevent recursive inclusion ------------------------------------ */
21
#ifndef __75x_I2C_H
22
#define __75x_I2C_H
23
 
24
/* Includes ----------------------------------------------------------------- */
25
#include "75x_map.h"
26
 
27
/* Exported types ----------------------------------------------------------- */
28
/* I2C Init structure definition */
29
typedef struct
30
{
31
   u32 I2C_CLKSpeed;
32
   u16 I2C_OwnAddress;
33
   u8  I2C_GeneralCall;
34
   u8  I2C_Ack;
35
}I2C_InitTypeDef;
36
 
37
/* Exported constants --------------------------------------------------------*/
38
/* General Call */
39
#define  I2C_GeneralCall_Enable      0x10
40
#define  I2C_GeneralCall_Disable     0xEF
41
 
42
/* Acknowledgement */
43
#define  I2C_Ack_Enable      0x04
44
#define  I2C_Ack_Disable     0xFB
45
 
46
/* I2C Flags */
47
#define  I2C_FLAG_SB      0x0001
48
#define  I2C_FLAG_M_SL    0x0002
49
#define  I2C_FLAG_ADSL    0x0004
50
#define  I2C_FLAG_BTF     0x0008
51
#define  I2C_FLAG_BUSY    0x0010
52
#define  I2C_FLAG_TRA     0x0020
53
#define  I2C_FLAG_ADD10   0x0040
54
#define  I2C_FLAG_EVF     0x0080
55
#define  I2C_FLAG_GCAL    0x0100
56
#define  I2C_FLAG_BERR    0x0200
57
#define  I2C_FLAG_ARLO    0x0400
58
#define  I2C_FLAG_STOPF   0x0800
59
#define  I2C_FLAG_AF      0x1000
60
#define  I2C_FLAG_ENDAD   0x2000
61
#define  I2C_FLAG_ACK     0x4000
62
 
63
/* I2C Events */
64
#define  I2C_EVENT_SLAVE_ADDRESS_MATCHED   ( I2C_FLAG_EVF | I2C_FLAG_BUSY  |I2C_FLAG_ADSL)    
65
#define  I2C_EVENT_SLAVE_BYTE_RECEIVED     ( I2C_FLAG_EVF | I2C_FLAG_BUSY  | I2C_FLAG_BTF )     
66
#define  I2C_EVENT_SLAVE_BYTE_TRANSMITTED  ( I2C_FLAG_EVF | I2C_FLAG_BUSY  | I2C_FLAG_BTF  | I2C_FLAG_TRA ) 
67
#define  I2C_EVENT_MASTER_MODE_SELECT      ( I2C_FLAG_EVF | I2C_FLAG_BUSY  | I2C_FLAG_M_SL | I2C_FLAG_SB )                 
68
#define  I2C_EVENT_MASTER_MODE_SELECTED    ( I2C_FLAG_EVF | I2C_FLAG_BUSY  | I2C_FLAG_M_SL | I2C_FLAG_ENDAD )    
69
#define  I2C_EVENT_MASTER_BYTE_RECEIVED    ( I2C_FLAG_EVF | I2C_FLAG_BUSY  | I2C_FLAG_M_SL | I2C_FLAG_BTF )                
70
#define  I2C_EVENT_MASTER_BYTE_TRANSMITTED ( I2C_FLAG_EVF | I2C_FLAG_BUSY  | I2C_FLAG_M_SL | I2C_FLAG_BTF | I2C_FLAG_TRA )  
71
#define  I2C_EVENT_MASTER_MODE_ADDRESS10   ( I2C_FLAG_EVF | I2C_FLAG_BUSY  | I2C_FLAG_M_SL |I2C_FLAG_ADD10 )               
72
#define  I2C_EVENT_SLAVE_STOP_DETECTED       I2C_FLAG_STOPF                                  
73
#define  I2C_EVENT_SLAVE_ACK_FAILURE       ( I2C_FLAG_EVF | I2C_FLAG_BUSY | I2C_FLAG_BTF  | I2C_FLAG_TRA | I2C_FLAG_AF)    
74
 
75
#define  I2C_BUS_ERROR_DETECTED       I2C_FLAG_BERR
76
#define  I2C_ARBITRATION_LOST         I2C_FLAG_ARLO
77
#define  I2C_SLAVE_GENERAL_CALL       (I2C_FLAG_BUSY | I2C_FLAG_GCAL)
78
 
79
/* Master/Receiver Mode */
80
#define  I2C_MODE_TRANSMITTER          0x00
81
#define  I2C_MODE_RECEIVER             0x01
82
 
83
/* I2C Registers offset */
84
#define  I2C_CR     0x00
85
#define  I2C_SR1    0x04
86
#define  I2C_SR2    0x08
87
#define  I2C_CCR    0x0C
88
#define  I2C_OAR1   0x10
89
#define  I2C_OAR2   0x14
90
#define  I2C_DR     0x18
91
#define  I2C_ECCR   0x1C
92
 
93
/* Exported macro ------------------------------------------------------------*/
94
/* Exported functions ------------------------------------------------------- */
95
 
96
void I2C_DeInit(void);
97
void I2C_Init(I2C_InitTypeDef* I2C_InitStruct);
98
void I2C_StructInit(I2C_InitTypeDef* I2C_InitStruct);
99
void I2C_Cmd(FunctionalState NewState);
100
void I2C_GenerateSTART(FunctionalState NewState);
101
void I2C_GenerateSTOP(FunctionalState NewState);
102
void I2C_AcknowledgeConfig(FunctionalState NewState);
103
void I2C_ITConfig(FunctionalState NewState);
104
u16 I2C_GetLastEvent(void);
105
ErrorStatus I2C_CheckEvent(u16 I2C_EVENT);
106
void I2C_SendData(u8 Data);
107
u8 I2C_ReceiveData(void);
108
void I2C_Send7bitAddress(u8 Address, u8 Direction);
109
u8 I2C_ReadRegister(u8 I2C_Register);
110
FlagStatus I2C_GetFlagStatus(u16 I2C_FLAG);
111
void I2C_ClearFlag(u16 I2C_FLAG, ...);
112
 
113
#endif /* __75x_I2C_H */
114
 
115
/******************* (C) COPYRIGHT 2006 STMicroelectronics *****END OF FILE****/

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.