#include #include #include #include "I2C_ADXL345.h" void PINMUX_RESET_CONFIG() { *(volatile unsigned int *)0xFFD08704 = 0x0; //i20mux *(volatile unsigned int *)0xFFD0849C = 0x1; //sda mux *(volatile unsigned int *)0xFFD084A0 = 0x1; //scl mux } void HPS_CONFIG(void) { *(volatile unsigned int *)0xFFC0406C = 2; //ic enable while( ((*(volatile unsigned int *)0xFFC0409C) & 0x1) == 1); //while i2c module is enabled, do nothing *(volatile unsigned int *)0xFFC04000 = 65; //con register *(volatile unsigned int *)0xFFC04004 = 0x53; //tar register *(volatile unsigned int *)0xFFC0401C = 90; //ic_fs_scl_hcnt *(volatile unsigned int *)0xFFC0401C = 160; //ic_fs_scl_lcnt *(volatile unsigned int *)0xFFC040A0 = 4; //spklen *(volatile unsigned int *)0xFFC0406C = 1; //ic enable while( ((*(volatile unsigned int *)0xFFC0409C) & 0x1) == 0); //*(volatile unsigned int *)0xFFD05014 = 0xFFFF0FFF; //DEASSERT I2C0 RESET CHECK } void ADXL_WRITE_BYTE(uint8_t address, uint8_t value) { *(volatile unsigned int *)0xFFC04010 = address + 0x400; *(volatile unsigned int *)0xFFC04010 = value; } void ADXL_READ_BYTE(uint8_t address, uint8_t *value) { *(volatile unsigned int *)0xFFC04010 = address + 0x400; *(volatile unsigned int *)0xFFC04010 = 0x100; while (*(volatile unsigned int *)0xFFC04078 == 0); *value = *(volatile unsigned int *)0xFFC04010; } void ADXL_READ_BYTES(uint8_t address, uint8_t len) { int i; uint8_t threshold = *(volatile unsigned int *)0xFFC04078; //read how many receive fifo valid entries *(volatile unsigned int *)0xFFC04010 = address + 0x400; for (i=0;i