2020-02-15 22:09:55 +01:00
|
|
|
/* Reflow Oven Controller
|
|
|
|
*
|
|
|
|
* Copyright (C) 2020 Mario Hüttel <mario.huettel@gmx.net>
|
|
|
|
*
|
|
|
|
* This file is part of the Reflow Oven Controller Project.
|
|
|
|
*
|
|
|
|
* The reflow oven controller is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* GDSII-Converter is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with the reflow oven controller project.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2020-02-09 19:13:37 +01:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <stddef.h>
|
2020-01-26 15:27:06 +01:00
|
|
|
|
|
|
|
#ifndef UART_UART_H_
|
|
|
|
#define UART_UART_H_
|
|
|
|
|
2020-02-10 22:38:24 +01:00
|
|
|
#define UART_RECEIVE_DMA_STREAM DMA2_Stream5
|
2020-02-09 19:13:37 +01:00
|
|
|
|
2020-02-11 22:49:47 +01:00
|
|
|
#define UART_SEND_DMA_STREAM DMA2_Stream7
|
2020-02-09 19:13:37 +01:00
|
|
|
|
|
|
|
#define UART_PERIPH USART1
|
|
|
|
#define UART_RCC_MASK RCC_APB2ENR_USART1EN
|
|
|
|
|
2020-02-10 22:38:24 +01:00
|
|
|
#ifdef DEBUGBUILD
|
|
|
|
|
|
|
|
#define UART_PORT GPIOA
|
|
|
|
#define UART_PORT_RCC_MASK RCC_AHB1ENR_GPIOAEN
|
2020-02-09 19:13:37 +01:00
|
|
|
#define UART_RX_PIN 10
|
|
|
|
#define UART_TX_PIN 9
|
|
|
|
#define UART_RX_PIN_ALTFUNC 7
|
|
|
|
#define UART_TX_PIN_ALTFUNC 7
|
2020-02-10 22:38:24 +01:00
|
|
|
#else
|
|
|
|
|
|
|
|
#endif
|
2020-02-09 19:13:37 +01:00
|
|
|
|
|
|
|
/* UART_DIV is 45.5625 => 115200 @ 84 MHz */
|
|
|
|
#define UART_DIV_FRACTION 9U /* Equals 9/16 = 0.5625 */
|
|
|
|
#define UART_DIV_MANTISSA 45U /* Equals 45 */
|
|
|
|
|
|
|
|
#define UART_BRR_REG_VALUE ((UART_DIV_MANTISSA<<4) | UART_DIV_FRACTION);
|
|
|
|
|
2020-01-26 15:27:06 +01:00
|
|
|
void initUART();
|
|
|
|
void sendChar(char c);
|
|
|
|
void sendString(char* s, int count);
|
2020-02-09 19:13:37 +01:00
|
|
|
|
|
|
|
|
|
|
|
void uart_init_with_dma();
|
|
|
|
|
|
|
|
void uart_disable();
|
|
|
|
|
|
|
|
void uart_send_char(char c);
|
|
|
|
|
|
|
|
void uart_send_array(const char *data, uint32_t len);
|
|
|
|
|
2020-02-11 22:49:47 +01:00
|
|
|
void uart_send_string(const char *string);
|
2020-02-09 19:13:37 +01:00
|
|
|
|
2020-02-11 22:49:47 +01:00
|
|
|
void uart_send_array_with_dma(const char *data, uint32_t len);
|
2020-02-09 19:13:37 +01:00
|
|
|
|
2020-02-11 22:49:47 +01:00
|
|
|
void uart_send_string_with_dma(const char *string);
|
2020-02-09 19:13:37 +01:00
|
|
|
|
|
|
|
int uart_receive_data_with_dma(const char **data, size_t *len);
|
|
|
|
|
|
|
|
|
2020-01-26 15:27:06 +01:00
|
|
|
#endif /* UART_UART_H_ */
|