Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion arm11/source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ void __attribute__((noreturn)) MainLoop(void)

devId = (args[0] & 0xff);
regAddr = (args[0] >> 8) & 0xFF;
size = (args[0] >> 16) % SHMEM_BUFFER_SIZE;
size = ((args[0] >> 16) & 0x7FFF) % SHMEM_BUFFER_SIZE;

if (args[0] & BIT(31)) {
pxiReply = I2C_writeRegBuf(devId, regAddr, sharedMem.dataBuffer.b, size);
Expand Down
16 changes: 10 additions & 6 deletions arm9/source/system/i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
bool I2C_readRegBuf(I2cDevice devId, u8 regAddr, u8 *out, u32 size)
{
int ret;
u8 *const dataBuffer = ARM_GetSHMEM()->dataBuffer.b;
const u32 arg = devId | (regAddr << 8) | (size << 16);

if (size >= SHMEM_BUFFER_SIZE)
_Static_assert(SHMEM_BUFFER_SIZE < BIT(15));
if (size >= BIT(15))
return false;

u8 *const dataBuffer = ARM_GetSHMEM()->dataBuffer.b;
const u32 arg = devId | (regAddr << 8) | (size << 16);

ret = PXI_DoCMD(PXICMD_I2C_OP, &arg, 1);
ARM_InvDC_Range(dataBuffer, size);

Expand All @@ -24,12 +26,14 @@ bool I2C_readRegBuf(I2cDevice devId, u8 regAddr, u8 *out, u32 size)
bool I2C_writeRegBuf(I2cDevice devId, u8 regAddr, const u8 *in, u32 size)
{
int ret;
u8 *const dataBuffer = ARM_GetSHMEM()->dataBuffer.b;
const u32 arg = devId | (regAddr << 8) | (size << 16) | BIT(31);

if (size >= SHMEM_BUFFER_SIZE)
_Static_assert(SHMEM_BUFFER_SIZE < BIT(15));
if (size >= BIT(15))
return false;

u8 *const dataBuffer = ARM_GetSHMEM()->dataBuffer.b;
const u32 arg = devId | (regAddr << 8) | (size << 16) | BIT(31);

memcpy(dataBuffer, in, size);
ARM_WbDC_Range(dataBuffer, size);
ARM_DSB();
Expand Down
Loading