2 Copyright © 2010-2019, The AROS Development Team. All rights reserved.
6 #include <aros/symbolsets.h>
7 #include <aros/debug.h>
8 #include <proto/exec.h>
9 #include <proto/kernel.h>
13 static IPTR __arm_periiobase
;
14 #define ARM_PERIIOBASE __arm_periiobase
15 #include <hardware/bcm2708.h>
18 #include "i2c-bcm2708.h"
20 APTR KernelBase
__attribute__((used
)) = NULL
;
22 void METHOD(I2CBCM2708
, Hidd_I2C
, PutByte
)
24 while (!(rd32le(BSC0_STATUS
) & BSC_STATUS_DONE
))
26 asm volatile ("mov r2,r2\n");
29 wr32le(BSC0_DATALEN
, 1);
30 wr32le(BSC0_FIFO
, msg
->data
);
32 wr32le(BSC0_STATUS
, BSC_CLEAR
);
33 wr32le(BSC0_CONTROL
, BSC_WRITE
);
36 void METHOD(I2CBCM2708
, Hidd_I2C
, GetByte
)
38 while (!(rd32le(BSC0_STATUS
) & BSC_STATUS_DONE
))
40 asm volatile ("mov r2,r2\n");
43 wr32le(BSC0_DATALEN
, 1);
44 wr32le(BSC0_STATUS
, BSC_CLEAR
);
45 wr32le(BSC0_CONTROL
, BSC_READ
);
47 *msg
->data
= rd32le(BSC0_FIFO
);
50 void I2CBCM2708_Init(void)
53 KernelBase
= OpenResource("kernel.resource");
54 __arm_periiobase
= KrnGetSystemAttr(KATTR_PeripheralBase
);
56 /* BSC0 is on GPIO 0 & 1 */
57 tmp
= rd32le(GPFSEL0
);
58 tmp
&= ~0x3f; // Mask out bits 0-5
59 tmp
|= 0x24; // Set bits 0-5 to binary '100100'
63 ADD2LIBS((STRPTR
)"i2c.hidd", 0, static struct Library
*, I2CBase
);