Skip to content

Bootcamp: SEAN WANG#285

Open
PrecisionPilot wants to merge 3 commits into
UWARG:masterfrom
PrecisionPilot:master
Open

Bootcamp: SEAN WANG#285
PrecisionPilot wants to merge 3 commits into
UWARG:masterfrom
PrecisionPilot:master

Conversation

@PrecisionPilot
Copy link
Copy Markdown

Done yo

Copy link
Copy Markdown
Contributor

@EemanAleem EemanAleem left a comment

Choose a reason for hiding this comment

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

Mostly correct, great job!!!

Comment thread nucleof072rb/Core/Src/main.c Outdated
adc_value = MAX_ADC;

/* USER CODE END 1 */
uint16_t pwm_range = MAX_PWM - MIN_PWM;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would suggest having this just predefined as a global var since you're deriving another constant from two constants.

Comment thread nucleof072rb/Core/Src/main.c Outdated
// Multiply before divide to avoid truncating to 0
uint16_t ccr_value =
MIN_PWM +
(adc_value * pwm_range) / MAX_ADC;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Make sure to protect against integer division in abstracted calculations! Your calculation itself is correct tho, congrats :)

Comment thread nucleof072rb/Core/Src/main.c Outdated
&hspi1,
tx_buffer,
rx_buffer,
3,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Make sure to not have magic numbers and allot a variable to this, or just have it depend on the size of your tx or rx buffers, upto you.

Comment thread nucleof072rb/Core/Src/main.c Outdated
tx_buffer,
rx_buffer,
3,
HAL_MAX_DELAY
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is incorrect as this has a value of 0xFFFFFFFF, which effectively works as a poll until the process is successful. This is not beneficial since we'd like to timeout of the process if it doesn't work for a set period of time, say 100ms. You may assign a var for this too.

rx_buffer,
3,
HAL_MAX_DELAY
);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Use the output of the HAL_SPI_TransmitReceive function to output whether the process was successful and move forward, or report the alternative output you get with a simple print statement.

HAL_GPIO_WritePin(GPIOB, GPIO_PIN_8, GPIO_PIN_SET);

if (status != HAL_OK)
continue;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This if condition effectively achieves nothing lol, you need to either have everything from the HAL_GPIO_WritePin onwards in the if statement itself, otherwise it doesn't execute any other code. A print statement of some kind is usually useful here.

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