WIP getting data with interrupts
This commit is contained in:
		
					parent
					
						
							
								b35c7ceb72
							
						
					
				
			
			
				commit
				
					
						256cd3c500
					
				
			
		
					 2 changed files with 73 additions and 14 deletions
				
			
		
							
								
								
									
										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
		Add a link
		
	
		Reference in a new issue