芯片破解LPC11xx读写AT24C04主模式
| IIC.c文件: 芯片破解/***************************************************************************** * i2c.c: I2C C file for NXP LPC11xx Family Microprocessors * * Copyright(C) 2008, NXP Semiconductor * All rights reserved. * * History * 2008.07.19 ver 1.00 Preliminary version, first Release * *****************************************************************************/ #include "LPC11xx.h" /* LPC11xx Peripheral Registers */ #include "type.h" #include "i2c.h" #include "Delay.h" volatile uint32_t I2CMasterState = I2C_IDLE; volatile uint32_t I2CSlaveState = I2C_IDLE; volatile uint32_t I2CMode; volatile uint8_t I2CMasterBuffer[I2C_BUFSIZE]={0}; volatile uint8_t I2CSlaveBuffer[I2C_BUFSIZE] ={0}; volatile uint32_t I2CReadLength; volatile uint32_t I2CWriteLength; volatile uint32_t RdIndex = 0; volatile uint32_t WrIndex = 0; /* From device to device, the I2C communication protocol may vary, in the example below, the protocol uses repeated start to read data from or write to the device: For master read: the sequence is: STA,Addr(W),offset,RE-STA,Addr(r),data...STO for master write: the sequence is: STA,Addr(W),offset,RE-STA,Addr(w),data...STO Thus, in state 8, the address is always WRITE. in state 10, the address could be READ or WRITE depending on the I2C command. */ /***************************************************************************** ** Function name: I2C_IRQHandler ** ** Descriptions: I2C interrupt handler, deal with master mode only. ** ** parameters: None ** Returned value: None ** *****************************************************************************/ void I2C_IRQHandler(void) { uint8_t StatValue; /* this handler deals with master read and master write only */ StatValue = LPC_I2C->STAT; switch ( StatValue ) { /**************** Master write **********************************/ |

芯片解密