WIP getting data with interrupts
This commit is contained in:
parent
b35c7ceb72
commit
256cd3c500
2 changed files with 73 additions and 14 deletions
|
@ -16,8 +16,31 @@ typedef enum {
|
|||
bpa_trim_top_reg = 0x07,
|
||||
bpa_trim_bot_reg = 0x08,
|
||||
pu_reg = 0x09,
|
||||
data_top_reg = 0x0A,
|
||||
data_bot_reg = 0x0B,
|
||||
} SensorRegisters;
|
||||
|
||||
typedef enum {
|
||||
top_block_0 = 0,
|
||||
top_block_1,
|
||||
top_block_2,
|
||||
top_block_3,
|
||||
bot_block_0,
|
||||
bot_block_1,
|
||||
bot_block_2,
|
||||
bot_block_3,
|
||||
stop
|
||||
} StepArrayRetrieve;
|
||||
|
||||
typedef enum {
|
||||
cam_blk_0 = 0,
|
||||
cam_blk_1 = 1 << 4,
|
||||
cam_blk_2 = 2 << 4,
|
||||
cam_blk_3 = 3 << 4,
|
||||
} SensorBlockValue;
|
||||
|
||||
typedef enum {
|
||||
data_top_reg = 0x0A,
|
||||
data_bot_reg = 0x0B,
|
||||
start_get_mat = 1 << 3 | 1
|
||||
} ArrayResgiters;
|
||||
|
||||
#endif //SENSOR_REGISTERS_H
|
||||
|
|
60
Src/main.c
60
Src/main.c
|
@ -63,11 +63,17 @@ static void MX_NVIC_Init(void);
|
|||
/* Private user code ---------------------------------------------------------*/
|
||||
/* USER CODE BEGIN 0 */
|
||||
|
||||
typedef struct config_s {
|
||||
const uint8_t address;
|
||||
const uint8_t write_read;
|
||||
uint8_t command[2];
|
||||
} Config;
|
||||
volatile ArrayResgiters array_part = data_top_reg;
|
||||
volatile StepArrayRetrieve block_step = top_block_0;
|
||||
const uint8_t part_half_array = 256;
|
||||
const uint8_t ptat_num = 1;
|
||||
const uint8_t total_array_size = 1024;
|
||||
uint16_t top_blk0[part_half_array + ptat_num] = { 0 };
|
||||
uint16_t top_blk1[part_half_array + ptat_num] = { 0 };
|
||||
uint16_t top_blk2[part_half_array + ptat_num] = { 0 };
|
||||
uint16_t top_blk3[part_half_array + ptat_num] = { 0 };
|
||||
uint16_t bot_blk0[part_half_array + ptat_num] = { 0 };
|
||||
uint16_t complete_array[total_array_size] = { 0 };
|
||||
|
||||
void configure_sensor() {
|
||||
uint8_t data = 1;
|
||||
|
@ -104,7 +110,41 @@ void configure_sensor() {
|
|||
HAL_Delay(6);
|
||||
}
|
||||
|
||||
// void HAL_I2C_MasterRxCpltCallback(I2C_HandleTypeDef *hi2c) {}
|
||||
void HAL_I2C_MasterRxCpltCallback(I2C_HandleTypeDef *hi2c) {
|
||||
switch (block_step) {
|
||||
case top_block_0:
|
||||
block_step = top_block_1;
|
||||
HAL_I2C_Mem_Read_IT(&hi2c1,
|
||||
sensor_addr,
|
||||
data_top_reg | start_get_mat,
|
||||
1,
|
||||
(uint8_t *) top_blk0,
|
||||
sizeof(top_blk0) * sizeof(uint16_t));
|
||||
break;
|
||||
case top_block_1:
|
||||
block_step = top_block_2;
|
||||
break;
|
||||
case top_block_2:
|
||||
block_step = top_block_3;
|
||||
break;
|
||||
case top_block_3:
|
||||
block_step = bot_block_0;
|
||||
break;
|
||||
case bot_block_0:
|
||||
block_step = bot_block_1;
|
||||
break;
|
||||
case bot_block_1:
|
||||
block_step = bot_block_2;
|
||||
break;
|
||||
case bot_block_2:
|
||||
block_step = bot_block_3;
|
||||
break;
|
||||
case bot_block_3:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* USER CODE END 0 */
|
||||
|
||||
|
@ -114,11 +154,7 @@ 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--------------------------------------------------------*/
|
||||
|
@ -154,7 +190,7 @@ int main(void) {
|
|||
sensor_addr,
|
||||
data_top_reg,
|
||||
1,
|
||||
(uint8_t *) &top_half,
|
||||
(uint8_t *) &top_blk0,
|
||||
part_half_array * sizeof(uint16_t),
|
||||
5);
|
||||
/* USER CODE END 2 */
|
||||
|
|
Loading…
Add table
Reference in a new issue