Thundersoft
/
IKS01A2_for_TT_Mxx
Creating a project about IKS10A2 for TT_Mxx
common_define.cpp@1:28de8dff2317, 2019-04-26 (annotated)
- Committer:
- ThunderSoft
- Date:
- Fri Apr 26 09:51:19 2019 +0000
- Revision:
- 1:28de8dff2317
- Parent:
- 0:69ddd5bce0a0
"Update the mbed-os code to support TT_M4G9"
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ThunderSoft | 0:69ddd5bce0a0 | 1 | #include "common_define.h" |
ThunderSoft | 0:69ddd5bce0a0 | 2 | |
ThunderSoft | 0:69ddd5bce0a0 | 3 | |
ThunderSoft | 0:69ddd5bce0a0 | 4 | |
ThunderSoft | 0:69ddd5bce0a0 | 5 | |
ThunderSoft | 0:69ddd5bce0a0 | 6 | void i2cWrite(I2C * dev_i2c,uint8_t address,uint8_t* pBuffer, uint8_t RegisterAddr, uint16_t NumByteToWrite) |
ThunderSoft | 0:69ddd5bce0a0 | 7 | { |
ThunderSoft | 0:69ddd5bce0a0 | 8 | uint8_t temp_buffer[NumByteToWrite + 1]; |
ThunderSoft | 0:69ddd5bce0a0 | 9 | temp_buffer[0] = RegisterAddr; |
ThunderSoft | 0:69ddd5bce0a0 | 10 | memcpy(temp_buffer + 1,pBuffer,NumByteToWrite); |
ThunderSoft | 0:69ddd5bce0a0 | 11 | dev_i2c->write((int)address,(const char *)temp_buffer,NumByteToWrite + 1); |
ThunderSoft | 0:69ddd5bce0a0 | 12 | } |
ThunderSoft | 0:69ddd5bce0a0 | 13 | |
ThunderSoft | 0:69ddd5bce0a0 | 14 | |
ThunderSoft | 0:69ddd5bce0a0 | 15 | void i2cRead(I2C * dev_i2c,uint8_t address,uint8_t* pBuffer, uint8_t RegisterAddr, uint16_t NumByteToRead) |
ThunderSoft | 0:69ddd5bce0a0 | 16 | { |
ThunderSoft | 0:69ddd5bce0a0 | 17 | dev_i2c->write((int)address,(const char *)&RegisterAddr,1); |
ThunderSoft | 0:69ddd5bce0a0 | 18 | dev_i2c->read((int)address,(char *)pBuffer,NumByteToRead); |
ThunderSoft | 0:69ddd5bce0a0 | 19 | } |
ThunderSoft | 0:69ddd5bce0a0 | 20 | |
ThunderSoft | 0:69ddd5bce0a0 | 21 | void i2cWriteForVL6180X(I2C * dev_i2c,uint8_t address,uint8_t* pBuffer, uint16_t RegisterAddr, uint16_t NumByteToWrite) |
ThunderSoft | 0:69ddd5bce0a0 | 22 | { |
ThunderSoft | 0:69ddd5bce0a0 | 23 | uint8_t temp_buffer[NumByteToWrite + 2]; |
ThunderSoft | 0:69ddd5bce0a0 | 24 | temp_buffer[0] = (RegisterAddr >> 8) & 0xff; |
ThunderSoft | 0:69ddd5bce0a0 | 25 | temp_buffer[1] = (RegisterAddr) & 0xff; |
ThunderSoft | 0:69ddd5bce0a0 | 26 | memcpy(temp_buffer + 2,pBuffer,NumByteToWrite); |
ThunderSoft | 0:69ddd5bce0a0 | 27 | dev_i2c->write((int)address,(const char *)temp_buffer,NumByteToWrite + 2); |
ThunderSoft | 0:69ddd5bce0a0 | 28 | } |
ThunderSoft | 0:69ddd5bce0a0 | 29 | |
ThunderSoft | 0:69ddd5bce0a0 | 30 | void i2cReadForVL6180X(I2C * dev_i2c,uint8_t address,uint8_t* pBuffer, uint16_t RegisterAddr, uint16_t NumByteToRead) |
ThunderSoft | 0:69ddd5bce0a0 | 31 | { |
ThunderSoft | 0:69ddd5bce0a0 | 32 | uint8_t temp_buffer[2]; |
ThunderSoft | 0:69ddd5bce0a0 | 33 | temp_buffer[0] = (RegisterAddr >> 8) & 0xff; |
ThunderSoft | 0:69ddd5bce0a0 | 34 | temp_buffer[1] = (RegisterAddr) & 0xff; |
ThunderSoft | 0:69ddd5bce0a0 | 35 | dev_i2c->write((int)address,(const char *)temp_buffer,2); |
ThunderSoft | 0:69ddd5bce0a0 | 36 | dev_i2c->read((int)address,(char *)pBuffer,NumByteToRead); |
ThunderSoft | 0:69ddd5bce0a0 | 37 | } |
ThunderSoft | 0:69ddd5bce0a0 | 38 | |
ThunderSoft | 0:69ddd5bce0a0 | 39 | void i2cReadForFXS_MUTIL(I2C * dev_i2c,uint8_t address,uint8_t* pBuffer, uint16_t RegisterAddr, uint16_t NumByteToRead) |
ThunderSoft | 0:69ddd5bce0a0 | 40 | { |
ThunderSoft | 0:69ddd5bce0a0 | 41 | dev_i2c->write((int)address,(const char *)&RegisterAddr,1,true); |
ThunderSoft | 0:69ddd5bce0a0 | 42 | dev_i2c->read((int)address,(char *)pBuffer,NumByteToRead); |
ThunderSoft | 0:69ddd5bce0a0 | 43 | } |
ThunderSoft | 0:69ddd5bce0a0 | 44 | |
ThunderSoft | 0:69ddd5bce0a0 | 45 | void i2cWriteForFXS_MUTIL(I2C * dev_i2c,uint8_t address,uint8_t* pBuffer, uint16_t RegisterAddr, uint16_t NumByteToWrite) |
ThunderSoft | 0:69ddd5bce0a0 | 46 | { |
ThunderSoft | 0:69ddd5bce0a0 | 47 | uint8_t temp_buffer[NumByteToWrite + 1]; |
ThunderSoft | 0:69ddd5bce0a0 | 48 | temp_buffer[0] = RegisterAddr; |
ThunderSoft | 0:69ddd5bce0a0 | 49 | memcpy(temp_buffer + 1,pBuffer,NumByteToWrite); |
ThunderSoft | 0:69ddd5bce0a0 | 50 | dev_i2c->write((int)address,(const char *)temp_buffer,NumByteToWrite + 1); |
ThunderSoft | 0:69ddd5bce0a0 | 51 | } |