Merge branch 'dev' into ui
This commit is contained in:
34
stm-firmware/include/reflow-controller/onewire-if.h
Normal file
34
stm-firmware/include/reflow-controller/onewire-if.h
Normal file
@@ -0,0 +1,34 @@
|
||||
/* 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.
|
||||
*
|
||||
* The Reflow Oven Control Firmware 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/>.
|
||||
*/
|
||||
|
||||
#ifndef __ONEWIRE_IF_H__
|
||||
#define __ONEWIRE_IF_H__
|
||||
|
||||
#include <stm-periph/uart.h>
|
||||
|
||||
int onewire_if_init_uart(struct stm_uart *uart, uint32_t brr_val, USART_TypeDef *onewire_uart, volatile uint32_t *rcc_reg, uint8_t rcc_bit_num);
|
||||
|
||||
void onewire_if_disable(struct stm_uart *uart);
|
||||
|
||||
int onewire_if_send_byte(struct stm_uart *uart);
|
||||
|
||||
int onewire_if_receive_byte(struct stm_uart *uart);
|
||||
|
||||
#endif /* __ONEWIRE_IF_H__ */
|
@@ -0,0 +1,47 @@
|
||||
/* 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.
|
||||
*
|
||||
* The Reflow Oven Control Firmware 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/>.
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifndef __ONEWIRE_TEMP_SENSORS_H__
|
||||
#define __ONEWIRE_TEMP_SENSORS_H__
|
||||
|
||||
#define ONEWIRE_TEMP_PORT GPIOB
|
||||
#define ONEWIRE_TEMP_RCC_MASK RCC_AHB1ENR_GPIOBEN
|
||||
#define ONEWIRE_TEMP_TX_PIN 10U
|
||||
#define ONEWIRE_TEMP_RX_PIN 11U
|
||||
#define ONEWIRE_TEMP_AF_NUM 7U
|
||||
|
||||
#define ONEWIRE_UART_DEV USART3
|
||||
|
||||
void onewire_temp_sensors_setup_hw();
|
||||
|
||||
/**
|
||||
* @brief onewire_temp_sensors_discover
|
||||
* @param id_list
|
||||
* @param list_len
|
||||
* @return Negative: error, >= 0: amount of discovered sensors
|
||||
*/
|
||||
int onewire_temp_sensors_discover(uint32_t *id_list, size_t list_len);
|
||||
|
||||
float onewire_temp_sensor_read_temp(uint32_t id);
|
||||
|
||||
#endif /* __ONEWIRE_TEMP_SENSORS_H__ */
|
33
stm-firmware/include/reflow-controller/shell-uart-config.h
Normal file
33
stm-firmware/include/reflow-controller/shell-uart-config.h
Normal file
@@ -0,0 +1,33 @@
|
||||
#ifndef __SHELL_UART_CONFIG_H__
|
||||
#define __SHELL_UART_CONFIG_H__
|
||||
|
||||
#define SHELL_UART_RECEIVE_DMA_STREAM DMA2_Stream5
|
||||
|
||||
#define SHELL_UART_SEND_DMA_STREAM DMA2_Stream7
|
||||
|
||||
#define SHELL_UART_PERIPH USART1
|
||||
#define SHELL_UART_RCC_REG RCC->APB2ENR
|
||||
#define SHELL_UART_RCC_MASK RCC_APB2ENR_USART1EN
|
||||
|
||||
#define SHELL_UART_RX_DMA_TRIGGER 4U
|
||||
#define SHELL_UART_TX_DMA_TRIGGER 4U
|
||||
|
||||
#ifdef DEBUGBUILD
|
||||
|
||||
#define SHELL_UART_PORT GPIOA
|
||||
#define SHELL_UART_PORT_RCC_MASK RCC_AHB1ENR_GPIOAEN
|
||||
#define SHELL_UART_RX_PIN 10
|
||||
#define SHELL_UART_TX_PIN 9
|
||||
#define SHELL_UART_RX_PIN_ALTFUNC 7
|
||||
#define SHELL_UART_TX_PIN_ALTFUNC 7
|
||||
#else
|
||||
|
||||
#endif
|
||||
|
||||
/* UART_DIV is 45.5625 => 115200 @ 84 MHz */
|
||||
#define SHELL_UART_DIV_FRACTION 9U /* Equals 9/16 = 0.5625 */
|
||||
#define SHELL_UART_DIV_MANTISSA 45U /* Equals 45 */
|
||||
|
||||
#define SHELL_UART_BRR_REG_VALUE ((SHELL_UART_DIV_MANTISSA<<4) | SHELL_UART_DIV_FRACTION);
|
||||
|
||||
#endif /* __SHELL_UART_CONFIG_H__ */
|
@@ -24,7 +24,7 @@
|
||||
#include <stddef.h>
|
||||
#include <shellmatta.h>
|
||||
|
||||
shellmatta_handle_t shell_init(void);
|
||||
shellmatta_handle_t shell_init(shellmatta_write_t write_func);
|
||||
|
||||
void shell_handle_input(shellmatta_handle_t shell, const char *data, size_t len);
|
||||
|
||||
|
@@ -29,6 +29,7 @@
|
||||
#define PINMASK(pin) ((0x3) << (pin * 2))
|
||||
#define SETAF(PORT,PIN,AF) PORT->AFR[(PIN < 8 ? 0 : 1)] |= AF << ((PIN < 8 ? PIN : (PIN - 8)) * 4)
|
||||
#define ANALOG(pin) (0x03 << (pin * 2))
|
||||
#define OTYP_OPENDRAIN(pin) (0x1U << (pin))
|
||||
|
||||
#define BITMASK_TO_BITNO(x) (x&0x1?0:x&0x2?1:x&0x4?2:x&0x8?3: \
|
||||
x&0x10?4:x&0x20?5:x&0x40?6:x&0x80?7: \
|
||||
|
@@ -18,57 +18,55 @@
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stm32/stm32f4xx.h>
|
||||
#include <stm-periph/dma-ring-buffer.h>
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#ifndef UART_UART_H_
|
||||
#define UART_UART_H_
|
||||
|
||||
#define UART_RECEIVE_DMA_STREAM DMA2_Stream5
|
||||
struct stm_uart {
|
||||
USART_TypeDef *uart_dev;
|
||||
uint32_t brr_val;
|
||||
uint8_t base_dma_num;
|
||||
DMA_Stream_TypeDef *dma_tx_stream;
|
||||
uint8_t dma_tx_trigger_channel;
|
||||
DMA_Stream_TypeDef *dma_rx_stream;
|
||||
uint8_t dma_rx_trigger_channel;
|
||||
char *dma_rx_buff;
|
||||
char *dma_tx_buff;
|
||||
size_t rx_buff_count;
|
||||
size_t tx_buff_count;
|
||||
volatile uint32_t *rcc_reg;
|
||||
uint8_t rcc_bit_no;
|
||||
struct dma_ring_buffer_to_mem rx_ring_buff;
|
||||
struct dma_ring_buffer_to_periph tx_ring_buff;
|
||||
uint8_t tx : 1;
|
||||
uint8_t rx : 1;
|
||||
};
|
||||
|
||||
#define UART_SEND_DMA_STREAM DMA2_Stream7
|
||||
int uart_init(struct stm_uart *uart);
|
||||
|
||||
#define UART_PERIPH USART1
|
||||
#define UART_RCC_MASK RCC_APB2ENR_USART1EN
|
||||
void uart_disable(struct stm_uart *uart);
|
||||
|
||||
#ifdef DEBUGBUILD
|
||||
void uart_send_char(struct stm_uart *uart, char c);
|
||||
|
||||
#define UART_PORT GPIOA
|
||||
#define UART_PORT_RCC_MASK RCC_AHB1ENR_GPIOAEN
|
||||
#define UART_RX_PIN 10
|
||||
#define UART_TX_PIN 9
|
||||
#define UART_RX_PIN_ALTFUNC 7
|
||||
#define UART_TX_PIN_ALTFUNC 7
|
||||
#else
|
||||
void uart_send_array(struct stm_uart *uart, const char *data, uint32_t len);
|
||||
|
||||
#endif
|
||||
void uart_send_string(struct stm_uart *uart, const char *string);
|
||||
|
||||
/* 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 */
|
||||
void uart_send_array_with_dma(struct stm_uart *uart, const char *data, uint32_t len);
|
||||
|
||||
#define UART_BRR_REG_VALUE ((UART_DIV_MANTISSA<<4) | UART_DIV_FRACTION);
|
||||
void uart_send_string_with_dma(struct stm_uart *uart, const char *string);
|
||||
|
||||
void initUART();
|
||||
void sendChar(char c);
|
||||
void sendString(char* s, int count);
|
||||
int uart_receive_data_with_dma(struct stm_uart *uart, const char **data, size_t *len);
|
||||
|
||||
char uart_get_char(struct stm_uart *uart);
|
||||
|
||||
void uart_init_with_dma();
|
||||
int uart_check_rx_avail(struct stm_uart *uart);
|
||||
|
||||
void uart_disable();
|
||||
|
||||
void uart_send_char(char c);
|
||||
|
||||
void uart_send_array(const char *data, uint32_t len);
|
||||
|
||||
void uart_send_string(const char *string);
|
||||
|
||||
void uart_send_array_with_dma(const char *data, uint32_t len);
|
||||
|
||||
void uart_send_string_with_dma(const char *string);
|
||||
|
||||
int uart_receive_data_with_dma(const char **data, size_t *len);
|
||||
void uart_tx_dma_complete_int_callback(struct stm_uart *uart);
|
||||
|
||||
|
||||
#endif /* UART_UART_H_ */
|
||||
|
Reference in New Issue
Block a user