Subversion Repositories NaviCtrl

Rev

Rev 378 | Rev 469 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 378 Rev 465
Line 86... Line 86...
86
        I2C_InitTypeDef   I2C_Struct;
86
        I2C_InitTypeDef   I2C_Struct;
87
        GPIO_InitTypeDef  GPIO_InitStructure;
87
        GPIO_InitTypeDef  GPIO_InitStructure;
Line 88... Line 88...
88
       
88
       
Line 89... Line 89...
89
        I2C_State = I2C_STATE_OFF;
89
        I2C_State = I2C_STATE_OFF;
90
 
90
 
91
        UART1_PutString("\r\n I2C init...");
91
        UART1_PutString("\r\n I2C1 init...");
92
        // enable Port 2 peripherie
92
        // enable Port 2 peripherie
93
        SCU_APBPeriphClockConfig(__GPIO2, ENABLE);
93
        SCU_APBPeriphClockConfig(__GPIO2, ENABLE);
Line 187... Line 187...
187
 
187
 
188
//--------------------------------------------------------------
188
//--------------------------------------------------------------
189
void I2C1_Deinit(void)
189
void I2C1_Deinit(void)
190
{
190
{
191
        GPIO_InitTypeDef  GPIO_InitStructure;
191
        GPIO_InitTypeDef  GPIO_InitStructure;
192
        UART1_PutString("\r\n I2C deinit...");
192
        UART1_PutString("\r\n I2C1 deinit...");
193
        I2C_GenerateStart(I2C1, DISABLE);
193
        I2C_GenerateStart(I2C1, DISABLE);
194
        I2C_GenerateSTOP(I2C1, ENABLE);
194
        I2C_GenerateSTOP(I2C1, ENABLE);
195
        VIC_ITCmd(I2C1_ITLine, DISABLE);
195
        VIC_ITCmd(I2C1_ITLine, DISABLE);
196
        I2C_State = I2C_STATE_OFF;
196
        I2C_State = I2C_STATE_OFF;
Line 221... Line 221...
221
//--------------------------------------------------------------
221
//--------------------------------------------------------------
222
void I2C1_IRQHandler(void)
222
void I2C1_IRQHandler(void)
223
{
223
{
224
        static u8 Rx_Idx = 0, Tx_Idx = 0;
224
        static u8 Rx_Idx = 0, Tx_Idx = 0;
225
        u16 status;
225
        u16 status;
-
 
226
                u8 text[20];
Line 226... Line 227...
226
 
227
 
227
        //IENABLE;  // do not enable IRQ nesting for I2C!!!!
228
        //IENABLE;  // do not enable IRQ nesting for I2C!!!!
228
        // detemine I2C State
229
        // detemine I2C State
Line 240... Line 241...
240
                VIC_ITCmd(I2C1_ITLine, DISABLE);
241
                VIC_ITCmd(I2C1_ITLine, DISABLE);
241
                return;
242
                return;
242
        }
243
        }
243
        else
244
        else
244
        {       // depending on current i2c state
245
        {       // depending on current i2c state
-
 
246
               
-
 
247
                        sprintf(text, "%02X ", status);
-
 
248
                        UART1_PutString(text);
245
                switch(status)
249
                switch(status)
246
                {
250
                {
247
                        // the start condition was initiated on the bus
251
                        // the start condition was initiated on the bus
248
                        case I2C_EVENT_MASTER_MODE_SELECT:
252
                        case I2C_EVENT_MASTER_MODE_SELECT:
249
                                // update current bus state variable
253
                                // update current bus state variable