IonizationChamber/software/Firmware/Src/Logger.c

81 wiersze
1.2 KiB
C
Czysty Zwykły widok Historia

/*
* DataLogger.c
*
* Created on: 16.06.2019
* Author: robert
*/
2019-07-03 17:24:45 +00:00
#include "Logger.h"
2019-07-20 16:12:17 +00:00
//#include <stdio.h>
2019-07-02 17:07:41 +00:00
#include "stm8s_uart1.h"
2019-07-08 16:48:13 +00:00
#include "PinoutConfiguration.h"
2019-07-02 17:07:41 +00:00
2019-07-20 09:14:09 +00:00
static void GPIO_setup(void);
static void UART1_setup(void);
2019-07-06 14:46:54 +00:00
#ifdef USE_FULL_ASSERT
void assert_failed(uint8_t* file, uint32_t line)
{
(void)file;
(void)line;
2019-07-20 16:12:17 +00:00
//printf("[error] asset failed %s %d\r\n", file, line);
2019-07-06 14:46:54 +00:00
while (TRUE)
{
// empty
}
}
#endif
2019-07-20 09:14:09 +00:00
void Logger_Init()
{
GPIO_setup();
UART1_setup();
}
void Logger_Tick()
{
2019-07-27 14:02:34 +00:00
// printf ("ok ");
2019-07-20 09:14:09 +00:00
}
void putchar(char c)
{
/* Write a character to the UART1 */
UART1_SendData8(c);
/* Loop until the end of transmission */
while (UART1_GetFlagStatus(UART1_FLAG_TXE) == RESET);
}
2019-07-02 17:07:41 +00:00
void GPIO_setup(void)
{
2019-07-08 16:48:13 +00:00
GPIO_DeInit(PORT_UART);
2019-07-02 17:07:41 +00:00
2019-07-08 16:48:13 +00:00
GPIO_Init(PORT_UART, PIN_TX, GPIO_MODE_OUT_PP_HIGH_FAST);
GPIO_Init(PORT_UART, PIN_RX, GPIO_MODE_IN_PU_NO_IT);
2019-07-02 17:07:41 +00:00
}
void UART1_setup(void)
{
2019-07-03 17:24:45 +00:00
// TODO: magic numbers
UART1_DeInit();
2019-07-02 17:07:41 +00:00
2019-07-03 17:24:45 +00:00
UART1_Init(9600,
2019-07-27 14:02:34 +00:00
UART1_WORDLENGTH_8D,
UART1_STOPBITS_1,
UART1_PARITY_NO,
UART1_SYNCMODE_CLOCK_DISABLE,
UART1_MODE_TXRX_ENABLE);
2019-07-03 17:24:45 +00:00
UART1_Cmd(ENABLE);
2019-07-02 17:07:41 +00:00
}