Yes, each sensor is using a different pin for each select chip. if (*select == 0) { HAL_GPIO_WritePin(ACCEL_CS_GPIO_Port, ACCEL_CS_Pin, GPIO_PIN_RESET); // NSS low } else { HAL_GPIO_WritePin(GYRO_CS_GPIO_Port, GYRO_CS_Pin, GPIO_PIN_RESET); // NSS low } HAL_SPI_TransmitReceive(&hspi2, &addr, rdBuffer, len+1, 50); while(hspi2.State == HAL_SPI_STATE_BUSY); if (*select == 0) { HAL_GPIO_WritePin(ACCEL_CS_GPIO_Port, ACCEL_CS_Pin, GPIO_PIN_SET); // NSS high } else { HAL_GPIO_WritePin(GYRO_CS_GPIO_Port, GYRO_CS_Pin, GPIO_PIN_SET); // NSS high } memcpy(reg_data, &rdBuffer[1], len); As you can see in the code, each CS goes to a different GPIO which is enabled or disabled before and after SPI communication is made. The CS of the magnetometer is in a different common file, but the operation of the SPI is the same.
... View more