SPI Code
SPI Code
h"
//Defines
#define GPIOAEN (1U << 0)
#define USART1EN (1 << 4)
#define SYS_FREQ 16000000UL
#define APB1_CLK SYS_FREQ
#define UART_BAUDRATE 115200
#define CR1_TE (1U << 3)
#define CR1_UE (1U << 13)
#define SR_TXE (1U << 7)
//Function Prototypes
static void uart_set_baudrate(USART_TypeDef *USARTx, uint32_t PeriphClk, uint32_t
BaudRate);
static uint16_t compute_uart_bd(uint32_t PeriphClk, uint32_t Baudrate);
void usart1_tx_init();
void uart1_write(int ch);
int main()
{
usart1_tx_init();
while (1)
{
uart1_write('L');
}
return 0;
}
void usart1_tx_init()
{
//Configure USART GPIO PIN
//Enable clock to GPIOA
RCC->AHB1ENR |= GPIOAEN;
//Set PA9 to alternate function mode
GPIOA->MODER &= ~(1U << 18);
//Delay to prevent issues when plugging board in, then opening COM (was
sending incorrect data).
for(int index = 0;index < 1000000;index++);
//Looks like the issue is still there.
}