any idea how to connect magnetometer LIS2MDLTR made by ST ?
here is the code I am trying
uint8_t whoami_reg[1];
whoami_reg[0] = 0x4F | 0x80; // read command
uint8_t whoami_val[1];
whoami_val[0] = 0;
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4, GPIO_PIN_RESET); // CS low
HAL_SPI_Transmit(&hspi1, whoami_reg, 1, HAL_MAX_DELAY);
HAL_SPI_Receive(&hspi1, whoami_val, 1, HAL_MAX_DELAY);
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4, GPIO_PIN_SET); // CS high
whoami_val[0] should be = 0x40
I tried all the possible settings CPOL (HIGH and LOW) , CPHA ( 1 edge and 2 edge) , slower baud and nothing, I read some posts other people had problem too with SPI but apparently made it working only with I2C
I even tried to solder another LIS2MDLTR and another, nothing!




