Files
-
PCB ESP32 / bak / PCB1.PcbDoc
-
PCB ESP32 / bak / Sheet1.SchDoc
-
PCB ESP32 / bak / Sheet2.SchDoc
-
PCB ESP32 / Control_Board / Conns.SchDoc
-
PCB ESP32 / Control_Board / Control_Board.PcbDoc
-
PCB ESP32 / Control_Board / PCB2.PcbDoc
-
PCB ESP32 / Control_Board / Circuit Maker / Control_Board.PcbDoc
-
PCB ESP32 / Main / PCB2.PcbDoc
-
PCB ESP32 / Main / Sheet1.SchDoc
-
PCB ESP32 / Main / Sheet2.SchDoc
-
PCB ESP32 / Main / Sheet3.SchDoc
-
PCB ESP32 / Main / Sheet4.SchDoc
-
PCB ESP32 / Main / Sheet4_Matrix.SchDoc
-
PCB ESP32 / Matrix / PCB1.PcbDoc
-
PCB ESP32 / Matrix2 / PCB2.PcbDoc
-
PCB ESP32 / Panel / panel.PcbDoc
-
PCB ESP32 / refs / OnOnfre_DevBoard_rev4.sch
-
PCB ESP32 / Resistor Patch / 1 / ResistorPatch1.PcbDoc
-
PCB ESP32 / Resistor Patch / 1 / ResistorPatch1.SchDoc
-
PCB ESP32 / Resistor Patch / 2 / ResistorPatch2.PcbDoc
-
PCB ESP32 / Resistor Patch / 2 / ResistorPatch2.SchDoc
-
PCB ESP32 / SOT223 Patch / PCB1.PcbDoc
-
PCB ESP32 / SOT223 Patch / Sheet1.SchDoc
Last update 5 years 4 months
by Afonso Muralha
FilesCODEISSI Testsrc | |
---|---|
.. | |
I2C.cpp | |
IS31FL3741.cpp | |
main.cpp |
I2C.cpp/*================================= */ #include "../include/I2C.h" int Delay_Time = 3; /* Delay_Time Speed 1 2MHz 3 1MHz 4 800KHz 7 500KHz 9 400KHz 12 300KHz */ int I2C_WriteByte(int DeviceAddress, int WriteAddress, int SendByte) { /* //I2C_Start(); if(!I2C_Start())return FALSE1; I2C_SendByte(DeviceAddress & 0xFE);// if(!I2C_WaitAck()) { I2C_Stop(); return FALSE1; } I2C_SendByte(WriteAddress); // I2C_WaitAck(); I2C_SendByte(SendByte); I2C_WaitAck(); I2C_Stop(); //Systick_Delay_1ms(10); return TRUE1;*/ Wire.beginTransmission(DeviceAddress/2); // transmit to device IS31FL373x Wire.write(WriteAddress); // sends regaddress Wire.write(SendByte); // sends regaddress Wire.endTransmission(); // stop transmitting } /* //I2C дһ��byte���Ĵ�����ַ������ uint8_t I2C_Write2Byte(int WriteAddress, int SendByte) { if(!I2C_Start())return FALSE1; I2C_SendByte(WriteAddress); if(!I2C_WaitAck()) { I2C_Stop(); return FALSE1; } I2C_SendByte(SendByte); I2C_WaitAck(); I2C_Stop(); return TRUE1; } //I2C ����д //������ַ����д��Ĵ�����ʼ��ַ����д�����������ȣ����������ַ uint8_t I2C_WriteBuffer(uint8_t* pBuffer, int length, int DeviceAddress, int WriteAddress ) { //I2C_Start(); if(!I2C_Start())return FALSE1; I2C_SendByte(DeviceAddress & 0xFE);//???? if(!I2C_WaitAck()){I2C_Stop(); return FALSE1;} I2C_SendByte(WriteAddress); //?????????? I2C_WaitAck(); while(length--) { I2C_SendByte(*pBuffer); I2C_WaitAck(); pBuffer++; } I2C_Stop(); //Systick_Delay_1ms(10); return TRUE1; } // I2C ��һ��byte uint8_t I2C_ReadByte(int DeviceAddress,int ReadAddress) { uint8_t rec; //I2C_Start(); if(!I2C_Start())return FALSE1; I2C_SendByte(DeviceAddress & 0xFE);// if(!I2C_WaitAck()){I2C_Stop(); return FALSE1;} I2C_SendByte(ReadAddress); // I2C_WaitAck(); I2C_Stop(); //selectable I2C_Start(); I2C_SendByte(DeviceAddress | 0x01); I2C_WaitAck(); rec=I2C_ReceiveByte(); I2C_WaitAck(); I2C_Stop(); return rec; } // I2C ������һ������ uint8_t I2C_ReadBuffer(uint8_t* pBuffer, int length, int ReadAddress, int DeviceAddress) { if(length == 0) return FALSE1; // I2C_Start(); if(!I2C_Start())return FALSE1; I2C_SendByte(DeviceAddress & 0xFE);//???? if(!I2C_WaitAck()){I2C_Stop(); return FALSE1;} I2C_SendByte(ReadAddress); //?????????? I2C_WaitAck(); I2C_Stop(); //selectable I2C_Start(); I2C_SendByte(DeviceAddress | 0x01); I2C_WaitAck(); while(length) { *pBuffer = I2C_ReceiveByte(); if(length == 1)I2C_NoAck(); else I2C_Ack(); pBuffer++; length--; } I2C_Stop(); return TRUE1; } */