Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i2c HAL refactor #265

Draft
wants to merge 67 commits into
base: main
Choose a base branch
from
Draft

Conversation

StefanoAlbini96
Copy link
Contributor

@StefanoAlbini96 StefanoAlbini96 commented May 16, 2023

Major refactoring of the HAL for the i2c peripheral.
The main changes are due to the usage of the memory mapped i2c_peri structure to access directly the registers.
Moreover the code has been modified to be more clear and compact.

The irq_index() function has been completely removed and substituted with sanity checks on the irq variable. For this, an additional field in the i2c_irq_t enum has been added in order to always keep track of the number of different interrupt types related to the i2c.

Albini Stefano and others added 30 commits January 24, 2023 10:37

/**
* Computes default timing parameters for a particular I2C speed, given the
* clock period, in nanoseconds.
*
* Returns an unspecified value for an invalid speed.
*/
static i2c_config_t default_timing_for_speed(i2c_speed_t speed,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please, comment the function in doxyg. format

}
uint32_t lowest_target_device_speed_khz;
switch (timing_config.lowest_target_device_speed) {
case kDifI2cSpeedStandard:
case kI2cSpeedStandard:
lowest_target_device_speed_khz = 100;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we have defines for those values?

/**
* @file i2c.c
* @date 17/04/2023
* @brief This is the main file for the HAL of the I2C peripheral
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing here the author and version

}


i2c_config_t default_timing_for_speed(i2c_speed_t speed,
Copy link
Collaborator

@JoseCalero JoseCalero Jun 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this function relies on multiple ad-hoc values, should we define those in DEFINEs etc?

.stop_signal_hold_cycles = round_up_divide(500, clock_period_nanos),
};
default:
return (i2c_config_t){0};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a little bit weird, let's discuss this

/*
* The "enabled" state.
typedef enum i2c_result {
/**
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are you assigning values to this if that are already by default?

/** **/
/****************************************************************************/

#ifndef _TEMPLATE_C_SRC
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this needs to be changed

Copy link
Collaborator

@JoseCalero JoseCalero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to speak about how to conceptualise the i2c design (HAL and upper layers). Right now the control config/block is transparent for anyone regardless of the layer he/she can access to (I can modify the config even if I am in the APP layer). Plus, there is no IRQ management control into the current HAL. Let's talk about this (for example, check TWI info in here: https://infocenter.nordicsemi.com/index.jsp?topic=%2Fstruct_sdk%2Fstruct%2Fsdk_nrf5_latest.html)

@JuanSapriza JuanSapriza mentioned this pull request Aug 8, 2023
4 tasks
@JoseCalero JoseCalero marked this pull request as draft August 14, 2023 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants