Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
90b38e7
fix the bug
GabeMillikan Nov 13, 2025
0d8168e
add test for fix
GabeMillikan Nov 13, 2025
f1d8ae7
squash because git history is fucked 😂✌️(was: ea61956ece6897481ad3a98…
GabeMillikan Oct 16, 2025
44e836a
Automatic CMake Format: Standardized formatting automatically
github-actions[bot] Nov 12, 2025
4ac5089
move Inhouse into new Lib/Peripherals
GabeMillikan Nov 12, 2025
6aeb568
start on circularbuffer implementation
GabeMillikan Nov 12, 2025
9459d4a
Automatic CMake Format: Standardized formatting automatically
github-actions[bot] Nov 12, 2025
4db6702
disallow multiple-init of one usart channel
GabeMillikan Nov 12, 2025
37c1adf
remove usart_receive (we will use interrupt-based rx)
GabeMillikan Nov 12, 2025
80503ca
implement interrupt-based io
GabeMillikan Nov 12, 2025
d3bd61f
revert settings.json
GabeMillikan Nov 12, 2025
67573e4
use a real config
GabeMillikan Nov 12, 2025
8e4b840
make rx callback configurable
GabeMillikan Nov 13, 2025
f60fc84
move usage example into G4HELLO
GabeMillikan Nov 13, 2025
be68114
Automatic CMake Format: Standardized formatting automatically
github-actions[bot] Nov 13, 2025
f5d35c4
move byte into its own var for easier debugging
GabeMillikan Nov 13, 2025
379667a
undo changes to ecu
GabeMillikan Nov 13, 2025
fa43b95
stop hardcoding everything except for clock
GabeMillikan Nov 13, 2025
df64b38
make rx callback optional
GabeMillikan Nov 14, 2025
e22233a
support for lpuart
GabeMillikan Nov 14, 2025
2ce9d86
holy shit it works??
GabeMillikan Nov 14, 2025
c56df10
Merge branch 'main' into usart-initial-impl
dchansen06 Dec 4, 2025
14200d1
Merge branch 'main' into usart-initial-impl
dchansen06 Dec 5, 2025
140a370
Fix ordering of USART release, hardware then handle
dchansen06 Dec 10, 2025
887add5
Merge branch 'main' into usart-initial-impl
dchansen06 Dec 10, 2025
b3cd3a8
Merge branch 'main' into usart-initial-impl
dchansen06 Dec 16, 2025
ffa9c46
Remove unused LPUART1 initialization function from G4HELLO `main.c`
dchansen06 Dec 17, 2025
18f85d3
Merge branch 'main' into usart-initial-impl
dchansen06 Dec 23, 2025
299736f
Merge branch 'main' into usart-initial-impl
dchansen06 Dec 31, 2025
e46816a
Merge branch 'main' into usart-initial-impl
dchansen06 Jan 1, 2026
029d901
Automatic Clang-Format: Standardized formatting automatically
github-actions[bot] Jan 1, 2026
51b004c
Merge branch 'main' into usart-initial-impl
dchansen06 Jan 1, 2026
8248a02
Merge branch 'main' into usart-initial-impl
dchansen06 Jan 6, 2026
1eec086
Merge branch 'main' into usart-initial-impl
dchansen06 Jan 9, 2026
250d83b
Merge branch 'main' into usart-initial-impl
dchansen06 Jan 9, 2026
63f508e
Automatic Clang-Format: Standardized formatting automatically
github-actions[bot] Jan 9, 2026
4511154
Merge branch 'main' into usart-initial-impl
dchansen06 Jan 16, 2026
daa013a
Merge branch 'main' into usart-initial-impl
dchansen06 Jan 20, 2026
65120c9
Automatic Clang-Format: Standardized formatting automatically
github-actions[bot] Jan 20, 2026
3821d3c
Merge branch 'main' into usart-initial-impl
dchansen06 Jan 23, 2026
1454cc7
Merge branch 'main' into usart-initial-impl
dchansen06 Jan 28, 2026
90b560e
Merge branch 'main' into usart-initial-impl
dchansen06 Feb 1, 2026
7ebc7d9
Merge branch 'main' into usart-initial-impl
dchansen06 Feb 1, 2026
2169d86
Merge branch 'main' into usart-initial-impl
dchansen06 Feb 2, 2026
47b6d67
Merge branch 'main' into usart-initial-impl
dchansen06 Feb 2, 2026
b5785e3
Merge branch 'main' into usart-initial-impl
dchansen06 Feb 3, 2026
c94a677
Merge branch 'main' into usart-initial-impl
dchansen06 Feb 3, 2026
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
6 changes: 5 additions & 1 deletion BLINKY/G4HELLO/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ target_sources(
Core/Src/syscalls.c
)

target_link_libraries(${GR_PROJECT_NAME}_USER_CODE INTERFACE)
target_link_libraries(
${GR_PROJECT_NAME}_USER_CODE
INTERFACE
PERIPHERAL_USART_LIB
)

target_include_directories(${GR_PROJECT_NAME}_USER_CODE INTERFACE Core/Inc)
115 changes: 42 additions & 73 deletions BLINKY/G4HELLO/Core/Src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "Logomatic.h"
#include "Peripherals/USART/usart.h"
/* USER CODE END Includes */

/* Private typedef -----------------------------------------------------------*/
Expand All @@ -48,13 +49,20 @@
/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_LPUART1_UART_Init(void);
/* USER CODE BEGIN PFP */

/* USER CODE END PFP */

/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
void received_byte_callback(uint8_t byte)
{
LOGOMATIC("Received byte: 0x%02X ('%c')\n", byte, (byte >= 32 && byte <= 126) ? byte : '.');

#ifndef LOGOMATIC_ENABLED
byte = byte; // suppress unused variable warning
#endif
}

/* Enable ITM for SWO output */
static void ITM_Enable(void)
Expand Down Expand Up @@ -102,9 +110,40 @@ int main(void)

/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_LPUART1_UART_Init();
// MX_LPUART1_UART_Init();
/* USER CODE BEGIN 2 */

USARTConfig config = {
.instance = LPUART1,
.tx_queue_length = 16,
.on_rx_byte = NULL,
.gpio_port = GPIOA,
.ll_gpio =
&(LL_GPIO_InitTypeDef){
.Pin = LL_GPIO_PIN_2 | LL_GPIO_PIN_3,
.Mode = LL_GPIO_MODE_ALTERNATE,
.Alternate = LL_GPIO_AF_12,
.OutputType = LL_GPIO_OUTPUT_PUSHPULL,
.Pull = LL_GPIO_PULL_NO,
.Speed = LL_GPIO_SPEED_FREQ_LOW,
},
.ll_lpuart =
&(LL_LPUART_InitTypeDef){
.PrescalerValue = LL_LPUART_PRESCALER_DIV1,
.BaudRate = 115200,
.DataWidth = LL_LPUART_DATAWIDTH_8B,
.StopBits = LL_LPUART_STOPBITS_1,
.Parity = LL_LPUART_PARITY_NONE,
.TransferDirection = LL_LPUART_DIRECTION_TX_RX,
},
};
USARTHandle *handle = usart_init_peripheral(&config);
for (uint8_t i = 0; i < 30; i++) {
LOGOMATIC("sending message over usart... %d\n", i);
usart_send(handle, "Hello World!\r\n", 14);
LL_mDelay(1000);
}
LOGOMATIC("USART test messages sent, releasing...\n");
usart_release(&handle);
/* USER CODE END 2 */

/* Infinite loop */
Expand Down Expand Up @@ -161,76 +200,6 @@ void SystemClock_Config(void)
}
}

/**
* @brief LPUART1 Initialization Function
* @param None
* @retval None
*/
static void MX_LPUART1_UART_Init(void)
{

/* USER CODE BEGIN LPUART1_Init 0 */

/* USER CODE END LPUART1_Init 0 */

LL_LPUART_InitTypeDef LPUART_InitStruct = {0};

LL_GPIO_InitTypeDef GPIO_InitStruct = {0};

LL_RCC_SetLPUARTClockSource(LL_RCC_LPUART1_CLKSOURCE_PCLK1);

/* Peripheral clock enable */
LL_APB1_GRP2_EnableClock(LL_APB1_GRP2_PERIPH_LPUART1);

LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOA);
/**LPUART1 GPIO Configuration
PA2 ------> LPUART1_TX (ST-LINK VCP)
PA3 ------> LPUART1_RX (ST-LINK VCP)
*/
GPIO_InitStruct.Pin = LL_GPIO_PIN_2;
GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
GPIO_InitStruct.Alternate = LL_GPIO_AF_12;
LL_GPIO_Init(GPIOA, &GPIO_InitStruct);

GPIO_InitStruct.Pin = LL_GPIO_PIN_3;
GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
GPIO_InitStruct.Alternate = LL_GPIO_AF_12;
LL_GPIO_Init(GPIOA, &GPIO_InitStruct);

/* USER CODE BEGIN LPUART1_Init 1 */

/* USER CODE END LPUART1_Init 1 */
LPUART_InitStruct.PrescalerValue = LL_LPUART_PRESCALER_DIV1;
LPUART_InitStruct.BaudRate = 115200;
LPUART_InitStruct.DataWidth = LL_LPUART_DATAWIDTH_8B;
LPUART_InitStruct.StopBits = LL_LPUART_STOPBITS_1;
LPUART_InitStruct.Parity = LL_LPUART_PARITY_NONE;
LPUART_InitStruct.TransferDirection = LL_LPUART_DIRECTION_TX_RX;
LL_LPUART_Init(LPUART1, &LPUART_InitStruct);
LL_LPUART_SetTXFIFOThreshold(LPUART1, LL_LPUART_FIFOTHRESHOLD_1_8);
LL_LPUART_SetRXFIFOThreshold(LPUART1, LL_LPUART_FIFOTHRESHOLD_1_8);
LL_LPUART_DisableFIFO(LPUART1);
LL_LPUART_SetWakeUpMethod(LPUART1, LL_LPUART_WAKEUP_IDLELINE);

/* USER CODE BEGIN WKUPType LPUART1 */

/* USER CODE END WKUPType LPUART1 */

LL_LPUART_Enable(LPUART1);

/* Polling LPUART1 initialisation */
while ((!(LL_LPUART_IsActiveFlag_TEACK(LPUART1))) || (!(LL_LPUART_IsActiveFlag_REACK(LPUART1)))) {}
/* USER CODE BEGIN LPUART1_Init 2 */

/* USER CODE END LPUART1_Init 2 */
}

/**
* @brief GPIO Initialization Function
* @param None
Expand Down
2 changes: 2 additions & 0 deletions Lib/Peripherals/USART/common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ add_library(PERIPHERAL_USART_LIB INTERFACE)

target_sources(PERIPHERAL_USART_LIB INTERFACE ${CMAKE_CURRENT_LIST_DIR}/usart.c)

target_link_libraries(PERIPHERAL_USART_LIB INTERFACE CircularBuffer_Lib)

# Make headers accessible as #include "Peripherals/USART/usart.h"
target_include_directories(
PERIPHERAL_USART_LIB
Expand Down
Loading