<commit_before>/*
 * This file is part of the OpenMV project.
 * Copyright (c) 2013/2014 <NAME> <<EMAIL>>
 * This work is licensed under the MIT license, see the file LICENSE for details.
 *
 * SCCB (I2C like) driver.
 *
 */
#include <stdbool.h>
#include STM32_HAL_H
#include <systick.h>
#include "omv_boardconfig.h"
#include "cambus.h"
#define I2C_FREQUENCY   (100000)
#define I2C_TIMEOUT     (1000)

static I2C_HandleTypeDef I2CHandle;

int cambus_init()
{
    /* Configure I2C */
    I2CHandle.Instance             = SCCB_I2C;
    I2CHandle.Init.AddressingMode  = I2C_ADDRESSINGMODE_7BIT;
    #if defined(MCU_SERIES_F7) || defined(MCU_SERIES_H7)
    I2CHandle.Init.Timing          = 0x40912732; // 100KHz
    #else
    I2CHandle.Init.ClockSpeed      = I2C_FREQUENCY;
    I2CHandle.Init.DutyCycle       = I2C_DUTYCYCLE_2;
    #endif
    I2CHandle.Init.DualAddressMode = I2C_DUALADDRESS_DISABLED;
    I2CHandle.Init.GeneralCallMode = I2C_GENERALCALL_DISABLED;
    I2CHandle.Init.NoStretchMode   = I2C_NOSTRETCH_DISABLED;
    I2CHandle.Init.OwnAddress1     = 0xFE;
    I2CHandle.Init.OwnAddress2     = 0xFE;

    if (HAL_I2C_Init(&I2CHandle) != HAL_OK) {
        /* Initialization Error */
        return -1;
    }
    return 0;
}

int cambus_scan()
{
    for (uint8_t addr=0x08; addr<=0x77; addr++) {<commit_msg>Fix SCCB/I2C timing for F7 & H7.<commit_after>/*
 * This file is part of the OpenMV project.
 * Copyright (c) 2013/2014 <NAME> <<EMAIL>>
 * This work is licensed under the MIT license, see the file LICENSE for details.
 *
 * SCCB (I2C like) driver.
 *
 */
#include <stdbool.h>
#include STM32_HAL_H
#include <systick.h>
#include "omv_boardconfig.h"
#include "cambus.h"
#define I2C_FREQUENCY   (100000)
#define I2C_TIMEOUT     (1000)

static I2C_HandleTypeDef I2CHandle;

int cambus_init()
{
    /* Configure I2C */
    I2CHandle.Instance             = SCCB_I2C;
    I2CHandle.Init.AddressingMode  = I2C_ADDRESSINGMODE_7BIT;
    #if defined(MCU_SERIES_F7)
    I2CHandle.Init.Timing          = 0x1090699B; // 100KHz, rise time = 100ns, fall time = 20ns
    #elif defined(MCU_SERIES_H7)
    I2CHandle.Init.Timing          = 0x40604E73; // 100KHz, rise time = 100ns, fall time = 20ns
    #else
    I2CHandle.Init.ClockSpeed      = I2C_FREQUENCY;
    I2CHandle.Init.DutyCycle       = I2C_DUTYCYCLE_2;
    #endif
    I2CHandle.Init.DualAddressMode = I2C_DUALADDRESS_DISABLED;
    I2CHandle.Init.GeneralCallMode = I2C_GENERALCALL_DISABLED;
    I2CHandle.Init.NoStretchMode   = I2C_NOSTRETCH_DISABLED;
    I2CHandle.Init.OwnAddress1     = 0xFE;
    I2CHandle.Init.OwnAddress2     = 0xFE;

    if (HAL_I2C_Init(&I2CHandle) != HAL_OK) {
        /* Initialization Error */
        return -1;
    }
    return 0;
}

int cambus_scan()
{
    for (uint8_t addr=0x08; addr<=0x77; addr++) {
{'fraction_non_alphanumeric': 0.10556552962298026, 'fraction_numerical': 0.06175942549371634, 'mean_word_length': 3.1520119225037257, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4179213', 'n_tokens_mistral': 1231, 'n_tokens_neox': 1154, 'n_words': 215}