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

intergated sht #218

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions Core/Src/mpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,20 @@ static inline int write_reg(uint8_t *data, uint8_t reg, uint8_t length)
HAL_MAX_DELAY);
}

static inline int temp_read_reg(uint8_t *data, uint8_t reg, uint8_t length)
{
return HAL_I2C_Mem_Read(hi2c, SHT30_I2C_ADDRESS, reg,
I2C_MEMADD_SIZE_8BIT, data, length,
HAL_MAX_DELAY);
}

static inline int temp_write_reg(uint8_t *data, uint8_t reg, uint8_t length)
{
return HAL_I2C_Mem_Write(hi2c, SHT30_I2C_ADDRESS, reg,
I2C_MEMADD_SIZE_8BIT, data, length,
HAL_MAX_DELAY);
}

mpu_t *init_mpu(ADC_HandleTypeDef *pedals_adc, ADC_HandleTypeDef *lv_adc,
GPIO_TypeDef *led_gpio, GPIO_TypeDef *watchdog_gpio)
{
Expand All @@ -51,8 +65,8 @@ mpu_t *init_mpu(ADC_HandleTypeDef *pedals_adc, ADC_HandleTypeDef *lv_adc,
/* Initialize the Onboard Temperature Sensor */
mpu->temp_sensor = malloc(sizeof(sht30_t));
assert(mpu->temp_sensor);
mpu->temp_sensor->i2c_handle = hi2c;
assert(!sht30_init(mpu->temp_sensor)); /* This is always connected */
assert(!sht30_init(mpu->temp_sensor, temp_write_reg,
temp_read_reg)); /* This is always connected */

assert(!HAL_ADC_Start_DMA(mpu->pedals_adc, mpu->pedal_dma_buf,
sizeof(mpu->pedal_dma_buf) /
Copy link
Contributor

Choose a reason for hiding this comment

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

this looks good to me. @jr1221 we dont have one of these on mpu right now do we? if not i say we can just merge this one ths embedded base PR looks good. If there is one of these on mpu, lets test before merge

Choose a reason for hiding this comment

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

what kind of testing should I do? I didn't see any test files in caios work, is there a standard for testing in C that NER uses?

Expand Down
Loading