Using MemRead to get data, MemWrite to configure it.
Retrieves block 0 from top array
This commit is contained in:
parent
7796b73e0e
commit
b35c7ceb72
1 changed files with 15 additions and 5 deletions
20
Src/main.c
20
Src/main.c
|
@ -114,7 +114,11 @@ void configure_sensor() {
|
|||
*/
|
||||
int main(void) {
|
||||
/* USER CODE BEGIN 1 */
|
||||
|
||||
const uint8_t part_half_array = 256;
|
||||
const uint8_t ptat_num = 1;
|
||||
const uint8_t total_array_size = 1024;
|
||||
uint_fast16_t top_half[part_half_array + ptat_num] = { 0 };
|
||||
uint_fast16_t complete_array[total_array_size] = { 0 };
|
||||
/* USER CODE END 1 */
|
||||
|
||||
/* MCU Configuration--------------------------------------------------------*/
|
||||
|
@ -139,14 +143,20 @@ int main(void) {
|
|||
MX_NVIC_Init();
|
||||
/* USER CODE BEGIN 2 */
|
||||
// TODO: configs
|
||||
if (HAL_I2C_IsDeviceReady(&hi2c1, sensor_addr, 3, 10) != HAL_OK) { Error_Handler(); }
|
||||
configure_sensor(); {
|
||||
uint8_t data = status_reg;
|
||||
uint8_t received_data = 0;
|
||||
HAL_I2C_Master_Transmit(&hi2c1, sensor_addr, &data, 1, 5);
|
||||
HAL_Delay(30);
|
||||
HAL_I2C_Master_Receive(&hi2c1, sensor_addr | 1, &received_data, 1, 5);
|
||||
HAL_I2C_Mem_Write(&hi2c1, sensor_addr, status_reg, 1, &received_data, 1, 5);
|
||||
}
|
||||
|
||||
// Getting first top half array
|
||||
HAL_I2C_Mem_Read(&hi2c1,
|
||||
sensor_addr,
|
||||
data_top_reg,
|
||||
1,
|
||||
(uint8_t *) &top_half,
|
||||
part_half_array * sizeof(uint16_t),
|
||||
5);
|
||||
/* USER CODE END 2 */
|
||||
|
||||
/* Infinite loop */
|
||||
|
|
Loading…
Add table
Reference in a new issue