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

Add USART1 back in HWinit #135

Merged
merged 1 commit into from
Dec 15, 2024
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions include/hwinit.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ extern "C"
void clock_setup(void);
void usart_setup(void);
void usart2_setup(void);
void usart1_setup(void);
void nvic_setup(void);
void rtc_setup(void);
void tim_setup(void);
Expand Down
21 changes: 21 additions & 0 deletions src/hwinit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ void clock_setup(void)
rcc_periph_clock_enable(RCC_GPIOE);
rcc_periph_clock_enable(RCC_USART3);
rcc_periph_clock_enable(RCC_USART2);//GS450H Inverter Comms
rcc_periph_clock_enable(RCC_USART1);//LIN Comms
rcc_periph_clock_enable(RCC_TIM1); //GS450H oil pump pwm
rcc_periph_clock_enable(RCC_TIM2); //GS450H 500khz usart clock
rcc_periph_clock_enable(RCC_TIM3); //PWM outputs
Expand Down Expand Up @@ -102,6 +103,26 @@ void spi3_setup() //spi3 used for digi pots (fuel gauge etc)
spi_enable(SPI3);
}

/**
* Setup USART1 for LINbus
*/

void usart1_setup(void)
{
/* Setup GPIO pin GPIO_USART1_TX and GPIO_USART1_RX. */
gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_50_MHZ,
GPIO_CNF_OUTPUT_ALTFN_PUSHPULL, GPIO_USART1_TX);
gpio_set_mode(GPIOA, GPIO_MODE_INPUT,
GPIO_CNF_INPUT_FLOAT, GPIO_USART1_RX);
usart_set_baudrate(USART1, 19200);
usart_set_databits(USART1, 8);
usart_set_stopbits(USART1, USART_STOPBITS_1);
usart_set_mode(USART1, USART_MODE_TX_RX);
usart_set_parity(USART1, USART_PARITY_NONE);
usart_set_flow_control(USART1, USART_FLOWCONTROL_NONE);
usart_enable(USART1);
}

/**
* Setup USART2 500000 8N1 for Toyota inverter comms
*/
Expand Down
Loading