First test version to sample temperature input and blink LEDs

This commit is contained in:
2020-01-26 21:07:54 +01:00
parent 284f2b26c4
commit ad7badba56
21 changed files with 472 additions and 47 deletions

44
stm-firmware/UART/uart.c Normal file
View File

@@ -0,0 +1,44 @@
/*
* uart.c
*
* Created on: Dec 15, 2014
* Author: shino-chan
*/
//USART2
//PA2 => TX
//PA3 => RX
//Alternate Function 7
#include "uart.h"
#include <stm32f4xx.h>
void initUART() {
__DSB();
RCC->AHB1ENR |= RCC_AHB1ENR_GPIOAEN;
RCC->APB1ENR |= RCC_APB1ENR_USART2EN;
__DSB();
GPIOA->MODER |= (1<<5);
GPIOA->AFR[0] |= (7<<8); //Enable Clock
GPIOA->MODER |= (1<<5);
GPIOA->AFR[0] |= (7<<8);
asm("nop");
asm("nop");
asm("nop");
USART2->BRR = 0x1117; //Baudrate 273.4375=>0x1117 9600baud bei 42MHz Periph
USART2->CR1 = USART_CR1_UE | USART_CR1_TE;
}
void sendChar(char c) {
while(!(USART2->SR & USART_SR_TXE));
USART2->DR = c;
}
void sendString(char* s, int count) {
int i = 0;
for (i = 0; i < count; i++,s++)
{
if (!(*s))
break;
sendChar(*s);
}
}

17
stm-firmware/UART/uart.h Normal file
View File

@@ -0,0 +1,17 @@
/*
* uart.h
*
* Created on: Dec 15, 2014
* Author: shino-chan
*/
#ifndef UART_UART_H_
#define UART_UART_H_
void initUART();
void sendChar(char c);
void sendString(char* s, int count);
#ifdef _P20N_
void yuri();
#endif
#endif /* UART_UART_H_ */